diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5aca2991fb69e..b0d64a3ba3ff1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -143,10 +143,15 @@ /docs/standard/asynchronous-programming-patterns/ @BillWagner # Attributes /docs/standard/attributes/ @tdykstra +# Character encoding +/docs/standard/base-types/character-encoding/ @tdykstra +/docs/standard/base-types/character-encoding-introduction/ @tdykstra # Base types /docs/standard/base-types/ @adegeo # Collections /docs/standard/collections/ @IEvangelist +# System.CommandLine +/docs/standard/commandline/ @tdykstra # Data /docs/standard/data/ @gewarren # Data - SQLite diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index 4a16ecf8e87d9..09c26589e269b 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -40,7 +40,7 @@ jobs: echo "Downloading dotnet-install.ps1" Invoke-WebRequest https://raw.githubusercontent.com/dotnet/install-scripts/master/src/dotnet-install.ps1 -OutFile dotnet-install.ps1 echo "Installing dotnet version ${{ env.DOTNET_INSTALLER_CHANNEL }}" - .\dotnet-install.ps1 -InstallDir "c:\program files\dotnet" -Channel "${{ env.DOTNET_INSTALLER_CHANNEL }}" + .\dotnet-install.ps1 -InstallDir "c:\program files\dotnet" -Channel "${{ env.DOTNET_INSTALLER_CHANNEL }}" -Quality preview # Print dotnet info - name: Display .NET info diff --git a/.github/workflows/dependencies/dotnet-whatsnew.2.1.4.nupkg b/.github/workflows/dependencies/dotnet-whatsnew.2.1.4.nupkg deleted file mode 100644 index effa69c8fea93..0000000000000 Binary files a/.github/workflows/dependencies/dotnet-whatsnew.2.1.4.nupkg and /dev/null differ diff --git a/.github/workflows/dependencies/dotnet-whatsnew.2.1.5.nupkg b/.github/workflows/dependencies/dotnet-whatsnew.2.1.5.nupkg new file mode 100644 index 0000000000000..7421136e4d1ad Binary files /dev/null and b/.github/workflows/dependencies/dotnet-whatsnew.2.1.5.nupkg differ diff --git a/.openpublishing.publish.config.json b/.openpublishing.publish.config.json index a34c5f41c11f8..771620001eee7 100644 --- a/.openpublishing.publish.config.json +++ b/.openpublishing.publish.config.json @@ -55,7 +55,7 @@ { "path_to_root": "_csharpstandard", "url": "https://github.com/dotnet/csharpstandard", - "branch": "draft-v6", + "branch": "draft-v7", "include_in_build": true, "branch_mapping": {} }, @@ -118,6 +118,7 @@ ".openpublishing.redirection.fsharp.json", ".openpublishing.redirection.fundamentals.json", ".openpublishing.redirection.machine-learning.json", + ".openpublishing.redirection.orleans.json", ".openpublishing.redirection.standard.json", ".openpublishing.redirection.visual-basic.json" ], diff --git a/.openpublishing.redirection.csharp.json b/.openpublishing.redirection.csharp.json index 3cc9eaa18690b..58cb4c23ff960 100644 --- a/.openpublishing.redirection.csharp.json +++ b/.openpublishing.redirection.csharp.json @@ -1,5 +1,17 @@ { "redirections": [ + { + "source_path_from_root": "/_csharplang/proposals/csharp-7.0/binary-literals.md", + "redirect_url": "/dotnet/csharp/language-reference/language-specification/lexical-structure#6453-integer-literals" + }, + { + "source_path_from_root": "/_csharplang/proposals/csharp-7.0/digit-separators.md", + "redirect_url": "/dotnet/csharp/language-reference/language-specification/lexical-structure#6453-integer-literals" + }, + { + "source_path_from_root": "/_csharplang/proposals/csharp-7.3/leading-digit-separator.md", + "redirect_url": "/dotnet/csharp/language-reference/language-specification/lexical-structure#6453-integer-literals" + }, { "source_path_from_root": "/docs/csharp/basic-types.md", "redirect_url": "/dotnet/csharp/fundamentals/types" @@ -151,6 +163,10 @@ "source_path_from_root": "/docs/csharp/lambda-expressions.md", "redirect_url": "/dotnet/csharp/language-reference/operators/lambda-expressions" }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs8892.md", + "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/warning-waves#cs8892" + }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-options/addmodule-compiler-option.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-options/inputs" @@ -851,6 +867,10 @@ "source_path_from_root": "/docs/csharp/language-reference/operators/right-shift-operator.md", "redirect_url": "/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#right-shift-operator-" }, + { + "source_path_from_root": "/docs/csharp/language-reference/operators/null-parameter-check.md", + "redirect_url": "/dotnet/csharp/language-reference/operators" + }, { "source_path_from_root": "/docs/csharp/language-reference/operators/subtraction-assignment-operator.md", "redirect_url": "/dotnet/csharp/language-reference/operators/arithmetic-operators#compound-assignment" diff --git a/.openpublishing.redirection.json b/.openpublishing.redirection.json index d83e89ad3a1b5..ac33ac33de873 100644 --- a/.openpublishing.redirection.json +++ b/.openpublishing.redirection.json @@ -79,10 +79,6 @@ { "source_path_from_root": "/docs/tutorials/index.md", "redirect_url": "/dotnet/samples-and-tutorials/" - }, - { - "source_path_from_root": "/docs/orleans/whats-new/whats-new-in-orleans.md", - "redirect_url": "https://github.com/dotnet/orleans/releases" } ] } diff --git a/.openpublishing.redirection.orleans.json b/.openpublishing.redirection.orleans.json new file mode 100644 index 0000000000000..f57b61f6ac10a --- /dev/null +++ b/.openpublishing.redirection.orleans.json @@ -0,0 +1,12 @@ +{ + "redirections": [ + { + "source_path_from_root": "/docs/orleans/whats-new/whats-new-in-orleans.md", + "redirect_url": "https://github.com/dotnet/orleans/releases" + }, + { + "source_path_from_root": "/docs/orleans/deployment/azure-web-apps-with-azure-cloud-services.md", + "redirect_url": "/dotnet/orleans/deployment/deploy-to-azure-app-service" + } + ] +} \ No newline at end of file diff --git a/.repoman.yml b/.repoman.yml index d5152be3337f4..78eaf0dc20647 100644 --- a/.repoman.yml +++ b/.repoman.yml @@ -67,6 +67,13 @@ issues: # New issue opened, add Not Triaged - labels-add: [":watch: Not Triaged"] + # Dependabot opened issue, label it + - check: + - type: query + value: "Issue.user.login == 'dependabot'" + pass: + - labels-add: ["dependencies"] + # If breaking change issue metadata, add labels - check: - type: metadata-comment diff --git a/docfx.json b/docfx.json index b2823523f3b30..1adceba66c8e5 100644 --- a/docfx.json +++ b/docfx.json @@ -39,10 +39,13 @@ "inactive/**", "rejected/**", "csharp-6.0/enum-base-type.md", + "csharp-7.0/binary-literals.md", + "csharp-7.0/digit-separators.md", "csharp-7.0/expression-bodied-everything.md", "csharp-7.0/ref-locals-returns.md", "csharp-7.0/tuples.md", "csharp-7.0/value-task.md", + "csharp-7.2/leading-separator.md", "csharp-7.2/readonly-struct.md", "csharp-7.2/ref-extension-methods.md", "csharp-7.2/ref-struct-and-span.md", @@ -359,7 +362,6 @@ "docs/orleans/**/*.*": "dapine", "docs/core/**/**.md": "dotnetcontent", "docs/core/compatibility/**/**.md": "gewarren", - "docs/core/compatibility/aspnet-core/**/**.md": "kirklarkin", "docs/core/deploying/**/**.md": "adegeo", "docs/core/diagnostics/**/**.md": "tommcdon", "docs/core/extensions/**/**.md": "dapine", diff --git a/docs/architecture/blazor-for-web-forms-developers/components.md b/docs/architecture/blazor-for-web-forms-developers/components.md index 392507d7e99fb..b286a9ddb7361 100644 --- a/docs/architecture/blazor-for-web-forms-developers/components.md +++ b/docs/architecture/blazor-for-web-forms-developers/components.md @@ -557,7 +557,7 @@ To capture a component reference in Blazor, use the `@ref` directive attribute. @code { - MyLoginDialog loginDialog; + MyLoginDialog loginDialog = default!; void OnSomething() { diff --git a/docs/architecture/blazor-for-web-forms-developers/data.md b/docs/architecture/blazor-for-web-forms-developers/data.md index f7a98fb5c6a21..68b76c02057db 100644 --- a/docs/architecture/blazor-for-web-forms-developers/data.md +++ b/docs/architecture/blazor-for-web-forms-developers/data.md @@ -130,7 +130,7 @@ Whenever you need to access data from GitHub, create a client with a name of `gi } ``` -This method returns the string describing the collection of issues in the *dotnet/docs* GitHub repository. It returns content in JSON format and is deserialized into appropriate GitHub issue objects. There are many ways that you can configure the `HttpClientFactory` to deliver preconfigured `HttpClient` objects. Try configuring multiple `HttpClient` instances with different names and endpoints for the various web services you work with. This approach will make your interactions with those services easier to work with on each page. For more details, read [the documentation for the IHttpClientFactory](/aspnet/core/fundamentals/http-requests). +This method returns the string describing the collection of issues in the *dotnet/docs* GitHub repository. It returns content in JSON format and is deserialized into appropriate GitHub issue objects. There are many ways that you can configure the `HttpClientFactory` to deliver preconfigured `HttpClient` objects. Try configuring multiple `HttpClient` instances with different names and endpoints for the various web services you work with. This approach will make your interactions with those services easier to work with on each page. For more information, see [Make HTTP requests using IHttpClientFactory](/aspnet/core/fundamentals/http-requests). >[!div class="step-by-step"] >[Previous](forms-validation.md) diff --git a/docs/architecture/cloud-native/application-resiliency-patterns.md b/docs/architecture/cloud-native/application-resiliency-patterns.md index 1279188ee08dc..9d7f79952eeee 100644 --- a/docs/architecture/cloud-native/application-resiliency-patterns.md +++ b/docs/architecture/cloud-native/application-resiliency-patterns.md @@ -11,7 +11,7 @@ ms.date: 04/06/2022 The first line of defense is application resiliency. -While you could invest considerable time writing your own resiliency framework, such products already exist. [Polly](https://dotnetfoundation.org/projects/polly) is a comprehensive .NET resilience and transient-fault-handling library that allows developers to express resiliency policies in a fluent and thread-safe manner. Polly targets applications built with either the .NET Framework or .NET 6. The following table describes the resiliency features, called `policies`, available in the Polly Library. They can be applied individually or grouped together. +While you could invest considerable time writing your own resiliency framework, such products already exist. [Polly](https://dotnetfoundation.org/projects/polly) is a comprehensive .NET resilience and transient-fault-handling library that allows developers to express resiliency policies in a fluent and thread-safe manner. Polly targets applications built with either .NET Framework or .NET 6. The following table describes the resiliency features, called `policies`, available in the Polly Library. They can be applied individually or grouped together. | Policy | Experience | | :-------- | :-------- | diff --git a/docs/architecture/cloud-native/elastic-search-in-azure.md b/docs/architecture/cloud-native/elastic-search-in-azure.md index 7d1d32b7f82e0..5a7208c9acf1f 100644 --- a/docs/architecture/cloud-native/elastic-search-in-azure.md +++ b/docs/architecture/cloud-native/elastic-search-in-azure.md @@ -55,8 +55,6 @@ This chapter presented a detailed look at data in cloud-native systems. We start - [Getting Behind the 9-Ball: Cosmos DB Consistency Levels Explained](https://blog.jeremylikness.com/blog/2018-03-23_getting-behind-the-9ball-cosmosdb-consistency-levels/) -- [Exploring the different types of NoSQL Databases Part II](https://www.3pillarglobal.com/insights/exploring-the-different-types-of-nosql-databases) - - [On RDBMS, NoSQL and NewSQL databases. Interview with John Ryan](http://www.odbms.org/blog/2018/03/on-rdbms-nosql-and-newsql-databases-interview-with-john-ryan/) - [SQL vs NoSQL vs NewSQL: The Full Comparison](https://www.xenonstack.com/blog/sql-vs-nosql-vs-newsql/) diff --git a/docs/architecture/cloud-native/infrastructure-as-code.md b/docs/architecture/cloud-native/infrastructure-as-code.md index 7a7105d0560db..6252b538d59b1 100644 --- a/docs/architecture/cloud-native/infrastructure-as-code.md +++ b/docs/architecture/cloud-native/infrastructure-as-code.md @@ -74,7 +74,7 @@ provider "azurerm" { version = "=1.28.0" } -resource "azurerm_resource_group" "test" { +resource "azurerm_resource_group" "testrg" { name = "production" location = "West US" } diff --git a/docs/architecture/cloud-native/infrastructure-resiliency-azure.md b/docs/architecture/cloud-native/infrastructure-resiliency-azure.md index ca0b5c559acd9..983e524ed57cd 100644 --- a/docs/architecture/cloud-native/infrastructure-resiliency-azure.md +++ b/docs/architecture/cloud-native/infrastructure-resiliency-azure.md @@ -45,7 +45,7 @@ To architect redundancy, you need to identify the critical paths in your applica - *Leveraging a load balancer.* Load-balancing distributes your application's requests to healthy service instances and automatically removes unhealthy instances from rotation. When deploying to Kubernetes, load balancing can be specified in the Kubernetes manifest file in the Services section. -- *Plan for multiregion deployment.* If you deploy your application to a single region, and that region becomes unavailable, your application will also become unavailable. This may be unacceptable under the terms of your application's service level agreements. Instead, consider deploying your application and its services across multiple regions. For example, an Azure Kubernetes Service (AKS) cluster is deployed to a single region. To protect your system from a regional failure, you might deploy your application to multiple AKS clusters across different regions and use the [Paired Regions](https://buildazure.com/2017/01/06/azure-region-pairs-explained/) feature to coordinate platform updates and prioritize recovery efforts. +- *Plan for multiregion deployment.* If you deploy your application to a single region, and that region becomes unavailable, your application will also become unavailable. This may be unacceptable under the terms of your application's service level agreements. Instead, consider deploying your application and its services across multiple regions. For example, an Azure Kubernetes Service (AKS) cluster is deployed to a single region. To protect your system from a regional failure, you might deploy your application to multiple AKS clusters across different regions and use the [Paired Regions](/azure/virtual-machines/regions#region-pairs) feature to coordinate platform updates and prioritize recovery efforts. - *Enable [geo-replication](/azure/sql-database/sql-database-active-geo-replication).* Geo-replication for services such as Azure SQL Database and Cosmos DB will create secondary replicas of your data across multiple regions. While both services will automatically replicate data within the same region, geo-replication protects you against a regional outage by enabling you to fail over to a secondary region. Another best practice for geo-replication centers around storing container images. To deploy a service in AKS, you need to store and pull the image from a repository. Azure Container Registry integrates with AKS and can securely store container images. To improve performance and availability, consider geo-replicating your images to a registry in each region where you have an AKS cluster. Each AKS cluster then pulls container images from the local container registry in its region as shown in Figure 6-4: diff --git a/docs/architecture/cloud-native/summary.md b/docs/architecture/cloud-native/summary.md index 3c76d55212fd5..30577a6252ec7 100644 --- a/docs/architecture/cloud-native/summary.md +++ b/docs/architecture/cloud-native/summary.md @@ -1,6 +1,7 @@ --- title: Summary - Architecting cloud-native .NET apps for Azure -description: A summary of key conclusions from the Architecting Cloud-Native .NET Apps for Azure guide/e-book. +description: Learn the key conclusions about Cloud Native applications that are fully developed in the Architecting Cloud-Native .NET Apps for Azure guide/e-book. +ms.custom: kr2b-contr-experiment ms.date: 04/06/2022 --- diff --git a/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/common-container-design-principles.md b/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/common-container-design-principles.md index d68a0bba4a635..fe3018e0aeca1 100644 --- a/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/common-container-design-principles.md +++ b/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/common-container-design-principles.md @@ -11,7 +11,7 @@ Ahead of getting into the development process there are a few basic concepts wor ## Container equals a process -In the container model, a container represents a single process. By defining a container as a process boundary, you begin to create the primitives used to scale, or batch-off, processes. When you run a Docker container, you'll see an [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) definition. This defines the process and the lifetime of the container. When the process completes, the container life-cycle ends. There are long-running processes, such as web servers, and short-lived processes, such as batch jobs, which might have been implemented as Microsoft Azure [WebJobs](https://azure.microsoft.com/documentation/articles/websites-webjobs-resources/). If the process fails, the container ends, and the orchestrator takes over. If the orchestrator was instructed to keep five instances running and one fails, the orchestrator will create another container to replace the failed process. In a batch job, the process is started with parameters. When the process completes, the work is complete. +In the container model, a container represents a single process. By defining a container as a process boundary, you begin to create the primitives used to scale, or batch-off, processes. When you run a Docker container, you'll see an [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) definition. This defines the process and the lifetime of the container. When the process completes, the container life-cycle ends. There are long-running processes, such as web servers, and short-lived processes, such as batch jobs, which might have been implemented as Microsoft Azure [WebJobs](https://github.com/Azure/azure-webjobs-sdk/wiki). If the process fails, the container ends, and the orchestrator takes over. If the orchestrator was instructed to keep five instances running and one fails, the orchestrator will create another container to replace the failed process. In a batch job, the process is started with parameters. When the process completes, the work is complete. You might find a scenario in which you want multiple processes running in a single container. In any architecture document, there's never a "never," nor is there always an "always." For scenarios requiring multiple processes, a common pattern is to use [Supervisor](http://supervisord.org/). diff --git a/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/docker-apps-inner-loop-workflow.md b/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/docker-apps-inner-loop-workflow.md index d83d72228f44c..dd82e6e022382 100644 --- a/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/docker-apps-inner-loop-workflow.md +++ b/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/docker-apps-inner-loop-workflow.md @@ -292,7 +292,7 @@ Visual Studio Code supports debugging Docker if you're using Node.js and other p You also can debug .NET or .NET Framework containers in Docker when using Visual Studio for Windows or Mac, as described in the next section. > [!TIP] -> To learn more about debugging Node.js Docker containers, see and [https://docs.microsoft.com/archive/blogs/user_ed/visual-studio-code-new-features-13-big-debugging-updates-rich-object-hover-conditional-breakpoints-node-js-mono-more](/archive/blogs/user_ed/visual-studio-code-new-features-13-big-debugging-updates-rich-object-hover-conditional-breakpoints-node-js-mono-more). +> To learn more about debugging Node.js Docker containers, see and [https://docs.microsoft.com/archive/blogs/user_ed/visual-studio-code-new-features-13-big-debugging-updates-rich-object-hover-conditional-breakpoints-node-js-mono-more](/archive/blogs/user_ed/visual-studio-code-new-features-13-big-debugging-updates-rich-object-hover-conditional-breakpoints-node-js-mono-more). > [!div class="step-by-step"] > [Previous](docker-apps-development-environment.md) diff --git a/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/orchestrate-high-scalability-availability.md b/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/orchestrate-high-scalability-availability.md index 6e9f1297e7537..067f7f66c0d19 100644 --- a/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/orchestrate-high-scalability-availability.md +++ b/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/orchestrate-high-scalability-availability.md @@ -59,7 +59,7 @@ Figure 4-7 shows the structure of a Kubernetes cluster where a master node (VM) ## Development environment for Kubernetes -In the development environment that [Docker announced in July 2018](https://blog.docker.com/2018/07/kubernetes-is-now-available-in-docker-desktop-stable-channel/), Kubernetes can also run in a single development machine (Windows 10 or macOS) by just installing [Docker Desktop](https://www.docker.com/products/docker-desktop). You can later deploy to the cloud (AKS) for further integration tests, as shown in figure 4-8. +In the development environment that Docker announced in July 2018, Kubernetes can also run in a single development machine (Windows 10 or macOS) by just installing [Docker Desktop](https://www.docker.com/products/docker-desktop). You can later deploy to the cloud (AKS) for further integration tests, as shown in figure 4-8. ![Diagram showing Kubernetes on a dev machine then deployed to AKS.](./media/orchestrate-high-scalability-availability/kubernetes-development-environment.png) diff --git a/docs/architecture/dapr-for-net-developers/reference-application.md b/docs/architecture/dapr-for-net-developers/reference-application.md index 4a5ee2e3d8b54..831565af531dd 100644 --- a/docs/architecture/dapr-for-net-developers/reference-application.md +++ b/docs/architecture/dapr-for-net-developers/reference-application.md @@ -381,7 +381,7 @@ public class CatalogService : ICatalogService } ``` -Notice how no Dapr specific code is required to make the service invocation call. All communication is done using the standard HttpClient object. +Notice how no Dapr-specific code is required to make the service invocation call. All communication is done using the standard HttpClient object. The Dapr HttpClient is configured for the `CatalogService` class on program startup: diff --git a/docs/architecture/devops-for-aspnet-developers/actions-vs-pipelines.md b/docs/architecture/devops-for-aspnet-developers/actions-vs-pipelines.md index c3d9e826fb13f..1da20a4053a47 100644 --- a/docs/architecture/devops-for-aspnet-developers/actions-vs-pipelines.md +++ b/docs/architecture/devops-for-aspnet-developers/actions-vs-pipelines.md @@ -39,7 +39,7 @@ GitHub Workflows execute on *runners*. The runner code is essentially a fork of Hosted agents (Azure Pipelines) and hosted runners (GitHub) are agents that are spun up and managed by Azure DevOps or GitHub respectively. You don't need to maintain any build infrastructure. When a pipeline triggers that targets a hosted agent, an instance of the specified agent image is created. The job is run by the agent on the instance, and once the job completes, the instance is destroyed. The same applies for hosted runners running GitHub workflows. > [!NOTE] -> The list of software installed on Azure Pipeline images is listed in [this repository](https://github.com/actions/virtual-environments/tree/main/images). You can select the platform folder and examine the *README.md* files. You can find information on [GitHub hosted runners](https://docs.github.com/actions/reference/specifications-for-github-hosted-runners). +> The list of software installed on Azure Pipelines images is listed in [this repository](https://github.com/actions/virtual-environments/tree/main/images). You can select the platform folder and examine the *README.md* files. You can find information on [GitHub hosted runners](https://docs.github.com/actions/reference/specifications-for-github-hosted-runners). ### Private agents and self-hosted runners diff --git a/docs/architecture/grpc-for-wcf-developers/ws-protocols.md b/docs/architecture/grpc-for-wcf-developers/ws-protocols.md index ca68124ae77b4..ad89213f1161b 100644 --- a/docs/architecture/grpc-for-wcf-developers/ws-protocols.md +++ b/docs/architecture/grpc-for-wcf-developers/ws-protocols.md @@ -15,7 +15,7 @@ One of the real benefits of working with Windows Communication Foundation (WCF) SOAP services expose Web Services Description Language (WSDL) schema documents with information such as data formats, operations, or communication options. You can use this schema to generate the client code. -gRPC works best when servers and clients are generated from the same `.proto` files, but a Server Reflection optional extension does provide a way to expose dynamic information from a running server. For more information, see the [Grpc.Reflection](https://nuget.org/packages/Grpc.Reflection) NuGet package and the [gRPC C# Server Reflection](https://github.com/grpc/grpc/blob/master/doc/csharp/server_reflection.md) article. +gRPC works best when servers and clients are generated from the same `.proto` files, but a Server Reflection optional extension does provide a way to expose dynamic information from a running server. For more information, see the [Grpc.Reflection](https://nuget.org/packages/Grpc.Reflection) NuGet package. The WS-Discovery protocol is used to locate services on a local network. gRPC services are located through DNS or a service registry such as Consul or ZooKeeper. diff --git a/docs/architecture/microservices/architect-microservice-container-applications/scalable-available-multi-container-microservice-applications.md b/docs/architecture/microservices/architect-microservice-container-applications/scalable-available-multi-container-microservice-applications.md index d2d758aa4c24f..fc65158d517ba 100644 --- a/docs/architecture/microservices/architect-microservice-container-applications/scalable-available-multi-container-microservice-applications.md +++ b/docs/architecture/microservices/architect-microservice-container-applications/scalable-available-multi-container-microservice-applications.md @@ -57,7 +57,7 @@ In figure 4-24, you can see the structure of a Kubernetes cluster where a master ## Development environment for Kubernetes -In the development environment, [Docker announced in July 2018](https://blog.docker.com/2018/07/kubernetes-is-now-available-in-docker-desktop-stable-channel/) that Kubernetes can also run in a single development machine (Windows 10 or macOS) by installing [Docker Desktop](https://docs.docker.com/install/). You can later deploy to the cloud (AKS) for further integration tests, as shown in figure 4-25. +In the development environment, Docker announced in July 2018 that Kubernetes can also run in a single development machine (Windows 10 or macOS) by installing [Docker Desktop](https://docs.docker.com/install/). You can later deploy to the cloud (AKS) for further integration tests, as shown in figure 4-25. ![Diagram showing Kubernetes on a dev machine then deployed to AKS](./media/scalable-available-multi-container-microservice-applications/kubernetes-development-environment.png) diff --git a/docs/architecture/microservices/container-docker-introduction/docker-defined.md b/docs/architecture/microservices/container-docker-introduction/docker-defined.md index a92f56e734a60..b57e2e5bf4db6 100644 --- a/docs/architecture/microservices/container-docker-introduction/docker-defined.md +++ b/docs/architecture/microservices/container-docker-introduction/docker-defined.md @@ -72,7 +72,7 @@ So, simplifying, that's the core idea of Docker. In Docker, each layer is the resulting set of changes that happen to the filesystem after executing a command, such as, installing a program. -So, when you "look" at the filesystem after the layer has been copied, you see all the files, included the layer when the program was installed. +So, when you "look" at the filesystem after the layer has been copied, you see all the files, included in the layer when the program was installed. You can think of an image as an auxiliary read-only hard disk ready to be installed in a "computer" where the operating system is already installed. diff --git a/docs/architecture/microservices/docker-application-development-process/docker-app-development-workflow.md b/docs/architecture/microservices/docker-application-development-process/docker-app-development-workflow.md index be5bfc1e2831c..7ac05871a601b 100644 --- a/docs/architecture/microservices/docker-application-development-process/docker-app-development-workflow.md +++ b/docs/architecture/microservices/docker-application-development-process/docker-app-development-workflow.md @@ -546,11 +546,6 @@ The development process for Docker apps: 1 - Code your App, 2 - Write Dockerfile In addition, you need to perform step 2 (adding Docker support to your projects) just once. Therefore, the workflow is similar to your usual development tasks when using .NET for any other development. You need to know what is going on under the covers (the image build process, what base images you're using, deployment of containers, etc.) and sometimes you will also need to edit the Dockerfile or docker-compose.yml file to customize behaviors. But most of the work is greatly simplified by using Visual Studio, making you a lot more productive. -### Additional resources - -- **Debug apps in a local Docker container** \ - - ## Using PowerShell commands in a Dockerfile to set up Windows Containers [Windows Containers](/virtualization/windowscontainers/about/index) allow you to convert your existing Windows applications into Docker images and deploy them with the same tools as the rest of the Docker ecosystem. To use Windows Containers, you run PowerShell commands in the Dockerfile, as shown in the following example: diff --git a/docs/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly.md b/docs/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly.md index d21dfcca7185c..cfc465da0c985 100644 --- a/docs/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly.md +++ b/docs/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly.md @@ -16,11 +16,11 @@ The following steps show how you can use Http retries with Polly integrated into **Reference the .NET 6 packages** -`IHttpClientFactory` is available since .NET Core 2.1 however we recommend you to use the latest .NET 6 packages from NuGet in your project. You typically also need to reference the extension package `Microsoft.Extensions.Http.Polly`. +`IHttpClientFactory` is available since .NET Core 2.1, however, we recommend you use the latest .NET 6 packages from NuGet in your project. You typically also need to reference the extension package `Microsoft.Extensions.Http.Polly`. **Configure a client with Polly's Retry policy, in Startup** -As shown in previous sections, you need to define a named or typed client HttpClient configuration in your standard Startup.ConfigureServices(...) method, but now, you add incremental code specifying the policy for the Http retries with exponential backoff, as below: +As shown in previous sections, you need to define a named or typed client HttpClient configuration in your standard `Startup.ConfigureServices(...)` method, but now, you add incremental code specifying the policy for the Http retries with exponential backoff, as below: ```csharp //ConfigureServices() - Startup.cs diff --git a/docs/architecture/microservices/implement-resilient-applications/monitor-app-health.md b/docs/architecture/microservices/implement-resilient-applications/monitor-app-health.md index 5156022149277..02665ac6baf65 100644 --- a/docs/architecture/microservices/implement-resilient-applications/monitor-app-health.md +++ b/docs/architecture/microservices/implement-resilient-applications/monitor-app-health.md @@ -222,7 +222,7 @@ Sample configuration file for health check UI: ```json // Configuration { - "HealthChecks-UI": { + "HealthChecksUI": { "HealthChecks": [ { "Name": "Ordering HTTP Check", diff --git a/docs/architecture/microservices/index.md b/docs/architecture/microservices/index.md index 5acdcd4ba6bca..a06f2ac16ce98 100644 --- a/docs/architecture/microservices/index.md +++ b/docs/architecture/microservices/index.md @@ -21,7 +21,7 @@ To make it easier to get started, the guide focuses on a reference containerized - Clone/Fork the reference application [eShopOnContainers on GitHub](https://github.com/dotnet-architecture/eShopOnContainers) -- Watch the [introductory video on Channel 9](https://aka.ms/microservices-video) +- Watch the [introductory video](https://aka.ms/microservices-video) - Get to know the [Microservices Architecture](https://aka.ms/MicroservicesArchitecture) right away diff --git a/docs/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation.md b/docs/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation.md index 44210d07a1893..8989036345931 100644 --- a/docs/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation.md +++ b/docs/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation.md @@ -1,9 +1,9 @@ --- -title: Domain events. design and implementation +title: "Domain events: Design and implementation" description: .NET Microservices Architecture for Containerized .NET Applications | Get an in-depth view of domain events, a key concept to establish communication between aggregates. ms.date: 10/08/2018 --- -# Domain events: design and implementation +# Domain events: Design and implementation [!INCLUDE [download-alert](../includes/download-alert.md)] @@ -17,7 +17,7 @@ An important benefit of domain events is that side effects can be expressed expl For example, if you're just using Entity Framework and there has to be a reaction to some event, you would probably code whatever you need close to what triggers the event. So the rule gets coupled, implicitly, to the code, and you have to look into the code to, hopefully, realize the rule is implemented there. -On the other hand, using domain events makes the concept explicit, because there is a `DomainEvent` and at least one `DomainEventHandler` involved. +On the other hand, using domain events makes the concept explicit, because there's a `DomainEvent` and at least one `DomainEventHandler` involved. For example, in the eShopOnContainers application, when an order is created, the user becomes a buyer, so an `OrderStartedDomainEvent` is raised and handled in the `ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler`, so the underlying concept is evident. @@ -25,7 +25,7 @@ In short, domain events help you to express, explicitly, the domain rules, based It's important to ensure that, just like a database transaction, either all the operations related to a domain event finish successfully or none of them do. -Domain events are similar to messaging-style events, with one important difference. With real messaging, message queuing, message brokers, or a service bus using AMQP, a message is always sent asynchronously and communicated across processes and machines. This is useful for integrating multiple Bounded Contexts, microservices, or even different applications. However, with domain events, you want to raise an event from the domain operation you are currently running, but you want any side effects to occur within the same domain. +Domain events are similar to messaging-style events, with one important difference. With real messaging, message queuing, message brokers, or a service bus using AMQP, a message is always sent asynchronously and communicated across processes and machines. This is useful for integrating multiple Bounded Contexts, microservices, or even different applications. However, with domain events, you want to raise an event from the domain operation you're currently running, but you want any side effects to occur within the same domain. The domain events and their side effects (the actions triggered afterwards that are managed by event handlers) should occur almost immediately, usually in-process, and within the same domain. Thus, domain events could be synchronous or asynchronous. Integration events, however, should always be asynchronous. @@ -51,7 +51,7 @@ Figure 7-14 shows how consistency between aggregates is achieved by domain event Alternately, you can have the aggregate root subscribed for events raised by members of its aggregates (child entities). For instance, each OrderItem child entity can raise an event when the item price is higher than a specific amount, or when the product item amount is too high. The aggregate root can then receive those events and perform a global calculation or aggregation. -It is important to understand that this event-based communication is not implemented directly within the aggregates; you need to implement domain event handlers. +It's important to understand that this event-based communication is not implemented directly within the aggregates; you need to implement domain event handlers. Handling the domain events is an application concern. The domain model layer should only focus on the domain logic—things that a domain expert would understand, not application infrastructure like handlers and side-effect persistence actions using repositories. Therefore, the application layer level is where you should have domain event handlers triggering actions when a domain event is raised. @@ -78,7 +78,7 @@ As shown in Figure 7-15, starting from the same domain event, you can handle mul **Figure 7-15**. Handling multiple actions per domain -There can be several handlers for the same domain event in the Application Layer, one handler can solve consistency between aggregates and another handler can publish an integration event, so other microservices can do something with it. The event handlers are typically in the application layer, because you will use infrastructure objects like repositories or an application API for the microservice's behavior. In that sense, event handlers are similar to command handlers, so both are part of the application layer. The important difference is that a command should be processed only once. A domain event could be processed zero or *n* times, because it can be received by multiple receivers or event handlers with a different purpose for each handler. +There can be several handlers for the same domain event in the Application Layer, one handler can solve consistency between aggregates and another handler can publish an integration event, so other microservices can do something with it. The event handlers are typically in the application layer, because you'll use infrastructure objects like repositories or an application API for the microservice's behavior. In that sense, event handlers are similar to command handlers, so both are part of the application layer. The important difference is that a command should be processed only once. A domain event could be processed zero or *n* times, because it can be received by multiple receivers or event handlers with a different purpose for each handler. Having an open number of handlers per domain event allows you to add as many domain rules as needed, without affecting current code. For instance, implementing the following business rule might be as easy as adding a few event handlers (or even just one): @@ -121,7 +121,7 @@ This is essentially a class that holds all the data related to the OrderStarted In terms of the ubiquitous language of the domain, since an event is something that happened in the past, the class name of the event should be represented as a past-tense verb, like OrderStartedDomainEvent or OrderShippedDomainEvent. That's how the domain event is implemented in the ordering microservice in eShopOnContainers. -As noted earlier, an important characteristic of events is that since an event is something that happened in the past, it should not change. Therefore, it must be an immutable class. You can see in the previous code that the properties are read-only. There's no way to update the object, you can only set values when you create it. +As noted earlier, an important characteristic of events is that since an event is something that happened in the past, it shouldn't change. Therefore, it must be an immutable class. You can see in the previous code that the properties are read-only. There's no way to update the object, you can only set values when you create it. It's important to highlight here that if domain events were to be handled asynchronously, using a queue that required serializing and deserializing the event objects, the properties would have to be "private set" instead of read-only, so the deserializer would be able to assign the values upon dequeuing. This is not an issue in the Ordering microservice, as the domain event pub/sub is implemented synchronously using MediatR. @@ -129,9 +129,9 @@ It's important to highlight here that if domain events were to be handled asynch The next question is how to raise a domain event so it reaches its related event handlers. You can use multiple approaches. -Udi Dahan originally proposed (for example, in several related posts, such as [Domain Events – Take 2](https://udidahan.com/2008/08/25/domain-events-take-2/)) using a static class for managing and raising the events. This might include a static class named DomainEvents that would raise domain events immediately when it is called, using syntax like `DomainEvents.Raise(Event myEvent)`. Jimmy Bogard wrote a blog post ([Strengthening your domain: Domain Events](https://lostechies.com/jimmybogard/2010/04/08/strengthening-your-domain-domain-events/)) that recommends a similar approach. +Udi Dahan originally proposed (for example, in several related posts, such as [Domain Events – Take 2](https://udidahan.com/2008/08/25/domain-events-take-2/)) using a static class for managing and raising the events. This might include a static class named DomainEvents that would raise domain events immediately when it's called, using syntax like `DomainEvents.Raise(Event myEvent)`. Jimmy Bogard wrote a blog post ([Strengthening your domain: Domain Events](https://lostechies.com/jimmybogard/2010/04/08/strengthening-your-domain-domain-events/)) that recommends a similar approach. -However, when the domain events class is static, it also dispatches to handlers immediately. This makes testing and debugging more difficult, because the event handlers with side-effects logic are executed immediately after the event is raised. When you are testing and debugging, you just want to focus on what is happening in the current aggregate classes; you do not want to suddenly be redirected to other event handlers for side effects related to other aggregates or application logic. This is why other approaches have evolved, as explained in the next section. +However, when the domain events class is static, it also dispatches to handlers immediately. This makes testing and debugging more difficult, because the event handlers with side-effects logic are executed immediately after the event is raised. When you're testing and debugging, you just want to focus on what is happening in the current aggregate classes; you don't want to suddenly be redirected to other event handlers for side effects related to other aggregates or application logic. This is why other approaches have evolved, as explained in the next section. #### The deferred approach to raise and dispatch events @@ -205,7 +205,7 @@ public class OrderingContext : DbContext, IUnitOfWork With this code, you dispatch the entity events to their respective event handlers. -The overall result is that you have decoupled the raising of a domain event (a simple add into a list in memory) from dispatching it to an event handler. In addition, depending on what kind of dispatcher you are using, you could dispatch the events synchronously or asynchronously. +The overall result is that you've decoupled the raising of a domain event (a simple add into a list in memory) from dispatching it to an event handler. In addition, depending on what kind of dispatcher you are using, you could dispatch the events synchronously or asynchronously. Be aware that transactional boundaries come into significant play here. If your unit of work and transaction can span more than one aggregate (as when using EF Core and a relational database), this can work well. But if the transaction cannot span aggregates, you have to implement additional steps to achieve consistency. This is another reason why persistence ignorance is not universal; it depends on the storage system you use. @@ -219,7 +219,7 @@ Vaughn Vernon says the following in [Effective Aggregate Design. Part II: Making > Thus, if executing a command on one aggregate instance requires that additional business rules execute on one or more aggregates, use eventual consistency \[...\] There is a practical way to support eventual consistency in a DDD model. An aggregate method publishes a domain event that is in time delivered to one or more asynchronous subscribers. -This rationale is based on embracing fine-grained transactions instead of transactions spanning many aggregates or entities. The idea is that in the second case, the number of database locks will be substantial in large-scale applications with high scalability needs. Embracing the fact that highly scalable applications need not have instant transactional consistency between multiple aggregates helps with accepting the concept of eventual consistency. Atomic changes are often not needed by the business, and it is in any case the responsibility of the domain experts to say whether particular operations need atomic transactions or not. If an operation always needs an atomic transaction between multiple aggregates, you might ask whether your aggregate should be larger or was not correctly designed. +This rationale is based on embracing fine-grained transactions instead of transactions spanning many aggregates or entities. The idea is that in the second case, the number of database locks will be substantial in large-scale applications with high scalability needs. Embracing the fact that highly scalable applications need not have instant transactional consistency between multiple aggregates helps with accepting the concept of eventual consistency. Atomic changes are often not needed by the business, and it is in any case the responsibility of the domain experts to say whether particular operations need atomic transactions or not. If an operation always needs an atomic transaction between multiple aggregates, you might ask whether your aggregate should be larger or wasn't correctly designed. However, other developers and architects like Jimmy Bogard are okay with spanning a single transaction across several aggregates—but only when those additional aggregates are related to side effects for the same original command. For instance, in [A better domain events pattern](https://lostechies.com/jimmybogard/2014/05/13/a-better-domain-events-pattern/), Bogard says this: @@ -227,11 +227,11 @@ However, other developers and architects like Jimmy Bogard are okay with spannin If you dispatch the domain events right *before* committing the original transaction, it is because you want the side effects of those events to be included in the same transaction. For example, if the EF DbContext SaveChanges method fails, the transaction will roll back all changes, including the result of any side effect operations implemented by the related domain event handlers. This is because the DbContext life scope is by default defined as "scoped." Therefore, the DbContext object is shared across multiple repository objects being instantiated within the same scope or object graph. This coincides with the HttpRequest scope when developing Web API or MVC apps. -Actually, both approaches (single atomic transaction and eventual consistency) can be right. It really depends on your domain or business requirements and what the domain experts tell you. It also depends on how scalable you need the service to be (more granular transactions have less impact with regard to database locks). And it depends on how much investment you are willing to make in your code, since eventual consistency requires more complex code in order to detect possible inconsistencies across aggregates and the need to implement compensatory actions. Consider that if you commit changes to the original aggregate and afterwards, when the events are being dispatched, if there is an issue and the event handlers cannot commit their side effects, you will have inconsistencies between aggregates. +Actually, both approaches (single atomic transaction and eventual consistency) can be right. It really depends on your domain or business requirements and what the domain experts tell you. It also depends on how scalable you need the service to be (more granular transactions have less impact with regard to database locks). And it depends on how much investment you're willing to make in your code, since eventual consistency requires more complex code in order to detect possible inconsistencies across aggregates and the need to implement compensatory actions. Consider that if you commit changes to the original aggregate and afterwards, when the events are being dispatched, if there's an issue and the event handlers cannot commit their side effects, you'll have inconsistencies between aggregates. A way to allow compensatory actions would be to store the domain events in additional database tables so they can be part of the original transaction. Afterwards, you could have a batch process that detects inconsistencies and runs compensatory actions by comparing the list of events with the current state of the aggregates. The compensatory actions are part of a complex topic that will require deep analysis from your side, which includes discussing it with the business user and domain experts. -In any case, you can choose the approach you need. But the initial deferred approach—raising the events before committing, so you use a single transaction—is the simplest approach when using EF Core and a relational database. It is easier to implement and valid in many business cases. It is also the approach used in the ordering microservice in eShopOnContainers. +In any case, you can choose the approach you need. But the initial deferred approach—raising the events before committing, so you use a single transaction—is the simplest approach when using EF Core and a relational database. It's easier to implement and valid in many business cases. It's also the approach used in the ordering microservice in eShopOnContainers. But how do you actually dispatch those events to their respective event handlers? What's the `_mediator` object you see in the previous example? It has to do with the techniques and artifacts you use to map between events and their event handlers. @@ -300,7 +300,7 @@ public class ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler // ...Parameter validations... } - public async Task Handle(OrderStartedDomainEvent orderStartedEvent) + public async Task HandleAsync(OrderStartedDomainEvent orderStartedEvent) { var cardTypeId = (orderStartedEvent.CardTypeId != 0) ? orderStartedEvent.CardTypeId : 1; var userGuid = _identityService.GetUserIdentity(); diff --git a/docs/architecture/microservices/net-core-net-framework-containers/container-framework-choice-factors.md b/docs/architecture/microservices/net-core-net-framework-containers/container-framework-choice-factors.md index f71cf5e4eee7f..ce9c48ffe83ed 100644 --- a/docs/architecture/microservices/net-core-net-framework-containers/container-framework-choice-factors.md +++ b/docs/architecture/microservices/net-core-net-framework-containers/container-framework-choice-factors.md @@ -1,13 +1,13 @@ --- -title: Decision table. .NET frameworks to use for Docker -description: .NET Microservices Architecture for Containerized .NET Applications | Decision table, .NET frameworks to use for Docker +title: Decision table. .NET implementations to use for Docker +description: .NET Microservices Architecture for Containerized .NET Applications | Decision table, .NET implementations to use for Docker ms.date: 11/19/2021 --- -# Decision table: .NET frameworks to use for Docker +# Decision table: .NET implementations to use for Docker [!INCLUDE [download-alert](../includes/download-alert.md)] -The following decision table summarizes whether to use .NET Framework or .NET 6. Remember that for Linux containers, you need Linux-based Docker hosts (VMs or servers) and that for Windows Containers you need Windows Server based Docker hosts (VMs or servers). +The following decision table summarizes whether to use .NET Framework or .NET 6. Remember that for Linux containers, you need Linux-based Docker hosts (VMs or servers), and that for Windows Containers, you need Windows Server-based Docker hosts (VMs or servers). > [!IMPORTANT] > Your development machines will run one Docker host, either Linux or Windows. Related microservices that you want to run and test together in one solution will all need to run on the same container platform. @@ -22,7 +22,7 @@ The following decision table summarizes whether to use .NET Framework or .NET 6. | ASP.NET Core | .NET 6 | .NET 6 (recommended)
.NET Framework | | ASP.NET 4 (MVC 5, Web API 2, and Web Forms) | -- | .NET Framework | | SignalR services | .NET Core 2.1 or higher version | .NET Framework
.NET Core 2.1 or higher version | -| WCF, WF, and other legacy frameworks | WCF in .NET Core (client library only) | .NET Framework
WCF in .NET 6 (client library only) | +| WCF, WF, and other legacy frameworks | WCF in .NET Core (client library only) or [CoreWCF](https://www.nuget.org/profiles/corewcf) | .NET Framework
WCF in .NET 6 (client library only) or [CoreWCF](https://www.nuget.org/profiles/corewcf) | | Consumption of Azure services | .NET 6
(eventually most Azure services will provide client SDKs for .NET 6) | .NET Framework
.NET 6
(eventually most Azure services will provide client SDKs for .NET 6) | >[!div class="step-by-step"] diff --git a/docs/architecture/microservices/net-core-net-framework-containers/general-guidance.md b/docs/architecture/microservices/net-core-net-framework-containers/general-guidance.md index bd23cff1760c7..eb800bc219f8f 100644 --- a/docs/architecture/microservices/net-core-net-framework-containers/general-guidance.md +++ b/docs/architecture/microservices/net-core-net-framework-containers/general-guidance.md @@ -29,7 +29,7 @@ Use .NET Framework for your containerized Docker server application when: - You need to use third-party .NET libraries or NuGet packages that are not available for .NET 6. -Using .NET Framework on Docker can improve your deployment experiences by minimizing deployment issues. This ["lift and shift" scenario](https://aka.ms/liftandshiftwithcontainersebook) is important for containerizing legacy applications that were originally developed with the traditional .NET Framework, like ASP.NET WebForms, MVC web apps or WCF (Windows Communication Foundation) services. +Using .NET Framework on Docker can improve your deployment experiences by minimizing deployment issues. This ["lift and shift" scenario](https://aka.ms/liftandshiftwithcontainersebook) is important for containerizing legacy applications that were originally developed with the traditional .NET Framework, like ASP.NET WebForms, MVC web apps, or WCF (Windows Communication Foundation) services. ### Additional resources diff --git a/docs/architecture/microservices/net-core-net-framework-containers/net-framework-container-scenarios.md b/docs/architecture/microservices/net-core-net-framework-containers/net-framework-container-scenarios.md index 49a8eb25ef3f0..9873e3137edd8 100644 --- a/docs/architecture/microservices/net-core-net-framework-containers/net-framework-container-scenarios.md +++ b/docs/architecture/microservices/net-core-net-framework-containers/net-framework-container-scenarios.md @@ -25,14 +25,12 @@ However, even with that exceptional progression since .NET Standard 2.0 and .NET ## Using .NET technologies not available for .NET 6 -Some .NET Framework technologies aren't available in the current version of .NET (version 5.0 as of this writing). Some of them might become available in later releases, but others don't fit the new application patterns targeted by .NET Core and might never be available. +Some .NET Framework technologies aren't available in .NET 6. Some of them might become available in later releases, but others don't fit the new application patterns targeted by .NET Core and might never be available. The following list shows most of the technologies that aren't available in .NET 6: - ASP.NET Web Forms. This technology is only available on .NET Framework. Currently there are no plans to bring ASP.NET Web Forms to .NET or later. -- WCF services. Even when a [WCF-Client library](https://github.com/dotnet/wcf) is available to consume WCF services from .NET 6, as of Jan-2021, the WCF server implementation is only available on .NET Framework. - - Workflow-related services. Windows Workflow Foundation (WF), Workflow Services (WCF + WF in a single service), and WCF Data Services (formerly known as ADO.NET Data Services) are only available on .NET Framework. There are currently no plans to bring them to .NET 6. In addition to the technologies listed in the official [.NET roadmap](https://github.com/dotnet/core/blob/main/roadmap.md), other features might be ported to the new [unified .NET platform](https://devblogs.microsoft.com/dotnet/introducing-net-5/). You might consider participating in the discussions on GitHub so that your voice can be heard. And if you think something is missing, file a new issue in the [dotnet/runtime](https://github.com/dotnet/runtime/issues/new) GitHub repository. diff --git a/docs/architecture/modernize-desktop/example-migration.md b/docs/architecture/modernize-desktop/example-migration.md index 488009308c555..c4379ea336746 100644 --- a/docs/architecture/modernize-desktop/example-migration.md +++ b/docs/architecture/modernize-desktop/example-migration.md @@ -102,7 +102,7 @@ Update the versions of the packages you've found to be compatible, as shown in t #### Microsoft.Windows.Compatibility -If your application depends on APIs that aren't available on .NET, such as Registry, ACLs, or WCF, you have to include a reference to the `Microsoft.Windows.Compatibility` package to add these Windows-specific APIs. They work on .NET but aren't included as they aren't cross-platform. +If your application depends on APIs that aren't available on .NET, such as Registry or ACLs, you have to include a reference to the `Microsoft.Windows.Compatibility` package to add these Windows-specific APIs. They work on .NET but aren't included as they aren't cross-platform. There's a tool called Platform compatibility analyzer ([https://docs.microsoft.com/dotnet/standard/analyzers/platform-compat-analyzer](../../standard/analyzers/platform-compat-analyzer.md)) that helps you identify APIs that aren't compatible with your code. @@ -117,7 +117,6 @@ Some technologies aren't available on .NET, such as: * AppDomains * Remoting * Code Access Security -* WCF Server * Windows Workflow That's why you need to find a replacement for these technologies if you're using them in your application. For more information, see the [.NET Framework technologies unavailable on .NET Core and .NET 5+](../../core/porting/net-framework-tech-unavailable.md) article. diff --git a/docs/architecture/modernize-desktop/migrate-modern-applications.md b/docs/architecture/modernize-desktop/migrate-modern-applications.md index c642a16368020..ac06ed3756625 100644 --- a/docs/architecture/modernize-desktop/migrate-modern-applications.md +++ b/docs/architecture/modernize-desktop/migrate-modern-applications.md @@ -164,7 +164,7 @@ Second, you'll need to regenerate the service client with the new tools present After the migration, if you find that there are libraries you need that aren't present on .NET, you can add a reference to the [Microsoft.Windows.Compatibility](https://www.nuget.org/packages/Microsoft.Windows.Compatibility) NuGet package and see if the missing functions are there. -If you're using the class to perform web service calls, you may find some differences on .NET. The recommendation is to use the System.Net.Http.HttpClient instead. +If you're using the class to perform web service calls, you may find some differences on .NET. The recommendation is to use instead. ## Consuming a COM Object @@ -212,13 +212,13 @@ Across machines, use a network-based solution as an alternative. Preferably, use Sandboxing, which relies on the runtime or the framework to constrain which resources a managed application or library uses or runs, isn't supported on .NET. -Use security boundaries that are provided by the operating system, such as virtualization, containers, or user accounts for running processes with the minimum set of privileges. +Use security boundaries that are provided by the operating system, such as virtualization, containers, or user accounts, for running processes with the minimum set of privileges. ### Security Transparency Similar to CAS, Security Transparency separates sandboxed code from security critical code in a declarative fashion but is no longer supported as a security boundary. -Use security boundaries that are provided by the operating system, such as virtualization, containers, or user accounts for running processes with the least set of privileges. +Use security boundaries that are provided by the operating system, such as virtualization, containers, or user accounts, for running processes with the least set of privileges. >[!div class="step-by-step"] >[Previous](whats-new-dotnet.md ) diff --git a/docs/architecture/modernize-with-azure-containers/index.md b/docs/architecture/modernize-with-azure-containers/index.md index 86aed0e2a7092..a6b2d6cf1666f 100644 --- a/docs/architecture/modernize-with-azure-containers/index.md +++ b/docs/architecture/modernize-with-azure-containers/index.md @@ -180,7 +180,7 @@ This guide doesn't show you how to create Cloud-Native applications, such as how ## Who should use this guide -This guide was written for developers and solution architects who want to modernize existing ASP.NET web applications or WCF services that are based on the .NET Framework, for improved agility in shipping and releasing applications. +This guide was written for developers and solution architects who want to modernize existing ASP.NET web applications or WCF services that are based on .NET Framework, for improved agility in shipping and releasing applications. You also might find this guide useful if you are a technical decision maker, such as an enterprise architect or a development lead/director who just wants an overview of the benefits that you can get by using Windows Containers, and by deploying to the cloud when using Microsoft Azure. diff --git a/docs/architecture/modernize-with-azure-containers/media/image1-6.png b/docs/architecture/modernize-with-azure-containers/media/image1-6.png index 18332e726fdbe..8fecb90beaae2 100644 Binary files a/docs/architecture/modernize-with-azure-containers/media/image1-6.png and b/docs/architecture/modernize-with-azure-containers/media/image1-6.png differ diff --git a/docs/architecture/modernize-with-azure-containers/migrate-your-relational-databases-to-azure.md b/docs/architecture/modernize-with-azure-containers/migrate-your-relational-databases-to-azure.md index e121f463b0a42..1a782019197e5 100644 --- a/docs/architecture/modernize-with-azure-containers/migrate-your-relational-databases-to-azure.md +++ b/docs/architecture/modernize-with-azure-containers/migrate-your-relational-databases-to-azure.md @@ -97,18 +97,12 @@ Whenever you change an original RDBMS, you might need to retest. You also might If you have any other database (for example, IBM DB2) and you opt for a lift and shift approach, you might want to continue using those databases as IaaS VMs in Azure, unless you are willing to perform a more complex data migration. A more complex data migration will require additional effort because you'd be migrating to a different database type with the new schema and different programming libraries. -To learn how to migrate databases by using Azure Database Migration Service, see [Get to the cloud faster with Azure SQL Database Managed Instance and Azure Database Migration Service](https://channel9.msdn.com/Events/Build/2017/P4008). - ## Additional resources - **Choose a cloud SQL Server option: Azure SQL Database (PaaS) or SQL Server on Azure VM (IaaS)** [https://docs.microsoft.com/azure/sql-database/sql-database-paas-vs-sql-server-iaas](/azure/sql-database/sql-database-paas-vs-sql-server-iaas) -- **Get to the cloud faster with Azure SQL DB Managed Instance and Database Migration Service** - - - - **SQL Server database migration to SQL Database in the cloud** [https://docs.microsoft.com/azure/sql-database/sql-database-cloud-migrate](/azure/sql-database/sql-database-cloud-migrate) diff --git a/docs/architecture/porting-existing-aspnet-apps/comparing-razor-pages-aspnet-mvc.md b/docs/architecture/porting-existing-aspnet-apps/comparing-razor-pages-aspnet-mvc.md index 85d10e5d5cf74..3c69157de4ae0 100644 --- a/docs/architecture/porting-existing-aspnet-apps/comparing-razor-pages-aspnet-mvc.md +++ b/docs/architecture/porting-existing-aspnet-apps/comparing-razor-pages-aspnet-mvc.md @@ -1,6 +1,7 @@ --- title: Compare Razor Pages to ASP.NET MVC -description: Razor Pages offer a better way to organize responsibilities than traditional MVC views for page-based apps. Learn how they compare to the traditional ASP.NET MVC approach in this section. +description: Learn how Razor Pages offer a better way to organize responsibilities than the traditional ASP.NET MVC approach. +ms.custom: kr2b-contr-experiment author: ardalis ms.date: 12/10/2021 --- diff --git a/docs/architecture/porting-existing-aspnet-apps/example-migration-eshop.md b/docs/architecture/porting-existing-aspnet-apps/example-migration-eshop.md index ba72c3cef10bc..89a159e87fe2e 100644 --- a/docs/architecture/porting-existing-aspnet-apps/example-migration-eshop.md +++ b/docs/architecture/porting-existing-aspnet-apps/example-migration-eshop.md @@ -90,8 +90,8 @@ The next dialog will ask you to choose which template to use. Select the **Empty Since the built-in migration tool for migrating *packages.config* to `` doesn't work on ASP.NET projects, you can use a community tool instead, or migrate by hand. A [community tool I've used](https://gist.github.com/tomkuijsten/2d75074d9a3c19c04ee8ea19a6289ddf) uses an XSL file to transform from one format to the other. To use it, first copy the *packages.config* file to the newly created ASP.NET Core project folder. Make a backup of your files, as this script removes the *packages.config* file from all folders under where you run the script. Then run these commands from the project folder (or for the entire solution if you prefer): ```powershell -iwr https://git.io/vdKaV -OutFile Convert-ToPackageReference.ps1 -iwr https://git.io/vdKar -OutFile Convert-ToPackageReference.xsl +iwr https://gist.githubusercontent.com/aienabled/0bce5e4b17118122f2772e7c9218bf9c/raw/778953f89882877a7124894b47dccfb1ba3e80a0/Convert-ToPackageReference.ps1 -OutFile Convert-ToPackageReference.ps1 +iwr https://gist.githubusercontent.com/aienabled/0bce5e4b17118122f2772e7c9218bf9c/raw/778953f89882877a7124894b47dccfb1ba3e80a0/Convert-ToPackageReference.xsl -OutFile Convert-ToPackageReference.xsl ./Convert-ToPackageReference.ps1 | Out-Null ``` diff --git a/docs/architecture/porting-existing-aspnet-apps/identify-migration-sequence.md b/docs/architecture/porting-existing-aspnet-apps/identify-migration-sequence.md index df929402fca3b..d96fa77e7a9d5 100644 --- a/docs/architecture/porting-existing-aspnet-apps/identify-migration-sequence.md +++ b/docs/architecture/porting-existing-aspnet-apps/identify-migration-sequence.md @@ -94,7 +94,6 @@ You can use the .NET Portability Analyzer to determine how compatible existing l - [Porting from .NET Framework to .NET Core](../../core/porting/index.md) - [The .NET Portability Analyzer](../../standard/analyzers/portability-analyzer.md) -- [Channel 9: A Brief Look at the .NET Portability Analyzer (Video)](https://channel9.msdn.com/Blogs/Seth-Juarez/A-Brief-Look-at-the-NET-Portability-Analyzer) - [2 Years, 200 Apps: A .NET Core Migration at Scale (Video)](https://www.youtube.com/watch?v=C-2haqb60No) >[!div class="step-by-step"] diff --git a/docs/architecture/porting-existing-aspnet-apps/migration-considerations.md b/docs/architecture/porting-existing-aspnet-apps/migration-considerations.md index e2198849b53b3..db48151c18e46 100644 --- a/docs/architecture/porting-existing-aspnet-apps/migration-considerations.md +++ b/docs/architecture/porting-existing-aspnet-apps/migration-considerations.md @@ -45,15 +45,17 @@ There are many compelling reasons to consider migrating to .NET Core, which pres The biggest reason to stay on .NET Framework is when an app isn't under active development and wouldn't benefit substantially from the advantages listed above. In that case, there probably isn't a good business case to incur the cost of porting the app. If your app might benefit from the advantages .NET Core offers, you may still need to stay on .NET Framework if you need certain technologies that are unavailable on .NET Core. There are some [.NET technologies that are unavailable on .NET Core](../../core/porting/net-framework-tech-unavailable.md), including AppDomains, Remoting, Code Access Security (CAS), Security Transparency, and `System.EnterpriseServices`. A brief summary of these technologies and their alternatives is included here. For more detailed guidance, see the documentation. +[!INCLUDE [cas-deprecated](../../../includes/cas-deprecated.md)] + ### Application domains Application domains (AppDomains) isolate apps from one another. AppDomains require runtime support and can be expensive. Creating additional app domains isn't supported, and there are no plans to add this capability to .NET Core in the future. For code isolation, use separate processes or containers as an alternative. Some customers use AppDomains as a way of unloading assemblies. In .NET Core [AssemblyLoadContext](../../standard/assembly/unloadability.md) provides an alternative way to unload assemblies. ### WCF -Server-side WCF isn't supported in .NET Core. .NET Core supports WCF clients but not WCF hosts. Apps that require this functionality will need to upgrade to a different communication technology (such as gRPC or REST) as part of a migration. +.NET Core and .NET 5+ support WCF clients. Server-side WCF is possible through [CoreWCF](https://www.nuget.org/profiles/corewcf), which is officially supported by Microsoft as of April 2022. Apps that require server-side WCF functionality can also consider a different communication technology (such as gRPC or REST) as part of a migration. -There is a [WCF client port available from the .NET Foundation](../../core/whats-new/dotnet-5.md#windows-communication-foundation). It is entirely open source, cross platform, and supported by Microsoft. There is also a community-supported [CoreWCF project](https://github.com/CoreWCF/CoreWCF) that is *not* officially supported by Microsoft. +There is a [WCF client port available from the .NET Foundation](../../core/whats-new/dotnet-5.md#windows-communication-foundation). It's entirely open source, cross platform, and supported by Microsoft. To learn more about migrating from WCF to gRPC, consult the [gRPC for WCF Developers](../grpc-for-wcf-developers/index.md) ebook. diff --git a/docs/azure/TOC.yml b/docs/azure/TOC.yml index a7b1ea581bc4d..900adcaf338de 100644 --- a/docs/azure/TOC.yml +++ b/docs/azure/TOC.yml @@ -36,7 +36,21 @@ - name: What is the Azure SDK for .NET? href: ./sdk/azure-sdk-for-dotnet.md - name: Authentication - href: ./sdk/authentication.md + items: + - name: Overview + href: sdk/authentication.md + - name: Auth during local development + items: + - name: Auth using developer service principals + href: sdk/authentication-local-development-service-principal.md + - name: Auth using developer accounts + href: sdk/authentication-local-development-dev-accounts.md + - name: Auth from Azure-hosted apps + href: sdk/authentication-azure-hosted-apps.md + - name: Auth from on-premises apps + href: sdk/authentication-on-premises-apps.md + - name: Additional auth methods + href: sdk/authentication-additional-methods.md - name: Dependency injection href: ./sdk/dependency-injection.md - name: Thread safety diff --git a/docs/azure/azure-tools.md b/docs/azure/azure-tools.md index 45aa900b3fd3d..172096ed55646 100644 --- a/docs/azure/azure-tools.md +++ b/docs/azure/azure-tools.md @@ -4,8 +4,7 @@ description: This article describes additional tools and utilities for working w ms.date: 1/1/2021 ms.topic: conceptual ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 recommendations: false --- diff --git a/docs/azure/configure-visual-studio.md b/docs/azure/configure-visual-studio.md index 8b2780c6fa554..ba044b85ba0bb 100644 --- a/docs/azure/configure-visual-studio.md +++ b/docs/azure/configure-visual-studio.md @@ -1,39 +1,37 @@ --- title: Configure Visual Studio for Azure Development with .NET -description: This article helps you configure Visual Studio for Azure development including getting the right workloads installed and connecting Visual Studio to your Azure account +description: This article helps you configure Visual Studio for Azure development including getting the right workloads installed and connecting Visual Studio to your Azure account. ms.date: 11/30/2020 ms.topic: conceptual ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 recommendations: false --- - # Configure Visual Studio for Azure development with .NET -Visual Studio includes tooling to help with the development and deployment of applications on Azure. This guide will help you make sure that you have Visual Studio properly configured for Azure development. +Visual Studio includes tooling to help with the development and deployment of applications on Azure. This guide will help you make sure that Visual Studio is properly configured for Azure development. -### Download Visual Studio 2019 +## Download Visual Studio -If you already have Visual Studio 2019 installed, you can skip this step. +If you already have Visual Studio installed, you can skip this step. > [!div class="nextstepaction"] -> [Download Visual Studio 2019](https://www.visualstudio.com/downloads/) +> [Download Visual Studio](https://www.visualstudio.com/downloads/) -### Install Azure workloads +## Install Azure workloads -Launch the **Visual Studio Installer** and validate that you have the workloads **Azure development** and **ASP.NET and web development** are installed. If either of these workloads is not installed, select these workloads to install them. +Open Visual Studio Installer and validate that the workloads **Azure development** and **ASP.NET and web development** are installed. If either of these workloads is not installed, select them to be installed. ![Screenshot of the Visual Studio Installer showing the Azure development and ASP.NET and Web Development Workloads selected](./media/visual-studio-installer-azure-development.png) -### Authenticate Visual Studio with Azure +## Authenticate Visual Studio with Azure -When debugging apps through Visual Studio, Visual Studio can use your Azure account to authenticate and access Azure Resources with. This account is also used when you publish apps directly from Visual Studio to Azure. +When debugging apps through Visual Studio, Visual Studio can use your Azure account to authenticate and access Azure Resources. This account is also used when you publish apps directly from Visual Studio to Azure. -To authenticate your Azure account from Visual Studio, select the **Tools** > **Options** menu to launch the **Options** dialog. Navigate to the `Azure Service Authentication` options and sign in using your Azure account. +To authenticate your Azure account from Visual Studio, select the **Tools** > **Options** menu to launch the **Options** dialog. Navigate to the **Azure Service Authentication** options and sign in using your Azure account. ![Screenshot of the Visual Studio Options Dialog showing the Azure Login](./media/visual-studio-azure-login-dialog.png) -### Next steps +## Next steps -If you also use [Visual Studio Code](https://code.visualstudio.com/) for development in .NET or any other language, you should also [configure Visual Studio Code for Azure development](./configure-vs-code.md). Otherwise, proceed to [Installing the Azure CLI](./install-azure-cli.md). +If you also use [Visual Studio Code](https://code.visualstudio.com/) for development in .NET or any other language, you should [configure Visual Studio Code for Azure development](./configure-vs-code.md). Otherwise, proceed to [Installing the Azure CLI](./install-azure-cli.md). diff --git a/docs/azure/configure-vs-code.md b/docs/azure/configure-vs-code.md index 4ef08b781c851..97ddd4df0010a 100644 --- a/docs/azure/configure-vs-code.md +++ b/docs/azure/configure-vs-code.md @@ -4,8 +4,7 @@ description: This article helps you configure Visual Studio Code for Azure devel ms.date: 11/30/2020 ms.topic: conceptual ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 recommendations: false --- diff --git a/docs/azure/create-azure-account.md b/docs/azure/create-azure-account.md index b87b6ce1ca2b0..1b40bb2b033ee 100644 --- a/docs/azure/create-azure-account.md +++ b/docs/azure/create-azure-account.md @@ -4,8 +4,7 @@ description: To use Azure, you need an Azure account. This article covers the t ms.date: 11/30/2020 ms.topic: conceptual ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 recommendations: false --- diff --git a/docs/azure/dotnet-dev-env-checklist.md b/docs/azure/dotnet-dev-env-checklist.md index 59697b366772e..c81ace9d65fcb 100644 --- a/docs/azure/dotnet-dev-env-checklist.md +++ b/docs/azure/dotnet-dev-env-checklist.md @@ -4,8 +4,7 @@ description: Provides a quick summary of all the tools you should have installed ms.date: 1/1/2021 ms.topic: conceptual ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 --- # .NET on Azure development environment checklist diff --git a/docs/azure/includes/dotnet-all.md b/docs/azure/includes/dotnet-all.md index 10ae1cac79302..d71d68716a524 100644 --- a/docs/azure/includes/dotnet-all.md +++ b/docs/azure/includes/dotnet-all.md @@ -7,9 +7,9 @@ | ASP.NET Extension - DataProtection Keys | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Extensions.AspNetCore.DataProtection.Keys/1.1.0) | [docs](/dotnet/api/overview/azure/Extensions.AspNetCore.DataProtection.Keys-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Extensions.AspNetCore.DataProtection.Keys_1.1.0/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/) | | Attestation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Security.Attestation/1.0.0) | [docs](/dotnet/api/overview/azure/Security.Attestation-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.Attestation_1.0.0/sdk/attestation/Azure.Security.Attestation/) | | Azure Mixed Reality Authentication | NuGet [1.0.1](https://www.nuget.org/packages/Azure.MixedReality.Authentication/1.0.1) | [docs](/dotnet/api/overview/azure/MixedReality.Authentication-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.Authentication_1.0.1/sdk/mixedreality/Azure.MixedReality.Authentication/) | -| Azure Object Anchors Conversion | NuGet [0.3.0-beta.2](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.2) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme-pre) | GitHub [0.3.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.2/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | +| Azure Object Anchors Conversion | NuGet [0.3.0-beta.3](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.3) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme-pre) | GitHub [0.3.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.3/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | | Azure Remote Rendering | NuGet [1.1.0](https://www.nuget.org/packages/Azure.MixedReality.RemoteRendering/1.1.0) | [docs](/dotnet/api/overview/azure/MixedReality.RemoteRendering-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.RemoteRendering_1.1.0/sdk/remoterendering/Azure.MixedReality.RemoteRendering/) | -| Azure Video Analyzer Edge | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Media.VideoAnalyzer.Edge/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Media.VideoAnalyzer.Edge-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Media.VideoAnalyzer.Edge_1.0.0-beta.5/sdk/videoanalyzer/Azure.Media.VideoAnalyzer.Edge/) | +| Azure Video Analyzer Edge | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.Media.VideoAnalyzer.Edge/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/Media.VideoAnalyzer.Edge-readme-pre) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Media.VideoAnalyzer.Edge_1.0.0-beta.6/sdk/videoanalyzer/Azure.Media.VideoAnalyzer.Edge/) | | Azure.Analytics.Purview.Administration | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Analytics.Purview.Administration/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Analytics.Purview.Administration-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Purview.Administration_1.0.0-beta.1/sdk/purview/Azure.Analytics.Purview.Administration/) | | Azure.Identity.BrokeredAuthentication | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Identity.BrokeredAuthentication/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Identity.BrokeredAuthentication-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity.BrokeredAuthentication_1.0.0-beta.2/sdk/identity/Azure.Identity.BrokeredAuthentication/) | | Cognitive Search | NuGet [11.3.0](https://www.nuget.org/packages/Azure.Search.Documents/11.3.0)
NuGet [11.4.0-beta.7](https://www.nuget.org/packages/Azure.Search.Documents/11.4.0-beta.7) | [docs](/dotnet/api/overview/azure/Search.Documents-readme) | GitHub [11.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.3.0/sdk/search/Azure.Search.Documents/)
GitHub [11.4.0-beta.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.4.0-beta.7/sdk/search/Azure.Search.Documents/) | @@ -21,18 +21,18 @@ | Communication SMS | NuGet [1.0.1](https://www.nuget.org/packages/Azure.Communication.Sms/1.0.1) | [docs](/dotnet/api/overview/azure/Communication.Sms-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Communication.Sms_1.0.1/sdk/communication/Azure.Communication.Sms/) | | ConfidentialLedger | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Security.ConfidentialLedger/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Security.ConfidentialLedger-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.ConfidentialLedger_1.0.0-beta.2/sdk/confidentialledger/Azure.Security.ConfidentialLedger/) | | Container Registry | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Containers.ContainerRegistry/1.0.0)
NuGet [1.1.0-beta.4](https://www.nuget.org/packages/Azure.Containers.ContainerRegistry/1.1.0-beta.4) | [docs](/dotnet/api/overview/azure/Containers.ContainerRegistry-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Containers.ContainerRegistry_1.0.0/sdk/containerregistry/Azure.Containers.ContainerRegistry/)
GitHub [1.1.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Containers.ContainerRegistry_1.1.0-beta.4/sdk/containerregistry/Azure.Containers.ContainerRegistry/) | -| Conversation Analysis | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.0.0-beta.2/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | +| Conversation Analysis | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.0.0-beta.3/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | | Core | NuGet [1.24.0](https://www.nuget.org/packages/Azure.Core/1.24.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.24.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.24.0/sdk/core/Azure.Core/) | | Core - AMQP | NuGet [1.2.0](https://www.nuget.org/packages/Azure.Core.Amqp/1.2.0) | [docs](/dotnet/api/overview/azure/Core.Amqp-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Amqp_1.2.0/sdk/core/Azure.Core.Amqp/) | | Cosmos DB | NuGet [4.0.0-preview3](https://www.nuget.org/packages/Azure.Cosmos/4.0.0-preview3) | [docs](/dotnet/api/azure.cosmos) | GitHub [4.0.0-preview3](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/releases/4.0.0-preview3) | | Digital Twins - Core | NuGet [1.2.2](https://www.nuget.org/packages/Azure.DigitalTwins.Core/1.2.2)
NuGet [1.4.0-beta.1](https://www.nuget.org/packages/Azure.DigitalTwins.Core/1.4.0-beta.1) | [docs](/dotnet/api/overview/azure/DigitalTwins.Core-readme) | GitHub [1.2.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.DigitalTwins.Core_1.2.2/sdk/digitaltwins/Azure.DigitalTwins.Core/)
GitHub [1.4.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.DigitalTwins.Core_1.4.0-beta.1/sdk/digitaltwins/Azure.DigitalTwins.Core/) | -| Document Translation | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.AI.Translation.Document/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/AI.Translation.Document-readme-pre) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Document_1.0.0-beta.6/sdk/translation/Azure.AI.Translation.Document/) | -| Event Grid | NuGet [4.10.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.10.0)
NuGet [4.11.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.11.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid-readme) | GitHub [4.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.10.0/sdk/eventgrid/Azure.Messaging.EventGrid/)
GitHub [4.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.11.0-beta.1/sdk/eventgrid/Azure.Messaging.EventGrid/) | -| Event Hubs | NuGet [5.6.2](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.6.2)
NuGet [5.7.0-beta.5](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.7.0-beta.5) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs-readme) | GitHub [5.6.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.6.2/sdk/eventhub/Azure.Messaging.EventHubs/)
GitHub [5.7.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.7.0-beta.5/sdk/eventhub/Azure.Messaging.EventHubs/) | -| Event Hubs - Event Processor | NuGet [5.6.2](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.6.2)
NuGet [5.7.0-beta.5](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.7.0-beta.5) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs.Processor-readme) | GitHub [5.6.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.6.2/sdk/eventhub/Azure.Messaging.EventHubs.Processor/)
GitHub [5.7.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.7.0-beta.5/sdk/eventhub/Azure.Messaging.EventHubs.Processor/) | -| Extensions - Azure | NuGet [1.1.1](https://www.nuget.org/packages/Microsoft.Extensions.Azure/1.1.1) | | GitHub [1.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Extensions.Azure_1.1.1/sdk/extensions/Microsoft.Extensions.Azure/) | +| Document Translation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Translation.Document/1.0.0) | [docs](/dotnet/api/overview/azure/AI.Translation.Document-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Document_1.0.0/sdk/translation/Azure.AI.Translation.Document/) | +| Event Grid | NuGet [4.10.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.10.0)
NuGet [4.11.0-beta.2](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.11.0-beta.2) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid-readme) | GitHub [4.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.10.0/sdk/eventgrid/Azure.Messaging.EventGrid/)
GitHub [4.11.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.11.0-beta.2/sdk/eventgrid/Azure.Messaging.EventGrid/) | +| Event Hubs | NuGet [5.7.0](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.7.0) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs-readme) | GitHub [5.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.7.0/sdk/eventhub/Azure.Messaging.EventHubs/) | +| Event Hubs - Event Processor | NuGet [5.7.0](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.7.0) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs.Processor-readme) | GitHub [5.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.7.0/sdk/eventhub/Azure.Messaging.EventHubs.Processor/) | +| Extensions - Azure | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Extensions.Azure/1.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Extensions.Azure-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Extensions.Azure_1.2.0/sdk/extensions/Microsoft.Extensions.Azure/) | | FarmBeats | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Verticals.AgriFood.Farming/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Verticals.AgriFood.Farming-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Verticals.AgriFood.Farming_1.0.0-beta.1/sdk/farmbeats/Azure.Verticals.AgriFood.Farming/) | -| Form Recognizer | NuGet [3.1.1](https://www.nuget.org/packages/Azure.AI.FormRecognizer/3.1.1)
NuGet [4.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.FormRecognizer/4.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.FormRecognizer-readme) | GitHub [3.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_3.1.1/sdk/formrecognizer/Azure.AI.FormRecognizer/)
GitHub [4.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_4.0.0-beta.3/sdk/formrecognizer/Azure.AI.FormRecognizer/) | +| Form Recognizer | NuGet [3.1.1](https://www.nuget.org/packages/Azure.AI.FormRecognizer/3.1.1)
NuGet [4.0.0-beta.4](https://www.nuget.org/packages/Azure.AI.FormRecognizer/4.0.0-beta.4) | [docs](/dotnet/api/overview/azure/AI.FormRecognizer-readme) | GitHub [3.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_3.1.1/sdk/formrecognizer/Azure.AI.FormRecognizer/)
GitHub [4.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_4.0.0-beta.4/sdk/formrecognizer/Azure.AI.FormRecognizer/) | | Identity | NuGet [1.6.0](https://www.nuget.org/packages/Azure.Identity/1.6.0) | [docs](/dotnet/api/overview/azure/Identity-readme) | GitHub [1.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity_1.6.0/sdk/identity/Azure.Identity/) | | IoT Device Update | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.IoT.DeviceUpdate/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/IoT.DeviceUpdate-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.IoT.DeviceUpdate_1.0.0-beta.3/sdk/deviceupdate/Azure.IoT.DeviceUpdate/) | | Key Vault - Administration | NuGet [4.1.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Administration/4.1.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Administration-readme) | GitHub [4.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Administration_4.1.0/sdk/keyvault/Azure.Security.KeyVault.Administration/) | @@ -48,62 +48,68 @@ | Purview Catalog | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Purview.Catalog/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Purview.Catalog-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Purview.Catalog_1.0.0-beta.3/sdk/purview/Azure.Analytics.Purview.Catalog/) | | Purview Scanning | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Analytics.Purview.Scanning/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Analytics.Purview.Scanning-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Purview.Scanning_1.0.0-beta.2/sdk/purview/Azure.Analytics.Purview.Scanning/) | | Question Answering | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Language.QuestionAnswering/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Azure.AI.Language.QuestionAnswering/1.1.0-beta.1) | [docs](/dotnet/api/overview/azure/AI.Language.QuestionAnswering-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.QuestionAnswering_1.0.0/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.QuestionAnswering_1.1.0-beta.1/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/) | -| Schema Registry | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Data.SchemaRegistry/1.1.0) | [docs](/dotnet/api/overview/azure/Data.SchemaRegistry-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.SchemaRegistry_1.1.0/sdk/schemaregistry/Azure.Data.SchemaRegistry/) | -| Schema Registry - Avro | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro_1.0.0-beta.8/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/) | -| Service Bus | NuGet [7.7.0](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.7.0)
NuGet [7.8.0-beta.2](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.8.0-beta.2) | [docs](/dotnet/api/overview/azure/Messaging.ServiceBus-readme) | GitHub [7.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.7.0/sdk/servicebus/Azure.Messaging.ServiceBus/)
GitHub [7.8.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.8.0-beta.2/sdk/servicebus/Azure.Messaging.ServiceBus/) | -| Storage - Blobs | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Storage.Blobs/12.11.0)
NuGet [12.12.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Blobs/12.12.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.11.0/sdk/storage/Azure.Storage.Blobs/)
GitHub [12.12.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.12.0-beta.1/sdk/storage/Azure.Storage.Blobs/) | -| Storage - Blobs Batch | NuGet [12.8.0](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.8.0)
NuGet [12.9.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.9.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.8.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.8.0/sdk/storage/Azure.Storage.Blobs.Batch/)
GitHub [12.9.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.9.0-beta.1/sdk/storage/Azure.Storage.Blobs.Batch/) | -| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.23](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.23) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme-pre) | GitHub [12.0.0-preview.23](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.23/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) | -| Storage - Common | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Common/12.10.0)
NuGet [12.11.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Common/12.11.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.10.0/sdk/storage/Azure.Storage.Common/)
GitHub [12.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.11.0-beta.1/sdk/storage/Azure.Storage.Common/) | -| Storage - Files Data Lake | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.9.0/sdk/storage/Azure.Storage.Files.DataLake/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.10.0-beta.1/sdk/storage/Azure.Storage.Files.DataLake/) | -| Storage - Files Shares | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.9.0/sdk/storage/Azure.Storage.Files.Shares/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.10.0-beta.1/sdk/storage/Azure.Storage.Files.Shares/) | -| Storage - Queues | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Queues/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.9.0/sdk/storage/Azure.Storage.Queues/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.10.0-beta.1/sdk/storage/Azure.Storage.Queues/) | +| Schema Registry | NuGet [1.2.0](https://www.nuget.org/packages/Azure.Data.SchemaRegistry/1.2.0) | [docs](/dotnet/api/overview/azure/Data.SchemaRegistry-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.SchemaRegistry_1.2.0/sdk/schemaregistry/Azure.Data.SchemaRegistry/) | +| Schema Registry - Avro | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/1.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro_1.0.0/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/) | +| Service Bus | NuGet [7.8.1](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.8.1)
NuGet [7.9.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.9.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.ServiceBus-readme) | GitHub [7.8.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.8.1/sdk/servicebus/Azure.Messaging.ServiceBus/)
GitHub [7.9.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.9.0-beta.1/sdk/servicebus/Azure.Messaging.ServiceBus/) | +| Storage - Blobs | NuGet [12.12.0](https://www.nuget.org/packages/Azure.Storage.Blobs/12.12.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.12.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.12.0/sdk/storage/Azure.Storage.Blobs/) | +| Storage - Blobs Batch | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.9.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.9.0/sdk/storage/Azure.Storage.Blobs.Batch/) | +| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.25](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.25) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme-pre) | GitHub [12.0.0-preview.25](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.25/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) | +| Storage - Common | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Storage.Common/12.11.0) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.11.0/sdk/storage/Azure.Storage.Common/) | +| Storage - Files Data Lake | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.10.0/sdk/storage/Azure.Storage.Files.DataLake/) | +| Storage - Files Shares | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.10.0/sdk/storage/Azure.Storage.Files.Shares/) | +| Storage - Queues | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.10.0/sdk/storage/Azure.Storage.Queues/) | | Synapse - AccessControl | NuGet [1.0.0-preview.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.AccessControl/1.0.0-preview.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.AccessControl-readme-pre) | GitHub [1.0.0-preview.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.AccessControl_1.0.0-preview.5/sdk/synapse/Azure.Analytics.Synapse.AccessControl/) | -| Synapse - Artifacts | NuGet [1.0.0-preview.14](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.14) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme-pre) | GitHub [1.0.0-preview.14](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.14/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | +| Synapse - Artifacts | NuGet [1.0.0-preview.15](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.15) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme-pre) | GitHub [1.0.0-preview.15](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.15/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | | Synapse - Managed Private Endpoints | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.ManagedPrivateEndpoints/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.ManagedPrivateEndpoints-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.ManagedPrivateEndpoints_1.0.0-beta.5/sdk/synapse/Azure.Analytics.Synapse.ManagedPrivateEndpoints/) | | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme-pre) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | -| Tables | NuGet [12.5.0](https://www.nuget.org/packages/Azure.Data.Tables/12.5.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.5.0/sdk/tables/Azure.Data.Tables/) | -| Text Analytics | NuGet [5.1.1](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.1.1)
NuGet [5.2.0-beta.2](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.2.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.1.1/sdk/textanalytics/Azure.AI.TextAnalytics/)
GitHub [5.2.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.2.0-beta.2/sdk/textanalytics/Azure.AI.TextAnalytics/) | +| Tables | NuGet [12.6.0](https://www.nuget.org/packages/Azure.Data.Tables/12.6.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.6.0/sdk/tables/Azure.Data.Tables/) | +| Text Analytics | NuGet [5.1.1](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.1.1)
NuGet [5.2.0-beta.3](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.2.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.1.1/sdk/textanalytics/Azure.AI.TextAnalytics/)
GitHub [5.2.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.2.0-beta.3/sdk/textanalytics/Azure.AI.TextAnalytics/) | | Web PubSub | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Messaging.WebPubSub/1.0.0) | [docs](/dotnet/api/overview/azure/Messaging.WebPubSub-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.WebPubSub_1.0.0/sdk/webpubsub/Azure.Messaging.WebPubSub/) | | Azure Functions extension for Azure Table service | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Tables/1.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Tables-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.Tables_1.0.0/sdk/tables/Microsoft.Azure.WebJobs.Extensions.Tables/) | | CloudNative CloudEvents with Event Grid | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents/1.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents_1.0.0/sdk/eventgrid/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents/) | | Core Spatial | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial/1.1.0)
NuGet [1.2.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial/1.2.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Core.Spatial-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial_1.1.0/sdk/core/Microsoft.Azure.Core.Spatial/)
GitHub [1.2.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial_1.2.0-beta.1/sdk/core/Microsoft.Azure.Core.Spatial/) | | Core Spatial Newtonsoft Json | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial.NewtonsoftJson/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial.NewtonsoftJson/1.1.0-beta.1) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial.NewtonsoftJson_1.0.0/sdk/core/Microsoft.Azure.Core.Spatial.NewtonsoftJson/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial.NewtonsoftJson_1.1.0-beta.1/sdk/core/Microsoft.Azure.Core.Spatial.NewtonsoftJson/) | -| WebJobs Extensions - Event Grid | NuGet [3.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.1.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventGrid-readme) | GitHub [3.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventGrid_3.1.0/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/) | -| WebJobs Extensions - Event Hubs | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventHubs/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventHubs-readme) | GitHub [5.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventHubs_5.0.1/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/) | -| WebJobs Extensions - Service Bus | NuGet [5.3.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.3.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.ServiceBus-readme) | GitHub [5.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.ServiceBus_5.3.0/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/) | +| WebJobs Extensions - Event Grid | NuGet [3.2.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventGrid-readme) | GitHub [3.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventGrid_3.2.0/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/) | +| WebJobs Extensions - Event Hubs | NuGet [5.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventHubs/5.1.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventHubs-readme) | GitHub [5.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventHubs_5.1.0/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/) | +| WebJobs Extensions - Service Bus | NuGet [5.5.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.5.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.ServiceBus-readme) | GitHub [5.5.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.ServiceBus_5.5.1/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/) | | WebJobs Extensions - SignalR Service | NuGet [1.8.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.SignalRService/1.8.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.SignalRService-readme) | GitHub [1.8.0](https://github.com/Azure/azure-functions-signalrservice-extension/tree/v1.2.0/src/SignalRServiceExtension) | -| WebJobs Extensions - Storage | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage/5.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage-readme) | GitHub [5.0.0](https://github.com/Azure/azure-webjobs-sdk/tree/master/src/Microsoft.Azure.WebJobs.Extensions.Storage) | +| WebJobs Extensions - Storage | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage-readme) | GitHub [5.0.1](https://github.com/Azure/azure-webjobs-sdk/tree/master/src/Microsoft.Azure.WebJobs.Extensions.Storage) | | WebJobs Extensions - Web PubSub | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.WebPubSub/1.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.WebPubSub-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.WebPubSub_1.2.0/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSub/) | -| Grafana | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.0.0-beta.1) | | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.0.0-beta.1/sdk/grafana/Azure.ResourceManager.Grafana/) | | Resource Management - App Configuration | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.AppConfiguration/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.AppConfiguration-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.AppConfiguration_1.0.0-beta.4/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/) | | Resource Management - App Service | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.AppService/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.AppService-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.AppService_1.0.0-beta.2/sdk/websites/Azure.ResourceManager.AppService/) | -| Resource Management - Azure Stack HCI | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.0.0-beta.3/sdk/azurestackhci/Azure.ResourceManager.Hci/) | +| Resource Management - Azure Stack HCI | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.0.0-beta.4/sdk/azurestackhci/Azure.ResourceManager.Hci/) | | Resource Management - Cdn | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.Cdn/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.Cdn-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Cdn_1.0.0-beta.5/sdk/cdn/Azure.ResourceManager.Cdn/) | | Resource Management - Communication | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.0.0)
NuGet [1.1.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.1.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Communication-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.0.0/sdk/communication/Azure.ResourceManager.Communication/)
GitHub [1.1.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.1.0-beta.3/sdk/communication/Azure.ResourceManager.Communication/) | | Resource Management - Compute | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Compute/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Compute-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Compute_1.0.0-beta.8/sdk/compute/Azure.ResourceManager.Compute/) | | Resource Management - Connected VMware vSphere | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ConnectedVMwarevSphere/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ConnectedVMwarevSphere-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ConnectedVMwarevSphere_1.0.0-beta.4/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/) | -| Resource Management - Core | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.0.0/sdk/resourcemanager/Azure.ResourceManager/) | +| Resource Management - Container Apps | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Applications.Containers/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Applications.Containers-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Applications.Containers_1.0.0-beta.1/sdk/containerapps/Azure.ResourceManager.Applications.Containers/) | +| Resource Management - Core | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.1.0/sdk/resourcemanager/Azure.ResourceManager/) | | Resource Management - Cosmos DB | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.CosmosDB/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.CosmosDB-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.CosmosDB_1.0.0-beta.5/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/) | | Resource Management - Device Update | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.DeviceUpdate/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.DeviceUpdate-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.DeviceUpdate_1.0.0-beta.4/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/) | | Resource Management - DNS | NuGet [1.0.0-preview.1](https://www.nuget.org/packages/Azure.ResourceManager.Dns/1.0.0-preview.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Dns-readme-pre) | GitHub [1.0.0-preview.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Dns_1.0.0-preview.1/sdk/dns/Azure.ResourceManager.Dns/) | | Resource Management - Dns Resolver | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.DnsResolver/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.DnsResolver-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.DnsResolver_1.0.0-beta.3/sdk/dnsresolver/Azure.ResourceManager.DnsResolver/) | +| Resource Management - Dynatrace | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Dynatrace/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Dynatrace-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Dynatrace_1.0.0-beta.1/sdk/dynatrace/Azure.ResourceManager.Dynatrace/) | | Resource Management - Edge Order | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.EdgeOrder/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.EdgeOrder-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.EdgeOrder_1.0.0-beta.3/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/) | | Resource Management - Event Hubs | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.EventHubs/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.EventHubs-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.EventHubs_1.0.0-beta.4/sdk/eventhub/Azure.ResourceManager.EventHubs/) | | Resource Management - Extended Location | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.ExtendedLocation/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.ExtendedLocation-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ExtendedLocation_1.0.0-beta.2/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocation/) | +| Resource Management - Grafana | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Grafana-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.0.0-beta.1/sdk/grafana/Azure.ResourceManager.Grafana/) | +| Resource Management - IotCentral | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.IotCentral/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.IotCentral-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.IotCentral_1.0.0-beta.1/sdk/iotcentral/Azure.ResourceManager.IotCentral/) | | Resource Management - Key Vault | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.KeyVault/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.KeyVault-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.KeyVault_1.0.0-beta.8/sdk/keyvault/Azure.ResourceManager.KeyVault/) | +| Resource Management - Machine Learning | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearning/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearning-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MachineLearning_1.0.0-beta.1/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/) | | Resource Management - Monitor | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.Monitor/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.Monitor-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Monitor_1.0.0-beta.2/sdk/monitor/Azure.ResourceManager.Monitor/) | | Resource Management - Network | NuGet [1.0.0-beta.7](https://www.nuget.org/packages/Azure.ResourceManager.Network/1.0.0-beta.7) | [docs](/dotnet/api/overview/azure/ResourceManager.Network-readme-pre) | GitHub [1.0.0-beta.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Network_1.0.0-beta.7/sdk/network/Azure.ResourceManager.Network/) | -| Resource Management - Resources | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.0.0/sdk/resources/Azure.ResourceManager.Resources/) | +| Resource Management - Resources | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.1.0/sdk/resources/Azure.ResourceManager.Resources/) | | Resource Management - Service Bus | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ServiceBus/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ServiceBus-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ServiceBus_1.0.0-beta.4/sdk/servicebus/Azure.ResourceManager.ServiceBus/) | -| Resource Management - Sql | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Sql/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Sql-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Sql_1.0.0-beta.4/sdk/sqlmanagement/Azure.ResourceManager.Sql/) | -| Resource Management - Storage | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Storage/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Storage-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Storage_1.0.0-beta.8/sdk/storage/Azure.ResourceManager.Storage/) | +| Resource Management - Service Linker | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.ServiceLinker/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.ServiceLinker-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ServiceLinker_1.0.0-beta.1/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/) | +| Resource Management - Sql | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.Sql/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.Sql-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Sql_1.0.0-beta.5/sdk/sqlmanagement/Azure.ResourceManager.Sql/) | +| Resource Management - Storage | NuGet [1.0.0-beta.9](https://www.nuget.org/packages/Azure.ResourceManager.Storage/1.0.0-beta.9) | [docs](/dotnet/api/overview/azure/ResourceManager.Storage-readme-pre) | GitHub [1.0.0-beta.9](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Storage_1.0.0-beta.9/sdk/storage/Azure.ResourceManager.Storage/) | | Resource Management - Storage Pool | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.StoragePool/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.StoragePool-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.StoragePool_1.0.0-beta.3/sdk/storagepool/Azure.ResourceManager.StoragePool/) | | Resource Management - Web PubSub | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.WebPubSub/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.WebPubSub-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WebPubSub_1.0.0-beta.4/sdk/webpubsub/Azure.ResourceManager.WebPubSub/) | | Azure.Communication.Administration | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Communication.Administration/1.0.0-beta.3) | | | -| Azure.Communication.Calling | NuGet [1.0.0-beta.31](https://www.nuget.org/packages/Azure.Communication.Calling/1.0.0-beta.31) | | | +| Azure.Communication.Calling | NuGet [1.0.0-beta.32](https://www.nuget.org/packages/Azure.Communication.Calling/1.0.0-beta.32) | | | | Azure.Communication.CallingServer | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Communication.CallingServer/1.0.0-beta.3) | | | +| Azure.Communication.Email | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Communication.Email/1.0.0-beta.1) | | | | Azure.IoT.TimeSeriesInsights | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.IoT.TimeSeriesInsights/1.0.0-beta.1) | | | | Azure.Quantum.Jobs | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Quantum.Jobs/1.0.0-beta.3) | | | | IoT Models Repository | NuGet [1.0.0-preview.5](https://www.nuget.org/packages/Azure.IoT.ModelsRepository/1.0.0-preview.5) | | | @@ -111,33 +117,36 @@ | Microsoft.Azure.Cosmos.Templates | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Templates/1.0.0) | | | | Microsoft.Azure.Functions.Analyzers | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Analyzers/1.0.0) | | | | Microsoft.Azure.Functions.Authentication.WebAssembly | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Authentication.WebAssembly/1.0.0)
NuGet [1.0.1-preview](https://www.nuget.org/packages/Microsoft.Azure.Functions.Authentication.WebAssembly/1.0.1-preview) | | | -| Microsoft.Azure.Functions.Worker.Core | NuGet [1.4.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Core/1.4.0)
NuGet [1.5.0-preview1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Core/1.5.0-preview1) | | | +| Microsoft.Azure.Functions.Worker.Core | NuGet [1.4.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Core/1.4.0)
NuGet [1.6.0-preview3](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Core/1.6.0-preview3) | | | | Microsoft.Azure.Functions.Worker.Extensions.Abstractions | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Abstractions/1.1.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights | NuGet [1.0.0-preview4](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights/1.0.0-preview4) | | | | Microsoft.Azure.Functions.Worker.Extensions.CosmosDB | NuGet [3.0.9](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.CosmosDB/3.0.9)
NuGet [4.0.0-preview2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.CosmosDB/4.0.0-preview2) | | | -| Microsoft.Azure.Functions.Worker.Extensions.EventGrid | NuGet [2.1.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.EventGrid/2.1.0)
NuGet [3.0.0-beta.3](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.EventGrid/3.0.0-beta.3) | | | -| Microsoft.Azure.Functions.Worker.Extensions.EventHubs | NuGet [4.2.1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.EventHubs/4.2.1)
NuGet [5.0.0-beta.6](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.EventHubs/5.0.0-beta.6) | | | +| Microsoft.Azure.Functions.Worker.Extensions.DurableTask | NuGet [0.4.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.DurableTask/0.4.1-beta) | | | +| Microsoft.Azure.Functions.Worker.Extensions.EventGrid | NuGet [3.2.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.EventGrid/3.2.0) | | | +| Microsoft.Azure.Functions.Worker.Extensions.EventHubs | NuGet [5.1.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.EventHubs/5.1.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.Http | NuGet [3.0.13](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Http/3.0.13) | | | -| Microsoft.Azure.Functions.Worker.Extensions.Kafka | NuGet [3.3.2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Kafka/3.3.2) | | | +| Microsoft.Azure.Functions.Worker.Extensions.Kafka | NuGet [3.4.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Kafka/3.4.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.OpenApi | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/1.3.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.RabbitMQ | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.RabbitMQ/1.1.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.SendGrid | NuGet [3.0.2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.SendGrid/3.0.2) | | | -| Microsoft.Azure.Functions.Worker.Extensions.ServiceBus | NuGet [4.2.1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus/4.2.1)
NuGet [5.0.0-beta.6](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus/5.0.0-beta.6) | | | +| Microsoft.Azure.Functions.Worker.Extensions.ServiceBus | NuGet [5.4.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus/5.4.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.SignalRService | NuGet [1.7.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.SignalRService/1.7.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.Storage | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Storage/5.0.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs/5.0.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues/5.0.0) | | | +| Microsoft.Azure.Functions.Worker.Extensions.Storage.Tables | NuGet [1.0.0-preview1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Storage.Tables/1.0.0-preview1) | | | | Microsoft.Azure.Functions.Worker.Extensions.Timer | NuGet [4.1.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Timer/4.1.0) | | | | Microsoft.Azure.Functions.Worker.Extensions.Warmup | NuGet [4.0.2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Warmup/4.0.2) | | | -| Microsoft.Azure.Functions.Worker.Grpc | NuGet [1.3.1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Grpc/1.3.1)
NuGet [1.4.0-preview1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Grpc/1.4.0-preview1) | | | -| Microsoft.Azure.Functions.Worker.ItemTemplates | NuGet [4.0.2057](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ItemTemplates/4.0.2057) | | | -| Microsoft.Azure.Functions.Worker.ProjectTemplates | NuGet [4.0.2057](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ProjectTemplates/4.0.2057) | | | +| Microsoft.Azure.Functions.Worker.Grpc | NuGet [1.3.1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Grpc/1.3.1)
NuGet [1.4.1-preview3](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Grpc/1.4.1-preview3) | | | +| Microsoft.Azure.Functions.Worker.ItemTemplates | NuGet [4.0.2185](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ItemTemplates/4.0.2185) | | | +| Microsoft.Azure.Functions.Worker.ProjectTemplates | NuGet [4.0.2185](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ProjectTemplates/4.0.2185) | | | | Microsoft.Azure.Functions.Worker.Sdk.Analyzers | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk.Analyzers/1.1.0) | | | +| Microsoft.Azure.Functions.Worker.Sdk.Generators | NuGet [1.0.0-preview1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk.Generators/1.0.0-preview1) | | | | Microsoft.Azure.IoT.Edge.Function | NuGet [3.5.3](https://www.nuget.org/packages/Microsoft.Azure.IoT.Edge.Function/3.5.3) | | | | Microsoft.Azure.IoT.Edge.Module | NuGet [3.1.1](https://www.nuget.org/packages/Microsoft.Azure.IoT.Edge.Module/3.1.1) | | | | Microsoft.Azure.Management.ChangeAnalysis | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.ChangeAnalysis/1.0.0) | | | -| Microsoft.Azure.Management.Chaos | NuGet [0.9.15-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Chaos/0.9.15-preview) | | | -| Microsoft.Azure.Management.DataProtection.Backup | NuGet [2.0.0.1](https://www.nuget.org/packages/Microsoft.Azure.Management.DataProtection.Backup/2.0.0.1) | | | +| Microsoft.Azure.Management.Chaos | NuGet [0.9.15-preview.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Chaos/0.9.15-preview.1) | | | +| Microsoft.Azure.Management.DataProtection.Backup | NuGet [2.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.DataProtection.Backup/2.1.0) | | | | Microsoft.Azure.Management.DeviceUpdate | NuGet [1.0.1-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Management.DeviceUpdate/1.0.1-beta.1) | | | | Microsoft.Azure.Management.Elastic | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Elastic/1.0.0-beta.1) | | | | Microsoft.Azure.Management.ExtendedLocation | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.ExtendedLocation/1.0.0) | | | @@ -164,11 +173,11 @@ | Microsoft.Azure.Management.Quota | NuGet [1.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Quota/1.0.0-preview) | | | | Microsoft.Azure.Management.ServiceFabricManagedClusters | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.ServiceFabricManagedClusters/1.0.0) | | | | Microsoft.Azure.Management.StoragePool | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.StoragePool/1.0.0) | | | -| Microsoft.Azure.Management.VideoAnalyzer | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Microsoft.Azure.Management.VideoAnalyzer/1.0.0-beta.2) | | | +| Microsoft.Azure.Management.VideoAnalyzer | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Microsoft.Azure.Management.VideoAnalyzer/1.0.0-beta.3) | | | | Microsoft.Azure.ServiceBus.EventProcessorHost | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.ServiceBus.EventProcessorHost/5.0.1) | | | | Microsoft.Azure.SignalR.Emulator | NuGet [1.0.0-preview1-10809](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Emulator/1.0.0-preview1-10809) | | | | Microsoft.Azure.WebJobs.Extensions.ApplicationInsights | NuGet [1.0.0-preview4](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ApplicationInsights/1.0.0-preview4) | | | -| Microsoft.Azure.WebJobs.Extensions.Sql | NuGet [0.1.286-preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Sql/0.1.286-preview) | | | +| Microsoft.Azure.WebJobs.Extensions.Sql | NuGet [0.1.346-preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Sql/0.1.346-preview) | | | | Microsoft.Azure.WebJobs.Extensions.Timers.Storage | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Timers.Storage/1.0.0-beta.1) | | | | Microsoft.Azure.WebPubSub.AspNetCore | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Microsoft.Azure.WebPubSub.AspNetCore/1.0.0-beta.3) | | | | Microsoft.Azure.WebPubSub.Common | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebPubSub.Common/1.1.0) | | | @@ -190,10 +199,10 @@ | Azure Active Directory - App Authentication | NuGet [1.6.2](https://www.nuget.org/packages/Microsoft.Azure.Services.AppAuthentication/1.6.2) | | | | Azure Mixed Reality Authentication | NuGet [1.0.1](https://www.nuget.org/packages/Azure.MixedReality.Authentication/1.0.1) | [docs](/dotnet/api/overview/azure/MixedReality.Authentication-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.Authentication_1.0.1/sdk/mixedreality/Azure.MixedReality.Authentication/) | | Azure Monitor Exporter for OpenTelemetry | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Microsoft.OpenTelemetry.Exporter.AzureMonitor/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.OpenTelemetry.Exporter.AzureMonitor-readme-pre) | | -| Azure Object Anchors Conversion | NuGet [0.3.0-beta.2](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.2) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme-pre) | GitHub [0.3.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.2/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | +| Azure Object Anchors Conversion | NuGet [0.3.0-beta.3](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.3) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme-pre) | GitHub [0.3.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.3/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | | Azure Remote Rendering | NuGet [1.1.0](https://www.nuget.org/packages/Azure.MixedReality.RemoteRendering/1.1.0) | [docs](/dotnet/api/overview/azure/MixedReality.RemoteRendering-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.RemoteRendering_1.1.0/sdk/remoterendering/Azure.MixedReality.RemoteRendering/) | | Azure Stack - Azure Consistent Storage | NuGet [0.10.8-preview](https://www.nuget.org/packages/Microsoft.AzureStack.AzureConsistentStorage/0.10.8-preview) | | | -| Azure Video Analyzer Edge | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Media.VideoAnalyzer.Edge/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Media.VideoAnalyzer.Edge-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Media.VideoAnalyzer.Edge_1.0.0-beta.5/sdk/videoanalyzer/Azure.Media.VideoAnalyzer.Edge/) | +| Azure Video Analyzer Edge | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.Media.VideoAnalyzer.Edge/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/Media.VideoAnalyzer.Edge-readme-pre) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Media.VideoAnalyzer.Edge_1.0.0-beta.6/sdk/videoanalyzer/Azure.Media.VideoAnalyzer.Edge/) | | Azure.Analytics.Purview.Administration | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Analytics.Purview.Administration/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Analytics.Purview.Administration-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Purview.Administration_1.0.0-beta.1/sdk/purview/Azure.Analytics.Purview.Administration/) | | Azure.Identity.BrokeredAuthentication | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Identity.BrokeredAuthentication/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Identity.BrokeredAuthentication-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity.BrokeredAuthentication_1.0.0-beta.2/sdk/identity/Azure.Identity.BrokeredAuthentication/) | | Batch | NuGet [15.3.0](https://www.nuget.org/packages/Microsoft.Azure.Batch/15.3.0) | | GitHub [15.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Batch_15.3.0/sdk/batch/Microsoft.Azure.Batch/) | @@ -233,14 +242,14 @@ | Container Registry | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Containers.ContainerRegistry/1.0.0)
NuGet [1.1.0-beta.4](https://www.nuget.org/packages/Azure.Containers.ContainerRegistry/1.1.0-beta.4) | [docs](/dotnet/api/overview/azure/Containers.ContainerRegistry-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Containers.ContainerRegistry_1.0.0/sdk/containerregistry/Azure.Containers.ContainerRegistry/)
GitHub [1.1.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Containers.ContainerRegistry_1.1.0-beta.4/sdk/containerregistry/Azure.Containers.ContainerRegistry/) | | Container Registry | NuGet [1.0.0-preview.2](https://www.nuget.org/packages/Microsoft.Azure.ContainerRegistry/1.0.0-preview.2) | | GitHub [1.0.0-preview.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.ContainerRegistry_1.0.0-preview.2/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/) | | Content Moderator | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.ContentModerator/2.0.0) | | | -| Conversation Analysis | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.0.0-beta.2/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | +| Conversation Analysis | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.0.0-beta.3/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | | Core | NuGet [1.24.0](https://www.nuget.org/packages/Azure.Core/1.24.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.24.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.24.0/sdk/core/Azure.Core/) | | Core - AMQP | NuGet [1.2.0](https://www.nuget.org/packages/Azure.Core.Amqp/1.2.0) | [docs](/dotnet/api/overview/azure/Core.Amqp-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Amqp_1.2.0/sdk/core/Azure.Core.Amqp/) | | Cosmos DB | NuGet [4.0.0-preview3](https://www.nuget.org/packages/Azure.Cosmos/4.0.0-preview3) | [docs](/dotnet/api/azure.cosmos) | GitHub [4.0.0-preview3](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/releases/4.0.0-preview3) | -| Cosmos DB | NuGet [3.26.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.26.1) | [docs](/dotnet/api/overview/azure/cosmosdb) | GitHub [3.26.1](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/3.12.0/Microsoft.Azure.Cosmos) | +| Cosmos DB | NuGet [3.27.2](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.27.2) | [docs](/dotnet/api/overview/azure/cosmosdb) | GitHub [3.27.2](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/3.12.0/Microsoft.Azure.Cosmos) | | Cosmos DB - BulkExecutor | NuGet [2.5.1-preview](https://www.nuget.org/packages/Microsoft.Azure.CosmosDB.BulkExecutor/2.5.1-preview) | | GitHub [2.5.1-preview](https://github.com/Azure/azure-cosmosdb-bulkexecutor-dotnet-getting-started) | -| Cosmos DB - Direct | NuGet [3.28.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Direct/3.28.0) | | GitHub [3.28.0](https://github.com/Azure/azure-cosmos-dotnet-v3) | -| Cosmos DB - Encryption | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Encryption/1.0.0) | | GitHub [1.0.0](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/releases/encryption/1.0.0-preview4/Microsoft.Azure.Cosmos.Encryption) | +| Cosmos DB - Direct | NuGet [3.28.2](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Direct/3.28.2) | | GitHub [3.28.2](https://github.com/Azure/azure-cosmos-dotnet-v3) | +| Cosmos DB - Encryption | NuGet [1.0.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Encryption/1.0.1) | | GitHub [1.0.1](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/releases/encryption/1.0.0-preview4/Microsoft.Azure.Cosmos.Encryption) | | Custom Image Search | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Search.CustomImageSearch/2.0.0) | | | | Custom Search | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Search.CustomSearch/2.0.0) | | | | Custom Vision Prediction | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction/2.0.0) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction_2.0.0/sdk/cognitiveservices/Vision.CustomVision.Prediction) | @@ -248,25 +257,25 @@ | Data Lake Analytics | NuGet [1.4.211011](https://www.nuget.org/packages/Microsoft.Azure.DataLake.USQL.SDK/1.4.211011) | | | | Data Lake Storage | NuGet [1.2.5-alpha](https://www.nuget.org/packages/Microsoft.Azure.DataLake.Store/1.2.5-alpha) | [docs](/dotnet/api/overview/azure/data-lake-store) | GitHub [1.2.5-alpha](https://github.com/Azure/azure-data-lake-store-net/tree/1.2.3-alpha) | | DCAP | NuGet [1.10.0](https://www.nuget.org/packages/Microsoft.Azure.DCAP/1.10.0) | | GitHub [1.10.0](https://github.com/microsoft/Azure-DCAP-Client/tree/1.6) | -| Devices Client | NuGet [1.40.0](https://www.nuget.org/packages/Microsoft.Azure.Devices.Client/1.40.0)
NuGet [1.41.0-preview-001](https://www.nuget.org/packages/Microsoft.Azure.Devices.Client/1.41.0-preview-001) | | | +| Devices Client | NuGet [1.41.0](https://www.nuget.org/packages/Microsoft.Azure.Devices.Client/1.41.0)
NuGet [1.41.0-preview-001](https://www.nuget.org/packages/Microsoft.Azure.Devices.Client/1.41.0-preview-001) | | | | Digital Twins - Core | NuGet [1.2.2](https://www.nuget.org/packages/Azure.DigitalTwins.Core/1.2.2)
NuGet [1.4.0-beta.1](https://www.nuget.org/packages/Azure.DigitalTwins.Core/1.4.0-beta.1) | [docs](/dotnet/api/overview/azure/DigitalTwins.Core-readme) | GitHub [1.2.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.DigitalTwins.Core_1.2.2/sdk/digitaltwins/Azure.DigitalTwins.Core/)
GitHub [1.4.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.DigitalTwins.Core_1.4.0-beta.1/sdk/digitaltwins/Azure.DigitalTwins.Core/) | | Document DB | NuGet [2.18.0](https://www.nuget.org/packages/Microsoft.Azure.DocumentDB/2.18.0) | | GitHub [2.18.0](https://github.com/Azure/azure-cosmos-dotnet-v2) | | Document DB - Change Feed Processor | NuGet [2.4.0](https://www.nuget.org/packages/Microsoft.Azure.DocumentDB.ChangeFeedProcessor/2.4.0) | | GitHub [2.4.0](https://github.com/Azure/azure-documentdb-changefeedprocessor-dotnet/tree/master) | | Document DB - Core | NuGet [2.18.0](https://www.nuget.org/packages/Microsoft.Azure.DocumentDB.Core/2.18.0) | | GitHub [2.18.0](https://github.com/Azure/azure-cosmos-dotnet-v2) | -| Document Translation | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.AI.Translation.Document/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/AI.Translation.Document-readme-pre) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Document_1.0.0-beta.6/sdk/translation/Azure.AI.Translation.Document/) | +| Document Translation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Translation.Document/1.0.0) | [docs](/dotnet/api/overview/azure/AI.Translation.Document-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Document_1.0.0/sdk/translation/Azure.AI.Translation.Document/) | | Entity Search | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Search.EntitySearch/2.0.0) | | | -| Event Grid | NuGet [4.10.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.10.0)
NuGet [4.11.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.11.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid-readme) | GitHub [4.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.10.0/sdk/eventgrid/Azure.Messaging.EventGrid/)
GitHub [4.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.11.0-beta.1/sdk/eventgrid/Azure.Messaging.EventGrid/) | +| Event Grid | NuGet [4.10.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.10.0)
NuGet [4.11.0-beta.2](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.11.0-beta.2) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid-readme) | GitHub [4.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.10.0/sdk/eventgrid/Azure.Messaging.EventGrid/)
GitHub [4.11.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.11.0-beta.2/sdk/eventgrid/Azure.Messaging.EventGrid/) | | Event Grid | NuGet [3.2.1](https://www.nuget.org/packages/Microsoft.Azure.EventGrid/3.2.1) | [docs](/dotnet/api/overview/azure/eventgrid) | GitHub [3.2.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.EventGrid_3.2.1/sdk/eventgrid/Microsoft.Azure.EventGrid/) | -| Event Hubs | NuGet [5.6.2](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.6.2)
NuGet [5.7.0-beta.5](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.7.0-beta.5) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs-readme) | GitHub [5.6.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.6.2/sdk/eventhub/Azure.Messaging.EventHubs/)
GitHub [5.7.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.7.0-beta.5/sdk/eventhub/Azure.Messaging.EventHubs/) | +| Event Hubs | NuGet [5.7.0](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.7.0) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs-readme) | GitHub [5.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.7.0/sdk/eventhub/Azure.Messaging.EventHubs/) | | Event Hubs | NuGet [4.3.2](https://www.nuget.org/packages/Microsoft.Azure.EventHubs/4.3.2) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.EventHubs-readme) | GitHub [4.3.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.EventHubs_4.3.2/sdk/eventhub/Microsoft.Azure.EventHubs/) | -| Event Hubs - Event Processor | NuGet [5.6.2](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.6.2)
NuGet [5.7.0-beta.5](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.7.0-beta.5) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs.Processor-readme) | GitHub [5.6.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.6.2/sdk/eventhub/Azure.Messaging.EventHubs.Processor/)
GitHub [5.7.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.7.0-beta.5/sdk/eventhub/Azure.Messaging.EventHubs.Processor/) | +| Event Hubs - Event Processor | NuGet [5.7.0](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.7.0) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs.Processor-readme) | GitHub [5.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.7.0/sdk/eventhub/Azure.Messaging.EventHubs.Processor/) | | Event Hubs - Processor | NuGet [4.3.2](https://www.nuget.org/packages/Microsoft.Azure.EventHubs.Processor/4.3.2) | | GitHub [4.3.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.EventHubs.Processor_4.3.2/sdk/eventhub/Microsoft.Azure.EventHubs.Processor/) | | Event Hubs - Service Fabric Processor | NuGet [0.5.4](https://www.nuget.org/packages/Microsoft.Azure.EventHubs.ServiceFabricProcessor/0.5.4) | | GitHub [0.5.4](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.EventHubs.ServiceFabricProcessor_0.5.4/sdk/eventhub/Microsoft.Azure.EventHubs.ServiceFabricProcessor/) | -| Extensions - Azure | NuGet [1.1.1](https://www.nuget.org/packages/Microsoft.Extensions.Azure/1.1.1) | | GitHub [1.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Extensions.Azure_1.1.1/sdk/extensions/Microsoft.Extensions.Azure/) | -| Extensions - Caching Cosmos | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Cosmos/1.2.0) | | GitHub [1.2.0](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/tree/v1.0.0-preview4) | +| Extensions - Azure | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Extensions.Azure/1.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Extensions.Azure-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Extensions.Azure_1.2.0/sdk/extensions/Microsoft.Extensions.Azure/) | +| Extensions - Caching Cosmos | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Cosmos/1.3.0) | | GitHub [1.3.0](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/tree/v1.0.0-preview4) | | Face | NuGet [2.8.0-preview.2](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.Face/2.8.0-preview.2) | | GitHub [2.8.0-preview.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Vision.Face_2.6.0-preview.1/sdk/cognitiveservices/Vision.Face) | | FarmBeats | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Verticals.AgriFood.Farming/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Verticals.AgriFood.Farming-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Verticals.AgriFood.Farming_1.0.0-beta.1/sdk/farmbeats/Azure.Verticals.AgriFood.Farming/) | -| Form Recognizer | NuGet [3.1.1](https://www.nuget.org/packages/Azure.AI.FormRecognizer/3.1.1)
NuGet [4.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.FormRecognizer/4.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.FormRecognizer-readme) | GitHub [3.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_3.1.1/sdk/formrecognizer/Azure.AI.FormRecognizer/)
GitHub [4.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_4.0.0-beta.3/sdk/formrecognizer/Azure.AI.FormRecognizer/) | +| Form Recognizer | NuGet [3.1.1](https://www.nuget.org/packages/Azure.AI.FormRecognizer/3.1.1)
NuGet [4.0.0-beta.4](https://www.nuget.org/packages/Azure.AI.FormRecognizer/4.0.0-beta.4) | [docs](/dotnet/api/overview/azure/AI.FormRecognizer-readme) | GitHub [3.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_3.1.1/sdk/formrecognizer/Azure.AI.FormRecognizer/)
GitHub [4.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_4.0.0-beta.4/sdk/formrecognizer/Azure.AI.FormRecognizer/) | | Form Recognizer | NuGet [0.8.0-preview](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.FormRecognizer/0.8.0-preview) | | GitHub [0.8.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitiveservices/FormRecognizer) | | Functions - Extensions | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Extensions/1.1.0) | | GitHub [1.1.0](https://github.com/Azure/azure-functions-dotnet-extensions) | | Gallery | NuGet [2.6.2-preview](https://www.nuget.org/packages/Microsoft.Azure.Gallery/2.6.2-preview) | | | @@ -303,7 +312,7 @@ | Media Analytics Edge | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Media.Analytics.Edge/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Media.Analytics.Edge-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Media.Analytics.Edge_1.0.0-beta.1/sdk/mediaservices/Azure.Media.Analytics.Edge) | | Media Live Video Analytics Edge | NuGet [1.0.4-preview.1](https://www.nuget.org/packages/Microsoft.Azure.Media.LiveVideoAnalytics.Edge/1.0.4-preview.1) | | GitHub [1.0.4-preview.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Media.LiveVideoAnalytics.Edge_1.0.4-preview.1/sdk/mediaservices/Microsoft.Azure.Media.LiveVideoAnalytics.Edge) | | Metrics Advisor | NuGet [1.1.0](https://www.nuget.org/packages/Azure.AI.MetricsAdvisor/1.1.0) | [docs](/dotnet/api/overview/azure/AI.MetricsAdvisor-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.MetricsAdvisor_1.1.0/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/) | -| Microsoft.Azure.Amqp | NuGet [2.5.10](https://www.nuget.org/packages/Microsoft.Azure.Amqp/2.5.10) | | | +| Microsoft.Azure.Amqp | NuGet [2.5.12](https://www.nuget.org/packages/Microsoft.Azure.Amqp/2.5.12) | | | | Microsoft.Azure.Devices | NuGet [1.37.0](https://www.nuget.org/packages/Microsoft.Azure.Devices/1.37.0)
NuGet [1.38.0-preview-001](https://www.nuget.org/packages/Microsoft.Azure.Devices/1.38.0-preview-001) | | | | Microsoft.Azure.Devices.Client.PCL | NuGet [1.0.16](https://www.nuget.org/packages/Microsoft.Azure.Devices.Client.PCL/1.0.16) | | | | Microsoft.Azure.Devices.DigitalTwin.Client | NuGet [1.0.0-preview-001](https://www.nuget.org/packages/Microsoft.Azure.Devices.DigitalTwin.Client/1.0.0-preview-001) | | | @@ -318,8 +327,8 @@ | Microsoft.Azure.Devices.Provisioning.Transport.Http | NuGet [1.15.1](https://www.nuget.org/packages/Microsoft.Azure.Devices.Provisioning.Transport.Http/1.15.1)
NuGet [1.16.0-preview-001](https://www.nuget.org/packages/Microsoft.Azure.Devices.Provisioning.Transport.Http/1.16.0-preview-001) | | | | Microsoft.Azure.Devices.Provisioning.Transport.Mqtt | NuGet [1.17.1](https://www.nuget.org/packages/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt/1.17.1)
NuGet [1.18.0-preview-001](https://www.nuget.org/packages/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt/1.18.0-preview-001) | | | | Microsoft.Azure.Devices.Shared | NuGet [1.30.1](https://www.nuget.org/packages/Microsoft.Azure.Devices.Shared/1.30.1)
NuGet [1.31.0-preview-001](https://www.nuget.org/packages/Microsoft.Azure.Devices.Shared/1.31.0-preview-001) | | | -| Microsoft.Azure.Functions.Worker | NuGet [1.6.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/1.6.0)
NuGet [1.7.0-preview1](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/1.7.0-preview1) | | | -| Microsoft.Azure.Functions.Worker.Sdk | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/1.3.0) | | | +| Microsoft.Azure.Functions.Worker | NuGet [1.6.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/1.6.0)
NuGet [1.8.0-preview3](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/1.8.0-preview3) | | | +| Microsoft.Azure.Functions.Worker.Sdk | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/1.3.0)
NuGet [1.5.0-preview2](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/1.5.0-preview2) | | | | Microsoft.Azure.uamqp | NuGet [1.2.11](https://www.nuget.org/packages/Microsoft.Azure.uamqp/1.2.11) | | | | Microsoft.Azure.umqtt | NuGet [1.1.11](https://www.nuget.org/packages/Microsoft.Azure.umqtt/1.1.11) | | | | Mobile Apps | NuGet [2.0.3](https://www.nuget.org/packages/Microsoft.Azure.Mobile.Server/2.0.3) | | | @@ -339,51 +348,51 @@ | QnA Maker | NuGet [2.0.1](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker/2.0.1)
NuGet [3.0.0-preview.1](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker/3.0.0-preview.1) | | GitHub [2.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker_2.0.1/sdk/cognitiveservices/Knowledge.QnAMaker) | | Question Answering | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Language.QuestionAnswering/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Azure.AI.Language.QuestionAnswering/1.1.0-beta.1) | [docs](/dotnet/api/overview/azure/AI.Language.QuestionAnswering-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.QuestionAnswering_1.0.0/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.QuestionAnswering_1.1.0-beta.1/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/) | | Relay | NuGet [2.0.15596](https://www.nuget.org/packages/Microsoft.Azure.Relay/2.0.15596)
NuGet [3.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Relay/3.0.0-preview) | [docs](/dotnet/api/overview/azure/service-bus-relay) | GitHub [2.0.15596](https://github.com/Azure/azure-relay-dotnet/tree/2.0.1) | -| Schema Registry | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Data.SchemaRegistry/1.1.0) | [docs](/dotnet/api/overview/azure/Data.SchemaRegistry-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.SchemaRegistry_1.1.0/sdk/schemaregistry/Azure.Data.SchemaRegistry/) | -| Schema Registry - Avro | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro_1.0.0-beta.8/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/) | +| Schema Registry | NuGet [1.2.0](https://www.nuget.org/packages/Azure.Data.SchemaRegistry/1.2.0) | [docs](/dotnet/api/overview/azure/Data.SchemaRegistry-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.SchemaRegistry_1.2.0/sdk/schemaregistry/Azure.Data.SchemaRegistry/) | +| Schema Registry - Avro | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/1.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro_1.0.0/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/) | | Search | NuGet [10.1.0](https://www.nuget.org/packages/Microsoft.Azure.Search/10.1.0) | | GitHub [10.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Search_10.1.0/sdk/search/Microsoft.Azure.Search/) | | Search - Common | NuGet [10.1.0](https://www.nuget.org/packages/Microsoft.Azure.Search.Common/10.1.0) | | GitHub [10.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Search.Common_10.1.0/sdk/search/Microsoft.Azure.Search.Common/) | | Search - Data | NuGet [10.1.0](https://www.nuget.org/packages/Microsoft.Azure.Search.Data/10.1.0) | | GitHub [10.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Search.Data_10.1.0/sdk/search/Microsoft.Azure.Search.Data/) | | Search - Service | NuGet [10.1.0](https://www.nuget.org/packages/Microsoft.Azure.Search.Service/10.1.0) | | GitHub [10.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Search.Service_10.1.0/sdk/search/Microsoft.Azure.Search.Service/) | -| Service Bus | NuGet [7.7.0](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.7.0)
NuGet [7.8.0-beta.2](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.8.0-beta.2) | [docs](/dotnet/api/overview/azure/Messaging.ServiceBus-readme) | GitHub [7.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.7.0/sdk/servicebus/Azure.Messaging.ServiceBus/)
GitHub [7.8.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.8.0-beta.2/sdk/servicebus/Azure.Messaging.ServiceBus/) | +| Service Bus | NuGet [7.8.1](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.8.1)
NuGet [7.9.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.9.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.ServiceBus-readme) | GitHub [7.8.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.8.1/sdk/servicebus/Azure.Messaging.ServiceBus/)
GitHub [7.9.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.9.0-beta.1/sdk/servicebus/Azure.Messaging.ServiceBus/) | | Service Bus | NuGet [5.2.0](https://www.nuget.org/packages/Microsoft.Azure.ServiceBus/5.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.ServiceBus-readme) | GitHub [5.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.ServiceBus_5.2.0/sdk/servicebus/Microsoft.Azure.ServiceBus/) | | Service Bus - Message ID plugin | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.ServiceBus.MessageIdPlugin/2.0.0) | | | -| SignalR | NuGet [1.17.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR/1.17.0) | | GitHub [1.17.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR) | -| SignalR - ASP.NET | NuGet [1.17.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR.AspNet/1.17.0) | | GitHub [1.17.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR.AspNet) | +| SignalR | NuGet [1.18.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR/1.18.0) | | GitHub [1.18.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR) | +| SignalR - ASP.NET | NuGet [1.18.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR.AspNet/1.18.0) | | GitHub [1.18.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR.AspNet) | | SignalR - Benchmark | NuGet [1.0.0-preview1-10415](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Benchmark/1.0.0-preview1-10415) | | GitHub [1.0.0-preview1-10415](https://github.com/azure/azure-signalr-bench) | -| SignalR - Protocols | NuGet [1.17.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Protocols/1.17.0) | | GitHub [1.17.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR.Protocols) | +| SignalR - Protocols | NuGet [1.18.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Protocols/1.18.0) | | GitHub [1.18.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR.Protocols) | | SignalR - Serverless Protocols | NuGet [1.6.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Serverless.Protocols/1.6.0) | | GitHub [1.6.0](https://github.com/Azure/azure-functions-signalrservice-extension/tree/v1.2.0/src/Microsoft.Azure.SignalR.Serverless.Protocols) | -| Speech | NuGet [1.21.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech/1.21.0) | | | -| Speech Remoteconversation | NuGet [1.21.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech.Remoteconversation/1.21.0) | | | -| Speech Xamarin iOS | NuGet [1.21.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech.Xamarin.iOS/1.21.0) | | | +| Speech | NuGet [1.22.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech/1.22.0) | | | +| Speech Remoteconversation | NuGet [1.22.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech.Remoteconversation/1.22.0) | | | +| Speech Xamarin iOS | NuGet [1.22.0](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech.Xamarin.iOS/1.22.0) | | | | Spell Check | NuGet [4.1.0-preview.1](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Language.SpellCheck/4.1.0-preview.1) | | GitHub [4.1.0-preview.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Language.SpellCheck_4.1.0-preview.1/sdk/cognitiveservices/Language.SpellCheck) | | Spring Cloud Client | NuGet [2.0.0-preview.3](https://www.nuget.org/packages/Microsoft.Azure.SpringCloud.Client/2.0.0-preview.3) | | | | SQL Database Elastic Scale Client | NuGet [2.3.0](https://www.nuget.org/packages/Microsoft.Azure.SqlDatabase.ElasticScale.Client/2.3.0) | | GitHub [2.3.0](https://github.com/Azure/elastic-db-tools/tree/v2.3.0/Src/ElasticScale.Client) | | SQL Database Elastic Scale Service SplitMerge | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Azure.SqlDatabase.ElasticScale.Service.SplitMerge/1.2.0) | | | | SQL Database Jobs | NuGet [0.8.3362.1](https://www.nuget.org/packages/Microsoft.Azure.SqlDatabase.Jobs/0.8.3362.1) | | | -| Storage - Blobs | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Storage.Blobs/12.11.0)
NuGet [12.12.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Blobs/12.12.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.11.0/sdk/storage/Azure.Storage.Blobs/)
GitHub [12.12.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.12.0-beta.1/sdk/storage/Azure.Storage.Blobs/) | +| Storage - Blobs | NuGet [12.12.0](https://www.nuget.org/packages/Azure.Storage.Blobs/12.12.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.12.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.12.0/sdk/storage/Azure.Storage.Blobs/) | | Storage - Blobs | NuGet [11.2.3](https://www.nuget.org/packages/Microsoft.Azure.Storage.Blob/11.2.3) | | GitHub [11.2.3](https://github.com/Azure/azure-storage-net/tree/master/Blob) | -| Storage - Blobs Batch | NuGet [12.8.0](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.8.0)
NuGet [12.9.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.9.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.8.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.8.0/sdk/storage/Azure.Storage.Blobs.Batch/)
GitHub [12.9.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.9.0-beta.1/sdk/storage/Azure.Storage.Blobs.Batch/) | -| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.23](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.23) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme-pre) | GitHub [12.0.0-preview.23](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.23/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) | -| Storage - Common | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Common/12.10.0)
NuGet [12.11.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Common/12.11.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.10.0/sdk/storage/Azure.Storage.Common/)
GitHub [12.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.11.0-beta.1/sdk/storage/Azure.Storage.Common/) | +| Storage - Blobs Batch | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.9.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.9.0/sdk/storage/Azure.Storage.Blobs.Batch/) | +| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.25](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.25) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme-pre) | GitHub [12.0.0-preview.25](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.25/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) | +| Storage - Common | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Storage.Common/12.11.0) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.11.0/sdk/storage/Azure.Storage.Common/) | | Storage - Data Movement | NuGet [2.0.4](https://www.nuget.org/packages/Microsoft.Azure.Storage.DataMovement/2.0.4) | | GitHub [2.0.4](https://github.com/Azure/azure-storage-net-data-movement/tree/v1.3.0) | -| Storage - Files Data Lake | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.9.0/sdk/storage/Azure.Storage.Files.DataLake/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.10.0-beta.1/sdk/storage/Azure.Storage.Files.DataLake/) | -| Storage - Files Shares | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.9.0/sdk/storage/Azure.Storage.Files.Shares/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.10.0-beta.1/sdk/storage/Azure.Storage.Files.Shares/) | +| Storage - Files Data Lake | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.10.0/sdk/storage/Azure.Storage.Files.DataLake/) | +| Storage - Files Shares | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.10.0/sdk/storage/Azure.Storage.Files.Shares/) | | Storage - Files Shares | NuGet [11.2.3](https://www.nuget.org/packages/Microsoft.Azure.Storage.File/11.2.3) | | GitHub [11.2.3](https://github.com/Azure/azure-storage-net/tree/master/File) | -| Storage - Queues | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Queues/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.9.0/sdk/storage/Azure.Storage.Queues/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.10.0-beta.1/sdk/storage/Azure.Storage.Queues/) | +| Storage - Queues | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.10.0/sdk/storage/Azure.Storage.Queues/) | | Storage - Queues | NuGet [11.2.3](https://www.nuget.org/packages/Microsoft.Azure.Storage.Queue/11.2.3) | | GitHub [11.2.3](https://github.com/Azure/azure-storage-net/tree/master/Queue) | | Synapse | NuGet [0.1.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Synapse/0.1.0-preview) | | GitHub [0.1.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Synapse_0.1.0-preview/sdk/synapse/Microsoft.Azure.Synapse/) | | Synapse - AccessControl | NuGet [1.0.0-preview.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.AccessControl/1.0.0-preview.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.AccessControl-readme-pre) | GitHub [1.0.0-preview.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.AccessControl_1.0.0-preview.5/sdk/synapse/Azure.Analytics.Synapse.AccessControl/) | -| Synapse - Artifacts | NuGet [1.0.0-preview.14](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.14) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme-pre) | GitHub [1.0.0-preview.14](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.14/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | +| Synapse - Artifacts | NuGet [1.0.0-preview.15](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.15) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme-pre) | GitHub [1.0.0-preview.15](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.15/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | | Synapse - Managed Private Endpoints | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.ManagedPrivateEndpoints/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.ManagedPrivateEndpoints-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.ManagedPrivateEndpoints_1.0.0-beta.5/sdk/synapse/Azure.Analytics.Synapse.ManagedPrivateEndpoints/) | | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme-pre) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | -| Tables | NuGet [12.5.0](https://www.nuget.org/packages/Azure.Data.Tables/12.5.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.5.0/sdk/tables/Azure.Data.Tables/) | +| Tables | NuGet [12.6.0](https://www.nuget.org/packages/Azure.Data.Tables/12.6.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.6.0/sdk/tables/Azure.Data.Tables/) | | Tables | NuGet [2.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Table/2.0.0-preview) | | | | Tables | NuGet [2.1.2](https://www.nuget.org/packages/Microsoft.Azure.CosmosDB.Table/2.1.2) | | | | Template | NuGet [1.0.2-preview1](https://www.nuget.org/packages/Microsoft.Azure.Template/1.0.2-preview1) | | | | Test HttpRecorder | NuGet [1.13.3](https://www.nuget.org/packages/Microsoft.Azure.Test.HttpRecorder/1.13.3) | | GitHub [1.13.3](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/mgmtcommon/TestFramework/Microsoft.Azure.Test.HttpRecorder) | -| Text Analytics | NuGet [5.1.1](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.1.1)
NuGet [5.2.0-beta.2](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.2.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.1.1/sdk/textanalytics/Azure.AI.TextAnalytics/)
GitHub [5.2.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.2.0-beta.2/sdk/textanalytics/Azure.AI.TextAnalytics/) | +| Text Analytics | NuGet [5.1.1](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.1.1)
NuGet [5.2.0-beta.3](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.2.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.1.1/sdk/textanalytics/Azure.AI.TextAnalytics/)
GitHub [5.2.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.2.0-beta.3/sdk/textanalytics/Azure.AI.TextAnalytics/) | | Text Analytics | NuGet [4.1.0-preview.2](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Language.TextAnalytics/4.1.0-preview.2) | | GitHub [4.1.0-preview.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Language.TextAnalytics_4.1.0-preview.2/sdk/cognitiveservices/Language.TextAnalytics) | | Video Search | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Search.VideoSearch/2.0.0) | | | | Vision Content Moderator | NuGet [2.1.0-preview.1](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.ContentModerator/2.1.0-preview.1) | | GitHub [2.1.0-preview.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Vision.ContentModerator_2.1.0-preview.1/sdk/cognitiveservices/Vision.ContentModerator) | @@ -394,31 +403,31 @@ | Web - Redis Session State Provider | NuGet [4.0.1](https://www.nuget.org/packages/Microsoft.Web.RedisSessionStateProvider/4.0.1) | | GitHub [4.0.1](https://github.com/Azure/aspnet-redis-providers/tree/NuGet-Release/RedisSessionStateProvider-4.0.1/src/RedisSessionStateProvider) | | Web PubSub | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Messaging.WebPubSub/1.0.0) | [docs](/dotnet/api/overview/azure/Messaging.WebPubSub-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.WebPubSub_1.0.0/sdk/webpubsub/Azure.Messaging.WebPubSub/) | | Web Search | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Search.WebSearch/2.0.0) | | | -| WebJobs | NuGet [3.0.32](https://www.nuget.org/packages/Microsoft.Azure.WebJobs/3.0.32) | | GitHub [3.0.32](https://github.com/Azure/azure-webjobs-sdk/tree/v3.0.18/src/Microsoft.Azure.WebJobs) | -| WebJobs - Core | NuGet [3.0.32](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Core/3.0.32) | | GitHub [3.0.32](https://github.com/Azure/azure-webjobs-sdk/tree/v3.0.18) | +| WebJobs | NuGet [3.0.33](https://www.nuget.org/packages/Microsoft.Azure.WebJobs/3.0.33) | | GitHub [3.0.33](https://github.com/Azure/azure-webjobs-sdk/tree/v3.0.18/src/Microsoft.Azure.WebJobs) | +| WebJobs - Core | NuGet [3.0.33](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Core/3.0.33) | | GitHub [3.0.33](https://github.com/Azure/azure-webjobs-sdk/tree/v3.0.18) | | WebJobs - Host Storage | NuGet [4.0.4](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Host.Storage/4.0.4)
NuGet [5.0.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Host.Storage/5.0.0-beta.1) | | GitHub [4.0.4](https://github.com/Azure/azure-webjobs-sdk/tree/storage-v4.0.1/src/Microsoft.Azure.WebJobs.Host.Storage) | | WebJobs - Host Test Common | NuGet [3.0.30](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Host.TestCommon/3.0.30) | | GitHub [3.0.30](https://github.com/Azure/azure-webjobs-sdk) | -| WebJobs - Item Templates | NuGet [4.0.2057](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.ItemTemplates/4.0.2057) | | GitHub [4.0.2057](https://github.com/Azure/azure-functions-templates/tree/3.1.1582) | +| WebJobs - Item Templates | NuGet [4.0.2185](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.ItemTemplates/4.0.2185) | | GitHub [4.0.2185](https://github.com/Azure/azure-functions-templates/tree/3.1.1582) | | WebJobs - Logging | NuGet [4.0.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Logging/4.0.2) | | GitHub [4.0.2](https://github.com/Azure/azure-webjobs-sdk/tree/dev/src/Microsoft.Azure.WebJobs.Logging) | -| WebJobs - Logging Application Insights | NuGet [3.0.30](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/3.0.30) | | GitHub [3.0.30](https://github.com/Azure/azure-webjobs-sdk/tree/v3.0.18/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights) | -| WebJobs - Project Templates | NuGet [4.0.2057](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.ProjectTemplates/4.0.2057) | | GitHub [4.0.2057](https://github.com/Azure/azure-functions-templates/tree/3.1.1582) | +| WebJobs - Logging Application Insights | NuGet [3.0.33](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/3.0.33) | | GitHub [3.0.33](https://github.com/Azure/azure-webjobs-sdk/tree/v3.0.18/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights) | +| WebJobs - Project Templates | NuGet [4.0.2185](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.ProjectTemplates/4.0.2185) | | GitHub [4.0.2185](https://github.com/Azure/azure-functions-templates/tree/3.1.1582) | | WebJobs - Scrip Web Host | NuGet [1.0.0-beta3](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Script.WebHost/1.0.0-beta3) | | GitHub [1.0.0-beta3](https://github.com/Azure/azure-functions-host/tree/dev/src/WebJobs.Script.WebHost) | | WebJobs - Script | NuGet [1.0.0-beta3](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Script/1.0.0-beta3) | | GitHub [1.0.0-beta3](https://github.com/Azure/azure-functions-host/tree/dev/src/WebJobs.Script) | | WebJobs - Script Abstractions | NuGet [1.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Script.Abstractions/1.0.0-preview) | | | | WebJobs - Script Extensibility | NuGet [1.0.0-beta3](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Script.Extensibility/1.0.0-beta3) | | GitHub [1.0.0-beta3](https://github.com/Azure/azure-functions-host) | | WebJobs - Script Extensions Metadata Generator | NuGet [4.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator/4.0.1) | | GitHub [4.0.1](https://github.com/Azure/azure-functions-host) | | WebJobs - Service Bus | NuGet [3.0.0-beta8](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.ServiceBus/3.0.0-beta8) | | GitHub [3.0.0-beta8](https://github.com/Azure/azure-webjobs-sdk/tree/v3.0.0-beta8/src/Microsoft.Azure.WebJobs.ServiceBus) | -| WebJobs - Sources | NuGet [3.0.30](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Sources/3.0.30) | | GitHub [3.0.30](https://github.com/Azure/azure-webjobs-sdk) | +| WebJobs - Sources | NuGet [3.0.33](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Sources/3.0.33) | | GitHub [3.0.33](https://github.com/Azure/azure-webjobs-sdk) | | WebJobs Extensions | NuGet [4.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions/4.0.1)
NuGet [5.0.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions/5.0.0-beta.1) | | GitHub [4.0.1](https://github.com/Azure/azure-webjobs-sdk-extensions/tree/dev/src/WebJobs.Extensions) | | WebJobs Extensions - API Hub | NuGet [1.0.0-beta9](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ApiHub/1.0.0-beta9) | | GitHub [1.0.0-beta9](https://github.com/Azure/azure-webjobs-sdk-extensions) | | WebJobs Extensions - Auth Tokens | NuGet [1.0.0-beta6](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.AuthTokens/1.0.0-beta6) | | GitHub [1.0.0-beta6](https://github.com/Azure/azure-webjobs-sdk-extensions) | | WebJobs Extensions - Cosmos DB | NuGet [3.0.10](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.CosmosDB/3.0.10)
NuGet [4.0.0-preview3](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.CosmosDB/4.0.0-preview3) | | GitHub [3.0.10](https://github.com/Azure/azure-webjobs-sdk-extensions/tree/cosmos-v3.0.7/src/WebJobs.Extensions.CosmosDB) | | WebJobs Extensions - Document DB | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DocumentDB/1.3.0) | | GitHub [1.3.0](https://github.com/Azure/azure-webjobs-sdk-extensions) | -| WebJobs Extensions - Durable Task | NuGet [2.6.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask/2.6.1) | [docs](/dotnet/api/overview/azure/functions) | GitHub [2.6.1](https://github.com/Azure/azure-functions-durable-extension/tree/v2.2.2/src/WebJobs.Extensions.DurableTask) | +| WebJobs Extensions - Durable Task | NuGet [2.7.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask/2.7.2) | [docs](/dotnet/api/overview/azure/functions) | GitHub [2.7.2](https://github.com/Azure/azure-functions-durable-extension/tree/v2.2.2/src/WebJobs.Extensions.DurableTask) | | WebJobs Extensions - Durable Task Analyzers | NuGet [0.4.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers/0.4.2) | | GitHub [0.4.2](https://github.com/Azure/azure-functions-durable-extension/tree/Analyzer-v0.3.0/src/WebJobs.Extensions.DurableTask.Analyzers) | | WebJobs Extensions - Edge Hub | NuGet [1.0.7](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EdgeHub/1.0.7) | | GitHub [1.0.7](https://github.com/Azure/iotedge/tree/1.0.7/edge-hub) | | WebJobs Extensions - Http | NuGet [3.0.12](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Http/3.0.12) | | GitHub [3.0.12](https://github.com/Azure/azure-webjobs-sdk-extensions/tree/v3.0.2/src/WebJobs.Extensions.Http) | -| WebJobs Extensions - Kafka | NuGet [3.3.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Kafka/3.3.2) | | GitHub [3.3.2](https://github.com/Azure/azure-functions-kafka-extension/tree/3.0.0/src/Microsoft.Azure.WebJobs.Extensions.Kafka) | +| WebJobs Extensions - Kafka | NuGet [3.4.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Kafka/3.4.0) | | GitHub [3.4.0](https://github.com/Azure/azure-functions-kafka-extension/tree/3.0.0/src/Microsoft.Azure.WebJobs.Extensions.Kafka) | | WebJobs Extensions - Microsoft Graph | NuGet [1.0.0-beta6](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.MicrosoftGraph/1.0.0-beta6) | | GitHub [1.0.0-beta6](https://github.com/Azure/azure-functions-microsoftgraph-extension) | | WebJobs Extensions - Mobile Apps | NuGet [3.0.0-beta8](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.MobileApps/3.0.0-beta8) | | GitHub [3.0.0-beta8](https://github.com/Azure/azure-webjobs-sdk-extensions/tree/v3.0.0-beta8/src/WebJobs.Extensions.MobileApps) | | WebJobs Extensions - Notification Hubs | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.NotificationHubs/1.3.0) | | GitHub [1.3.0](https://github.com/Azure/azure-webjobs-sdk-extensions) | @@ -427,8 +436,8 @@ | WebJobs Extensions - OpenAPI Core | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/1.3.0) | | | | WebJobs Extensions - RabbitMQ | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.RabbitMQ/1.1.0)
NuGet [2.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.RabbitMQ/2.0.0-preview) | | GitHub [1.1.0](https://github.com/Azure/azure-functions-rabbitmq-extension/tree/v0.2.2029-beta) | | WebJobs Extensions - SendGrid | NuGet [3.0.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.SendGrid/3.0.2) | | GitHub [3.0.2](https://github.com/Azure/azure-webjobs-sdk-extensions/tree/v3.0.0/src/WebJobs.Extensions.SendGrid) | -| WebJobs Extensions - Storage Blobs | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/5.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs-readme) | | -| WebJobs Extensions - Storage Queues | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/5.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage.Queues-readme) | | +| WebJobs Extensions - Storage Blobs | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs-readme) | | +| WebJobs Extensions - Storage Queues | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage.Queues-readme) | | | WebJobs Extensions - Twilio | NuGet [3.0.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Twilio/3.0.2) | | GitHub [3.0.2](https://github.com/Azure/azure-webjobs-sdk-extensions/tree/v3.0.0/src/WebJobs.Extensions.Twilio) | | WebJobs Extensions - WebHooks | NuGet [1.0.0-beta4](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.WebHooks/1.0.0-beta4) | | GitHub [1.0.0-beta4](https://github.com/Azure/azure-webjobs-sdk-extensions) | | WebSites - DataProtection | NuGet [0.1.78-alpha](https://www.nuget.org/packages/Microsoft.Azure.WebSites.DataProtection/0.1.78-alpha) | | | @@ -458,11 +467,11 @@ | Core Newtonsoft Json | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.NewtonsoftJson/1.0.0) | | | | Core Spatial | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial/1.1.0)
NuGet [1.2.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial/1.2.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Core.Spatial-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial_1.1.0/sdk/core/Microsoft.Azure.Core.Spatial/)
GitHub [1.2.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial_1.2.0-beta.1/sdk/core/Microsoft.Azure.Core.Spatial/) | | Core Spatial Newtonsoft Json | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial.NewtonsoftJson/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial.NewtonsoftJson/1.1.0-beta.1) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial.NewtonsoftJson_1.0.0/sdk/core/Microsoft.Azure.Core.Spatial.NewtonsoftJson/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial.NewtonsoftJson_1.1.0-beta.1/sdk/core/Microsoft.Azure.Core.Spatial.NewtonsoftJson/) | -| WebJobs Extensions - Event Grid | NuGet [3.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.1.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventGrid-readme) | GitHub [3.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventGrid_3.1.0/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/) | -| WebJobs Extensions - Event Hubs | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventHubs/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventHubs-readme) | GitHub [5.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventHubs_5.0.1/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/) | -| WebJobs Extensions - Service Bus | NuGet [5.3.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.3.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.ServiceBus-readme) | GitHub [5.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.ServiceBus_5.3.0/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/) | +| WebJobs Extensions - Event Grid | NuGet [3.2.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventGrid-readme) | GitHub [3.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventGrid_3.2.0/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/) | +| WebJobs Extensions - Event Hubs | NuGet [5.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventHubs/5.1.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventHubs-readme) | GitHub [5.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventHubs_5.1.0/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/) | +| WebJobs Extensions - Service Bus | NuGet [5.5.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.5.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.ServiceBus-readme) | GitHub [5.5.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.ServiceBus_5.5.1/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/) | | WebJobs Extensions - SignalR Service | NuGet [1.8.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.SignalRService/1.8.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.SignalRService-readme) | GitHub [1.8.0](https://github.com/Azure/azure-functions-signalrservice-extension/tree/v1.2.0/src/SignalRServiceExtension) | -| WebJobs Extensions - Storage | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage/5.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage-readme) | GitHub [5.0.0](https://github.com/Azure/azure-webjobs-sdk/tree/master/src/Microsoft.Azure.WebJobs.Extensions.Storage) | +| WebJobs Extensions - Storage | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage-readme) | GitHub [5.0.1](https://github.com/Azure/azure-webjobs-sdk/tree/master/src/Microsoft.Azure.WebJobs.Extensions.Storage) | | WebJobs Extensions - Web PubSub | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.WebPubSub/1.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.WebPubSub-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.WebPubSub_1.2.0/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSub/) | | AzureStack Management | NuGet [0.10.8-preview](https://www.nuget.org/packages/Microsoft.AzureStack.Management/0.10.8-preview) | | | | AzureStack Management - Azure Bridge Admin | NuGet [0.1.0-preview](https://www.nuget.org/packages/Microsoft.AzureStack.Management.AzureBridge.Admin/0.1.0-preview) | | GitHub [0.1.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/azurestack/Microsoft.AzureStack.Management.AzureBridge.Admin) | @@ -479,7 +488,6 @@ | AzureStack Management - Subscription | NuGet [0.1.0-preview](https://www.nuget.org/packages/Microsoft.AzureStack.Management.Subscription/0.1.0-preview) | | GitHub [0.1.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/azurestack/Microsoft.AzureStack.Management.Subscription) | | AzureStack Management - Subscriptions Admin | NuGet [0.2.0-preview](https://www.nuget.org/packages/Microsoft.AzureStack.Management.Subscriptions.Admin/0.2.0-preview) | | GitHub [0.2.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/azurestack/Microsoft.AzureStack.Management.Subscriptions.Admin) | | AzureStack Management - Update Admin | NuGet [0.1.0-preview](https://www.nuget.org/packages/Microsoft.AzureStack.Management.Update.Admin/0.1.0-preview) | | GitHub [0.1.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/azurestack/Microsoft.AzureStack.Management.Update.Admin) | -| Grafana | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.0.0-beta.1) | | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.0.0-beta.1/sdk/grafana/Azure.ResourceManager.Grafana/) | | Management - Advisor | NuGet [0.9.5-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Advisor/0.9.5-preview) | | GitHub [0.9.5-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/advisor/Microsoft.Azure.Management.Advisor) | | Management - Alerts Management | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.AlertsManagement/1.0.0) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.AlertsManagement_1.0.0/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/) | | Management - Analysis | NuGet [2.0.4](https://www.nuget.org/packages/Microsoft.Azure.Management.Analysis/2.0.4) | | | @@ -503,9 +511,9 @@ | Management - Billing Fluent | NuGet [1.9.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.Billing.Fluent/1.9.1-beta) | | | | Management - Blueprint | NuGet [0.20.7-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Blueprint/0.20.7-preview) | | GitHub [0.20.7-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Blueprint_0.20.7-preview/sdk/blueprint/Microsoft.Azure.Management.Blueprint/) | | Management - Bot Service | NuGet [0.9.3-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.BotService/0.9.3-preview) | | GitHub [0.9.3-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/botservice/Microsoft.Azure.Management.BotService) | -| Management - Cognitive Services | NuGet [8.2.0](https://www.nuget.org/packages/Microsoft.Azure.Management.CognitiveServices/8.2.0) | | GitHub [8.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.CognitiveServices_8.2.0/sdk/cognitiveservices/Microsoft.Azure.Management.CognitiveServices/) | +| Management - Cognitive Services | NuGet [8.3.0](https://www.nuget.org/packages/Microsoft.Azure.Management.CognitiveServices/8.3.0) | | GitHub [8.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.CognitiveServices_8.3.0/sdk/cognitiveservices/Microsoft.Azure.Management.CognitiveServices/) | | Management - Cognitive Services Fluent | NuGet [1.9.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.CognitiveServices.Fluent/1.9.1-beta) | | | -| Management - Compute | NuGet [54.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Compute/54.0.0) | | GitHub [54.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Compute_54.0.0/sdk/compute/Microsoft.Azure.Management.Compute/) | +| Management - Compute | NuGet [55.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Compute/55.0.0) | | GitHub [55.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Compute_55.0.0/sdk/compute/Microsoft.Azure.Management.Compute/) | | Management - Compute Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Compute.Fluent/1.38.1) | [docs](/dotnet/api/overview/azure/virtualmachines) | | | Management - Confluent | NuGet [1.0.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Confluent/1.0.1) | | | | Management - Consumption | NuGet [3.0.2](https://www.nuget.org/packages/Microsoft.Azure.Management.Consumption/3.0.2) | | GitHub [3.0.2](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/consumption/Microsoft.Azure.Management.Consumption) | @@ -518,14 +526,14 @@ | Management - Container Service Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.ContainerService.Fluent/1.38.1) | | | | Management - Content Delivery Network | NuGet [6.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Cdn/6.1.0) | | GitHub [6.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Cdn_6.1.0/sdk/cdn/Microsoft.Azure.Management.Cdn/) | | Management - Content Delivery Network Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Cdn.Fluent/1.38.1) | [docs](/dotnet/api/overview/azure/cdn) | | -| Management - Cosmos DB | NuGet [3.3.0](https://www.nuget.org/packages/Microsoft.Azure.Management.CosmosDB/3.3.0)
NuGet [3.5.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.CosmosDB/3.5.0-preview) | | GitHub [3.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.CosmosDB_3.3.0/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/)
GitHub [3.5.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.CosmosDB_3.5.0-preview/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/) | +| Management - Cosmos DB | NuGet [3.3.0](https://www.nuget.org/packages/Microsoft.Azure.Management.CosmosDB/3.3.0)
NuGet [3.8.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.CosmosDB/3.8.0-preview) | | GitHub [3.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.CosmosDB_3.3.0/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/)
GitHub [3.8.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.CosmosDB_3.8.0-preview/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/) | | Management - Cosmos DB Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.CosmosDB.Fluent/1.38.1) | | | | Management - Customer Insights | NuGet [0.9.1-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.CustomerInsights/0.9.1-preview) | | GitHub [0.9.1-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/customer-insights/Microsoft.Azure.Management.CustomerInsights) | | Management - Customer Insights Fluent | NuGet [1.9.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.CustomerInsights.Fluent/1.9.1-beta) | | | | Management - Data Box | NuGet [2.0.1](https://www.nuget.org/packages/Microsoft.Azure.Management.DataBox/2.0.1) | | GitHub [2.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.DataBox_2.0.1/sdk/databox/Microsoft.Azure.Management.DataBox/) | | Management - Data Box Edge | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.DataBoxEdge/1.1.0) | | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.DataBoxEdge_1.1.0/sdk/databoxedge/Microsoft.Azure.Management.DataBoxEdge/) | | Management - Data Factories | NuGet [4.13.3](https://www.nuget.org/packages/Microsoft.Azure.Management.DataFactories/4.13.3) | [docs](/dotnet/api/overview/azure/data-factory) | | -| Management - Data Factory | NuGet [6.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.DataFactory/6.0.0) | [docs](/dotnet/api/overview/azure/data-factory) | GitHub [6.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.DataFactory_6.0.0/sdk/datafactory/Microsoft.Azure.Management.DataFactory/) | +| Management - Data Factory | NuGet [6.2.0](https://www.nuget.org/packages/Microsoft.Azure.Management.DataFactory/6.2.0) | [docs](/dotnet/api/overview/azure/data-factory) | GitHub [6.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.DataFactory_6.2.0/sdk/datafactory/Microsoft.Azure.Management.DataFactory/) | | Management - Data Lake Analytics | NuGet [3.5.3-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.DataLake.Analytics/3.5.3-preview) | [docs](/dotnet/api/overview/azure/data-lake-analytics) | GitHub [3.5.3-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/datalake-analytics/Microsoft.Azure.Management.DataLake.Analytics) | | Management - Data Lake Storage | NuGet [2.4.2-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.DataLake.Store/2.4.2-preview) | [docs](/dotnet/api/overview/azure/data-lake-store) | GitHub [2.4.2-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/datalake-store/Microsoft.Azure.Management.DataLake.Store) | | Management - Data Lake Storage Uploader | NuGet [1.0.1-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.DataLake.StoreUploader/1.0.1-preview) | | | @@ -541,16 +549,16 @@ | Management - DNS | NuGet [3.0.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Dns/3.0.1) | [docs](/dotnet/api/overview/azure/dns) | GitHub [3.0.1](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/dns/Microsoft.Azure.Management.Dns) | | Management - DNS Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Dns.Fluent/1.38.1) | | | | Management - Edge Gateway | NuGet [0.8.1-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.EdgeGateway/0.8.1-preview) | | GitHub [0.8.1-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/edgegateway/Microsoft.Azure.Management.EdgeGateway) | -| Management - Event Grid | NuGet [7.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.EventGrid/7.0.0) | [docs](/dotnet/api/overview/azure/eventgrid) | GitHub [7.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.EventGrid_7.0.0/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/) | +| Management - Event Grid | NuGet [7.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.EventGrid/7.0.0)
NuGet [8.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.EventGrid/8.0.0-preview) | [docs](/dotnet/api/overview/azure/eventgrid) | GitHub [7.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.EventGrid_7.0.0/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/)
GitHub [8.0.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.EventGrid_8.0.0-preview/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/) | | Management - Event Hubs | NuGet [4.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.EventHub/4.0.0) | [docs](/dotnet/api/overview/azure/event-hubs) | GitHub [4.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/eventhub/Microsoft.Azure.Management.EventHub) | | Management - Event Hubs Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.EventHub.Fluent/1.38.1) | | | | Management - Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Fluent/1.38.1) | | | | Management - Front Door | NuGet [4.0.1](https://www.nuget.org/packages/Microsoft.Azure.Management.FrontDoor/4.0.1) | | GitHub [4.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.FrontDoor_4.0.1/sdk/frontdoor/Microsoft.Azure.Management.FrontDoor/) | | Management - Graph RBAC Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Graph.RBAC.Fluent/1.38.1) | | | -| Management - Guest Configuration | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.GuestConfiguration/2.0.0) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.GuestConfiguration_2.0.0/sdk/guestconfiguration/Microsoft.Azure.Management.GuestConfiguration/) | +| Management - Guest Configuration | NuGet [3.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.GuestConfiguration/3.0.0) | | GitHub [3.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.GuestConfiguration_3.0.0/sdk/guestconfiguration/Microsoft.Azure.Management.GuestConfiguration/) | | Management - HD Insight | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.HDInsight/8.0.0) | [docs](/dotnet/api/overview/azure/hdinsight) | GitHub [8.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.HDInsight_8.0.0/sdk/hdinsight/Microsoft.Azure.Management.HDInsight/) | | Management - HD Insight Job | NuGet [2.0.7](https://www.nuget.org/packages/Microsoft.Azure.Management.HDInsight.Job/2.0.7) | [docs](/dotnet/api/overview/azure/hdinsight) | | -| Management - Health Care APIs | NuGet [3.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.HealthcareApis/3.0.0) | | GitHub [3.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.HealthcareApis_3.0.0/sdk/healthcareapis/Microsoft.Azure.Management.HealthcareApis/) | +| Management - Health Care APIs | NuGet [4.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.HealthcareApis/4.0.0) | | GitHub [4.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.HealthcareApis_4.0.0/sdk/healthcareapis/Microsoft.Azure.Management.HealthcareApis/) | | Management - Hybrid Compute | NuGet [0.1.0-preview.2](https://www.nuget.org/packages/Microsoft.Azure.Management.HybridCompute/0.1.0-preview.2) | | GitHub [0.1.0-preview.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.HybridCompute_0.1.0-preview.2/sdk/hybridcompute/Microsoft.Azure.Management.HybridCompute/) | | Management - Hybrid Data | NuGet [1.0.1](https://www.nuget.org/packages/Microsoft.Azure.Management.HybridData/1.0.1) | | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.HybridData_1.0.1/sdk/hybriddatamanager/Microsoft.Azure.Management.HybridDataManager) | | Management - Intune | NuGet [0.2.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Intune/0.2.0-preview) | | | @@ -559,7 +567,7 @@ | Management - Key Vault | NuGet [3.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.KeyVault/3.1.0)
NuGet [4.0.0-preview.1](https://www.nuget.org/packages/Microsoft.Azure.Management.KeyVault/4.0.0-preview.1) | | GitHub [3.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.KeyVault_3.1.0/sdk/keyvault/Microsoft.Azure.Management.KeyVault/)
GitHub [4.0.0-preview.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.KeyVault_4.0.0-preview.1/sdk/keyvault/Microsoft.Azure.Management.KeyVault/) | | Management - Key Vault Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.KeyVault.Fluent/1.38.1) | | | | Management - Kusto | NuGet [10.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Kusto/10.0.0) | | GitHub [10.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Kusto_10.0.0/sdk/kusto/Microsoft.Azure.Management.Kusto/) | -| Management - Lab Services | NuGet [3.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.LabServices/3.0.0) | | GitHub [3.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/labservices/Microsoft.Azure.Management.LabServices) | +| Management - Lab Services | NuGet [4.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.LabServices/4.0.0) | | GitHub [4.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/labservices/Microsoft.Azure.Management.LabServices) | | Management - Location Based Services | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.LocationBasedServices/2.0.0) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/locationbasedservices/Microsoft.Azure.Management.LocationBasedServices) | | Management - Locks Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Locks.Fluent/1.38.1) | | | | Management - Logic Apps | NuGet [4.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Logic/4.1.0) | | GitHub [4.1.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/logic/Microsoft.Azure.Management.Logic) | @@ -569,7 +577,7 @@ | Management - Machine Learning Fluent | NuGet [1.9.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.MachineLearning.Fluent/1.9.1-beta) | | | | Management - Maintenance | NuGet [1.3.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Maintenance/1.3.0)
NuGet [1.4.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Maintenance/1.4.0-preview) | | GitHub [1.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Maintenance_1.3.0/sdk/maintenance/Microsoft.Azure.Management.Maintenance/)
GitHub [1.4.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Maintenance_1.4.0-preview/sdk/maintenance/Microsoft.Azure.Management.Maintenance/) | | Management - Managed Network | NuGet [1.0.1-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.ManagedNetwork/1.0.1-preview) | | GitHub [1.0.1-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.ManagedNetwork_1.0.1-preview/sdk/managednetwork/Microsoft.Azure.Management.ManagedNetwork/) | -| Management - Managed Service Identity | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.ManagedServiceIdentity/1.0.0) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.ManagedServiceIdentity_1.0.0/sdk/managedserviceidentity/Microsoft.Azure.Management.ManagedServiceIdentity/) | +| Management - Managed Service Identity | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.ManagedServiceIdentity/1.0.0)
NuGet [2.0.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Management.ManagedServiceIdentity/2.0.0-beta.1) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.ManagedServiceIdentity_1.0.0/sdk/managedserviceidentity/Microsoft.Azure.Management.ManagedServiceIdentity/)
GitHub [2.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.ManagedServiceIdentity_2.0.0-beta.1/sdk/managedserviceidentity/Microsoft.Azure.Management.ManagedServiceIdentity/) | | Management - Managed Service Identity Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Msi.Fluent/1.38.1) | | | | Management - Managed Services | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.ManagedServices/1.1.0) | | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.ManagedServices_1.1.0/sdk/managedservices/Microsoft.Azure.Management.ManagedServices/) | | Management - Management Groups | NuGet [2.0.0-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.ManagementGroups/2.0.0-beta) | | GitHub [2.0.0-beta](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups) | @@ -584,11 +592,11 @@ | Management - Monitor Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Monitor.Fluent/1.38.1) | [docs](/dotnet/api/overview/azure/monitor) | | | Management - MySQL | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.MySQL/1.0.0) | | | | Management - NetApp | NuGet [1.16.0](https://www.nuget.org/packages/Microsoft.Azure.Management.NetApp/1.16.0) | | GitHub [1.16.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.NetApp_1.16.0/sdk/netapp/Microsoft.Azure.Management.NetApp/) | -| Management - Network | NuGet [21.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Network/21.0.0) | | GitHub [21.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Network_21.0.0/sdk/network/Microsoft.Azure.Management.Network/) | +| Management - Network | NuGet [22.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Network/22.0.0)
NuGet [22.1.0-Beta.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Network/22.1.0-Beta.1) | | GitHub [22.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Network_22.0.0/sdk/network/Microsoft.Azure.Management.Network/)
GitHub [22.1.0-Beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Network_22.1.0-Beta.1/sdk/network/Microsoft.Azure.Management.Network/) | | Management - Network Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Network.Fluent/1.38.1) | [docs](/dotnet/api/overview/azure/virtual-network) | | | Management - Notification Hubs | NuGet [2.3.4-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.NotificationHubs/2.3.4-preview) | [docs](/dotnet/api/overview/azure/notification-hubs) | GitHub [2.3.4-preview](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/notificationhubs/Microsoft.Azure.Management.NotificationHubs) | | Management - Notification Hubs Fluent | NuGet [1.9.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.NotificationHubs.Fluent/1.9.1-beta) | | | -| Management - Operational Insights | NuGet [0.24.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.OperationalInsights/0.24.0-preview) | | GitHub [0.24.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.OperationalInsights_0.24.0-preview/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/) | +| Management - Operational Insights | NuGet [0.25.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.OperationalInsights/0.25.0-preview) | | GitHub [0.25.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.OperationalInsights_0.25.0-preview/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/) | | Management - Peering | NuGet [2.1.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Peering/2.1.1) | | GitHub [2.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Peering_2.1.1/sdk/peering/Microsoft.Azure.Management.Peering/) | | Management - Policy Insights | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.PolicyInsights/5.0.0) | | GitHub [5.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.PolicyInsights_5.0.0/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/) | | Management - PostgreSQL | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.PostgreSQL/2.0.0) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/postgresql/Microsoft.Azure.Management.PostgreSQL) | @@ -597,7 +605,7 @@ | Management - Private DNS | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.PrivateDns/1.0.0) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.PrivateDns_1.0.0/sdk/privatedns/Microsoft.Azure.Management.PrivateDns/) | | Management - Private DNS Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.PrivateDns.Fluent/1.38.1) | | | | Management - Recovery Services | NuGet [4.3.2-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.RecoveryServices/4.3.2-preview) | [docs](/dotnet/api/overview/azure/recovery-services) | GitHub [4.3.2-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.RecoveryServices_4.3.2-preview/sdk/recoveryservices/Microsoft.Azure.Management.RecoveryServices/) | -| Management - Recovery Services Backup | NuGet [4.4.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.RecoveryServices.Backup/4.4.0-preview) | [docs](/dotnet/api/overview/azure/recovery-services) | GitHub [4.4.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.RecoveryServices.Backup_4.4.0-preview/sdk/recoveryservices-backup/Microsoft.Azure.Management.RecoveryServices.Backup/) | +| Management - Recovery Services Backup | NuGet [5.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.RecoveryServices.Backup/5.0.0-preview) | [docs](/dotnet/api/overview/azure/recovery-services) | GitHub [5.0.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.RecoveryServices.Backup_5.0.0-preview/sdk/recoveryservices-backup/Microsoft.Azure.Management.RecoveryServices.Backup/) | | Management - Recovery Services Site Recovery | NuGet [2.2.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.RecoveryServices.SiteRecovery/2.2.0-preview) | | GitHub [2.2.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.RecoveryServices.SiteRecovery_2.2.0-preview/sdk/recoveryservices-siterecovery/Microsoft.Azure.Management.RecoveryServices.SiteRecovery/) | | Management - Recovery Services Vault Upgrade | NuGet [1.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.RecoveryServicesVaultUpgrade/1.0.0-preview) | | | | Management - Redis | NuGet [8.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Redis/8.0.0) | | | @@ -607,7 +615,7 @@ | Management - Remote App | NuGet [1.0.9](https://www.nuget.org/packages/Microsoft.Azure.Management.RemoteApp/1.0.9) | | | | Management - Reservations | NuGet [1.15.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Reservations/1.15.0-preview) | | GitHub [1.15.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Reservations_1.15.0-preview/sdk/reservations/Microsoft.Azure.Management.Reservations/) | | Management - Resource Graph | NuGet [2.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.ResourceGraph/2.1.0) | | GitHub [2.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.ResourceGraph_2.1.0/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/) | -| Management - Resource Manager | NuGet [3.17.3-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.ResourceManager/3.17.3-preview) | | | +| Management - Resource Manager | NuGet [3.17.4-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.ResourceManager/3.17.4-preview) | | | | Management - Resource Manager Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.ResourceManager.Fluent/1.38.1) | [docs](/dotnet/api/overview/azure/resource-manager) | | | Management - Resources | NuGet [2.20.1-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Resources/2.20.1-preview) | | | | Management - Sample Project Publish | NuGet [0.9.0-Preview](https://www.nuget.org/packages/Microsoft.Azure.Management.SampleProjectPublish/0.9.0-Preview) | | | @@ -623,13 +631,13 @@ | Management - Service Fabric Fluent | NuGet [1.9.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.ServiceFabric.Fluent/1.9.1-beta) | | | | Management - SignalR | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Management.SignalR/1.1.0)
NuGet [1.1.2-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.SignalR/1.1.2-preview) | | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.SignalR_1.1.0/sdk/signalr/Microsoft.Azure.Management.SignalR/)
GitHub [1.1.2-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.SignalR_1.1.2-preview/sdk/signalr/Microsoft.Azure.Management.SignalR/) | | Management - Site Recovery | NuGet [2.0.2-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.SiteRecovery/2.0.2-preview) | | | -| Management - SQL | NuGet [2.1.1-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Sql/2.1.1-preview) | | | +| Management - SQL | NuGet [3.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Sql/3.0.0-preview) | | | | Management - SQL Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Sql.Fluent/1.38.1) | [docs](/dotnet/api/overview/azure/sql) | | | Management - SQL Virtual Machine | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.SqlVirtualMachine/1.0.0) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.SqlVirtualMachine_1.0.0/sdk/sqlvirtualmachine/Microsoft.Azure.Management.SqlVirtualMachine/) | | Management - Storage | NuGet [24.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Storage/24.0.0) | | GitHub [24.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Storage_24.0.0/sdk/storage/Microsoft.Azure.Management.Storage/) | | Management - Storage Cache | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.StorageCache/2.0.0) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.StorageCache_2.0.0/sdk/storagecache/Microsoft.Azure.Management.StorageCache/) | | Management - Storage Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.Storage.Fluent/1.38.1) | | | -| Management - Storage Sync | NuGet [6.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.StorageSync/6.0.0) | | GitHub [6.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.StorageSync_6.0.0/sdk/storagesync/Microsoft.Azure.Management.StorageSync/) | +| Management - Storage Sync | NuGet [7.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.StorageSync/7.0.0) | | GitHub [7.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.StorageSync_7.0.0/sdk/storagesync/Microsoft.Azure.Management.StorageSync/) | | Management - Storsimple 8000 series | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Storsimple8000series/1.0.0) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/storsimple8000series/Microsoft.Azure.Management.StorSimple8000Series) | | Management - StorSimple Fluent | NuGet [1.9.1-beta](https://www.nuget.org/packages/Microsoft.Azure.Management.StorSimple.Fluent/1.9.1-beta) | [docs](/dotnet/api/overview/azure/storsimple) | | | Management - Stream Analytics | NuGet [4.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.StreamAnalytics/4.0.0) | [docs](/dotnet/api/overview/azure/stream-analytics) | GitHub [4.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/streamanalytics/Microsoft.Azure.Management.StreamAnalytics) | @@ -638,9 +646,9 @@ | Management - Synapse | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.Synapse/2.0.0)
NuGet [2.6.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Synapse/2.6.0-preview) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Synapse_2.0.0/sdk/synapse/Microsoft.Azure.Management.Synapse/)
GitHub [2.6.0-preview](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.Synapse_2.6.0-preview/sdk/synapse/Microsoft.Azure.Management.Synapse/) | | Management - Traffic Manager | NuGet [2.5.4](https://www.nuget.org/packages/Microsoft.Azure.Management.TrafficManager/2.5.4) | | GitHub [2.5.4](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/trafficmanager/Microsoft.Azure.Management.TrafficManager) | | Management - Traffic Manager Fluent | NuGet [1.38.1](https://www.nuget.org/packages/Microsoft.Azure.Management.TrafficManager.Fluent/1.38.1) | [docs](/dotnet/api/overview/azure/traffic-manager) | | -| Management - WebSites | NuGet [3.1.2](https://www.nuget.org/packages/Microsoft.Azure.Management.WebSites/3.1.2) | | GitHub [3.1.2](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/websites/Microsoft.Azure.Management.WebSites) | +| Management - WebSites | NuGet [4.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.WebSites/4.0.0) | | GitHub [4.0.0](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/websites/Microsoft.Azure.Management.WebSites) | | Management - Workload Monitor | NuGet [1.0.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.WorkloadMonitor/1.0.0-preview) | | | -| Microsoft.Azure.Management.RedisEnterprise | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.RedisEnterprise/2.0.0) | | | +| Microsoft.Azure.Management.RedisEnterprise | NuGet [3.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.RedisEnterprise/3.0.0) | | | | Profiles hybrid_2018_03_01 Management - Authorization | NuGet [0.9.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Profiles.hybrid_2018_03_01.Authorization/0.9.0-preview) | | | | Profiles hybrid_2018_03_01 Management - Compute | NuGet [0.9.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Profiles.hybrid_2018_03_01.Compute/0.9.0-preview) | | | | Profiles hybrid_2018_03_01 Management - DNS | NuGet [0.9.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Profiles.hybrid_2018_03_01.Dns/0.9.0-preview) | | | @@ -662,30 +670,36 @@ | Profiles hybrid_2019_03_01 Management - WebSites | NuGet [0.9.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Management.Profiles.hybrid_2019_03_01.Websites/0.9.0-preview) | | | | Resource Management - App Configuration | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.AppConfiguration/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.AppConfiguration-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.AppConfiguration_1.0.0-beta.4/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/) | | Resource Management - App Service | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.AppService/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.AppService-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.AppService_1.0.0-beta.2/sdk/websites/Azure.ResourceManager.AppService/) | -| Resource Management - Azure Stack HCI | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.0.0-beta.3/sdk/azurestackhci/Azure.ResourceManager.Hci/) | +| Resource Management - Azure Stack HCI | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.0.0-beta.4/sdk/azurestackhci/Azure.ResourceManager.Hci/) | | Resource Management - Cdn | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.Cdn/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.Cdn-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Cdn_1.0.0-beta.5/sdk/cdn/Azure.ResourceManager.Cdn/) | | Resource Management - Communication | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.0.0)
NuGet [1.1.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.1.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Communication-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.0.0/sdk/communication/Azure.ResourceManager.Communication/)
GitHub [1.1.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.1.0-beta.3/sdk/communication/Azure.ResourceManager.Communication/) | | Resource Management - Compute | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Compute/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Compute-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Compute_1.0.0-beta.8/sdk/compute/Azure.ResourceManager.Compute/) | | Resource Management - Connected VMware vSphere | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ConnectedVMwarevSphere/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ConnectedVMwarevSphere-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ConnectedVMwarevSphere_1.0.0-beta.4/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/) | -| Resource Management - Core | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.0.0/sdk/resourcemanager/Azure.ResourceManager/) | +| Resource Management - Container Apps | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Applications.Containers/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Applications.Containers-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Applications.Containers_1.0.0-beta.1/sdk/containerapps/Azure.ResourceManager.Applications.Containers/) | +| Resource Management - Core | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.1.0/sdk/resourcemanager/Azure.ResourceManager/) | | Resource Management - Cosmos DB | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.CosmosDB/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.CosmosDB-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.CosmosDB_1.0.0-beta.5/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/) | | Resource Management - Device Update | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.DeviceUpdate/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.DeviceUpdate-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.DeviceUpdate_1.0.0-beta.4/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/) | | Resource Management - DNS | NuGet [1.0.0-preview.1](https://www.nuget.org/packages/Azure.ResourceManager.Dns/1.0.0-preview.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Dns-readme-pre) | GitHub [1.0.0-preview.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Dns_1.0.0-preview.1/sdk/dns/Azure.ResourceManager.Dns/) | | Resource Management - Dns Resolver | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.DnsResolver/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.DnsResolver-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.DnsResolver_1.0.0-beta.3/sdk/dnsresolver/Azure.ResourceManager.DnsResolver/) | +| Resource Management - Dynatrace | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Dynatrace/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Dynatrace-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Dynatrace_1.0.0-beta.1/sdk/dynatrace/Azure.ResourceManager.Dynatrace/) | | Resource Management - Edge Order | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.EdgeOrder/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.EdgeOrder-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.EdgeOrder_1.0.0-beta.3/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/) | | Resource Management - Event Hubs | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.EventHubs/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.EventHubs-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.EventHubs_1.0.0-beta.4/sdk/eventhub/Azure.ResourceManager.EventHubs/) | | Resource Management - Extended Location | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.ExtendedLocation/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.ExtendedLocation-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ExtendedLocation_1.0.0-beta.2/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocation/) | +| Resource Management - Grafana | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Grafana-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.0.0-beta.1/sdk/grafana/Azure.ResourceManager.Grafana/) | +| Resource Management - IotCentral | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.IotCentral/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.IotCentral-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.IotCentral_1.0.0-beta.1/sdk/iotcentral/Azure.ResourceManager.IotCentral/) | | Resource Management - Key Vault | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.KeyVault/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.KeyVault-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.KeyVault_1.0.0-beta.8/sdk/keyvault/Azure.ResourceManager.KeyVault/) | +| Resource Management - Machine Learning | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearning/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearning-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MachineLearning_1.0.0-beta.1/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/) | | Resource Management - Monitor | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.Monitor/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.Monitor-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Monitor_1.0.0-beta.2/sdk/monitor/Azure.ResourceManager.Monitor/) | | Resource Management - Network | NuGet [1.0.0-beta.7](https://www.nuget.org/packages/Azure.ResourceManager.Network/1.0.0-beta.7) | [docs](/dotnet/api/overview/azure/ResourceManager.Network-readme-pre) | GitHub [1.0.0-beta.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Network_1.0.0-beta.7/sdk/network/Azure.ResourceManager.Network/) | -| Resource Management - Resources | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.0.0/sdk/resources/Azure.ResourceManager.Resources/) | +| Resource Management - Resources | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.1.0/sdk/resources/Azure.ResourceManager.Resources/) | | Resource Management - Service Bus | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ServiceBus/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ServiceBus-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ServiceBus_1.0.0-beta.4/sdk/servicebus/Azure.ResourceManager.ServiceBus/) | -| Resource Management - Sql | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Sql/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Sql-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Sql_1.0.0-beta.4/sdk/sqlmanagement/Azure.ResourceManager.Sql/) | -| Resource Management - Storage | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Storage/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Storage-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Storage_1.0.0-beta.8/sdk/storage/Azure.ResourceManager.Storage/) | +| Resource Management - Service Linker | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.ServiceLinker/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.ServiceLinker-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ServiceLinker_1.0.0-beta.1/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/) | +| Resource Management - Sql | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.Sql/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.Sql-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Sql_1.0.0-beta.5/sdk/sqlmanagement/Azure.ResourceManager.Sql/) | +| Resource Management - Storage | NuGet [1.0.0-beta.9](https://www.nuget.org/packages/Azure.ResourceManager.Storage/1.0.0-beta.9) | [docs](/dotnet/api/overview/azure/ResourceManager.Storage-readme-pre) | GitHub [1.0.0-beta.9](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Storage_1.0.0-beta.9/sdk/storage/Azure.ResourceManager.Storage/) | | Resource Management - Storage Pool | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.StoragePool/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.StoragePool-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.StoragePool_1.0.0-beta.3/sdk/storagepool/Azure.ResourceManager.StoragePool/) | | Resource Management - Web PubSub | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.WebPubSub/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.WebPubSub-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WebPubSub_1.0.0-beta.4/sdk/webpubsub/Azure.ResourceManager.WebPubSub/) | | Security Insights | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.Management.SecurityInsights/2.0.0) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Management.SecurityInsights_2.0.0/sdk/securityinsights/Microsoft.Azure.Management.SecurityInsights/) | -| SignalR Management | NuGet [1.17.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Management/1.17.0) | | GitHub [1.17.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR.Management) | +| SignalR Management | NuGet [1.18.0](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Management/1.18.0) | | GitHub [1.18.0](https://github.com/Azure/azure-signalr/tree/v1.5.0/src/Microsoft.Azure.SignalR.Management) | | SQL Server Mangement - Key Vault Provider | NuGet [2.4.0](https://www.nuget.org/packages/Microsoft.SqlServer.Management.AlwaysEncrypted.AzureKeyVaultProvider/2.4.0) | | | | WindowsAzure Management | NuGet [4.1.3](https://www.nuget.org/packages/Microsoft.WindowsAzure.Management/4.1.3) | | | | WindowsAzure Management - Automation | NuGet [1.0.3](https://www.nuget.org/packages/Microsoft.WindowsAzure.Management.Automation/1.0.3) | | | diff --git a/docs/azure/includes/dotnet-new.md b/docs/azure/includes/dotnet-new.md index bc3384158b3de..67a013a115020 100644 --- a/docs/azure/includes/dotnet-new.md +++ b/docs/azure/includes/dotnet-new.md @@ -7,9 +7,9 @@ | ASP.NET Extension - DataProtection Keys | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Extensions.AspNetCore.DataProtection.Keys/1.1.0) | [docs](/dotnet/api/overview/azure/Extensions.AspNetCore.DataProtection.Keys-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Extensions.AspNetCore.DataProtection.Keys_1.1.0/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/) | | Attestation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Security.Attestation/1.0.0) | [docs](/dotnet/api/overview/azure/Security.Attestation-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.Attestation_1.0.0/sdk/attestation/Azure.Security.Attestation/) | | Azure Mixed Reality Authentication | NuGet [1.0.1](https://www.nuget.org/packages/Azure.MixedReality.Authentication/1.0.1) | [docs](/dotnet/api/overview/azure/MixedReality.Authentication-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.Authentication_1.0.1/sdk/mixedreality/Azure.MixedReality.Authentication/) | -| Azure Object Anchors Conversion | NuGet [0.3.0-beta.2](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.2) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme-pre) | GitHub [0.3.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.2/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | +| Azure Object Anchors Conversion | NuGet [0.3.0-beta.3](https://www.nuget.org/packages/Azure.MixedReality.ObjectAnchors.Conversion/0.3.0-beta.3) | [docs](/dotnet/api/overview/azure/MixedReality.ObjectAnchors.Conversion-readme-pre) | GitHub [0.3.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.ObjectAnchors.Conversion_0.3.0-beta.3/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/) | | Azure Remote Rendering | NuGet [1.1.0](https://www.nuget.org/packages/Azure.MixedReality.RemoteRendering/1.1.0) | [docs](/dotnet/api/overview/azure/MixedReality.RemoteRendering-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.MixedReality.RemoteRendering_1.1.0/sdk/remoterendering/Azure.MixedReality.RemoteRendering/) | -| Azure Video Analyzer Edge | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Media.VideoAnalyzer.Edge/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Media.VideoAnalyzer.Edge-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Media.VideoAnalyzer.Edge_1.0.0-beta.5/sdk/videoanalyzer/Azure.Media.VideoAnalyzer.Edge/) | +| Azure Video Analyzer Edge | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.Media.VideoAnalyzer.Edge/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/Media.VideoAnalyzer.Edge-readme-pre) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Media.VideoAnalyzer.Edge_1.0.0-beta.6/sdk/videoanalyzer/Azure.Media.VideoAnalyzer.Edge/) | | Azure.Analytics.Purview.Administration | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Analytics.Purview.Administration/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Analytics.Purview.Administration-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Purview.Administration_1.0.0-beta.1/sdk/purview/Azure.Analytics.Purview.Administration/) | | Azure.Identity.BrokeredAuthentication | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Identity.BrokeredAuthentication/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Identity.BrokeredAuthentication-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity.BrokeredAuthentication_1.0.0-beta.2/sdk/identity/Azure.Identity.BrokeredAuthentication/) | | Cognitive Search | NuGet [11.3.0](https://www.nuget.org/packages/Azure.Search.Documents/11.3.0)
NuGet [11.4.0-beta.7](https://www.nuget.org/packages/Azure.Search.Documents/11.4.0-beta.7) | [docs](/dotnet/api/overview/azure/Search.Documents-readme) | GitHub [11.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.3.0/sdk/search/Azure.Search.Documents/)
GitHub [11.4.0-beta.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Search.Documents_11.4.0-beta.7/sdk/search/Azure.Search.Documents/) | @@ -21,18 +21,18 @@ | Communication SMS | NuGet [1.0.1](https://www.nuget.org/packages/Azure.Communication.Sms/1.0.1) | [docs](/dotnet/api/overview/azure/Communication.Sms-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Communication.Sms_1.0.1/sdk/communication/Azure.Communication.Sms/) | | ConfidentialLedger | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Security.ConfidentialLedger/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Security.ConfidentialLedger-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.ConfidentialLedger_1.0.0-beta.2/sdk/confidentialledger/Azure.Security.ConfidentialLedger/) | | Container Registry | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Containers.ContainerRegistry/1.0.0)
NuGet [1.1.0-beta.4](https://www.nuget.org/packages/Azure.Containers.ContainerRegistry/1.1.0-beta.4) | [docs](/dotnet/api/overview/azure/Containers.ContainerRegistry-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Containers.ContainerRegistry_1.0.0/sdk/containerregistry/Azure.Containers.ContainerRegistry/)
GitHub [1.1.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Containers.ContainerRegistry_1.1.0-beta.4/sdk/containerregistry/Azure.Containers.ContainerRegistry/) | -| Conversation Analysis | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.0.0-beta.2/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | +| Conversation Analysis | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.Language.Conversations/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.Language.Conversations-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.Conversations_1.0.0-beta.3/sdk/cognitivelanguage/Azure.AI.Language.Conversations/) | | Core | NuGet [1.24.0](https://www.nuget.org/packages/Azure.Core/1.24.0) | [docs](/dotnet/api/overview/azure/Core-readme) | GitHub [1.24.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core_1.24.0/sdk/core/Azure.Core/) | | Core - AMQP | NuGet [1.2.0](https://www.nuget.org/packages/Azure.Core.Amqp/1.2.0) | [docs](/dotnet/api/overview/azure/Core.Amqp-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Core.Amqp_1.2.0/sdk/core/Azure.Core.Amqp/) | | Cosmos DB | NuGet [4.0.0-preview3](https://www.nuget.org/packages/Azure.Cosmos/4.0.0-preview3) | [docs](/dotnet/api/azure.cosmos) | GitHub [4.0.0-preview3](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/releases/4.0.0-preview3) | | Digital Twins - Core | NuGet [1.2.2](https://www.nuget.org/packages/Azure.DigitalTwins.Core/1.2.2)
NuGet [1.4.0-beta.1](https://www.nuget.org/packages/Azure.DigitalTwins.Core/1.4.0-beta.1) | [docs](/dotnet/api/overview/azure/DigitalTwins.Core-readme) | GitHub [1.2.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.DigitalTwins.Core_1.2.2/sdk/digitaltwins/Azure.DigitalTwins.Core/)
GitHub [1.4.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.DigitalTwins.Core_1.4.0-beta.1/sdk/digitaltwins/Azure.DigitalTwins.Core/) | -| Document Translation | NuGet [1.0.0-beta.6](https://www.nuget.org/packages/Azure.AI.Translation.Document/1.0.0-beta.6) | [docs](/dotnet/api/overview/azure/AI.Translation.Document-readme-pre) | GitHub [1.0.0-beta.6](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Document_1.0.0-beta.6/sdk/translation/Azure.AI.Translation.Document/) | -| Event Grid | NuGet [4.10.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.10.0)
NuGet [4.11.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.11.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid-readme) | GitHub [4.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.10.0/sdk/eventgrid/Azure.Messaging.EventGrid/)
GitHub [4.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.11.0-beta.1/sdk/eventgrid/Azure.Messaging.EventGrid/) | -| Event Hubs | NuGet [5.6.2](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.6.2)
NuGet [5.7.0-beta.5](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.7.0-beta.5) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs-readme) | GitHub [5.6.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.6.2/sdk/eventhub/Azure.Messaging.EventHubs/)
GitHub [5.7.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.7.0-beta.5/sdk/eventhub/Azure.Messaging.EventHubs/) | -| Event Hubs - Event Processor | NuGet [5.6.2](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.6.2)
NuGet [5.7.0-beta.5](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.7.0-beta.5) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs.Processor-readme) | GitHub [5.6.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.6.2/sdk/eventhub/Azure.Messaging.EventHubs.Processor/)
GitHub [5.7.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.7.0-beta.5/sdk/eventhub/Azure.Messaging.EventHubs.Processor/) | -| Extensions - Azure | NuGet [1.1.1](https://www.nuget.org/packages/Microsoft.Extensions.Azure/1.1.1) | | GitHub [1.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Extensions.Azure_1.1.1/sdk/extensions/Microsoft.Extensions.Azure/) | +| Document Translation | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Translation.Document/1.0.0) | [docs](/dotnet/api/overview/azure/AI.Translation.Document-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Translation.Document_1.0.0/sdk/translation/Azure.AI.Translation.Document/) | +| Event Grid | NuGet [4.10.0](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.10.0)
NuGet [4.11.0-beta.2](https://www.nuget.org/packages/Azure.Messaging.EventGrid/4.11.0-beta.2) | [docs](/dotnet/api/overview/azure/Messaging.EventGrid-readme) | GitHub [4.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.10.0/sdk/eventgrid/Azure.Messaging.EventGrid/)
GitHub [4.11.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventGrid_4.11.0-beta.2/sdk/eventgrid/Azure.Messaging.EventGrid/) | +| Event Hubs | NuGet [5.7.0](https://www.nuget.org/packages/Azure.Messaging.EventHubs/5.7.0) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs-readme) | GitHub [5.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.7.0/sdk/eventhub/Azure.Messaging.EventHubs/) | +| Event Hubs - Event Processor | NuGet [5.7.0](https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor/5.7.0) | [docs](/dotnet/api/overview/azure/Messaging.EventHubs.Processor-readme) | GitHub [5.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs.Processor_5.7.0/sdk/eventhub/Azure.Messaging.EventHubs.Processor/) | +| Extensions - Azure | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Extensions.Azure/1.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Extensions.Azure-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Extensions.Azure_1.2.0/sdk/extensions/Microsoft.Extensions.Azure/) | | FarmBeats | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.Verticals.AgriFood.Farming/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/Verticals.AgriFood.Farming-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Verticals.AgriFood.Farming_1.0.0-beta.1/sdk/farmbeats/Azure.Verticals.AgriFood.Farming/) | -| Form Recognizer | NuGet [3.1.1](https://www.nuget.org/packages/Azure.AI.FormRecognizer/3.1.1)
NuGet [4.0.0-beta.3](https://www.nuget.org/packages/Azure.AI.FormRecognizer/4.0.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.FormRecognizer-readme) | GitHub [3.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_3.1.1/sdk/formrecognizer/Azure.AI.FormRecognizer/)
GitHub [4.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_4.0.0-beta.3/sdk/formrecognizer/Azure.AI.FormRecognizer/) | +| Form Recognizer | NuGet [3.1.1](https://www.nuget.org/packages/Azure.AI.FormRecognizer/3.1.1)
NuGet [4.0.0-beta.4](https://www.nuget.org/packages/Azure.AI.FormRecognizer/4.0.0-beta.4) | [docs](/dotnet/api/overview/azure/AI.FormRecognizer-readme) | GitHub [3.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_3.1.1/sdk/formrecognizer/Azure.AI.FormRecognizer/)
GitHub [4.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.FormRecognizer_4.0.0-beta.4/sdk/formrecognizer/Azure.AI.FormRecognizer/) | | Identity | NuGet [1.6.0](https://www.nuget.org/packages/Azure.Identity/1.6.0) | [docs](/dotnet/api/overview/azure/Identity-readme) | GitHub [1.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Identity_1.6.0/sdk/identity/Azure.Identity/) | | IoT Device Update | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.IoT.DeviceUpdate/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/IoT.DeviceUpdate-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.IoT.DeviceUpdate_1.0.0-beta.3/sdk/deviceupdate/Azure.IoT.DeviceUpdate/) | | Key Vault - Administration | NuGet [4.1.0](https://www.nuget.org/packages/Azure.Security.KeyVault.Administration/4.1.0) | [docs](/dotnet/api/overview/azure/Security.KeyVault.Administration-readme) | GitHub [4.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Security.KeyVault.Administration_4.1.0/sdk/keyvault/Azure.Security.KeyVault.Administration/) | @@ -48,56 +48,61 @@ | Purview Catalog | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Purview.Catalog/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Purview.Catalog-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Purview.Catalog_1.0.0-beta.3/sdk/purview/Azure.Analytics.Purview.Catalog/) | | Purview Scanning | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.Analytics.Purview.Scanning/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/Analytics.Purview.Scanning-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Purview.Scanning_1.0.0-beta.2/sdk/purview/Azure.Analytics.Purview.Scanning/) | | Question Answering | NuGet [1.0.0](https://www.nuget.org/packages/Azure.AI.Language.QuestionAnswering/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Azure.AI.Language.QuestionAnswering/1.1.0-beta.1) | [docs](/dotnet/api/overview/azure/AI.Language.QuestionAnswering-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.QuestionAnswering_1.0.0/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.Language.QuestionAnswering_1.1.0-beta.1/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/) | -| Schema Registry | NuGet [1.1.0](https://www.nuget.org/packages/Azure.Data.SchemaRegistry/1.1.0) | [docs](/dotnet/api/overview/azure/Data.SchemaRegistry-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.SchemaRegistry_1.1.0/sdk/schemaregistry/Azure.Data.SchemaRegistry/) | -| Schema Registry - Avro | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro_1.0.0-beta.8/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/) | -| Service Bus | NuGet [7.7.0](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.7.0)
NuGet [7.8.0-beta.2](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.8.0-beta.2) | [docs](/dotnet/api/overview/azure/Messaging.ServiceBus-readme) | GitHub [7.7.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.7.0/sdk/servicebus/Azure.Messaging.ServiceBus/)
GitHub [7.8.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.8.0-beta.2/sdk/servicebus/Azure.Messaging.ServiceBus/) | -| Storage - Blobs | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Storage.Blobs/12.11.0)
NuGet [12.12.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Blobs/12.12.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.11.0/sdk/storage/Azure.Storage.Blobs/)
GitHub [12.12.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.12.0-beta.1/sdk/storage/Azure.Storage.Blobs/) | -| Storage - Blobs Batch | NuGet [12.8.0](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.8.0)
NuGet [12.9.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.9.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.8.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.8.0/sdk/storage/Azure.Storage.Blobs.Batch/)
GitHub [12.9.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.9.0-beta.1/sdk/storage/Azure.Storage.Blobs.Batch/) | -| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.23](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.23) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme-pre) | GitHub [12.0.0-preview.23](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.23/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) | -| Storage - Common | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Common/12.10.0)
NuGet [12.11.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Common/12.11.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.10.0/sdk/storage/Azure.Storage.Common/)
GitHub [12.11.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.11.0-beta.1/sdk/storage/Azure.Storage.Common/) | -| Storage - Files Data Lake | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.9.0/sdk/storage/Azure.Storage.Files.DataLake/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.10.0-beta.1/sdk/storage/Azure.Storage.Files.DataLake/) | -| Storage - Files Shares | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.9.0/sdk/storage/Azure.Storage.Files.Shares/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.10.0-beta.1/sdk/storage/Azure.Storage.Files.Shares/) | -| Storage - Queues | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.9.0)
NuGet [12.10.0-beta.1](https://www.nuget.org/packages/Azure.Storage.Queues/12.10.0-beta.1) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.9.0/sdk/storage/Azure.Storage.Queues/)
GitHub [12.10.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.10.0-beta.1/sdk/storage/Azure.Storage.Queues/) | +| Schema Registry | NuGet [1.2.0](https://www.nuget.org/packages/Azure.Data.SchemaRegistry/1.2.0) | [docs](/dotnet/api/overview/azure/Data.SchemaRegistry-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.SchemaRegistry_1.2.0/sdk/schemaregistry/Azure.Data.SchemaRegistry/) | +| Schema Registry - Avro | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/1.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro_1.0.0/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/) | +| Service Bus | NuGet [7.8.1](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.8.1)
NuGet [7.9.0-beta.1](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.9.0-beta.1) | [docs](/dotnet/api/overview/azure/Messaging.ServiceBus-readme) | GitHub [7.8.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.8.1/sdk/servicebus/Azure.Messaging.ServiceBus/)
GitHub [7.9.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.9.0-beta.1/sdk/servicebus/Azure.Messaging.ServiceBus/) | +| Storage - Blobs | NuGet [12.12.0](https://www.nuget.org/packages/Azure.Storage.Blobs/12.12.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.12.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.12.0/sdk/storage/Azure.Storage.Blobs/) | +| Storage - Blobs Batch | NuGet [12.9.0](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.9.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.9.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.9.0/sdk/storage/Azure.Storage.Blobs.Batch/) | +| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.25](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.25) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme-pre) | GitHub [12.0.0-preview.25](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.25/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) | +| Storage - Common | NuGet [12.11.0](https://www.nuget.org/packages/Azure.Storage.Common/12.11.0) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.11.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.11.0/sdk/storage/Azure.Storage.Common/) | +| Storage - Files Data Lake | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.10.0/sdk/storage/Azure.Storage.Files.DataLake/) | +| Storage - Files Shares | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.10.0/sdk/storage/Azure.Storage.Files.Shares/) | +| Storage - Queues | NuGet [12.10.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.10.0) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.10.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.10.0/sdk/storage/Azure.Storage.Queues/) | | Synapse - AccessControl | NuGet [1.0.0-preview.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.AccessControl/1.0.0-preview.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.AccessControl-readme-pre) | GitHub [1.0.0-preview.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.AccessControl_1.0.0-preview.5/sdk/synapse/Azure.Analytics.Synapse.AccessControl/) | -| Synapse - Artifacts | NuGet [1.0.0-preview.14](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.14) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme-pre) | GitHub [1.0.0-preview.14](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.14/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | +| Synapse - Artifacts | NuGet [1.0.0-preview.15](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.15) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme-pre) | GitHub [1.0.0-preview.15](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.15/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) | | Synapse - Managed Private Endpoints | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.ManagedPrivateEndpoints/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.ManagedPrivateEndpoints-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.ManagedPrivateEndpoints_1.0.0-beta.5/sdk/synapse/Azure.Analytics.Synapse.ManagedPrivateEndpoints/) | | Synapse - Monitoring | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.Analytics.Synapse.Monitoring/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Monitoring-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Monitoring_1.0.0-beta.3/sdk/synapse/Azure.Analytics.Synapse.Monitoring/) | | Synapse - Spark | NuGet [1.0.0-preview.8](https://www.nuget.org/packages/Azure.Analytics.Synapse.Spark/1.0.0-preview.8) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Spark-readme-pre) | GitHub [1.0.0-preview.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Spark_1.0.0-preview.8/sdk/synapse/Azure.Analytics.Synapse.Spark/) | -| Tables | NuGet [12.5.0](https://www.nuget.org/packages/Azure.Data.Tables/12.5.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.5.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.5.0/sdk/tables/Azure.Data.Tables/) | -| Text Analytics | NuGet [5.1.1](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.1.1)
NuGet [5.2.0-beta.2](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.2.0-beta.2) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.1.1/sdk/textanalytics/Azure.AI.TextAnalytics/)
GitHub [5.2.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.2.0-beta.2/sdk/textanalytics/Azure.AI.TextAnalytics/) | +| Tables | NuGet [12.6.0](https://www.nuget.org/packages/Azure.Data.Tables/12.6.0) | [docs](/dotnet/api/overview/azure/Data.Tables-readme) | GitHub [12.6.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.Tables_12.6.0/sdk/tables/Azure.Data.Tables/) | +| Text Analytics | NuGet [5.1.1](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.1.1)
NuGet [5.2.0-beta.3](https://www.nuget.org/packages/Azure.AI.TextAnalytics/5.2.0-beta.3) | [docs](/dotnet/api/overview/azure/AI.TextAnalytics-readme) | GitHub [5.1.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.1.1/sdk/textanalytics/Azure.AI.TextAnalytics/)
GitHub [5.2.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.AI.TextAnalytics_5.2.0-beta.3/sdk/textanalytics/Azure.AI.TextAnalytics/) | | Web PubSub | NuGet [1.0.0](https://www.nuget.org/packages/Azure.Messaging.WebPubSub/1.0.0) | [docs](/dotnet/api/overview/azure/Messaging.WebPubSub-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.WebPubSub_1.0.0/sdk/webpubsub/Azure.Messaging.WebPubSub/) | | Azure Functions extension for Azure Table service | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Tables/1.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Tables-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.Tables_1.0.0/sdk/tables/Microsoft.Azure.WebJobs.Extensions.Tables/) | | CloudNative CloudEvents with Event Grid | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents/1.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents_1.0.0/sdk/eventgrid/Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents/) | | Core Spatial | NuGet [1.1.0](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial/1.1.0)
NuGet [1.2.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial/1.2.0-beta.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Core.Spatial-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial_1.1.0/sdk/core/Microsoft.Azure.Core.Spatial/)
GitHub [1.2.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial_1.2.0-beta.1/sdk/core/Microsoft.Azure.Core.Spatial/) | | Core Spatial Newtonsoft Json | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial.NewtonsoftJson/1.0.0)
NuGet [1.1.0-beta.1](https://www.nuget.org/packages/Microsoft.Azure.Core.Spatial.NewtonsoftJson/1.1.0-beta.1) | | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial.NewtonsoftJson_1.0.0/sdk/core/Microsoft.Azure.Core.Spatial.NewtonsoftJson/)
GitHub [1.1.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Core.Spatial.NewtonsoftJson_1.1.0-beta.1/sdk/core/Microsoft.Azure.Core.Spatial.NewtonsoftJson/) | -| WebJobs Extensions - Event Grid | NuGet [3.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.1.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventGrid-readme) | GitHub [3.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventGrid_3.1.0/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/) | -| WebJobs Extensions - Event Hubs | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventHubs/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventHubs-readme) | GitHub [5.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventHubs_5.0.1/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/) | -| WebJobs Extensions - Service Bus | NuGet [5.3.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.3.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.ServiceBus-readme) | GitHub [5.3.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.ServiceBus_5.3.0/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/) | +| WebJobs Extensions - Event Grid | NuGet [3.2.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventGrid-readme) | GitHub [3.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventGrid_3.2.0/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/) | +| WebJobs Extensions - Event Hubs | NuGet [5.1.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventHubs/5.1.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventHubs-readme) | GitHub [5.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventHubs_5.1.0/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/) | +| WebJobs Extensions - Service Bus | NuGet [5.5.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.5.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.ServiceBus-readme) | GitHub [5.5.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.ServiceBus_5.5.1/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/) | | WebJobs Extensions - SignalR Service | NuGet [1.8.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.SignalRService/1.8.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.SignalRService-readme) | GitHub [1.8.0](https://github.com/Azure/azure-functions-signalrservice-extension/tree/v1.2.0/src/SignalRServiceExtension) | -| WebJobs Extensions - Storage | NuGet [5.0.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage/5.0.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage-readme) | GitHub [5.0.0](https://github.com/Azure/azure-webjobs-sdk/tree/master/src/Microsoft.Azure.WebJobs.Extensions.Storage) | +| WebJobs Extensions - Storage | NuGet [5.0.1](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage/5.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Storage-readme) | GitHub [5.0.1](https://github.com/Azure/azure-webjobs-sdk/tree/master/src/Microsoft.Azure.WebJobs.Extensions.Storage) | | WebJobs Extensions - Web PubSub | NuGet [1.2.0](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.WebPubSub/1.2.0) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.WebPubSub-readme) | GitHub [1.2.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.WebPubSub_1.2.0/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSub/) | -| Grafana | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.0.0-beta.1) | | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.0.0-beta.1/sdk/grafana/Azure.ResourceManager.Grafana/) | | Resource Management - App Configuration | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.AppConfiguration/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.AppConfiguration-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.AppConfiguration_1.0.0-beta.4/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/) | | Resource Management - App Service | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.AppService/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.AppService-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.AppService_1.0.0-beta.2/sdk/websites/Azure.ResourceManager.AppService/) | -| Resource Management - Azure Stack HCI | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.0.0-beta.3/sdk/azurestackhci/Azure.ResourceManager.Hci/) | +| Resource Management - Azure Stack HCI | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Hci/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Hci-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Hci_1.0.0-beta.4/sdk/azurestackhci/Azure.ResourceManager.Hci/) | | Resource Management - Cdn | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.Cdn/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.Cdn-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Cdn_1.0.0-beta.5/sdk/cdn/Azure.ResourceManager.Cdn/) | | Resource Management - Communication | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.0.0)
NuGet [1.1.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.Communication/1.1.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.Communication-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.0.0/sdk/communication/Azure.ResourceManager.Communication/)
GitHub [1.1.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Communication_1.1.0-beta.3/sdk/communication/Azure.ResourceManager.Communication/) | | Resource Management - Compute | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Compute/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Compute-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Compute_1.0.0-beta.8/sdk/compute/Azure.ResourceManager.Compute/) | | Resource Management - Connected VMware vSphere | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ConnectedVMwarevSphere/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ConnectedVMwarevSphere-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ConnectedVMwarevSphere_1.0.0-beta.4/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/) | -| Resource Management - Core | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.0.0/sdk/resourcemanager/Azure.ResourceManager/) | +| Resource Management - Container Apps | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Applications.Containers/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Applications.Containers-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Applications.Containers_1.0.0-beta.1/sdk/containerapps/Azure.ResourceManager.Applications.Containers/) | +| Resource Management - Core | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager_1.1.0/sdk/resourcemanager/Azure.ResourceManager/) | | Resource Management - Cosmos DB | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.CosmosDB/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.CosmosDB-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.CosmosDB_1.0.0-beta.5/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/) | | Resource Management - Device Update | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.DeviceUpdate/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.DeviceUpdate-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.DeviceUpdate_1.0.0-beta.4/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/) | | Resource Management - DNS | NuGet [1.0.0-preview.1](https://www.nuget.org/packages/Azure.ResourceManager.Dns/1.0.0-preview.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Dns-readme-pre) | GitHub [1.0.0-preview.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Dns_1.0.0-preview.1/sdk/dns/Azure.ResourceManager.Dns/) | | Resource Management - Dns Resolver | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.DnsResolver/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.DnsResolver-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.DnsResolver_1.0.0-beta.3/sdk/dnsresolver/Azure.ResourceManager.DnsResolver/) | +| Resource Management - Dynatrace | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Dynatrace/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Dynatrace-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Dynatrace_1.0.0-beta.1/sdk/dynatrace/Azure.ResourceManager.Dynatrace/) | | Resource Management - Edge Order | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.EdgeOrder/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.EdgeOrder-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.EdgeOrder_1.0.0-beta.3/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/) | | Resource Management - Event Hubs | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.EventHubs/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.EventHubs-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.EventHubs_1.0.0-beta.4/sdk/eventhub/Azure.ResourceManager.EventHubs/) | | Resource Management - Extended Location | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.ExtendedLocation/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.ExtendedLocation-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ExtendedLocation_1.0.0-beta.2/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocation/) | +| Resource Management - Grafana | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.Grafana/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.Grafana-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Grafana_1.0.0-beta.1/sdk/grafana/Azure.ResourceManager.Grafana/) | +| Resource Management - IotCentral | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.IotCentral/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.IotCentral-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.IotCentral_1.0.0-beta.1/sdk/iotcentral/Azure.ResourceManager.IotCentral/) | | Resource Management - Key Vault | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.KeyVault/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.KeyVault-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.KeyVault_1.0.0-beta.8/sdk/keyvault/Azure.ResourceManager.KeyVault/) | +| Resource Management - Machine Learning | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.MachineLearning/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.MachineLearning-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.MachineLearning_1.0.0-beta.1/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/) | | Resource Management - Monitor | NuGet [1.0.0-beta.2](https://www.nuget.org/packages/Azure.ResourceManager.Monitor/1.0.0-beta.2) | [docs](/dotnet/api/overview/azure/ResourceManager.Monitor-readme-pre) | GitHub [1.0.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Monitor_1.0.0-beta.2/sdk/monitor/Azure.ResourceManager.Monitor/) | | Resource Management - Network | NuGet [1.0.0-beta.7](https://www.nuget.org/packages/Azure.ResourceManager.Network/1.0.0-beta.7) | [docs](/dotnet/api/overview/azure/ResourceManager.Network-readme-pre) | GitHub [1.0.0-beta.7](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Network_1.0.0-beta.7/sdk/network/Azure.ResourceManager.Network/) | -| Resource Management - Resources | NuGet [1.0.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.0.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.0.0/sdk/resources/Azure.ResourceManager.Resources/) | +| Resource Management - Resources | NuGet [1.1.0](https://www.nuget.org/packages/Azure.ResourceManager.Resources/1.1.0) | [docs](/dotnet/api/overview/azure/ResourceManager.Resources-readme) | GitHub [1.1.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Resources_1.1.0/sdk/resources/Azure.ResourceManager.Resources/) | | Resource Management - Service Bus | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.ServiceBus/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.ServiceBus-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ServiceBus_1.0.0-beta.4/sdk/servicebus/Azure.ResourceManager.ServiceBus/) | -| Resource Management - Sql | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.Sql/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.Sql-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Sql_1.0.0-beta.4/sdk/sqlmanagement/Azure.ResourceManager.Sql/) | -| Resource Management - Storage | NuGet [1.0.0-beta.8](https://www.nuget.org/packages/Azure.ResourceManager.Storage/1.0.0-beta.8) | [docs](/dotnet/api/overview/azure/ResourceManager.Storage-readme-pre) | GitHub [1.0.0-beta.8](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Storage_1.0.0-beta.8/sdk/storage/Azure.ResourceManager.Storage/) | +| Resource Management - Service Linker | NuGet [1.0.0-beta.1](https://www.nuget.org/packages/Azure.ResourceManager.ServiceLinker/1.0.0-beta.1) | [docs](/dotnet/api/overview/azure/ResourceManager.ServiceLinker-readme-pre) | GitHub [1.0.0-beta.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.ServiceLinker_1.0.0-beta.1/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/) | +| Resource Management - Sql | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.ResourceManager.Sql/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/ResourceManager.Sql-readme-pre) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Sql_1.0.0-beta.5/sdk/sqlmanagement/Azure.ResourceManager.Sql/) | +| Resource Management - Storage | NuGet [1.0.0-beta.9](https://www.nuget.org/packages/Azure.ResourceManager.Storage/1.0.0-beta.9) | [docs](/dotnet/api/overview/azure/ResourceManager.Storage-readme-pre) | GitHub [1.0.0-beta.9](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.Storage_1.0.0-beta.9/sdk/storage/Azure.ResourceManager.Storage/) | | Resource Management - Storage Pool | NuGet [1.0.0-beta.3](https://www.nuget.org/packages/Azure.ResourceManager.StoragePool/1.0.0-beta.3) | [docs](/dotnet/api/overview/azure/ResourceManager.StoragePool-readme-pre) | GitHub [1.0.0-beta.3](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.StoragePool_1.0.0-beta.3/sdk/storagepool/Azure.ResourceManager.StoragePool/) | | Resource Management - Web PubSub | NuGet [1.0.0-beta.4](https://www.nuget.org/packages/Azure.ResourceManager.WebPubSub/1.0.0-beta.4) | [docs](/dotnet/api/overview/azure/ResourceManager.WebPubSub-readme-pre) | GitHub [1.0.0-beta.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.ResourceManager.WebPubSub_1.0.0-beta.4/sdk/webpubsub/Azure.ResourceManager.WebPubSub/) | diff --git a/docs/azure/install-azure-cli.md b/docs/azure/install-azure-cli.md index be49daf3468f2..2c75d31e8539e 100644 --- a/docs/azure/install-azure-cli.md +++ b/docs/azure/install-azure-cli.md @@ -4,8 +4,7 @@ description: Azure developers will need the Azure CLI installed, so this article ms.date: 11/30/2020 ms.topic: conceptual ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 recommendations: false --- diff --git a/docs/azure/intro.md b/docs/azure/intro.md index 13c2e833b5cf5..7fd572410ffe7 100644 --- a/docs/azure/intro.md +++ b/docs/azure/intro.md @@ -4,8 +4,7 @@ description: Learn the basics you need to know about Azure and .NET. ms.date: 05/05/2021 ms.topic: overview ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 --- # Introduction to Azure and .NET diff --git a/docs/azure/key-azure-services.md b/docs/azure/key-azure-services.md index f7a7adaf5a03e..642fc7d5e44b7 100644 --- a/docs/azure/key-azure-services.md +++ b/docs/azure/key-azure-services.md @@ -4,7 +4,6 @@ description: Azure has over 100 services, but this article focuses on the ~8 or ms.date: 06/01/2021 ms.topic: conceptual ms.custom: devx-track-dotnet -ms.author: daberry author: DavidCBerry13 --- diff --git a/docs/azure/migration/sql.md b/docs/azure/migration/sql.md index 1e928bb4bea9c..e0383821529b6 100644 --- a/docs/azure/migration/sql.md +++ b/docs/azure/migration/sql.md @@ -10,7 +10,7 @@ recommendations: false This article provides a brief outline of two options for migrating a SQL Server database to Azure. Azure has three primary options for migrating a production SQL Server database. This article focuses on the following two options: -1. [SQL Server on Azure VMs](/azure/virtual-machines/windows/sql/virtual-machines-windows-sql-server-iaas-overview): A SQL Server instance installed and hosted on a Windows Virtual Machine running in Azure, also known as Infrastructure as a Service (IaaS). +1. [SQL Server on Azure VMs](/azure/azure-sql/virtual-machines/windows/sql-server-on-azure-vm-iaas-what-is-overview): A SQL Server instance installed and hosted on a Windows Virtual Machine running in Azure, also known as Infrastructure as a Service (IaaS). 2. [Azure SQL Database](/azure/sql-database/sql-database-technical-overview): A fully managed SQL database Azure service, also known as Platform as a Service (PaaS). Both come with pros and cons that you will need to evaluate before migrating. The third option is [Azure SQL Database managed instances](/azure/sql-database/sql-database-managed-instance). @@ -19,14 +19,14 @@ Both come with pros and cons that you will need to evaluate before migrating. Th The following migration guides will be useful, depending on which service you use: -* [Migrate a SQL Server database to SQL Server in an Azure VM](/azure/virtual-machines/windows/sql/virtual-machines-windows-migrate-sql) -* [Migrate your SQL Server database to Azure SQL Database](/azure/sql-database/sql-database-migrate-your-sql-server-database) +* [Migrate a SQL Server database to SQL Server in an Azure VM](/azure/azure-sql/migration-guides/virtual-machines/sql-server-to-sql-on-azure-vm-migration-overview) +* [Migrate your SQL Server database to Azure SQL Database](/azure/dms/tutorial-sql-server-to-azure-sql) Additionally, the following links to conceptual content will help you understand VMs better: -* [High availability and disaster recovery for SQL Server in Azure Virtual Machines](/azure/virtual-machines/windows/sql/virtual-machines-windows-sql-high-availability-dr) -* [Performance best practices for SQL Server in Azure Virtual Machines](/azure/virtual-machines/windows/sql/virtual-machines-windows-sql-performance) -* [Application Patterns and Development Strategies for SQL Server in Azure Virtual Machines](/azure/virtual-machines/windows/sql/virtual-machines-windows-sql-server-app-patterns-dev-strategies) +* [High availability and disaster recovery for SQL Server in Azure Virtual Machines](/azure/azure-sql/virtual-machines/windows/business-continuity-high-availability-disaster-recovery-hadr-overview) +* [Performance best practices for SQL Server in Azure Virtual Machines](/azure/azure-sql/virtual-machines/windows/performance-guidelines-best-practices-checklist) +* [Application Patterns and Development Strategies for SQL Server in Azure Virtual Machines](/azure/azure-sql/virtual-machines/windows/application-patterns-development-strategies) And the following links will help you understand Azure SQL Database better: diff --git a/docs/azure/sdk/authentication-additional-methods.md b/docs/azure/sdk/authentication-additional-methods.md new file mode 100644 index 0000000000000..7144fd0b8e4fc --- /dev/null +++ b/docs/azure/sdk/authentication-additional-methods.md @@ -0,0 +1,78 @@ +--- +title: Additional methods to authenticate to Azure resources from .NET apps +description: This article describes additional, less common methods you can use to authenticate your .NET app to Azure resources. +ms.date: 05/05/2022 +ms.topic: how-to +ms.custom: devx-track-dotnet +--- + +# Additional methods to authenticate to Azure resources from .NET apps + +This article lists additional methods apps may use to authenticate to Azure resources. The methods on this page are less commonly used and when possible, it is encouraged to use one of the methods outlined in the [authenticating .NET apps to Azure using the Azure SDK overview](./authentication.md) article. + +## Interactive browser authentication + +This method interactively authenticates an application through [`InteractiveBrowserCredential`](/dotnet/api/azure.identity.interactivebrowsercredential) by collecting user credentials in the default system. + +Interactive browser authentication enables the application for all operations allowed by the interactive login credentials. As a result, if you are the owner or administrator of your subscription, your code has inherent access to most resources in that subscription without having to assign any specific permissions. For this reason, the use of interactive browser authentication is discouraged for anything but experimentation. + +### Example using InteractiveBrowserCredential + +The following example demonstrates using an [`InteractiveBrowserCredential`](/dotnet/api/azure.identity.interactivebrowsercredential) to authenticate with the [`BlobServiceClient`](/dotnet/api/azure.storage.blobs.blobserviceclient): + +```csharp +using Azure.Identity; +using Azure.Storage.Blobs; + +var client = new BlobServiceClient( + new Uri("https://.blob.core.windows.net"), + new InteractiveBrowserCredential()); + +foreach (var blobItem in client.GetBlobContainers()) +{ + Console.WriteLine(blobItem.Name); +} +``` + +For more exact control, such as setting redirect URIs, you can supply specific arguments to `InteractiveBrowserCredential` such as `redirect_uri`. + +## Device code authentication + +This method interactively authenticates a user on devices with limited UI (typically devices without a keyboard): + +1. When the application attempts to authenticate, the credential prompts the user with a URL and an authentication code. +1. The user visits the URL on a separate browser-enabled device (a computer, smartphone, etc.) and enters the code. +1. The user follows a normal authentication process in the browser. +1. Upon successful authentication, the application is authenticated on the device. + +For more information, see [Microsoft identity platform and the OAuth 2.0 device authorization grant flow](/azure/active-directory/develop/v2-oauth2-device-code). + +Device code authentication in a development environment enables the application for all operations allowed by the interactive login credentials. As a result, if you are the owner or administrator of your subscription, your code has inherent access to most resources in that subscription without having to assign any specific permissions. However, you can use this method with a specific client ID, rather than the default, for which you can assign specific permissions. + +## Authentication with a username and password + +This method authenticates an application using previous-collected credentials and the [`UsernamePasswordCredential`](/dotnet/api/azure.identity.usernamepasswordcredential) object. + +This method of authentication is discouraged because it's less secure than other flows. Also, this method is not interactive and is therefore **not compatible with any form of multi-factor authentication or consent prompting.** The application must already have consent from the user or a directory administrator. + +Furthermore, this method authenticates only work and school accounts; Microsoft accounts are not supported. For more information, see [Sign up your organization to use Azure Active Directory](/azure/active-directory/fundamentals/sign-up-organization). + +```csharp +using Azure.Identity; +using Azure.Storage.Blobs; + +var clientId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID"); +var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID"); +var username = Environment.GetEnvironmentVariable("AZURE_USERNAME"); +var password = Environment.GetEnvironmentVariable("AZURE_PASSWORD"); + +var client = new BlobServiceClient( + new Uri("https://.blob.core.windows.net"), + new UsernamePasswordCredential(username, password, tenantId, clientId)); + +foreach (var blobItem in client.GetBlobContainers()) +{ + Console.WriteLine(blobItem.Name); +} + +``` diff --git a/docs/azure/sdk/authentication-azure-hosted-apps.md b/docs/azure/sdk/authentication-azure-hosted-apps.md new file mode 100644 index 0000000000000..6bc5092952495 --- /dev/null +++ b/docs/azure/sdk/authentication-azure-hosted-apps.md @@ -0,0 +1,110 @@ +--- +title: Authenticating Azure-hosted apps to Azure resources with the Azure SDK for .NET +description: This article covers how to configure authentication for apps to Azure services when the app is hosted in an Azure service like Azure App Service, Azure Functions, or Azure Virtual Machines. +ms.date: 05/05/2022 +ms.topic: how-to +ms.custom: devx-track-dotnet +--- + +# Authenticating Azure-hosted apps to Azure resources with the Azure SDK for .NET + +When an app is hosted in Azure using a service like Azure App Service, Azure Virtual Machines, or Azure Container Instances, the recommended approach to authenticating an app to Azure resources is to use a [managed identity](/azure/active-directory/managed-identities-azure-resources/overview). + +A managed identity provides an identity for your app such that it can connect to other Azure resources without the need to use a secret key or other application secret. Internally, Azure knows the identity of your app and what resources it's allowed to connect to. Azure uses this information to automatically obtain Azure AD tokens for the app to allow it to connect to other Azure resources, all without you having to manage any application secrets. + +## Managed identity types + +There are two types of managed identities: + +- **System-assigned managed identities** - This type of managed identity is provided by and tied directly to an Azure resource. When you enable managed identity on an Azure resource, you get a system-assigned managed identity for that resource. A system-assigned managed identity is tied to the lifecycle of the Azure resource it's associated with. When the resource is deleted, Azure automatically deletes the identity for you. Since all you have to do is enable managed identity for the Azure resource hosting your code, this is the easiest type of managed identity to use. +- **User-assigned managed identities** - You may also create a managed identity as a standalone Azure resource. This is most frequently used when your solution has multiple workloads that run on multiple Azure resources that all need to share the same identity and same permissions. For example, if your solution had components that ran on multiple App Service and virtual machine instances that all needed access to the same set of Azure resources, creating and using a user-assigned managed identity across those resources would make sense. + +This article will cover the steps to enable and use a system-assigned managed identity for an app. If you need to use a user-assigned managed identity, see the article [Manage user-assigned managed identities](/azure/active-directory/managed-identities-azure-resources/how-manage-user-assigned-managed-identities) to see how to create a user-assigned managed identity. + +## 1 - Enable managed identity in the Azure resource hosting the app + +The first step is to enable managed identity on Azure resource hosting your app. For example, if you're hosting a .NET application using Azure App Service, you need to enable managed identity for the App Service web app that is hosting your app. If you were using a virtual machine to host your app, you would enable your VM to use managed identity. + +You can enable managed identity to be used for an Azure resource using either the Azure portal or the Azure CLI. + +### [Azure portal](#tab/azure-portal) + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Enable managed identity step 1](<./includes/enable-managed-identity-azure-portal-1.md>)] | :::image type="content" source="./media/enable-managed-identity-azure-portal-1-240px.png" alt-text="A screenshot showing how to use the top search bar in the Azure portal to locate and navigate to a resource in Azure." lightbox="./media/enable-managed-identity-azure-portal-1.png"::: | +| [!INCLUDE [Enable managed identity step 2](<./includes/enable-managed-identity-azure-portal-2.md>)] | :::image type="content" source="./media/enable-managed-identity-azure-portal-2-240px.png" alt-text="A screenshot showing the location of the Identity menu item in the left-hand menu for an Azure resource." lightbox="./media/enable-managed-identity-azure-portal-2.png"::: | +| [!INCLUDE [Enable managed identity step 3](<./includes/enable-managed-identity-azure-portal-3.md>)] | :::image type="content" source="./media/enable-managed-identity-azure-portal-3-240px.png" alt-text="A screenshot showing how to enable managed identity for an Azure resource on the resource's Identity page." lightbox="./media/enable-managed-identity-azure-portal-3.png"::: | + +### [Azure CLI](#tab/azure-cli) + +Azure CLI commands can be run in the [Azure Cloud Shell](https://shell.azure.com) or on a workstation with the [Azure CLI installed](/cli/azure/install-azure-cli). + +The Azure CLI commands used to enable managed identity for an Azure resource are of the form `az identity --resource-group --name `. Specific commands for popular Azure services are shown below. + +[!INCLUDE [Enable managed identity Azure CLI](<./includes/enable-managed-identity-azure-cli.md>)] + +The output will look like the following. + +```json +{ + "principalId": "99999999-9999-9999-9999-999999999999", + "tenantId": "33333333-3333-3333-3333-333333333333", + "type": "SystemAssigned", + "userAssignedIdentities": null +} + +``` + +The `principalId` value is the unique ID of the managed identity. Keep a copy of this output as you'll need these values in the next step. + +--- + +## 2 - Assign roles to the managed identity + +Next, you need to determine what roles (permissions) your app needs and assign the managed identity to those roles in Azure. A managed identity can be assigned roles at a resource, resource group, or subscription scope. This example will show how to assign roles at the resource group scope since most applications group all their Azure resources into a single resource group. + +### [Azure portal](#tab/azure-portal) + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Assign managed identity to role step 1](<./includes/assign-managed-identity-to-role-azure-portal-1.md>)] | :::image type="content" source="./media/assign-managed-identity-to-role-azure-portal-1-240px.png" alt-text="A screenshot showing how to use the top search bar in the Azure portal to locate and navigate to a resource group in Azure. This is the resource group that you'll assign roles (permissions) to." lightbox="./media/assign-managed-identity-to-role-azure-portal-1.png"::: | +| [!INCLUDE [Assign managed identity to role step 2](<./includes/assign-managed-identity-to-role-azure-portal-2.md>)] | :::image type="content" source="./media/assign-managed-identity-to-role-azure-portal-2-240px.png" alt-text="A screenshot showing the location of the Access control (IAM) menu item in the left-hand menu of an Azure resource group." lightbox="./media/assign-managed-identity-to-role-azure-portal-2.png"::: | +| [!INCLUDE [Assign managed identity to role step 3](<./includes/assign-managed-identity-to-role-azure-portal-3.md>)] | :::image type="content" source="./media/assign-managed-identity-to-role-azure-portal-3-240px.png" alt-text="A screenshot showing how to navigate to the role assignments tab and the location of the button used to add role assignments to a resource group." lightbox="./media/assign-managed-identity-to-role-azure-portal-3.png"::: | +| [!INCLUDE [Assign managed identity to role step 4](<./includes/assign-managed-identity-to-role-azure-portal-4.md>)] | :::image type="content" source="./media/assign-managed-identity-to-role-azure-portal-4-240px.png" alt-text="A screenshot showing how to filter and select role assignments to be added to the resource group." lightbox="./media/assign-managed-identity-to-role-azure-portal-4.png"::: | +| [!INCLUDE [Assign managed identity to role step 5](<./includes/assign-managed-identity-to-role-azure-portal-5.md>)] | :::image type="content" source="./media/assign-managed-identity-to-role-azure-portal-5-240px.png" alt-text="A screenshot showing how to select managed identity as the type of user you want to assign the role (permission) on the add role assignments page." lightbox="./media/assign-managed-identity-to-role-azure-portal-5.png"::: | +| [!INCLUDE [Assign managed identity to role step 6](<./includes/assign-managed-identity-to-role-azure-portal-6.md>)] | :::image type="content" source="./media/assign-managed-identity-to-role-azure-portal-6-240px.png" alt-text="A screenshot showing how to use the select managed identities dialog to filter and select the managed identity to assign the role to." lightbox="./media/assign-managed-identity-to-role-azure-portal-6.png"::: | +| [!INCLUDE [Assign managed identity to role step 7](<./includes/assign-managed-identity-to-role-azure-portal-7.md>)] | :::image type="content" source="./media/assign-managed-identity-to-role-azure-portal-7-240px.png" alt-text="A screenshot of the final add role assignment screen where a user needs to select the Review + Assign button to finalize the role assignment." lightbox="./media/assign-managed-identity-to-role-azure-portal-7.png"::: | + +### [Azure CLI](#tab/azure-cli) + +A managed identity is assigned a role in Azure using the [az role assignment create] command. + +```azurecli +az role assignment create --assignee "{managedIdentityId}" \ + --role "{roleName}" \ + --resource-group "{resourceGroupName}" +``` + +To get the role names that a service principal can be assigned to, use the [az role definition list](/cli/azure/role/definition#az-role-definition-list) command. + +```azurecli +az role definition list \ + --query "sort_by([].{roleName:roleName, description:description}, &roleName)" \ + --output table +``` + +For example, to allow the managed identity with the ID of `99999999-9999-9999-9999-999999999999` read, write, and delete access to Azure Storage blob containers and data to all storage accounts in the *msdocs-dotnet-sdk-auth-example* resource group, you would assign the application service principal to the *Storage Blob Data Contributor* role using the following command. + +```azurecli +az role assignment create --assignee 99999999-9999-9999-9999-999999999999 \ + --role "Storage Blob Data Contributor" \ + --resource-group "msdocs-dotnet-sdk-auth-example" +``` + +For information on assigning permissions at the resource or subscription level using the Azure CLI, see the article [Assign Azure roles using the Azure CLI](/azure/role-based-access-control/role-assignments-cli). + +--- + +## 3 - Implement DefaultAzureCredential in your application + +[!INCLUDE [Implement Default Azure Credentials](<./includes/implement-defaultazurecredential.md>)] diff --git a/docs/azure/sdk/authentication-local-development-dev-accounts.md b/docs/azure/sdk/authentication-local-development-dev-accounts.md new file mode 100644 index 0000000000000..5008d456d3c20 --- /dev/null +++ b/docs/azure/sdk/authentication-local-development-dev-accounts.md @@ -0,0 +1,158 @@ +--- +title: Authenticate .NET apps to Azure services during local development using developer accounts +description: This article describes how to authenticate your application to Azure services when using the Azure SDK for .NET during local development using developer accounts. +ms.date: 05/05/2022 +ms.topic: how-to +ms.custom: devx-track-dotnet +--- + +# Authenticate .NET apps to Azure services during local development using developer accounts + +When creating cloud applications, developers need to debug and test applications on their local workstation. When an application is run on a developer's workstation during local development, it still must authenticate to any Azure services used by the app. This article covers how to use a developer's Azure credentials to authenticate the app to Azure during local development. + +:::image type="content" source="media/local-dev-dev-accounts-overview.png" alt-text="A diagram showing how an app running in local developer will obtain the application service principal from a .env file and then use that identity to connect to Azure resources."::: + +For an app to authenticate to Azure during local development using the developer's Azure credentials, the developer must be signed-in to Azure from the VS Code Azure Tools extension, the Azure CLI, or Azure PowerShell. The Azure SDK for .NET is able to detect that the developer is signed-in from one of these tools and then obtain the necessary credentials from the credentials cache to authenticate the app to Azure as the signed-in user. + +This approach is easiest to set up for a development team since it takes advantage of the developers' existing Azure accounts. However, a developer's account will likely have more permissions than required by the application, therefore exceeding the permissions the app will run with in production. As an alternative, you can [create application service principals to use during local development](./authentication-local-development-service-principal.md) which can be scoped to have only the access needed by the app. + +## 1 - Create Azure AD group for local development + +Since there are almost always multiple developers who work on an application, it's recommended to first create an Azure AD group to encapsulate the roles (permissions) the app needs in local development. This offers the following advantages. + +- Every developer is assured to have the same roles assigned since roles are assigned at the group level. +- If a new role is needed for the app, it only needs to be added to the Azure AD group for the app. +- If a new developer joins the team, they simply must be added to the correct Azure AD group to get the correct permissions to work on the app. + +If you have an existing Azure AD group for your development team, you can use that group. Otherwise, complete the following steps to create an Azure AD group. + +### [Azure portal](#tab/azure-portal) + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Create app AD group step 1](<./includes/local-dev-accounts-app-ad-group-azure-portal-1.md>)] | :::image type="content" source="./media/local-dev-accounts-app-ad-group-azure-portal-1-240px.png" alt-text="A screenshot showing how to use the top search bar in the Azure portal to search for and navigate to the Azure Active Directory page." lightbox="./media/local-dev-accounts-app-ad-group-azure-portal-1.png"::: | +| [!INCLUDE [Create app AD group step 2](<./includes/local-dev-accounts-app-ad-group-azure-portal-2.md>)] | :::image type="content" source="./media/local-dev-accounts-app-ad-group-azure-portal-2-240px.png" alt-text="A screenshot showing the location of the Groups menu item in the left-hand menu of the Azure Active Directory Default Directory page." lightbox="./media/local-dev-accounts-app-ad-group-azure-portal-2.png"::: | +| [!INCLUDE [Create app AD group step 3](<./includes/local-dev-accounts-app-ad-group-azure-portal-3.md>)] | :::image type="content" source="./media/local-dev-accounts-app-ad-group-azure-portal-3-240px.png" alt-text="A screenshot showing the location of the New Group button in the All groups page." lightbox="./media/local-dev-accounts-app-ad-group-azure-portal-3.png"::: | +| [!INCLUDE [Create app AD group step 4](<./includes/local-dev-accounts-app-ad-group-azure-portal-4.md>)] | :::image type="content" source="./media/local-dev-accounts-app-ad-group-azure-portal-4-240px.png" alt-text="A screenshot showing how to fill out the form to create a new Azure Active Directory group for the application. This screenshot also shows the location of the link to select to add members to this group" lightbox="./media/local-dev-accounts-app-ad-group-azure-portal-4.png"::: | +| [!INCLUDE [Create app AD group step 5](<./includes/local-dev-accounts-app-ad-group-azure-portal-5.md>)] | :::image type="content" source="./media/local-dev-accounts-app-ad-group-azure-portal-5-240px.png" alt-text="A screenshot of the Add members dialog box showing how to select developer accounts to be included in the group." lightbox="./media/local-dev-accounts-app-ad-group-azure-portal-5.png"::: | +| [!INCLUDE [Create app AD group step 6](<./includes/local-dev-accounts-app-ad-group-azure-portal-6.md>)] | :::image type="content" source="./media/local-dev-accounts-app-ad-group-azure-portal-6-240px.png" alt-text="A screenshot of the New Group page showing how to complete the process by selecting the Create button." lightbox="./media/local-dev-accounts-app-ad-group-azure-portal-6.png"::: | + +### [Azure CLI](#tab/azure-cli) + +The [az ad group create](/cli/azure/ad/group#az-ad-group-create) command is used to create groups in Azure Active Directory. The `--display-name` and `--main-nickname` parameters are required. The name given to the group should be based on the name of the application. It's also useful to include a phrase like 'local-dev' in the name of the group to indicate the purpose of the group. + +```azurecli +az ad group create \ + --display-name MyDisplay \ + --mail-nickname MyDisplay \ + --description +``` + +To add members to the group, you'll need the object ID of Azure user. Use the [az ad user list](/cli/azure/ad/sp#az-ad-user-list) to list the available service principals. The `--filter` parameter command accepts OData style filters and can be used to filter the list on the display name of the user as shown. The `--query` parameter limits to columns to only those of interest. + +```azurecli +az ad user list \ + --filter "startswith(displayName, 'Bob')" \ + --query "[].{objectId:objectId, displayName:displayName}" \ + --output table +``` + +The [az ad group member add](/cli/azure/ad/group/member#az-ad-group-member-add) command can then be used to add members to groups. + +```azurecli +az ad group member add \ + --group \ + --member-id +``` + +--- + +## 2 - Assign roles to the Azure AD group + +Next, you need to determine what roles (permissions) your app needs on what resources and assign those roles to your app. In this example, the roles will be assigned to the Azure Active Directory group created in step 1. Roles can be assigned a role at a resource, resource group, or subscription scope. This example will show how to assign roles at the resource group scope since most applications group all their Azure resources into a single resource group. + +### [Azure portal](#tab/azure-portal) + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-1.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-1-240px.png" alt-text="A screenshot showing how to use the top search box in the Azure portal to locate and navigate to the resource group you want to assign roles (permissions) to." lightbox="./media/assign-local-dev-group-to-role-azure-portal-1.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-2.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-2-240px.png" alt-text="A screenshot of the resource group page showing the location of the Access control (IAM) menu item." lightbox="./media/assign-local-dev-group-to-role-azure-portal-2.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-3.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-3-240px.png" alt-text="A screenshot showing how to navigate to the role assignments tab and the location of the button used to add role assignments to a resource group." lightbox="./media/assign-local-dev-group-to-role-azure-portal-3.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-4.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-4-240px.png" alt-text="A screenshot showing how to filter and select role assignments to be added to the resource group." lightbox="./media/assign-local-dev-group-to-role-azure-portal-4.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-5.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-5-240px.png" alt-text="A screenshot showing the radio button to select to assign a role to an Azure AD group and the link used to select the group to assign the role to." lightbox="./media/assign-local-dev-group-to-role-azure-portal-5.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-6.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-6-240px.png" alt-text="A screenshot showing how to filter for and select the Azure AD group for the application in the Select members dialog box." lightbox="./media/assign-local-dev-group-to-role-azure-portal-6.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-7.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-7-240px.png" alt-text="A screenshot showing the completed Add role assignment page and the location of the Review + assign button used to complete the process." lightbox="./media/assign-local-dev-group-to-role-azure-portal-7.png"::: | + +### [Azure CLI](#tab/azure-cli) + +An application service principal is assigned a role in Azure using the [az role assignment create](/cli/azure/role/assignment) command. + +```azurecli +az role assignment create --assignee "{appId}" \ + --role "{roleName}" \ + --resource-group "{resourceGroupName}" +``` + +To get the role names that a service principal can be assigned to, use the [az role definition list](/cli/azure/role/definition#az-role-definition-list) command. + +```azurecli +az role definition list --query "sort_by([].{roleName:roleName, description:description}, &roleName)" --output table + +``` + +For example, to allow the application service principal with the appId of `00000000-0000-0000-0000-000000000000` read, write, and delete access to Azure Storage blob containers and data to all storage accounts in the *msdocs-dotnet-sdk-auth-example* resource group, you would assign the application service principal to the *Storage Blob Data Contributor* role using the following command. + +```azurecli +az role assignment create --assignee "00000000-0000-0000-0000-000000000000" \ + --role "Storage Blob Data Contributor" \ + --resource-group "msdocs-dotnet-sdk-auth-example" +``` + +For information on assigning permissions at the resource or subscription level using the Azure CLI, see the article [Assign Azure roles using the Azure CLI](/azure/role-based-access-control/role-assignments-cli). + +--- + +## 3 - Sign-in to Azure using .NET Tooling + +Next you need to sign in to Azure using one of several .NET tooling options. The account you sign into should also exist in the Azure Active Directory group you created and configured earlier. + +### [Visual Studio](#tab/sign-in-visual-studio) + +On the top menu of Visual Studio, navigate to **Tools** > **Options** to open the options dialog. In the search bar in the upper left, type *Azure* to filter the options. Under the **Azure Service Authentication**, choose **Account Selection**. + +Select the drop-down menu under **Choose an account** and choose to add a Microsoft Account. A window will open prompting you to pick an account. Enter the credentials for your desired Azure account, and then select the confirmation. + +:::image type="content" source="./media/visual-studio-sign-in.png" alt-text="A screenshot showing how to sign in to Azure using Visual Studio."::: + +### [VS Code Azure Tools extension](#tab/sign-in-vscode) + +For an app to use the developer credentials from VS Code, the [VS Code Azure Tools extension must be installed](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack) in VS Code. + +> [!div class="nextstepaction"] +> [Install the Azure Tools extensions for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack) + +On the left-hand panel, you'll see an Azure icon. Select this icon, and a control panel for Azure services will appear. Choose **Sign in to Azure...** under any service to complete the authentication process for the Azure tools in Visual Studio Code. + +:::image type="content" source="./media/vs-code-azure-login-small.png" alt-text="Screenshot of the Visual Studio Code showing how to sign-in the Azure tools to Azure." lightbox="./media/vs-code-azure-login.png"::: + +### [Azure CLI](#tab/sign-in-azure-cli) + +Open a terminal on your developer workstation and sign-in to Azure from the [Azure CLI](/cli/azure/what-is-azure-cli). + +```azurecli +az login +``` + +### [Azure PowerShell](#tab/sign-in-azure-powershell) + +Open a terminal on your developer workstation and sign-in to Azure from [Azure PowerShell](/powershell/azure/what-is-azure-powershell). + +```azurepowershell +Connect-AzAccount +``` + +--- + +## 4 - Implement DefaultAzureCredential in your application + +[!INCLUDE [Implement Default Azure Credentials](<./includes/implement-defaultazurecredential.md>)] diff --git a/docs/azure/sdk/authentication-local-development-service-principal.md b/docs/azure/sdk/authentication-local-development-service-principal.md new file mode 100644 index 0000000000000..22afd3f50a4fc --- /dev/null +++ b/docs/azure/sdk/authentication-local-development-service-principal.md @@ -0,0 +1,255 @@ +--- +title: Authenticate .NET apps to Azure services during local development using service principals +description: This article describes how to authenticate your application to Azure services when using the Azure SDK for NET during local development using dedicated application service principals. +ms.date: 05/05/2022 +ms.topic: how-to +ms.custom: devx-track-dotnet +--- + +# Authenticate NET apps to Azure services during local development using service principals + +When creating cloud applications, developers need to debug and test applications on their local workstation. When an application is run on a developer's workstation during local development, it still must authenticate to any Azure services used by the app. This article covers how to set up dedicated application service principal objects to be used during local development. + +:::image type="content" source="media/local-dev-service-principal-overview.png" alt-text="A diagram showing how a .NET app during local development will use the developer's credentials to connect to Azure by obtaining those credentials locally installed development tools."::: + +Dedicated application service principals for local development allow you to follow the principle of least privilege during app development. Since permissions are scoped to exactly what is needed for the app during development, app code is prevented from accidentally accessing an Azure resource intended for use by a different app. This also prevents bugs from occurring when the app is moved to production because the app was overprivileged in the dev environment. + +An application service principal is set up for the app when the app is registered in Azure. When registering apps for local development, it's recommended to: + +- Create separate app registrations for each developer working on the app. This will create separate application service principals for each developer to use during local development and avoid the need for developers to share credentials for a single application service principal. +- Create separate app registrations per app. This scopes the app's permissions to only what is needed by the app. + +During local development, environment variables are set with the application service principal's identity. The Azure SDK for NET reads these environment variables and uses this information to authenticate the app to the Azure resources it needs. + +## 1 - Register the application in Azure + +Application service principal objects are created with an app registration in Azure. This can be done using either the Azure portal or Azure CLI. + +### [Azure portal](#tab/azure-portal) + +Sign in to the [Azure portal](https://portal.azure.com/) and follow these steps. + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Create app registration step 1](<./includes/local-dev-app-registration-azure-portal-1.md>)] | :::image type="content" source="./media/local-dev-app-registration-azure-portal-1-240px.png" alt-text="A screenshot showing how to use the top search bar in the Azure portal to find and navigate to the App registrations page." lightbox="./media/local-dev-app-registration-azure-portal-1.png"::: | +| [!INCLUDE [Create app registration step 2](<./includes/local-dev-app-registration-azure-portal-2.md>)] | :::image type="content" source="./media/local-dev-app-registration-azure-portal-2-240px.png" alt-text="A screenshot showing the location of the New registration button in the App registrations page." lightbox="./media/local-dev-app-registration-azure-portal-2.png"::: | +| [!INCLUDE [Create app registration step 3](<./includes/local-dev-app-registration-azure-portal-3.md>)] | :::image type="content" source="./media/local-dev-app-registration-azure-portal-3-240px.png" alt-text="A screenshot showing how to fill out the Register an application page by giving the app a name and specifying supported account types as accounts in this organizational directory only." lightbox="./media/local-dev-app-registration-azure-portal-3.png"::: | +| [!INCLUDE [Create app registration step 4](<./includes/local-dev-app-registration-azure-portal-4.md>)] | :::image type="content" source="./media/local-dev-app-registration-azure-portal-4-240px.png" alt-text="A screenshot of the App registration page after the app registration has been completed. This screenshot shows the location of the application ID and tenant ID, which will be needed in a future step. It also shows the location of the link to use to add an application secret for the app." lightbox="./media/local-dev-app-registration-azure-portal-4.png"::: | +| [!INCLUDE [Create app registration step 5](<./includes/local-dev-app-registration-azure-portal-5.md>)] | :::image type="content" source="./media/local-dev-app-registration-azure-portal-5-240px.png" alt-text="A screenshot showing the location of the link to use to create a new client secret on the certificates and secrets page." lightbox="./media/local-dev-app-registration-azure-portal-5.png"::: | +| [!INCLUDE [Create app registration step 6](<./includes/local-dev-app-registration-azure-portal-6.md>)] | :::image type="content" source="./media/local-dev-app-registration-azure-portal-6-240px.png" alt-text="A screenshot showing the page where a new client secret is added for the application service principal create by the app registration process." lightbox="./media/local-dev-app-registration-azure-portal-6.png"::: | +| [!INCLUDE [Create app registration step 7](<./includes/local-dev-app-registration-azure-portal-7.md>)] | :::image type="content" source="./media/local-dev-app-registration-azure-portal-7-240px.png" alt-text="A screenshot showing the page with the generated client secret." lightbox="./media/local-dev-app-registration-azure-portal-7.png"::: | + +### [Azure CLI](#tab/azure-cli) + +Azure CLI commands can be run in the [Azure Cloud Shell](https://shell.azure.com) or on a workstation with the [Azure CLI installed](/cli/azure/install-azure-cli). + +First, use the [az ad sp create-for-rbac](/cli/azure/ad/sp#az-ad-sp-create-for-rbac) command to create a new service principal for the app. This will also create the app registration for the app at the same time. + +```azurecli +az ad sp create-for-rbac --name {service-principal-name} +``` + +The output of this command will look like the following. It's recommended to copy this output into a temporary file in a text editor as you'll need these values in a future step as this is the only place you ever see the client secret (password) for the service principal. You can, however, add a new password later without invalidating the service principal or existing passwords if need be. + +```json +{ + "appId": "00000000-0000-0000-0000-000000000000", + "displayName": "{service-principal-name}", + "password": "abcdefghijklmnopqrstuvwxyz", + "tenant": "11111111-1111-1111-1111-111111111111" +} +``` + +--- + +## 2 - Create an Azure AD security group for local development + +Since there typically multiple developers who work on an application, it's recommended to create an Azure AD group to encapsulate the roles (permissions) the app needs in local development rather than assigning the roles to individual service principal objects. This offers the following advantages. + +- Every developer is assured to have the same roles assigned since roles are assigned at the group level. +- If a new role is needed for the app, it only needs to be added to the Azure AD group for the app. +- If a new developer joins the team, a new application service principal is created for the developer and added to the group, assuring the developer has the right permissions to work on the app. + +### [Azure portal](#tab/azure-portal) + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Create app AD group step 1](<./includes/local-dev-app-ad-group-azure-portal-1.md>)] | :::image type="content" source="./media/local-dev-app-ad-group-azure-portal-1-240px.png" alt-text="A screenshot showing how to use the top search bar in the Azure portal to search for and navigate to the Azure Active Directory page." lightbox="./media/local-dev-app-ad-group-azure-portal-1.png"::: | +| [!INCLUDE [Create app AD group step 2](<./includes/local-dev-app-ad-group-azure-portal-2.md>)] | :::image type="content" source="./media/local-dev-app-ad-group-azure-portal-2-240px.png" alt-text="A screenshot showing the location of the Groups menu item in the left-hand menu of the Azure Active Directory Default Directory page." lightbox="./media/local-dev-app-ad-group-azure-portal-2.png"::: | +| [!INCLUDE [Create app AD group step 3](<./includes/local-dev-app-ad-group-azure-portal-3.md>)] | :::image type="content" source="./media/local-dev-app-ad-group-azure-portal-3-240px.png" alt-text="A screenshot showing the location of the New Group button in the All groups page." lightbox="./media/local-dev-app-ad-group-azure-portal-3.png"::: | +| [!INCLUDE [Create app AD group step 4](<./includes/local-dev-app-ad-group-azure-portal-4.md>)] | :::image type="content" source="./media/local-dev-app-ad-group-azure-portal-4-240px.png" alt-text="A screenshot showing how to fill out the form to create a new Azure Active Directory group for the application. This screenshot also shows the location of the link to select to add members to this group." lightbox="./media/local-dev-app-ad-group-azure-portal-4.png"::: | +| [!INCLUDE [Create app AD group step 5](<./includes/local-dev-app-ad-group-azure-portal-5.md>)] | :::image type="content" source="./media/local-dev-app-ad-group-azure-portal-5-240px.png" alt-text="A screenshot of the Add members dialog box showing how to select application service principals to be included in the group." lightbox="./media/local-dev-app-ad-group-azure-portal-5.png"::: | +| [!INCLUDE [Create app AD group step 6](<./includes/local-dev-app-ad-group-azure-portal-6.md>)] | :::image type="content" source="./media/local-dev-app-ad-group-azure-portal-6-240px.png" alt-text="A screenshot of the New Group page showing how to complete the process by selecting the Create button." lightbox="./media/local-dev-app-ad-group-azure-portal-6.png"::: | + +### [Azure CLI](#tab/azure-cli) + +The [az ad group create](/cli/azure/ad/group#az-ad-group-create) command is used to create groups in Azure Active Directory. The `--display-name` and `--main-nickname` parameters are required. The name given to the group should be based on the name of the application. It's also useful to include a phrase like 'local-dev' in the name of the group to indicate the purpose of the group. + +```azurecli +az ad group create \ + --display-name MyDisplay \ + --mail-nickname MyDisplay \ + --description \ +``` + +To add members to the group, you'll need the object ID of the application service principal, which is different that the application ID. Use the [az ad sp list](/cli/azure/ad/sp#az-ad-sp-list) to list the available service principals. The `--filter` parameter command accepts OData style filters and can be used to filter the list as shown. The `--query` parameter limits to columns to only those of interest. + +```azurecli +az ad sp list \ + --filter "startswith(displayName, 'msdocs')" \ + --query "[].{objectId:objectId, displayName:displayName}" \ + --output table +``` + +The [az ad group member add](/cli/azure/ad/group/member#az-ad-group-member-add) command can then be used to add members to groups. + +```azurecli +az ad group member add \ + --group \ \ + --member-id \ \ +``` + +--- + +## 3 - Assign roles to the application + +Next, you need to determine what roles (permissions) your app needs on what resources and assign those roles to your app. In this example, the roles will be assigned to the Azure Active Directory group created in step 2. Roles can be assigned a role at a resource, resource group, or subscription scope. This example will show how to assign roles at the resource group scope since most applications group all their Azure resources into a single resource group. + +### [Azure portal](#tab/azure-portal) + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-1.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-1-240px.png" alt-text="A screenshot showing how to use the top search box in the Azure portal to locate and navigate to the resource group you want to assign roles (permissions) to." lightbox="./media/assign-local-dev-group-to-role-azure-portal-1.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-2.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-2-240px.png" alt-text="A screenshot of the resource group page showing the location of the Access control (IAM) menu item." lightbox="./media/assign-local-dev-group-to-role-azure-portal-2.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-3.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-3-240px.png" alt-text="A screenshot showing how to navigate to the role assignments tab and the location of the button used to add role assignments to a resource group." lightbox="./media/assign-local-dev-group-to-role-azure-portal-3.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-4.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-4-240px.png" alt-text="A screenshot showing how to filter and select role assignments to be added to the resource group." lightbox="./media/assign-local-dev-group-to-role-azure-portal-4.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-5.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-5-240px.png" alt-text="A screenshot showing the radio button to select to assign a role to an Azure AD group and the link used to select the group to assign the role to." lightbox="./media/assign-local-dev-group-to-role-azure-portal-5.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-6.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-6-240px.png" alt-text="A screenshot showing how to filter for and select the Azure AD group for the application in the Select members dialog box." lightbox="./media/assign-local-dev-group-to-role-azure-portal-6.png"::: | +| [!INCLUDE [Assign dev service principal to role step 1](<./includes/assign-local-dev-group-to-role-azure-portal-7.md>)] | :::image type="content" source="./media/assign-local-dev-group-to-role-azure-portal-7-240px.png" alt-text="A screenshot showing the completed Add role assignment page and the location of the Review + assign button used to complete the process." lightbox="./media/assign-local-dev-group-to-role-azure-portal-7.png"::: | + +### [Azure CLI](#tab/azure-cli) + +An application service principal is assigned a role in Azure using the [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command. + +```azurecli +az role assignment create --assignee "{appId}" \ + --role "{roleName}" \ + --resource-group "{resourceGroupName}" +``` + +To get the role names that a service principal can be assigned to, use the [az role definition list](/cli/azure/role/definition#az-role-definition-list) command. + +```azurecli +az role definition list \ + --query "sort_by([].{roleName:roleName, description:description}, &roleName)" \ + --output table +``` + +For example, to allow the application service principal with the appId of `00000000-0000-0000-0000-000000000000` read, write, and delete access to Azure Storage blob containers and data to all storage accounts in the *msdocs-dotnet-sdk-auth-example* resource group, you would assign the application service principal to the *Storage Blob Data Contributor* role using the following command. + +```azurecli +az role assignment create --assignee "00000000-0000-0000-0000-000000000000" \ + --role "Storage Blob Data Contributor" \ + --resource-group "msdocs-dotnet-sdk-auth-example" +``` + +For information on assigning permissions at the resource or subscription level using the Azure CLI, see the article [Assign Azure roles using the Azure CLI](/azure/role-based-access-control/role-assignments-cli). + +--- + +## 4 - Set application environment variables + +The `DefaultAzureCredential` object will look for the service principal information in a set of environment variables at runtime. There are multiple ways to configure environment variables when working with .NET depending on your tooling and environment. + +Regardless of which approach you choose, you'll need to configure the following environment variables when working with a service principal. + +- `AZURE_CLIENT_ID` → The app ID value. +- `AZURE_TENANT_ID` → The tenant ID value. +- `AZURE_CLIENT_SECRET` → The password/credential generated for the app. + +### [Visual Studio](#tab/visual-studio) + +When working locally with Visual Studio, environment variables can be set in the `launchsettings.json` file in the `Properties` folder of your project. When the app starts up, these values will be pulled in automatically. Keep in mind these configurations do not travel with your application when it gets deployed, so you'll still need to set up environment variables on your target hosting environment. + +```json +"profiles": { + "SampleProject": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7177;http://localhost:5177", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "AZURE_CLIENT_ID": "00000000-0000-0000-0000-000000000000", + "AZURE_TENANT_ID":"11111111-1111-1111-1111-111111111111", + "AZURE_CLIENT_SECRET": "=abcdefghijklmnopqrstuvwxyz" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "AZURE_CLIENT_ID": "00000000-0000-0000-0000-000000000000", + "AZURE_TENANT_ID": "11111111-1111-1111-1111-111111111111", + "AZURE_CLIENT_SECRET": "=abcdefghijklmnopqrstuvwxyz" + } + } + } +``` + +### [VS Code](#tab/vs-code) + +When working locally with Visual Studio Code, environment variables can be set in the `launch.json` file of your project. When the app starts up, these values will be pulled in automatically. Keep in mind these configurations do not travel with your application when it gets deployed, so you'll still need to set up environment variables on your target hosting environment. + +```json +"configurations": [ +{ + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "AZURE_CLIENT_ID": "00000000-0000-0000-0000-000000000000", + "AZURE_TENANT_ID":"11111111-1111-1111-1111-111111111111", + "AZURE_CLIENT_SECRET": "=abcdefghijklmnopqrstuvwxyz" + } +} +``` + +### [Windows](#tab/windows) + +You can set environment variables for Windows from the command line. However, when using this approach the values are accessible to all applications running on that operating system and may cause conflicts if you aren't careful. Environment variables can be set at the user or system level. + +```bash +# Set user environment variables +setx ASPNETCORE_ENVIRONMENT "Development" +setx AZURE_CLIENT_ID "00000000-0000-0000-0000-000000000000" +setx AZURE_TENANT_ID "11111111-1111-1111-1111-111111111111" +setx AZURE_CLIENT_SECRET "=abcdefghijklmnopqrstuvwxyz" + +# Set system environment variables - requires running as admin +setx ASPNETCORE_ENVIRONMENT "Development" +setx AZURE_CLIENT_ID "00000000-0000-0000-0000-000000000000" /m +setx AZURE_TENANT_ID "11111111-1111-1111-1111-111111111111" /m +setx AZURE_CLIENT_SECRET "=abcdefghijklmnopqrstuvwxyz" /m +``` + +PowerShell can also be used to set environment variables at the user or machine level. + +```powershell +# Set user environment variables +[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development", "User") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000", "User") +[Environment]::SetEnvironmentVariable("AZURE_TENANT_ID", "11111111-1111-1111-1111-111111111111", "User") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_SECRET", "=abcdefghijklmnopqrstuvwxyz", "User") + +# Set system environment variables - requires running as admin +[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development", "Machine") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000", "Machine") +[Environment]::SetEnvironmentVariable("AZURE_TENANT_ID", "11111111-1111-1111-1111-111111111111", "Machine") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_SECRET", "=abcdefghijklmnopqrstuvwxyz", "Machine") +``` + +--- + +## 5 - Implement DefaultAzureCredential in your application + +[!INCLUDE [Implement Default Azure Credentials](<./includes/implement-defaultazurecredential.md>)] diff --git a/docs/azure/sdk/authentication-on-premises-apps.md b/docs/azure/sdk/authentication-on-premises-apps.md new file mode 100644 index 0000000000000..e4cee48e2e4ba --- /dev/null +++ b/docs/azure/sdk/authentication-on-premises-apps.md @@ -0,0 +1,172 @@ +--- +title: Authenticate to Azure resources from .NET apps hosted on-premises +description: This article describes how to authenticate your application to Azure services when using the Azure SDK for .NET in on-premises hosted applications. +ms.date: 05/05/2022 +ms.topic: how-to +ms.custom: devx-track-dotnet +--- + +# Authenticate to Azure resources from .NET apps hosted on-premises + +Apps hosted outside of Azure (for example on-premises or at a third-party data center) should use an application service principal to authenticate to Azure when accessing Azure resources. Application service principal objects are created using the app registration process in Azure. When an application service principal is created, a client ID and client secret will be generated for your app. The client ID, client secret, and your tenant ID are then stored in environment variables so they can be used by the Azure SDK for .NET to authenticate your app to Azure at runtime. + +A different app registration should be created for each environment the app is hosted in. This allows environment specific resource permissions to be configured for each service principal and make sure an app deployed to one environment does not talk to Azure resources that are part of another environment. + +## 1 - Register the application in Azure + +An app can be registered with Azure using either the Azure portal or the Azure CLI. + +### [Azure portal](#tab/azure-portal) + +Sign in to the [Azure portal](https://portal.azure.com/) and follow these steps. + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Create app registration step 1](<./includes/on-premises-app-registration-azure-portal-1.md>)] | :::image type="content" source="./media/on-premises-app-registration-azure-portal-1-240px.png" lightbox="./media/on-premises-app-registration-azure-portal-1.png" alt-text="A screenshot showing how to use the top search bar in the Azure portal to find and navigate to the App registrations page." ::: | +| [!INCLUDE [Create app registration step 2](<./includes/on-premises-app-registration-azure-portal-2.md>)] | :::image type="content" source="./media/on-premises-app-registration-azure-portal-2-240px.png" lightbox="./media/on-premises-app-registration-azure-portal-2.png" alt-text="A screenshot showing the location of the New registration button in the App registrations page." ::: | +| [!INCLUDE [Create app registration step 3](<./includes/on-premises-app-registration-azure-portal-3.md>)] | :::image type="content" source="./media/on-premises-app-registration-azure-portal-3-240px.png" lightbox="./media/on-premises-app-registration-azure-portal-3.png" alt-text="A screenshot showing how to fill out the Register an application page by giving the app a name and specifying supported account types as accounts in this organizational directory only." ::: | +| [!INCLUDE [Create app registration step 4](<./includes/on-premises-app-registration-azure-portal-4.md>)] | :::image type="content" source="./media/on-premises-app-registration-azure-portal-4-240px.png" lightbox="./media/on-premises-app-registration-azure-portal-4.png" alt-text="A screenshot of the App registration page after the app registration has been completed. This screenshot shows the location of the application ID and tenant ID which will be needed in a future step. It also shows the location of the link to use to add an application secret for the app." ::: | +| [!INCLUDE [Create app registration step 5](<./includes/on-premises-app-registration-azure-portal-5.md>)] | :::image type="content" source="./media/on-premises-app-registration-azure-portal-5-240px.png" lightbox="./media/on-premises-app-registration-azure-portal-5.png" alt-text="A screenshot showing the location of the link to use to create a new client secret on the certificates and secrets page." ::: | +| [!INCLUDE [Create app registration step 6](<./includes/on-premises-app-registration-azure-portal-6.md>)] | :::image type="content" source="./media/on-premises-app-registration-azure-portal-6-240px.png" lightbox="./media/on-premises-app-registration-azure-portal-6.png" alt-text="A screenshot showing the page where a new client secret is added for the application service principal created by the app registration process." ::: | +| [!INCLUDE [Create app registration step 7](<./includes/on-premises-app-registration-azure-portal-7.md>)] | :::image type="content" source="./media/on-premises-app-registration-azure-portal-7-240px.png" lightbox="./media/on-premises-app-registration-azure-portal-7.png" alt-text="A screenshot showing the page with the generated client secret." ::: | + +### [Azure CLI](#tab/azure-cli) + +```azurecli +az ad sp create-for-rbac --name +``` + +The output of the command will be similar to the following. Make note of these values or keep this window open as you will need these values in the next step and will not be able to view the password (client secret) value again. + +```json +{ + "appId": "00000000-1111-2222-3333-444444444444", + "displayName": "msdocs-dotnet-sdk-auth-prod", + "password": "abcdefghijklmnopqrstuvwxyz", + "tenant": "00000000-0000-0000-0000-000000000000" +} +``` + +--- + +## 2 - Assign roles to the application service principal + +Next, you need to determine what roles (permissions) your app needs on what resources and assign those roles to your app. Roles can be assigned a role at a resource, resource group, or subscription scope. This example will show how to assign roles for the service principal at the resource group scope since most applications group all their Azure resources into a single resource group. + +### [Azure portal](#tab/azure-portal) + +| Instructions | Screenshot | +|:----------------|-----------:| +| [!INCLUDE [Assign service principal to role step 1](<./includes/assign-service-principal-to-role-azure-portal-1.md>)] | :::image type="content" source="./media/assign-service-principal-to-role-azure-portal-1-240px.png" lightbox="./media/assign-service-principal-to-role-azure-portal-1.png" alt-text="A screenshot showing how to use the top search box in the Azure portal to locate and navigate to the resource group you want to assign roles (permissions) to." ::: | +| [!INCLUDE [Assign service principal to role step 2](<./includes/assign-service-principal-to-role-azure-portal-2.md>)] | :::image type="content" source="./media/assign-service-principal-to-role-azure-portal-2-240px.png" lightbox="./media/assign-service-principal-to-role-azure-portal-2.png" alt-text="A screenshot of the resource group page showing the location of the Access control (IAM) menu item." ::: | +| [!INCLUDE [Assign service principal to role step 3](<./includes/assign-service-principal-to-role-azure-portal-3.md>)] | :::image type="content" source="./media/assign-service-principal-to-role-azure-portal-3-240px.png" lightbox="./media/assign-service-principal-to-role-azure-portal-3.png" alt-text="A screenshot showing how to navigate to the role assignments tab and the location of the button used to add role assignments to a resource group." ::: | +| [!INCLUDE [Assign service principal to role step 4](<./includes/assign-service-principal-to-role-azure-portal-4.md>)] | :::image type="content" source="./media/assign-service-principal-to-role-azure-portal-4-240px.png" lightbox="./media/assign-service-principal-to-role-azure-portal-4.png" alt-text="A screenshot showing how to filter and select role assignments to be added to the resource group." ::: | +| [!INCLUDE [Assign service principal to role step 5](<./includes/assign-service-principal-to-role-azure-portal-5.md>)] | :::image type="content" source="./media/assign-service-principal-to-role-azure-portal-5-240px.png" lightbox="./media/assign-service-principal-to-role-azure-portal-5.png" alt-text="A screenshot showing the radio button to select to assign a role to an Azure AD group and the link used to select the group to assign the role to." ::: | +| [!INCLUDE [Assign service principal to role step 6](<./includes/assign-service-principal-to-role-azure-portal-6.md>)] | :::image type="content" source="./media/assign-service-principal-to-role-azure-portal-6-240px.png" lightbox="./media/assign-service-principal-to-role-azure-portal-6.png" alt-text="A screenshot showing how to filter for and select the Azure AD group for the application in the Select members dialog box." ::: | +| [!INCLUDE [Assign service principal to role step 7](<./includes/assign-service-principal-to-role-azure-portal-7.md>)] | :::image type="content" source="./media/assign-service-principal-to-role-azure-portal-7-240px.png" lightbox="./media/assign-service-principal-to-role-azure-portal-7.png" alt-text="A screenshot showing the completed Add role assignment page and the location of the Review + assign button used to complete the process." ::: | + +### [Azure CLI](#tab/azure-cli) + +A service principal is assigned a role in Azure using the [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command. + +```azurecli +az role assignment create --assignee "{appId}" \ + --role "{roleName}" \ + --resource-group "{resourceGroupName}" +``` + +To get the role names that a service principal can be assigned to, use the [az role definition list](/cli/azure/role/definition#az-role-definition-list) command. + +```azurecli +az role definition list \ + --query "sort_by([].{roleName:roleName, description:description}, &roleName)" \ + --output table +``` + +For example, to allow the service principal with the appId of `00000000-0000-0000-0000-000000000000` read, write, and delete access to Azure Storage blob containers and data to all storage accounts in the *msdocs-dotnet-sdk-auth-example* resource group, you would assign the application service principal to the *Storage Blob Data Contributor* role using the following command. + +```azurecli +az role assignment create --assignee "00000000-0000-0000-0000-000000000000" \ + --role "Storage Blob Data Contributor" \ + --resource-group "msdocs-dotnet-sdk-auth-example" +``` + +For information on assigning permissions at the resource or subscription level using the Azure CLI, see the article [Assign Azure roles using the Azure CLI](/azure/role-based-access-control/role-assignments-cli). + +--- + +## 3 - Configure environment variables for application + +The `DefaultAzureCredential` object will look for service principal credentials in a set of environment variables at runtime. There are multiple ways to configure environment variables when working with .NET depending on your tooling and environment. + +Regardless of which approach you choose, you will need to configure the following environment variables when working with a service principal. + +- `AZURE_CLIENT_ID` → The app ID value. +- `AZURE_TENANT_ID` → The tenant ID value. +- `AZURE_CLIENT_SECRET` → The password/credential generated for the app. + +### [IIS](#tab/iis-app-pool) + +If your app is hosted in IIS it is recommended that you set environment variables per app pool to isolate settings between applications. + +```bash +appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='Contoso'].environmentVariables.[name='ASPNETCORE_ENVIRONMENT',value='Production']" /commit:apphost +appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='Contoso'].environmentVariables.[name='AZURE_CLIENT_ID',value='00000000-0000-0000-0000-000000000000']" /commit:apphost +appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='Contoso'].environmentVariables.[name='AZURE_TENANT_ID',value='11111111-1111-1111-1111-111111111111']" /commit:apphost +appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='Contoso'].environmentVariables.[name='AZURE_CLIENT_SECRET',value='=abcdefghijklmnopqrstuvwxyz']" /commit:apphost +``` + +You can also configure these settings directly using the `applicationPools` element inside of the `applicationHost.config` file. + +```xml + + + + + + + + + + +``` + +### [Windows](#tab/windows) + +You can set environment variables for Windows from the command line. However, when using this approach the values are accessible to all applications running on that operating system and may cause conflicts if you are not careful. Environment variables can be set at either user or system level. + +```bash +# Set user environment variables +setx ASPNETCORE_ENVIRONMENT "Development" +setx AZURE_CLIENT_ID "00000000-0000-0000-0000-000000000000" +setx AZURE_TENANT_ID "11111111-1111-1111-1111-111111111111" +setx AZURE_CLIENT_SECRET "=abcdefghijklmnopqrstuvwxyz" + +# Set system environment variables - requires running as admin +setx ASPNETCORE_ENVIRONMENT "Development" +setx AZURE_CLIENT_ID "00000000-0000-0000-0000-000000000000" /m +setx AZURE_TENANT_ID "11111111-1111-1111-1111-111111111111" /m +setx AZURE_CLIENT_SECRET "=abcdefghijklmnopqrstuvwxyz" /m +``` + +You can also use PowerShell to set environment variables at either the user or machine level. + +```powershell +# Set user environment variables +[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development", "User") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000", "User") +[Environment]::SetEnvironmentVariable("AZURE_TENANT_ID", "11111111-1111-1111-1111-111111111111", "User") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_SECRET", "=abcdefghijklmnopqrstuvwxyz", "User") + +# Set system environment variables - requires running as admin +[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development", "Machine") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000", "Machine") +[Environment]::SetEnvironmentVariable("AZURE_TENANT_ID", "11111111-1111-1111-1111-111111111111", "Machine") +[Environment]::SetEnvironmentVariable("AZURE_CLIENT_SECRET", "=abcdefghijklmnopqrstuvwxyz", "Machine") +``` + +--- + +## 4 - Implement DefaultAzureCredential in application + +[!INCLUDE [Implement Default Azure Credentials](<./includes/implement-defaultazurecredential.md>)] diff --git a/docs/azure/sdk/authentication.md b/docs/azure/sdk/authentication.md index 9faa54bae5bde..e49b63c8ae8ac 100644 --- a/docs/azure/sdk/authentication.md +++ b/docs/azure/sdk/authentication.md @@ -1,89 +1,80 @@ --- -title: Understanding Authentication in the Azure libraries for .NET -description: Explains the different ways of authenticating with the Azure SDK for .NET. -ms.date: 06/19/2020 +title: How to authenticate .NET applications with Azure services +description: How to acquire the necessary credential objects to authenticate a .NET application with Azure services by using the Azure .NET SDK +ms.date: 05/05/2022 +ms.topic: conceptual ms.custom: devx-track-dotnet --- -# Authenticate with the Azure SDK for .NET +# How to authenticate .NET apps to Azure services using the .NET Azure SDK -## Recommended: Azure.Identity +When an application needs to access an Azure resource such as storage, key vault, or cognitive services, the application must be authenticated to Azure. This is true for all applications, whether deployed to Azure, deployed on-premises, or under development on a local developer workstation. This article describes the recommended approaches to authenticate an app to Azure when using the Azure SDK for .NET. -The latest packages in the Azure SDK for .NET use a common authentication package to authenticate, `Azure.Identity`. Using `Azure.Identity` is recommended over other authentication mechanisms described later in this document. Packages supporting the credentials provided by `Azure.Identity` are built on top of `Azure.Core` and have package identifiers starting with *Azure*. [See the package list](packages.md) for an inventory of packages that use `Azure.Core`. +## Recommended app authentication approach -For complete instructions on using `Azure.Identity` in your project, see the documentation for [Azure Identity client for .NET](/dotnet/api/overview/azure/identity-readme). +It is recommended that apps use token-based authentication rather than connection strings when authenticating to Azure resources. The Azure SDK for .NET provides classes that support token-based authentication and allow apps to seamlessly authenticate to Azure resources whether the app is in local development, deployed to Azure, or deployed to an on-premises server. -> [!TIP] -> See the [Azure Identity, Resource Management, and Storage sample](/samples/dotnet/samples/azure-identity-resource-management-storage/) for examples of using Azure Identity to manage and access Azure resources. +The specific type of token-based authentication an app should use to authenticate to Azure resources depends on where the app is being run and is shown in the following diagram. -To authenticate with libraries that don't support Azure.Identity, see the rest of this topic. +:::image type="content" source="./media/dotnet-sdk-auth-strategy.png" alt-text="A diagram showing the recommended token-based authentication strategies for an app depending on where it's running." ::: -## Access Azure resources +- **When a developer is running an app during local development -** The app can authenticate to Azure using either an application service principal for local development or by using the developer's Azure credentials. Each of these options is discussed in more detail in the section [authentication during local development](#authentication-during-local-development). +- **When an app is hosted on Azure -** The app should authenticate to Azure resources using a managed identity. This option is discussed in more detail below in the section [authentication in server environments](#authentication-in-server-environments). +- **When an app is hosted and deployed on-premises -** The app should authenticate to Azure resources using an application service principal. This option is discussed in more detail below in the section [authentication in server environments](#authentication-in-server-environments). -To interact with Azure resources, such as retrieving a secret from Key Vault or storing a blob in Storage, many Azure service libraries require a connection string or keys for authentication. For example, SQL Database uses a [standard SQL connection string](/azure/azure-sql/database/connect-query-dotnet-core). Service connection strings are used in other Azure services like [CosmosDB](/azure/cosmos-db/), [Azure Cache for Redis](/azure/azure-cache-for-redis/cache-dotnet-how-to-use-azure-redis-cache), and [Service Bus](/azure/service-bus-messaging/service-bus-dotnet-get-started-with-queues). You can get those strings using the Azure portal, CLI, or PowerShell. You can also use the Azure management libraries for .NET to query resources to build connection strings in your code. +### DefaultAzureCredential -The methods for using a connection string vary by product. [Refer to the documentation for your Azure product](/azure/?product=featured). +The [`DefaultAzureCredential`](#use-defaultazurecredential-in-an-application) class provided by the Azure SDK allows apps to use different authentication methods depending on the environment they're run in. This allows apps to be promoted from local development to test environments to production without code changes. You configure the appropriate authentication method for each environment and `DefaultAzureCredential` will automatically detect and use that authentication method. The use of `DefaultAzureCredential` should be preferred over manually coding conditional logic or feature flags to use different authentication methods in different environments. -## Manage Azure resources +Details about using the `DefaultAzureCredential` class are covered later in this article in the section [Use `DefaultAzureCredential` in an application](#use-defaultazurecredential-in-an-application). -[!include[Create service principal](../includes/create-sp.md)] +### Advantages of token-based authentication -Now that the service principal is created, two options are available to authenticate to the service principal to create and manage resources. +Token-based authentication is strongly recommended over using connection strings when building apps for Azure. Token-based authentication offers the following advantages over authenticating with connection strings. -For both options you will need to add the following NuGet packages to your project. +- The token-based authentication methods described below allows you to establish the specific permissions needed by the app on the Azure resource. This follows the [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege). In contrast, a connection string grants full rights to the Azure resource. +- Whereas anyone or any app with a connection string can connect to an Azure resource, token-based authentication methods scope access to the resource to only the app(s) intended to access the resource. +- In the case of a managed identity, there is no application secret to store. This makes the app more secure because there's no connection string or application secret than can be compromised. +- The [azure.identity](https://pypi.org/project/azure-identity/) package in the Azure SDK manages tokens for you behind the scenes. This makes using token based authentication as easy to use as a connection string. -```powershell -Install-Package Microsoft.Azure.Management.Fluent -Install-Package Microsoft.Azure.Management.ResourceManager.Fluent -``` +Use of connection strings should be limited to initial proof of concept apps or development prototypes that don't access production or sensitive data. Otherwise, the token-based authentication classes available in the Azure SDK should always be preferred when authenticating to Azure resources. -### Authenticate with token credentials +## Authentication in server environments -The first method is to build the token credential object in code. You should store the credentials securely in a configuration file, the registry, or Azure KeyVault. +When hosting in a server environment, each application should be assigned a unique *application identity* per environment the application is run in. In Azure, an app identity is represented by a **service principal**, a special type of *security principal* intended to identify and authenticate apps to Azure. The type of service principal to use for your app depends on where your app is running. -```csharp -var credentials = SdkContext.AzureCredentialsFactory - .FromServicePrincipal(clientId, - clientSecret, - tenantId, - AzureEnvironment.AzureGlobalCloud); -``` +| Authentication method | Description | +|-----------------------|-------------| +| Apps hosted in Azure | [!INCLUDE [sdk-auth-overview-managed-identity](./includes/sdk-auth-overview-managed-identity.md)] | +| Apps hosted outside of Azure
(for example on-premises apps) | [!INCLUDE [sdk-auth-overview-service-principal](./includes/sdk-auth-overview-service-principal.md)] | -Use the *clientId*, *clientSecret*, and *tenantId* values from the JSON output when you created the service principal. +## Authentication during local development -Then create the entry point `Azure` object to start working with the API: +When an application is run on a developer's workstation during local development, it still must authenticate to any Azure services used by the app. The two main strategies for authenticating apps to Azure during local development are: -```csharp -var azure = Microsoft.Azure.Management.Fluent.Azure - .Configure() - .Authenticate(credentials) - .WithDefaultSubscription(); -``` +| Authentication method | Description | +|-----------------------|-------------| +| Create dedicated application service principal objects to be used during local development | [!INCLUDE [sdk-auth-overview-dev-service-principals](./includes/sdk-auth-overview-dev-service-principals.md)] | +| Authenticate the app to Azure using the developer's credentials during local development | [!INCLUDE [sdk-auth-overview-dev-accounts](./includes/sdk-auth-overview-dev-accounts.md)] | -It is recommended that you explicitly provide the *subscriptionId* from the JSON output to the `Azure` object: +## Use DefaultAzureCredential in an application -```csharp -var azure = Microsoft.Azure.Management.Fluent.Azure - .Configure() - .Authenticate(credentials) - .WithSubscription(subscriptionId); -``` +[!INCLUDE [Implement Default Azure Credentials](<./includes/implement-defaultazurecredential.md>)] -### File-based authentication +### Exploring the sequence of DefaultAzureCredential authentication methods -File-based authentication allows you to put the service principal credentials in a plain text file and secure it within the file system. +Internally, `DefaultAzureCredential` implements a chain of credential providers for authenticating applications to Azure resources. Each credential provider is able to detect if credentials of that type are configured for the app. `DefaultAzureCredential` sequentially checks each provider in order and uses the credentials from the first provider that has credentials configured. -[!include[File-based authentication](../includes/file-based-auth.md)] +The order in which `DefaultAzureCredential` looks for credentials is shown in the diagram and table below. -Read the contents of the file and create the entry point `Azure` object to start working with the API: +:::image type="content" source="./media/authentication-defaultazurecredential.png" alt-text="A diagram showing the `DefaultAzureCredential` sequence checks to see what authentication source is configured for an application." lightbox="./media/default-azure-credential-sequence-diagram.png"::: -```csharp -// pull in the location of the authentication properties file from the environment -var credentials = SdkContext.AzureCredentialsFactory - .FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION")); - -var azure = Microsoft.Azure.Management.Fluent.Azure - .Configure() - .Authenticate(credentials) - .WithDefaultSubscription(); -``` +| Credential type | Description | +|-------------------------------|-------------| +| Application service principal | `DefaultAzureCredential` reads a set of environment variables to determine if an application service principal (application user) has been set for the app. If so, `DefaultAzureCredential` uses these values to authenticate the app to Azure.

This method is most often used in server environments but can also be used when developing locally. | +| Managed Identity | If the application is deployed to an Azure host with Managed Identity enabled, `DefaultAzureCredential` will authenticate the app to Azure using that Managed Identity. Authentication using a Managed Identity is discussed in the [Authentication in server environments](#authentication-in-server-environments) section of this document.

This method is only available when an application is hosted in Azure using a service like Azure App Service, Azure Functions, or Azure Virtual Machines. | +| Visual Studio | If the developer has authenticated to Azure by logging into Visual Studio, `DefaultAzureCredential` will authenticate the app to Azure using that same account. | +| Visual Studio Code | If the developer has authenticated to Azure using the Visual Studio Code Azure Account plugin, `DefaultAzureCredential` will authenticate the app to Azure using that same account. | +| Azure CLI | If a developer has authenticated to Azure using the `az login` command in the Azure CLI, `DefaultAzureCredential` will authenticate the app to Azure using that same account. | +| Azure PowerShell | If a developer has authenticated to Azure using the `Connect-AzAccount` cmdlet from Azure PowerShell, `DefaultAzureCredential` will authenticate the app to Azure using that same account. | +| Interactive | If enabled, `DefaultAzureCredential` will interactively authenticate the developer via the current system's default browser. By default, this option is disabled. | diff --git a/docs/azure/sdk/azure-sdk-for-dotnet.md b/docs/azure/sdk/azure-sdk-for-dotnet.md index 1a380af809b68..eea8dcec7ba34 100644 --- a/docs/azure/sdk/azure-sdk-for-dotnet.md +++ b/docs/azure/sdk/azure-sdk-for-dotnet.md @@ -3,8 +3,7 @@ title: Azure SDK for .NET Overview description: Provides an overview of what the Azure SDK for .NET is and the basic steps to use the SDK in a .NET application ms.date: 09/02/2021 ms.custom: devx-track-dotnet -ms.author: daberry -author: daberry +author: DavidCBerry13 --- # Azure SDK for .NET overview diff --git a/docs/azure/sdk/dependency-injection.md b/docs/azure/sdk/dependency-injection.md index 195831a2cafdf..1579c7ca764a7 100644 --- a/docs/azure/sdk/dependency-injection.md +++ b/docs/azure/sdk/dependency-injection.md @@ -178,7 +178,7 @@ At some point, you might want to change the default settings for a service clien { "AzureDefaults": { "Retry": { - "maxTries": 3 + "maxRetries": 3 } }, "KeyVault": { diff --git a/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-1.md b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-1.md new file mode 100644 index 0000000000000..7c2f9a583aed9 --- /dev/null +++ b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-1.md @@ -0,0 +1,3 @@ +Locate the resource group for your application by searching for the resource group name using the search box at the top of the Azure portal.
+
+Navigate to your resource group by selecting the resource group name under the *Resource Groups* heading in the dialog box. diff --git a/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-2.md b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-2.md new file mode 100644 index 0000000000000..798fd48a5eda0 --- /dev/null +++ b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-2.md @@ -0,0 +1 @@ +On the page for the resource group, select *Access control (IAM)* from the left-hand menu. diff --git a/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-3.md b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-3.md new file mode 100644 index 0000000000000..dc3aa38a07de4 --- /dev/null +++ b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-3.md @@ -0,0 +1,4 @@ +On the *Access control (IAM)* page: + +1. Select the *Role assignments* tab. +1. Select *+ Add* from the top menu and then *Add role assignment* from the resulting drop-down menu. diff --git a/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-4.md b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-4.md new file mode 100644 index 0000000000000..1ff15830a2eb4 --- /dev/null +++ b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-4.md @@ -0,0 +1,6 @@ +The *Add role assignment* page lists all of the roles that can be assigned for the resource group. + +1. Use the search box to filter the list to a more manageable size. This example shows how to filter for Storage Blob roles. +1. Select the role that you want to assign. +
+Select *Next* to go to the next screen. diff --git a/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-5.md b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-5.md new file mode 100644 index 0000000000000..c956b4d57fe60 --- /dev/null +++ b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-5.md @@ -0,0 +1,6 @@ +The next *Add role assignment* page allows you to specify what user to assign the role to. + +1. Select *User, group, or service principal* under *Assign access to*. +1. Select *+ Select members* under *Members* + +A dialog box will open on the right-hand side of the Azure portal. diff --git a/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-6.md b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-6.md new file mode 100644 index 0000000000000..5604e19c30547 --- /dev/null +++ b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-6.md @@ -0,0 +1,6 @@ +In the *Select members* dialog: + +1. The *Select* text box can be used to filter the list of users and groups in your subscription. If needed, type the first few characters of the local development Azure AD group you created for the app. +1. Select the local development Azure AD group associated with your application. + +Select *Select* at the bottom of the dialog to continue. diff --git a/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-7.md b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-7.md new file mode 100644 index 0000000000000..fcaacdecf8bba --- /dev/null +++ b/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-7.md @@ -0,0 +1,3 @@ +The Azure AD group will now show as selected on the *Add role assignment* screen.
+
+Select *Review + assign* to go to the final page and then *Review + assign* again to complete the process. diff --git a/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-1.md b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-1.md new file mode 100644 index 0000000000000..7c2f9a583aed9 --- /dev/null +++ b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-1.md @@ -0,0 +1,3 @@ +Locate the resource group for your application by searching for the resource group name using the search box at the top of the Azure portal.
+
+Navigate to your resource group by selecting the resource group name under the *Resource Groups* heading in the dialog box. diff --git a/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-2.md b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-2.md new file mode 100644 index 0000000000000..798fd48a5eda0 --- /dev/null +++ b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-2.md @@ -0,0 +1 @@ +On the page for the resource group, select *Access control (IAM)* from the left-hand menu. diff --git a/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-3.md b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-3.md new file mode 100644 index 0000000000000..dc3aa38a07de4 --- /dev/null +++ b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-3.md @@ -0,0 +1,4 @@ +On the *Access control (IAM)* page: + +1. Select the *Role assignments* tab. +1. Select *+ Add* from the top menu and then *Add role assignment* from the resulting drop-down menu. diff --git a/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-4.md b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-4.md new file mode 100644 index 0000000000000..1ff15830a2eb4 --- /dev/null +++ b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-4.md @@ -0,0 +1,6 @@ +The *Add role assignment* page lists all of the roles that can be assigned for the resource group. + +1. Use the search box to filter the list to a more manageable size. This example shows how to filter for Storage Blob roles. +1. Select the role that you want to assign. +
+Select *Next* to go to the next screen. diff --git a/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-5.md b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-5.md new file mode 100644 index 0000000000000..c18f7c0085625 --- /dev/null +++ b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-5.md @@ -0,0 +1,6 @@ +The next *Add role assignment* page allows you to specify what user to assign the role to. + +1. Select *Managed identity* under *Assign access to*. +1. Select *+ Select members* under *Members* + +A dialog box will open on the right-hand side of the Azure portal. diff --git a/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-6.md b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-6.md new file mode 100644 index 0000000000000..29c9f8c7f8735 --- /dev/null +++ b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-6.md @@ -0,0 +1,6 @@ +In the *Select managed identities* dialog: + +1. The *Managed identity* dropdown and *Select* text box can be used to filter the list of managed identities in your subscription. In this example by selecting *App Service*, only managed identities associated with an App Service are displayed. +1. Select the managed identity for the Azure resource hosting your application. + +Select *Select* at the bottom of the dialog to continue. diff --git a/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-7.md b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-7.md new file mode 100644 index 0000000000000..96841bf6f1e24 --- /dev/null +++ b/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-7.md @@ -0,0 +1,3 @@ +The managed identity will now show as selected on the *Add role assignment* screen.
+
+Select *Review + assign* to go to the final page and then *Review + assign* again to complete the process. diff --git a/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-1.md b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-1.md new file mode 100644 index 0000000000000..7c2f9a583aed9 --- /dev/null +++ b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-1.md @@ -0,0 +1,3 @@ +Locate the resource group for your application by searching for the resource group name using the search box at the top of the Azure portal.
+
+Navigate to your resource group by selecting the resource group name under the *Resource Groups* heading in the dialog box. diff --git a/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-2.md b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-2.md new file mode 100644 index 0000000000000..798fd48a5eda0 --- /dev/null +++ b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-2.md @@ -0,0 +1 @@ +On the page for the resource group, select *Access control (IAM)* from the left-hand menu. diff --git a/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-3.md b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-3.md new file mode 100644 index 0000000000000..dc3aa38a07de4 --- /dev/null +++ b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-3.md @@ -0,0 +1,4 @@ +On the *Access control (IAM)* page: + +1. Select the *Role assignments* tab. +1. Select *+ Add* from the top menu and then *Add role assignment* from the resulting drop-down menu. diff --git a/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-4.md b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-4.md new file mode 100644 index 0000000000000..1ff15830a2eb4 --- /dev/null +++ b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-4.md @@ -0,0 +1,6 @@ +The *Add role assignment* page lists all of the roles that can be assigned for the resource group. + +1. Use the search box to filter the list to a more manageable size. This example shows how to filter for Storage Blob roles. +1. Select the role that you want to assign. +
+Select *Next* to go to the next screen. diff --git a/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-5.md b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-5.md new file mode 100644 index 0000000000000..c956b4d57fe60 --- /dev/null +++ b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-5.md @@ -0,0 +1,6 @@ +The next *Add role assignment* page allows you to specify what user to assign the role to. + +1. Select *User, group, or service principal* under *Assign access to*. +1. Select *+ Select members* under *Members* + +A dialog box will open on the right-hand side of the Azure portal. diff --git a/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-6.md b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-6.md new file mode 100644 index 0000000000000..e545ffb9ac777 --- /dev/null +++ b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-6.md @@ -0,0 +1,6 @@ +In the *Select members* dialog: + +1. The *Select* text box can be used to filter the list of users and groups in your subscription. If needed, type the first few characters of the service principal you created for the app to filter the list. +1. Select the service principal associated with your application. + +Select *Select* at the bottom of the dialog to continue. diff --git a/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-7.md b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-7.md new file mode 100644 index 0000000000000..db1fb007dc848 --- /dev/null +++ b/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-7.md @@ -0,0 +1,3 @@ +The service principal will now show as selected on the *Add role assignment* screen.
+
+Select *Review + assign* to go to the final page and then *Review + assign* again to complete the process. diff --git a/docs/azure/sdk/includes/enable-managed-identity-azure-cli.md b/docs/azure/sdk/includes/enable-managed-identity-azure-cli.md new file mode 100644 index 0000000000000..da60e46d69071 --- /dev/null +++ b/docs/azure/sdk/includes/enable-managed-identity-azure-cli.md @@ -0,0 +1,13 @@ +#### [Azure App Service](#tab/azure-app-service) + +```azurecli +az webapp identity assign --resource-group -name +``` + +#### [Azure Virtual Machines](#tab/azure-virtual-machines) + +```azurecli +az vm identity assign --resource-group -name +``` + +--- diff --git a/docs/azure/sdk/includes/enable-managed-identity-azure-portal-1.md b/docs/azure/sdk/includes/enable-managed-identity-azure-portal-1.md new file mode 100644 index 0000000000000..845296ae3ccb9 --- /dev/null +++ b/docs/azure/sdk/includes/enable-managed-identity-azure-portal-1.md @@ -0,0 +1,3 @@ +Navigate to the resource that hosts your application code in the Azure portal.
+
+For example, you can type the name of your resource in the search box at the top of the page and navigate to it by selecting it in the dialog box. diff --git a/docs/azure/sdk/includes/enable-managed-identity-azure-portal-2.md b/docs/azure/sdk/includes/enable-managed-identity-azure-portal-2.md new file mode 100644 index 0000000000000..8829646f2b193 --- /dev/null +++ b/docs/azure/sdk/includes/enable-managed-identity-azure-portal-2.md @@ -0,0 +1,3 @@ +On the page for your resource, select the *Identity* menu item from the left-hand menu.
+
+All Azure resources capable of supporting managed identity will have an *Identity* menu item even though the layout of the menu may vary slightly. diff --git a/docs/azure/sdk/includes/enable-managed-identity-azure-portal-3.md b/docs/azure/sdk/includes/enable-managed-identity-azure-portal-3.md new file mode 100644 index 0000000000000..96613ae37a1d8 --- /dev/null +++ b/docs/azure/sdk/includes/enable-managed-identity-azure-portal-3.md @@ -0,0 +1,6 @@ +On the *Identity* page: + +1. Change the *Status* slider to *On*. +1. Click *Save*. + +A confirmation dialog will verify you want to enable managed identity for your service. Answer *Yes* and managed identity will be enabled for the Azure resource. diff --git a/docs/azure/sdk/includes/implement-defaultazurecredential.md b/docs/azure/sdk/includes/implement-defaultazurecredential.md new file mode 100644 index 0000000000000..37be8e93c2df1 --- /dev/null +++ b/docs/azure/sdk/includes/implement-defaultazurecredential.md @@ -0,0 +1,60 @@ +`DefaultAzureCredential` supports multiple authentication methods and determines the authentication method being used at runtime. In this way, your app can use different authentication methods in different environments without implementing environment specific code. + +The order and locations in which `DefaultAzureCredential` looks for credentials is shown in the diagram and table below. + +:::image type="content" source="../media/authentication-defaultazurecredential.png" alt-text="A diagram showing the sequence in which DefaultAzureCredential checks to see what authentication source is configured for an application." lightbox="../media/default-azure-credential-sequence-diagram.png"::: + +To implement `DefaultAzureCredential`, first add the [`Azure.Identity`](/dotnet/api/azure.identity) and optionally the [`Microsoft.Extensions.Azure`](/dotnet/api/microsoft.extensions.azure) packages to your application. You can do this using either the command line or the NuGet Package Manager. + +### [Command Line](#tab/command-line) + +Open a terminal environment of your choice in the application project directory and enter the command below. + +```terminal +dotnet add package Azure.Identity +dotnet add package Microsoft.Extensions.Azure +``` + +### [NuGet Package Manager](#tab/nuget-package) + +Right click on your project node in Visual Studio and select **Manage NuGet Packages**. Search for **Azure.Identity** in the search field, and install the matching package. Repeat this process for the **Microsoft.Extensions.Azure** package as well. + +:::image type="content" source="../media/nuget-azure-identity.png" alt-text="Install a package using the package manager."::: + +--- + +Azure services are generally accessed using corresponding client classes from the SDK. These classes and your own custom services should be registered in the `Program.cs` file so they can be accessed via dependency injection throughout your app. Inside of `Program.cs`, follow the steps below to correctly setup your service and `DefaultAzureCredential`. + +1. Include the `Azure.Identity` and `Microsoft.Extensions.Azure` namespaces with a using statement. +1. Register the Azure service using relevant helper methods. +1. Pass and instance of the `DefaultAzureCredential` object to the `UseCredential` method. + +An example of this is shown in the following code segment. + +```c# +using Microsoft.Extensions.Azure; +using Azure.Identity; + +// Inside of Program.cs +builder.Services.AddAzureClients(x => +{ + x.AddBlobServiceClient(new Uri("https://.blob.core.windows.net")); + x.UseCredential(new DefaultAzureCredential()); +}); +``` + +Alternatively, you can also utilize DefaultAzureCredential in your services more directly without the help of additional Azure registration methods, as seen below. + +```c# +using Azure.Identity; + +// Inside of Program.cs +builder.Services.AddSingleton(x => + new BlobServiceClient( + new Uri("https://.blob.core.windows.net"), + new DefaultAzureCredential())); +``` + +When the above code is run on your local workstation during local development, it will look in the environment variables for an application service principal or at Visual Studio, VS Code, the Azure CLI, or Azure PowerShell for a set of developer credentials, either of which can be used to authenticate the app to Azure resources during local development. + +When deployed to Azure this same code can also authenticate your app to other Azure resources. `DefaultAzureCredential` can retrieve environment settings and managed identity configurations to authenticate to other services automatically. diff --git a/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-1.md b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-1.md new file mode 100644 index 0000000000000..1be87a123dbc2 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-1.md @@ -0,0 +1 @@ +Navigate to the Azure Active Directory page in the Azure portal by typing *Azure Active Directory* into the search box at the top of the page and then selecting *Azure Active Directory* from under services. diff --git a/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-2.md b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-2.md new file mode 100644 index 0000000000000..b796442faaa44 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-2.md @@ -0,0 +1 @@ +On the *Azure Active Directory* page, select **Groups** from the left-hand menu. diff --git a/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-3.md b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-3.md new file mode 100644 index 0000000000000..e3a3f0b89f4d2 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-3.md @@ -0,0 +1 @@ +On the *All groups* page, select **New group**. diff --git a/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-4.md b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-4.md new file mode 100644 index 0000000000000..c560c361a0397 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-4.md @@ -0,0 +1,6 @@ +On the **New Group** page: + +1. **Group type** → **Security** +1. **Group name** → A name for the security group, typically created from the application name. It is also helpful to include a string like *local-dev* in the name of the group to indicate the purpose of the group. +1. **Group description** → A description of the purpose of the group. +1. Select the **No members selected** link under **Members** to add members to the group. diff --git a/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-5.md b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-5.md new file mode 100644 index 0000000000000..4be75f05623b2 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-5.md @@ -0,0 +1,5 @@ +On the **Add members** dialog box: + +1. Use the search box to filter the list of user names in the list. +1. Select the user(s) for local development for this app. As objects are selected, they will move to the *Selected items* list at the bottom of the dialog. +1. When finished, select the **Select** button. diff --git a/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-6.md b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-6.md new file mode 100644 index 0000000000000..5464a6d7716f4 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-accounts-app-ad-group-azure-portal-6.md @@ -0,0 +1,3 @@ +Back on the **New group** page, select **Create** to create the group.
+
+The group will be created and you will be taken back to the **All groups** page. It may take up to 30 seconds for the group to appear and you may need to refresh the page due to caching in the Azure portal. diff --git a/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-1.md b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-1.md new file mode 100644 index 0000000000000..1be87a123dbc2 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-1.md @@ -0,0 +1 @@ +Navigate to the Azure Active Directory page in the Azure portal by typing *Azure Active Directory* into the search box at the top of the page and then selecting *Azure Active Directory* from under services. diff --git a/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-2.md b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-2.md new file mode 100644 index 0000000000000..b796442faaa44 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-2.md @@ -0,0 +1 @@ +On the *Azure Active Directory* page, select **Groups** from the left-hand menu. diff --git a/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-3.md b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-3.md new file mode 100644 index 0000000000000..e3a3f0b89f4d2 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-3.md @@ -0,0 +1 @@ +On the *All groups* page, select **New group**. diff --git a/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-4.md b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-4.md new file mode 100644 index 0000000000000..c560c361a0397 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-4.md @@ -0,0 +1,6 @@ +On the **New Group** page: + +1. **Group type** → **Security** +1. **Group name** → A name for the security group, typically created from the application name. It is also helpful to include a string like *local-dev* in the name of the group to indicate the purpose of the group. +1. **Group description** → A description of the purpose of the group. +1. Select the **No members selected** link under **Members** to add members to the group. diff --git a/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-5.md b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-5.md new file mode 100644 index 0000000000000..625dc616f8506 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-5.md @@ -0,0 +1,5 @@ +On the **Add members** dialog box: + +1. Use the search box to filter the list of principal names in the list. +1. Select the application service principals for local development for this app. As objects are selected, they will be greyed out and move to the *Selected items* list at the bottom of the dialog. +1. When finished, select the **Select** button. diff --git a/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-6.md b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-6.md new file mode 100644 index 0000000000000..5464a6d7716f4 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-ad-group-azure-portal-6.md @@ -0,0 +1,3 @@ +Back on the **New group** page, select **Create** to create the group.
+
+The group will be created and you will be taken back to the **All groups** page. It may take up to 30 seconds for the group to appear and you may need to refresh the page due to caching in the Azure portal. diff --git a/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-1.md b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-1.md new file mode 100644 index 0000000000000..a084bacc686bc --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-1.md @@ -0,0 +1,4 @@ +In the Azure portal: + + 1. Enter *app registrations* in the search bar at the top of the Azure portal. + 1. Select the item labeled **App registrations** under the **Services** heading on the menu that appears below the search bar. diff --git a/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-2.md b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-2.md new file mode 100644 index 0000000000000..e5f386b9e87e8 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-2.md @@ -0,0 +1 @@ +On the **App registrations** page, select **+ New registration**. diff --git a/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-3.md b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-3.md new file mode 100644 index 0000000000000..b8a429b3caa21 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-3.md @@ -0,0 +1,6 @@ +On the **Register an application** page, fill out the form as follows. + +1. **Name** → Enter a name for the app registration in Azure. It is recommended this name include the app name, the user the app registration is for, and an identifier like 'dev' to indicate this app registration is for use in local development. +1. **Supported account types** → *Accounts in this organizational directory only*. + +Select **Register** to register your app and create the application service principal. diff --git a/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-4.md b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-4.md new file mode 100644 index 0000000000000..4e59f41e79488 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-4.md @@ -0,0 +1,5 @@ +On the App registration page for your app: + +1. **Application (client) ID** → This is the app id the app will use to access Azure during local development. Copy this value to a temporary location in a text editor as you will need it in a future step. +1. **Directory (tenant) id** → This value will also be needed by your app when it authenticates to Azure. Copy this value to a temporary location in a text editor it will also be needed it in a future step. +1. **Client credentials** → You must set the client credentials for the app before your app can authenticate to Azure and use Azure services. Select *Add a certificate or secret* to add credentials for your app. diff --git a/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-5.md b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-5.md new file mode 100644 index 0000000000000..460b59c741216 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-5.md @@ -0,0 +1 @@ +On the Certificates & secrets page, select **+ New client secret**. diff --git a/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-6.md b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-6.md new file mode 100644 index 0000000000000..30ee46b6e1090 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-6.md @@ -0,0 +1,6 @@ +The **Add a client secret** dialog will pop out from the right-hand side of the page. In this dialog: + +1. **Description** → Enter a value of *Current*. +1. **Expires** → Select a value of *24 months*. + +Select **Add** to add the secret. diff --git a/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-7.md b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-7.md new file mode 100644 index 0000000000000..afbc508390ea8 --- /dev/null +++ b/docs/azure/sdk/includes/local-dev-app-registration-azure-portal-7.md @@ -0,0 +1,5 @@ +On the *Certificates & secrets* page, you will be shown the value of the client secret.
+
+Copy this value to a temporary location in a text editor as you will need it in a future step.
+
+***IMPORTANT: This is the only time you will see this value.*** Once you leave or refresh this page, you will not be able to see this value again. You may add an additional client secret without invalidating this client secret, but you will not see this value again. diff --git a/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-1.md b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-1.md new file mode 100644 index 0000000000000..5cf9302796cc8 --- /dev/null +++ b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-1.md @@ -0,0 +1,4 @@ +In the Azure portal: + + 1. Enter *app registrations* in the search bar at the top of the Azure portal. + 1. Select the item labeled **App registrations** under the under **Services** heading on the menu that appears below the search bar. diff --git a/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-2.md b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-2.md new file mode 100644 index 0000000000000..e5f386b9e87e8 --- /dev/null +++ b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-2.md @@ -0,0 +1 @@ +On the **App registrations** page, select **+ New registration**. diff --git a/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-3.md b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-3.md new file mode 100644 index 0000000000000..1bfe879d67671 --- /dev/null +++ b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-3.md @@ -0,0 +1,6 @@ +On the **Register an application** page, fill out the form as follows. + +1. **Name** → Enter a name for the app registration in Azure. It is recommended this name include the app name and environment (test, prod) the app registration is for. +1. **Supported account types** → *Accounts in this organizational directory only*. + +Select **Register** to register your app and create the application service principal. diff --git a/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-4.md b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-4.md new file mode 100644 index 0000000000000..4e59f41e79488 --- /dev/null +++ b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-4.md @@ -0,0 +1,5 @@ +On the App registration page for your app: + +1. **Application (client) ID** → This is the app id the app will use to access Azure during local development. Copy this value to a temporary location in a text editor as you will need it in a future step. +1. **Directory (tenant) id** → This value will also be needed by your app when it authenticates to Azure. Copy this value to a temporary location in a text editor it will also be needed it in a future step. +1. **Client credentials** → You must set the client credentials for the app before your app can authenticate to Azure and use Azure services. Select *Add a certificate or secret* to add credentials for your app. diff --git a/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-5.md b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-5.md new file mode 100644 index 0000000000000..460b59c741216 --- /dev/null +++ b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-5.md @@ -0,0 +1 @@ +On the Certificates & secrets page, select **+ New client secret**. diff --git a/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-6.md b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-6.md new file mode 100644 index 0000000000000..bca28c4fd69fa --- /dev/null +++ b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-6.md @@ -0,0 +1,8 @@ +The **Add a client secret** dialog will pop out from the right-hand side of the page. In this dialog: + +1. **Description** → Enter a value of *Current*. +1. **Expires** → Select a value of *24 months*. + +Select **Add** to add the secret.
+
+***IMPORTANT: Set a reminder in your calendar prior to the expiration date of the secret.*** This way, you can add a new secret prior and update your apps prior to the expiration of this secret and avoid a service interruption in your app. diff --git a/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-7.md b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-7.md new file mode 100644 index 0000000000000..afbc508390ea8 --- /dev/null +++ b/docs/azure/sdk/includes/on-premises-app-registration-azure-portal-7.md @@ -0,0 +1,5 @@ +On the *Certificates & secrets* page, you will be shown the value of the client secret.
+
+Copy this value to a temporary location in a text editor as you will need it in a future step.
+
+***IMPORTANT: This is the only time you will see this value.*** Once you leave or refresh this page, you will not be able to see this value again. You may add an additional client secret without invalidating this client secret, but you will not see this value again. diff --git a/docs/azure/sdk/includes/sdk-auth-overview-dev-accounts.md b/docs/azure/sdk/includes/sdk-auth-overview-dev-accounts.md new file mode 100644 index 0000000000000..9cc3e8b98b39a --- /dev/null +++ b/docs/azure/sdk/includes/sdk-auth-overview-dev-accounts.md @@ -0,0 +1,6 @@ +In this method, a developer must be signed-in to Azure from either Visual Studio, the Azure Tools extension for VS Code, the Azure CLI, or Azure PowerShell on their local workstation. The application then can access the developer's credentials from the credential store and use those credentials to access Azure resources from the app.
+
+This method has the advantage of easier setup since a developer only needs to login to their Azure account from Visual Studio, VS Code or the Azure CLI. The disadvantage of this approach is that the developer's account likely has more permissions than required by the application, therefore not properly replicating the permissions the app will run with in production.
+
+> [!div class="nextstepaction"] +> [Learn about auth from Azure hosted apps](../authentication-local-development-dev-accounts.md) diff --git a/docs/azure/sdk/includes/sdk-auth-overview-dev-service-principals.md b/docs/azure/sdk/includes/sdk-auth-overview-dev-service-principals.md new file mode 100644 index 0000000000000..147f84a4fcb65 --- /dev/null +++ b/docs/azure/sdk/includes/sdk-auth-overview-dev-service-principals.md @@ -0,0 +1,8 @@ +In this method, dedicated **application service principal** objects are set up using the App registration process for use during local development. The identity of the service principal is then stored as environment variables to be accessed by the app when it is run in local development.
+
+This method allows you to assign the specific resource permissions needed by the app to the service principal objects used by developers during local development. This makes sure the application only has access to the specific resources it needs and replicates the permissions the app will have in production.
+
+The downside of this approach is the need to create separate service principal objects for each developer that works on an application.
+
+> [!div class="nextstepaction"] +> [Learn about auth from Azure hosted apps](../authentication-local-development-service-principal.md) diff --git a/docs/azure/sdk/includes/sdk-auth-overview-managed-identity.md b/docs/azure/sdk/includes/sdk-auth-overview-managed-identity.md new file mode 100644 index 0000000000000..289ace6ca4d28 --- /dev/null +++ b/docs/azure/sdk/includes/sdk-auth-overview-managed-identity.md @@ -0,0 +1,6 @@ +Apps hosted in Azure should use a **Managed Identity service principal**. Managed identities are designed to represent the identity of an app hosted in Azure and can only be used with Azure hosted apps.
+
+For example, a .NET web app hosted in Azure App Service would be assigned a Managed Identity. The Managed Identity assigned to the app would then be used to authenticate the app to other Azure services.
+
+> [!div class="nextstepaction"] +> [Learn about auth from Azure hosted apps](../authentication-azure-hosted-apps.md) diff --git a/docs/azure/sdk/includes/sdk-auth-overview-service-principal.md b/docs/azure/sdk/includes/sdk-auth-overview-service-principal.md new file mode 100644 index 0000000000000..a193fe33b100a --- /dev/null +++ b/docs/azure/sdk/includes/sdk-auth-overview-service-principal.md @@ -0,0 +1,6 @@ +Apps hosted outside of Azure (for example on-premises apps) that need to connect to Azure services should use an **Application service principal**. An Application service principal represents the identity of the app in Azure and is created through the application registration process.
+
+For example, consider a .NET web app hosted on-premises that makes use of Azure Blob Storage. You would create an Application service principal for the app using the App registration process. The `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET` would all be stored as environment variables to be read by the application at runtime and allow the app to authenticate to Azure using the Application service principal.
+
+> [!div class="nextstepaction"] +> [Learn about auth from apps hosted outside of Azure](../authentication-on-premises-apps.md) diff --git a/docs/azure/sdk/includes/set-environment-variables.md b/docs/azure/sdk/includes/set-environment-variables.md new file mode 100644 index 0000000000000..fe57728e305ab --- /dev/null +++ b/docs/azure/sdk/includes/set-environment-variables.md @@ -0,0 +1,83 @@ +The `DefaultAzureCredential` object will look for service principal credentials in a set of environment variables at runtime. There are multiple ways to configure environment variables when working with .NET depending on your tooling and environment. + +Regardless of which approach you choose, you will need to configure the following environment variables when working with a service principal. + +- `AZURE_CLIENT_ID` → The app ID value. +- `AZURE_TENANT_ID` → The tenant ID value. +- `AZURE_CLIENT_SECRET` → The password/credential generated for the app. + +### [Visual Studio](#tab/visual-studio) + +When working locally with Visual Studio, environment variables can be set in the `launchsettings.json` file in the `Properties` folder of your project. When the app starts up, these values will be pulled in automatically. Keep in mind these configurations do not travel with your application when it gets deployed, so you will still need to setup environment variables on your target hosting environment. + +```json +"profiles": { + "SampleProject": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7177;http://localhost:5177", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "AZURE_CLIENT_ID": "00000000-0000-0000-0000-000000000000", + "AZURE_TENANT_ID":"11111111-1111-1111-1111-111111111111", + "AZURE_CLIENT_SECRET": "=abcdefghijklmnopqrstuvwxyz" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "AZURE_CLIENT_ID": "00000000-0000-0000-0000-000000000000", + "AZURE_TENANT_ID": "11111111-1111-1111-1111-111111111111", + "AZURE_CLIENT_SECRET": "=abcdefghijklmnopqrstuvwxyz" + } + } + } +``` + +### [VS Code](#tab/vs-code) + +When working locally with Visual Studio Code, environment variables can be set in the `launch.json` file of your project. When the app starts up, these values will be pulled in automatically. Keep in mind these configurations do not travel with your application when it gets deployed, so you will still need to setup environment variables on your target hosting environment. + +```json +"configurations": [ +{ + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "AZURE_CLIENT_ID": "00000000-0000-0000-0000-000000000000", + "AZURE_TENANT_ID":"11111111-1111-1111-1111-111111111111", + "AZURE_CLIENT_SECRET": "=abcdefghijklmnopqrstuvwxyz" + } +} +``` + +### [Windows](#tab/windows) + +You can easily set environment variables for Windows from the command line. Windows environment variables can be used for both local development or for hosting environments. However, remember that when using this approach the values will apply to all applications running on that operating system and may cause conflicts if you are not careful. + +```bash +setx AZURE_CLIENT_ID "00000000-0000-0000-0000-000000000000" +setx AZURE_TENANT_ID "11111111-1111-1111-1111-111111111111" +setx AZURE_CLIENT_SECRET "=abcdefghijklmnopqrstuvwxyz" +``` + +Alternatively, if your app is hosted in IIS you can also set environment variables per app. This can be configured using the applicationHost.config file. + +```xml + + + + + + + + + + + + +``` + +--- diff --git a/docs/azure/sdk/logging.md b/docs/azure/sdk/logging.md index c40309fc1cbb7..b9f9c1ab0df3d 100644 --- a/docs/azure/sdk/logging.md +++ b/docs/azure/sdk/logging.md @@ -20,7 +20,7 @@ The [Azure SDK](https://azure.microsoft.com/downloads/) for .NET client librarie ## Log information -The SDK logs the following information, sanitizing parameter query and header values to remove personal data. +The SDK logs each HTTP request and response, sanitizing parameter query and header values to remove personal data. HTTP request log entry: diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-1-240px.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-1-240px.png new file mode 100644 index 0000000000000..61b981b817914 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-1.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-1.png new file mode 100644 index 0000000000000..238dc0318a657 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-2-240px.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-2-240px.png new file mode 100644 index 0000000000000..9986eb24538d6 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-2.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-2.png new file mode 100644 index 0000000000000..fe8fbc4822039 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-3-240px.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-3-240px.png new file mode 100644 index 0000000000000..9b0ba5c2a21b5 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-3.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-3.png new file mode 100644 index 0000000000000..c925c49571913 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-4-240px.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-4-240px.png new file mode 100644 index 0000000000000..f27e3d8ca5b46 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-4-240px.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-4.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-4.png new file mode 100644 index 0000000000000..d32af017b7b28 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-4.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-5-240px.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-5-240px.png new file mode 100644 index 0000000000000..190c9c7c8e02e Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-5-240px.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-5.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-5.png new file mode 100644 index 0000000000000..edcf681014e13 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-5.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-6-240px.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-6-240px.png new file mode 100644 index 0000000000000..be16e82654f3e Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-6-240px.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-6.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-6.png new file mode 100644 index 0000000000000..4ea84ee9d8dc8 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-6.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-7-240px.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-7-240px.png new file mode 100644 index 0000000000000..751f016e80880 Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-7-240px.png differ diff --git a/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-7.png b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-7.png new file mode 100644 index 0000000000000..23adf1ccf8daa Binary files /dev/null and b/docs/azure/sdk/media/assign-local-dev-group-to-role-azure-portal-7.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-1-240px.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-1-240px.png new file mode 100644 index 0000000000000..a8d30d5a18d6b Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-1.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-1.png new file mode 100644 index 0000000000000..ea478ec8744b2 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-2-240px.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-2-240px.png new file mode 100644 index 0000000000000..4c30c3727c1b2 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-2.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-2.png new file mode 100644 index 0000000000000..b073fcce46413 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-3-240px.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-3-240px.png new file mode 100644 index 0000000000000..43f33fec34365 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-3.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-3.png new file mode 100644 index 0000000000000..8a54077f36314 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-4-240px.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-4-240px.png new file mode 100644 index 0000000000000..730205ce6d5ce Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-4-240px.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-4.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-4.png new file mode 100644 index 0000000000000..fee9e0c0ace1b Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-4.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-5-240px.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-5-240px.png new file mode 100644 index 0000000000000..aded1177bff62 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-5-240px.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-5.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-5.png new file mode 100644 index 0000000000000..4725e8d23bc94 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-5.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-6-240px.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-6-240px.png new file mode 100644 index 0000000000000..e060f32a30819 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-6-240px.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-6.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-6.png new file mode 100644 index 0000000000000..cb7e1c6ee9b95 Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-6.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-7-240px.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-7-240px.png new file mode 100644 index 0000000000000..a47f6bc6a6f4e Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-7-240px.png differ diff --git a/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-7.png b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-7.png new file mode 100644 index 0000000000000..b24e71b4c081e Binary files /dev/null and b/docs/azure/sdk/media/assign-managed-identity-to-role-azure-portal-7.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-1-240px.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-1-240px.png new file mode 100644 index 0000000000000..9436389bb04bb Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-1.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-1.png new file mode 100644 index 0000000000000..1c82356b23832 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-2-240px.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-2-240px.png new file mode 100644 index 0000000000000..00315b889e344 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-2.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-2.png new file mode 100644 index 0000000000000..8a0d05ad95259 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-3-240px.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-3-240px.png new file mode 100644 index 0000000000000..88bd270fd316e Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-3.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-3.png new file mode 100644 index 0000000000000..18ac67523a0b2 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-4-240px.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-4-240px.png new file mode 100644 index 0000000000000..f887b6b3d3b9e Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-4-240px.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-4.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-4.png new file mode 100644 index 0000000000000..695ac649e5799 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-4.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-5-240px.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-5-240px.png new file mode 100644 index 0000000000000..900117241e5c2 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-5-240px.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-5.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-5.png new file mode 100644 index 0000000000000..7824a78eebdf0 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-5.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-6-240px.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-6-240px.png new file mode 100644 index 0000000000000..1f297a93b8774 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-6-240px.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-6.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-6.png new file mode 100644 index 0000000000000..262723f68e2f6 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-6.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-7-240px.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-7-240px.png new file mode 100644 index 0000000000000..fb67e50117a61 Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-7-240px.png differ diff --git a/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-7.png b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-7.png new file mode 100644 index 0000000000000..8d99791817d5f Binary files /dev/null and b/docs/azure/sdk/media/assign-service-principal-to-role-azure-portal-7.png differ diff --git a/docs/azure/sdk/media/authentication-defaultazurecredential.png b/docs/azure/sdk/media/authentication-defaultazurecredential.png new file mode 100644 index 0000000000000..9878b613a7024 Binary files /dev/null and b/docs/azure/sdk/media/authentication-defaultazurecredential.png differ diff --git a/docs/azure/sdk/media/default-azure-credential-sequence-diagram.png b/docs/azure/sdk/media/default-azure-credential-sequence-diagram.png new file mode 100644 index 0000000000000..e239a91d4f6f2 Binary files /dev/null and b/docs/azure/sdk/media/default-azure-credential-sequence-diagram.png differ diff --git a/docs/azure/sdk/media/dotnet-sdk-auth-strategy.png b/docs/azure/sdk/media/dotnet-sdk-auth-strategy.png new file mode 100644 index 0000000000000..9e5d3ae47e507 Binary files /dev/null and b/docs/azure/sdk/media/dotnet-sdk-auth-strategy.png differ diff --git a/docs/azure/sdk/media/enable-managed-identity-azure-portal-1-240px.png b/docs/azure/sdk/media/enable-managed-identity-azure-portal-1-240px.png new file mode 100644 index 0000000000000..d601a83a4f19f Binary files /dev/null and b/docs/azure/sdk/media/enable-managed-identity-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/enable-managed-identity-azure-portal-1.png b/docs/azure/sdk/media/enable-managed-identity-azure-portal-1.png new file mode 100644 index 0000000000000..d818c2dac2278 Binary files /dev/null and b/docs/azure/sdk/media/enable-managed-identity-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/enable-managed-identity-azure-portal-2-240px.png b/docs/azure/sdk/media/enable-managed-identity-azure-portal-2-240px.png new file mode 100644 index 0000000000000..4024c86df1717 Binary files /dev/null and b/docs/azure/sdk/media/enable-managed-identity-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/enable-managed-identity-azure-portal-2.png b/docs/azure/sdk/media/enable-managed-identity-azure-portal-2.png new file mode 100644 index 0000000000000..a3c9a78172970 Binary files /dev/null and b/docs/azure/sdk/media/enable-managed-identity-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/enable-managed-identity-azure-portal-3-240px.png b/docs/azure/sdk/media/enable-managed-identity-azure-portal-3-240px.png new file mode 100644 index 0000000000000..6ff33c937ca16 Binary files /dev/null and b/docs/azure/sdk/media/enable-managed-identity-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/enable-managed-identity-azure-portal-3.png b/docs/azure/sdk/media/enable-managed-identity-azure-portal-3.png new file mode 100644 index 0000000000000..0b685fd774355 Binary files /dev/null and b/docs/azure/sdk/media/enable-managed-identity-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-1-240px.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-1-240px.png new file mode 100644 index 0000000000000..2d60bde983983 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-1.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-1.png new file mode 100644 index 0000000000000..7b58da8fdce40 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-2-240px.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-2-240px.png new file mode 100644 index 0000000000000..958fcffa8d8c5 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-2.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-2.png new file mode 100644 index 0000000000000..f429261c5e103 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-3-240px.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-3-240px.png new file mode 100644 index 0000000000000..47342477f6bf0 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-3.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-3.png new file mode 100644 index 0000000000000..75816e304d1fc Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-4-240px.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-4-240px.png new file mode 100644 index 0000000000000..dad36de9ab32f Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-4-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-4.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-4.png new file mode 100644 index 0000000000000..e11a264f36232 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-4.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-5-240px.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-5-240px.png new file mode 100644 index 0000000000000..fbbd42ee5ea0e Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-5-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-5.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-5.png new file mode 100644 index 0000000000000..321febab39f25 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-5.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-6-240px.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-6-240px.png new file mode 100644 index 0000000000000..2f72a5ff554f7 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-6-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-6.png b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-6.png new file mode 100644 index 0000000000000..4f29a40546322 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-accounts-app-ad-group-azure-portal-6.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-1-240px.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-1-240px.png new file mode 100644 index 0000000000000..2d60bde983983 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-1.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-1.png new file mode 100644 index 0000000000000..7b58da8fdce40 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-2-240px.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-2-240px.png new file mode 100644 index 0000000000000..958fcffa8d8c5 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-2.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-2.png new file mode 100644 index 0000000000000..f429261c5e103 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-3-240px.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-3-240px.png new file mode 100644 index 0000000000000..47342477f6bf0 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-3.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-3.png new file mode 100644 index 0000000000000..75816e304d1fc Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-4-240px.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-4-240px.png new file mode 100644 index 0000000000000..331065c228a95 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-4-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-4.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-4.png new file mode 100644 index 0000000000000..fffebda95dc2b Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-4.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-5-240px.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-5-240px.png new file mode 100644 index 0000000000000..d3b0d693ebb09 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-5-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-5.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-5.png new file mode 100644 index 0000000000000..0811978d13c82 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-5.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-6-240px.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-6-240px.png new file mode 100644 index 0000000000000..57be28bea9c89 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-6-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-6.png b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-6.png new file mode 100644 index 0000000000000..fb53294d7ab38 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-ad-group-azure-portal-6.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-1-240px.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-1-240px.png new file mode 100644 index 0000000000000..2a611f35ee9bb Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-1.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-1.png new file mode 100644 index 0000000000000..8ac8554309dce Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-2-240px.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-2-240px.png new file mode 100644 index 0000000000000..01bd5170ee7e3 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-2.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-2.png new file mode 100644 index 0000000000000..7683df0ed28db Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-3-240px.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-3-240px.png new file mode 100644 index 0000000000000..0569c52efabb6 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-3.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-3.png new file mode 100644 index 0000000000000..b586204c7f863 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-4-240px.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-4-240px.png new file mode 100644 index 0000000000000..d009e8f2a133a Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-4-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-4.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-4.png new file mode 100644 index 0000000000000..90a1f0c670f0b Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-4.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-5-240px.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-5-240px.png new file mode 100644 index 0000000000000..63f63fc7af175 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-5-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-5.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-5.png new file mode 100644 index 0000000000000..c9e5636ee6b32 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-5.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-6-240px.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-6-240px.png new file mode 100644 index 0000000000000..e2f2058391cc8 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-6-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-6.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-6.png new file mode 100644 index 0000000000000..437a4d1e7ea7a Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-6.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-7-240px.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-7-240px.png new file mode 100644 index 0000000000000..de2f1058be1b6 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-7-240px.png differ diff --git a/docs/azure/sdk/media/local-dev-app-registration-azure-portal-7.png b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-7.png new file mode 100644 index 0000000000000..79de665404e03 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-app-registration-azure-portal-7.png differ diff --git a/docs/azure/sdk/media/local-dev-dev-accounts-overview.png b/docs/azure/sdk/media/local-dev-dev-accounts-overview.png new file mode 100644 index 0000000000000..196ed814b9801 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-dev-accounts-overview.png differ diff --git a/docs/azure/sdk/media/local-dev-service-principal-overview.png b/docs/azure/sdk/media/local-dev-service-principal-overview.png new file mode 100644 index 0000000000000..811e535cf7424 Binary files /dev/null and b/docs/azure/sdk/media/local-dev-service-principal-overview.png differ diff --git a/docs/azure/sdk/media/nuget-azure-identity.png b/docs/azure/sdk/media/nuget-azure-identity.png new file mode 100644 index 0000000000000..8e5cfa138a1af Binary files /dev/null and b/docs/azure/sdk/media/nuget-azure-identity.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-1-240px.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-1-240px.png new file mode 100644 index 0000000000000..58ca5abcecb17 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-1-240px.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-1.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-1.png new file mode 100644 index 0000000000000..5773540947ff7 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-1.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-2-240px.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-2-240px.png new file mode 100644 index 0000000000000..2eb02abc15181 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-2-240px.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-2.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-2.png new file mode 100644 index 0000000000000..1e3142820baa8 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-2.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-3-240px.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-3-240px.png new file mode 100644 index 0000000000000..f652100dac430 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-3-240px.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-3.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-3.png new file mode 100644 index 0000000000000..8a9146f1ce69b Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-3.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-4-240px.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-4-240px.png new file mode 100644 index 0000000000000..31b3c554e0dc8 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-4-240px.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-4.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-4.png new file mode 100644 index 0000000000000..453709fde89da Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-4.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-5-240px.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-5-240px.png new file mode 100644 index 0000000000000..8380cbc631e89 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-5-240px.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-5.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-5.png new file mode 100644 index 0000000000000..cca6b02e9841a Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-5.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-6-240px.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-6-240px.png new file mode 100644 index 0000000000000..bb100685f279e Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-6-240px.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-6.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-6.png new file mode 100644 index 0000000000000..7eacf77551d3b Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-6.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-7-240px.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-7-240px.png new file mode 100644 index 0000000000000..27fc12fdf0262 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-7-240px.png differ diff --git a/docs/azure/sdk/media/on-premises-app-registration-azure-portal-7.png b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-7.png new file mode 100644 index 0000000000000..33dd612d54a26 Binary files /dev/null and b/docs/azure/sdk/media/on-premises-app-registration-azure-portal-7.png differ diff --git a/docs/azure/sdk/media/visual-studio-sign-in.png b/docs/azure/sdk/media/visual-studio-sign-in.png new file mode 100644 index 0000000000000..9faa35712a330 Binary files /dev/null and b/docs/azure/sdk/media/visual-studio-sign-in.png differ diff --git a/docs/azure/sdk/media/vs-code-azure-login-small.png b/docs/azure/sdk/media/vs-code-azure-login-small.png new file mode 100644 index 0000000000000..21b8413f2d8a0 Binary files /dev/null and b/docs/azure/sdk/media/vs-code-azure-login-small.png differ diff --git a/docs/azure/sdk/media/vs-code-azure-login.png b/docs/azure/sdk/media/vs-code-azure-login.png new file mode 100644 index 0000000000000..559586c80ab21 Binary files /dev/null and b/docs/azure/sdk/media/vs-code-azure-login.png differ diff --git a/docs/azure/sdk/resource-management.md b/docs/azure/sdk/resource-management.md index fb346a8c33400..a88eaef77cfa4 100644 --- a/docs/azure/sdk/resource-management.md +++ b/docs/azure/sdk/resource-management.md @@ -1,15 +1,16 @@ --- title: Resource management description: Learn how to use the Azure SDK for .NET to manage Azure resources. -ms.date: 08/27/2021 +ms.date: 04/20/2022 ms.author: xinrzhu author: nickzhums --- + # Resource management using the Azure SDK for .NET The next-generation of .NET SDK's management (or "management plane") libraries will help you create, provision, and manage Azure resources from within .NET applications. All Azure services have corresponding management libraries. -With the management libraries (names beginning with `Azure.ResourceManager`, e.g. `Azure.ResourceManager.Compute`), you can write configuration and deployment programs to perform the same tasks that you can through the Azure portal, Azure CLI, or other resource management tools. +With the management libraries (names beginning with `Azure.ResourceManager`, for example, `Azure.ResourceManager.Compute`), you can write configuration and deployment programs to perform the same tasks that you can through the Azure portal, Azure CLI, or other resource management tools. Those packages follow the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), which provide core capabilities that are shared amongst all Azure SDKs, including: @@ -19,7 +20,7 @@ Those packages follow the [new Azure SDK guidelines](https://azure.github.io/azu - Distributed tracing. > [!NOTE] -> *Azure.ResourceManager.** packages are currently in Public Preview and may be subject to breaking changes in the future. +> The stable versions of [Azure.ResourceManager](https://www.nuget.org/packages/Azure.ResourceManager) and [Azure.ResourceManager.Resources](https://www.nuget.org/packages/Azure.ResourceManager.Resources) are now available. Phased releases of additional Azure services' management plane client libraries are coming soon. ## Get started @@ -29,13 +30,26 @@ Install the Azure Resources management packages for .NET with [NuGet](https://ww For example: +# [PowerShell](#tab/PowerShell) + ```PowerShell -Install-Package Azure.ResourceManager -Version 1.0.0-beta.5 -Install-Package Azure.ResourceManager.Compute -Version 1.0.0-beta.3 -Install-Package Azure.ResourceManager.Network -Version 1.0.0-beta.3 -Install-Package Azure.ResourceManager.Resources -Version 1.0.0-beta.3 +Install-Package Azure.ResourceManager -Version 1.0.0 +Install-Package Azure.ResourceManager.Resources -Version 1.0.0 +Install-Package Azure.ResourceManager.Compute -Version 1.0.0-beta.8 +Install-Package Azure.ResourceManager.Network -Version 1.0.0-beta.7 ``` +# [.NET CLI](#tab/dotnetcli) + +```dotnetcli +dotnet add package Azure.ResourceManager +dotnet add package Azure.ResourceManager.Resources +dotnet add package Azure.ResourceManager.Compute --prerelease +dotnet add package Azure.ResourceManager.Network --prerelease +``` + +--- + ### Prerequisites Set up a way to authenticate to Azure with Azure Identity. Some options are: @@ -65,21 +79,18 @@ var armClient = new ArmClient(new DefaultAzureCredential()); For more information about the `Azure.Identity.DefaultAzureCredential` class, see [DefaultAzureCredential Class](/dotnet/api/azure.identity.defaultazurecredential). ----- - ## Key concepts ### Understanding Azure Resource Hierarchy -To reduce both the number of clients needed to perform common tasks and the amount of redundant parameters that each of those clients take, we have introduced an object hierarchy in the SDK that mimics the object hierarchy in Azure. Each resource client in the SDK has methods to access the resource clients of its children that is already scoped to the proper subscription and resource group. +To reduce the number of clients needed to perform common tasks and the number of redundant parameters that each of those clients take, we've introduced an object hierarchy in the SDK that mimics the object hierarchy in Azure. Each resource client in the SDK has methods to access the resource clients of its children that are already scoped to the proper subscription and resource group. -To accomplish this, we're introducing 3 standard types for all resources in Azure: +To accomplish this, we're introducing three standard types for all resources in Azure: #### **[Resource].cs** -This represents a full resource client object which contains a **Data** property exposing the details as a **[Resource]Data** type. -It also has access to all of the operations on that resource without needing to pass in scope parameters such as subscription ID or resource name. This makes it very convenient to directly execute operations on the result of list calls -since everything is returned as a full resource client now. +This type represents a full resource client object that contains a **Data** property exposing the details as a **[Resource]Data** type. +It also has access to all of the operations on that resource without needing to pass in scope parameters such as subscription ID or resource name. This makes it convenient to directly execute operations on the result of list calls, since everything is returned as a full resource client now. ```csharp ArmClient armClient = new ArmClient(new DefaultAzureCredential()); @@ -96,11 +107,11 @@ await foreach (VirtualMachine vm in rg.GetVirtualMachines().GetAllAsync()) #### **[Resource]Data.cs** -This represents the model that makes up a given resource. Typically, this is the response data from a service call such as HTTP GET and provides details about the underlying resource. Previously, this was represented by a **Model** class. +This type represents the model that makes up a given resource. Typically, this is the response data from a service call such as HTTP GET and provides details about the underlying resource. Previously, this was represented by a **Model** class. #### **[Resource]Collection.cs** -This represents the operations you can perform on a collection of resources belonging to a specific parent resource. +This type represents the operations you can perform on a collection of resources belonging to a specific parent resource. This object provides most of the logical collection operations. | Collection Behavior | Collection Method | @@ -108,10 +119,9 @@ This object provides most of the logical collection operations. | Iterate/List | GetAll() | | Index | Get(string name) | | Add | CreateOrUpdate(string name, [Resource]Data data) | -| Contains | CheckIfExists(string name) | -| TryGet | GetIfExists(string name) | +| Contains | Exists(string name) | -For most things, the parent will be a **ResourceGroup**. However, each parent / child relationship is represented this way. For example, a **Subnet** is a child of a **VirtualNetwork** and a **ResourceGroup** is a child of a **Subscription**. +For most things, the parent will be a **ResourceGroup**. However, each parent-child relationship is represented this way. For example, a **Subnet** is a child of a **VirtualNetwork** and a **ResourceGroup** is a child of a **Subscription**. ### Putting it all together @@ -145,7 +155,7 @@ await foreach(VirtualMachine vm in vmCollection.GetAllAsync()) #### Structured Resource Identifier -Resource IDs contain useful information about the resource itself, but they are plain strings that have to be parsed. Instead of implementing your own parsing logic, you can use a `ResourceIdentifier` object which will do the parsing for you: `new ResourceIdentifier("myid");`. +Resource IDs contain useful information about the resource itself, but they're plain strings that have to be parsed. Instead of implementing your own parsing logic, you can use a `ResourceIdentifier` object that will do the parsing for you: `new ResourceIdentifier("myid");`. #### Example: Parsing an ID using a ResourceIdentifier object @@ -158,7 +168,7 @@ Console.WriteLine($"Vnet: {id.Parent.Name}"); Console.WriteLine($"Subnet: {id.Name}"); ``` -However, keep in mind that some of those properties could be null. You can usually tell by the id string itself which type a resource ID is, but if you are unsure, check if the properties are null or use the Try methods to retrieve the values as it's shown below: +However, keep in mind that some of those properties could be null. You can usually tell by the ID string itself which type a resource ID is. But if you're unsure, check if the properties are null, or use the `Try` methods to retrieve the values, as shown in the following example. #### Example: ResourceIdentifier TryGet methods @@ -177,11 +187,11 @@ Console.WriteLine($"Vnet: {id.Parent.Name}"); Console.WriteLine($"Subnet: {id.Name}"); ``` -### Managing Existing Resources By Id +### Managing Existing Resources By ID -Performing operations on resources that already exist is a common use case when using the management client libraries. In this scenario you usually have the identifier of the resource you want to work on as a string. Although the new object hierarchy is great for provisioning and working within the scope of a given parent, it is not the most efficient when it comes to this specific scenario. +Performing operations on resources that already exist is a common use case when using the management client libraries. In this scenario, you usually have the identifier of the resource you want to work on as a string. Although the new object hierarchy is great for provisioning and working within the scope of a given parent, it is not the most efficient when it comes to this specific scenario. -Here is an example how you to access an `AvailabilitySet` object and manage it directly with its id: +Here's an example how you to access an `AvailabilitySet` object and manage it directly with its ID: ```csharp using Azure.Identity; @@ -206,7 +216,7 @@ ResourceGroup resourceGroup = await subscription.GetResourceGroups().GetAsync(id AvailabilitySet availabilitySet = await resourceGroup.GetAvailabilitySets().GetAsync(id.Name); ``` -This approach required a lot of code and 3 API calls to Azure. The same can be done with less code and without any API calls by using extension methods that we have provided on the client itself. These extension methods allow you to pass in a resource identifier and retrieve a scoped resource client. The object returned is a *[Resource]* mentioned above, since it has not reached out to Azure to retrieve the data yet the Data property will be null. +This approach required a lot of code and three API calls to Azure. The same can be done with less code and without any API calls by using extension methods that we've provided on the client itself. These extension methods allow you to pass in a resource identifier and retrieve a scoped resource client. The object returned is a [Resource](#resourcecs). Since it hasn't reached out to Azure to retrieve the data yet, the `Data` property will be null. So, the previous example would end up looking like this: @@ -226,11 +236,11 @@ Console.WriteLine(availabilitySet.Data.Name); ### Check if a [Resource] exists -If you are not sure if a resource you want to get exists, or you just want to check if it exists, you can use `GetIfExists()` or `CheckIfExists()` methods, which can be invoked from any [Resource]Collection class. +If you aren't sure if a resource you want to get exists, or you just want to check if it exists, you can use `Exists()` or `ExistsAsync()` methods, which can be invoked from any [Resource]Collection class. -`GetIfExists()` and `GetIfExistsAsync()` return a `Response` where T is null if the specified resource does not exist. On the other hand, `CheckIfExists()` and `CheckIfExistsAsync()` return `Response` where the bool will be false if the specified resource does not exist. Both of these methods still give you access to the underlying raw response. +`Exists()` returns a `Response` while `ExistsAsync()` as its async version returns a `Task>`, in the `Reponse` object, you can visit its `Value` property to check if a [Resource] exists. The `Value` is `false` if the resource does not exist and vice versa. -In previous versions of packages, you would have to catch the `RequestFailedException` and inspect the status code for 404. With this new API, we hope that this can boost the developer productivity and optimize resource access. . +In previous versions of packages, you would have to catch the `RequestFailedException` and inspect the status code for 404. With this new API, we hope that this can boost the developer productivity and optimize resource access. ```csharp ArmClient armClient = new ArmClient(new DefaultAzureCredential()); @@ -248,14 +258,14 @@ catch (RequestFailedException ex) when (ex.Status == 404) } ``` -Now with these convenience methods we can simply do the following. +Now with these convenience methods, we can simply do the following. ```csharp ArmClient armClient = new ArmClient(new DefaultAzureCredential()); Subscription subscription = await armClient.GetDefaultSubscriptionAsync(); string rgName = "myRgName"; -bool exists = await subscription.GetResourceGroups().CheckIfExistsAsync(rgName); +bool exists = await subscription.GetResourceGroups().Exists(rgName).Value; if (exists) { @@ -271,27 +281,6 @@ else } ``` -Another way to do this is by using `GetIfExists()` which will avoid the race condition mentioned above: - -```csharp -ArmClient armClient = new ArmClient(new DefaultAzureCredential()); -Subscription subscription = await armClient.GetDefaultSubscriptionAsync(); -string rgName = "myRgName"; - -ResourceGroup myRG = await subscription.GetResourceGroups().GetIfExistsAsync(rgName); - -if (myRG == null) -{ - Console.WriteLine($"Resource Group {rgName} does not exist."); -} -else -{ - // At this point, we are sure that myRG is a not null Resource Group, so we can use this object to perform any operations we want. -} -``` - ----- - ## Examples ### Create a resource group @@ -348,15 +337,11 @@ await resourceGroup.DeleteAsync(); For more detailed examples, take a look at [samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/resourcemanager/Azure.ResourceManager/samples) we have available. ----- - ## Troubleshooting - If you have a bug to report or have a suggestion, file an issue via [GitHub issues](https://github.com/Azure/azure-sdk-for-net/issues) and make sure you add the "Preview" label to the issue. -- If you need help, check [previous - questions](https://stackoverflow.com/questions/tagged/azure+.net) - or ask new ones on StackOverflow using azure and .NET tags. -- If having trouble with authentication, go to [DefaultAzureCredential documentation](/dotnet/api/azure.identity.defaultazurecredential). +- If you need help, check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net), or ask new ones on StackOverflow using Azure and .NET tags. +- If having trouble with authentication, see the [DefaultAzureCredential documentation](/dotnet/api/azure.identity.defaultazurecredential). ## Next steps @@ -368,6 +353,6 @@ For more detailed examples, take a look at [samples](https://github.com/Azure/az ### Additional Documentation -If you are migrating from the old SDK to this preview, check out this [Migration guide](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/MigrationGuide.md). +If you're migrating from the old SDK to this preview, check out this [Migration guide](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/MigrationGuide.md). -For more information on Azure SDK, please refer to [this website](https://azure.github.io/azure-sdk/). +For more information on Azure SDK, see [Azure SDK Releases](https://azure.github.io/azure-sdk/). diff --git a/docs/core/additional-tools/dotnet-coverage.md b/docs/core/additional-tools/dotnet-coverage.md index ac409ad97e19f..615e52b804cc1 100644 --- a/docs/core/additional-tools/dotnet-coverage.md +++ b/docs/core/additional-tools/dotnet-coverage.md @@ -18,7 +18,7 @@ dotnet-coverage [-h, --help] [--version] The `dotnet-coverage` tool: -* Enables the collection of code coverage data of a running process on Windows and Linux x64. +* Enables the collection of code coverage data of a running process on Windows (x86, x64 and arm64), Linux (x64) and macOS (x64). * Provides cross-platform merging of code coverage reports. ## Options @@ -60,10 +60,10 @@ The `merge` command is used to merge several code coverage reports into one. Thi ### Synopsis ```console -dotnet-coverage merge +dotnet-coverage merge [--remove-input-files] [-r|--recursive] [-o|--output ] [-f|--output-format ] - [-l|--log-file ] [-ll|--log-level ] [-?|-h|--help] + [-l|--log-file ] [-ll|--log-level ] [-?|-h|--help] ``` @@ -101,7 +101,7 @@ dotnet-coverage merge ## dotnet-coverage collect -The `collect` command is used to collect code coverage data for any .NET process and its subprocesses. For example, you can collect code coverage data for a console application or a Blazor application. This command is available on Windows (x86 and x64), Linux (x64), and macOS (x64). The command supports only .NET modules. Native modules are not supported. +The `collect` command is used to collect code coverage data for any .NET process and its subprocesses. For example, you can collect code coverage data for a console application or a Blazor application. This command is available on Windows (x86, x64 and arm64), Linux (x64), and macOS (x64). The command supports only .NET modules. Native modules are not supported. ### Synopsis @@ -112,7 +112,7 @@ The `collect` command can run in two modes. The `collect` command will collect code coverage for the given process executed by the `command` argument. ```console -dotnet-coverage collect +dotnet-coverage collect [-s|--settings ] [-id|--session-id ] [-o|--output ] [-f|--output-format ] [-l|--log-file ] [-ll|--log-level ] [-?|-h|--help] @@ -124,7 +124,7 @@ dotnet-coverage collect The `collect` command hosts a server for code coverage collection. Clients can connect to the server via `connect` command. ```console -dotnet-coverage collect +dotnet-coverage collect [-s|--settings ] [-id|--session-id ] [-sv|--server-mode] [-b|--background] [-t|--timeout] [-o|--output ] [-f|--output-format ] @@ -181,12 +181,12 @@ dotnet-coverage collect ## dotnet-coverage connect -The `connect` command is used to connect with the existing server and collects code coverage data for any .NET process and its subprocesses. For example, you can collect code coverage data for a console application or a Blazor application. This command is available on Windows (x86 and x64), Linux (x64), and macOS (x64). The command supports only .NET modules. Native modules are not supported. +The `connect` command is used to connect with the existing server and collects code coverage data for any .NET process and its subprocesses. For example, you can collect code coverage data for a console application or a Blazor application. This command is available on Windows (x86, x64 and arm64), Linux (x64), and macOS (x64). The command supports only .NET modules. Native modules are not supported. ### Synopsis ```console -dotnet-coverage connect +dotnet-coverage connect [-b|--background] [-t|--timeout] [-l|--log-file ] [-ll|--log-level ] [-?|-h|--help] diff --git a/docs/core/compatibility/5.0.md b/docs/core/compatibility/5.0.md index 515402e5c8b01..6a423d8aef0bd 100644 --- a/docs/core/compatibility/5.0.md +++ b/docs/core/compatibility/5.0.md @@ -7,6 +7,8 @@ ms.date: 12/14/2020 If you're migrating an app to .NET 5, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or cryptography. +[!INCLUDE [binary-source-compat](includes/binary-source-compat.md)] + ## ASP.NET Core | Title | Binary compatible | Source compatible | diff --git a/docs/core/compatibility/6.0.md b/docs/core/compatibility/6.0.md index cdb68943db515..7fba17ffc5867 100644 --- a/docs/core/compatibility/6.0.md +++ b/docs/core/compatibility/6.0.md @@ -8,6 +8,8 @@ no-loc: [Blazor, Razor, Kestrel] If you're migrating an app to .NET 6, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms. +[!INCLUDE [binary-source-compat](includes/binary-source-compat.md)] + > [!NOTE] > > This article is a work-in-progress. It's not a complete list of breaking changes in .NET 6. To query breaking changes that are still pending publication, see [Issues of .NET](https://issuesof.net/?q=%20is:open%20-label:Documented%20is:issue%20(label:%22Breaking%20Change%22%20or%20label:breaking-change)%20(repo:dotnet%2Fdocs%20or%20repo:aspnet%2FAnnouncements)%20group:repo%20(label:%22:checkered_flag:%20Release:%20.NET%206%22%20or%20label:6.0.0)%20sort:created-desc). @@ -16,6 +18,7 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff | Title | Binary compatible | Source compatible | Introduced | | - | :-: | :-: | - | +| [ActionResult\ sets StatusCode to 200](aspnet-core/6.0/actionresult-statuscode.md) | ✔️ | ❌ | | | [AddDataAnnotationsValidation method made obsolete](aspnet-core/6.0/adddataannotationsvalidation-obsolete.md) | ✔️ | ❌ | | | [Assemblies removed from Microsoft.AspNetCore.App shared framework](aspnet-core/6.0/assemblies-removed-from-shared-framework.md) | ❌ | ✔️ | | | [Blazor: Parameter name changed in RequestImageFileAsync method](aspnet-core/6.0/blazor-parameter-name-changed-in-method.md) | ✔️ | ❌ | Preview 1 | @@ -41,6 +44,14 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff | [SignalR: Java Client updated to RxJava3](aspnet-core/6.0/signalr-java-client-updated.md) | ❌ | ✔️ | Preview 4 | | [TryParse and BindAsync methods are validated](aspnet-core/6.0/tryparse-bindasync-validation.md) | ❌ | ❌ | RC 2 | +## Containers + +| Title | Binary compatible | Source compatible | Introduced | +| - | :-: | :-: | - | +| [Default console logger formatting in container images](containers/6.0/console-formatter-default.md) | ✔️ | ❌ | Servicing 6.0.6 | + +For information on other breaking changes for containers in .NET 6, see [.NET 6 Container Release Notes](https://github.com/dotnet/dotnet-docker/discussions/3699). + ## Core .NET libraries | Title | Binary compatible | Source compatible | Introduced | @@ -64,6 +75,7 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff | [Standard numeric format parsing precision](core-libraries/6.0/numeric-format-parsing-handles-higher-precision.md) | ✔️ | ❌ | Preview 2 | | [Static abstract members in interfaces](core-libraries/6.0/static-abstract-interface-methods.md) | ❌ | ✔️ | Preview 7 | | [StringBuilder.Append overloads and evaluation order](core-libraries/6.0/stringbuilder-append-evaluation-order.md) | ❌ | ✔️ | RC 1 | +| [Strong-name APIs throw PlatformNotSupportedException](core-libraries/6.0/strong-name-signing-exceptions.md) | ❌ | ✔️ | Preview 4 | | [System.Drawing.Common only supported on Windows](core-libraries/6.0/system-drawing-common-windows-only.md) | ❌ | ❌ | Preview 7 | | [System.Security.SecurityContext is marked obsolete](core-libraries/6.0/securitycontext-obsolete.md) | ✔️ | ❌ | RC 1 | | [Task.FromResult may return singleton](core-libraries/6.0/task-fromresult-returns-singleton.md) | ❌ | ✔️ | Preview 1 | @@ -128,6 +140,7 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff | [MSBuild no longer supports calling GetType()](sdk/6.0/calling-gettype-property-functions.md) | | | RC 1 | | [OutputType not automatically set to WinExe](sdk/6.0/outputtype-not-set-automatically.md) | ✔️ | ❌ | RC 1 | | [Publish ReadyToRun with --no-restore requires changes](sdk/6.0/publish-readytorun-requires-restore-change.md) | ✔️ | ❌ | 6.0.100 | +| [runtimeconfig.dev.json file not generated](sdk/6.0/runtimeconfigdev-file.md) | ❌ | ✔️ | 6.0.100 | | [RuntimeIdentifier warning if self-contained is unspecified](sdk/6.0/runtimeidentifier-self-contained.md) | ✔️ | ❌ | RC 1 | | [Version requirements for .NET 6 SDK](sdk/6.0/vs-msbuild-version.md) | ✔️ | ✔️ | 6.0.300 | | [Write reference assemblies to IntermediateOutputPath](sdk/6.0/write-reference-assemblies-to-obj.md) | ❌ | ✔️ | 6.0.200 | diff --git a/docs/core/compatibility/7.0.md b/docs/core/compatibility/7.0.md index ba718abb29915..b611ba1b410d6 100644 --- a/docs/core/compatibility/7.0.md +++ b/docs/core/compatibility/7.0.md @@ -8,6 +8,8 @@ no-loc: [Blazor, Razor, Kestrel] If you're migrating an app to .NET 7, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms. +[!INCLUDE [binary-source-compat](includes/binary-source-compat.md)] + > [!NOTE] > > This article is a work in progress. It's not a complete list of breaking changes in .NET 7. To query breaking changes that are still pending publication, see [Issues of .NET](https://issuesof.net/?q=%20is:open%20-label:Documented%20is:issue%20(label:%22Breaking%20Change%22%20or%20label:breaking-change)%20(repo:dotnet%2Fdocs%20or%20repo:aspnet%2FAnnouncements)%20group:repo%20(label:%22:checkered_flag:%20Release:%20.NET%207%22%20or%20label:7.0.0)%20sort:created-desc). @@ -29,11 +31,26 @@ If you're migrating an app to .NET 7, the breaking changes listed here might aff | - | :-: | :-: | - | | [API obsoletions with non-default diagnostic IDs](core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md) | ✔️ | ❌ | Preview 1 | | [C++/CLI projects in Visual Studio](core-libraries/7.0/cpluspluscli-compiler-version.md) +| [Collectible Assembly in non-collectible AssemblyLoadContext](core-libraries/7.0/collectible-assemblies.md) | ❌ | ✔️ | Preview 5 | +| [Equals method behavior change for NaN](core-libraries/7.0/equals-nan.md) | ❌ | ✔️ | Preview 5 | | [FullPath and OldFullPath return fully qualified path](core-libraries/7.0/filesystemeventargs-fullpath.md) | ✔️ | ❌ | Preview 1 | | [Generic type constraint on PatternContext\](core-libraries/7.0/patterncontext-generic-constraint.md) | ❌ | ❌ | Preview 3 | | [SerializationFormat.Binary is obsolete](core-libraries/7.0/serializationformat-binary.md) | ❌ | ❌ | Preview 2 | | [Validate CompressionLevel for BrotliStream](core-libraries/7.0/compressionlevel-validation.md) | ❌ | ✔️ | Preview 1 | +## Cryptography + +| Title | Binary compatible | Source compatible | Introduced | +| - | :-: | :-: | - | +| [Decrypting EnvelopedCms doesn't double unwrap](cryptography/7.0/decrypt-envelopedcms.md) | ❌ | ✔️ | Preview 5 | +| [X500DistinguishedName parsing of friendly names](cryptography/7.0/x500-distinguished-names.md) | ❌ | ✔️ | Preview 5 | + +## Deployment + +| Title | Binary compatible | Source compatible | Introduced | +| - | :-: | :-: | - | +| [Multi-level lookup is disabled](deployment/7.0/multilevel-lookup.md) | ❌ | ✔️ | Preview 4 | + ## Networking | Title | Binary compatible | Source compatible | Introduced | @@ -41,11 +58,12 @@ If you're migrating an app to .NET 7, the breaking changes listed here might aff | [AllowRenegotiation default is false](networking/7.0/allowrenegotiation-default.md) | ❌ | ❌ | Preview 3 | | [Custom ping payloads on Linux](networking/7.0/ping-custom-payload-linux.md) | ❌ | ✔️ | Preview 2 | -## SDK +## SDK and MSBuild | Title | Binary compatible | Source compatible | Introduced | | - | :-: | :-: | - | | [Version requirements for .NET 7 SDK](sdk/7.0/vs-msbuild-version.md) | ✔️ | ✔️ | 7.0.100 | +| [MSBuild serialization of custom types in .NET 7](sdk/7.0/custom-serialization.md) | ❌ | ❌ | 7.0.100 | ## Serialization diff --git a/docs/core/compatibility/aspnet-core/6.0/actionresult-statuscode.md b/docs/core/compatibility/aspnet-core/6.0/actionresult-statuscode.md new file mode 100644 index 0000000000000..ccee9820545d1 --- /dev/null +++ b/docs/core/compatibility/aspnet-core/6.0/actionresult-statuscode.md @@ -0,0 +1,92 @@ +--- +title: "Breaking change: ActionResult sets StatusCode to 200" +description: "Learn about the breaking change in ASP.NET Core 6.0 where ActionResult always sets the status code to 200, even if it was set manually." +ms.date: 05/23/2022 +--- +# ActionResult\ sets StatusCode to 200 + +When returning a `T` in an MVC/API controller action that declares the return type as , the is always set to 200, except when the `T` is a . + +This change can cause unexpected behavior in some scenarios where you set the status code manually, since previously the was `null`. Also, an action filter could be affected by this change if it expects a null value instead of 200. + +## Version introduced + +ASP.NET Core 6.0 + +## Previous behavior + +Previously, a controller's action that returns `T` and sets `Response.StatusCode` manually generated the specified response status code. For example, the following controller's action will generate a `202 Accepted` response. + +```csharp +// Generates a 202 Accepted response +public ActionResult Get() +{ + Response.StatusCode = StatusCodes.Status202Accepted; + return new Model(); +} +``` + +## New behavior + +Now, the same controller's action that returns `T` and sets `Response.StatusCode` manually always generates a `200 OK` response. + +```csharp +// Generates a 200 OK response +public ActionResult Get() +{ + Response.StatusCode = StatusCodes.Status202Accepted; + return new Model(); +} +``` + +## Type of breaking change + +This change can affect [source compatibility](../../categories.md#source-compatibility). + +## Reason for change + +Returning a status code of `200 OK` is [documented since ASP.NET Core 3.1](/aspnet/core/web-api/action-return-types#actionresultt-type). However, it keeps as `null` and eventually generates a `200 OK` response only because it's the default. Since the default internal behavior could change, we decided to avoid relying on the default and to explicitly set to the expected `200 OK`. + +## Recommended action + +If your code sets the status code manually and is broken by this change, you'll need to change your controller action. For example, the following code snippet sets a status code of 202 and is broken by this change. + +```csharp +public ActionResult Get() +{ + Response.StatusCode = StatusCodes.Status202Accepted; + return new Model(); +} +``` + +To retain the desired behavior of a 202 status code, the following code snippets show some options. + +```csharp +public ActionResult Get() +{ + return Accepted(new Model()); +} + +// or + +public ActionResult Get() +{ + return StatusCode(StatusCodes.Status202Accepted, new Model()); +} + +// or + +public Model Get() +{ + Response.StatusCode = StatusCodes.Status202Accepted; + return new Model(); +} +``` + +## Affected APIs + +- MVC/API controller actions + +## See also + +- [ActionResult\ type](/aspnet/core/web-api/action-return-types#actionresultt-type) diff --git a/docs/core/compatibility/aspnet-core/6.0/rc1-minimal-api-renames.md b/docs/core/compatibility/aspnet-core/6.0/rc1-minimal-api-renames.md index d08224435fc84..f0a2f70ee3a76 100644 --- a/docs/core/compatibility/aspnet-core/6.0/rc1-minimal-api-renames.md +++ b/docs/core/compatibility/aspnet-core/6.0/rc1-minimal-api-renames.md @@ -5,7 +5,7 @@ ms.date: 10/25/2021 --- # Minimal API renames in RC 1 -Some APIS were renamed to improve the consistency of type names and to remove "minimal" and "action" from the API names. +Some APIs were renamed to improve the consistency of type names and to remove "minimal" and "action" from the API names. ## Version introduced diff --git a/docs/core/compatibility/aspnet-core/7.0/mvc-empty-body-model-binding.md b/docs/core/compatibility/aspnet-core/7.0/mvc-empty-body-model-binding.md index 3d5bb0cb399e1..8fd3e88f666e3 100644 --- a/docs/core/compatibility/aspnet-core/7.0/mvc-empty-body-model-binding.md +++ b/docs/core/compatibility/aspnet-core/7.0/mvc-empty-body-model-binding.md @@ -28,8 +28,8 @@ ASP.NET Core 7.0 Preview 3 If a controller action binds a parameter from the request body and the client request doesn't include a `Content-Length` request header, the framework throws an internal exception during deserialization of the request body. For example, the `System.Text.Json`-based input formatter throws an exception similar to the following: ``` -System.Text.Json.JsonException: 'The input does not contain any JSON tokens. -Expected the input to start with a valid JSON token, when isFinalBlock is true. +System.Text.Json.JsonException: 'The input does not contain any JSON tokens. +Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.' ``` diff --git a/docs/core/compatibility/categories.md b/docs/core/compatibility/categories.md index c54652b1771a7..de0ac94e749e1 100644 --- a/docs/core/compatibility/categories.md +++ b/docs/core/compatibility/categories.md @@ -23,7 +23,7 @@ When behavioral changes are externally visible and modify a type's public contra ## Binary compatibility -Binary compatibility refers to the ability of a consumer of an API to use the API on a newer version without recompilation. Such changes as adding methods or adding a new interface implementation to a type do not affect binary compatibility. However, removing or altering an assembly's public signatures so that consumers can no longer access the same interface exposed by the assembly does affect binary compatibility. A change of this kind is termed a *binary incompatible change*. +Binary compatibility refers to the ability of a consumer of an API to use the API on a newer version without recompilation. Changes such as adding methods or adding a new interface implementation to a type do not affect binary compatibility. However, removing or altering an assembly's public signatures so that consumers can no longer access the same interface exposed by the assembly does affect binary compatibility. A change of this kind is termed a *binary incompatible change*. ## Source compatibility diff --git a/docs/core/compatibility/code-analysis/5.0/ca1416-platform-compatibility-analyzer.md b/docs/core/compatibility/code-analysis/5.0/ca1416-platform-compatibility-analyzer.md index 1694a4ca8dc3c..967ff6488f303 100644 --- a/docs/core/compatibility/code-analysis/5.0/ca1416-platform-compatibility-analyzer.md +++ b/docs/core/compatibility/code-analysis/5.0/ca1416-platform-compatibility-analyzer.md @@ -88,7 +88,7 @@ public void PlayCMajor() If you don't want to fix all your call sites, you can choose one of the following options to suppress the warning: -- To suppress rule CA1416, you can do so using `#pragma` or the [**DisabledWarnings**](../../../../csharp/language-reference/compiler-options/errors-warnings.md#disabledwarnings) compiler flag, or by [setting the rule's severity](../../../../fundamentals/code-analysis/configuration-options.md#severity-level) to `none` in an .editorconfig file. +- To suppress rule CA1416, you can do so using `#pragma` or the [**NoWarn**](../../../../csharp/language-reference/compiler-options/errors-warnings.md#nowarn) compiler flag, or by [setting the rule's severity](../../../../fundamentals/code-analysis/configuration-options.md#severity-level) to `none` in an .editorconfig file. ```csharp public void PlayCMajor() diff --git a/docs/core/compatibility/containers/6.0/console-formatter-default.md b/docs/core/compatibility/containers/6.0/console-formatter-default.md new file mode 100644 index 0000000000000..2069c8a815cb3 --- /dev/null +++ b/docs/core/compatibility/containers/6.0/console-formatter-default.md @@ -0,0 +1,66 @@ +--- +title: ".NET 6 breaking change: Default console logger formatting in container images" +description: Learn about the .NET 6 breaking change in .NET containers where the default formatting for the console logger in aspnet container images is no longer JSON. +ms.date: 05/02/2022 +--- +# Default console logger formatting in container images + +The default console formatter that's configured in `aspnet` containers has changed. + +## Previous behavior + +In previous servicing releases of .NET 6, `aspnet` container images were configured with the `Logging__Console__FormatterName` environment variable set to `Json`. This resulted in console output formatted similarly to the following: + +```txt +{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7000/","State":{"Message":"Now listening on: http://localhost:7000/","address":"http://localhost:7000/","{OriginalFormat}":"Now listening on: {address}"}} +{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7001/","State":{"Message":"Now listening on: http://localhost:7001/","address":"http://localhost:7001/","{OriginalFormat}":"Now listening on: {address}"}} +{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7002/","State":{"Message":"Now listening on: http://localhost:7002/","address":"http://localhost:7002/","{OriginalFormat}":"Now listening on: {address}"}} +{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Application started. Press Ctrl\u002BC to shut down.","State":{"Message":"Application started. Press Ctrl\u002BC to shut down.","{OriginalFormat}":"Application started. Press Ctrl\u002BC to shut down."}} +{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Hosting environment: Development","State":{"Message":"Hosting environment: Development","envName":"Development","{OriginalFormat}":"Hosting environment: {envName}"}} +{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Content root path: C:\\source\\temp\\web50","State":{"Message":"Content root path: C:\\source\\temp\\web50","contentRoot":"C:\\source\\temp\\web50","{OriginalFormat}":"Content root path: {contentRoot}"}} +``` + +## New behavior + +Starting in .NET 6.0.6, `aspnet` container images have the `Logging__Console__FormatterName` environment variable unset by default. This results in simple, multiline, human-readable console output similar to the following: + +```txt +warn: Microsoft.AspNetCore.Server.HttpSys.MessagePump[37] + Overriding address(es) ''. Binding to endpoints added to UrlPrefixes instead. +info: Microsoft.Hosting.Lifetime[0] + Now listening on: http://localhost:7000/ +info: Microsoft.Hosting.Lifetime[0] + Now listening on: http://localhost:7001/ +info: Microsoft.Hosting.Lifetime[0] + Now listening on: http://localhost:7002/ +info: Microsoft.Hosting.Lifetime[0] + Application started. Press Ctrl+C to shut down. +info: Microsoft.Hosting.Lifetime[0] + Hosting environment: Development +info: Microsoft.Hosting.Lifetime[0] + Content root path: C:\source\temp\web50 +``` + +## Version introduced + +.NET 6.0.6 (May 2022 servicing) + +## Type of breaking change + +This change can affect [source compatibility](../../categories.md#source-compatibility). + +## Reason for change + +When the change to use JSON formatting was introduced in the .NET 6 GA release, it broke many scenarios that relied on the original, simple formatting as described in [dotnet/dotnet-docker#2725](https://github.com/dotnet/dotnet-docker#2725). + +## Recommended action + +If you want to continue using the JSON formatting, you can configure your container to use it by setting the `Logging__Console__FormatterName` environment variable value to `Json`. + +## Affected APIs + +None. + +## See also + +- [dotnet/dotnet-docker#3706](https://github.com/dotnet/dotnet-docker#3706) diff --git a/docs/core/compatibility/core-libraries/5.0/obsolete-apis-with-custom-diagnostics.md b/docs/core/compatibility/core-libraries/5.0/obsolete-apis-with-custom-diagnostics.md index 5728cceb40edd..300374d21bed5 100644 --- a/docs/core/compatibility/core-libraries/5.0/obsolete-apis-with-custom-diagnostics.md +++ b/docs/core/compatibility/core-libraries/5.0/obsolete-apis-with-custom-diagnostics.md @@ -10,7 +10,7 @@ Some APIs have been marked as obsolete, starting in .NET 5. This breaking change ## Change description -In previous .NET versions, these APIs can be used without any build warning. In .NET 5 and later versions, use of these APIS produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings. +In previous .NET versions, these APIs can be used without any build warning. In .NET 5 and later versions, use of these APIs produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings. The following table lists the custom diagnostic IDs and their corresponding warning messages for obsoleted APIs. diff --git a/docs/core/compatibility/core-libraries/5.0/thread-abort-obsolete.md b/docs/core/compatibility/core-libraries/5.0/thread-abort-obsolete.md index 421efccb23ae1..8117a9932a1cf 100644 --- a/docs/core/compatibility/core-libraries/5.0/thread-abort-obsolete.md +++ b/docs/core/compatibility/core-libraries/5.0/thread-abort-obsolete.md @@ -17,6 +17,8 @@ Starting in .NET 5, always throws a on all .NET implementations except .NET Framework, was added to the method to draw attention to places where it's called. +When you call to abort a thread other than the current thread, you don't know what code has executed or failed to execute when the is thrown. You also cannot be certain of the state of your application or any application and user state that it's responsible for preserving. For example, calling may prevent the execution of static constructors or the release of managed or unmanaged resources. For this reason, always throws a on .NET Core and .NET 5+. + ## Version introduced 5.0 @@ -67,15 +69,3 @@ Given that ## Affected APIs - - - diff --git a/docs/core/compatibility/core-libraries/6.0/file-replace-exceptions-on-unix.md b/docs/core/compatibility/core-libraries/6.0/file-replace-exceptions-on-unix.md index 2746260126002..27f60a37d24c0 100644 --- a/docs/core/compatibility/core-libraries/6.0/file-replace-exceptions-on-unix.md +++ b/docs/core/compatibility/core-libraries/6.0/file-replace-exceptions-on-unix.md @@ -7,7 +7,7 @@ ms.date: 10/13/2021 The behavior of on Unix-based operating systems has changed. The exceptions it throws now match those that are thrown by the Windows implementation. -## Previous Behavior +## Previous behavior On Unix, with .NET 5, the method: diff --git a/docs/core/compatibility/core-libraries/6.0/filestream-doesnt-sync-offset-with-os.md b/docs/core/compatibility/core-libraries/6.0/filestream-doesnt-sync-offset-with-os.md index 2c88d6ffd0578..0cae35e0af32f 100644 --- a/docs/core/compatibility/core-libraries/6.0/filestream-doesnt-sync-offset-with-os.md +++ b/docs/core/compatibility/core-libraries/6.0/filestream-doesnt-sync-offset-with-os.md @@ -80,7 +80,7 @@ None. - Core .NET libraries -### Affected APIS +### Affected APIs Not detectible via API analysis. diff --git a/docs/core/compatibility/core-libraries/6.0/hosting-exception-handling.md b/docs/core/compatibility/core-libraries/6.0/hosting-exception-handling.md index a40b225751149..1fc7b5d692937 100644 --- a/docs/core/compatibility/core-libraries/6.0/hosting-exception-handling.md +++ b/docs/core/compatibility/core-libraries/6.0/hosting-exception-handling.md @@ -1,7 +1,7 @@ --- title: ".NET 6 breaking change: Exception handling in hosting" description: Learn about the .NET 6 breaking change in core .NET libraries where unhandled exceptions from a BackgroundService are logged instead of lost. -ms.date: 04/23/2021 +ms.date: 05/06/2022 --- # Unhandled exceptions from a BackgroundService @@ -23,7 +23,7 @@ The new behavior is consistent with the way other app models behave when unhandl ## Recommended action -If you prefer to keep the previous behavior of allowing an unhandled exception in a to not stop the Host, you can set `HostOptions.BackgroundServiceExceptionBehavior` to `BackgroundServiceExceptionBehavior.Ignore`. +If you prefer to keep the previous behavior of allowing an unhandled exception in a to not stop the Host, you can set to . ```csharp Host.CreateBuilder(args) diff --git a/docs/core/compatibility/core-libraries/6.0/obsolete-apis-with-custom-diagnostics.md b/docs/core/compatibility/core-libraries/6.0/obsolete-apis-with-custom-diagnostics.md index 4083f59d044d5..dd1ea8c221bb3 100644 --- a/docs/core/compatibility/core-libraries/6.0/obsolete-apis-with-custom-diagnostics.md +++ b/docs/core/compatibility/core-libraries/6.0/obsolete-apis-with-custom-diagnostics.md @@ -10,7 +10,7 @@ Some APIs have been marked as obsolete, starting in .NET 6. This breaking change ## Change description -In previous .NET versions, these APIs can be used without any build warning. In .NET 6 and later versions, use of these APIS produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings. +In previous .NET versions, these APIs can be used without any build warning. In .NET 6 and later versions, use of these APIs produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings. The following table lists the custom diagnostic IDs and their corresponding warning messages for obsoleted APIs. diff --git a/docs/core/compatibility/core-libraries/6.0/strong-name-signing-exceptions.md b/docs/core/compatibility/core-libraries/6.0/strong-name-signing-exceptions.md new file mode 100644 index 0000000000000..5770a5778837c --- /dev/null +++ b/docs/core/compatibility/core-libraries/6.0/strong-name-signing-exceptions.md @@ -0,0 +1,38 @@ +--- +title: "Breaking change: Strong-name APIs throw PlatformNotSupportedException" +description: Learn about the .NET 6 breaking change in core .NET libraries where an exception is thrown in StrongNameKeyPair constructors and AssemblyName.KeyPair. +ms.date: 05/31/2022 +--- +# Strong-name APIs throw PlatformNotSupportedException + +A few [APIs](#affected-apis) that aren't supported in .NET/.NET Core but didn't do anything when accessed have been changed to now throw a at run time. Previously, using these APIs would eventually result in a run-time exception further along; the exception is now thrown when the type is instantiated or first accessed. + +## Previous behavior + +In previous versions, calling or was a no-op. Calling read the stream but otherwise did nothing. + +## New behavior + +Starting in .NET 6, each of the three affected APIs throws a at run time. + +## Version introduced + +.NET 6 + +## Type of breaking change + +This change can affect [binary compatibility](../../categories.md#binary-compatibility). + +## Reason for change + +Previously, an application that called the API compiled and ran, but as soon as the instance was used in any code path, it threw a run-time exception. To make it more explicit that this scenario is unsupported, the exception-throwing logic was moved into the instance constructor. In case no instances are created, the exception is also thrown in public entry points that return this type, that is, . + +## Recommended action + +Strong-name signing is not supported in .NET/.NET Core, and there is no workaround. + +## Affected APIs + +- +- +- diff --git a/docs/core/compatibility/core-libraries/7.0/collectible-assemblies.md b/docs/core/compatibility/core-libraries/7.0/collectible-assemblies.md new file mode 100644 index 0000000000000..4032de3ecbe4b --- /dev/null +++ b/docs/core/compatibility/core-libraries/7.0/collectible-assemblies.md @@ -0,0 +1,41 @@ +--- +title: ".NET 7 breaking change: Collectible Assembly in non-collectible AssemblyLoadContext" +description: Learn about the .NET 7 breaking change in core .NET libraries where resolving a collectible Assembly in a non-collectible AssemblyLoadContext results in a FileLoadException. +ms.date: 05/10/2022 +--- +# Collectible Assembly in non-collectible AssemblyLoadContext + +.NET incorrectly allowed garbage-collectible assemblies to resolve into a non-collectible . In some cases, this lead to runtime crashes or unexpected exceptions. This change prevents the incorrect behavior by throwing an exception when the or event returns a collectible and the is non-collectible. + +## Previous behavior + +Returning a collectible in the override or the event of a non-collectible doesn't cause any exceptions to be thrown. + +## New behavior + +Returning a collectible in the override or the event of a non-collectible throws a with a as the inner exception. + +## Version introduced + +.NET 7 Preview 5 + +## Type of breaking change + +This change can affect [binary compatibility](../../categories.md#binary-compatibility). + +## Reason for change + +This change fixes a bug. The collectible would be garbage-collected while the that has a reference to it is alive for the rest of the process lifetime. If the code running in that context references anything from that `Assembly` after it's collected, it would crash the runtime or result in a , , or other kinds of bad behavior. + +## Recommended action + +Don't return collectible assemblies in or the event of a non-collectible . A possible workaround is to change the `AssemblyLoadContext` to be collectible by passing `true` for the `isCollectible` parameter in its constructor, and then keep a reference to that `AssemblyLoadContext` forever to make sure it's never collected. + +## Affected APIs + +- +- event + +## See also + +- [Use collectible AssemblyLoadContext](../../../../standard/assembly/unloadability.md#use-collectible-assemblyloadcontext) diff --git a/docs/core/compatibility/core-libraries/7.0/compressionlevel-validation.md b/docs/core/compatibility/core-libraries/7.0/compressionlevel-validation.md index 7b3c7c9e70532..6b3da6675ce39 100644 --- a/docs/core/compatibility/core-libraries/7.0/compressionlevel-validation.md +++ b/docs/core/compatibility/core-libraries/7.0/compressionlevel-validation.md @@ -9,7 +9,7 @@ The argument that's passed to parameter was considered valid. The value would either map to the one of the enumeration's defined values or passed as-is to the underlying Brotli implementation. +Passing any value between 0 and 11 for the parameter was considered valid. The value would either map to one of the enumeration's defined values or be passed as-is to the underlying Brotli implementation. ## New behavior diff --git a/docs/core/compatibility/core-libraries/7.0/equals-nan.md b/docs/core/compatibility/core-libraries/7.0/equals-nan.md new file mode 100644 index 0000000000000..d8832aadcba6e --- /dev/null +++ b/docs/core/compatibility/core-libraries/7.0/equals-nan.md @@ -0,0 +1,108 @@ +--- +title: ".NET 7 breaking change: Equals method behavior change for NaN" +description: Learn about the .NET 7 breaking change in core .NET libraries where the behavior of some Equals(T other) instance methods changed for NaN values. +ms.date: 05/18/2022 +--- +# Equals method behavior change for NaN + +The `Equals(T other)` instance method for the following types was updated to meet the implementation requirements. As a result, the method now correctly handles NaN. This change ensures the types can correctly be used alongside `GetHashCode`, , and other hash sets. + +- +- +- +- +- +- +- +- +- +- +- + +## Previous behavior + +Previously, the `Equals(T other)` instance method followed the IEEE 754 requirements and deferred to the `==` implementation. This meant that `NaN != NaN`, even when the two NaN are bitwise identical. + +For example: + +```csharp +float f = float.NaN; +Console.WriteLine(f == f); // False +Console.WriteLine(f.Equals(f)); // True +``` + +While for several of the listed types: + +```csharp +Vector2 v = new Vector2(float.NaN); +Console.WriteLine(v == v); // False +Console.WriteLine(v.Equals(v)); // False +``` + +This is problematic because using one of these types as a key in a dictionary meant that the key could never be resolved: + +```csharp +Vector2 v = new Vector2(float.NaN); +var s = new HashSet(); +s.Add(v); +Console.WriteLine(s.Contains(v)); // False +``` + +## New behavior + +The behavior is now the same as for the primitive floating-point types, which is that the `==` and `!=` methods continue to follow the IEEE 754 requirements where `NaN != NaN`. But the `Equals(T other)` instance methods follow the requirements so that `NaN.Equals(NaN)`. + +For example (no change): + +```csharp +float f = float.NaN; +Console.WriteLine(f == f); // False +Console.WriteLine(f.Equals(f)); // True +``` + +While for several of the listed types (the second line now prints `True`): + +```csharp +Vector2 v = new Vector2(float.NaN); +Console.WriteLine(v == v); // False +Console.WriteLine(v.Equals(v)); // True +``` + +And when used in some hash set (the output now prints `True`): + +```csharp +Vector2 v = new Vector2(float.NaN); +var s = new HashSet(); +s.Add(v); +Console.WriteLine(s.Contains(v)); // True +``` + +## Version introduced + +.NET 7 Preview 5 + +## Type of breaking change + +This change can affect [binary compatibility](../../categories.md#binary-compatibility). + +## Reason for change + +The previous implementation did not meet the implementation requirements of or `object.Equals(object obj)`. This resulted in the affected types not being usable in hash sets or with `GetHashCode`. + +## Recommended action + +If you prefer the previous behavior, switch to using `==` or `!=` instead of `Equals(T other)`. + +## Affected APIs + +- +- +- +- +- +- +- +- +- +- +- diff --git a/docs/core/compatibility/core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md b/docs/core/compatibility/core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md index a75bf4b9db5be..d746353aa447f 100644 --- a/docs/core/compatibility/core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md +++ b/docs/core/compatibility/core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md @@ -10,7 +10,7 @@ Some APIs have been marked as obsolete, starting in .NET 7. This breaking change ## Change description -In previous .NET versions, these APIs can be used without any build warning. In .NET 7 and later versions, use of these APIS produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings. +In previous .NET versions, these APIs can be used without any build warning. In .NET 7 and later versions, use of these APIs produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings. The following table lists the custom diagnostic IDs and their corresponding warning messages for obsoleted APIs. diff --git a/docs/core/compatibility/core-libraries/7.0/serializationformat-binary.md b/docs/core/compatibility/core-libraries/7.0/serializationformat-binary.md index 914079c89252f..ce356016e9afd 100644 --- a/docs/core/compatibility/core-libraries/7.0/serializationformat-binary.md +++ b/docs/core/compatibility/core-libraries/7.0/serializationformat-binary.md @@ -7,7 +7,7 @@ ms.date: 03/18/2022 is obsolete for and . Binary serialization relies on , which is insecure. If you use in your code, obsoletion warning [SYSLIB0038](../../../../fundamentals/syslib-diagnostics/syslib0038.md) will be generated at compile time. -In addition, a is thrown at run time if you: +In addition, an is thrown at run time if you: - Set or to . - Call one of the deserialization constructors for or with binary data. diff --git a/docs/core/compatibility/cryptography/7.0/decrypt-envelopedcms.md b/docs/core/compatibility/cryptography/7.0/decrypt-envelopedcms.md new file mode 100644 index 0000000000000..b767bb21cb373 --- /dev/null +++ b/docs/core/compatibility/cryptography/7.0/decrypt-envelopedcms.md @@ -0,0 +1,71 @@ +--- +title: "Breaking change: Decrypting EnvelopedCms doesn't double unwrap" +description: Learn about the .NET 7 breaking change in cryptography where decrypting EnvelopedCms no longer removes extra data that was introduced by a bug in .NET Core 2.0. +ms.date: 05/24/2022 +--- +# Decrypting EnvelopedCms doesn't double unwrap + +In .NET Core 2.0 on macOS and Linux, the implementation incorrectly wrapped content in an extra ASN.1 OCTET STRING value. To maintain compatibility when processing content created with this error, the class still looked at the decrypted content and tried to remove the extra data. removed the extra data on Windows when using an external private key, and on all other operating systems for any decryption. + +Unfortunately, this opportunistic compatibility code cannot distinguish between documents that were created incorrectly and documents that were created correctly but have the same data shape. + +## Previous behavior + +Previously, if the decrypted content started with the byte value `0x04` and a legally encoded ASN.1 BER length value that was less than or equal to the number of bytes remaining in the content, the data provided in the `envelopedCms.ContentInfo.Content` property only received the data associated with the content octets portion of the value when treated as an ASN.1 OCTET STRING. + +For example, if the initially decrypted content was the byte series `{ 0x04, 0x03, 0x01, 0x02, 0x03 }` or `{ 0x04, 0x03, 0x01, 0x02, 0x03, [continued content] }`, the value of `envelopedCms.ContentInfo.Content` was the byte series `{ 0x01, 0x02, 0x03 }`. + +Values that did not start with `0x04`, or started with `0x04` but were not followed by an acceptably encoded length value, were fully reported. + +For some overloads of , this behavior only occurred on non-Windows operating systems. For more information, see [Affected APIs](#affected-apis). + +## New behavior + +The class no longer attempts to work around the previous issue, and always reports the decrypted content faithfully. + +If you're processing documents that were created by the .NET Core 2.0 version of the class on macOS or Linux, you'll see extra data at the beginning of the content. + +## Version introduced + +.NET 7 Preview 5 + +## Type of breaking change + +This change can affect [binary compatibility](../../categories.md#binary-compatibility). + +## Reason for change + +The compatibility code could not differentiate between incorrectly created documents and documents that were legitimately transporting data that looked like a BER-encoded ASN.1 OCTET STRING. + +Due to the nature of the BER encoding, callers that were negatively impacted by this compatibility code could not easily recover their missing data. + +## Recommended action + +Callers that read documents created with on .NET Core 2.0 for macOS or Linux can add code to remove the extra data. To remove it, use the class from the [System.Formats.Asn1 NuGet package](https://www.nuget.org/packages/System.Formats.Asn1), which is already a dependency of the class. + +```csharp +envelopedCms.Decrypt(...); + +byte[] content = envelopedCms.ContentInfo.Content; + +if (envelopedCms.ContentInfo.Oid.Value == "1.2.840.113549.1.7.1") +{ + if (content?.Length > 0 && content[0] == 0x04) + { + try + { + content = AsnDecoder.ReadOctetString(content, AsnEncodingRules.BER, out _); + } + catch (AsnContentException) + { + } + } +} +``` + +## Affected APIs + +- +- (non-Windows only) +- (non-Windows only) +- (non-Windows only) diff --git a/docs/core/compatibility/cryptography/7.0/x500-distinguished-names.md b/docs/core/compatibility/cryptography/7.0/x500-distinguished-names.md new file mode 100644 index 0000000000000..4e4ea2dec49eb --- /dev/null +++ b/docs/core/compatibility/cryptography/7.0/x500-distinguished-names.md @@ -0,0 +1,37 @@ +--- +title: "Breaking change: X500DistinguishedName parsing of friendly names" +description: Learn about the .NET 7 breaking change in cryptography where X500DistinguishedName parsing doesn't permit friendly names where OIDs are expected on MacOS and Linux. +ms.date: 05/19/2022 +--- +# X500DistinguishedName parsing of friendly names + +On Linux and macOS, a distinguished name with a relative distinguished name component that is prefixed with "OID." followed by a friendly name will no longer parse. For example, `OID.STREET=MainStreet` no longer parses. + +## Previous behavior + +On Linux and macOS only, a distinguished name would successfully parse even if the object identifier (OID) was a friendly name. + +## New behavior + +Attempting to parse a distinguished name with a component prefixed with "OID." but not followed by a well-formed, dotted-decimal OID throws a . + +## Version introduced + +.NET 7 Preview 5 + +## Type of breaking change + +This change can affect [binary compatibility](../../categories.md#binary-compatibility). + +## Reason for change + +Windows does not permit distinguished names with friendly name OIDs, and that it worked in Linux and macOS was coincidence and not intentional. To bring consistency throughout platforms, the parsing logic was improved to not accept this form. + +## Recommended action + +Change "OID."-prefixed relative distinguished name components to use an OID, such as `OID.1.2.3.4=MyValue`. + +## Affected APIs + +- +- diff --git a/docs/core/compatibility/deployment/7.0/multilevel-lookup.md b/docs/core/compatibility/deployment/7.0/multilevel-lookup.md new file mode 100644 index 0000000000000..172eccc5e1f5d --- /dev/null +++ b/docs/core/compatibility/deployment/7.0/multilevel-lookup.md @@ -0,0 +1,52 @@ +--- +title: "Breaking change: Multi-level lookup is disabled" +description: Learn about the .NET 7 breaking change in deployment where multi-level lookup is disabled. +ms.date: 04/08/2022 +--- +# Multi-level lookup is disabled + +On Windows, framework-dependent .NET applications no longer search for frameworks in multiple install locations. + +## Previous behavior + +In previous versions, a framework-dependent .NET application searched for frameworks in multiple install locations on Windows. The locations were: + +- When running the application through [dotnet](../../../tools/dotnet.md), subdirectories relative to the `dotnet` executable. +- When running the application through its executable (`apphost`), the location specified by the value of the `DOTNET_ROOT` environment variable (if set). +- The globally registered install location in **HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\\InstallLocation** (if set). +- The default install location of *%ProgramFiles%\dotnet* (or *%ProgramFiles(x86)%\dotnet* for 32-bit processes on 64-bit Windows). + +This multi-level lookup behavior was enabled by default but could be disabled by setting the environment variable `DOTNET_MULTILEVEL_LOOKUP=0`. + +## New behavior + +Applications that target .NET 7 or a later version only look for frameworks in one location, which is the first location where a .NET installation is found. When running an application through [dotnet](../../../tools/dotnet.md), frameworks are only searched for in subdirectories relative to the `dotnet` executable. When running an application through its executable (`apphost`), frameworks are only searched for in the first of the following locations where .NET is found: + +- The location specified by the value of the `DOTNET_ROOT` environment variable (if set). +- The globally registered install location in **HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\\InstallLocation** (if set). +- The default install location of *%ProgramFiles%\dotnet* (or *%ProgramFiles(x86)%\dotnet* for 32-bit processes on 64-bit Windows). + +## Version introduced + +.NET 7 Preview 4 + +## Type of breaking change + +This change can affect [binary compatibility](../../categories.md#binary-compatibility). + +## Reason for change + +There've been numerous issues caused by multi-level lookup: + +- Confusion for users: application can pick a global or default install location despite running .NET from a private install. +- Inconsistency between platforms (Windows versus non-Windows). +- Behavior breaks, often in automated systems: a new global .NET install can affect otherwise isolated builds and tests. +- Performance issues. + +## Recommended action + +Make sure the required version of .NET is installed at the single .NET install location. The error messages that are emitted on failure to launch include the expected location. + +## Affected APIs + +None. diff --git a/docs/core/compatibility/includes/binary-source-compat.md b/docs/core/compatibility/includes/binary-source-compat.md new file mode 100644 index 0000000000000..0f03bf4bbfbec --- /dev/null +++ b/docs/core/compatibility/includes/binary-source-compat.md @@ -0,0 +1,4 @@ +This article categorizes each breaking change as *binary incompatible* or *source incompatible*: + +- **Binary incompatible** - Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, or different run-time behavior. +- **Source incompatible** - Source code may encounter a breaking change in behavior when targeting the new runtime or using the new SDK or component. Behavior changes can include compile errors or different run-time behavior. diff --git a/docs/core/compatibility/sdk/6.0/publish-readytorun-requires-restore-change.md b/docs/core/compatibility/sdk/6.0/publish-readytorun-requires-restore-change.md index d814b0ff334ec..dda1a83f71ede 100644 --- a/docs/core/compatibility/sdk/6.0/publish-readytorun-requires-restore-change.md +++ b/docs/core/compatibility/sdk/6.0/publish-readytorun-requires-restore-change.md @@ -21,7 +21,7 @@ In .NET 6, `dotnet restore` followed by `dotnet publish -p:PublishReadyToRun=tru ## Reason for change -The crossgen binary is not required for many workloads, so it was split out from the main SDK. It it typically acquired on-demand, and the publishing MSBuild targets now handle this acquisition by adding the package to the list of packages to be restored. +The crossgen binary is not required for many workloads, so it was split out from the main SDK. It is typically acquired on-demand, and the publishing MSBuild targets now handle this acquisition by adding the package to the list of packages to be restored. ## Recommended action diff --git a/docs/core/compatibility/sdk/6.0/runtimeconfigdev-file.md b/docs/core/compatibility/sdk/6.0/runtimeconfigdev-file.md new file mode 100644 index 0000000000000..bd6ef93b01800 --- /dev/null +++ b/docs/core/compatibility/sdk/6.0/runtimeconfigdev-file.md @@ -0,0 +1,36 @@ +--- +title: "Breaking change: runtimeconfig.dev.json file not generated" +description: Learn about the breaking change in the .NET 6 SDK where the runtimeconfig.dev.json file is no longer generated by default. +ms.date: 05/04/2022 +--- +# runtimeconfig.dev.json file not generated + +The .NET SDK no longer generates the *runtimeconfig.dev.json* file by default. This file was not used in most scenarios, and finding and loading the file added small amounts of performance overhead. + +## Previous behavior + +An *\[Appname].runtimesettings.dev.json* file was automatically generated at compile time. + +## New behavior + +The *\[Appname].runtimesettings.dev.json* file is no longer generated by default. + +## Version introduced + +.NET SDK 6.0.100 + +## Change category + +This change may affect [*binary compatibility*](../../categories.md#binary-compatibility). + +## Reason for change + +Not generating the file provides a small but measurable performance improvement. + +## Recommended action + +This change should not affect most customers. However, if you still require this file, add `true` to your project. For more information, see [GenerateRuntimeConfigDevFile](../../../project-sdk/msbuild-props.md#generateruntimeconfigdevfile). + +## Affected APIs + +N/A diff --git a/docs/core/compatibility/sdk/6.0/runtimeidentifier-self-contained.md b/docs/core/compatibility/sdk/6.0/runtimeidentifier-self-contained.md index 72fca838e115b..90d7dfd2f7c7f 100644 --- a/docs/core/compatibility/sdk/6.0/runtimeidentifier-self-contained.md +++ b/docs/core/compatibility/sdk/6.0/runtimeidentifier-self-contained.md @@ -41,9 +41,14 @@ The default without specifying a `RuntimeIdentifier` is to generate a framework- ## Recommended action -- Specify a boolean value in your project file for `SelfContained`. -- Or, add `--sc` with a value to your build or publish command. +- Specify a Boolean value in your project file for `SelfContained`. +- Or, add `--self-contained` with a value to your build or publish command. ## Affected APIs N/A + +## See also + +- [dotnet build command](../../../tools/dotnet-build.md) +- [dotnet publish command](../../../tools/dotnet-publish.md) diff --git a/docs/core/compatibility/sdk/6.0/vs-msbuild-version.md b/docs/core/compatibility/sdk/6.0/vs-msbuild-version.md index e4da4098f4ed7..f1c15c7e3131c 100644 --- a/docs/core/compatibility/sdk/6.0/vs-msbuild-version.md +++ b/docs/core/compatibility/sdk/6.0/vs-msbuild-version.md @@ -5,7 +5,7 @@ ms.date: 03/25/2022 --- # Version requirements for .NET 6 SDK -The NET 6.0.300 SDK no longer loads in version 16.11 or earlier of Visual Studio or MSBuild. +Starting with the .NET SDK 6.0.300, the .NET SDK no longer loads in version 16.11 or earlier of Visual Studio or MSBuild. ## Version introduced @@ -13,11 +13,11 @@ The NET 6.0.300 SDK no longer loads in version 16.11 or earlier of Visual Studio ## Old behavior -.NET SDK 6.0.300 would load in the 16.10 and 16.11 versions of Visual Studio and MSBuild. +The .NET SDK would load in the 16.10 and 16.11 versions of Visual Studio and MSBuild. ## New behavior -.NET SDK 6.0.300 can only be used with version 17.0 or later of Visual Studio and MSBuild. In addition, any scenarios that use a source generator could fail when using a Visual Studio or MSBuild version earlier than version 17.2. +The .NET SDK can only be used with version 17.0 or later of Visual Studio and MSBuild. In addition, any scenarios that use a source generator could fail when using a Visual Studio or MSBuild version earlier than version 17.2. ## Reason for change diff --git a/docs/core/compatibility/sdk/6.0/write-reference-assemblies-to-obj.md b/docs/core/compatibility/sdk/6.0/write-reference-assemblies-to-obj.md index 498e9c4e589f0..428a88e5e6866 100644 --- a/docs/core/compatibility/sdk/6.0/write-reference-assemblies-to-obj.md +++ b/docs/core/compatibility/sdk/6.0/write-reference-assemblies-to-obj.md @@ -13,7 +13,7 @@ The .NET SDK now writes [reference assemblies](../../../../standard/assembly/ref ## Old behavior -Since reference assemblies were added, the .NET SDK has written reference assemblies to the `ref` directory in the `OutDir` directory of the compilation. +Since reference assemblies were added, the .NET SDK has written reference assemblies to the *ref* directory in the `OutDir` directory of the compilation. In .NET 5, the [ProduceReferenceAssembly](../../../../csharp/language-reference/compiler-options/output.md#producereferenceassembly) property was introduced and defaulted to `true` for `net5.0` and later applications. With this change, many applications began implicitly generating reference assemblies in the `OutDir` directory. ## New behavior diff --git a/docs/core/compatibility/sdk/7.0/custom-serialization.md b/docs/core/compatibility/sdk/7.0/custom-serialization.md new file mode 100644 index 0000000000000..52390cc8c62c3 --- /dev/null +++ b/docs/core/compatibility/sdk/7.0/custom-serialization.md @@ -0,0 +1,32 @@ +--- +title: "Breaking change: Serialization of custom types in .NET 7" +description: Learn about a breaking change in MSBuild for .NET 7 where serialization using BinaryFormatter of certain user-defined types is removed. +author: baronfel +ms.date: 05/06/2022 +--- + +# BinaryFormatter serialization of custom BuildEventArgs and ITaskItems removed for .NET 7 + +MSBuild in .NET 7 doesn't support serialization of custom `BuildEventArgs`-derived and `ITaskItem`-derived types via the `BinaryFormatter` serializer. + +## Version introduced + +MSBuild 17.4 (.NET SDK 7.0.100) + +## Old behavior + +MSBuild used BinaryFormatter to preserve custom types that derived from BuildEventArgs and ITaskItem across certain boundaries, most notably when running in a multi-process environment. + +## New behavior + +MSBuild will no longer support this mechanism, so code that used custom types derived from BuildEventArgs and ITaskItem may fail. + +## Reason for change + +BinaryFormatter was [made obsolete in .NET 5](https://github.com/dotnet/designs/blob/main/accepted/2020/better-obsoletion/binaryformatter-obsoletion.md). Per this plan, all first-party code in the dotnet GitHub organization must migrate away from its use by .NET 7. This change impacts user-exposed functionality of MSBuild. + +## Recommended action + +* Engage with the MSBuild team on [this GitHub discussion](https://github.com/dotnet/msbuild/discussions/7582) about your specific use cases and how you can migrate away from the `TranslateDotNet` mechanism. + +* Avoid returning custom derived types from tasks or when logging. diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index b7d670c842980..4ee4668cf1ade 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -43,6 +43,10 @@ items: href: core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md - name: C++/CLI projects in Visual Studio href: core-libraries/7.0/cpluspluscli-compiler-version.md + - name: Collectible Assembly in non-collectible AssemblyLoadContext + href: core-libraries/7.0/collectible-assemblies.md + - name: Equals method behavior change for NaN + href: core-libraries/7.0/equals-nan.md - name: FullPath and OldFullPath return fully qualified path href: core-libraries/7.0/filesystemeventargs-fullpath.md - name: Generic type constraint on PatternContext @@ -51,16 +55,28 @@ items: href: core-libraries/7.0/serializationformat-binary.md - name: Validate CompressionLevel for BrotliStream href: core-libraries/7.0/compressionlevel-validation.md + - name: Cryptography + items: + - name: EnvelopedCms.Decrypt doesn't double unwrap + href: cryptography/7.0/decrypt-envelopedcms.md + - name: X500DistinguishedName parsing of friendly names + href: cryptography/7.0/x500-distinguished-names.md + - name: Deployment + items: + - name: Multi-level lookup is disabled + href: deployment/7.0/multilevel-lookup.md - name: Networking items: - name: AllowRenegotiation default is false href: networking/7.0/allowrenegotiation-default.md - name: Custom ping payloads on Linux href: networking/7.0/ping-custom-payload-linux.md - - name: SDK + - name: SDK and MSBuild items: - name: Version requirements for .NET 7 SDK href: sdk/7.0/vs-msbuild-version.md + - name: Serialization of custom types in .NET 7 + href: sdk/7.0/custom-serialization.md - name: Serialization items: - name: Deserialize Version type with leading or trailing whitespace @@ -75,6 +91,8 @@ items: href: 6.0.md - name: ASP.NET Core items: + - name: ActionResult sets StatusCode to 200 + href: aspnet-core/6.0/actionresult-statuscode.md - name: AddDataAnnotationsValidation method made obsolete href: aspnet-core/6.0/adddataannotationsvalidation-obsolete.md - name: Assemblies removed from shared framework @@ -123,6 +141,12 @@ items: href: aspnet-core/6.0/signalr-java-client-updated.md - name: TryParse and BindAsync methods are validated href: aspnet-core/6.0/tryparse-bindasync-validation.md + - name: Containers + items: + - name: Default console logger formatting in container images + href: containers/6.0/console-formatter-default.md + - name: Other breaking changes + href: https://github.com/dotnet/dotnet-docker/discussions/3699 - name: Core .NET libraries items: - name: API obsoletions with non-default diagnostic IDs @@ -163,6 +187,8 @@ items: href: core-libraries/6.0/static-abstract-interface-methods.md - name: StringBuilder.Append overloads and evaluation order href: core-libraries/6.0/stringbuilder-append-evaluation-order.md + - name: Strong-name APIs throw PlatformNotSupportedException + href: core-libraries/6.0/strong-name-signing-exceptions.md - name: System.Drawing.Common only supported on Windows href: core-libraries/6.0/system-drawing-common-windows-only.md - name: System.Security.SecurityContext is marked obsolete @@ -229,6 +255,8 @@ items: href: sdk/6.0/outputtype-not-set-automatically.md - name: Publish ReadyToRun with --no-restore requires changes href: sdk/6.0/publish-readytorun-requires-restore-change.md + - name: runtimeconfig.dev.json file not generated + href: sdk/6.0/runtimeconfigdev-file.md - name: RuntimeIdentifier warning if self-contained is unspecified href: sdk/6.0/runtimeidentifier-self-contained.md - name: Version requirements for .NET 6 SDK @@ -557,6 +585,8 @@ items: href: aspnet-core/7.0/signalr-hub-method-parameters-di.md - name: .NET 6 items: + - name: ActionResult sets StatusCode to 200 + href: aspnet-core/6.0/actionresult-statuscode.md - name: AddDataAnnotationsValidation method made obsolete href: aspnet-core/6.0/adddataannotationsvalidation-obsolete.md - name: Assemblies removed from shared framework @@ -701,6 +731,14 @@ items: href: code-analysis/5.0/ca2200-rethrow-to-preserve-stack-details.md - name: CA2247 warning href: code-analysis/5.0/ca2247-ctor-arg-should-be-taskcreationoptions.md + - name: Containers + items: + - name: .NET 6 + items: + - name: Default console logger formatting in container images + href: containers/6.0/console-formatter-default.md + - name: Other breaking changes + href: https://github.com/dotnet/dotnet-docker/discussions/3699 - name: Core .NET libraries items: - name: .NET 7 @@ -709,6 +747,10 @@ items: href: core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md - name: C++/CLI projects in Visual Studio href: core-libraries/7.0/cpluspluscli-compiler-version.md + - name: Collectible Assembly in non-collectible AssemblyLoadContext + href: core-libraries/7.0/collectible-assemblies.md + - name: Equals method behavior change for NaN + href: core-libraries/7.0/equals-nan.md - name: FullPath and OldFullPath return fully qualified path href: core-libraries/7.0/filesystemeventargs-fullpath.md - name: Generic type constraint on PatternContext @@ -757,6 +799,8 @@ items: href: core-libraries/6.0/static-abstract-interface-methods.md - name: StringBuilder.Append overloads and evaluation order href: core-libraries/6.0/stringbuilder-append-evaluation-order.md + - name: Strong-name APIs throw PlatformNotSupportedException + href: core-libraries/6.0/strong-name-signing-exceptions.md - name: System.Drawing.Common only supported on Windows href: core-libraries/6.0/system-drawing-common-windows-only.md - name: System.Security.SecurityContext is marked obsolete @@ -831,6 +875,12 @@ items: href: corefx.md - name: Cryptography items: + - name: .NET 7 + items: + - name: EnvelopedCms.Decrypt doesn't double unwrap + href: cryptography/7.0/decrypt-envelopedcms.md + - name: X500DistinguishedName parsing of friendly names + href: cryptography/7.0/x500-distinguished-names.md - name: .NET 6 items: - name: CreateEncryptor methods throw exception for incorrect feedback size @@ -849,6 +899,12 @@ items: href: cryptography/5.0/tripledes-default-feedback-size-change.md - name: .NET Core 2.1-3.0 href: cryptography.md + - name: Deployment + items: + - name: .NET 7 + items: + - name: Multi-level lookup is disabled + href: deployment/7.0/multilevel-lookup.md - name: Entity Framework Core items: - name: EF Core 6 @@ -939,6 +995,8 @@ items: items: - name: Version requirements for .NET 7 SDK href: sdk/7.0/vs-msbuild-version.md + - name: Serialization of custom types in .NET 7 + href: sdk/7.0/custom-serialization.md - name: .NET 6 items: - name: -p option for `dotnet run` is deprecated @@ -961,6 +1019,8 @@ items: href: sdk/6.0/outputtype-not-set-automatically.md - name: Publish ReadyToRun with --no-restore requires changes href: sdk/6.0/publish-readytorun-requires-restore-change.md + - name: runtimeconfig.dev.json file not generated + href: sdk/6.0/runtimeconfigdev-file.md - name: RuntimeIdentifier warning if self-contained is unspecified href: sdk/6.0/runtimeidentifier-self-contained.md - name: Version requirements for .NET 6 SDK diff --git a/docs/core/compatibility/windows-forms/7.0/apis-throw-argumentnullexception.md b/docs/core/compatibility/windows-forms/7.0/apis-throw-argumentnullexception.md index eeb90b33faeb2..7e6684f0e0b5c 100644 --- a/docs/core/compatibility/windows-forms/7.0/apis-throw-argumentnullexception.md +++ b/docs/core/compatibility/windows-forms/7.0/apis-throw-argumentnullexception.md @@ -34,15 +34,16 @@ Throwing conforms to .NET Runtime behavior. ## Affected APIs -The following table lists the affected APIs and specific parameters in .NET 7 Preview 1: - -| Method/property | Parameter name | -|-|-| -| | `owner` | -| | `bitmap` | -| | `bitmap` | -| | `control` or `cellStyle` | -| | `g` | -| | `g` or `contentPanel` | -| | `g` or `item` | -| | `g` or `toolStripPanel` | +The following table lists the affected APIs and specific parameters. + +| Method/property | Parameter name | Change version | +|-|-|-| +| | `owner` | Preview 1 | +| | `bitmap` | Preview 1 | +| | `bitmap` | Preview 1 | +| | `control` or `cellStyle` | Preview 1 | +| | `g` | Preview 1 | +| | `g` or `contentPanel` | Preview 1 | +| | `g` or `item` | Preview 1 | +| | `g` or `toolStripPanel` | Preview 1 | +| | `owner` | Preview 5 | diff --git a/docs/core/diagnostics/debug-highcpu.md b/docs/core/diagnostics/debug-highcpu.md index 585023c3d707f..a70d05d41ed45 100644 --- a/docs/core/diagnostics/debug-highcpu.md +++ b/docs/core/diagnostics/debug-highcpu.md @@ -83,38 +83,56 @@ With the web app running, immediately after startup, the CPU isn't being consume `https://localhost:5001/api/diagscenario/highcpu/60000` -Now, rerun the [dotnet-counters](dotnet-counters.md) command. To monitor just the `cpu-usage`, specify `System.Runtime[cpu-usage]` as part of the command. +Now, rerun the [dotnet-counters](dotnet-counters.md) command. If interested in monitoring just the `cpu-usage` counter, add '--counters System.Runtime[cpu-usage]` to the previous command. We are unsure if the CPU is being consumed, so we will monitor the same list of counters as above to verify counter values are within expected range for our application. ```dotnetcli -dotnet-counters monitor --counters System.Runtime[cpu-usage] -p 22884 --refresh-interval 1 +dotnet-counters monitor -p 22884 --refresh-interval 1 ``` -You should see an increase in CPU usage as shown below: +You should see an increase in CPU usage as shown below (depending on the host machine, expect varying CPU usage): ```console Press p to pause, r to resume, q to quit. Status: Running [System.Runtime] + % Time in GC since last GC (%) 0 + Allocation Rate / 1 sec (B) 0 CPU Usage (%) 25 + Exception Count / 1 sec 0 + GC Heap Size (MB) 4 + Gen 0 GC Count / 60 sec 0 + Gen 0 Size (B) 0 + Gen 1 GC Count / 60 sec 0 + Gen 1 Size (B) 0 + Gen 2 GC Count / 60 sec 0 + Gen 2 Size (B) 0 + LOH Size (B) 0 + Monitor Lock Contention Count / 1 sec 0 + Number of Active Timers 1 + Number of Assemblies Loaded 140 + ThreadPool Completed Work Item Count / 1 sec 3 + ThreadPool Queue Length 0 + ThreadPool Thread Count 7 + Working Set (MB) 63 ``` -Throughout the duration of the request, the CPU usage will hover around 25% . Depending on the host machine, expect varying CPU usage. +Throughout the duration of the request, the CPU usage will hover around the increased percentage. > [!TIP] > To visualize an even higher CPU usage, you can exercise this endpoint in multiple browser tabs simultaneously. -At this point, you can safely say the CPU is running higher than you expect. +At this point, you can safely say the CPU is running higher than you expect. Identifying the effects of a problem is key to finding the cause. We will use the effect of high CPU consumption in addition to diagnostic tools to find the cause of the problem. -## Trace generation +## Analyze High CPU with Profiler -When analyzing a slow request, you need a diagnostics tool that can provide insights into what the code is doing. The usual choice is a profiler, and there are different profiler options to choose from. +When analyzing an app with high CPU usage, you need a diagnostics tool that can provide insights into what the code is doing. The usual choice is a profiler, and there are different profiler options to choose from. `dotnet-trace` can be used on all operating systems, however, its limitations of safe-point bias and managed-only callstacks result in more general information compared to a kernel-aware profiler like 'perf' for Linux or ETW for Windows. If your performance investigation involves only managed code, generally `dotnet-trace` will be sufficient. ### [Linux](#tab/linux) -The `perf` tool can be used to generate .NET Core app profiles. Exit the previous instance of the [sample debug target](/samples/dotnet/samples/diagnostic-scenarios). +The `perf` tool can be used to generate .NET Core app profiles. We will demonstrate this tool, although dotnet-trace could be used as well. Exit the previous instance of the [sample debug target](/samples/dotnet/samples/diagnostic-scenarios). -Set the `DOTNET_PerfMapEnabled` environment variable to cause the .NET Core app to create a `map` file in the `/tmp` directory. This `map` file is used by `perf` to map CPU address to JIT-generated functions by name. For more information, see [Write perf map](../runtime-config/debugging-profiling.md#write-perf-map). +Set the `DOTNET_PerfMapEnabled` environment variable to cause the .NET app to create a `map` file in the `/tmp` directory. This `map` file is used by `perf` to map CPU addresses to JIT-generated functions by name. For more information, see [Export perf maps](../runtime-config/debugging-profiling.md#export-perf-maps). [!INCLUDE [complus-prefix](../../../includes/complus-prefix.md)] @@ -150,7 +168,7 @@ This command generates a `flamegraph.svg` that you can view in the browser to in ### [Windows](#tab/windows) -On Windows, you can use the [dotnet-trace](dotnet-trace.md) tool as a profiler. Using the previous [sample debug target](/samples/dotnet/samples/diagnostic-scenarios), exercise the high CPU endpoint (`https://localhost:5001/api/diagscenario/highcpu/60000`) again. While it's running within the 1-minute request, use the `collect` command as follows: +On Windows, you can use the [dotnet-trace](dotnet-trace.md) tool as a profiler. Using the previous [sample debug target](/samples/dotnet/samples/diagnostic-scenarios), exercise the high CPU endpoint (`https://localhost:5001/api/diagscenario/highcpu/60000`) again. While it's running within the 1-minute request, use the `collect` command, with the `providers` option to specify the provider we want: [Microsoft-DotNetCore-SampleProfiler](well-known-event-providers.md#microsoft-dotnetcore-sampleprofiler-provider), to collect a trace of the app as follows: ```dotnetcli dotnet-trace collect -p 22884 --providers Microsoft-DotNETCore-SampleProfiler @@ -158,12 +176,16 @@ dotnet-trace collect -p 22884 --providers Microsoft-DotNETCore-SampleProfiler Let [dotnet-trace](dotnet-trace.md) run for about 20-30 seconds, and then press the Enter to exit the collection. The result is a `nettrace` file located in the same folder. The `nettrace` files are a great way to use existing analysis tools on Windows. -Open the `nettrace` with [`PerfView`](https://github.com/microsoft/perfview/blob/main/documentation/Downloading.md) as shown below. +Open the `nettrace` with [`PerfView`](https://github.com/microsoft/perfview/blob/main/documentation/Downloading.md) by navigating to samples/core/diagnostics/DiagnosticScenarios/ and clicking on the arrow by the `nettrace` file. Open the 'Thread Time (with StartStop Activities) Stacks' and choose the 'CallTree' tab near the top. After checking the box to the left of one of the threads, your file should look similar to the one pictured below. [![PerfView image](media/perfview.jpg)](media/perfview.jpg#lightbox) --- +## Analyzing High CPU Data with Visual Studio + +All \*.nettrace files can be analyzed in Visual Studio. To analyze a Linux \*.nettrace file in Visual Studio, transfer the \*.nettrace file, in addition to the other necessary documents, to a Windows machine, and then open the \*.nettrace file in Visual Studio. For more information, see [Analyze CPU Usage Data](/visualstudio/profiling/beginners-guide-to-performance-profiling?#step-2-analyze-cpu-usage-data). + ## See also - [dotnet-trace](dotnet-trace.md) to list processes diff --git a/docs/core/diagnostics/debug-threadpool-starvation.md b/docs/core/diagnostics/debug-threadpool-starvation.md new file mode 100644 index 0000000000000..eef11e760eede --- /dev/null +++ b/docs/core/diagnostics/debug-threadpool-starvation.md @@ -0,0 +1,312 @@ +--- +title: Debug ThreadPool Starvation +description: A tutorial that walks you through debugging and fixing a ThreadPool starvation issue on .NET Core +ms.topic: tutorial +ms.date: 04/19/2022 +--- + +# Debug ThreadPool Starvation + +**This article applies to: ✔️** .NET Core 3.1 and later versions + +In this tutorial, you'll learn how to debug a ThreadPool starvation scenario. ThreadPool starvation occurs when the pool has no available threads to process new work items and it often causes applications to respond slowly. Using the provided example [ASP.NET Core web app](/samples/dotnet/samples/diagnostic-scenarios), you can cause ThreadPool starvation intentionally and learn how to diagnose it. + +In this tutorial, you will: + +> [!div class="checklist"] +> +> - Investigate an app that is responding to requests slowly +> - Use the dotnet-counters tool to identify ThreadPool starvation is likely occuring +> - Use the dotnet-stack tool to determine what work is keeping the ThreadPool threads busy + +## Prerequisites + +The tutorial uses: + +- [.NET Core 6.0 SDK](https://dotnet.microsoft.com/download/dotnet) to build and run the sample app +- [Sample web app](/samples/dotnet/samples/diagnostic-scenarios) to demonstrate ThreadPool starvation behavior +- [Bombardier](https://github.com/codesenberg/bombardier/releases) to generate load for the sample web app +- [dotnet-counters](dotnet-counters.md) to observe performance counters +- [dotnet-stack](dotnet-stack.md) to examine thread stacks + +## Running the sample app + +1. Download the code for the [sample app](/samples/dotnet/samples/diagnostic-scenarios) and build it using the .NET SDK: + + ```dotnetcli + E:\demo\DiagnosticScenarios>dotnet build + Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET + Copyright (C) Microsoft Corporation. All rights reserved. + + Determining projects to restore... + All projects are up-to-date for restore. + DiagnosticScenarios -> E:\demo\DiagnosticScenarios\bin\Debug\net6.0\DiagnosticScenarios.dll + + Build succeeded. + 0 Warning(s) + 0 Error(s) + + Time Elapsed 00:00:01.26 + ``` + +1. Run the app: + + ```dotnetcli + E:\demo\DiagnosticScenarios>bin\Debug\net6.0\DiagnosticScenarios.exe + info: Microsoft.Hosting.Lifetime[14] + Now listening on: http://localhost:5000 + info: Microsoft.Hosting.Lifetime[14] + Now listening on: https://localhost:5001 + info: Microsoft.Hosting.Lifetime[0] + Application started. Press Ctrl+C to shut down. + info: Microsoft.Hosting.Lifetime[0] + Hosting environment: Production + info: Microsoft.Hosting.Lifetime[0] + Content root path: E:\demo\DiagnosticScenarios + ``` + +If you use a web browser and send requests to `https://localhost:5001/api/diagscenario/taskwait`, you should see the response `success:taskwait` returned after about 500 ms. This shows that the web server is serving traffic as expected. + +## Observing slow performance + +The demo web server has several endpoints which mock doing a database request and then returning a response to the user. Each of these endpoints has a delay of approximately 500 ms when serving requests one at a time but the performance is much worse when the web server is subjected to some load. Download the [Bombardier](https://github.com/codesenberg/bombardier/releases) load testing tool and observe the difference in latency when 125 concurrent requests are sent to each endpoint. + +```dotnetcli +bombardier-windows-amd64.exe https://localhost:5001/api/diagscenario/taskwait +Bombarding https://localhost:5001/api/diagscenario/taskwait for 10s using 125 connection(s) +[=============================================================================================] 10s +Done! +Statistics Avg Stdev Max + Reqs/sec 33.06 234.67 3313.54 + Latency 3.48s 1.39s 10.79s + HTTP codes: + 1xx - 0, 2xx - 454, 3xx - 0, 4xx - 0, 5xx - 0 + others - 0 + Throughput: 75.37KB/s +``` + +This second endpoint uses a code pattern that performs even worse: + +```dotnetcli +bombardier-windows-amd64.exe https://localhost:5001/api/diagscenario/tasksleepwait +Bombarding https://localhost:5001/api/diagscenario/tasksleepwait for 10s using 125 connection(s) +[=============================================================================================] 10s +Done! +Statistics Avg Stdev Max + Reqs/sec 1.61 35.25 788.91 + Latency 15.42s 2.18s 18.30s + HTTP codes: + 1xx - 0, 2xx - 140, 3xx - 0, 4xx - 0, 5xx - 0 + others - 0 + Throughput: 36.57KB/s +``` + +Both of these endpoints show dramatically more than the 500-ms average latency when load is high (3.48 s and 15.42 s respectively). If you run this example on an older version of .NET Core, you're likely to see both examples perform equally badly. .NET 6 has updated ThreadPool heuristics that reduce the performance impact of the bad coding pattern used in the first example. + +## Detecting ThreadPool starvation + +If you observed the behavior above on a real world service, you would know it's responding slowly under load but you wouldn't know the cause. [dotnet-counters](dotnet-counters.md) is a tool that can show live performance counters. These counters can provide clues about certain problems and are often easy to get. In production environments, you might have similar counters provided by remote monitoring tools and web dashboards. Install dotnet-counters and begin monitoring the web service: + +```dotnetcli +dotnet-counters monitor -n DiagnosticScenarios +Press p to pause, r to resume, q to quit. + Status: Running + +[System.Runtime] + % Time in GC since last GC (%) 0 + Allocation Rate (B / 1 sec) 0 + CPU Usage (%) 0 + Exception Count (Count / 1 sec) 0 + GC Committed Bytes (MB) 0 + GC Fragmentation (%) 0 + GC Heap Size (MB) 34 + Gen 0 GC Count (Count / 1 sec) 0 + Gen 0 Size (B) 0 + Gen 1 GC Count (Count / 1 sec) 0 + Gen 1 Size (B) 0 + Gen 2 GC Count (Count / 1 sec) 0 + Gen 2 Size (B) 0 + IL Bytes Jitted (B) 279,021 + LOH Size (B) 0 + Monitor Lock Contention Count (Count / 1 sec) 0 + Number of Active Timers 0 + Number of Assemblies Loaded 121 + Number of Methods Jitted 3,223 + POH (Pinned Object Heap) Size (B) 0 + ThreadPool Completed Work Item Count (Count / 1 sec) 0 + ThreadPool Queue Length 0 + ThreadPool Thread Count 1 + Time spent in JIT (ms / 1 sec) 0.387 + Working Set (MB) 87 +``` + +The counters above are an example while the web server wasn't serving any requests. Run Bombardier again with the `api/diagscenario/tasksleepwait` endpoint and sustained load for 2 minutes so there's plenty of time to observe what happens to the performance counters. + +```dotnetcli +bombardier-windows-amd64.exe https://localhost:5001/api/diagscenario/tasksleepwait -d 120s +``` + +ThreadPool starvation occurs when there are no free threads to handle the queued work items and the runtime responds by increasing the number of ThreadPool threads. You should observe the `ThreadPool Thread Count` rapidly increase to 2-3x the number of processor cores on your machine and then further threads are added 1-2 per second until eventually stabilizing somewhere above 125. The slow and steady increase of ThreadPool threads combined with CPU Usage much less than 100% are the key signals that ThreadPool starvation is currently a performance bottleneck. The thread count increase will continue until either the pool hits the maximum number of threads, enough threads have been created to satisfy all the incoming work items, or the CPU has been saturated. Often, but not always, ThreadPool starvation will also show large values for `ThreadPool Queue Length` and low values for `ThreadPool Completed Work Item Count`, meaning that there's a large amount of pending work and little work being completed. Here's an example of the counters while the thread count is still rising: + +```dotnetcli +Press p to pause, r to resume, q to quit. + Status: Running + +[System.Runtime] + % Time in GC since last GC (%) 0 + Allocation Rate (B / 1 sec) 24,480 + CPU Usage (%) 0 + Exception Count (Count / 1 sec) 0 + GC Committed Bytes (MB) 56 + GC Fragmentation (%) 40.603 + GC Heap Size (MB) 89 + Gen 0 GC Count (Count / 1 sec) 0 + Gen 0 Size (B) 6,306,160 + Gen 1 GC Count (Count / 1 sec) 0 + Gen 1 Size (B) 8,061,400 + Gen 2 GC Count (Count / 1 sec) 0 + Gen 2 Size (B) 192 + IL Bytes Jitted (B) 279,263 + LOH Size (B) 98,576 + Monitor Lock Contention Count (Count / 1 sec) 0 + Number of Active Timers 124 + Number of Assemblies Loaded 121 + Number of Methods Jitted 3,227 + POH (Pinned Object Heap) Size (B) 1,197,336 + ThreadPool Completed Work Item Count (Count / 1 sec) 2 + ThreadPool Queue Length 29 + ThreadPool Thread Count 96 + Time spent in JIT (ms / 1 sec) 0 + Working Set (MB) 152 +``` + +Once the count of ThreadPool threads stabilizes, the pool is no longer starving. But if it stabilizes at a high value (more than about three times the number of processor cores), that usually indicates the application code is blocking some ThreadPool threads and the ThreadPool is compensating by running with more threads. Running steady at high thread counts won't necessarily have large impacts on request latency, but if load varies dramatically over time or the app will be periodically restarted, then each time the ThreadPool is likely to enter a period of starvation where it's slowly increasing threads and delivering poor request latency. Each thread also consumes memory, so reducing the total number of threads needed provides another benefit. + +Starting in .NET 6, ThreadPool heuristics were modified to scale up the number of ThreadPool threads much faster in response to certain blocking Task APIs. ThreadPool starvation can still occur with these APIs, but the duration is much briefer than it was with older .NET versions because the runtime responds more quickly. Run Bombardier again with the `api/diagscenario/taskwait` endpoint: + +```dotnetcli +bombardier-windows-amd64.exe https://localhost:5001/api/diagscenario/taskwait -d 120s +``` + +On .NET 6 you should observe the pool increase the thread count more quickly than before and then stabilize at a high number of threads. ThreadPool starvation is occurring while the thread count is climbing. + +## Resolving ThreadPool starvation + +To eliminate ThreadPool starvation, ThreadPool threads need to remain unblocked so that they're available to handle incoming work items. There are two ways to determine what each thread was doing, either using the [dotnet-stack](dotnet-stack.md) tool or capturing a dump with [dotnet-dump](dotnet-dump.md) that can be viewed in [Visual Studio](/visualstudio/debugger/using-dump-files). dotnet-stack can be faster because it shows the thread stacks immediately on the console, but Visual Studio dump debugging offers better visualizations that map frames to source, Just My Code can filter out runtime implementation frames, and the Parallel Stacks feature can help group large numbers of threads with similar stacks. This tutorial shows the dotnet-stack option. See the [diagnosing ThreadPool starvation tutorial video](/shows/on-net/diagnosing-thread-pool-exhaustion-issues-in-net-core-apps) for an example of investigating the thread stacks using Visual Studio. + +Run Bombardier again to put the web server under load: + +```dotnetcli +bombardier-windows-amd64.exe https://localhost:5001/api/diagscenario/taskwait -d 120s +``` + +Then run dotnet-stack to see the thread stack traces: + +```dotnetcli +dotnet-stack report -n DiagnosticScenarios +``` + +You should see a long output containing a large number of stacks, many of which look like this: + +```dotnetcli +Thread (0x25968): + [Native Frames] + System.Private.CoreLib.il!System.Threading.ManualResetEventSlim.Wait(int32,value class System.Threading.CancellationToken) + System.Private.CoreLib.il!System.Threading.Tasks.Task.SpinThenBlockingWait(int32,value class System.Threading.CancellationToken) + System.Private.CoreLib.il!System.Threading.Tasks.Task.InternalWaitCore(int32,value class System.Threading.CancellationToken) + System.Private.CoreLib.il!System.Threading.Tasks.Task`1[System.__Canon].GetResultCore(bool) + DiagnosticScenarios!testwebapi.Controllers.DiagScenarioController.TaskWait() + Anonymously Hosted DynamicMethods Assembly!dynamicClass.lambda_method1(pMT: 00007FF7A8CBF658,class System.Object,class System.Object[]) + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+SyncObjectResultExecutor.Execute(class Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultTypeMapper,class Microsoft.Extensions.Internal.ObjectMethodExecutor,class System.Object,class System.Object[]) + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(value class State&,value class Scope&,class System.Object&,bool&) + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(value class State&,value class Scope&,class System.Object&,bool&) + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(value class State&,value class Scope&,class System.Object&,bool&) + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(value class State&,value class Scope&,class System.Object&,bool&) + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeAsync() + Microsoft.AspNetCore.Mvc.Core.il!Microsoft.AspNetCore.Mvc.Routing.ControllerRequestDelegateFactory+<>c__DisplayClass10_0.b__0(class Microsoft.AspNetCore.Http.HttpContext) + Microsoft.AspNetCore.Routing.il!Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(class Microsoft.AspNetCore.Http.HttpContext) + Microsoft.AspNetCore.Authorization.Policy.il!Microsoft.AspNetCore.Authorization.AuthorizationMiddleware+d__6.MoveNext() + System.Private.CoreLib.il!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start(!!0&) + Microsoft.AspNetCore.Authorization.Policy.il!Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(class Microsoft.AspNetCore.Http.HttpContext) + Microsoft.AspNetCore.HttpsPolicy.il!Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware.Invoke(class Microsoft.AspNetCore.Http.HttpContext) + Microsoft.AspNetCore.HttpsPolicy.il!Microsoft.AspNetCore.HttpsPolicy.HstsMiddleware.Invoke(class Microsoft.AspNetCore.Http.HttpContext) + Microsoft.AspNetCore.HostFiltering.il!Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware.Invoke(class Microsoft.AspNetCore.Http.HttpContext) + Microsoft.AspNetCore.Server.Kestrel.Core.il!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol+d__223`1[System.__Canon].MoveNext() + System.Private.CoreLib.il!System.Threading.ExecutionContext.RunInternal(class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object) + System.Private.CoreLib.il!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.Threading.Tasks.VoidTaskResult,Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol+d__223`1[System.__Canon]].MoveNext(class System.Threading.Thread) + System.Private.CoreLib.il!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(class System.Runtime.CompilerServices.IAsyncStateMachineBox,bool) + System.Private.CoreLib.il!System.Threading.Tasks.Task.RunContinuations(class System.Object) + System.IO.Pipelines.il!System.IO.Pipelines.StreamPipeReader+<g__Core|36_0>d.MoveNext() + System.Private.CoreLib.il!System.Threading.ExecutionContext.RunInternal(class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object) + System.Private.CoreLib.il!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.IO.Pipelines.ReadResult,System.IO.Pipelines.StreamPipeReader+<g__Core|36_0>d].MoveNext(class System.Threading.Thread) + System.Private.CoreLib.il!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(class System.Runtime.CompilerServices.IAsyncStateMachineBox,bool) + System.Private.CoreLib.il!System.Threading.Tasks.Task.RunContinuations(class System.Object) + System.Private.CoreLib.il!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[System.Int32].SetExistingTaskResult(class System.Threading.Tasks.Task`1,!0) + System.Net.Security.il!System.Net.Security.SslStream+d__186`1[System.Net.Security.AsyncReadWriteAdapter].MoveNext() + System.Private.CoreLib.il!System.Threading.ExecutionContext.RunInternal(class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object) + System.Private.CoreLib.il!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.Int32,System.Net.Security.SslStream+d__186`1[System.Net.Security.AsyncReadWriteAdapter]].MoveNext(class System.Threading.Thread) + Microsoft.AspNetCore.Server.Kestrel.Core.il!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.DuplexPipeStream+d__27.MoveNext() + System.Private.CoreLib.il!System.Threading.ExecutionContext.RunInternal(class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object) + System.Private.CoreLib.il!System.Threading.ThreadPoolWorkQueue.Dispatch() + System.Private.CoreLib.il!System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() +``` + +The frames at the bottom of these stacks indicate that these threads are ThreadPool threads: + +```dotnetcli + System.Private.CoreLib.il!System.Threading.ThreadPoolWorkQueue.Dispatch() + System.Private.CoreLib.il!System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() +``` + +And the frames near the top reveal that the thread is blocked on a call to `GetResultCore(bool)` from the DiagnosticScenarioController.TaskWait() function: + +```dotnetcli +Thread (0x25968): + [Native Frames] + System.Private.CoreLib.il!System.Threading.ManualResetEventSlim.Wait(int32,value class System.Threading.CancellationToken) + System.Private.CoreLib.il!System.Threading.Tasks.Task.SpinThenBlockingWait(int32,value class System.Threading.CancellationToken) + System.Private.CoreLib.il!System.Threading.Tasks.Task.InternalWaitCore(int32,value class System.Threading.CancellationToken) + System.Private.CoreLib.il!System.Threading.Tasks.Task`1[System.__Canon].GetResultCore(bool) + DiagnosticScenarios!testwebapi.Controllers.DiagScenarioController.TaskWait() +``` + +Now you can navigate to the code for this controller in the sample app's *Controllers/DiagnosticScenarios.cs* file to see that it's calling an async API without using `await`. This is the [sync-over-async](https://devblogs.microsoft.com/pfxteam/should-i-expose-synchronous-wrappers-for-asynchronous-methods/) code pattern, which is known to block threads and is the most common cause of ThreadPool starvation. + +```csharp +public ActionResult TaskWait() +{ + // ... + Customer c = PretendQueryCustomerFromDbAsync("Dana").Result; + return "success:taskwait"; +} + +In this case the code can be readily changed to use the async/await instead as shown in the TaskAsyncWait() endpoint. Using await allows the current thread to service other workitems while the database query is in progress. When the database lookup is complete a ThreadPool thread will resume execution. This way no thread is blocked in the code during each request: + +```csharp +public async Task> TaskAsyncWait() +{ + // ... + Customer c = await PretendQueryCustomerFromDbAsync("Dana"); + return "success:taskasyncwait"; +} + +Running Bombadier to send load to the `api/diagscenario/taskasyncwait` endpoint shows that the ThreadPool thread count stays much lower and average latency remains near 500ms when using the async/await approach: + +```dotnetcli +>bombardier-windows-amd64.exe https://localhost:5001/api/diagscenario/taskasyncwait +Bombarding https://localhost:5001/api/diagscenario/taskasyncwait for 10s using 125 connection(s) +[=============================================================================================] 10s +Done! +Statistics Avg Stdev Max + Reqs/sec 227.92 274.27 1263.48 + Latency 532.58ms 58.64ms 1.14s + HTTP codes: + 1xx - 0, 2xx - 2390, 3xx - 0, 4xx - 0, 5xx - 0 + others - 0 + Throughput: 98.81KB/s +``` diff --git a/docs/core/diagnostics/diagnostic-port.md b/docs/core/diagnostics/diagnostic-port.md index a4aad45abb2d5..14ed60acf0ead 100644 --- a/docs/core/diagnostics/diagnostic-port.md +++ b/docs/core/diagnostics/diagnostic-port.md @@ -5,19 +5,25 @@ ms.date: 4/11/2022 ms.topic: overview --- -# Diagnostic Port +# Diagnostic port **This article applies to: ✔️** .NET Core 3.1 and later versions -The .NET Core runtime exposes a service endpoint that allows other processes to send diagnostic commands and receive responses over an [IPC channel](https://en.wikipedia.org/wiki/Inter-process_communication). This endpoint is called a diagnostic port. Some of the commands that can be sent to the diagnostic port are capturing a memory dump, starting an [EventPipe](./eventpipe.md) trace, or requesting the command-line used to launch the app. The diagnostic port supports different transports depending on platform. Currently both the CoreCLR and Mono runtime implementations use Named Pipes on Windows and Unix Domain Sockets on Linux and macOS. The Mono runtime implementation on Android, iOS, and tvOS uses TCP/IP. The channel uses a [custom binary protocol](https://github.com/dotnet/diagnostics/blob/main/documentation/design-docs/ipc-protocol.md). Most developers will never directly interact with the underlying channel and protocol, but rather will use GUI or CLI tools that communicate on their behalf. For example the [dotnet-dump](./dotnet-dump.md) and [dotnet-trace](./dotnet-trace.md) tools abstract sending protocol commands to capture dumps and start traces. For developers that want to write custom tooling the [Microsoft.Diagnsotics.NETCore.Client NuGet package](./diagnostics-client-library.md) provides a .NET API abstraction of the underlying transport and protocol. +The .NET Core runtime exposes a service endpoint that allows other processes to send diagnostic commands and receive responses over an [IPC channel](https://en.wikipedia.org/wiki/Inter-process_communication). This endpoint is called a *diagnostic port*. Commands can be sent to the diagnostic port to: -## Security Considerations +- Capture a memory dump. +- Start an [EventPipe](./eventpipe.md) trace. +- Request the command-line used to launch the app. + +The diagnostic port supports different transports depending on platform. Currently both the CoreCLR and Mono runtime implementations use Named Pipes on Windows and Unix Domain Sockets on Linux and macOS. The Mono runtime implementation on Android, iOS, and tvOS uses TCP/IP. The channel uses a [custom binary protocol](https://github.com/dotnet/diagnostics/blob/main/documentation/design-docs/ipc-protocol.md). Most developers will never directly interact with the underlying channel and protocol, but rather will use GUI or CLI tools that communicate on their behalf. For example, the [dotnet-dump](./dotnet-dump.md) and [dotnet-trace](./dotnet-trace.md) tools abstract sending protocol commands to capture dumps and start traces. For developers that want to write custom tooling, the [Microsoft.Diagnsotics.NETCore.Client NuGet package](./diagnostics-client-library.md) provides a .NET API abstraction of the underlying transport and protocol. + +## Security considerations The diagnostic port exposes sensitive information about a running application. If an untrusted user gains access to this channel they could observe detailed program state, including any secrets that are in memory, and arbitrarily modify the execution of the program. On the CoreCLR runtime, the default diagnostic port is configured to only be accessible by the same user account that launched the app or by an account with super-user permissions. If your security model does not trust other processes with the same user account credentials, all diagnostic ports can be disabled by setting environment variable `DOTNET_EnableDiagnostics=0`. Doing this will block your ability to use external tooling such as .NET debugging or any of the dotnet-* diagnostic tools. [!INCLUDE [complus-prefix](../../../includes/complus-prefix.md)] -## Default Diagnostic Port +## Default diagnostic port On Windows, Linux, and macOS, the runtime has one diagnostic port open by default at a well-known endpoint. This is the port that the dotnet-* diagnostic tools are connecting to automatically when they haven't been explicitly configured to use an alternate port. The endpoint is: @@ -26,11 +32,11 @@ On Windows, Linux, and macOS, the runtime has one diagnostic port open by defaul `{pid}` is the process id written in decimal, `{temp}` is the `TMPDIR` environment variable or the value `/tmp` if `TMPDIR` is undefined/empty, and `{disambiguation_key}` is the process start time written in decimal. On macOS and NetBSD, the process start time is number of seconds since UNIX epoch time and on all other platforms it is jiffies since boot time. -## Suspending the runtime at startup +## Suspend the runtime at startup -By default the runtime executes managed code as soon as it starts, regardless whether any diagnostic tools have connected to the diagnostic port. Sometime it is useful to have the runtime wait to run managed code until after a diagnostic tool is connected, to observe the initial program behavior. Setting environment variable `DOTNET_DefaultDiagnosticPortSuspend=1` causes the runtime to wait until a tool connects to the default port. If no tool is attached after several seconds, the runtime prints a warning message to the console explaining that it is still waiting for a tool to attach. +By default, the runtime executes managed code as soon as it starts, regardless whether any diagnostic tools have connected to the diagnostic port. Sometimes it is useful to have the runtime wait to run managed code until after a diagnostic tool is connected, to observe the initial program behavior. Setting environment variable `DOTNET_DefaultDiagnosticPortSuspend=1` causes the runtime to wait until a tool connects to the default port. If no tool is attached after several seconds, the runtime prints a warning message to the console explaining that it is still waiting for a tool to attach. -## Configuring additional diagnostic ports +## Configure additional diagnostic ports > [!IMPORTANT] > This works for apps running .NET 5 or later only. @@ -56,6 +62,6 @@ The complete syntax for a port is `address[,(listen|connect)][,(suspend|nosuspen Tools such as [dotnet-dump](./dotnet-dump.md), [dotnet-counters](./dotnet-counters.md), or [dotnet-trace](./dotnet-trace.md) all support `collect` or `monitor` verbs which communicate to a .NET app via the diagnostic port. When these tools are using the `--processId` argument the tool automatically computes the default diagnostic port address and connects to it. When specifying the `--diagnostic-port` argument, the tool listens at the given address and you should use the `DOTNET_DiagnosticPorts` environment variable to configure your app to connect. For a complete example with dotnet-counters, see [Using the Diagnostic Port](./dotnet-counters.md#using-diagnostic-port). -## Using ds-router to proxy the diagnostic port +## Use ds-router to proxy the diagnostic port All of the dotnet-* diagnostic tools expect to connect to a diagnostic port that is a local Named Pipe or Unix Domain Socket. Mono often runs on isolated hardware or in emulators that need a proxy over TCP to become accessible. The [dotnet-dsrouter tool](./dotnet-dsrouter.md) can proxy a local Named Pipe or Unix Domain Socket to TCP so that the tools can be used in those environments. For more information, see [dotnet-dsrouter](./dotnet-dsrouter.md). diff --git a/docs/core/diagnostics/diagnostics-in-containers.md b/docs/core/diagnostics/diagnostics-in-containers.md index fc61f6511d58c..cbef5ed20d137 100644 --- a/docs/core/diagnostics/diagnostics-in-containers.md +++ b/docs/core/diagnostics/diagnostics-in-containers.md @@ -10,28 +10,11 @@ The same diagnostics tools that are useful for diagnosing .NET Core issues in ot ## Using .NET CLI tools in a container -**These tools apply to: ✔️** .NET Core 3.0 SDK and later versions +**These tools apply to: ✔️** .NET Core 3.1 SDK and later versions -The .NET Core global CLI diagnostic tools ([`dotnet-counters`](dotnet-counters.md), [`dotnet-dump`](dotnet-dump.md), [`dotnet-gcdump`](dotnet-gcdump.md), and [`dotnet-trace`](dotnet-trace.md)) are designed to work in a wide variety of environments and should all work directly in Docker containers. Because of this, these tools are the preferred method of collecting diagnostic information for .NET Core scenarios targeting .NET Core 3.0 or above (or 3.1 or above in the case of `dotnet-gcdump`) in containers. +The .NET Core global CLI diagnostic tools ([`dotnet-counters`](dotnet-counters.md), [`dotnet-dump`](dotnet-dump.md), [`dotnet-gcdump`](dotnet-gcdump.md), and [`dotnet-trace`](dotnet-trace.md)) are designed to work in a wide variety of environments and should all work directly in Docker containers. Because of this, these tools are the preferred method of collecting diagnostic information for .NET Core scenarios targeting .NET Core 3.1 or later in containers. -The only complicating factor of using these tools in a container is that they are installed with the .NET SDK and many Docker containers run without the .NET SDK present. One easy solution to this problem is to install the tools in the initial Docker image. The tools don't need the .NET SDK to run, only to be installed. Therefore, it's possible to create a Dockerfile with a [multi-stage build](https://docs.docker.com/develop/develop-images/multistage-build/) that installs the tools in a build stage (where the .NET SDK is present) and then copies the binaries into the final image. The only downside to this approach is increased Docker image size. - -```dockerfile -# In build stage -# Install desired .NET CLI diagnostics tools -RUN dotnet tool install --tool-path /tools dotnet-trace -RUN dotnet tool install --tool-path /tools dotnet-counters -RUN dotnet tool install --tool-path /tools dotnet-dump - -... - -# In final stage -# Copy diagnostics tools -WORKDIR /tools -COPY --from=build /tools . -``` - -Alternatively, the .NET SDK can be installed in a container when needed in order to install the CLI tools. Be aware that installing the .NET SDK will have the side-effect of reinstalling the .NET runtime. So be sure to install the version of the SDK that matches the runtime present in the container. +You can also install these tools without the .NET SDK by downloading the single-file variants from the links in the previous paragraph. These installs require a global install of the .NET runtime version 3.1 or later, which you can acquire following any of the prescribed methods in the [.NET installation documentation](../install/index.yml) or by consuming any of the official runtime containers. ### Using .NET Core global CLI tools in a sidecar container diff --git a/docs/core/diagnostics/diagnosticsource-diagnosticlistener.md b/docs/core/diagnostics/diagnosticsource-diagnosticlistener.md new file mode 100644 index 0000000000000..5ff34080134dc --- /dev/null +++ b/docs/core/diagnostics/diagnosticsource-diagnosticlistener.md @@ -0,0 +1,251 @@ +--- +title: DiagnosticSource and DiagnosticListener +description: An overview of DiagnosticSource/DiagnosticListener including guidance on logging events, instrumenting code, and consuming data. +ms.date: 05/12/2022 +--- +# DiagnosticSource and DiagnosticListener + +**This article applies to: ✔️** .NET Core 3.1 and later versions **✔️** .NET Framework 4.5 and later versions + + is a module that allows code to be instrumented for production-time +logging of rich data payloads for consumption within the process that was instrumented. At run time, consumers can dynamically discover +data sources and subscribe to the ones of interest. was designed to allow in-process +tools to access rich data. When using , the consumer is assumed +to be within the same process and as a result, non-serializable types (for example, `HttpResponseMessage` or `HttpContext`) can be passed, +giving customers plenty of data to work with. + +## Getting Started with DiagnosticSource + +This walkthrough shows how to create a DiagnosticSource event and instrument code with . +It then explains how to consume the event by finding interesting DiagnosticListeners, subscribing to their events, and decoding event data payloads. +It finishes by describing *filtering*, which allows only specific events to pass through the system. + +## DiagnosticSource Implementation + +You will work with the following code. This code is an *HttpClient* class with a `SendWebRequest` method that sends an HTTP request to the URL and receives a reply. + +:::code language="csharp" source="snippets/diagnosticsource/csharp/Program.cs" id="WholeProgram"::: + +Running the provided implementation prints to the console. + +```console +New Listener discovered: System.Net.Http +Data received: RequestStart: { Url = https://docs.microsoft.com/dotnet/core/diagnostics/ } +``` + +## Log an event + +The `DiagnosticSource` type is an abstract base class that defines the methods needed to log events. The class that holds the implementation is `DiagnosticListener`. +The first step in instrumenting code with `DiagnosticSource` is to create a +`DiagnosticListener`. For example: + +:::code language="csharp" source="snippets/diagnosticsource/csharp/Program.cs" id="snippit1"::: + +Notice that `httpLogger` is typed as a `DiagnosticSource`. +That's because this code +only writes events and thus is only concerned with the `DiagnosticSource` methods that +the `DiagnosticListener` implements. `DiagnosticListeners` are given names when they are created, +and this name should be the name of a logical grouping of related events (typically the component). +Later, this name is used to find the Listener and subscribe to any of its events. +Thus the event names only need to be unique within a component. + +------------------------------------------- + +The `DiagnosticSource` logging +interface consists of two methods: + +```csharp + bool IsEnabled(string name) + void Write(string name, object value); +``` + +This is instrument site specific. You need to check the instrumentation site to see what types are passed into `IsEnabled`. This provides you with the information to know what to cast the payload to. + +A typical call site will look like: + +:::code language="csharp" source="snippets/diagnosticsource/csharp/Program.cs" id="snippit3"::: + +Every event has a `string` name (for example, `RequestStart`), and exactly one `object` as a payload. +If you need to send more than one item, you can do so by creating an `object` with properties to represent all its information. C#'s [anonymous type](../../csharp/fundamentals/types/anonymous-types.md) +feature is typically used to create a type to pass 'on the fly', and makes this scheme very +convenient. At the instrumentation site, you must guard the call to `Write()` with an `IsEnabled()` check on +the same event name. Without this check, even when the instrumentation is inactive, the rules +of the C# language require all the work of creating the payload `object` and calling `Write()` to be +done, even though nothing is actually listening for the data. By guarding the `Write()` call, you +make it efficient when the source is not enabled. + +Combining everything you have: + +:::code language="csharp" source="snippets/diagnosticsource/csharp/Program.cs" id="snippit4"::: + +------------------------------------------- + +### Discovery of DiagnosticListeners + +The first step in receiving events is to discover which `DiagnosticListeners` you are +interested in. `DiagnosticListener` supports a way of discovering `DiagnosticListeners` that are +active in the system at run time. The API to accomplish this is the property. + +Implement an `Observer` class that inherits from the `IObservable` interface, which is the 'callback' version of the `IEnumerable` interface. You can learn more about it at the [Reactive Extensions](https://github.com/dotnet/reactive) site. +An `IObserver` has three callbacks, `OnNext`, `OnComplete`, +and `OnError`. An `IObservable` has a single method called `Subscribe` that gets passed one of these +Observers. Once connected, the Observer gets callbacks (mostly `OnNext` callbacks) when things +happen. + +A typical use of the `AllListeners` static property looks like this: + +:::code language="csharp" source="snippets/diagnosticsource/csharp/Program.cs" id="snippit5"::: + +This code creates a callback delegate and, using the `AllListeners.Subscribe` method, requests +that the delegate be called for every active `DiagnosticListener` in the system. The decision of whether or not to subscribe to the listener +is made by inspecting its name. The code above is looking for the 'System.Net.Http' listener that you created previously. + +Like all calls to `Subscribe()`, this one returns an `IDisposable` that represents the subscription itself. +Callbacks will continue to happen as long as nothing calls `Dispose()` on this subscription object. +The code example never calls `Dispose()`, so it will receive callbacks forever. + +When you subscribe to `AllListeners`, you get a callback for ALL ACTIVE `DiagnosticListeners`. +Thus, upon subscribing, you get a flurry of callbacks for all existing `DiagnosticListeners`, and as new ones +are created, you receive a callback for those as well. You receive a complete list of everything it's possible +to subscribe to. + +#### Subscribe to DiagnosticListeners + +A `DiagnosticListener` implements the `IObservable>` interface, so you can +call `Subscribe()` on it as well. The following code shows how to fill out the previous example: + +:::code language="csharp" source="snippets/diagnosticsource/csharp/Program.cs" id="snippit6"::: + +In this example, after finding the 'System.Net.Http' `DiagnosticListener`, an action is created that +prints out the name of the listener, event, and `payload.ToString()`. + +> [!NOTE] +> `DiagnosticListener` implements `IObservable>`. This means + on each callback we get a `KeyValuePair`. The key of this pair is the name of the event + and the value is the payload `object`. The example simply logs this information + to the console. + +It's important to keep track of subscriptions to the `DiagnosticListener`. In the previous code, the +`networkSubscription` variable remembers this. If you form another `creation`, you must +unsubscribe the previous listener and subscribe to the new one. + +The `DiagnosticSource`/`DiagnosticListener` code is thread safe, but the +callback code also needs to be thread safe. To ensure the callback code is thread safe, locks are used. It is possible to create two `DiagnosticListeners` +with the same name at the same time. To avoid race conditions, updates of shared variables are performed under the protection of a lock. + +Once the previous code is run, the next time a `Write()` is done on 'System.Net.Http' `DiagnosticListener` +the information will be logged to the console. + +Subscriptions are independent of one another. As a result, other code +can do exactly the same thing as the code example and generate two 'pipes' of the logging +information. + +#### Decode Payloads + +The `KeyvaluePair` that is passed to the callback has the event name and payload, but the payload is typed simply as +an `object`. There are two ways of getting more specific data: + +If the payload is a well known type (for example, a `string`, or an `HttpMessageRequest`), then you can simply +cast the `object` to the expected type (using the `as` operator so as not to cause an exception if +you are wrong) and then access the fields. This is very efficient. + +Use reflection API. For example, assume the following method is present. + +```csharp + /// Define a shortcut method that fetches a field of a particular name. + static class PropertyExtensions + { + static object GetProperty(this object _this, string propertyName) + { + return _this.GetType().GetTypeInfo().GetDeclaredProperty(propertyName)?.GetValue(_this); + } + } +``` + +To decode the payload more fully, you could replace the `listener.Subscribe()` call with the following code. + +```csharp + networkSubscription = listener.Subscribe(delegate(KeyValuePair evnt) { + var eventName = evnt.Key; + var payload = evnt.Value; + if (eventName == "RequestStart") + { + var url = payload.GetProperty("Url") as string; + var request = payload.GetProperty("Request"); + Console.WriteLine("Got RequestStart with URL {0} and Request {1}", url, request); + } + }); +``` + +Note that using reflection is relatively expensive. However, using reflection is the only +option if the payloads were generated using anonymous types. This overhead can be reduced by +making fast, specialized property fetchers using either [PropertyInfo.GetMethod.CreateDelegate()](xref:System.Reflection.MethodInfo.CreateDelegate%2A) or +xref namespace, but that's beyond the scope of this article. +(For an example of a fast, delegate-based property fetcher, see the [PropertySpec](https://github.com/dotnet/runtime/blob/6de7147b9266d7730b0d73ba67632b0c198cb11e/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs#L1235) +class used in the `DiagnosticSourceEventSource`.) + +#### Filtering + +In the previous example, the code uses the `IObservable.Subscribe()` method to hook up the callback. This +causes all events to be given to the callback. However, `DiagnosticListener` has overloads of +`Subscribe()` that allow the controller to control which events are given. + +The `listener.Subscribe()` call in the previous example can be replaced with the following code to demonstrate. + +```csharp + // Create the callback delegate. + Action> callback = (KeyValuePair evnt) => + Console.WriteLine("From Listener {0} Received Event {1} with payload {2}", networkListener.Name, evnt.Key, evnt.Value.ToString()); + + // Turn it into an observer (using the Observer Class above). + Observer> observer = new Observer>(callback); + + // Create a predicate (asks only for one kind of event). + Predicate predicate = (string eventName) => eventName == "RequestStart"; + + // Subscribe with a filter predicate. + IDisposable subscription = listener.Subscribe(observer, predicate); + + // subscription.Dispose() to stop the callbacks. +``` + +This efficiently subscribes to only the 'RequestStart' events. All other events will cause the `DiagnosticSource.IsEnabled()` +method to return `false` and thus be efficiently filtered out. + +##### Context-based filtering + +Some scenarios require advanced filtering based on extended context. +Producers can call overloads and supply additional event properties as shown in the following code. + +```csharp +//aRequest and anActivity are the current request and activity about to be logged. +if (httpLogger.IsEnabled("RequestStart", aRequest, anActivity)) + httpLogger.Write("RequestStart", new { Url="http://clr", Request=aRequest }); +``` + +The next code example demonstrates that consumers can use such properties to filter events more precisely. + +```csharp + // Create a predicate (asks only for Requests for certains URIs) + Func predicate = (string eventName, object context, object activity) => + { + if (eventName == "RequestStart") + { + if (context is HttpRequestMessage request) + { + return IsUriEnabled(request.RequestUri); + } + } + return false; + } + + // Subscribe with a filter predicate + IDisposable subscription = listener.Subscribe(observer, predicate); +``` + +Producers are not aware of the filter a consumer has provided. `DiagnosticListener` +will invoke the provided filter, omitting additional arguments if necessary, thus the filter +should expect to receive a `null` context. +If a producer calls `IsEnabled()` with event name and context, those calls are enclosed in an overload that takes +only the event name. Consumers must ensure that their filter allows events without context +to pass through. diff --git a/docs/core/diagnostics/dotnet-counters.md b/docs/core/diagnostics/dotnet-counters.md index aac421bdeaef8..661b528c2c5ac 100644 --- a/docs/core/diagnostics/dotnet-counters.md +++ b/docs/core/diagnostics/dotnet-counters.md @@ -6,7 +6,7 @@ ms.topic: reference --- # Investigate performance counters (dotnet-counters) -**This article applies to:** ✔️ .NET Core 3.0 SDK and later versions +**This article applies to:** ✔️ `dotnet-counters` version 3.0.47001 and later versions ## Install @@ -417,7 +417,8 @@ dotnet-counters monitor [-h|--help] [-p|--process-id] [-n|--name] [--diagnostic- ## dotnet-counters ps -Display a list of dotnet processes that can be monitored. + Lists the dotnet processes that can be monitored by `dotnet-counters`. + `dotnet-counters` version 6.0.320703 and later, also display the command-line arguments that each process was started with, if available. ### Synopsis @@ -427,11 +428,13 @@ dotnet-counters ps [-h|--help] ### Example +Suppose you start a long-running app using the command ```dotnet run --configuration Release```. In another window, you run the ```dotnet-counters ps``` command. The output you'll see is as follows. The command-line arguments, if any, are shown in `dotnet-counters` version 6.0.320703 and later. + ```console > dotnet-counters ps - 15683 WebApi /home/user/repos/WebApi/WebApi - 16324 dotnet /usr/local/share/dotnet/dotnet + 21932 dotnet C:\Program Files\dotnet\dotnet.exe run --configuration Release + 36656 dotnet C:\Program Files\dotnet\dotnet.exe ``` ## Using diagnostic port diff --git a/docs/core/diagnostics/dotnet-dump.md b/docs/core/diagnostics/dotnet-dump.md index 87d35aeb086b5..ebf1c2ab4fd91 100644 --- a/docs/core/diagnostics/dotnet-dump.md +++ b/docs/core/diagnostics/dotnet-dump.md @@ -6,7 +6,7 @@ ms.topic: reference --- # Dump collection and analysis utility (dotnet-dump) -**This article applies to:** ✔️ .NET Core 3.0 SDK and later versions +**This article applies to:** ✔️ `dotnet-dump` version 3.0.47001 and later versions > [!NOTE] > `dotnet-dump` for macOS is only supported with .NET 5 and later versions. @@ -62,6 +62,7 @@ The `dotnet-dump` global tool is a way to collect and analyze Windows and Linux | ------------------------------------------- | | [dotnet-dump collect](#dotnet-dump-collect) | | [dotnet-dump analyze](#dotnet-dump-analyze) | +| [dotnet-dump ps](#dotnet-dump-ps) | ## dotnet-dump collect @@ -186,6 +187,28 @@ dotnet-dump analyze [-h|--help] [-c|--command] > [!NOTE] > Additional details can be found in [SOS Debugging Extension for .NET](sos-debugging-extension.md). +## dotnet-dump ps + + Lists the dotnet processes that dumps can be collected from. + `dotnet-dump` version 6.0.320703 and later versions also display the command-line arguments that each process was started with, if available. + +### Synopsis + +```console +dotnet-dump ps [-h|--help] +``` + +### Example + +Suppose you start a long-running app using the command ```dotnet run --configuration Release```. In another window, you run the ```dotnet-dump ps``` command. The output you'll see is as follows. The command-line arguments, if any, are shown in `dotnet-dump` version 6.0.320703 and later. + +```console +> dotnet-dump ps + + 21932 dotnet C:\Program Files\dotnet\dotnet.exe run --configuration Release + 36656 dotnet C:\Program Files\dotnet\dotnet.exe +``` + ## Using `dotnet-dump` The first step is to collect a dump. This step can be skipped if a core dump has already been generated. The operating system or the .NET Core runtime's built-in [dump generation feature](https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/xplat-minidump-generation.md) can each create core dumps. diff --git a/docs/core/diagnostics/dotnet-gcdump.md b/docs/core/diagnostics/dotnet-gcdump.md index 907d27d560d9b..2dfd2c1f883d5 100644 --- a/docs/core/diagnostics/dotnet-gcdump.md +++ b/docs/core/diagnostics/dotnet-gcdump.md @@ -6,7 +6,7 @@ ms.topic: reference --- # Heap analysis tool (dotnet-gcdump) -**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions +**This article applies to:** ✔️ `dotnet-gcdump` version 3.1.57502 and later versions ## Install @@ -62,6 +62,14 @@ You can collect multiple `.gcdump`s and open them simultaneously in Visual Studi - **`-h|--help`** Shows command-line help. + +## Commands + +| Command | +|------------------------------------------------ | +| [dotnet-gcdump collect](#dotnet-gcdump-collect) | +| [dotnet-gcdump ps](#dotnet-gcdump-ps) | +| [dotnet-gcdump report](#dotnet-gcdump-report-gcdump_filename) | ## `dotnet-gcdump collect` @@ -110,12 +118,23 @@ dotnet-gcdump collect [-h|--help] [-p|--process-id ] [-o|--output dotnet-gcdump ps + + 21932 dotnet C:\Program Files\dotnet\dotnet.exe run --configuration Release + 36656 dotnet C:\Program Files\dotnet\dotnet.exe ``` ## `dotnet-gcdump report ` @@ -150,4 +169,12 @@ dotnet-gcdump report [-h|--help] [-p|--process-id ] [-t|--report-type ## dotnet-stack ps - Lists the dotnet processes that traces can be collected from. + Lists the dotnet processes that stack traces can be collected from. + `dotnet-stack` version 6.0.320703 and later versions also display the command-line arguments that each process was started with, if available. ### Synopsis @@ -92,6 +93,17 @@ dotnet-stack report -p|--process-id dotnet-stack ps [-h|--help] ``` +### Example + +Suppose you start a long-running app using the command ```dotnet run --configuration Release```. In another window, you run the ```dotnet-stack ps``` command. The output you'll see is as follows. The command-line arguments, if any, are shown in `dotnet-stack` version 6.0.320703 and later. + +```console +> dotnet-stack ps + + 21932 dotnet C:\Program Files\dotnet\dotnet.exe run --configuration Release + 36656 dotnet C:\Program Files\dotnet\dotnet.exe +``` + ## Report managed stacks with dotnet-stack To report managed stacks using `dotnet-stack`: diff --git a/docs/core/diagnostics/dotnet-trace.md b/docs/core/diagnostics/dotnet-trace.md index 09de39116ccba..5a7ba07ed3ff9 100644 --- a/docs/core/diagnostics/dotnet-trace.md +++ b/docs/core/diagnostics/dotnet-trace.md @@ -6,7 +6,7 @@ ms.topic: reference --- # dotnet-trace performance analysis utility -**This article applies to:** ✔️ .NET Core 3.0 SDK and later versions +**This article applies to:** ✔️ `dotnet-trace` 3.0.47001 and later versions ## Install @@ -194,16 +194,16 @@ dotnet-trace collect [--buffersize ] [--clreventlevel ] [-- Shows the input and output streams of a launched child process in the current console. > [!NOTE] -> Stopping the trace may take a long time (up to minutes) for large applications. The runtime needs to send over the type cache for all managed code that was captured in the trace. -> [!NOTE] -> On Linux and macOS, this command expects the target application and `dotnet-trace` to share the same `TMPDIR` environment variable. Otherwise, the command will time out. +> - Stopping the trace may take a long time (up to minutes) for large applications. The runtime needs to send over the type cache for all managed code that was captured in the trace. -> [!NOTE] -> To collect a trace using `dotnet-trace`, it needs to be run as the same user as the user running target process or as root. Otherwise, the tool will fail to establish a connection with the target process. +> - On Linux and macOS, this command expects the target application and `dotnet-trace` to share the same `TMPDIR` environment variable. Otherwise, the command will time out. -> [!NOTE] -> If you see an error message similar to the following one: `[ERROR] System.ComponentModel.Win32Exception (299): A 32 bit processes cannot access modules of a 64 bit process.`, you are trying to use `dotnet-trace` that has mismatched bitness against the target process. Make sure to download the correct bitness of the tool in the [install](#install) link. +> - To collect a trace using `dotnet-trace`, it needs to be run as the same user as the user running the target process or as root. Otherwise, the tool will fail to establish a connection with the target process. + +> - If you see an error message similar to: `[ERROR] System.ComponentModel.Win32Exception (299): A 32 bit processes cannot access modules of a 64 bit process.`, you are trying to use a version of `dotnet-trace` that has mismatched bitness against the target process. Make sure to download the correct bitness of the tool in the [install](#install) link. + +> - If you experience an unhandled exception while running `dotnet-trace collect`, this results in a broken trace. If finding the root cause of the exception is your priority, navigate to [Collect dumps on crash](dumps.md#collect-dumps-on-crash). As a result of the crash in the program, the trace is truncated when the runtime rips apart to prevent breaking other parts of the program. Even though the trace is broken, you can still open it to see what happened leading up to the failure. However, it will be missing Rundown information (this happens at the end of a trace) so stacks might be unresolved (depending on what providers were turned on). Open the trace by executing PerfView with the `/ContinueOnError` flag at the command line. The logs will also contain the location the exception was fired. ## dotnet-trace convert @@ -237,6 +237,7 @@ dotnet-trace convert [] [--format ## dotnet-trace ps Lists the dotnet processes that traces can be collected from. + `dotnet-trace` 6.0.320703 and later, also display the command-line arguments that each process was started with, if available. ### Synopsis @@ -244,6 +245,17 @@ dotnet-trace convert [] [--format dotnet-trace ps [-h|--help] ``` +### Example + +Suppose you start a long-running app using the command ```dotnet run --configuration Release```. In another window, you run the ```dotnet-trace ps``` command. The output you'll see is as follows. The command-line arguments, if available, are shown in `dotnet-trace` version 6.0.320703 and later. + +```console +> dotnet-trace ps + + 21932 dotnet C:\Program Files\dotnet\dotnet.exe run --configuration Release + 36656 dotnet C:\Program Files\dotnet\dotnet.exe +``` + ## dotnet-trace list-profiles Lists pre-built tracing profiles with a description of what providers and filters are in each profile. @@ -405,9 +417,11 @@ However, when you want to gain a finer control over the lifetime of the app bein ## View the trace captured from dotnet-trace -On Windows, *.nettrace* files can be viewed on [PerfView](https://github.com/microsoft/perfview) for analysis: For traces collected on other platforms, the trace file can be moved to a Windows machine to be viewed on PerfView. +On Windows, you can view *.nettrace* files in [Visual Studio](/visualstudio/profiling/beginners-guide-to-performance-profiling?#step-2-analyze-cpu-usage-data) or [PerfView](https://github.com/microsoft/perfview) for analysis. + +On Linux, you can view the trace by changing the output format of `dotnet-trace` to `speedscope`. Change the output file format by using the `-f|--format` option. You can choose between `nettrace` (the default option) and `speedscope`. The option `-f speedscope` will make `dotnet-trace` produce a `speedscope` file. `Speedscope` files can be opened at . -On Linux, the trace can be viewed by changing the output format of `dotnet-trace` to `speedscope`. The output file format can be changed using the `-f|--format` option - `-f speedscope` will make `dotnet-trace` produce a `speedscope` file. You can choose between `nettrace` (the default option) and `speedscope`. `Speedscope` files can be opened at . +For traces collected on non-Windows platforms, you can also move the trace file to a Windows machine to be view it in Visual Studio or PerfView. > [!NOTE] > The .NET Core runtime generates traces in the `nettrace` format. The traces are converted to speedscope (if specified) after the trace is completed. Since some conversions may result in loss of data, the original `nettrace` file is preserved next to the converted file. diff --git a/docs/core/diagnostics/eventsource-activity-ids.md b/docs/core/diagnostics/eventsource-activity-ids.md index 3ee534ebb8896..17c4fdb0a64df 100644 --- a/docs/core/diagnostics/eventsource-activity-ids.md +++ b/docs/core/diagnostics/eventsource-activity-ids.md @@ -93,7 +93,7 @@ class DemoEventSource : EventSource public void WorkStart(string requestName) => WriteEvent(1, requestName); [Event(2)] public void WorkStop() => WriteEvent(2); - + [Event(3)] public void DebugMessage(string message) => WriteEvent(3, message); } diff --git a/docs/core/diagnostics/eventsource-collect-and-view-traces.md b/docs/core/diagnostics/eventsource-collect-and-view-traces.md index 232a255c02337..7744487c95940 100644 --- a/docs/core/diagnostics/eventsource-collect-and-view-traces.md +++ b/docs/core/diagnostics/eventsource-collect-and-view-traces.md @@ -46,7 +46,7 @@ namespace EventSourceDemo public void RequestStop(int requestId) => WriteEvent(3, requestId); [Event(4, Keywords = Keywords.Startup, Level = EventLevel.Verbose)] public void DebugMessage(string message) => WriteEvent(4, message); - + public class Keywords { @@ -85,13 +85,13 @@ keyword-based filtering, and "Demo" does no keyword or level filtering. ## Visual Studio -The [Visual Studio profiler](https://docs.microsoft.com/visualstudio/profiling) supports both collecting and viewing traces. It also can view traces +The [Visual Studio profiler](/visualstudio/profiling) supports both collecting and viewing traces. It also can view traces that have been collected in advance by other tools, such as [dotnet-trace](./dotnet-trace.md). ### Collect a trace Most of Visual Studio's profiling tools use predefined sets of events that serve a particular purpose, such as analyzing CPU usage or allocations. To -collect a trace with customized events, you'll use the [Events Viewer](https://docs.microsoft.com/visualstudio/profiling/events-viewer) tool. +collect a trace with customized events, you'll use the [Events Viewer](/visualstudio/profiling/events-viewer) tool. 1. To open the Performance Profiler in Visual Studio, select **Alt**+**F2**. @@ -177,7 +177,7 @@ of that type in the table on the right. ### Learn more -To learn more about using PerfView, see the [PerfView video tutorials](https://docs.microsoft.com/shows/PerfView-Tutorial/). +To learn more about using PerfView, see the [PerfView video tutorials](/shows/PerfView-Tutorial/). ## dotnet-trace diff --git a/docs/core/diagnostics/eventsource-instrumentation.md b/docs/core/diagnostics/eventsource-instrumentation.md index 65e691d020e53..04eb229637774 100644 --- a/docs/core/diagnostics/eventsource-instrumentation.md +++ b/docs/core/diagnostics/eventsource-instrumentation.md @@ -56,6 +56,9 @@ so on. to the WriteEvent\* APIs. For WriteEvent the arguments follow the Event ID, for WriteEventWithRelatedActivityId the arguments follow the relatedActivityId. For the WriteEvent\*Core methods, the arguments must be serialized manually into the `data` parameter. +8. Event names cannot contain `<` or `>` characters. While user-defined methods also cannot contain these characters, `async` methods +will be rewritten by the compiler to contain them. To be sure these generated methods don't become events, mark all non-event methods on an +with the . ## Best practices @@ -153,7 +156,7 @@ Events that are triggered more than 1,000/sec are good candidates for a unique k EventSource requires that all event parameters can be serialized so it only accepts a limited set of types. These are: -- Primitives: bool, byte, sybte, char, short, ushort, int, uint, long, ulong, float, double, IntPtr, and UIntPtr, Guid +- Primitives: bool, byte, sbyte, char, short, ushort, int, uint, long, ulong, float, double, IntPtr, and UIntPtr, Guid decimal, string, DateTime, DateTimeOffset, TimeSpan - Enums - Structures attributed with . Only @@ -187,7 +190,7 @@ enabled. ### Setting OpCodes and Tasks -ETW has concepts of [Tasks and OpCodes](https://docs.microsoft.com/windows/win32/wes/defining-tasks-and-opcodes) +ETW has concepts of [Tasks and OpCodes](/windows/win32/wes/defining-tasks-and-opcodes) which are further mechanisms for tagging and filtering events. You can associate events with specific tasks and opcodes using the and properties. Here's an example: @@ -199,8 +202,8 @@ public sealed class CustomizedEventSource : EventSource static public CustomizedEventSource Log { get; } = new CustomizedEventSource(); [Event(1, Task = Tasks.Request, Opcode=EventOpcode.Start)] - public void RequestStart(int RequestID, string Url) - { + public void RequestStart(int RequestID, string Url) + { WriteEvent(1, RequestID, Url); } @@ -210,11 +213,11 @@ public sealed class CustomizedEventSource : EventSource WriteEvent(2, RequestID, PhaseName); } - [Event(3, Keywords = Keywords.Requests, + [Event(3, Keywords = Keywords.Requests, Task = Tasks.Request, Opcode=EventOpcode.Stop)] - public void RequestStop(int RequestID) + public void RequestStop(int RequestID) { - WriteEvent(3, RequestID); + WriteEvent(3, RequestID); } public class Tasks @@ -313,10 +316,10 @@ public sealed class OptimizedEventSource : UtilBaseEventSource { public static OptimizedEventSource Log { get; } = new OptimizedEventSource(); - [Event(1, Keywords = Keywords.Kwd1, Level = EventLevel.Informational, + [Event(1, Keywords = Keywords.Kwd1, Level = EventLevel.Informational, Message = "LogElements called {0}/{1}/{2}.")] public void LogElements(int n, short sh, long l) - { + { WriteEvent(1, n, sh, l); // Calls UtilBaseEventSource.WriteEvent } @@ -350,8 +353,8 @@ Here's an example for adding a WriteEvent overload that takes four integer argum ```C# [NonEvent] -public unsafe void WriteEvent(int eventId, int arg1, int arg2, - int arg3, int arg4) +public unsafe void WriteEvent(int eventId, int arg1, int arg2, + int arg3, int arg4) { EventData* descrs = stackalloc EventProvider.EventData[4]; diff --git a/docs/core/diagnostics/index.md b/docs/core/diagnostics/index.md index 3100137787d25..363c5c0efa234 100644 --- a/docs/core/diagnostics/index.md +++ b/docs/core/diagnostics/index.md @@ -11,23 +11,29 @@ Software doesn't always behave as you would expect, but .NET Core has tools and This article helps you find the various tools you need. -## Managed debuggers +## Debuggers -[Managed debuggers](managed-debuggers.md) allow you to interact with your program. Pausing, incrementally executing, examining, and resuming gives you insight into the behavior of your code. A debugger is the first choice for diagnosing functional problems that can be easily reproduced. +[Debuggers](managed-debuggers.md) allow you to interact with your program. Pausing, incrementally executing, examining, and resuming gives you insight into the behavior of your code. A debugger is a good choice for diagnosing functional problems that can be easily reproduced. -## Logging and tracing +## Unit testing -[Logging and tracing](logging-tracing.md) are related techniques. They refer to instrumenting code to create log files. The files record the details of what a program does. These details can be used to diagnose the most complex problems. When combined with time stamps, these techniques are also valuable in performance investigations. +[Unit testing](../testing/index.md) is a key component of continuous integration and deployment of high-quality software. Unit tests are designed to give you an early warning when you break something. -## Metrics +## Instrumentation for observability -[Metrics](metrics.md) are numerical measurements recorded over time to monitor application performance and health. Metrics are often used to -generate alerts when potential problems are detected. In normal use, metrics have very low performance overhead and are configured as -'always-on' telemetry. The .NET runtime and libraries publish many built-in metrics, and you can create new ones using metric APIs. +.NET supports industry standard instrumentation techniques using metrics, logs, and distributed traces. Instrumentation is code that is added to a software project to record what it is doing. This information can then be collected in files, databases, or in-memory and analyzed to understand how a software program is operating. This is often used in production environments to monitor for problems and diagnose them. The .NET runtime has built-in instrumentation that can be optionally enabled and APIs that allow you to add custom instrumentation specialized for your application. -## Unit testing +### Metrics -[Unit testing](../testing/index.md) is a key component of continuous integration and deployment of high-quality software. Unit tests are designed to give you an early warning when you break something. +[Metrics](metrics.md) are numerical measurements recorded over time to monitor application performance and health. Metrics are often used to generate alerts when potential problems are detected. Metrics have very low performance overhead and many services configure them as always-on telemetry. + +### Logs + +[Logging](logging-tracing.md) is a technique where code is instrumented to produce a log, a record of interesting events that occured while the program was running. Often a baseline set of log events are configured on by default and more extensive logging can be enabled on-demand to diagnose particular problems. Performance overhead is variable depending on how much data is being logged. + +### Distributed traces + +[Distributed Tracing](./distributed-tracing.md) is a specialized form of logging that helps you localize failures and performance issues within applications distributed across multiple machines or processes. This technique tracks requests through an application correlating together work done by different application components and separating it from other work the application may be doing for concurrent requests. It is possible to trace every request and sampling can be optionally employed to bound the performance overhead. ## Dumps @@ -93,6 +99,10 @@ The [dotnet-stack](dotnet-stack.md) tool allows you to quickly print the managed [Tutorial: Debug deadlock](debug-deadlock.md) shows you how to use the [dotnet-dump](dotnet-dump.md) tool to investigate threads and locks. +### Debug ThreadPool Starvation + +[Tutorial: Debug threadPool starvation](debug-threadpool-starvation.md) shows you how to use the [dotnet-counters](dotnet-counters.md) and [dotnet-stack](dotnet-stack.md) tools to investigate ThreadPool starvation. + ### Debug a StackOverflow [Tutorial: Debug a StackOverflow](debug-stackoverflow.md) demonstrates how to debug a on Linux. diff --git a/docs/core/diagnostics/logging-tracing.md b/docs/core/diagnostics/logging-tracing.md index b08b337fdf528..ba30bd8f39a9e 100644 --- a/docs/core/diagnostics/logging-tracing.md +++ b/docs/core/diagnostics/logging-tracing.md @@ -1,110 +1,55 @@ --- -title: Logging and tracing - .NET Core -description: An introduction to .NET Core logging and tracing. -ms.date: 10/12/2020 +title: Logging and tracing - .NET +description: An introduction to .NET logging and tracing. +ms.date: 4/29/2022 --- -# .NET Core logging and tracing +# .NET logging and tracing -Logging and tracing are really two names for the same technique. The simple technique has been used since the early days of computers. It simply involves instrumenting an application to write output to be consumed later. +Code can be instrumented to produce a log, which serves as a record of interesting events that occurred while the program was running. To understand the application's behavior, logs are reviewed. Logging and tracing both encapsulate this technique. .NET has accumulated several different logging APIs over its history and this article will help you understand what options are available. -## Reasons to use logging and tracing +## Key distinctions in logging APIs -This simple technique is surprisingly powerful. It can be used in situations where a debugger fails: +### Structured logging -- Issues occurring over long periods of time, can be difficult to debug with a traditional debugger. Logs allow for detailed post-mortem review spanning long periods of time. In contrast, debuggers are constrained to real-time analysis. -- Multi-threaded applications and distributed applications are often difficult to debug. Attaching a debugger tends to modify behaviors. Detailed logs can be analyzed as needed to understand complex systems. -- Issues in distributed applications may arise from a complex interaction between many components and it may not be reasonable to connect a debugger to every part of the system. -- Many services shouldn't be stalled. Attaching a debugger often causes timeout failures. -- Issues aren't always foreseen. Logging and tracing are designed for low overhead so that programs can always be recording in case an issue occurs. +Logging APIs can either be structured or unstructured: -## .NET Core APIs +- Unstructured: Log entries have free-form text content that is intended to be viewed by humans. +- Structured: Log entries have a well defined schema and can be encoded in different binary and textual formats. These logs are designed to be machine translatable and queryable so that both humans and automated systems can work with them easily. -### Print-style APIs +APIs that support structured logging are preferable for non-trivial usage. They offer more functionality, flexibility, and performance with little difference in usability. -The , , and classes each provide similar print-style APIs that are convenient for logging. +### Configuration -The choice of which print-style API to use is up to you. The key differences are: +For simple use cases, you might want to use APIs that directly write messages to the console or a file. But most software projects will find it useful to configure which log events get recorded and how they are persisted. For example, when running in a local dev environment, you might want to output plain text to the console for easy readability. Then when the application is deployed to a production environment, you might switch to have the logs stored in a dedicated database or a set of rolling files. APIs with good configuration options will make these transitions easy, whereas less configurable options would require updating the instrumentation code everywhere to make changes. -- - - Always enabled and always writes to the console. - - Useful for information that your customer may need to see in the release. - - Because it's the simplest approach, it's often used for ad-hoc temporary debugging. This debug code is often never checked in to source control. -- - - Only enabled when `TRACE` is defined by adding `#define TRACE` to your source or specifying the option `/d:TRACE` when compiling. - - Writes to attached , by default the . - - Use this API when creating logs that will be enabled in most builds. -- - - Only enabled when `DEBUG` is defined by adding `#define DEBUG` to your source or specifying the option `/d:DEBUG` when compiling. - - Writes to an attached debugger. - - On `*nix` writes to stderr if `DOTNET_DebugWriteToStdErr` or `COMPlus_DebugWriteToStdErr` is set. - - Use this API when creating logs that will be enabled only in debug builds. +### Sinks -### Logging events +Most logging APIs allow log messages to be sent to different destinations called sinks. Some APIs have a large number of pre-made sinks, whereas others only have a few. If no pre-made sink exists, there's usually an extensibility API that will let you author a custom sink, although this requires writing a bit more code. -The following APIs are more event oriented. Rather than logging simple strings they log event objects. +## .NET logging APIs -- [System.Diagnostics.Tracing.EventSource](./eventsource.md) - - EventSource is the primary root .NET Core tracing API. - - Available in all .NET Standard versions. - - Only allows tracing serializable objects. - - Can be consumed in-process via any [EventListener](xref:System.Diagnostics.Tracing.EventListener) instances configured to consume the EventSource. - - Can be consumed out-of-process via: - - [.NET Core's EventPipe](./eventpipe.md) on all platforms - - [Event Tracing for Windows (ETW)](/windows/win32/etw/event-tracing-portal) +### ILogger -- - - Included in .NET Core and as a [NuGet package](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource) for .NET Framework. - - Allows in-process tracing of non-serializable objects. - - Includes a bridge to allow selected fields of logged objects to be written to an . +For most cases, whether adding logging to an existing project or creating a new project, the [ILogger](../extensions/logging.md) interface is a good default choice. `ILogger` supports fast structured logging, flexible configuration, and a collection of [common sinks](../extensions/logging-providers.md#built-in-logging-providers). Additionally, the `ILogger` interface can also serve as a facade over many [third party logging implementations](../extensions/logging-providers.md#third-party-logging-providers) that offer more functionality and extensibility. -- - - Windows only. - - Writes messages to the Windows Event Log. - - System administrators expect fatal application error messages to appear in the Windows Event Log. +### EventSource -## Distributed Tracing +[EventSource](./eventsource.md) is an older high performance structured logging API. It was originally designed to integrate well with [Event Tracing for Windows (ETW)](/windows/win32/etw/event-tracing-portal), but was later extended to support [EventPipe](./eventpipe.md) cross-platform tracing and for custom sinks. In comparison to `ILogger`, `EventSource` has relatively few pre-made logging sinks and there is no built-in support to configure via separate configuration files. `EventSource` is excellent if you want tighter control over [ETW](/windows/win32/etw/event-tracing-portal) or [EventPipe](./eventpipe.md) integration, but for general purpose logging, `ILogger` is more flexible and easier to use. -[Distributed Tracing](./distributed-tracing.md) is a diagnostic technique that helps engineers -localize failures and performance issues within applications, especially those that may be -distributed across multiple machines or processes. This technique tracks requests through an -application correlating together work done by different application components and separating -it from other work the application may be doing for concurrent requests. +### Trace -## ILogger and logging frameworks + and are .NET's oldest logging APIs. These classes have flexible configuration APIs and a large ecosystem of sinks, but only support unstructured logging. On .NET Framework they can be configured via an app.config file, but in .NET Core, there's no built-in, file-based configuration mechanism. The .NET team continues to support these APIs for backward-compatibility purposes, but no new functionality will be added. These APIs are a fine choice for applications that are already using them. For newer apps that haven't already committed to a logging API, `ILogger` may offer better functionality. -The low-level APIs may not be the right choice for your logging needs. You may want to consider a logging framework. +## Specialized logging APIs -The interface has been used to create a common logging interface where the loggers can be inserted through dependency injection. +### Console -For instance, to allow you to make the best choice for your application .NET offers support for a selection of built-in and third-party frameworks: +The class has the and methods that can be used in simple logging scenarios. These APIs are very easy to get started with but the solution won't be as flexible as a general purpose logging API. Console only allows unstructured logging and there is no configuration support to select which log messages are enabled or to retarget to a different sink. Using the ILogger or Trace APIs with a console sink doesn't take much additional effort and keeps the logging configurable. -- [.NET Built-in logging providers](../extensions/logging-providers.md#built-in-logging-providers) -- [.NET Third-party logging providers](../extensions/logging-providers.md#third-party-logging-providers) +### DiagnosticSource -## Logging-related references + is intended for logging where the log messages will be analyzed synchronously in-process rather than serialized to any storage. This allows the source and listener to exchange arbitrary .NET objects as messages, whereas most logging APIs require the log event to be serializable. This technique can also be extremely fast, handling log events in tens of nanoseconds if the listener is implemented efficiently. Tools that use these APIs often act more like in-process profilers, though the API doesn't impose any constraint here. -- [How to: Compile Conditionally with Trace and Debug](../../framework/debug-trace-profile/how-to-compile-conditionally-with-trace-and-debug.md) +### EventLog -- [How to: Add Trace Statements to Application Code](../../framework/debug-trace-profile/how-to-add-trace-statements-to-application-code.md) - -- [Logging in .NET](../extensions/logging.md) provides an overview of the logging techniques it supports. - -- [C# string interpolation](../../csharp/language-reference/tokens/interpolated.md) can simplify writing logging code. - -- [Runtime Provider Event List](../../fundamentals/diagnostics/runtime-events.md) - -- [Well-known Event Providers in .NET](well-known-event-providers.md) - -- The property is useful for logging exceptions. - -- The class can be useful to provide stack info in your logs. - -## Performance considerations - -String formatting can take noticeable CPU processing time. - -In performance-critical applications, it's recommended that you: - -- Avoid lots of logging when no one is listening. Avoid constructing costly logging messages by checking if logging is enabled first. -- Only log what's useful. -- Defer fancy formatting to the analysis stage. + is a Windows only API that writes messages to the Windows EventLog. In many cases using ILogger with an optional EventLog sink when running on Windows may give similar functionality without coupling the app tightly to the Windows OS. diff --git a/docs/core/diagnostics/metrics-instrumentation.md b/docs/core/diagnostics/metrics-instrumentation.md index a3df09f7cd6ae..3038047440ef7 100644 --- a/docs/core/diagnostics/metrics-instrumentation.md +++ b/docs/core/diagnostics/metrics-instrumentation.md @@ -172,7 +172,7 @@ Types of instruments currently available: - Other common cases, such as business metrics, physical sensors, cache hit rates, or sizes of caches, queues, and files are usually well suited for `ObservableGauge`. > [!NOTE] -> OpenTelemetry also defines an UpDownCounter not currently present in the .NET API. ObservableGauge can usually be substituted by defining a variable to store the running +> OpenTelemetry also defines an UpDownCounter not currently present in the .NET API. UpDownCounter can usually be substituted by defining a variable to store the running > total and reporting the value of that variable in the ObservableGauge callback. ### Example of different instrument types diff --git a/docs/core/diagnostics/snippets/diagnosticsource/csharp/DiagnosticSource.csproj b/docs/core/diagnostics/snippets/diagnosticsource/csharp/DiagnosticSource.csproj new file mode 100644 index 0000000000000..40c60dd4c8843 --- /dev/null +++ b/docs/core/diagnostics/snippets/diagnosticsource/csharp/DiagnosticSource.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/docs/core/diagnostics/snippets/diagnosticsource/csharp/Program.cs b/docs/core/diagnostics/snippets/diagnosticsource/csharp/Program.cs new file mode 100644 index 0000000000000..b5ad47fdb6fe3 --- /dev/null +++ b/docs/core/diagnostics/snippets/diagnosticsource/csharp/Program.cs @@ -0,0 +1,84 @@ +// +using System.Diagnostics; +MyListener TheListener = new MyListener(); +TheListener.Listening(); +HTTPClient Client = new HTTPClient(); +Client.SendWebRequest("https://docs.microsoft.com/dotnet/core/diagnostics/"); + +// +class HTTPClient +{ + // + private static DiagnosticSource httpLogger = new DiagnosticListener("System.Net.Http"); + // + public byte[] SendWebRequest(string url) + { + // + if (httpLogger.IsEnabled("RequestStart")) + { + httpLogger.Write("RequestStart", new { Url = url }); + } + // + //Pretend this sends an HTTP request to the url and gets back a reply. + byte[] reply = new byte[] { }; + return reply; + } +} +// +// +class Observer : IObserver +{ + public Observer(Action onNext, Action onCompleted) + { + _onNext = onNext ?? new Action(_ => { }); + _onCompleted = onCompleted ?? new Action(() => { }); + } + public void OnCompleted() { _onCompleted(); } + public void OnError(Exception error) { } + public void OnNext(T value) { _onNext(value); } + private Action _onNext; + private Action _onCompleted; +} +class MyListener +{ + // + IDisposable networkSubscription; + IDisposable listenerSubscription; + private readonly object allListeners = new(); + public void Listening() + { + Action> whenHeard = delegate (KeyValuePair data) + { + Console.WriteLine($"Data received: {data.Key}: {data.Value}"); + }; + Action onNewListener = delegate (DiagnosticListener listener) + { + Console.WriteLine($"New Listener discovered: {listener.Name}"); + //Suscribe to the specific DiagnosticListener of interest. + if (listener.Name == "System.Net.Http") + { + //Use lock to ensure the callback code is thread safe. + lock (allListeners) + { + if (networkSubscription != null) + { + networkSubscription.Dispose(); + } + IObserver> iobserver = new Observer>(whenHeard, null); + networkSubscription = listener.Subscribe(iobserver); + } + + } + }; + //Subscribe to discover all DiagnosticListeners + IObserver observer = new Observer(onNewListener, null); + //When a listener is created, invoke the onNext function which calls the delegate. + listenerSubscription = DiagnosticListener.AllListeners.Subscribe(observer); + } + // + // Typically you leave the listenerSubscription subscription active forever. + // However when you no longer want your callback to be called, you can + // call listenerSubscription.Dispose() to cancel your subscription to the IObservable. +} +// +// diff --git a/docs/core/extensions/configuration.md b/docs/core/extensions/configuration.md index fccfeca8e596b..eef7a4c13078d 100644 --- a/docs/core/extensions/configuration.md +++ b/docs/core/extensions/configuration.md @@ -24,9 +24,15 @@ Configuration in .NET is performed using one or more [configuration providers](# > [!NOTE] > For information about configuring the .NET runtime itself, see [.NET Runtime configuration settings](../runtime-config/index.md). +## Concepts and abstractions + +Given one or more configuration sources, the type provides a unified view of the configuration data. Configuration is read-only, and the configuration pattern is not designed to be programmatically writable. The `IConfiguration` interface is a single representation of all the configuration sources, as shown in the following diagram: + +:::image type="content" source="media/configuration-sources.svg" lightbox="media/configuration-sources.svg" alt-text="The `IConfiguration` interface is a single representation of all the configuration sources."::: + ## Configure console apps -New .NET console applications created using [dotnet new](../tools/dotnet-new.md) or Visual Studio by default *do not* expose configuration capabilities. To add configuration in a new .NET console application, [add a package reference](../tools/dotnet-add-package.md) to [`Microsoft.Extensions.Hosting`](https://www.nuget.org/packages/Microsoft.Extensions.Hosting). Modify the *Program.cs* file to match the following code: +.NET console applications created using the [dotnet new](../tools/dotnet-new.md) command template or Visual Studio by default *do not* expose configuration capabilities. To add configuration in a new .NET console application, [add a package reference](../tools/dotnet-add-package.md) to [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting). Modify the *Program.cs* file to match the following code: :::code language="csharp" source="snippets/configuration/console/Program.cs" highlight="3"::: @@ -51,6 +57,44 @@ One of the key advantages of using the .NET configuration abstractions is the ab These abstractions are agnostic to their underlying configuration provider (). In other words, you can use an `IConfiguration` instance to access any configuration value from multiple providers. +The binder can use different approaches to process configuration values:​ + +- Direct deserialization (using built-in converters) for primitive types​. +- The for a complex type when the type has one​. +- Reflection for a complex type that has properties. + +> [!NOTE] +> The binder has a few limitations: +> +> - Properties are ignored if they have private setters or their type can't be converted. +> - Properties without corresponding configuration keys are ignored. + +#### Binding hierarchies + +Configuration values can contain hierarchical data. Hierarchical objects are represented with the use of the `:` delimiter in the configuration keys. To access a configuration value, use the `:` character to delimit a hierarchy. For example, consider the following configuration values: + +```json +{ + "Parent": { + "FavoriteNumber": 7, + "Child": { + "Name": "Example", + "GrandChild": { + "Age": 3 + } + } + } +} +``` + +The following table represents example keys and their corresponding values for the preceding example JSON: + +| Key | Value | +|---------------------------------|-------------| +| `"Parent:FavoriteNumber"` | `7` | +| `"Parent:Child:Name"` | `"Example"` | +| `"Parent:Child:GrandChild:Age"` | `3` | + ### Basic example To access configuration values in their basic form, without the assistance of the _generic host_ approach, use the type directly. @@ -114,6 +158,18 @@ When you run this application, the `Host.CreateDefaultBuilder` defines the behav > [!TIP] > Using the raw `IConfiguration` instance in this way, while convenient, doesn't scale very well. When applications grow in complexity, and their corresponding configurations become more complex, we recommend that you use the [_options pattern_](options.md) as an alternative. +### Basic example with hosting and using the indexer API + +Consider the same _appsettings.json_ file contents from the previous example: + +:::code language="json" source="snippets/configuration/console-indexer/appsettings.json"::: + +Replace the contents of the _Program.cs_ file with the following C# code: + +:::code language="csharp" source="snippets/configuration/console-indexer/Program.cs" highlight="11-15,17-22"::: + +The values are accessed using the indexer API where each key is a string, and the value is a string. Configuration supports properties, objects, arrays, and dictionaries. + ## Configuration providers The following table shows the configuration providers available to .NET Core apps. @@ -130,6 +186,9 @@ The following table shows the configuration providers available to .NET Core app | [Memory configuration provider](configuration-providers.md#memory-configuration-provider) | In-memory collections | | [App secrets (Secret Manager)](/aspnet/core/security/app-secrets) | File in the user profile directory | +> [!TIP] +> The order in which configuration providers are added matters. When multiple configuration providers are used and more than one provided specifies the same key, the last one added is used. + For more information on various configuration providers, see [Configuration providers in .NET](configuration-providers.md). ## See also diff --git a/docs/core/extensions/create-satellite-assemblies.md b/docs/core/extensions/create-satellite-assemblies.md index dde33ab3222a1..04100f8901310 100644 --- a/docs/core/extensions/create-satellite-assemblies.md +++ b/docs/core/extensions/create-satellite-assemblies.md @@ -1,7 +1,7 @@ --- title: Create satellite assemblies for .NET apps description: Get started with creating satellite assemblies for .NET apps. A satellite assembly can be easily updated or replaced to provide localized resources. -ms.date: 08/09/2021 +ms.date: 05/19/2022 dev_langs: - "csharp" - "vb" @@ -28,14 +28,14 @@ ms.assetid: 8d5c6044-2919-41d2-8321-274706b295ac # Create satellite assemblies for .NET apps -Resource files play a central role in localized applications. They enable an application to display strings, images, and other data in the user's own language and culture, and to provide alternate data if resources for the user's own language or culture are unavailable. The .NET Framework uses a hub-and-spoke model to locate and retrieve localized resources. The hub is the main assembly that contains the non-localizable executable code and the resources for a single culture, which is called the neutral or default culture. The default culture is the fallback culture for the application; it is used when no localized resources are available. You use the attribute to designate the culture of the application's default culture. Each spoke connects to a satellite assembly that contains the resources for a single localized culture but does not contain any code. Because the satellite assemblies are not part of the main assembly, you can easily update or replace resources that correspond to a specific culture without replacing the main assembly for the application. +Resource files play a central role in localized applications. They enable an application to display strings, images, and other data in the user's language and culture, and provide alternate data if resources for the user's language or culture are unavailable. .NET uses a hub-and-spoke model to locate and retrieve localized resources. The hub is the main assembly that contains the non-localizable executable code and the resources for a single culture, which is called the neutral or default culture. The default culture is the fallback culture for the application; it's used when no localized resources are available. You use the attribute to designate the culture of the application's default culture. Each spoke connects to a satellite assembly that contains the resources for a single localized culture but does not contain any code. Because the satellite assemblies aren't part of the main assembly, you can easily update or replace resources that correspond to a specific culture without replacing the main assembly for the application. > [!NOTE] > The resources of an application's default culture can also be stored in a satellite assembly. To do this, you assign the attribute a value of . ## Satellite assembly name and location -The hub-and-spoke model requires that you place resources in specific locations so that they can be easily located and used. If you do not compile and name resources as expected, or if you do not place them in the correct locations, the common language runtime will not be able to locate them and will use the resources of the default culture instead. The .NET Framework Resource Manager, represented by a object, is used to automatically access localized resources. The Resource Manager requires the following: +The hub-and-spoke model requires that you place resources in specific locations so that they can be easily located and used. If you don't compile and name resources as expected, or if you don't place them in the correct locations, the common language runtime won't be able to locate them and will use the resources of the default culture instead. The .NET resource manager is represented by the type, and it's used to automatically access localized resources. The resource manager requires the following: - A single satellite assembly must include all the resources for a particular culture. In other words, you should compile multiple *.txt* or *.resx* files into a single binary *.resources* file. @@ -44,11 +44,11 @@ The hub-and-spoke model requires that you place resources in specific locations > [!NOTE] > If your application includes resources for subcultures, place each subculture in a separate subdirectory under the application directory. Do not place subcultures in subdirectories under their main culture's directory. -- The satellite assembly must have the same name as the application, and must use the file name extension ".resources.dll". For example, if an application is named *Example.exe*, the name of each satellite assembly should be *Example.resources.dll*. Note that the satellite assembly name does not indicate the culture of its resource files. However, the satellite assembly appears in a directory that does specify the culture. +- The satellite assembly must have the same name as the application, and must use the file name extension ".resources.dll". For example, if an application is named *Example.exe*, the name of each satellite assembly should be *Example.resources.dll*. The satellite assembly name doesn't indicate the culture of its resource files. However, the satellite assembly appears in a directory that does specify the culture. - Information about the culture of the satellite assembly must be included in the assembly's metadata. To store the culture name in the satellite assembly's metadata, you specify the `/culture` option when you use [Assembly Linker](../../framework/tools/al-exe-assembly-linker.md) to embed resources in the satellite assembly. -The following illustration shows a sample directory structure and location requirements for applications that you are not installing in the [global assembly cache](../../framework/app-domains/gac.md). The items with .txt and .resources extensions will not ship with the final application. These are the intermediate resource files used to create the final satellite resource assemblies. In this example, you could substitute .resx files for the .txt files. For more information, see [Package and deploy resources](package-and-deploy-resources.md). +The following illustration shows a sample directory structure and location requirements for applications that you aren't installing in the [global assembly cache](../../framework/app-domains/gac.md). The items with *.txt* and *.resources* extensions won't ship with the final application. These are the intermediate resource files used to create the final satellite resource assemblies. In this example, you could substitute *.resx* files for the *.txt* files. For more information, see [Package and deploy resources](package-and-deploy-resources.md). The following image shows the satellite assembly directory: @@ -56,7 +56,7 @@ The following image shows the satellite assembly directory: ## Compile satellite assemblies -You use [Resource File Generator (*resgen.exe*)](../../framework/tools/resgen-exe-resource-file-generator.md) to compile text files or XML (*.resx*) files that contain resources to binary *.resources* files. You then use [Assembly Linker (*al.exe*)](../../framework/tools/al-exe-assembly-linker.md) to compile *.resources* files into satellite assemblies. *al.exe* creates an assembly from the *.resources* files that you specify. Satellite assemblies can contain only resources; they cannot contain any executable code. +You use [Resource File Generator (*resgen.exe*)](../../framework/tools/resgen-exe-resource-file-generator.md) to compile text files or XML (*.resx*) files that contain resources to binary *.resources* files. You then use [Assembly Linker (*al.exe*)](../../framework/tools/al-exe-assembly-linker.md) to compile *.resources* files into satellite assemblies. *al.exe* creates an assembly from the *.resources* files that you specify. Satellite assemblies can contain only resources; they can't contain any executable code. The following *al.exe* command creates a satellite assembly for the application `Example` from the German resources file *strings.de.resources*. @@ -74,14 +74,27 @@ The following table describes the *al.exe* options used in these commands in mor | Option | Description | |--|--| -| `-target:lib` | Specifies that your satellite assembly is compiled to a library (.dll) file. Because a satellite assembly does not contain executable code and is not an application's main assembly, you must save satellite assemblies as DLLs. | +| `-target:lib` | Specifies that your satellite assembly is compiled to a library (.dll) file. Because a satellite assembly doesn't contain executable code and is not an application's main assembly, you must save satellite assemblies as DLLs. | | `-embed:strings.de.resources` | Specifies the name of the resource file to embed when *al.exe* compiles the assembly. You can embed multiple .resources files in a satellite assembly, but if you are following the hub-and-spoke model, you must compile one satellite assembly for each culture. However, you can create separate .resources files for strings and objects. | -| `-culture:de` | Specifies the culture of the resource to compile. The common language runtime uses this information when it searches for the resources for a specified culture. If you omit this option, *al.exe* will still compile the resource, but the runtime will not be able to find it when a user requests it. | -| `-out:Example.resources.dll` | Specifies the name of the output file. The name must follow the naming standard *baseName*.resources.*extension*, where *baseName* is the name of the main assembly and *extension* is a valid file name extension (such as .dll). Note that the runtime is not able to determine the culture of a satellite assembly based on its output file name; you must use the **/culture** option to specify it. | +| `-culture:de` | Specifies the culture of the resource to compile. The common language runtime uses this information when it searches for the resources for a specified culture. If you omit this option, *al.exe* will still compile the resource, but the runtime won't be able to find it when a user requests it. | +| `-out:Example.resources.dll` | Specifies the name of the output file. The name must follow the naming standard *baseName*.resources.*extension*, where *baseName* is the name of the main assembly and *extension* is a valid file name extension (such as .dll). The runtime is not able to determine the culture of a satellite assembly based on its output file name; you must use the **/culture** option to specify it. | | `-template:Example.dll` | Specifies an assembly from which the satellite assembly will inherit all assembly metadata except the culture field. This option affects satellite assemblies only if you specify an assembly that has a [strong name](../../standard/assembly/strong-named.md). | For a complete list of options available with *al.exe*, see [Assembly Linker (*al.exe*)](../../framework/tools/al-exe-assembly-linker.md). +> [!NOTE] +> There may be times when you want to use the .NET Core MSBuild task to compile satellite assemblies, even though you're targeting .NET Framework. For example, you may want to use the C# compiler [deterministic](../../csharp/language-reference/compiler-options/code-generation.md#deterministic) option to be able to compare assemblies from different builds. In this case, set [GenerateSatelliteAssembliesForCore](../project-sdk/msbuild-props.md#generatesatelliteassembliesforcore) to `true` in the *.csproj* file to generate satellite assemblies using *csc.exe* instead of [Al.exe (Assembly Linker)](../../framework/tools/al-exe-assembly-linker.md). +> +> ```xml +> +> +> true +> +> +> ``` +> +> The .NET Core MSBuild task uses *csc.exe* instead of *al.exe* to generate satellite assemblies, by default. For more information, see [Make it easier to opt into "Core" satellite assembly generation](https://github.com/dotnet/msbuild/pull/2726). + ## Satellite assemblies example The following is a simple "Hello world" example that displays a message box containing a localized greeting. The example includes resources for the English (United States), French (France), and Russian (Russia) cultures, and its fallback culture is English. To create the example, do the following: @@ -120,7 +133,7 @@ The following is a simple "Hello world" example that displays a message box cont [!code-csharp[Conceptual.Resources.Locating#1](~/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.locating/cs/program.cs#1)] [!code-vb[Conceptual.Resources.Locating#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.resources.locating/vb/module1.vb#1)] - If the application is named **Example** and you are compiling from the command-line, the command for the C# compiler is: + If the application is named **Example** and you're compiling from the command line, the command for the C# compiler is: ```console csc Example.cs -res:Greeting.resources @@ -152,7 +165,7 @@ Instead of installing assemblies in a local application subdirectory, you can in Installing assemblies in the global assembly cache requires that they have strong names. Strong-named assemblies are signed with a valid public/private key pair. They contain version information that the runtime uses to determine which assembly to use to satisfy a binding request. For more information about strong names and versioning, see [Assembly versioning](../../standard/assembly/versioning.md). For more information about strong names, see [Strong-named assemblies](../../standard/assembly/strong-named.md). -When you are developing an application, it is unlikely that you will have access to the final public/private key pair. In order to install a satellite assembly in the global assembly cache and ensure that it works as expected, you can use a technique called delayed signing. When you delay sign an assembly, at build time you reserve space in the file for the strong name signature. The actual signing is delayed until later, when the final public/private key pair is available. For more information about delayed signing, see [Delay signing an assembly](../../standard/assembly/delay-sign.md). +When you're developing an application, it's unlikely that you'll have access to the final public/private key pair. To install a satellite assembly in the global assembly cache and ensure that it works as expected, you can use a technique called delayed signing. When you delay sign an assembly, at build time you reserve space in the file for the strong name signature. The actual signing is delayed until later, when the final public/private key pair is available. For more information about delayed signing, see [Delay signing an assembly](../../standard/assembly/delay-sign.md). ### Obtain the public key @@ -194,7 +207,7 @@ sn –R StringLibrary.resources.dll RealKeyPair.snk ### Install a satellite assembly in the Global Assembly Cache -When the runtime searches for resources in the resource fallback process, it looks in the [global assembly cache](../../framework/app-domains/gac.md) first. (For more information, see the "Resource Fallback Process" section of the [Package and deploy resources](package-and-deploy-resources.md) topic.) As soon as a satellite assembly is signed with a strong name, it can be installed in the global assembly cache by using the [Global Assembly Cache tool (*gacutil.exe*)](../../framework/tools/gacutil-exe-gac-tool.md). +When the runtime searches for resources in the resource fallback process, it looks in the [global assembly cache](../../framework/app-domains/gac.md) first. (For more information, see the "Resource Fallback Process" section of [Package and deploy resources](package-and-deploy-resources.md).) As soon as a satellite assembly is signed with a strong name, it can be installed in the global assembly cache by using the [Global Assembly Cache tool (*gacutil.exe*)](../../framework/tools/gacutil-exe-gac-tool.md). The following *Gacutil.exe* command installs *StringLibrary.resources.dll** in the global assembly cache: @@ -206,15 +219,15 @@ The **/i** option specifies that *Gacutil.exe* should install the specified asse ### Resources in the Global Assembly Cache: An Example -The following example uses a method in a .NET Framework class library to extract and return a localized greeting from a resource file. The library and its resources are registered in the global assembly cache. The example includes resources for the English (United States), French (France), Russian (Russia), and English cultures. English is the default culture; its resources are stored in the main assembly. The example initially delay signs the library and its satellite assemblies with a public key, then re-signs them with a public/private key pair. To create the example, do the following: +The following example uses a method in a .NET class library to extract and return a localized greeting from a resource file. The library and its resources are registered in the global assembly cache. The example includes resources for the English (United States), French (France), Russian (Russia), and English cultures. English is the default culture; its resources are stored in the main assembly. The example initially delay-signs the library and its satellite assemblies with a public key, then re-signs them with a public/private key pair. To create the example, do the following: -1. If you are not using Visual Studio, use the following [Strong Name Tool (Sn.exe)](../../framework/tools/sn-exe-strong-name-tool.md) command to create a public/private key pair named *ResKey.snk*: +1. If you aren't using Visual Studio, use the following [Strong Name Tool (Sn.exe)](../../framework/tools/sn-exe-strong-name-tool.md) command to create a public/private key pair named *ResKey.snk*: ```console sn –k ResKey.snk ``` - If you are using Visual Studio, use the **Signing** tab of the project **Properties** dialog box to generate the key file. + If you're using Visual Studio, use the **Signing** tab of the project **Properties** dialog box to generate the key file. 2. Use the following [Strong Name Tool (Sn.exe)](../../framework/tools/sn-exe-strong-name-tool.md) command to create a public key file named *PublicKey.snk*: @@ -265,7 +278,7 @@ The following example uses a method in a .NET Framework class library to extract vbc -t:library -resource:Strings.resources -delaysign+ -keyfile:publickey.snk StringLibrary.vb ``` -8. Create a subdirectory in the main application directory for each localized culture supported by the application. You should create an *en-US*, an *fr-FR*, and an *ru-RU* subdirectory. Visual Studio creates these subdirectories automatically as part of the compilation process. Because all satellite assemblies have the same file name, the subdirectories are used to store individual culture-specific satellite assemblies until they are signed with a public/private key pair. +8. Create a subdirectory in the main application directory for each localized culture supported by the application. You should create an *en-US*, an *fr-FR*, and an *ru-RU* subdirectory. Visual Studio creates these subdirectories automatically as part of the compilation process. Because all satellite assemblies have the same file name, the subdirectories are used to store individual culture-specific satellite assemblies until they're signed with a public/private key pair. 9. Embed the individual culture-specific *.resources* files into delay signed satellite assemblies and save them to the appropriate directory. The command to do this for each *.resources* file is: @@ -295,7 +308,7 @@ The following example uses a method in a .NET Framework class library to extract where *filename* is the name of the file to register. -13. If you are using Visual Studio, create a new **Console Application** project named `Example`, add a reference to *StringLibrary.dll* and the following source code to it, and compile. +13. If you're using Visual Studio, create a new **Console Application** project named `Example`, add a reference to *StringLibrary.dll* and the following source code to it, and compile. [!code-csharp[Conceptual.Resources.Satellites#3](~/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.satellites/cs/example.cs#3)] [!code-vb[Conceptual.Resources.Satellites#3](~/samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.resources.satellites/vb/example.vb#3)] diff --git a/docs/core/extensions/dependency-injection-usage.md b/docs/core/extensions/dependency-injection-usage.md index 3ab5dba9df487..af2fa0cd041fb 100644 --- a/docs/core/extensions/dependency-injection-usage.md +++ b/docs/core/extensions/dependency-injection-usage.md @@ -80,7 +80,7 @@ Update *Program.cs* with the following code: :::code language="csharp" source="snippets/configuration/console-di/Program.cs" id="Program" highlight="6-10"::: -Each `services.Add{SERVICE_NAME}` extension method adds (and potentially configures) services. We recommended that apps follow this convention. Place extension methods in the namespace to encapsulate groups of service registrations. Including the namespace portion `Microsoft.Extensions.DependencyInjection` for DI extension methods also: +Each `services.Add{LIFETIME}<{SERVICE}>` extension method adds (and potentially configures) services. We recommended that apps follow this convention. Place extension methods in the namespace to encapsulate groups of service registrations. Including the namespace portion `Microsoft.Extensions.DependencyInjection` for DI extension methods also: - Allows them to be displayed in [IntelliSense](/visualstudio/ide/using-intellisense) without adding additional `using` blocks. - Prevents excessive `using` statements in the `Program` or `Startup` classes where these extension methods are typically called. diff --git a/docs/core/extensions/generic-host.md b/docs/core/extensions/generic-host.md index ebcebc4937e03..c6b02c6862b99 100644 --- a/docs/core/extensions/generic-host.md +++ b/docs/core/extensions/generic-host.md @@ -3,7 +3,7 @@ title: .NET Generic Host author: IEvangelist description: Learn about the .NET Generic Host, which is responsible for app startup and lifetime management. ms.author: dapine -ms.date: 11/12/2021 +ms.date: 06/08/2022 --- # .NET Generic Host @@ -33,20 +33,14 @@ The host is typically configured, built, and run by code in the `Program` class. The .NET Worker Service templates generate the following code to create a Generic Host: ```csharp -public class Program -{ - public static void Main(string[] args) +IHost host = Host.CreateDefaultBuilder(args) + .ConfigureServices((hostContext, services) => { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureServices((hostContext, services) => - { - services.AddHostedService(); - }); -} + services.AddHostedService(); + }) + .Build(); + +host.Run(); ``` ## Default builder settings @@ -90,7 +84,7 @@ The following example is an `IHostedService` implementation that registers `IHos The Worker Service template could be modified to add the `ExampleHostedService` implementation: -:::code language="csharp" source="snippets/configuration/app-lifetime/Program.cs" id="Program" highlight="14"::: +:::code language="csharp" source="snippets/configuration/app-lifetime/Program.cs" id="Program" highlight="8"::: The application would write the following sample output: @@ -113,7 +107,7 @@ Inject the service into a c Host configuration is used to configure properties of the [IHostEnvironment](#ihostenvironment) implementation. -The host configuration is available in [HostBuilderContext.Configuration](xref:Microsoft.Extensions.Hosting.HostBuilderContext.Configuration) within the method. When calling the `ConfigureAppConfiguration` method, the `HostBuilderContext` and `IConfigurationBuilder` are passed into the `configureDelegate`. The `configureDelegate` is defined as an `Action`. The host builder context exposes the `.Configuration` property, which is an instance of `IConfiguration`. It represents the configuration built from the host, whereas the `IConfigurationBuilder` is the builder object used to configure the app. +The host configuration is available in [HostBuilderContext.Configuration](xref:Microsoft.Extensions.Hosting.HostBuilderContext.Configuration) within the method. When calling the `ConfigureAppConfiguration` method, the `HostBuilderContext` and `IConfigurationBuilder` are passed into the `configureDelegate`. The `configureDelegate` is defined as an `Action`. The host builder context exposes the `Configuration` property, which is an instance of `IConfiguration`. It represents the configuration built from the host, whereas the `IConfigurationBuilder` is the builder object used to configure the app. > [!TIP] > After `ConfigureAppConfiguration` is called the `HostBuilderContext.Configuration` is replaced with the [app config](#app-configuration). @@ -122,7 +116,7 @@ To add host configuration, call to `0`, which [clobbered][clobbered] the user's exit code passed to `Environment.Exit`. +Since `ConsoleLifetime` blocked `ProcessExit` while waiting for the host to shut down, this behavior led to [deadlocks][deadlocks] from `Environment.Exit` also blocks waiting for the call to `ProcessExit`. Additionally, since the SIGTERM handling was attempting to gracefully shut down the process, `ConsoleLifetime` would set the to `0`, which [clobbered][clobbered] the user's exit code passed to `Environment.Exit`. [deadlocks]: https://github.com/dotnet/runtime/issues/50397 [clobbered]: https://github.com/dotnet/runtime/issues/42224 @@ -187,7 +179,7 @@ If your application uses hosting, and you want to gracefully stop the host, you ### Hosting shutdown process -The following sequence diagram shows how the signals are handled internally in the hosting code. It isn't necessary for most users to understand this process. But for developers that need a deep understanding, this may help you get started. +The following sequence diagram shows how the signals are handled internally in the hosting code. Most users don't need to understand this process. But for developers that need a deep understanding, this may help you get started. After the host has been started, when a user calls `Run` or `WaitForShutdown`, a handler gets registered for . Execution is paused in `WaitForShutdown`, waiting for the `ApplicationStopping` event to be raised. This is how the `Main` method doesn't return right away, and the app stays running until `Run` or `WaitForShutdown` returns. diff --git a/docs/core/extensions/http-client.md b/docs/core/extensions/http-client.md index 88c9605817519..f858cbfbc8fd9 100644 --- a/docs/core/extensions/http-client.md +++ b/docs/core/extensions/http-client.md @@ -1,20 +1,23 @@ --- -title: HTTP with .NET +title: IHttpClientFactory with .NET description: Learn how to use the HttpClient and IHttpClientFactory implementations with dependency injection in your .NET workloads. author: IEvangelist ms.author: dapine ms.date: 11/12/2021 --- -# HTTP with .NET +# IHttpClientFactory with .NET In this article, you'll learn how to use the `IHttpClientFactory` and the `HttpClient` types with various .NET fundamentals, such as dependency injection (DI), logging, and configuration. The type was introduced in .NET Framework 4.5, which was released in 2012. In other words, it's been around for a while. `HttpClient` is used for making HTTP requests and handling HTTP responses from web resources identified by a . The HTTP protocol makes up the vast majority of all internet traffic. With modern application development principles driving best practices, the serves as a factory abstraction that can create `HttpClient` instances with custom configurations. was introduced in .NET Core 2.1. Common HTTP-based .NET workloads can take advantage of resilient and transient-fault-handling third-party middleware with ease. -## Explore the `IHttpClientFactory` type +> [!NOTE] +> If your app requires cookies, it might be better not to use in your app. For alternative ways of managing clients, see [Guidelines for using HTTP clients](../../fundamentals/networking/httpclient-guidelines.md). -All of the sample source code in this article relies on the [`Microsoft.Extensions.Http`](https://www.nuget.org/packages/microsoft.extensions.http) NuGet package. Additionally, [The Internet Chuck Norris Database](https://www.icndb.com) free API is used to make HTTP GET requests for "nerdy" jokes. +## The `IHttpClientFactory` type + +All of the sample source code in this article relies on the [`Microsoft.Extensions.Http`](https://www.nuget.org/packages/microsoft.extensions.http) NuGet package. Additionally, [The Internet Chuck Norris Database](https://www.icndb.com) free API is used to make HTTP `GET` requests for "nerdy" jokes. When you call any of the extension methods, you're adding the `IHttpClientFactory` and related services to the . The `IHttpClientFactory` type offers the following benefits: @@ -145,16 +148,16 @@ The defined interface can be consumed where necessary, with the implementation p ## Make POST, PUT, and DELETE requests -In the preceding examples, all HTTP requests use the GET HTTP verb. `HttpClient` also supports other HTTP verbs, including: +In the preceding examples, all HTTP requests use the `GET` HTTP verb. `HttpClient` also supports other HTTP verbs, including: -- POST -- PUT -- DELETE -- PATCH +- `POST` +- `PUT` +- `DELETE` +- `PATCH` For a complete list of supported HTTP verbs, see . -The following example shows how to make an HTTP POST request: +The following example shows how to make an HTTP `POST` request: :::code source="snippets/http/basic/ItemService.cs" id="Create"::: @@ -167,13 +170,13 @@ In the preceding code, the `CreateItemAsync` method: `HttpClient` also supports other types of content. For example, and . For a complete list of supported content, see . -The following example shows an HTTP PUT request: +The following example shows an HTTP `PUT` request: :::code source="snippets/http/basic/ItemService.cs" id="Update"::: -The preceding code is very similar to the POST example. The `UpdateItemAsync` method calls instead of `PostAsync`. +The preceding code is very similar to the `POST` example. The `UpdateItemAsync` method calls instead of `PostAsync`. -The following example shows an HTTP DELETE request: +The following example shows an HTTP `DELETE` request: :::code source="snippets/http/basic/ItemService.cs" id="Delete"::: @@ -199,7 +202,7 @@ services.AddHttpClient("Named.Client") > [!IMPORTANT] > You can generally treat `HttpClient` instances as objects that **do not** require disposal. Disposal cancels outgoing requests and guarantees the given `HttpClient` instance can't be used after calling . `IHttpClientFactory` tracks and disposes resources used by `HttpClient` instances. -Keeping a single `HttpClient` instance alive for a long duration is a common pattern used before the inception of `IHttpClientFactory`. This pattern becomes unnecessary after migrating to `IHttpClientFactory`. +Keeping a single `HttpClient` instance alive for a long duration is a common pattern used before the inception of `IHttpClientFactory`. For information about which strategy to use in your app, see [Guidelines for using HTTP clients](../../fundamentals/networking/httpclient-guidelines.md). ## Configure the `HttpMessageHandler` diff --git a/docs/core/extensions/httpclient-http3.md b/docs/core/extensions/httpclient-http3.md index 231f2738a7fa2..5b724b63cb46d 100644 --- a/docs/core/extensions/httpclient-http3.md +++ b/docs/core/extensions/httpclient-http3.md @@ -3,7 +3,7 @@ title: Use HTTP/3 with HttpClient description: Learn how to use the HttpClient to access HTTP/3 servers in .NET 6 author: IEvangelist ms.author: samsp -ms.date: 11/12/2021 +ms.date: 04/19/2022 --- # Use HTTP/3 with HttpClient @@ -57,9 +57,12 @@ HTTP/3 uses QUIC as its transport protocol. The .NET implementation of HTTP/3 us On Linux, libmsquic is published via Microsoft's official Linux package repository packages.microsoft.com. To consume it, it must be added manually. See [Linux Software Repository for Microsoft Products](/windows-server/administration/linux-package-repository-for-microsoft-software). After configuring the package feed, it can be installed via the package manager of your distro, for example, for Ubuntu: ```bash -sudo apt install libmsquic +sudo apt install libmsquic=1.9* ``` +> [!NOTE] +> .NET 6 is only compatible with the 1.9.x versions of libmsquic. Libmsquic 2.x is not compatible due to breaking changes. Libmsquic will receive updates to 1.9.x when needed to incorporate security fixes. + ### macOS HTTP/3 is not currently supported on macOS but may be available in a future release. diff --git a/docs/core/extensions/media/configuration-sources.svg b/docs/core/extensions/media/configuration-sources.svg new file mode 100644 index 0000000000000..9b737226ec280 --- /dev/null +++ b/docs/core/extensions/media/configuration-sources.svg @@ -0,0 +1,16 @@ + + + + + + + IConfigurationappsettings.{Environment}.jsonEnvironment variablesCommand-line arguments*Other sources \ No newline at end of file diff --git a/docs/core/extensions/media/profile-settings.png b/docs/core/extensions/media/profile-settings.png index 49431ec4b28a0..3e7782b7e6a0a 100644 Binary files a/docs/core/extensions/media/profile-settings.png and b/docs/core/extensions/media/profile-settings.png differ diff --git a/docs/core/extensions/options-library-authors.md b/docs/core/extensions/options-library-authors.md index a4fd53278951f..d9e008c8759e6 100644 --- a/docs/core/extensions/options-library-authors.md +++ b/docs/core/extensions/options-library-authors.md @@ -14,7 +14,7 @@ As a .NET library author, you'll learn general guidance on how to correctly expo ## Naming conventions -By convention, extension methods responsible for registering services are named `Add{Service}`, where `{Service}` is a meaningful and descriptive name. Depending on the package, the registration of services may be accompanied by `Use{Service}` extension methods. The `Use{Service}` extension methods are commonplace in [ASP.NET Core](/aspnet). +By convention, extension methods responsible for registering services are named `Add{Service}`, where `{Service}` is a meaningful and descriptive name. `Add{Service}` extension methods are commonplace in [ASP.NET Core](/aspnet). ✔️ CONSIDER names that disambiguate your service from other offerings. diff --git a/docs/core/extensions/options.md b/docs/core/extensions/options.md index 020a47594160e..34576d467cbf3 100644 --- a/docs/core/extensions/options.md +++ b/docs/core/extensions/options.md @@ -3,7 +3,7 @@ title: Options pattern in .NET author: IEvangelist description: Learn how to use the options pattern to represent groups of related settings in .NET apps. ms.author: dapine -ms.date: 03/10/2022 +ms.date: 05/12/2022 --- # Options pattern in .NET @@ -11,7 +11,7 @@ ms.date: 03/10/2022 The options pattern uses classes to provide strongly-typed access to groups of related settings. When [configuration settings](configuration.md) are isolated by scenario into separate classes, the app adheres to two important software engineering principles: - The [Interface Segregation Principle (ISP) or Encapsulation](../../architecture/modern-web-apps-azure/architectural-principles.md#encapsulation): Scenarios (classes) that depend on configuration settings depend only on the configuration settings that they use. -- [Separation of Concerns](../../architecture/modern-web-apps-azure/architectural-principles.md#separation-of-concerns): Settings for different parts of the app aren't dependent or coupled to one another. +- [Separation of Concerns](../../architecture/modern-web-apps-azure/architectural-principles.md#separation-of-concerns): Settings for different parts of the app aren't dependent or coupled with one another. Options also provide a mechanism to validate configuration data. For more information, see the [Options validation](#options-validation) section. @@ -42,7 +42,7 @@ The following code is part of the _Program.cs_ C# file and: In the preceding code, changes to the JSON configuration file after the app has started are read. -[`ConfigurationBinder.Get`](xref:Microsoft.Extensions.Configuration.ConfigurationBinder.Get%2A) binds and returns the specified type. `ConfigurationBinder.Get` may be more convenient than using `ConfigurationBinder.Bind`. The following code shows how to use `ConfigurationBinder.Get` with the `TransientFaultHandlingOptions` class: +[`ConfigurationBinder.Get`](xref:Microsoft.Extensions.Configuration.ConfigurationBinder.Get%2A) binds and returns the specified type. `ConfigurationBinder.Get` maybe more convenient than using `ConfigurationBinder.Bind`. The following code shows how to use `ConfigurationBinder.Get` with the `TransientFaultHandlingOptions` class: ```csharp IConfigurationRoot configurationRoot = configuration.Build(); diff --git a/docs/core/extensions/performing-culture-insensitive-case-changes.md b/docs/core/extensions/performing-culture-insensitive-case-changes.md index 2e511c8469918..e3208cfd1adf0 100644 --- a/docs/core/extensions/performing-culture-insensitive-case-changes.md +++ b/docs/core/extensions/performing-culture-insensitive-case-changes.md @@ -1,7 +1,7 @@ --- title: Perform culture-insensitive case changes description: "Learn how to perform culture-insensitive case changes" -ms.date: 08/11/2021 +ms.date: 06/06/2022 dev_langs: - "csharp" - "vb" @@ -69,4 +69,5 @@ Although the `Char.ToUpper` and `Char.ToLower` methods have the same characteris - - - +- [Change case in .NET](../../standard/base-types/changing-case.md) - [Perform culture-insensitive string operations](performing-culture-insensitive-string-operations.md) diff --git a/docs/core/extensions/snippets/configuration/app-lifetime/ExampleHostedService.cs b/docs/core/extensions/snippets/configuration/app-lifetime/ExampleHostedService.cs index 95f0883ded19f..df3939a41b1df 100644 --- a/docs/core/extensions/snippets/configuration/app-lifetime/ExampleHostedService.cs +++ b/docs/core/extensions/snippets/configuration/app-lifetime/ExampleHostedService.cs @@ -3,7 +3,7 @@ namespace AppLifetime.Example; -public class ExampleHostedService : IHostedService +public sealed class ExampleHostedService : IHostedService { private readonly ILogger _logger; diff --git a/docs/core/extensions/snippets/configuration/app-lifetime/Program.cs b/docs/core/extensions/snippets/configuration/app-lifetime/Program.cs index 31112dae52fb1..3f3e5238587c8 100644 --- a/docs/core/extensions/snippets/configuration/app-lifetime/Program.cs +++ b/docs/core/extensions/snippets/configuration/app-lifetime/Program.cs @@ -1,19 +1,14 @@ // using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using AppLifetime.Example; -namespace AppLifetime.Example; +using IHost host = Host.CreateDefaultBuilder(args) + .ConfigureServices((_, services) => + services.AddHostedService()) + .Build(); -class Program -{ - static Task Main(string[] args) => - CreateHostBuilder(args).Build().RunAsync(); - - static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureServices((_, services) => - services.AddHostedService()); -} +await host.RunAsync(); // // // Sample output: diff --git a/docs/core/extensions/snippets/configuration/console-host/Program.cs b/docs/core/extensions/snippets/configuration/console-host/Program.cs index 9a970323a5ce1..cdc28990fa056 100644 --- a/docs/core/extensions/snippets/configuration/console-host/Program.cs +++ b/docs/core/extensions/snippets/configuration/console-host/Program.cs @@ -1,24 +1,16 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -class Program -{ - static async Task Main(string[] args) +using IHost host = Host.CreateDefaultBuilder(args) + .ConfigureHostConfiguration(configHost => { - using IHost host = CreateHostBuilder(args).Build(); + configHost.SetBasePath(Directory.GetCurrentDirectory()); + configHost.AddJsonFile("hostsettings.json", optional: true); + configHost.AddEnvironmentVariables(prefix: "PREFIX_"); + configHost.AddCommandLine(args); + }) + .Build(); - // Application code should start here. +// Application code should start here. - await host.RunAsync(); - } - - static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureHostConfiguration(configHost => - { - configHost.SetBasePath(Directory.GetCurrentDirectory()); - configHost.AddJsonFile("hostsettings.json", optional: true); - configHost.AddEnvironmentVariables(prefix: "PREFIX_"); - configHost.AddCommandLine(args); - }); -} +await host.RunAsync(); diff --git a/docs/core/extensions/snippets/configuration/console-indexer/Program.cs b/docs/core/extensions/snippets/configuration/console-indexer/Program.cs new file mode 100644 index 0000000000000..422fabf2a5bd8 --- /dev/null +++ b/docs/core/extensions/snippets/configuration/console-indexer/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +using IHost host = Host.CreateDefaultBuilder(args).Build(); + +// Ask the service provider for the configuration abstraction. +IConfiguration config = host.Services.GetRequiredService(); + +// Get values from the config given their key and their target type. +string ipOne = config["IPAddressRange:0"]; +string ipTwo = config["IPAddressRange:1"]; +string ipThree = config["IPAddressRange:2"]; +string versionOne = config["SupportedVersions:v1"]; +string versionThree = config["SupportedVersions:v3"]; + +// Write the values to the console. +Console.WriteLine($"IPAddressRange:0 = {ipOne}"); +Console.WriteLine($"IPAddressRange:1 = {ipTwo}"); +Console.WriteLine($"IPAddressRange:2 = {ipThree}"); +Console.WriteLine($"SupportedVersions:v1 = {versionOne}"); +Console.WriteLine($"SupportedVersions:v3 = {versionThree}"); + +// Application code which might rely on the config could start here. + +await host.RunAsync(); + +// This will output the following: +// IPAddressRange:0 = 46.36.198.123 +// IPAddressRange:1 = 46.36.198.124 +// IPAddressRange:2 = 46.36.198.125 +// SupportedVersions:v1 = 1.0.0 +// SupportedVersions:v3 = 3.0.7 diff --git a/docs/core/extensions/snippets/configuration/console-indexer/appsettings.json b/docs/core/extensions/snippets/configuration/console-indexer/appsettings.json new file mode 100644 index 0000000000000..d5f6c33a6deb9 --- /dev/null +++ b/docs/core/extensions/snippets/configuration/console-indexer/appsettings.json @@ -0,0 +1,11 @@ +{ + "SupportedVersions": { + "v1": "1.0.0", + "v3": "3.0.7" + }, + "IPAddressRange": [ + "46.36.198.123", + "46.36.198.124", + "46.36.198.125" + ] +} diff --git a/docs/core/extensions/snippets/configuration/console-indexer/console-indexer.csproj b/docs/core/extensions/snippets/configuration/console-indexer/console-indexer.csproj new file mode 100644 index 0000000000000..f49235e578c8b --- /dev/null +++ b/docs/core/extensions/snippets/configuration/console-indexer/console-indexer.csproj @@ -0,0 +1,20 @@ + + + + Exe + net6.0 + enable + true + + + + + Always + + + + + + + + diff --git a/docs/core/extensions/snippets/configuration/console-raw/NestedSettings.cs b/docs/core/extensions/snippets/configuration/console-raw/NestedSettings.cs index c6a3a5bf08ba8..1e4f184cf4d53 100644 --- a/docs/core/extensions/snippets/configuration/console-raw/NestedSettings.cs +++ b/docs/core/extensions/snippets/configuration/console-raw/NestedSettings.cs @@ -1,4 +1,4 @@ -public class NestedSettings +public sealed class NestedSettings { public string Message { get; set; } = null!; } diff --git a/docs/core/extensions/snippets/configuration/console-raw/Settings.cs b/docs/core/extensions/snippets/configuration/console-raw/Settings.cs index 023fb9c438eaa..c3b25bd99b963 100644 --- a/docs/core/extensions/snippets/configuration/console-raw/Settings.cs +++ b/docs/core/extensions/snippets/configuration/console-raw/Settings.cs @@ -1,4 +1,4 @@ -public class Settings +public sealed class Settings { public int KeyOne { get; set; } public bool KeyTwo { get; set; } diff --git a/docs/core/extensions/snippets/configuration/console-raw/appsettings.json b/docs/core/extensions/snippets/configuration/console-raw/appsettings.json index 97f151e79aa39..82223b1fd3cb0 100644 --- a/docs/core/extensions/snippets/configuration/console-raw/appsettings.json +++ b/docs/core/extensions/snippets/configuration/console-raw/appsettings.json @@ -3,7 +3,18 @@ "KeyOne": 1, "KeyTwo": true, "KeyThree": { - "Message": "Oh, that's nice..." - } + "Message": "Oh, that's nice...", + "SupportedVersions": { + "v1": "1.0.0", + "v3": "3.0.7" + } + }, + "IPAddressRange": [ + "46.36.198.121", + "46.36.198.122", + "46.36.198.123", + "46.36.198.124", + "46.36.198.125" + ] } } diff --git a/docs/core/extensions/snippets/configuration/custom-provider/Providers/EntityConfigurationProvider.cs b/docs/core/extensions/snippets/configuration/custom-provider/Providers/EntityConfigurationProvider.cs index e270089709872..2bd03dd780226 100644 --- a/docs/core/extensions/snippets/configuration/custom-provider/Providers/EntityConfigurationProvider.cs +++ b/docs/core/extensions/snippets/configuration/custom-provider/Providers/EntityConfigurationProvider.cs @@ -17,7 +17,7 @@ public override void Load() dbContext.Database.EnsureCreated(); Data = dbContext.Settings.Any() - ? dbContext.Settings.ToDictionary(c => c.Id, c => c.Value) + ? dbContext.Settings.ToDictionary(c => c.Id, c => c.Value, StringComparer.OrdinalIgnoreCase) : CreateAndSaveDefaultValues(dbContext); } diff --git a/docs/core/extensions/snippets/configuration/custom-provider/custom-provider.csproj b/docs/core/extensions/snippets/configuration/custom-provider/custom-provider.csproj index 3733db187a1e5..9cee8d88f729d 100644 --- a/docs/core/extensions/snippets/configuration/custom-provider/custom-provider.csproj +++ b/docs/core/extensions/snippets/configuration/custom-provider/custom-provider.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/docs/core/extensions/snippets/workers/timer-service/TimerService.cs b/docs/core/extensions/snippets/workers/timer-service/TimerService.cs index 00461719c0f8a..bad35e8559244 100644 --- a/docs/core/extensions/snippets/workers/timer-service/TimerService.cs +++ b/docs/core/extensions/snippets/workers/timer-service/TimerService.cs @@ -22,7 +22,7 @@ private void DoWork(object? state) int count = Interlocked.Increment(ref _executionCount); _logger.LogInformation( - "{Service} is working, execution count: {{Count:#,0}}", + "{Service} is working, execution count: {Count:#,0}", nameof(TimerHostedService), count); } diff --git a/docs/core/extensions/snippets/workers/windows-service/Properties/PublishProfiles/FolderProfile.pubxml b/docs/core/extensions/snippets/workers/windows-service/Properties/PublishProfiles/FolderProfile.pubxml index 1d6a74da22c94..8e09a9938cd23 100644 --- a/docs/core/extensions/snippets/workers/windows-service/Properties/PublishProfiles/FolderProfile.pubxml +++ b/docs/core/extensions/snippets/workers/windows-service/Properties/PublishProfiles/FolderProfile.pubxml @@ -1,18 +1,18 @@  - + Release Any CPU - bin\Release\net5.0\win-x64\publish\ + bin\Release\net6.0\win-x64\publish\ FileSystem - net5.0 + net6.0 win-x64 true - True - True - True + true + false + true - + \ No newline at end of file diff --git a/docs/core/extensions/snippets/workers/windows-service/WindowsBackgroundService.cs b/docs/core/extensions/snippets/workers/windows-service/WindowsBackgroundService.cs index e988975decdbc..bdf93e1e59206 100644 --- a/docs/core/extensions/snippets/workers/windows-service/WindowsBackgroundService.cs +++ b/docs/core/extensions/snippets/workers/windows-service/WindowsBackgroundService.cs @@ -12,12 +12,29 @@ public WindowsBackgroundService( protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - while (!stoppingToken.IsCancellationRequested) + try { - string joke = _jokeService.GetJoke(); - _logger.LogWarning(joke); + while (!stoppingToken.IsCancellationRequested) + { + string joke = _jokeService.GetJoke(); + _logger.LogWarning("{Joke}", joke); - await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken); + await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "{Message}", ex.Message); + + // Terminates this process and returns an exit code to the operating system. + // This is required to avoid the 'BackgroundServiceExceptionBehavior', which + // performs one of two scenarios: + // 1. When set to "Ignore": will do nothing at all, errors cause zombie services. + // 2. When set to "StopHost": will cleanly stop the host, and log errors. + // + // In order for the Windows Service Management system to leverage configured + // recovery options, we need to terminate the process with a non-zero exit code. + Environment.Exit(1); } } } diff --git a/docs/core/extensions/timer-service.md b/docs/core/extensions/timer-service.md index 3eb7e8222ada5..2b99cad313008 100644 --- a/docs/core/extensions/timer-service.md +++ b/docs/core/extensions/timer-service.md @@ -3,7 +3,7 @@ title: Implement the IHostedService interface description: Learn how to implement a custom IHostedService interface with .NET. author: IEvangelist ms.author: dapine -ms.date: 12/17/2021 +ms.date: 04/20/2022 ms.topic: tutorial --- diff --git a/docs/core/extensions/windows-service.md b/docs/core/extensions/windows-service.md index 86b6729e1f9a5..222123ad10d79 100644 --- a/docs/core/extensions/windows-service.md +++ b/docs/core/extensions/windows-service.md @@ -44,7 +44,7 @@ To install this from Visual Studio, use the **Manage NuGet Packages...** dialog. dotnet add package Microsoft.Extensions.Hosting.WindowsServices ``` -For more information on the .NET CLI add package command, see [`dotnet add package`](../tools/dotnet-add-package.md). +For more information on the .NET CLI add package command, see [dotnet add package](../tools/dotnet-add-package.md). After successfully adding the packages, your project file should now contain the following package references: @@ -221,6 +221,19 @@ You will see the configured restart values. :::image type="content" source="media/windows-service-recovery-properties-configured.png" alt-text="The Windows Service recovery configuration properties dialog with restart enabled."::: +#### Service recovery options and .NET `BackgroundService` instances + +With .NET 6, [new hosting exception handling behaviors](../compatibility/core-libraries/6.0/hosting-exception-handling.md) have been added to .NET. The enum was added to the `Microsoft.Extensions.Hosting` namespace, and is used to specify the behavior of the service when an exception is thrown. The following table lists the available options: + +| Option | Description | +|------------|--------------------------------------------------------------------| +| `Ignore` | Ignore exceptions thrown in `BackgroundService`. | +| `StopHost` | The `IHost` will be stopped when an unhandled exception is thrown. | + +The default behavior before .NET 6 is `Ignore`, which resulted in _zombie processes_ (a running process that didn't do anything). With .NET 6, the default behavior is `StopHost`, which results in the host being stopped when an exception is thrown. But it stops cleanly, meaning that the Windows Service management system will not restart the service. To correctly allow the service to be restarted, you can call with a non-zero exit code. Consider the following highlighted `catch` block: + +:::code source="snippets/workers/windows-service/WindowsBackgroundService.cs" highlight="25-38"::: + ## Verify service functionality To see the app created as a Windows Service, open **Services**. Select the Windows key (or Ctrl + Esc), and search from "Services". From the **Services** app, you should be able to find your service by its name. diff --git a/docs/core/extensions/work-with-resx-files-programmatically.md b/docs/core/extensions/work-with-resx-files-programmatically.md index ab7fa749d6b25..971f92a8b5ff7 100644 --- a/docs/core/extensions/work-with-resx-files-programmatically.md +++ b/docs/core/extensions/work-with-resx-files-programmatically.md @@ -13,7 +13,8 @@ ms.assetid: 168f941a-2b84-43f8-933f-cf4a8548d824 # Work with .resx files programmatically -> ![NOTE] This article applies to .NET Framework. For information that applies to .NET 5+ (including .NET Core), see [Resources in .resx files](create-resource-files.md#resources-in-resx-files). +> [!NOTE] +> This article applies to .NET Framework. For information that applies to .NET 5+ (including .NET Core), see [Resources in .resx files](create-resource-files.md#resources-in-resx-files). Because XML resource (.resx) files must consist of well-defined XML, including a header that must follow a specific schema followed by data in name/value pairs, you may find that creating these files manually is error-prone. As an alternative, you can create .resx files programmatically by using types and members in the .NET Class Library. You can also use the .NET Class Library to retrieve resources that are stored in .resx files. This article explains how you can use the types and members in the namespace to work with .resx files. diff --git a/docs/core/get-started.md b/docs/core/get-started.md index 7c4191baf8e5e..222704dd8ac48 100644 --- a/docs/core/get-started.md +++ b/docs/core/get-started.md @@ -9,22 +9,23 @@ ms.topic: tutorial --- # Get started with .NET -This article teaches you how to create and run a "Hello World!" .NET app. - -If you're unsure what .NET is, start with the [.NET introduction](introduction.md). +This article teaches you how to create and run a "Hello World!" app with [.NET](introduction.md). ## Create an application First, download and install the [.NET SDK](https://dotnet.microsoft.com/download/dotnet) on your computer. -Next, open a terminal such as **PowerShell**, **Command Prompt**, or **bash**. Enter the following `dotnet` commands to create and run a C# application: +Next, open a terminal such as **PowerShell**, **Command Prompt**, or **bash**. + +Type the following commands: ```dotnetcli -dotnet new console --output sample1 -dotnet run --project sample1 +dotnet new console -o sample1 +cd sample1 +dotnet run ``` -You see the following output: +You should see the following output: ```output Hello World! diff --git a/docs/core/install/linux-ubuntu.md b/docs/core/install/linux-ubuntu.md index 41f599b2a6bf7..55bf861a149fc 100644 --- a/docs/core/install/linux-ubuntu.md +++ b/docs/core/install/linux-ubuntu.md @@ -8,7 +8,7 @@ ms.date: 03/21/2022 # Install the .NET SDK or the .NET Runtime on Ubuntu -.NET is supported on Ubuntu. This article describes how to install .NET on Ubuntu. When an Ubuntu version falls out of support, .NET is no longer supported with that version. +.NET is supported on Ubuntu. This article describes how to install .NET on Ubuntu. When an [Ubuntu version](https://wiki.ubuntu.com/Releases) falls out of support, .NET is no longer supported with that version. [!INCLUDE [linux-intro-sdk-vs-runtime](includes/linux-intro-sdk-vs-runtime.md)] @@ -16,26 +16,15 @@ ms.date: 03/21/2022 ## Supported distributions -The following table is a list of currently supported .NET releases and the versions of Ubuntu they're supported on. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of [Ubuntu reaches end-of-life](https://wiki.ubuntu.com/Releases). - -- A ✔️ indicates that the version of Ubuntu or .NET is still supported. -- A ❌ indicates that the version of Ubuntu or .NET isn't supported on that Ubuntu release. -- When both a version of Ubuntu and a version of .NET have ✔️, that OS and .NET combination is supported. - -| Ubuntu | .NET Core 3.1 | .NET 5 | .NET 6 | -|--------------------------|---------------|----------|----------| -| ✔️ [21.10](#2110-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [21.04](#2104-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [20.10](#2010-) | ✔️ 3.1 | ✔️ 5.0 | ❌ 6.0 | -| ✔️ [20.04 (LTS)](#2004-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [19.10](#1910-) | ✔️ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [19.04](#1904-) | ✔️ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [18.10](#1810-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ✔️ [18.04 (LTS)](#1804-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [17.10](#1710-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [17.04](#1704-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [16.10](#1610-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ✔️ [16.04 (LTS)](#1604-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | +The following table is a list of currently supported .NET releases and the versions of Ubuntu they're supported on. + +| Ubuntu | .NET | +|------------------------|------------| +| [22.04 (LTS)](#2204) | 6+ | +| [21.10](#2110) | 3.1, 6 | +| [20.04 (LTS)](#2004) | 3.1, 6 | +| [18.04 (LTS)](#1804) | 3.1, 6 | +| [16.04 (LTS)](#1604) | 3.1, 6 | [!INCLUDE [versions-not-supported](includes/versions-not-supported.md)] @@ -47,48 +36,33 @@ The following table is a list of currently supported .NET releases and the versi [!INCLUDE [package-manager uninstall notice](./includes/linux-uninstall-preview-info.md)] -## 21.10 ✔️ +## 22.04 [!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] -> [!NOTE] -> The .NET 6 packages haven't yet been published for Ubuntu 21.10. The following `wget` command uses the Ubuntu 21.04 repository. This article will be updated when the packages are available in the Ubuntu 21.10 repository. - ```bash -wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb +wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb ``` [!INCLUDE [linux-apt-install-60](includes/linux-install-60-apt.md)] -## 21.04 ❌ - -[!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] - -```bash -wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb -``` +Note: [Ubuntu 22.04 includes OpenSSL 3](https://discourse.ubuntu.com/t/openssl-3-0-transition-plans/24453) as the baseline version. [.NET 6 supports OpenSSL 3](https://devblogs.microsoft.com/dotnet/announcing-net-6/#security) while earlier .NET versions do not. Microsoft does not test or support using OpenSSL 1.x on Ubuntu 22.04. -[!INCLUDE [linux-apt-install-60](includes/linux-install-60-apt.md)] - -## 20.10 ❌ - -[!INCLUDE [linux-not-supported](includes/linux-not-supported-ubuntu.md)] +## 21.10 [!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] ```bash -wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb +wget https://packages.microsoft.com/config/ubuntu/21.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb ``` -[!INCLUDE [linux-apt-install-50](includes/linux-install-50-apt.md)] +[!INCLUDE [linux-apt-install-60](includes/linux-install-60-apt.md)] -## 20.04 ✔️ +## 20.04 [!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] @@ -100,49 +74,7 @@ rm packages-microsoft-prod.deb [!INCLUDE [linux-apt-install-60](includes/linux-install-60-apt.md)] -## 19.10 ❌ - -[!INCLUDE [linux-not-supported](includes/linux-not-supported-ubuntu.md)] - -[!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] - -```bash -wget https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb -``` - -[!INCLUDE [linux-apt-install-31](includes/linux-install-31-apt.md)] - -## 19.04 ❌ - -[!INCLUDE [linux-not-supported](includes/linux-not-supported-ubuntu.md)] - -[!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] - -```bash -wget https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb -``` - -[!INCLUDE [linux-apt-install-31](includes/linux-install-31-apt.md)] - -## 18.10 ❌ - -[!INCLUDE [linux-not-supported](includes/linux-not-supported-ubuntu.md)] - -[!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] - -```bash -wget https://packages.microsoft.com/config/ubuntu/18.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb -``` - -[!INCLUDE [linux-apt-install-21](includes/linux-install-21-apt.md)] - -## 18.04 ✔️ +## 18.04 [!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] @@ -154,49 +86,7 @@ rm packages-microsoft-prod.deb [!INCLUDE [linux-apt-install-50](includes/linux-install-60-apt.md)] -## 17.10 ❌ - -[!INCLUDE [linux-not-supported](includes/linux-not-supported-ubuntu.md)] - -[!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] - -```bash -wget https://packages.microsoft.com/config/ubuntu/17.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb -``` - -[!INCLUDE [linux-apt-install-21](includes/linux-install-21-apt.md)] - -## 17.04 ❌ - -[!INCLUDE [linux-not-supported](includes/linux-not-supported-ubuntu.md)] - -[!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] - -```bash -wget https://packages.microsoft.com/config/ubuntu/17.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb -``` - -[!INCLUDE [linux-apt-install-21](includes/linux-install-21-apt.md)] - -## 16.10 ❌ - -[!INCLUDE [linux-not-supported](includes/linux-not-supported-ubuntu.md)] - -[!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] - -```bash -wget https://packages.microsoft.com/config/ubuntu/16.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb -``` - -[!INCLUDE [linux-apt-install-21](includes/linux-install-21-apt.md)] - -## 16.04 ✔️ +## 16.04 [!INCLUDE [linux-prep-intro-apt](includes/linux-prep-intro-apt.md)] diff --git a/docs/core/install/linux.md b/docs/core/install/linux.md index e03e530f2ce67..aac0ba0e3834a 100644 --- a/docs/core/install/linux.md +++ b/docs/core/install/linux.md @@ -1,12 +1,12 @@ --- title: Install .NET on Linux distributions -description: Learn about which versions of .NET can be installed on which versions of Linux distributions. +description: Learn about how to install .NET on Linux. .NET is not only available at package.microsoft.com, but also the official package archives for various Linux distributions. author: adegeo ms.author: adegeo ms.date: 03/25/2022 --- -# Install .NET on Linux distributions +# Install .NET on Linux > [!div class="op_single_selector"] > @@ -14,194 +14,53 @@ ms.date: 03/25/2022 > - [Install on macOS](macos.md) > - [Install on Linux](linux.md) -This article details which versions of the .NET SDK or Runtime can be installed on which versions of various Linux distributions. Most Linux platforms and distributions have a major release each year, and most provide a package manager that is used to install .NET. - -All .NET releases remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the Linux distribution reaches end-of-life. - -For the best compatibility, choose a long-term support (LTS) version. - -## Unsupported releases - -[!INCLUDE [versions-not-supported](includes/versions-not-supported.md)] - -These unsupported versions aren't detailed in the sections below and your mileage may vary if you try to install them. +This article details how to install .NET on various Linux distributions, manually and via a package manager. Typically, stable .NET versions are available in a package manager, and Preview versions are not. ## Manual installation -If you don't want to use a package manager to install .NET on Linux, you can install .NET in one of the following ways: +You can install .NET manually in the following ways: -- [Snap package](linux-snap.md) -- [Scripted install with _install-dotnet.sh_](linux-scripted-manual.md#scripted-install) +- [Download tarballs](https://dotnet.microsoft.com/download/dotnet) +- [Scripted install](linux-scripted-manual.md#scripted-install) - [Manual binary extraction](linux-scripted-manual.md#manual-install) -Be sure to check the appropriate distribution page for more information about any required dependencies that may be missing when you do a manual installation. - -## Install preview versions - -Preview and Release Candidate versions of .NET aren't available in package managers. You can install previews and release candidates of .NET [manually](#manual-installation). - -## Alpine - -The following table is a list of currently supported .NET releases and the versions of Alpine they're supported on. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of [Alpine reaches end-of-life](https://alpinelinux.org/releases/). - -- A ✔️ indicates that the version of Alpine or .NET is still supported. -- A ❌ indicates that the version of Alpine or .NET isn't supported on that Alpine release. -- When both a version of Alpine and a version of .NET have ✔️, that OS and .NET combination is supported. - -| Alpine | .NET Core 3.1 | .NET 5 | .NET 6 | -|---------|---------------|-----------|-----------| -| ✔️ 3.15 | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ✔️ 3.14 | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ✔️ 3.13 | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ✔️ 3.12 | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ 3.11 | ✔️ 3.1 | ✔️ 5.0 | ❌ 6.0 | -| ❌ 3.10 | ✔️ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ 3.9 | ✔️ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ 3.8 | ✔️ 3.1 | ❌ 5.0 | ❌ 6.0 | - -For more information, see [Install .NET on Alpine](linux-alpine.md). - -## CentOS - -CentOS 7 uses Yum as a package manager and CentOS 8 uses DNF. - -The following table is a list of currently supported .NET releases on both CentOS 7 and CentOS 8. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of CentOS is no longer supported. - -- A ✔️ indicates that the version of CentOS or .NET is still supported. -- A ❌ indicates that the version of CentOS or .NET isn't supported on that CentOS release. -- When both a version of CentOS and a version of .NET have ✔️, that OS and .NET combination is supported. - -| CentOS | .NET Core 3.1 | .NET 5 | .NET 6 | -|--------------------------|---------------|----------------|----------------| -| ✔️ [7](linux-centos.md#centos-7-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [8](linux-centos.md#centos-8-)\* | ✔️ 3.1 | ✔️ 5.0 | ❌ 6.0 | - -> [!WARNING] -> \*CentOS 8 reached an early End Of Life (EOL) on December 31st, 2021. For more information, see the official [CentOS Linux EOL page](https://www.centos.org/centos-linux-eol/). Because of this, .NET 6 won't be supported on CentOS Linux 8. - -For more information, see [Install .NET on CentOS](linux-centos.md). - -## CentOS Stream - -CentOS Stream uses DNF as the package manager. - -CentOS Stream information is covered in the [Red Hat and CentOS Stream](#red-hat-and-centos-stream) section. - -## Debian - -Debian uses APT (Advanced Package Tool) as a package manager. - -The following table is a list of currently supported .NET releases and the versions of Debian they're supported on. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of [Debian reaches end-of-life](https://wiki.debian.org/DebianReleases). - -- A ✔️ indicates that the version of Debian or .NET is still supported. -- A ❌ indicates that the version of Debian or .NET isn't supported on that Debian release. -- When both a version of Debian and a version of .NET have ✔️, that OS and .NET combination is supported. - -| Debian | .NET Core 3.1 | .NET 5 | .NET 6 | -|--------------------------|---------------|----------|----------| -| ✔️ [11](linux-debian.md#debian-11-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ✔️ [10](linux-debian.md#debian-10-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ✔️ [9](linux-debian.md#debian-9-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [8](linux-debian.md#debian-8-) | ❌ 3.1 | ❌ 5.0 | ❌ 5.0 | - -For more information, see [Install .NET on Debian](linux-debian.md). - -## Fedora - -Fedora uses DNF as its package manager. - -The following table is a list of currently supported .NET releases and the versions of Fedora they're supported on. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of [Fedora reaches end-of-life](https://fedoraproject.org/wiki/End_of_life). - -- A ✔️ indicates that the version of Fedora or .NET is still supported. -- A ❌ indicates that the version of Fedora or .NET isn't supported on that Fedora release. -- When both a version of Fedora and a version of .NET have ✔️, that OS and .NET combination is supported. - -| .NET Version | Fedora 35 ✔️ | 34 ✔️ | 33 ❌ | 32 ❌ | 31 ❌ | 30 ❌ | 29 ❌ | 28 ❌ | 27 ❌ | -| ------------ | ---------: | --: | --: | --: | --: | --: | --: | --: | --: | -| .NET 6 | ✔️ | ✔️ | ❌ | ❌ | ❌ |❌ |❌ |❌ |❌ | -| .NET 5 | ✔️ | ✔️ | ✔️ | ✔️ | ❌ |❌ |❌ |❌ |❌ | -| .NET Core 3.1 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |✔️ |✔️ |❌ |❌ | - -For more information, see [Install .NET on Fedora](linux-fedora.md). - -## openSUSE - -openSUSE uses zypper as the package manager. - -The following table is a list of currently supported .NET releases on openSUSE 15. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of openSUSE is no longer supported. - -- A ✔️ indicates that the version of openSUSE or .NET is still supported. -- A ❌ indicates that the version of openSUSE or .NET isn't supported on that openSUSE release. -- When both a version of openSUSE and a version of .NET have ✔️, that OS and .NET combination is supported. - -| openSUSE | .NET Core 3.1 | .NET 5 | .NET 6 | -|----------------------------|---------------|------------|----------------| -| ✔️ [15](linux-opensuse.md#opensuse-15-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | - -For more information, see [Install .NET on openSUSE](linux-opensuse.md). - -## Red Hat and CentOS Stream - -Red Hat Enterprise Linux (RHEL) uses yum (RHEL 7) and DNF (RHEL 8, CentOS Stream) as the package manager. - -The following table is a list of currently supported .NET releases on both RHEL and CentOS Stream. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the Linux distribution is no longer supported. - -- A ✔️ indicates that the version of RHEL or .NET is still supported. -- A ❌ indicates that the version of RHEL or .NET isn't supported on that RHEL release. -- When both a version of Linux distribution and a version of .NET have ✔️, that OS and .NET combination is supported. - -| Distribution | .NET Core 3.1 | .NET 5 | .NET 6 | -| ----------------------- | ------------------------------ | -------------------------- | -------------------------- | -| ✔️ RHEL 8 | ✔️ [3.1](linux-rhel.md#rhel-8-) | ✔️ [5.0](linux-rhel.md#rhel-8-) | ✔️ [6.0](linux-rhel.md#rhel-8-) | -| ✔️ RHEL 7 | ✔️ [3.1](linux-rhel.md#rhel-7--net-core-31) | ✔️ [5.0](linux-rhel.md#rhel-7--net-50) | ✔️ [6.0](linux-rhel.md#rhel-7--net-60) | -| ✔️ CentOS Stream 9 | ❌ 3.1 | ❌ 5.0 | ✔️ [6.0](linux-rhel.md#centos-stream-9-) | -| ✔️ CentOS Stream 8 | ✔️ [3.1](linux-rhel.md#centos-stream-8-) | ✔️ [5.0](linux-rhel.md#centos-stream-8-) | ✔️ [6.0](linux-rhel.md#centos-stream-8-) | +You may need to install [.NET dependencies](https://github.com/dotnet/core/blob/main/release-notes/6.0/linux-packages.md) if you install .NET manually. -For more information, see [Install .NET on RHEL](linux-rhel.md). +## Official package archives -## SLES +.NET is available in the [official package archives](https://pkgs.org/search/?q=dotnet) for various Linux distributions, including the following ones. -SLES uses zypper as the package manager. +- [Arch Linux](https://archlinux.org/packages/?q=dotnet) +- [Arch Linux User Repository](https://aur.archlinux.org/packages?K=dotnet) +- [Fedora](https://packages.fedoraproject.org/search?query=dotnet) +- [Red Hat Enterprise Linux](https://access.redhat.com/documentation/en-us/net/6.0) -The following table is a list of currently supported .NET releases on both SLES 12 SP2 and SLES 15. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of SLES is no longer supported. +.NET may or may not be [supported by Microsoft](https://github.com/dotnet/core/blob/main/os-lifecycle-policy.md) as published in the official package archives. You can still [open issues at dotnet/core](https://github.com/dotnet/core/issues) if you run into problems. -- A ✔️ indicates that the version of SLES or .NET is still supported. -- A ❌ indicates that the version of SLES or .NET isn't supported on that SLES release. -- When both a version of SLES and a version of .NET have ✔️, that OS and .NET combination is supported. +[Red Hat supports .NET](https://developers.redhat.com/topics/dotnet/) on Red Hat Enterprise Linux (RHEL). Red Hat and Microsoft collaborate to ensure that .NET works well on RHEL. -| SLES | .NET Core 3.1 | .NET 5 | .NET 6 | -|------------------------|---------------|----------|----------| -| ✔️ [15](linux-sles.md#sles-15-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ✔️ [12 SP2](linux-sles.md#sles-12-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | +## Microsoft packages -For more information, see [Install .NET on SLES](linux-sles.md). +.NET is also available via [packages.microsoft.com](https://packages.microsoft.com/). -## Ubuntu +- [CentOS](linux-centos.md) +- [Debian](linux-debian.md) +- [Fedora](linux-fedora.md) +- [openSUSE](linux-opensuse.md) +- [SLES](linux-sles.md) +- [Ubuntu](linux-ubuntu.md) -Ubuntu uses APT (Advanced Package Tool) as a package manager. +These packages are [supported by Microsoft](https://github.com/dotnet/core/blob/main/os-lifecycle-policy.md). -The following table is a list of currently supported .NET releases and the versions of Ubuntu they're supported on. These versions remain supported until either the version of [.NET reaches end-of-support](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) or the version of [Ubuntu reaches end-of-life](https://wiki.ubuntu.com/Releases). +You're encouraged to install .NET from the official archive for your distribution if it's available there, even if it's also available at packages.microsoft.com. -- A ✔️ indicates that the version of Ubuntu or .NET is still supported. -- A ❌ indicates that the version of Ubuntu or .NET isn't supported on that Ubuntu release. -- When both a version of Ubuntu and a version of .NET have ✔️, that OS and .NET combination is supported. +## Other distributions -| Ubuntu | .NET Core 3.1 | .NET 5 | .NET 6 | -|------------------------------------------|---------------|----------|----------| -| ✔️ [21.10](linux-ubuntu.md#2110-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ✔️ [21.04](linux-ubuntu.md#2104-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [20.10](linux-ubuntu.md#2010-) | ✔️ 3.1 | ✔️ 5.0 | ❌ 6.0 | -| ✔️ [20.04 (LTS)](linux-ubuntu.md#2004-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [19.10](linux-ubuntu.md#1910-) | ✔️ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [19.04](linux-ubuntu.md#1904-) | ✔️ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [18.10](linux-ubuntu.md#1810-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ✔️ [18.04 (LTS)](linux-ubuntu.md#1804-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| ❌ [17.10](linux-ubuntu.md#1710-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [17.04](linux-ubuntu.md#1704-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ❌ [16.10](linux-ubuntu.md#1610-) | ❌ 3.1 | ❌ 5.0 | ❌ 6.0 | -| ✔️ [16.04 (LTS)](linux-ubuntu.md#1604-) | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | +Installation information is also provided for other distributions. -For more information, see [Install .NET on Ubuntu](linux-ubuntu.md). +- [Alpine](linux-alpine.md) +- [Containers](/dotnet/core/docker/introduction#net-core-images) +- [Snap](linux-snap.md) ## Next steps diff --git a/docs/core/install/macos-notarization-issues.md b/docs/core/install/macos-notarization-issues.md index a6d4cc280a4e2..fc8f5e48f37fe 100644 --- a/docs/core/install/macos-notarization-issues.md +++ b/docs/core/install/macos-notarization-issues.md @@ -14,25 +14,29 @@ Beginning with macOS Catalina (version 10.15), all software built after June 1, The installers for .NET (both runtime and SDK) have been notarized since February 18, 2020. Prior released versions aren't notarized. You can manually install a non-notarized version of .NET by first downloading the installer, and then using the `sudo installer` command. For more information, see [Download and manually install for macOS](./macos.md#download-and-manually-install). -## appHost is disabled by default +## Native appHost -.NET doesn't produce an **appHost** version of your app, a native Mach-O executable. The executable is usually invoked by .NET when your project compiles, publishes, or is run with the `dotnet run` command. The non-**appHost** version of your app is a _dll_ file invoked by .NET directly. You can turn on **appHost** generation with the [`UseAppHost`](../project-sdk/msbuild-props.md#useapphost) boolean setting in the project file. You can also toggle the appHost with the `-p:UseAppHost` parameter on the command line for the specific `dotnet` command you run: +In .NET SDK 7 and later versions, an **appHost**, which is a native Mach-O executable, is produced for your app. This executable is usually invoked by .NET when your project compiles, publishes, or is run with the `dotnet run` command. The non-**appHost** version of your app is a _dll_ file that can be invoked by the `dotnet ` command. + +When run locally, the SDK signs the apphost using [ad hoc signing](https://developer.apple.com/documentation/security/seccodesignatureflags/1397793-adhoc), which allows the app to run locally. When distributing your app, you'll need to properly sign your app according to Apple guidance. + +You can also distribute your app without the apphost and rely on users to run your app using `dotnet`. To turn off **appHost** generation, add the [`UseAppHost`](../project-sdk/msbuild-props.md#useapphost) boolean setting in the project file and set it to `false`. You can also toggle the appHost with the `-p:UseAppHost` parameter on the command line for the specific `dotnet` command you run: - Project file ```xml - true + false ``` - Command-line parameter ```dotnetcli - dotnet run -p:UseAppHost=true + dotnet run -p:UseAppHost=false ``` -An **appHost** is always created when you publish your app [self-contained](../deploying/index.md#publish-self-contained). You would notarize this version of your app prior to distribution. +An **appHost** is required when you publish your app [self-contained](../deploying/index.md#publish-self-contained) and you cannot disable it. For more information about the `UseAppHost` setting, see [MSBuild properties for Microsoft.NET.Sdk](../project-sdk/msbuild-props.md#useapphost). @@ -48,7 +52,7 @@ More information about this scenario is provided in the [ASP.NET Core and macOS .NET provides the ability to manage certificates in the macOS Keychain with the class. Access to the macOS Keychain uses the applications identity as the primary key when deciding which partition to consider. For example, unsigned applications store secrets in the unsigned partition, but signed applications store their secrets in partitions only they can access. The source of execution that invokes your app decides which partition to use. -.NET provides three sources of execution: [appHost](#apphost-is-disabled-by-default), default host (the `dotnet` command), and a custom host. Each execution model may have different identities, either signed or unsigned, and has access to different partitions within the Keychain. Certificates imported by one mode may not be accessible from another. For example, the notarized versions of .NET have a default host that is signed. Certificates are imported into a secure partition based on its identity. These certificates aren't accessible from a generated appHost, as the appHost is unsigned. +.NET provides three sources of execution: [appHost](#native-apphost), default host (the `dotnet` command), and a custom host. Each execution model may have different identities, either signed or unsigned, and has access to different partitions within the Keychain. Certificates imported by one mode may not be accessible from another. For example, the notarized versions of .NET have a default host that is signed. Certificates are imported into a secure partition based on its identity. These certificates aren't accessible from a generated appHost, as the appHost is ad-hoc signed. Another example, by default, ASP.NET Core imports a default SSL certificate through the default host. ASP.NET Core applications that use an appHost won't have access to this certificate and will receive an error when .NET detects the certificate isn't accessible. The error message provides instructions on how to fix this problem. @@ -58,7 +62,7 @@ For more information on how to troubleshoot ASP.NET Core certificate issues, see ## Default entitlements -.NET's default host (the `dotnet` command) has a set of default entitlements. These entitlements are required for proper operation of .NET. It's possible that your application may need additional entitlements, in which case you'll need to generate and use an [appHost](#apphost-is-disabled-by-default) and then add the necessary entitlements locally. +.NET's default host (the `dotnet` command) has a set of default entitlements. These entitlements are required for proper operation of .NET. It's possible that your application may need additional entitlements, in which case you'll need to generate and use an [appHost](#native-apphost) and then add the necessary entitlements locally. Default set of entitlements for .NET: diff --git a/docs/core/install/macos.md b/docs/core/install/macos.md index 332f5cb342bd5..a1ebc6bbf8174 100644 --- a/docs/core/install/macos.md +++ b/docs/core/install/macos.md @@ -3,7 +3,7 @@ title: Install .NET on macOS description: Learn about what versions of macOS you can install .NET on. author: adegeo ms.author: adegeo -ms.date: 11/29/2021 +ms.date: 05/16/2022 --- # Install .NET on macOS @@ -30,9 +30,9 @@ The following table is a list of currently supported .NET releases and the versi | Operating System | .NET Core 3.1 | .NET 5 | .NET 6 | |---------------------------|---------------|----------------|----------------| -| macOS 12.0 "Monterey" | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| macOS 11.0 "Big Sur" | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | -| macOS 10.15 "Catalina" | ✔️ 3.1 | ✔️ 5.0 | ✔️ 6.0 | +| macOS 12.0 "Monterey" | ✔️ 3.1 | ❌ 5.0 | ✔️ 6.0 | +| macOS 11.0 "Big Sur" | ✔️ 3.1 | ❌ 5.0 | ✔️ 6.0 | +| macOS 10.15 "Catalina" | ✔️ 3.1 | ❌ 5.0 | ✔️ 6.0 | For more information about the life cycle of .NET releases, see [.NET and .NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core). @@ -95,7 +95,6 @@ As an alternative to the macOS installers for .NET, you can download and manuall First, download a **binary** release for either the SDK or the runtime from one of the following sites. If you install the .NET SDK, you will not need to install the corresponding runtime: - ✔️ [.NET 6 downloads](https://dotnet.microsoft.com/download/dotnet/6.0) -- ✔️ [.NET 5 downloads](https://dotnet.microsoft.com/download/dotnet/5.0) - ✔️ [.NET Core 3.1 downloads](https://dotnet.microsoft.com/download/dotnet/3.1) - [All .NET downloads](https://dotnet.microsoft.com/download/dotnet) @@ -167,7 +166,6 @@ Visual Studio for Mac installs the .NET SDK when the **.NET** workload is select | .NET SDK version | Visual Studio version | | --------------------- | ---------------------------------------------------- | | 6.0 | Visual Studio 2022 for Mac Preview 3 17.0 or higher. | -| 5.0 | Visual Studio 2019 for Mac version 8.8 or higher. | | 3.1 | Visual Studio 2019 for Mac version 8.4 or higher. | :::image type="content" source="media/install-sdk/mac-install-selection.png" alt-text="macOS Visual Studio 2019 for Mac with the .NET workload selected." lightbox="media/install-sdk/mac-install-selection.png"::: diff --git a/docs/core/install/windows.md b/docs/core/install/windows.md index 3723de61c82c2..fcb1ddec04f7d 100644 --- a/docs/core/install/windows.md +++ b/docs/core/install/windows.md @@ -3,7 +3,7 @@ title: Install .NET on Windows description: Learn about what versions of Windows you can install .NET on. author: adegeo ms.author: adegeo -ms.date: 11/05/2021 +ms.date: 05/16/2022 --- # Install .NET on Windows @@ -32,23 +32,23 @@ Windows 10 versions end-of-service dates are segmented by edition. Only **Home** | Operating System | .NET Core 3.1 | .NET 5 | .NET 6 | |----------------------------------------------|---------------|--------|--------| -| Windows 11 | ✔️ | ✔️ | ✔️ | -| Windows Server 2022 | ✔️ | ✔️ | ✔️ | -| Windows 10 Version 21H1 | ✔️ | ✔️ | ✔️ | -| Windows 10 / Windows Server, Version 20H2 | ✔️ | ✔️ | ✔️ | -| Windows 10 / Windows Server, Version 2004 | ✔️ | ✔️ | ✔️ | -| Windows 10 / Windows Server, Version 1909 | ✔️ | ✔️ | ✔️ | -| Windows 10 / Windows Server, Version 1903 | ✔️ | ✔️ | ✔️ | -| Windows 10, Version 1809 | ✔️ | ✔️ | ✔️ | -| Windows 10, Version 1803 | ✔️ | ✔️ | ✔️ | -| Windows 10, Version 1709 | ✔️ | ✔️ | ✔️ | -| Windows 10, Version 1607 | ✔️ | ✔️ | ✔️ | -| Windows 8.1 | ✔️ | ✔️ | ✔️ | -| Windows 7 SP1 [ESU][esu] | ✔️ | ✔️ | ✔️ | +| Windows 11 | ✔️ | ❌ | ✔️ | +| Windows Server 2022 | ✔️ | ❌ | ✔️ | +| Windows 10 Version 21H1 | ✔️ | ❌ | ✔️ | +| Windows 10 / Windows Server, Version 20H2 | ✔️ | ❌ | ✔️ | +| Windows 10 / Windows Server, Version 2004 | ✔️ | ❌ | ✔️ | +| Windows 10 / Windows Server, Version 1909 | ✔️ | ❌ | ✔️ | +| Windows 10 / Windows Server, Version 1903 | ✔️ | ❌ | ✔️ | +| Windows 10, Version 1809 | ✔️ | ❌ | ✔️ | +| Windows 10, Version 1803 | ✔️ | ❌ | ✔️ | +| Windows 10, Version 1709 | ✔️ | ❌ | ✔️ | +| Windows 10, Version 1607 | ✔️ | ❌ | ✔️ | +| Windows 8.1 | ✔️ | ❌ | ✔️ | +| Windows 7 SP1 [ESU][esu] | ✔️ | ❌ | ✔️ | | Windows Server 2019
Windows Server 2016
Windows Server 2012 R2
Windows Server 2012| ✔️ | ✔️ | ✔️ | -| Windows Server Core 2012 R2 | ✔️ | ✔️ | ✔️ | -| Windows Server Core 2012 | ✔️ | ✔️ | ✔️ | -| Nano Server, Version 1809+ | ✔️ | ✔️ | ✔️ | +| Windows Server Core 2012 R2 | ✔️ | ❌ | ✔️ | +| Windows Server Core 2012 | ✔️ | ❌ | ✔️ | +| Nano Server, Version 1809+ | ✔️ | ❌ | ✔️ | | Nano Server, Version 1803 | ✔️ | ❌ | ❌ | For more information about .NET 6 supported operating systems, distributions, and lifecycle policy, see [.NET 6 Supported OS Versions](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md). @@ -138,24 +138,6 @@ The following Windows versions are supported with .NET 6: For more information about .NET 6 supported operating systems, distributions, and lifecycle policy, see [.NET 6 Supported OS Versions](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md). -# [.NET 5](#tab/net50) - -The following Windows versions are supported with .NET 5: - -> [!NOTE] -> A `+` symbol represents the minimum version. - -| OS | Version | Architectures | -|---------------------|---------------|-----------------| -| Windows 11 | 21H2 | x64, Arm64 | -| Windows 10 Client | 1607+ | x64, x86, Arm64 | -| Windows Client | 7 SP1+, 8.1 | x64, x86 | -| Windows Server | 2012+ | x64, x86 | -| Windows Server Core | 2012+ | x64, x86 | -| Nano Server | 1809+ | x64 | - -For more information about .NET 5 supported operating systems, distributions, and lifecycle policy, see [.NET 5 Supported OS Versions](https://github.com/dotnet/core/blob/main/release-notes/5.0/5.0-supported-os.md). - # [.NET Core 3.1](#tab/netcore31) The following Windows versions are supported with .NET Core 3.1: @@ -173,60 +155,6 @@ The following Windows versions are supported with .NET Core 3.1: For more information about .NET Core 3.1 supported operating systems, distributions, and lifecycle policy, see [.NET Core 3.1 Supported OS Versions](https://github.com/dotnet/core/blob/main/release-notes/3.1/3.1-supported-os.md). -# [.NET Core 3.0](#tab/netcore30) - -_.NET Core 3.0 is currently ❌ out of support. For more information, see the [.NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core)._ - -The following Windows versions are supported with .NET Core 3.0: - -> [!NOTE] -> A `+` symbol represents the minimum version. - -| OS | Version | Architectures | -| ----------------------------- | ------------------------------ | --------------- | -| Windows Client | 7 SP1+, 8.1 | x64, x86 | -| Windows 10 Client | Version 1607+ | x64, x86 | -| Windows Server | 2012 R2+ | x64, x86 | -| Nano Server | Version 1803+ | x64, Arm32 | - -For more information about .NET Core 3.0 supported operating systems, distributions, and lifecycle policy, see [.NET Core 3.0 Supported OS Versions](https://github.com/dotnet/core/blob/main/release-notes/3.0/3.0-supported-os.md). - -# [.NET Core 2.2](#tab/netcore22) - -_.NET Core 2.2 is currently ❌ out of support. For more information, see the [.NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core)._ - -The following Windows versions are supported with .NET Core 2.2: - -> [!NOTE] -> A `+` symbol represents the minimum version. - -| OS | Version | Architectures | -| ----------------------------- | ------------------------------ | --------------- | -| Windows Client | 7 SP1+, 8.1 | x64, x86 | -| Windows 10 Client | Version 1607+ | x64, x86 | -| Windows Server | 2008 R2 SP1+ | x64, x86 | -| Nano Server | Version 1803+ | x64, Arm32 | - -For more information about .NET Core 2.2 supported operating systems, distributions, and lifecycle policy, see [.NET Core 2.2 Supported OS Versions](https://github.com/dotnet/core/blob/main/release-notes/2.2/2.2-supported-os.md). - -# [.NET Core 2.1](#tab/netcore21) - -_.NET Core 2.1 is currently ❌ out of support. For more information, see the [.NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core)._ - -The following Windows versions are supported with .NET Core 2.1: - -> [!NOTE] -> A `+` symbol represents the minimum version. - -| OS | Version | Architectures | -| ----------------------------- | ------------------------------ | --------------- | -| Windows Client | 7 SP1+, 8.1 | x64, x86 | -| Windows 10 Client | Version 1607+ | x64, x86 | -| Windows Server | 2008 R2 SP1+ | x64, x86 | -| Nano Server | Version 1803+ | x64, | - -For more information about .NET Core 2.1 supported operating systems, distributions, and lifecycle policy, see [.NET Core 2.1 Supported OS Versions](https://github.com/dotnet/core/blob/main/release-notes/2.1/2.1-supported-os.md). - ### Offline install for Windows 7 When doing an offline install for .NET Core 2.1 on Windows 7, you'll first need to make sure that the latest [Microsoft Root Certificate Authority 2011](https://www.microsoft.com/pkiops/Docs/Repository.htm) has been installed on the target machine. @@ -360,7 +288,6 @@ As an alternative to the Windows installers for .NET, you can download and manua Both .NET SDK and .NET Runtime can be manually installed after they've been downloaded. If you install .NET SDK, you don't need to install the corresponding runtime. First, download a binary release for either the SDK or the runtime from one of the following sites: - [.NET 6 downloads](https://dotnet.microsoft.com/download/dotnet/6.0) -- [.NET 5 downloads](https://dotnet.microsoft.com/download/dotnet/5.0) - [.NET Core 3.1 downloads](https://dotnet.microsoft.com/download/dotnet/3.1) - [All .NET Core downloads](https://dotnet.microsoft.com/download/dotnet) diff --git a/docs/core/introduction.md b/docs/core/introduction.md index dac6de9cf6eed..7f31bb4252cd1 100644 --- a/docs/core/introduction.md +++ b/docs/core/introduction.md @@ -67,7 +67,7 @@ For more information, see the [list of project repositories on GitHub.com](https [Tizen supports .NET](https://developer.tizen.org/development/training/.net-application) on Tizen platforms. -For more information, see [Releases and support for .NET Core and .NET 5](releases-and-support.md). +For more information, see [Releases and support for .NET Core and .NET 5+](releases-and-support.md). ## .NET Core, .NET Framework, Mono, UWP diff --git a/docs/core/porting/index.md b/docs/core/porting/index.md index 9348736067105..92aef605b4d66 100644 --- a/docs/core/porting/index.md +++ b/docs/core/porting/index.md @@ -67,9 +67,9 @@ There are a few technologies in .NET Framework that don't exist in .NET: (COM+) isn't supported in .NET. -- Windows Workflow Foundation (WF) and Windows Communication Foundation (WCF) +- Windows Workflow Foundation (WF) - WF and WCF aren't supported in .NET 5+ (including .NET Core). For alternatives, see [CoreWF](https://github.com/UiPath/corewf) and [CoreWCF](https://github.com/CoreWCF/CoreWCF). + WF isn't supported in .NET 5+ (including .NET Core). For an alternative, see [CoreWF](https://github.com/UiPath/corewf). For more information about these unsupported technologies, see [.NET Framework technologies unavailable on .NET Core and .NET 5+](net-framework-tech-unavailable.md). diff --git a/docs/core/porting/net-framework-tech-unavailable.md b/docs/core/porting/net-framework-tech-unavailable.md index 0299376696cfb..52fff7bfced08 100644 --- a/docs/core/porting/net-framework-tech-unavailable.md +++ b/docs/core/porting/net-framework-tech-unavailable.md @@ -2,7 +2,7 @@ title: .NET Framework technologies unavailable on .NET Core and .NET 5+ titleSuffix: "" description: Learn about .NET Framework technologies that are unavailable on .NET Core and .NET 5 and later versions. -ms.date: 05/21/2021 +ms.date: 05/11/2022 ms.topic: reference --- # .NET Framework technologies unavailable on .NET Core and .NET 5+ @@ -29,7 +29,7 @@ For more messaging options, see [.NET Open Source Developer Projects: Messaging] ## Code access security (CAS) -Sandboxing, which relies on the runtime or the framework to constrain which resources a managed application or library uses or runs, [isn't supported on .NET Framework](/previous-versions/dotnet/framework/code-access-security/code-access-security) and therefore is also not supported on .NET Core and .NET 5+. There are too many cases in the .NET Framework and the runtime where an elevation of privileges occurs to continue treating CAS as a security boundary. Also, CAS makes the implementation more complicated and often has correctness-performance implications for applications that don't intend to use it. +Sandboxing, which relies on the runtime or the framework to constrain which resources a managed application or library uses or runs, [isn't supported on .NET Framework](/previous-versions/dotnet/framework/code-access-security/code-access-security) and therefore is also not supported on .NET Core and .NET 5+. CAS is no longer treated as a security boundary, because there are too many cases in .NET Framework and the runtime where an elevation of privileges occurs. Also, CAS makes the implementation more complicated and often has correctness-performance implications for applications that don't intend to use it. Use security boundaries provided by the operating system, such as virtualization, containers, or user accounts, for running processes with the minimum set of privileges. @@ -37,15 +37,18 @@ Use security boundaries provided by the operating system, such as virtualization Similar to CAS, security transparency separates sandboxed code from security critical code in a declarative fashion but is [no longer supported as a security boundary](/previous-versions/dotnet/framework/code-access-security/security-transparent-code). This feature is heavily used by Silverlight. -Use security boundaries provided by the operating system, such as virtualization, containers, or user accounts, for running processes with the least set of privileges. +To run processes with the least set of privileges, use security boundaries provided by the operating system, such as virtualization, containers, or user accounts. ## System.EnterpriseServices (COM+) isn't supported by .NET Core and .NET 5+. -## Workflow Foundation and WCF +## Workflow Foundation -Windows Workflow Foundation (WF) and Windows Communication Foundation (WCF) are not supported in .NET 5+ (including .NET Core). For alternatives, see [CoreWF](https://github.com/UiPath/corewf) and [CoreWCF](https://github.com/CoreWCF/CoreWCF). +Windows Workflow Foundation (WF) is not supported in .NET 5+ (including .NET Core). For an alternative, see [CoreWF](https://github.com/UiPath/corewf). + +> [!TIP] +> Windows Communication Foundation (WCF) server can be used in .NET 5+ by using the [CoreWCF NuGet packages](https://www.nuget.org/profiles/corewcf). For more information, see [CoreWCF 1.0 has been Released](https://devblogs.microsoft.com/dotnet/corewcf-v1-released/). ## Saving assemblies generated by reflection diff --git a/docs/core/porting/upgrade-assistant-overview.md b/docs/core/porting/upgrade-assistant-overview.md index b855554a0704b..90d2e412667df 100644 --- a/docs/core/porting/upgrade-assistant-overview.md +++ b/docs/core/porting/upgrade-assistant-overview.md @@ -19,11 +19,12 @@ Currently the tool supports the following .NET Framework app types: - .NET Framework Windows Forms apps - .NET Framework WPF apps +- .NET Framework UWP apps - .NET Framework ASP.NET MVC apps - .NET Framework console apps - .NET Framework class libraries -The tool also supports project that use these code languages: +The tool also supports projects that use these code languages: - C# - Visual Basic.NET diff --git a/docs/core/porting/upgrade-assistant-uwp-framework.md b/docs/core/porting/upgrade-assistant-uwp-framework.md new file mode 100644 index 0000000000000..e06e9321dfc1a --- /dev/null +++ b/docs/core/porting/upgrade-assistant-uwp-framework.md @@ -0,0 +1,539 @@ +--- +title: Upgrade UWP apps to .NET 6 +description: Use the .NET Upgrade Assistant to upgrade an existing .NET Framework UWP app to .NET 6. Your project will be migrated to the Windows App SDK, and WinUI 3. The .NET Upgrade Assistant is a CLI tool that helps migrating an app from .NET Framework to WinUI3. +author: adegeo +ms.date: 05/23/2022 +--- +# Migrate UWP apps to Windows App SDK with the .NET Upgrade Assistant + +The [.NET Upgrade Assistant](upgrade-assistant-overview.md) is a command-line tool that can assist with upgrading .NET Framework UWP apps to .NET 6. Your project will be migrated to the Windows App SDK, and use Windows UI (WinUI) 3. This article provides: + +- What to expect +- Things to know before starting +- A demonstration of how to run the tool against a UWP app +- Troubleshooting tips + +> [!NOTE] +> .NET Upgrade Assistant with UWP support capabilities will soon be available on nuget.org as mentioned here [Overview of the .NET Upgrade Assistant](upgrade-assistant-overview.md). In order to use .NET Upgrade Assistant for migration of UWP apps, please get the tool from the public AZDO pipeline feeds [here](https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-tools). + +For more information on how to install the tool, see [Overview of the .NET Upgrade Assistant](upgrade-assistant-overview.md). + +## What to expect + +This tool migrates your app by: + +- Backing up your project. +- Converts your project to the latest SDK format and cleans up your NuGet package references. +- Targets .NET 6 and Windows App SDK. +- Upgrades from WinUI 2 to WinUI 3. +- Adds new template files such as _App.Xaml_, _MainWindow.Xaml_ and publish profiles. +- Update namespaces and adds **MainPage** navigation. +- Attempts to detect and fix APIs that have changed, and marks APIs that are no longer supported, with `//TODO` code comments. + +We aim to provide migration guidance in form of warning messages within the tool and TODO comments within your project as the tool tries to migrate the project. In this way, you'll always be in control of your migration. And for the APIs where complete automation isn't possible, plan is to add `//TODO` comments for the developers to know where the work will be needed. A typical `//TODO` comment will also include a link to our existing migration documentation. Check the Task list within the Visual Studio to see all the action items as TODO comments. + +> [!NOTE] +> After a successful run of the tool, you may chose to do the following if needed: move your code from _App.xaml.old.cs_ to _App.xaml.cs_ and move AssemblyInfo.cs from backup + +## Things to know before starting + +This tool currently supports C#, and in most cases the app will require more effort to complete the migration. The goal of the tool is to convert your project and code, so that it can compile. Some features require you to investigate and fix, and have `//TODO` code comments. For more information about what to consider before migrating, see [What is supported when migrating from UWP to WinUI 3](/windows/apps/windows-app-sdk/migrate-to-windows-app-sdk/what-is-supported). + +Additionally, you may choose to wait for the next version of .NET Upgrade Assistant tool before you start migrating your app, because of the current limitations of the tool: + +- `ApplicationView` APIs aren't supported. +- `AppWindow` related APIs aren't supported. + + The upgrade tries to generate a warning where possible, and deliberately breaks your code so it doesn't compile until you adjust your code. + +- Custom views aren't supported. + + For example, you won't receive a warning or a fix for a `CustomDialog` that extends `MessageDialog` and calls an API incorrectly. + +- WinRT Components aren't supported. +- Multi window apps might not convert correctly. +- Apps that follow a nonstandard file structure (Such as _App.xaml_, _App.xaml.cs_ missing from the root folder) might not be converted correctly. + +This release is currently in preview, and is receiving frequent updates. If you discover problems using the tool, report them in the tool's [GitHub repository](https://github.com/dotnet/upgrade-assistant). Use the **UWP** area tag so that all UWP related issues can be redirected to us. + +> [!NOTE] +> You may also refer UWP migration guide [here](/windows/apps/windows-app-sdk/migrate-to-windows-app-sdk/migrate-to-windows-app-sdk-ovw) that will tell you more about the changes from UWP APIs to the new Windows App SDK supported APIs and capabilities. + +## A demonstration of how to run the tool against a UWP app + +You can use the [PhotoLab UWP Sample app](https://github.com/microsoft/Windows-appsample-photo-lab.git) project to test upgrading with the Upgrade Assistant. + +> [!NOTE] +> You may also want to see the manual migration of PhotoLab sample app as a case study documented [here](/windows/apps/windows-app-sdk/migrate-to-windows-app-sdk/case-study-1). + +For the demo, we have a UWP sample app called "PhotoLab", which is an app for viewing and editing image files, demonstrating XAML layout, data binding, and UI customization features. The app will require more effort to complete the migration. This should be familiar if you've used .NET Upgrade Assistant in the past to migrate a WPF or WinForms app from .NET Framework to .NET 6. Now, run it against the PhotoLab app, which is .NET Native UWP project, and follow the steps one-by-one. + +## Analyze your app + +> [!NOTE] +> At the time of publishing this document, Analyze command is not working as it should. We are working to resolve the same. You may use the upgrade command without skipping the backup step. + +The .NET Upgrade Assistant tool includes an analyze mode that performs a simplified dry run of upgrading your app. It may provide insights as to what changes may be required before the upgrade is started. Open a terminal and navigate to the folder where the target project or solution is located. Run the `upgrade-assistant analyze` command, passing in the name of the project or solution you're upgrading. + +For example, running the analyze mode with the [PhotoLab UWP Sample app](https://github.com/microsoft/Windows-appsample-photo-lab.git) produces the following output, indicating that there aren't any changes to be made before upgrading: + +```console +> upgrade-assistant analyze .\PhotoLab.sln + +[23:08:38 INF] Loaded 7 extensions +[23:08:53 INF] Using MSBuild from C:\Program Files\dotnet\sdk\6.0.200\ +[23:08:53 INF] Using Visual Studio install from C:\Program Files\Microsoft Visual Studio\2022\Preview [v17] +[23:09:04 INF] Writing output to .\AnalysisReport.sarif +[23:09:04 INF] Skip minimum dependency check because Windows App SDK cannot work with targets lower than already recommended TFM. +[23:09:04 INF] Recommending Windows TFM net6.0-windows because the project either has Windows-specific dependencies or builds to a WinExe +[23:09:04 INF] Marking package Microsoft.NETCore.UniversalWindowsPlatform for removal based on package mapping configuration UWP +[23:09:04 INF] Adding package Microsoft.WindowsAppSDK based on package mapping configuration UWP +[23:09:04 INF] Adding package CommunityToolkit.WinUI.UI.Animations based on package mapping configuration UWP +[23:09:04 INF] Adding package Microsoft.Graphics.Win2D based on package mapping configuration UWP +[23:09:04 INF] Marking package Microsoft.Toolkit.Uwp.UI.Animations for removal based on package mapping configuration UWP +[23:09:04 INF] Marking package Microsoft.UI.Xaml for removal based on package mapping configuration UWP +[23:09:06 WRN] No version of Microsoft.Toolkit.Uwp.UI.Animations found that supports ["net6.0-windows"]; leaving unchanged +[23:09:07 INF] Package Microsoft.UI.Xaml, Version=2.4.2 does not support the target(s) net6.0-windows but a newer version (2.7.1) does. +[23:09:09 INF] Package Microsoft.WindowsAppSDK, Version=1.0.0 does not support the target(s) net6.0-windows but a newer version (1.0.3) does. +[23:09:10 WRN] No version of CommunityToolkit.WinUI.UI.Animations found that supports ["net6.0-windows"]; leaving unchanged +[23:09:11 INF] Reference to .NET Upgrade Assistant analyzer package (Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, version 0.3.326103) needs to be added +[23:09:13 INF] Adding Microsoft.Windows.Compatibility 6.0.0 helps with speeding up the upgrade process for Windows-based APIs +[23:09:14 WRN] Unable to find a supported WinUI nuget package for Microsoft.Toolkit.Uwp.UI.Animations. Skipping this package. +[23:09:16 INF] Running analyzers on PhotoLab +[23:09:25 INF] Identified 7 diagnostics in project PhotoLab +[23:09:25 INF] Diagnostic UA307 with the message Detect UWP back button generated +[23:09:25 INF] Diagnostic UA307 with the message Detect UWP back button generated +[23:09:25 INF] Diagnostic UA309 with the message Detect content dialog api generated +[23:09:25 INF] Diagnostic UA307 with the message Detect UWP back button generated +[23:09:25 INF] Diagnostic UA307 with the message Detect UWP back button generated +[23:09:25 INF] Diagnostic UA309 with the message Detect content dialog api generated +[23:09:25 INF] Diagnostic UA310 with the message Tries to detect the creation of known classes that implement IInitializeWithWindow generated +[23:09:25 INF] Analysis Complete, the report is available at .\AnalysisReport.sarif +``` + +There's quite a bit of internal diagnostic information in the output, but some information is helpful. Notice that the analyze mode indicates that the upgrade will recommend that the project target the `net6.0-windows` target framework moniker ([TFM](../../standard/frameworks.md)). A console application would probably get the recommendation to upgrade to TFM `net6.0` directly, unless it used some Windows-specific libraries. + +If any errors or warnings are reported, take care of them before you start an upgrade. + +## Run upgrade-assistant + +Open a terminal and navigate to the folder where the target project or solution is located. Run the `upgrade-assistant upgrade` command, passing in the name of the project or solution you're upgrading. + +When a project is provided, the upgrade process starts on that project immediately. If a solution is provided, you'll select which project you normally run, known as the upgrade entrypoint. Based on that project, a dependency graph is created and a suggestion as to which order you should upgrade the projects is provided. + +```console +upgrade-assistant upgrade .\PhotoLab.sln +``` + +The tool runs and shows you a list of the steps it will do. As each step is completed, the tool provides a set of commands allowing the user to apply or skip the next step or some other option such as: + +- Get more information about the step. +- Change projects. +- Adjust logging settings. +- Stop the upgrade and quit. + +Pressing Enter without choosing a number selects the first item in the list. + +As each step initializes, it may provide information about what it thinks will happen if you apply the step. + +### Select the entrypoint and project to upgrade + +The first step in upgrading the [PhotoLab UWP Sample app](https://github.com/microsoft/Windows-appsample-photo-lab.git) is choosing which project in the solution serves as the entrypoint project. You may notice that there's only one entrypoint, this is because there's only one project in this solution. + +``` +[23:29:49 INF] Loaded 7 extensions +[23:29:52 INF] Using MSBuild from C:\Program Files\dotnet\sdk\6.0.200\ +[23:29:52 INF] Using Visual Studio install from C:\Program Files\Microsoft Visual Studio\2022\Preview [v17] +[23:30:01 INF] Initializing upgrade step Select an entrypoint +[23:30:01 INF] Setting entrypoint to only project in solution: .\source\repos\Windows-appsample-photo-lab\PhotoLab\PhotoLab.csproj +[23:30:01 INF] Initializing upgrade step Select project to upgrade +[23:30:04 INF] Initializing upgrade step Back up project +Upgrade Steps + +``` + +After the entrypoint is determined, the next step is to choose which project to upgrade first. However, in this example, the tool determined that there's only one project within the solution, and it should begin upgrading that project. + +### Upgrade the project + +Once a project is selected, a list of upgrade steps the tool will take is listed. + +> [!IMPORTANT] +> Based on the project you're upgrading, you may or may not see every step listed in this example. + +The following output describes the steps involved in upgrading the project: + +``` +[23:30:04 INF] Initializing upgrade step Back up project + +Upgrade Steps + +Entrypoint: .\source\repos\Windows-appsample-photo-lab\PhotoLab\PhotoLab.csproj +Current Project: .\source\repos\Windows-appsample-photo-lab\PhotoLab\PhotoLab.csproj + +1. [Next step] Back up project +2. Convert project file to SDK style +3. Clean up NuGet package references + a. Duplicate reference analyzer + b. Package map reference analyzer + c. Target compatibility reference analyzer + d. Upgrade assistant reference analyzer + e. Windows Compatibility Pack Analyzer + f. MyDotAnalyzer reference analyzer + g. Newtonsoft.Json reference analyzer + h. Windows App SDK package analysis + i. Transitive reference analyzer +4. Update TFM +5. Update NuGet Packages + a. Duplicate reference analyzer + b. Package map reference analyzer + c. Target compatibility reference analyzer + d. Upgrade assistant reference analyzer + e. Windows Compatibility Pack Analyzer + f. MyDotAnalyzer reference analyzer + g. Newtonsoft.Json reference analyzer + h. Windows App SDK package analysis + i. Transitive reference analyzer +6. Add template files +7. Update Windows Desktop Project + a. Update WinUI namespaces + b. Update WinUI Project Properties + c. Update package.appxmanifest + d. Remove unnecessary files + e. Update animations xaml + f. Insert back button in XAML +8. Update source code + a. Apply fix for UA0002: Types should be upgraded + b. Apply fix for UA0012: 'UnsafeDeserialize()' does not exist + c. Apply fix for UA0014: .NET MAUI projects should not reference Xamarin.Forms namespaces + d. Apply fix for UA0015: .NET MAUI projects should not reference Xamarin.Essentials namespaces + e. Apply fix for [UA306_A1, UA306_A2, UA306_A3, UA306_A4, UA306_B, UA306_C, UA306_D, UA306_E, UA306_F, UA306_G, UA306_H, UA306_I]: Replace usage of Windows.UI.Core.CoreDispatcher, Replace usage of Window.Current.Dispatcher, Replace usage of App.Window.Dispatcher, Replace usage of Window.Dispatcher, Replace usage of Windows.Media.Capture.CameraCaptureUI, Replace usage of Micorsoft.UI.Xaml.Controls.InkCanvas, Replace usage of Microsoft.UI.Xaml.Controls.Maps.MapControl, Replace usage of Microsoft.UI.Xaml.Controls.MediaElement, Replace usage of Windows.Graphics.Printing.PrintManager, Replace usage of Windows.Security.Authentication.Web.WebAuthenticationBroker, Replace usage of Windows.UI.Xaml.Media.AcrylicBrush.BackgroundSource, Replace usage of Windows.UI.Shell.TaskbarManager + f. Apply fix for UA307: Custom back button implementation is needed + g. Apply fix for UA309: ContentDialog API needs to set XamlRoot + h. Apply fix for UA310: Classes that implement IInitializeWithWindow need to be initialized with Window Handle + i. Apply fix for UA311: Classes that implement IDataTransferManager should use IDataTransferManagerInterop.ShowShareUIForWindow + j. Apply fix for UA312: Interop APIs should use the window handle + k. Apply fix for [UA313, UA314]: MRT to MRT core migration, MRT to MRT core migration + l. Apply fix for [UA315_A, UA315_C, UA315_B]: Windows App SDK apps should use Microsoft.UI.Windowing.AppWindow, Windows App SDK apps should use Microsoft.UI.Windowing.AppWindow, Windows App SDK apps should use Microsoft.UI.Windowing.AppWindow +9. Move to next project + +Choose a command: + 1. Apply next step (Back up project) + 2. Skip next step (Back up project) + 3. See more step details + 4. Configure logging + 5. Exit +``` + +#### Upgrade the project file + +The project is upgraded from the .NET Framework project format to the .NET SDK project format. + +``` +[02:14:51 INF] Applying upgrade step Convert project file to SDK style +[02:14:52 INF] Converting project file format with try-convert, version 0.9.0-dev +[02:14:54 INF] Skip minimum dependency check because Windows App SDK cannot work with targets lower than already recommended TFM. +[02:14:54 INF] Recommending Windows TFM net6.0-windows because the project either has Windows-specific dependencies or builds to a WinExe +[02:14:56 INF] Converting project .\source\repos\Windows-appsample-photo-lab\PhotoLab\PhotoLab.csproj to SDK style +[02:14:58 INF] Project file converted successfully! The project may require additional changes to build successfully against the new .NET target. +[02:15:01 INF] Upgrade step Convert project file to SDK style applied successfully +``` + +Pay attention to the output of each step. The tool will indicate a message and you may need to make changes manually from this step onwards. + +#### Clean up NuGet references + +Once the project format has been updated, the next step is to clean up the NuGet package references. + +In addition to the packages referenced by your app, the _packages.config_ file contains references to the dependencies of those packages. For example, if you added reference to package **A** which depends on package **B**, both packages would be referenced in the _packages.config_ file. In the new project system, only the reference to package **A** is required. This step analyzes the package references and removes those that aren't required. + +``` +[02:18:32 INF] Initializing upgrade step Clean up NuGet package references +[02:18:32 INF] Initializing upgrade step Duplicate reference analyzer +[02:18:32 INF] No package updates needed +[02:18:32 INF] Initializing upgrade step Package map reference analyzer +[02:18:32 INF] Marking package Microsoft.NETCore.UniversalWindowsPlatform for removal based on package mapping configuration UWP +[02:18:32 INF] Adding package Microsoft.WindowsAppSDK based on package mapping configuration UWP +[02:18:32 INF] Adding package CommunityToolkit.WinUI.UI.Animations based on package mapping configuration UWP +[02:18:32 INF] Adding package Microsoft.Graphics.Win2D based on package mapping configuration UWP +[02:18:32 INF] Marking package Microsoft.Toolkit.Uwp.UI.Animations for removal based on package mapping configuration UWP +[02:18:32 INF] Marking package Microsoft.UI.Xaml for removal based on package mapping configuration UWP + +[02:19:04 INF] Applying upgrade step Remove package 'Microsoft.NETCore.UniversalWindowsPlatform' +[02:19:04 INF] Removing outdated package reference: Microsoft.NETCore.UniversalWindowsPlatform, Version=5.3.3 +[02:19:04 INF] Upgrade step Remove package 'Microsoft.NETCore.UniversalWindowsPlatform' applied successfully + + +[02:20:34 INF] Applying upgrade step Remove package 'Microsoft.Toolkit.Uwp.UI.Animations' +[02:20:34 INF] Removing outdated package reference: Microsoft.Toolkit.Uwp.UI.Animations, Version=1.5.1 +[02:20:34 INF] Upgrade step Remove package 'Microsoft.Toolkit.Uwp.UI.Animations' applied successfully + +[02:21:38 INF] Removing outdated package reference: Microsoft.UI.Xaml, Version=2.4.2 +[02:21:38 INF] Upgrade step Remove package 'Microsoft.UI.Xaml' applied successfully + +[02:22:13 INF] Adding package reference: Microsoft.WindowsAppSDK, Version=1.0.0 +[02:22:13 INF] Upgrade step Add package 'Microsoft.WindowsAppSDK' applied successfully + +[02:22:13 INF] Adding package reference: Microsoft.WindowsAppSDK, Version=1.0.0 +[02:22:13 INF] Upgrade step Add package 'Microsoft.WindowsAppSDK' applied successfully +Please press enter to continue... + +[02:23:04 INF] Adding package reference: CommunityToolkit.WinUI.UI.Animations, Version=7.1.2 +[02:23:04 INF] Upgrade step Add package 'CommunityToolkit.WinUI.UI.Animations' applied successfully + +[02:23:42 INF] Adding package reference: Microsoft.Graphics.Win2D, Version=1.0.0.30 +[02:23:42 INF] Upgrade step Add package 'Microsoft.Graphics.Win2D' applied successfully + +[02:23:42 INF] Applying upgrade step Package map reference analyzer +[02:23:42 INF] Upgrade step Package map reference analyzer applied successfully + +[02:24:22 INF] Initializing upgrade step Target compatibility reference analyzer +[02:24:22 INF] No package updates needed +[02:24:22 INF] Initializing upgrade step Upgrade assistant reference analyzer +[02:24:23 INF] Reference to .NET Upgrade Assistant analyzer package (Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, version 0.3.326103) needs to be added +[02:24:23 INF] Initializing upgrade step Add package 'Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers' + +[02:28:38 INF] Applying upgrade step Add package 'Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers' +[02:28:38 INF] Adding package reference: Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, Version=0.3.326103 +[02:28:38 INF] Upgrade step Add package 'Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers' applied successfully +[02:28:38 INF] Applying upgrade step Upgrade assistant reference analyzer +[02:28:38 INF] Upgrade step Upgrade assistant reference analyzer applied successfully +[02:28:52 INF] Applying upgrade step Add package 'Microsoft.Windows.Compatibility' +[02:28:52 INF] Adding package reference: Microsoft.Windows.Compatibility, Version=6.0.0 +[02:28:52 INF] Upgrade step Add package 'Microsoft.Windows.Compatibility' applied successfully +[02:28:52 INF] Applying upgrade step Windows Compatibility Pack Analyzer +[02:28:52 INF] Upgrade step Windows Compatibility Pack Analyzer applied successfully +[02:29:06 INF] Initializing upgrade step MyDotAnalyzer reference analyzer +[02:29:06 INF] No package updates needed +[02:29:06 INF] Initializing upgrade step Newtonsoft.Json reference analyzer +[02:29:06 INF] No package updates needed +[02:29:06 INF] Initializing upgrade step Windows App SDK package analysis +[02:29:06 INF] No package updates needed +[02:29:06 INF] Initializing upgrade step Transitive reference analyzer +[02:29:06 INF] No package updates needed +[02:29:06 INF] Applying upgrade step Clean up NuGet package references +[02:29:06 INF] Upgrade step Clean up NuGet package references applied successfully +``` + +Your app is still referencing .NET Framework assemblies. Some of those assemblies may be available as NuGet packages. This step analyzes those assemblies and references the appropriate NuGet package. + +In this example, a user may also see app specific reference such as Microsoft.Toolkit.Uwp.UI.Animations, `CommunityToolkit.WinUI.UI.Animations` and `Microsoft.Graphics.Win2D`. + +#### Handle the TFM + +The tool next changes the [TFM](../../standard/frameworks.md) from .NET Framework to the suggested SDK. In this example, it's `net6.0-windows`. + +``` +[02:29:06 INF] Initializing upgrade step Update TFM +[02:29:06 INF] Skip minimum dependency check because Windows App SDK cannot work with targets lower than already recommended TFM. +[02:29:06 INF] Recommending Windows TFM net6.0-windows10.0.19041 because the project either has Windows-specific dependencies or builds to a WinExe +``` + +#### Upgrade NuGet packages + +Next, the tool updates the project's NuGet packages to the versions that support the updated TFM, `net6.0-windows`. + +``` +[02:29:06 INF] Initializing upgrade step Update NuGet Packages +[02:29:06 INF] Initializing upgrade step Duplicate reference analyzer +[02:29:06 INF] No package updates needed +[02:29:06 INF] Initializing upgrade step Package map reference analyzer +[02:29:06 INF] No package updates needed +[02:29:06 INF] Initializing upgrade step Target compatibility reference analyzer +[02:29:06 INF] No package updates needed +[02:29:06 INF] Initializing upgrade step Upgrade assistant reference analyzer +[02:29:06 INF] No package updates needed +[02:29:06 INF] Initializing upgrade step Windows Compatibility Pack Analyzer +[02:29:07 INF] No package updates needed +[02:29:07 INF] Initializing upgrade step MyDotAnalyzer reference analyzer +[02:29:07 INF] No package updates needed +[02:29:07 INF] Initializing upgrade step Newtonsoft.Json reference analyzer +[02:29:07 INF] No package updates needed +[02:29:07 INF] Initializing upgrade step Windows App SDK package analysis +[02:29:07 INF] No package updates needed +[02:29:07 INF] Initializing upgrade step Transitive reference analyzer +[02:29:07 INF] No package updates needed +[02:29:07 INF] Applying upgrade step Update NuGet Packages +[02:29:07 INF] Upgrade step Update NuGet Packages applied successfully +``` + +#### Templates, config, and code files + +The next few steps may be skipped automatically by the tool if the tool determines there isn't anything to do for your project. + +Once the packages are updated, the next step is to update any template files. In this example, the tool automatically adds necessary publish profiles, _App.xaml.cs_, _MainWindow.xaml.cs_, _MainWindow.xaml_ etc. + +``` +[02:32:44 INF] Applying upgrade step Add template files +[02:32:44 INF] Added template file app.manifest +[02:32:44 INF] Added template file Properties\launchSettings.json +[02:32:44 INF] Added template file Properties\PublishProfiles\win10-arm64.pubxml +[02:32:44 INF] Added template file Properties\PublishProfiles\win10-x64.pubxml +[02:32:44 INF] Added template file Properties\PublishProfiles\win10-x86.pubxml +[02:32:44 INF] File already exists, moving App.xaml.cs to App.xaml.old.cs +[02:32:44 INF] Added template file App.xaml.cs +[02:32:44 INF] Added template file MainWindow.xaml.cs +[02:32:44 INF] Added template file MainWindow.xaml +[02:32:44 INF] Added template file UWPToWinAppSDKUpgradeHelpers.cs +[02:32:44 INF] 9 template items added +[02:32:44 INF] Upgrade step Add template files applied successfully +``` + +#### UWP specific changes + +The next step for the tool is to update the UWP app to the new Windows Desktop Project. + +> [!IMPORTANT] +> You may chose to skip the step for back button insertion as per your wish. Inserting back button may cause the UI to behave differently. If this happens, remove the stack panel that is inserted as a parent of the back button and reposition the back button where it seems . + +``` +[02:36:53 INF] Applying upgrade step Update WinUI namespaces +[02:36:53 INF] Upgrade step Update WinUI namespaces applied successfully + +[02:38:45 INF] Applying upgrade step Update WinUI Project Properties +[02:38:46 INF] Upgrade step Update WinUI Project Properties applied successfully + +[02:39:11 INF] Applying upgrade step Update package.appxmanifest +[02:39:11 INF] Upgrade step Update package.appxmanifest applied successfully + +[02:39:11 INF] Applying upgrade step Update package.appxmanifest +[02:39:11 INF] Upgrade step Update package.appxmanifest applied successfully + +[02:39:37 INF] Applying upgrade step Remove unnecessary files +[02:39:37 INF] Deleting .\source\repos\Windows-appsample-photo-lab\PhotoLab\Properties\AssemblyInfo.cs as it is not required for Windows App SDK projects. +[02:39:37 INF] Upgrade step Remove unnecessary files applied successfully + +[02:40:22 INF] Applying upgrade step Update animations xaml +[02:40:22 INF] Upgrade step Update animations xaml applied successfully + +[02:40:42 INF] Applying upgrade step Insert back button in XAML +[02:40:42 INF] Upgrade step Insert back button in XAML applied successfully +[02:40:42 INF] Applying upgrade step Update Windows Desktop Project +[02:40:42 INF] Upgrade step Update Windows Desktop Project applied successfully +``` + +#### Updating the source code + +In this step, the tool will try to migrate your code and perform source specific code changes. + +Code migration for the PhotoLab sample app includes: + +- Changes to Content Dialog and File Save picker APIs. +- Xaml update for Animations package. +- Showing warning messages and adding TODO comments in _DetailPage.xaml_ and _DetailPage.xaml.cs_ and _MainPage.xaml.cs_ for custom back button. +- Implementing the back button functionality and adding a TODO comment to customize XAML button. +- A documentation link can be accessed from the CLI tool to study more about for back button implementation. + +``` +[02:41:34 INF] Applying upgrade step Apply fix for UA307: Custom back button implementation is needed +[02:41:34 WRN] .\source\repos\Windows-appsample-photo-lab\PhotoLab\MainPage.xaml.cs + TODO UA307 Default back button in the title bar does not exist in WinUI3 apps. + The tool has generated a custom back button "UAGeneratedBackButton" in the XAML file. + Feel free to edit its position, behavior and use the custom back button instead. + Read: https://aka.ms/UA-back-button +[02:41:34 INF] Diagnostic UA307 fixed in .\source\repos\Windows-appsample-photo-lab\PhotoLab\MainPage.xaml.cs +[02:41:34 WRN] .\source\repos\Windows-appsample-photo-lab\PhotoLab\DetailPage.xaml.cs + TODO UA307 Default back button in the title bar does not exist in WinUI3 apps. + The tool has generated a custom back button "UAGeneratedBackButton" in the XAML file. + Feel free to edit its position, behavior and use the custom back button instead. + Read: https://aka.ms/UA-back-button +[02:41:34 INF] Diagnostic UA307 fixed in .\source\repos\Windows-appsample-photo-lab\PhotoLab\DetailPage.xaml.cs +[02:41:34 INF] Running analyzers on PhotoLab +[02:41:37 INF] Identified 4 diagnostics in project PhotoLab +[02:41:37 WRN] .\source\repos\Windows-appsample-photo-lab\PhotoLab\DetailPage.xaml.cs + TODO UA307 Default back button in the title bar does not exist in WinUI3 apps. + The tool has generated a custom back button "UAGeneratedBackButton" in the XAML file. + Feel free to edit its position, behavior and use the custom back button instead. + Read: https://aka.ms/UA-back-button +[02:41:37 INF] Diagnostic UA307 fixed in .\source\repos\Windows-appsample-photo-lab\PhotoLab\DetailPage.xaml.cs +[02:41:37 INF] Running analyzers on PhotoLab +[02:41:39 INF] Identified 3 diagnostics in project PhotoLab +[02:41:39 INF] Upgrade step Apply fix for UA307: Custom back button implementation is needed applied successfully + +[02:45:20 INF] Applying upgrade step Apply fix for UA309: ContentDialog API needs to set XamlRoot +[02:45:20 INF] Diagnostic UA309 fixed in .\source\repos\Windows-appsample-photo-lab\PhotoLab\DetailPage.xaml.cs +[02:45:20 INF] Diagnostic UA309 fixed in .\source\repos\Windows-appsample-photo-lab\PhotoLab\MainPage.xaml.cs +[02:45:20 INF] Running analyzers on PhotoLab +[02:45:23 INF] Identified 1 diagnostics in project PhotoLab +[02:45:23 INF] Upgrade step Apply fix for UA309: ContentDialog API needs to set XamlRoot applied successfully + +[02:45:52 INF] Applying upgrade step Apply fix for UA310: Classes that implement IInitializeWithWindow need to be initialized with Window Handle +[02:45:52 INF] Diagnostic UA310 fixed in ..\source\repos\Windows-appsample-photo-lab\PhotoLab\DetailPage.xaml.cs +[02:45:52 INF] Running analyzers on PhotoLab +[02:45:54 INF] Identified 0 diagnostics in project PhotoLab +[02:45:54 INF] Applying upgrade step Update source code +[02:46:00 INF] Upgrade step Update source code applied successfully +[02:46:00 INF] Upgrade step Apply fix for UA310: Classes that implement IInitializeWithWindow need to be initialized with Window Handle applied successfully +``` + +#### Completing the upgrade + +If there are any more projects to migrate, the tool lets you select which project to upgrade next. When there are no more projects to upgrade, the tool brings you to the "Finalize upgrade" step: + +``` +1. [Next step] Finalize upgrade + +Choose a command: + 1. Apply next step (Finalize upgrade) + 2. Skip next step (Finalize upgrade) + 3. See more step details + 4. Configure logging + 5. Exit +> +[02:47:13 INF] Applying upgrade step Finalize upgrade +[02:47:13 INF] Upgrade step Finalize upgrade applied successfully +``` + +Ideally, after successfully running the tool, the user should be able to F5 and run their new WinUI3 desktop project of PhotoLab app. Once the upgrade is complete, the migrated UWP project looks like the following XML: + +```xml + + + net6.0-windows10.0.19041.0 + x86 + WinExe + en-US + 10.0.17763.0 + win10-x86;win10-x64;win10-arm64 + true + app.manifest + true + x86;x64;arm64 + win10-$(Platform).pubxml + + + + Designer + + + + + + + + all + + + + + + + + + + +``` + +Notice that the .NET Upgrade Assistant also adds analyzers to the project that assist with continuing the upgrade process, such as the `Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers` NuGet package. + +Also notice that it's using Windows App SDK, WinUI3, and .NET 6. And now, you can take advantage of all new features that modern apps have to offer and grow your app with the platform. + +## After upgrading + +After you upgrade your projects, you'll need to compile and test them. Most certainly you'll have more work to do in finishing the upgrade. All TODO comments and action items can be seen on the Task List inside the Visual Studio. To open the Task List, press **View** > **TaskList**. It's possible that the .NET Framework version of your app contained library references that your project isn't actually using. You'll need to analyze each reference and determine whether or not it's required. The tool may have also added or upgraded a NuGet package reference to wrong version. + +## Troubleshooting tips + +There are several known problems that can occur when using the .NET Upgrade Assistant. In some cases, these problems are with the [try-convert tool](https://github.com/dotnet/try-convert) that the .NET Upgrade Assistant uses internally. + +[The tool's GitHub repository](https://github.com/dotnet/upgrade-assistant#troubleshooting-common-issues) has more troubleshooting tips and known issues. diff --git a/docs/core/porting/versioning-sdk-msbuild-vs.md b/docs/core/porting/versioning-sdk-msbuild-vs.md index d6f9713c68ec9..0db0d75000658 100644 --- a/docs/core/porting/versioning-sdk-msbuild-vs.md +++ b/docs/core/porting/versioning-sdk-msbuild-vs.md @@ -19,28 +19,34 @@ For example, version 5.0.203 ships with .NET 5, is the second minor Visual Studi The support timeframe for the SDK typically matches that of the Visual Studio version it's included in. -| SDK Version | MSBuild/VS version | Ship date | Lifecycle | +| SDK Version | MSBuild/Visual Studio version | Ship date | Lifecycle | |------------------|--------------------|--------------|-----------| -| 2.1.5xx | 15.9 | Nov '18 | Aug '21* | +| 2.1.5xx | 15.9 | Nov '18 | Aug '211 | | 2.1.8xx | 16.2 (No VS) | July '19 | Aug '21 | | 3.1.1xx | 16.4 | Dec '19 | Oct '21 | | 3.1.4xx | 16.7 | Aug '20 | Dec '22 | | 5.0.1xx | 16.8 | Nov '20 | Mar '21 | -| 5.0.2xx | 16.9 | March '21 | Aug '22 | +| 5.0.2xx | 16.9 | March '21 | May '221 | | 5.0.3xx | 16.10 | May '21 | Aug '21 | -| 5.0.4xx | 16.11 | Aug '21 | Feb '22* | -| 6.0.100 | 17.0** | Nov '21 | TBD | -| 6.0.200 | 17.1 | Feb '22 | TBD | -| 6.0.300 | 17.2^ | TBD | TBD | +| 5.0.4xx | 16.11 | Aug '21 | May '221 | +| 6.0.100 | 17.02 | Nov '21 | Jul '23 | +| 6.0.200 | 17.1 | Feb '22 | May '22 | +| 6.0.300 | 17.23 | May '22 | TBD | +| 6.0.400 | 17.3 | TBD | TBD | +| 7.0.100 | 17.4 | TBD | TBD | > [!NOTE] > Targeting `net6.0` is officially supported in Visual Studio 17.0+ only. -> \* MSBuild/Visual Studio supported for longer +> 1 MSBuild/Visual Studio supported for longer. > -> \*\* When .NET 6 releases, the goal is for the .NET SDK to be functional in version 16.11 for **downlevel** targeting. This means that you're not forced to update your SDK and Visual Studio versions simultaneously. However, you won't be able to target .NET 6 because of limitations in 6.0 features and C#10 features in version 16.11. This compatibility is specifically for targeting 5.0 and below. +> [Visual Studio 2019 Lifecycle](/lifecycle/products/visual-studio-2019) > -> ^ 6.0.300 and newer SDKs require a minimum Visual Studio version of 17.0. +> [Visual Studio 2022 Lifecycle](/lifecycle/products/visual-studio-2022) + +> 2 With .NET 6, the.NET 6.0.100 SDK can be used in version 16.11 for **downlevel** targeting. This means that you're not forced to update your SDK and Visual Studio versions simultaneously. However, you won't be able to target .NET 6 because of limitations in 6.0 features and C# 10 features in version 16.11. This compatibility is specifically for targeting 5.0 and below. +> +> 3 6.0.300 and newer SDKs require a minimum Visual Studio version of 17.0. Expect breaking changes that require a new MSBuild and Visual Studio version at least once a year, for each major SDK release. All versions of 5.0.Nxx SDK will load on all versions of Visual Studio and MSBuild from 16.8 - 16.11, as no breaking changes were made during that time. There shouldn't be breaking changes in SDK feature (patch) updates. diff --git a/docs/core/project-sdk/msbuild-props.md b/docs/core/project-sdk/msbuild-props.md index 2c45af4928e6d..23a21eca0122e 100644 --- a/docs/core/project-sdk/msbuild-props.md +++ b/docs/core/project-sdk/msbuild-props.md @@ -1,7 +1,7 @@ --- title: MSBuild properties for Microsoft.NET.Sdk description: Reference for the MSBuild properties and items that are understood by the .NET SDK. -ms.date: 01/13/2022 +ms.date: 05/24/2022 ms.topic: reference ms.custom: updateeachrelease --- @@ -148,7 +148,9 @@ The following MSBuild properties are documented in this section: - [CopyLocalLockFileAssemblies](#copylocallockfileassemblies) - [EnablePackageValidation](#enablepackagevalidation) - [ErrorOnDuplicatePublishOutputFiles](#erroronduplicatepublishoutputfiles) +- [GenerateRuntimeConfigDevFile](#generateruntimeconfigdevfile) - [GenerateRuntimeConfigurationFiles](#generateruntimeconfigurationfiles) +- [GenerateSatelliteAssembliesForCore](#generatesatelliteassembliesforcore) - [IsPublishable](#ispublishable) - [PreserveCompilationContext](#preservecompilationcontext) - [PreserveCompilationReferences](#preservecompilationreferences) @@ -221,6 +223,16 @@ The `EnablePackageValidation` property enables a series of validations on the pa This property was introduced in .NET 6. +### GenerateRuntimeConfigDevFile + +Starting with the .NET 6 SDK, the *\[Appname].runtimesettings.dev.json* file is [no longer generated by default](../compatibility/sdk/6.0/runtimeconfigdev-file.md) at compile time. If you still want this file to be generated, set the `GenerateRuntimeConfigDevFile` property to `true`. + +```xml + + true + +``` + ### GenerateRuntimeConfigurationFiles The `GenerateRuntimeConfigurationFiles` property controls whether runtime configuration options are copied from the *runtimeconfig.template.json* file to the *[appname].runtimeconfig.json* file. For apps that require a *runtimeconfig.json* file, that is, those whose `OutputType` is `Exe`, this property defaults to `true`. @@ -231,6 +243,19 @@ The `GenerateRuntimeConfigurationFiles` property controls whether runtime config ``` +### GenerateSatelliteAssembliesForCore + +The `GenerateSatelliteAssembliesForCore` property controls whether satellite assemblies are generated using *csc.exe* or [Al.exe (Assembly Linker)](../../framework/tools/al-exe-assembly-linker.md) in .NET Framework projects. (.NET Core and .NET 5+ projects always use *csc.exe* to generate satellite assemblies.) For .NET Framework projects, satellite assemblies are created by *al.exe*, by default. By setting the `GenerateSatelliteAssembliesForCore` property to `true`, satellite assemblies are created by *csc.exe* instead. Using *csc.exe* can be advantageous in the following situations: + +- You want to use the C# compiler [`deterministic` option](../../csharp/language-reference/compiler-options/code-generation.md#deterministic). +- You're limited by the fact that *al.exe* has no support for public signing and handles poorly. + +```xml + + true + +``` + ### IsPublishable The `IsPublishable` property allows the `Publish` target to run. This property only affects processes that use *.\*proj* files and the `Publish` target, such as the [dotnet publish](../tools/dotnet-publish.md) command. It does not affect publishing in Visual Studio, which uses the `PublishOnly` target. The default value is `true`. diff --git a/docs/core/rid-catalog.md b/docs/core/rid-catalog.md index fbdf250ab5af8..40c6b17da209d 100644 --- a/docs/core/rid-catalog.md +++ b/docs/core/rid-catalog.md @@ -1,7 +1,7 @@ --- title: .NET Runtime Identifier (RID) catalog description: Learn about the Runtime Identifier (RID) and how RIDs are used in .NET. -ms.date: 04/13/2022 +ms.date: 05/18/2022 ms.topic: reference --- # .NET RID Catalog @@ -151,6 +151,56 @@ macOS RIDs use the older "OSX" branding. Only common values are listed. For the For more information, see [.NET dependencies and requirements](./install/macos.md). +## iOS RIDs + +Only common values are listed. For the latest and complete version, see the [runtime.json](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json) file in the `dotnet/runtime` repository. + +- iOS, not version-specific + - `ios-arm64` +- iOS 10 + - `ios.10-arm64` +- iOS 11 + - `ios.11-arm64` +- iOS 12 + - `ios.12-arm64` +- iOS 13 + - `ios.13-arm64` +- iOS 14 + - `ios.14-arm64` +- iOS 15 + - `ios.15-arm64` + +## Android RIDs + +Only common values are listed. For the latest and complete version, see the [runtime.json](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json) file in the `dotnet/runtime` repository. + +- Android, not version-specific + - `android-arm64` +- Android 21 + - `android.21-arm64` +- Android 22 + - `android.22-arm64` +- Android 23 + - `android.23-arm64` +- Android 24 + - `android.24-arm64` +- Android 25 + - `android.25-arm64` +- Android 26 + - `android.26-arm64` +- Android 27 + - `android.27-arm64` +- Android 28 + - `android.28-arm64` +- Android 29 + - `android.29-arm64` +- Android 30 + - `android.30-arm64` +- Android 31 + - `android.31-arm64` +- Android 32 + - `android.32-arm64` + ## See also - [Runtime IDs](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/readme.md) diff --git a/docs/core/runtime-config/debugging-profiling.md b/docs/core/runtime-config/debugging-profiling.md index 9c4a3ae7cebf4..832dbb4436042 100644 --- a/docs/core/runtime-config/debugging-profiling.md +++ b/docs/core/runtime-config/debugging-profiling.md @@ -51,10 +51,12 @@ This article details the settings you can use to configure .NET debugging and pr | **Environment variable** | `CORECLR_PROFILER_PATH_32` | *string-path* | | **Environment variable** | `CORECLR_PROFILER_PATH_64` | *string-path* | -## Write perf map +## Export perf maps -- Enables or disables writing */tmp/perf-$pid.map* on Linux systems. +- Enables or disables emitting perf maps to */tmp/perf-$pid.map*. Perf maps allow third party tools, such as perf, to identify call sites from precompiled ReadyToRun (R2R) modules. - If you omit this setting, writing the perf map is disabled. This is equivalent to setting the value to `0`. +- When perf maps are disabled, not all managed callsites will be properly resolved. +- Enabling perf maps causes a 10-20% overhead. | | Setting name | Values | | - | - | - | @@ -72,4 +74,4 @@ This article details the settings you can use to configure .NET debugging and pr | **Environment variable** | `COMPlus_PerfMapIgnoreSignal` or `DOTNET_PerfMapIgnoreSignal` | `0` - disabled
`1` - enabled | > [!NOTE] -> This setting is ignored if [DOTNET_PerfMapEnabled](#write-perf-map) is omitted or set to `0` (that is, disabled). +> This setting is ignored if [DOTNET_PerfMapEnabled](#export-perf-maps) is omitted or set to `0` (that is, disabled). diff --git a/docs/core/runtime-config/garbage-collector.md b/docs/core/runtime-config/garbage-collector.md index 6b9ab8f6e0cd9..a5d4e2aeb0d35 100644 --- a/docs/core/runtime-config/garbage-collector.md +++ b/docs/core/runtime-config/garbage-collector.md @@ -1,22 +1,92 @@ --- title: Garbage collector config settings description: Learn about run-time settings for configuring how the garbage collector manages memory for .NET Core apps. -ms.date: 07/10/2020 +ms.date: 04/20/2022 ms.topic: reference --- # Runtime configuration options for garbage collection -This page contains information about garbage collector (GC) settings that can be changed at run time. If you're trying to achieve peak performance of a running app, consider using these settings. However, the defaults provide optimum performance for most applications in typical situations. +This page contains information about settings for the .NET runtime garbage collector (GC). If you're trying to achieve peak performance of a running app, consider using these settings. However, the defaults provide optimum performance for most applications in typical situations. Settings are arranged into groups on this page. The settings within each group are commonly used in conjunction with each other to achieve a specific result. > [!NOTE] > -> - These settings can also be changed dynamically by the app as it's running, so any run-time settings you set may be overridden. +> - These settings can also be changed dynamically by the app as it's running, so any configuration options you set may be overridden. > - Some settings, such as [latency level](../../standard/garbage-collection/latency.md), are typically set only through the API at design time. Such settings are omitted from this page. > - For number values, use decimal notation for settings in the *runtimeconfig.json* file and hexadecimal notation for environment variable settings. For hexadecimal values, you can specify them with or without the "0x" prefix. > - If you're using the environment variables, .NET 6 standardizes on the prefix `DOTNET_` instead of `COMPlus_`. However, the `COMPlus_` prefix will continue to work. If you're using a previous version of the .NET runtime, you should still use the `COMPlus_` prefix, for example, `COMPlus_gcServer`. +## Ways to specify the configuration + +For different versions of the .NET runtime, there are different ways to specify the configuration values. The following table shows a summary. + +| Config location | .NET versions this location applies to | Formats | How it's interpreted | +| -------------------- | -------------------------------------- | -------- | ------------------------------------------------------------ | +| runtimeconfig.json file | .NET Core | n | n is interpreted as a decimal value. | +| Environment variable | .NET Framework, .NET Core | 0xn or n | n is interpreted as a hex value in either format | +| app.config file | .NET Framework | 0xn | n is interpreted as a hex value1 | + +1 You can specify a value without the `0x` prefix for an app.config file setting, but it's not recommended. On .NET Framework 4.8+, due to a bug, a value specified without the `0x` prefix is interpreted as hexadecimal, but on previous versions of .NET Framework, it's interpreted as decimal. To avoid having to change your config, use the `0x` prefix when specifying a value in your app.config file. + +For example, to specify 12 heaps for `GCHeapCount` for a .NET Framework app named *A.exe*, add the following XML to the *A.exe.config* file. + +```xml + + + ... + + + 0xc + + +``` + +For both .NET Core and .NET Framework, you can use environment variables. + +On Windows using .NET 5 or a later version: + +```cmd +SET DOTNET_gcServer=1 +SET DOTNET_GCHeapCount=c +``` + +On Windows using .NET Core 3.1 or earlier: + +```cmd +SET COMPlus_gcServer=1 +SET COMPlus_GCHeapCount=c +``` + +On other operating systems: + +For .NET 5 or later versions: + +```bash +export DOTNET_gcServer=1 +export DOTNET_GCHeapCount=c +``` + +For .NET Core 3.1 and earlier versions: + +```bash +export COMPlus_gcServer=1 +export COMPlus_GCHeapCount=c +``` + +For .NET Core only, you can set the value in the *runtimeconfig.json* file. + +```json +{ + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true, + "System.GC.HeapCount": 12 + } + } +} +``` + ## Flavors of garbage collection The two main flavors of garbage collection are workstation GC and server GC. For more information about differences between the two, see [Workstation and server garbage collection](../../standard/garbage-collection/workstation-server-gc.md). @@ -495,7 +565,7 @@ Example: | **Environment variable** | `COMPlus_GCName` | *string_path* | .NET Core 2.0 | | **Environment variable** | `DOTNET_GCName` | *string_path* | .NET 6 | -## Conserve Memory +## Conserve memory - Configures the garbage collector to conserve memory at the expense of more frequent garbage collections and possibly longer pause times. - Default value is 0 - this implies no change. @@ -506,7 +576,6 @@ Example: | - | - | - | - | | **runtimeconfig.json** | N/A | N/A | N/A | | **Environment variable** | `COMPlus_GCConserveMemory` | `0` -`9` | .NET Framework 4.8 | -| **Environment variable** | `COMPlus_GCConserveMemory` | `0` -`9` | .NET 6 | | **Environment variable** | `DOTNET_GCConserveMemory` | `0` -`9` | .NET 6 | | **app.config for .NET Framework** | [GCConserveMemory](../../framework/configure-apps/file-schema/runtime/gcconservememory-element.md) | `0` -`9` | .NET Framework 4.8 | diff --git a/docs/core/runtime-config/threading.md b/docs/core/runtime-config/threading.md index e38048afbc16f..34b8169b97d49 100644 --- a/docs/core/runtime-config/threading.md +++ b/docs/core/runtime-config/threading.md @@ -104,6 +104,7 @@ In some cases, the thread pool detects work items that block its threads. To com | `System.Threading.ThreadPool.Blocking.ThreadsPerDelayStep_ProcCountFactor` | After the thread count based on `ThreadsToAddWithoutDelay` is reached, this value (after it is multiplied by the processor count) specifies after how many threads an additional `DelayStepMs` would be added to the delay before each new thread is created. | .NET 6 | | `System.Threading.ThreadPool.Blocking.DelayStepMs` | After the thread count based on `ThreadsToAddWithoutDelay` is reached, this value specifies how much additional delay to add per `ThreadsPerDelayStep` threads, which would be applied before each new thread is created. | .NET 6 | | `System.Threading.ThreadPool.Blocking.MaxDelayMs` | After the thread count based on `ThreadsToAddWithoutDelay` is reached, this value specifies the max delay to use before each new thread is created. | .NET 6 | +| `System.Threading.ThreadPool.Blocking.IgnoreMemoryUsage` | By default, the rate of thread injection in response to blocking is limited by heuristics that determine whether there is sufficient physical memory available. In some situations, it may be preferable to inject threads more quickly even in low-memory situations. You can disable the memory usage heuristics by turning off this switch. | .NET 7 | ### How the configuration settings take effect diff --git a/docs/core/runtime-discovery/troubleshoot-app-launch.md b/docs/core/runtime-discovery/troubleshoot-app-launch.md index 414dcb824dd15..8b34edcf2e9d9 100644 --- a/docs/core/runtime-discovery/troubleshoot-app-launch.md +++ b/docs/core/runtime-discovery/troubleshoot-app-launch.md @@ -8,11 +8,57 @@ zone_pivot_groups: operating-systems-set-one # Troubleshoot app launch failures -This article describes some common reasons and possible solutions for application launch failures. +This article describes some common reasons and possible solutions for application launch failures. It relates to [framework-dependent applications](../deploying/index.md#publish-framework-dependent), which rely on a .NET installation on your machine. + +If you already know which .NET version you need, you can download it from [.NET downloads](https://dotnet.microsoft.com/download/dotnet). + +## .NET installation not found + +If a .NET installation is not found, the application fails to launch with a message similar to: + +::: zone pivot="os-windows" + +```console +You must install .NET to run this application. + +App: C:\repos\myapp\myapp.exe +Architecture: x64 +Host version: 7.0.0 +.NET location: Not found +``` + +::: zone-end + +::: zone pivot="os-linux,os-macos" + +```bash +You must install .NET to run this application. + +App: /home/user/repos/myapp/myapp +Architecture: x64 +Host version: 7.0.0 +.NET location: Not found +``` + +::: zone-end + +The error message includes a link to download .NET. You can follow this link to get to the appropriate download page. You can also pick the .NET version (specified by `Host version`) from [.NET downloads](https://dotnet.microsoft.com/download/dotnet). + +::: zone pivot="os-windows,os-macos" +On the [download page](https://dotnet.microsoft.com/download/dotnet) for the required .NET version, find the **.NET Runtime** download that matches the architecture listed in the error message. You can then install it by downloading and running an **Installer**. +::: zone-end + +::: zone pivot="os-linux" +.NET is available through various Linux package managers. See [Install .NET on Linux](../install/linux.md) for details. Note that preview versions of .NET are typically not available through package managers. + +You need to install the .NET Runtime package for the appropriate version, like `dotnet-runtime6`. +::: zone-end + +Alternatively, on the [download page](https://dotnet.microsoft.com/download/dotnet) for the required .NET version, you can download [**Binaries**](#download-binaries) for the specified architecture. ## Required framework not found -[Framework-dependent applications](../deploying/index.md#publish-framework-dependent) rely on a .NET installation on your machine. If a required framework is not found or is not compatible with the required version, the application will fail to launch with a message similar to: +If a required framework or compatible version is not found, the application fails to launch with a message similar to: ::: zone pivot="os-windows" @@ -62,25 +108,44 @@ The following frameworks were found: ::: zone-end -The error indicates the name, version, and architecture of the missing framework and the location at which it is expected to be installed. To run the application, you can [install a compatible framework](#install-a-compatible-framework) at the specified ".NET location". If the application is targeting a lower version than one you have installed and you would like to run it on a higher version, you can also [configure roll-forward behavior](#configure-roll-forward-behavior) for the application. +The error indicates the name, version, and architecture of the missing framework and the location at which it is expected to be installed. To run the application, you can [install a compatible runtime](#install-a-compatible-runtime) at the specified ".NET location". If the application is targeting a lower version than one you have installed and you would like to run it on a higher version, you can also [configure roll-forward behavior](#configure-roll-forward-behavior) for the application. + +### Install a compatible runtime -### Install a compatible framework +The error message includes a link to download the missing framework. You can follow this link to get to the appropriate download page. -The error message includes a link to download the missing framework. You can follow this link to get the appropriate download page. Alternately, the [.NET downloads](https://dotnet.microsoft.com/download/dotnet) page offers all available versions of .NET. Select the version matching the one listed in the error message. +Alternately, you can download a runtime from the [.NET downloads](https://dotnet.microsoft.com/download/dotnet) page. There are multiple .NET runtime downloads. -Every version of .NET offers three different runtime downloads. The following table shows the frameworks that each contains. +The following table shows the frameworks that each runtime contains. -| Download name | Included frameworks | +::: zone pivot="os-windows" +| Runtime download | Included frameworks | | -------------------- | ------------------- | | ASP.NET Core Runtime | Microsoft.NETCore.App
Microsoft.AspNetCore.App | | .NET Desktop Runtime | Microsoft.NETCore.App
Microsoft.WindowsDesktop.App | | .NET Runtime | Microsoft.NETCore.App | +::: zone-end -To install a compatible framework, on the download page for the required .NET version, find a runtime download containing the missing framework. Once you have found the appropriate runtime download, you can then either install it using an [installer](#run-an-installer) or [script](#run-the-dotnet-install-script). You can also [download the binaries](#download-binaries) and extract them to the desired location. +::: zone pivot="os-linux,os-macos" +| Runtime download | Included frameworks | +| -------------------- | ------------------- | +| ASP.NET Core Runtime | Microsoft.NETCore.App
Microsoft.AspNetCore.App | +| .NET Runtime | Microsoft.NETCore.App | +::: zone-end -#### Run an installer +Select a runtime download containing the missing framework, and install it. -If your existing installation of .NET was installed through an installer or package manager, then the recommended option is to also install the required framework through an installer or package manager. Otherwise, you can [run the install script](#run-the-dotnet-install-script) or [download the binaries](#download-binaries). +::: zone pivot="os-windows,os-macos" +On the [download page](https://dotnet.microsoft.com/download/dotnet) for the required .NET version, find the runtime download that matches the architecture listed in the error message. You likely want to download an **Installer**. +::: zone-end + +::: zone pivot="os-linux" +.NET is available through various Linux package managers. See [Install .NET on Linux](../install/linux.md) for details. Note that preview versions of .NET are typically not available through package managers. + +You need to install the .NET runtime package for the appropriate version, like `dotnet-runtime6` or `dotnet-aspnet6`. +::: zone-end + +Alternatively, on the [download page](https://dotnet.microsoft.com/download/dotnet) for the required .NET version, you can download [**Binaries**](#download-binaries) for the specified architecture. In most cases, when the application that failed to launch is using such an installation, the ".NET location" in the error message points to: ::: zone pivot="os-windows" @@ -93,12 +158,9 @@ In most cases, when the application that failed to launch is using such an insta `/usr/local/share/dotnet/` ::: zone-end -::: zone pivot="os-windows,os-macos" -From the **Installers** column of the runtime download, download the installer matching the required architecture. Run the downloaded installer. -::: zone-end -::: zone pivot="os-linux" -Different Linux distributions provide .NET through different package managers. See [Install .NET on Linux](../install/linux.md) for details. Note that preview versions of .NET are not available through package managers. -::: zone-end +## Other options + +There are other installation and workaround options to consider. #### Run the dotnet-install script @@ -158,7 +220,7 @@ For more details on installation using the script, see [Install with bash automa #### Download binaries -From the **Binaries** column of the runtime download, download the binary release matching the required architecture. Extract the downloaded archive to the ".NET location" specified in the error message. +You can download a binary archive of .NET from the [download page](https://dotnet.microsoft.com/download/dotnet). From the **Binaries** column of the runtime download, download the binary release matching the required architecture. Extract the downloaded archive to the ".NET location" specified in the error message. ::: zone pivot="os-windows" For more details on manual installation, see [Install .NET on Windows](../install/windows.md#download-and-manually-install) diff --git a/docs/core/sdk.md b/docs/core/sdk.md index 7f7723eb8435c..db281998d6a85 100644 --- a/docs/core/sdk.md +++ b/docs/core/sdk.md @@ -9,7 +9,7 @@ ms.technology: dotnet-cli The .NET SDK is a set of libraries and tools that allow developers to create .NET applications and libraries. It contains the following components that are used to build and run applications: - The [.NET CLI](tools/index.md). -- The .NET [runtime](introduction.md#sdk-and-runtimes)and [libraries](introduction.md#runtime-libraries). +- The [.NET runtime](introduction.md#sdk-and-runtimes) and [libraries](introduction.md#runtime-libraries). - The `dotnet` [driver](tools/index.md#driver). ## How to install the .NET SDK diff --git a/docs/core/testing/unit-testing-published-output.md b/docs/core/testing/unit-testing-published-output.md index c2d446d01e75b..6856dc0632fc9 100644 --- a/docs/core/testing/unit-testing-published-output.md +++ b/docs/core/testing/unit-testing-published-output.md @@ -1,8 +1,6 @@ --- title: Test published output with dotnet vstest description: Learn how to run tests on published libraries, instead of on source code, with the dotnet vstest command. -author: kendrahavens -ms.author: kehavens ms.date: 10/18/2017 --- # Test published output with dotnet vstest diff --git a/docs/core/tools/custom-templates.md b/docs/core/tools/custom-templates.md index 8342c6e2b1cad..0f7c3c56b6a53 100644 --- a/docs/core/tools/custom-templates.md +++ b/docs/core/tools/custom-templates.md @@ -61,7 +61,7 @@ The *template.json* file is placed in a *.template.config* folder in the root di | `sourceName` | string | The name in the source tree to replace with the name the user specifies. The template engine will look for any occurrence of the `sourceName` mentioned in the config file and replace it in file names and file contents. The value to be replaced with can be given using the `-n` or `--name` options while running a template. If no name is specified, the current directory is used.| | `preferNameDirectory` | boolean | Indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory). The default value is false.| -The full schema for the *template.json* file is found at the [JSON Schema Store](http://json.schemastore.org/template). For more information about the *template.json* file, see the [dotnet templating wiki](https://github.com/dotnet/templating/wiki). +The full schema for the *template.json* file is found at the [JSON Schema Store](http://json.schemastore.org/template). For more information about the *template.json* file, see the [dotnet templating wiki](https://github.com/dotnet/templating/wiki). For deeper examples and information on how to make your templates visible in Visual Studio, check out the [resources that Sayed Hashimi has created](https://github.com/sayedihashimi/template-sample). #### Example diff --git a/docs/core/tools/dotnet-add-reference.md b/docs/core/tools/dotnet-add-reference.md index e637269b5a25b..dd61fd0484bbd 100644 --- a/docs/core/tools/dotnet-add-reference.md +++ b/docs/core/tools/dotnet-add-reference.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet add reference -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-build-server.md b/docs/core/tools/dotnet-build-server.md index aaeecb96386a0..0359e60c62785 100644 --- a/docs/core/tools/dotnet-build-server.md +++ b/docs/core/tools/dotnet-build-server.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet build-server -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index 15e8c505e98c1..b2459604de0de 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -5,7 +5,7 @@ ms.date: 08/12/2021 --- # dotnet build -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -110,7 +110,7 @@ The project or solution file to build. If a project or solution file isn't speci - **`--nologo`** - Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. + Doesn't display the startup banner or the copyright message. - **`--no-self-contained`** diff --git a/docs/core/tools/dotnet-clean.md b/docs/core/tools/dotnet-clean.md index fca9584cb9b05..1c8db764852ca 100644 --- a/docs/core/tools/dotnet-clean.md +++ b/docs/core/tools/dotnet-clean.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet clean -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -48,7 +48,7 @@ The MSBuild project or solution to clean. If a project or solution file is not s * **`--nologo`** - Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. + Doesn't display the startup banner or the copyright message. * **`-o|--output `** diff --git a/docs/core/tools/dotnet-environment-variables.md b/docs/core/tools/dotnet-environment-variables.md index e35f7b9268c9f..bbca934fba99b 100644 --- a/docs/core/tools/dotnet-environment-variables.md +++ b/docs/core/tools/dotnet-environment-variables.md @@ -1,12 +1,12 @@ --- title: .NET environment variables description: Learn about the environment variables that you can use to configure the .NET SDK, .NET CLI, and .NET runtime. -ms.date: 01/31/2022 +ms.date: 05/11/2022 --- # .NET environment variables -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions In this article, you'll learn about the environment variables used by .NET SDK, .NET CLI, and .NET runtime. Some environment variables are used by the .NET runtime, while others are only used by the .NET SDK and .NET CLI. Some environment variables are used by all. @@ -108,6 +108,9 @@ The `AppContext` switch can also be set by a config file. For more information c The same can be achieved via the environment variable `DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER`. To opt-out, set the value to either `false` or `0`. +> [!NOTE] +> Starting in .NET 5, this setting to use is no longer available. + ### `DOTNET_Jit*` and `DOTNET_GC*` There are two stressing-related features for the JIT and JIT-generated GC information: JIT Stress and GC Hole Stress. These features provide a way during development to discover edge cases and more "real world" scenarios without having to develop complex applications. The following environment variables are available: @@ -214,15 +217,18 @@ If `DOTNET_SKIP_FIRST_TIME_EXPERIENCE` is set to `true`, the `NuGetFallbackFolde ### `DOTNET_MULTILEVEL_LOOKUP` -Specifies whether .NET runtime, shared framework, or SDK are resolved from the global location. If not set, it defaults to 1 (logical `true`). Set to 0 (logical `false`) to not resolve from the global location and have isolated .NET installations. For more information about multi-level lookup, see [Multi-level SharedFX Lookup](https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/multilevel-sharedfx-lookup.md). +Specifies whether the .NET runtime, shared framework, or SDK are resolved from the global location. If not set, it defaults to 1 (logical `true`). Set the value to 0 (logical `false`) to not resolve from the global location and have isolated .NET installations. For more information about multi-level lookup, see [Multi-level SharedFX Lookup](https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/multilevel-sharedfx-lookup.md). + +> [!NOTE] +> This environment variable only applies to applications that target .NET 6 and earlier versions. Starting in .NET 7, .NET only looks for frameworks in one location. For more information, see [Multi-level lookup is disabled](../compatibility/deployment/7.0/multilevel-lookup.md). ### `DOTNET_ROLL_FORWARD` -Determines roll forward behavior. For more information, see the `--roll-forward` option earlier in this article. **Available starting with .NET Core 3.x.** +Determines roll forward behavior. For more information, see the `--roll-forward` option earlier in this article. ### `DOTNET_ROLL_FORWARD_TO_PRERELEASE` -If set to `1` (enabled), enables rolling forward to a pre-release version from a release version. By default (`0` - disabled), when a release version of .NET runtime is requested, roll-forward will only consider installed release versions. **Available starting with .NET Core 3.x.** +If set to `1` (enabled), enables rolling forward to a pre-release version from a release version. By default (`0` - disabled), when a release version of .NET runtime is requested, roll-forward will only consider installed release versions. For more information, see [Roll forward](../whats-new/dotnet-core-3-0.md#major-version-runtime-roll-forward). @@ -258,7 +264,7 @@ List of assemblies to load and execute startup hooks from. ### `DOTNET_BUNDLE_EXTRACT_BASE_DIR` -Specifies a directory to which a single-file application is extracted before it is executed. **Available starting with .NET Core 3.x.** +Specifies a directory to which a single-file application is extracted before it is executed. For more information, see [Single-file executables](../whats-new/dotnet-core-3-0.md#single-file-executables). @@ -280,8 +286,8 @@ Specifies the minimum number of hours between background downloads of advertisin Controls diagnostics tracing from the hosting components, such as `dotnet.exe`, `hostfxr`, and `hostpolicy`. * `COREHOST_TRACE=[0/1]` - default is `0` - tracing disabled. If set to `1`, diagnostics tracing is enabled. -* `COREHOST_TRACEFILE=` - has an effect only if tracing is enabled by setting `COREHOST_TRACE=1`. When set, the tracing information is written to the specified file; otherwise, the trace information is written to `stderr`. **Available starting with .NET Core 3.x.** -* `COREHOST_TRACE_VERBOSITY=[1/2/3/4]` - default is `4`. The setting is used only when tracing is enabled via `COREHOST_TRACE=1`. **Available starting with .NET Core 3.x.** +* `COREHOST_TRACEFILE=` - has an effect only if tracing is enabled by setting `COREHOST_TRACE=1`. When set, the tracing information is written to the specified file; otherwise, the trace information is written to `stderr`. +* `COREHOST_TRACE_VERBOSITY=[1/2/3/4]` - default is `4`. The setting is used only when tracing is enabled via `COREHOST_TRACE=1`. * `4` - all tracing information is written * `3` - only informational, warning, and error messages are written @@ -294,26 +300,6 @@ The typical way to get detailed trace information about application startup is t If set to `true`, invoking `dotnet` won't produce a warning when a preview SDK is being used. -### `DOTNET_WATCH_*` - -The following .NET watch settings are available as environment variables: - -- `DOTNET_WATCH`: The `dotnet watch` command sets this variable to `1` on all child processes launched. -- `DOTNET_WATCH_ITERATION`: The `dotnet watch` command sets this variable to `1` and increments by one each time - a file is changed and the command is restarted. -- `DOTNET_WATCH_SUPPRESS_STATIC_FILE_HANDLING`: If set to `1`, or `true`, `dotnet watch` will _not_ perform special handling for static content file. -- `DOTNET_WATCH_SUPPRESS_MSBUILD_INCREMENTALISM`: By default, `dotnet watch` optimizes the build by avoiding certain operations such as running `restore` or re-evaluating the set of watched files on every file change. If set to `1` or `true`, these optimizations are disabled. -- `DOTNET_WATCH_SUPPRESS_LAUNCH_BROWSER`: The `dotnet watch run` command will attempt to launch browsers for web apps with `launchBrowser` configured in the _launchSettings.json_ file. If set to `1` or `true`, this behavior is suppressed. -- `DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH` -- `DOTNET_WATCH_AUTO_RELOAD_WS_HOSTNAME`: As part of `dotnet watch`, the browser refresh server mechanism reads this value to determine the WebSocket host environment. The value `127.0.0.1` is replaced by `localhost`, and the `http://` and `https://` schemes are replaced with `ws://` and `wss://` respectively. -- `DOTNET_HOTRELOAD_NAMEDPIPE_NAME`: This value is configured by `dotnet watch` when the app is to be launched, and it specifies the named pipe. - -For more information, see [GitHub: .NET SDK dotnet-watch](https://github.com/dotnet/sdk/blob/main/src/BuiltInTools/dotnet-watch/README.md). - -#### `DOTNET_USE_POLLING_FILE_WATCHER` - -When set to `1` or `true`, `dotnet watch` will poll the file system for changes. This is required for some file systems, such as network shares, Docker mounted volumes, and other virtual file systems. The class uses `DOTNET_USE_POLLING_FILE_WATCHER` to determine whether the method will rely on the . - ### Configure MSBuild in the .NET CLI To execute MSBuild out-of-process, set the `DOTNET_CLI_RUN_MSBUILD_OUTOFPROC` environment variable to either `1`, `true`, or `yes`. By default, MSBuild will execute in-proc. To force MSBuild to use an external working node long-living process for building projects, set `DOTNET_CLI_USE_MSBUILDNOINPROCNODE` to `1`, `true`, or `yes`. This will set the `MSBUILDNOINPROCNODE` environment variable to `1`, which is referred to as _MSBuild Server V1_, as the entry process forwards most of the work to it. @@ -330,6 +316,10 @@ These are overrides that are used to force the resolved SDK tasks and targets to Configures the default programming language for the `dotnet new` command when the `-lang|--language` switch is omitted. The default value is `C#`. Valid values are `C#`, `F#`, or `VB`. For more information, see [dotnet new](dotnet-new.md). +### `dotnet watch` environment variables + +For information about `dotnet watch` settings that are available as environment variables, see [dotnet watch environment variables](dotnet-watch.md#environment-variables). + ## See also - [dotnet command](dotnet.md) diff --git a/docs/core/tools/dotnet-help.md b/docs/core/tools/dotnet-help.md index 8a5085bad35bf..3203e6bfde992 100644 --- a/docs/core/tools/dotnet-help.md +++ b/docs/core/tools/dotnet-help.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet help reference -**This article applies to:** ✔️ .NET Core 2.0 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-install-script.md b/docs/core/tools/dotnet-install-script.md index 705e85cf2c902..cccc9e34caa1c 100644 --- a/docs/core/tools/dotnet-install-script.md +++ b/docs/core/tools/dotnet-install-script.md @@ -102,8 +102,8 @@ The install scripts do not update the registry on Windows. They just download th - `Current` - Most current release. - `LTS` - Long-Term Support channel (most current supported release). - - Two-part version in A.B format, representing a specific release (for example, `2.1` or `3.0`). - - Three-part version in A.B.Cxx format, representing a specific SDK release (for example, 5.0.1xx or 5.0.2xx). Available since the 5.0 release. + - Two-part version in A.B format, representing a specific release (for example, `3.1` or `6.0`). + - Three-part version in A.B.Cxx format, representing a specific SDK release (for example, 6.0.1xx or 6.0.2xx). Available since the 5.0 release. The `version` parameter overrides the `channel` parameter when any version other than `latest` is used. @@ -158,7 +158,7 @@ The install scripts do not update the registry on Windows. They just download th The `version` parameter overrides the `channel` and `quality` parameters when any `version` other than `latest` is used. - Available since since the 5.0 release. + Available since the 5.0 release. - **`-Runtime|--runtime `** @@ -168,13 +168,9 @@ The install scripts do not update the registry on Windows. They just download th - `aspnetcore` - the `Microsoft.AspNetCore.App` shared runtime. - `windowsdesktop` - the `Microsoft.WindowsDesktop.App` shared runtime. -- **`--runtime-id ` [Deprecated]** +- **`--os `** - Specifies the [runtime identifier](../rid-catalog.md) for which the tools are being installed. Use `linux-x64` for portable Linux. (Only valid for Linux/macOS and for versions earlier than .NET Core 2.1.) - - **`--os `** - - Specifies the operating system for which the tools are being installed. Possible values are: `osx`, `linux`, `linux-musl`, `freebsd`, `rhel.6`. (Valid for .NET Core 2.1 and later.) + Specifies the operating system for which the tools are being installed. Possible values are: `osx`, `linux`, `linux-musl`, `freebsd`. The parameter is optional and should only be used when it's required to override the operating system that is detected by the script. @@ -236,25 +232,25 @@ The install scripts do not update the registry on Windows. They just download th ./dotnet-install.sh --channel 6.0.1xx --quality preview --install-dir ~/cli ``` -- Install the 3.0.0 version of the shared runtime: +- Install the 6.0.0 version of the shared runtime: Windows: ```powershell - ./dotnet-install.ps1 -Runtime dotnet -Version 3.0.0 + ./dotnet-install.ps1 -Runtime dotnet -Version 6.0.0 ``` macOS/Linux: ```bash - ./dotnet-install.sh --runtime dotnet --version 3.0.0 + ./dotnet-install.sh --runtime dotnet --version 6.0.0 ``` -- Obtain script and install the 2.1.2 version behind a corporate proxy (Windows only): +- Obtain script and install the 6.0.2 version behind a corporate proxy (Windows only): ```powershell Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -Proxy $env:HTTP_PROXY -ProxyUseDefaultCredentials -OutFile 'dotnet-install.ps1'; - ./dotnet-install.ps1 -InstallDir '~/.dotnet' -Version '2.1.2' -ProxyAddress $env:HTTP_PROXY -ProxyUseDefaultCredentials; + ./dotnet-install.ps1 -InstallDir '~/.dotnet' -Version '6.0.2' -Runtime 'dotnet' -ProxyAddress $env:HTTP_PROXY -ProxyUseDefaultCredentials; ``` - Obtain script and install .NET CLI one-liner examples: diff --git a/docs/core/tools/dotnet-list-package.md b/docs/core/tools/dotnet-list-package.md index d97c2a65e30d1..ba2537f0ee10a 100644 --- a/docs/core/tools/dotnet-list-package.md +++ b/docs/core/tools/dotnet-list-package.md @@ -5,7 +5,7 @@ ms.date: 04/13/2022 --- # dotnet list package -**This article applies to:** ✔️ .NET Core 2.2 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -84,7 +84,7 @@ The project or solution file to operate on. If not specified, the command search - **`--framework `** - Displays only the packages applicable for the specified [target framework](../../standard/frameworks.md). To specify multiple frameworks, repeat the option multiple times. For example: `--framework netcoreapp2.2 --framework netstandard2.0`. + Displays only the packages applicable for the specified [target framework](../../standard/frameworks.md). To specify multiple frameworks, repeat the option multiple times. For example: `--framework net6.0 --framework netstandard2.0`. [!INCLUDE [help](../../../includes/cli-help.md)] diff --git a/docs/core/tools/dotnet-list-reference.md b/docs/core/tools/dotnet-list-reference.md index b5d91322975aa..904a3728e2e0d 100644 --- a/docs/core/tools/dotnet-list-reference.md +++ b/docs/core/tools/dotnet-list-reference.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet list reference -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-msbuild.md b/docs/core/tools/dotnet-msbuild.md index faaa8ad44628e..1b6ee51ccdb1f 100644 --- a/docs/core/tools/dotnet-msbuild.md +++ b/docs/core/tools/dotnet-msbuild.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet msbuild -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-new-list.md b/docs/core/tools/dotnet-new-list.md index 398e6326bec8a..0de061084085a 100644 --- a/docs/core/tools/dotnet-new-list.md +++ b/docs/core/tools/dotnet-new-list.md @@ -5,7 +5,7 @@ ms.date: 04/29/2021 --- # dotnet new list -**This article applies to:** ✔️ .NET Core 2.0 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-new-sdk-templates.md b/docs/core/tools/dotnet-new-sdk-templates.md index d0e82739c90cb..f7b8aaa2e6402 100644 --- a/docs/core/tools/dotnet-new-sdk-templates.md +++ b/docs/core/tools/dotnet-new-sdk-templates.md @@ -86,6 +86,10 @@ Each template may have additional options available. The core templates have the If specified, doesn't execute an implicit restore during project creation. Available since .NET Core 2.2 SDK. +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `classlib` @@ -156,6 +160,10 @@ Each template may have additional options available. The core templates have the Doesn't execute an implicit restore during project creation. +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `mstest`, `xunit` @@ -307,6 +315,10 @@ The ability to create a project for an earlier TFM depends on having that versio Port number to use for the HTTPS endpoint in *launchSettings.json*. This option is not applicable when the parameter `no-https` is used (but `no-https` is ignored when an individual or organizational authentication setting is chosen for `--auth`). +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `blazorwasm` @@ -422,6 +434,10 @@ The ability to create a project for an earlier TFM depends on having that versio Port number to use for the HTTPS endpoint in *launchSettings.json*. This option is not applicable when the parameter `no-https` is used (but `no-https` is ignored when an individual or organizational authentication setting is chosen for `--auth`). +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `web` @@ -462,6 +478,10 @@ The ability to create a project for an earlier TFM depends on having that versio Port number to use for the HTTPS endpoint in *launchSettings.json*. This option is not applicable when the parameter `no-https` is used (but `no-https` is ignored when an individual or organizational authentication setting is chosen for `--auth`). +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `mvc`, `webapp` @@ -564,6 +584,10 @@ The ability to create a project for an earlier TFM depends on having that versio Port number to use for the HTTPS endpoint in *launchSettings.json*. This option is not applicable when the parameter `no-https` is used (but `no-https` is ignored when an individual or organizational authentication setting is chosen for `--auth`). +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `angular`, `react` @@ -617,6 +641,10 @@ The ability to create a project for an earlier TFM depends on having that versio Port number to use for the HTTPS endpoint in *launchSettings.json*. This option is not applicable when the parameter `no-https` is used (but `no-https` is ignored when an individual or organizational authentication setting is chosen for `--auth`). +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `reactredux` @@ -746,6 +774,10 @@ The ability to create a project for an earlier TFM depends on having that versio Doesn't execute an implicit restore during project creation. +- **`--use-program-main`** + + If specified, an explicit `Program` class and `Main` method will be used instead of top-level statements. Available since .NET SDK 6.0.300. Default value: `false`. + *** ## `globaljson` diff --git a/docs/core/tools/dotnet-new-uninstall.md b/docs/core/tools/dotnet-new-uninstall.md index 3518e32a2516f..c081e7a61773b 100644 --- a/docs/core/tools/dotnet-new-uninstall.md +++ b/docs/core/tools/dotnet-new-uninstall.md @@ -5,7 +5,7 @@ ms.date: 04/29/2021 --- # dotnet new uninstall -**This article applies to:** ✔️ .NET Core 2.0 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-new-update.md b/docs/core/tools/dotnet-new-update.md index 51897bf5ce514..db6d09edca3bd 100644 --- a/docs/core/tools/dotnet-new-update.md +++ b/docs/core/tools/dotnet-new-update.md @@ -5,13 +5,13 @@ ms.date: 04/29/2021 --- # dotnet new update -**This article applies to:** ✔️ .NET Core 3.0 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name -`dotnet new --update-check` checks for available updates for installed template packages. +`dotnet new --update-check` - Checks for available updates for installed template packages. -`dotnet new --update-apply` applies updates to installed template packages. +`dotnet new --update-apply` - Applies updates to installed template packages. ## Synopsis diff --git a/docs/core/tools/dotnet-new.md b/docs/core/tools/dotnet-new.md index b6ba9b3b8002c..3287ba0b2b33a 100644 --- a/docs/core/tools/dotnet-new.md +++ b/docs/core/tools/dotnet-new.md @@ -6,7 +6,7 @@ ms.date: 09/04/2020 --- # dotnet new <TEMPLATE> -**This article applies to:** ✔️ .NET Core 2.0 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-nuget-delete.md b/docs/core/tools/dotnet-nuget-delete.md index bd805a9dc6bf2..476b262711983 100644 --- a/docs/core/tools/dotnet-nuget-delete.md +++ b/docs/core/tools/dotnet-nuget-delete.md @@ -6,7 +6,7 @@ ms.date: 06/26/2019 --- # dotnet nuget delete -**This article applies to:** ✔️ .NET Core 1.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -54,7 +54,7 @@ The `dotnet nuget delete` command deletes or unlists a package from the server. * **`--no-service-endpoint`** - Doesn't append "api/v2/package" to the source URL. Option available since .NET Core 2.1 SDK. + Doesn't append "api/v2/package" to the source URL. * **`--non-interactive`** diff --git a/docs/core/tools/dotnet-nuget-locals.md b/docs/core/tools/dotnet-nuget-locals.md index 385ed963797fc..27ea087a83f55 100644 --- a/docs/core/tools/dotnet-nuget-locals.md +++ b/docs/core/tools/dotnet-nuget-locals.md @@ -6,7 +6,7 @@ ms.date: 02/14/2020 --- # dotnet nuget locals -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-nuget-push.md b/docs/core/tools/dotnet-nuget-push.md index 440223688664c..514bbdff51fae 100644 --- a/docs/core/tools/dotnet-nuget-push.md +++ b/docs/core/tools/dotnet-nuget-push.md @@ -6,7 +6,7 @@ ms.date: 02/14/2020 --- # dotnet nuget push -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -62,8 +62,7 @@ The command pushes an existing package. It doesn't create a package. To create a - **`--no-service-endpoint`** - Doesn't append "api/v2/package" to the source URL. Option available since .NET Core 2.1 SDK. - + Doesn't append "api/v2/package" to the source URL. - **`-s|--source `** Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP. @@ -72,7 +71,7 @@ The command pushes an existing package. It doesn't create a package. To create a - **`--skip-duplicate`** - When pushing multiple packages to an HTTP(S) server, treats any 409 Conflict response as a warning so that the push can continue. Available since .NET Core 3.1 SDK. + When pushing multiple packages to an HTTP(S) server, treats any 409 Conflict response as a warning so that the push can continue. - **`-sk|--symbol-api-key `** diff --git a/docs/core/tools/dotnet-pack.md b/docs/core/tools/dotnet-pack.md index 2c226457eaf88..c1b591f4d6373 100644 --- a/docs/core/tools/dotnet-pack.md +++ b/docs/core/tools/dotnet-pack.md @@ -5,7 +5,7 @@ ms.date: 08/23/2021 --- # dotnet pack -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -98,7 +98,7 @@ Web projects aren't packable by default. To override the default behavior, add t - **`--nologo`** - Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. + Doesn't display the startup banner or the copyright message. - **`-o|--output `** diff --git a/docs/core/tools/dotnet-publish.md b/docs/core/tools/dotnet-publish.md index 2b571dd07fe71..13c9edb8e8a73 100644 --- a/docs/core/tools/dotnet-publish.md +++ b/docs/core/tools/dotnet-publish.md @@ -5,7 +5,7 @@ ms.date: 12/02/2021 --- # dotnet publish -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -50,7 +50,7 @@ Any parameters passed to `dotnet publish` are passed to MSBuild. The `-c` and `- The `dotnet publish` command accepts MSBuild options, such as `-p` for setting properties and `-l` to define a logger. For example, you can set an MSBuild property by using the format: `-p:=`. -You can also set publish-related properties by referring to a *.pubxml* file (available since .NET Core 3.1 SDK). For example: +You can also set publish-related properties by referring to a *.pubxml* file. For example: ```dotnetcli dotnet publish -p:PublishProfile=FolderProfile @@ -62,7 +62,7 @@ The following MSBuild properties change the output of `dotnet publish`. - `PublishReadyToRun` - Compiles application assemblies as ReadyToRun (R2R) format. R2R is a form of ahead-of-time (AOT) compilation. For more information, see [ReadyToRun images](../deploying/ready-to-run.md). Available since .NET Core 3.0 SDK. + Compiles application assemblies as ReadyToRun (R2R) format. R2R is a form of ahead-of-time (AOT) compilation. For more information, see [ReadyToRun images](../deploying/ready-to-run.md). To see warnings about missing dependencies that could cause runtime failures, use `PublishReadyToRunShowWarnings=true`. @@ -70,7 +70,7 @@ The following MSBuild properties change the output of `dotnet publish`. - `PublishSingleFile` - Packages the app into a platform-specific single-file executable. For more information about single-file publishing, see the [single-file bundler design document](https://github.com/dotnet/designs/blob/main/accepted/2020/single-file/design.md). Available since .NET Core 3.0 SDK. + Packages the app into a platform-specific single-file executable. For more information about single-file publishing, see the [single-file bundler design document](https://github.com/dotnet/designs/blob/main/accepted/2020/single-file/design.md). We recommend that you specify this option in the project file rather than on the command line. @@ -96,7 +96,7 @@ For more information, see the following resources: * `PROJECT` is the path and filename of a C#, F#, or Visual Basic project file, or the path to a directory that contains a C#, F#, or Visual Basic project file. If the directory is not specified, it defaults to the current directory. - * `SOLUTION` is the path and filename of a solution file (*.sln* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. Available since .NET Core 3.0 SDK. + * `SOLUTION` is the path and filename of a solution file (*.sln* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. ## Options @@ -132,7 +132,7 @@ For more information, see the following resources: - **`--nologo`** - Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. + Doesn't display the startup banner or the copyright message. - **`--no-restore`** @@ -172,7 +172,7 @@ For more information, see the following resources: - **`--no-self-contained`** - Equivalent to `--self-contained false`. Available since .NET Core 3.0 SDK. + Equivalent to `--self-contained false`. - **`--source `** diff --git a/docs/core/tools/dotnet-remove-package.md b/docs/core/tools/dotnet-remove-package.md index 2ec223cb8ebf9..ffef92ff169d0 100644 --- a/docs/core/tools/dotnet-remove-package.md +++ b/docs/core/tools/dotnet-remove-package.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet remove package -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-remove-reference.md b/docs/core/tools/dotnet-remove-reference.md index 694e78326b3d6..828f87d54151d 100644 --- a/docs/core/tools/dotnet-remove-reference.md +++ b/docs/core/tools/dotnet-remove-reference.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet remove reference -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-restore.md b/docs/core/tools/dotnet-restore.md index 4c687d22a290e..c7298a453c5e5 100644 --- a/docs/core/tools/dotnet-restore.md +++ b/docs/core/tools/dotnet-restore.md @@ -5,7 +5,7 @@ ms.date: 02/27/2020 --- # dotnet restore -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-run.md b/docs/core/tools/dotnet-run.md index 7d97fe444f425..265f484aaba03 100644 --- a/docs/core/tools/dotnet-run.md +++ b/docs/core/tools/dotnet-run.md @@ -5,7 +5,7 @@ ms.date: 08/18/2021 --- # dotnet run -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -122,7 +122,7 @@ To run the application, the `dotnet run` command resolves the dependencies of th - **`-r|--runtime `** - Specifies the target runtime to restore packages for. For a list of Runtime Identifiers (RIDs), see the [RID catalog](../rid-catalog.md). `-r` short option available since .NET Core 3.0 SDK. + Specifies the target runtime to restore packages for. For a list of Runtime Identifiers (RIDs), see the [RID catalog](../rid-catalog.md). [!INCLUDE [verbosity](../../../includes/cli-verbosity-minimal.md)] diff --git a/docs/core/tools/dotnet-sln.md b/docs/core/tools/dotnet-sln.md index 25e14cead8f11..a9a846663c806 100644 --- a/docs/core/tools/dotnet-sln.md +++ b/docs/core/tools/dotnet-sln.md @@ -1,11 +1,11 @@ --- title: dotnet sln command description: The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file. -ms.date: 12/07/2020 +ms.date: 05/18/2022 --- # dotnet sln -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -23,12 +23,28 @@ dotnet sln [command] -h|--help The `dotnet sln` command provides a convenient way to list and modify projects in a solution file. -To use the `dotnet sln` command, the solution file must already exist. If you need to create one, use the [dotnet new](dotnet-new.md) command, as in the following example: +### Create a solution file + +To use the `dotnet sln` command, the solution file must already exist. If you need to create one, use the [dotnet new](dotnet-new.md) command with the `sln` template name. + +The following example creates a *.sln* file in the current folder, with the same name as the folder: ```dotnetcli dotnet new sln ``` +The following example creates a *.sln* file in the current folder, with the specified file name: + +```dotnetcli +dotnet new sln --name MySolution +``` + +The following example creates a *.sln* file in the specified folder, with the same name as the folder: + +```dotnetcli +dotnet new sln --output MySolution +``` + ## Arguments - **`SOLUTION_FILE`** @@ -100,11 +116,11 @@ dotnet sln add [-h|--help] - **`--in-root`** - Places the projects in the root of the solution, rather than creating a [solution folder](/visualstudio/ide/solutions-and-projects-in-visual-studio#solution-folder). Can't be used with `-s|--solution-folder`. Available since .NET Core 3.0 SDK. + Places the projects in the root of the solution, rather than creating a [solution folder](/visualstudio/ide/solutions-and-projects-in-visual-studio#solution-folder). Can't be used with `-s|--solution-folder`. - **`-s|--solution-folder `** - The destination [solution folder](/visualstudio/ide/solutions-and-projects-in-visual-studio#solution-folder) path to add the projects to. Can't be used with `--in-root`. Available since .NET Core 3.0 SDK. + The destination [solution folder](/visualstudio/ide/solutions-and-projects-in-visual-studio#solution-folder) path to add the projects to. Can't be used with `--in-root`. ### `remove` diff --git a/docs/core/tools/dotnet-store.md b/docs/core/tools/dotnet-store.md index 9018c958c77f7..5100078394e33 100644 --- a/docs/core/tools/dotnet-store.md +++ b/docs/core/tools/dotnet-store.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet store -**This article applies to:** ✔️ .NET Core 2.x SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-test.md b/docs/core/tools/dotnet-test.md index 65fd92420adad..72e992b94b05f 100644 --- a/docs/core/tools/dotnet-test.md +++ b/docs/core/tools/dotnet-test.md @@ -122,9 +122,10 @@ Where `Microsoft.NET.Test.Sdk` is the test host, `xunit` is the test framework. Enables data collector for the test run. For more information, see [Monitor and analyze test run](https://aka.ms/vstest-collect). - To collect code coverage on any platform that is supported by .NET Core, install [Coverlet](https://github.com/coverlet-coverage/coverlet/blob/master/README.md) and use the `--collect:"XPlat Code Coverage"` option. + On Windows (x86, x64 and arm64), Linux (x64) and macOS (x64), you can collect code coverage by using the `--collect "Code Coverage"` option. For more information, see [Use code coverage](/visualstudio/test/using-code-coverage-to-determine-how-much-code-is-being-tested) and [Customize code coverage analysis](/visualstudio/test/customizing-code-coverage-analysis). + + To collect code coverage on any platform that is supported by .NET Core, install [Coverlet](https://github.com/coverlet-coverage/coverlet/blob/master/README.md) and use the `--collect "XPlat Code Coverage"` option. - On Windows, you can collect code coverage by using the `--collect "Code Coverage"` option. This option generates a *.coverage* file, which can be opened in Visual Studio 2019 Enterprise. For more information, see [Use code coverage](/visualstudio/test/using-code-coverage-to-determine-how-much-code-is-being-tested) and [Customize code coverage analysis](/visualstudio/test/customizing-code-coverage-analysis). - **`-d|--diag `** diff --git a/docs/core/tools/dotnet-tool-install.md b/docs/core/tools/dotnet-tool-install.md index 5ef9c87065b16..362d064b4f0e7 100644 --- a/docs/core/tools/dotnet-tool-install.md +++ b/docs/core/tools/dotnet-tool-install.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet tool install -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -43,8 +43,6 @@ The `dotnet tool install` command provides a way for you to install .NET tools o * To install a global tool in a custom location, use the `--tool-path` option. * To install a local tool, omit the `--global` and `--tool-path` options. -**Local tools are available starting with .NET Core SDK 3.0.** - Global tools are installed in the following directories by default when you specify the `-g` or `--global` option: | OS | Path | diff --git a/docs/core/tools/dotnet-tool-list.md b/docs/core/tools/dotnet-tool-list.md index c75d71ca33707..601b5ee9f3751 100644 --- a/docs/core/tools/dotnet-tool-list.md +++ b/docs/core/tools/dotnet-tool-list.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet tool list -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -33,8 +33,6 @@ The `dotnet tool list` command provides a way for you to list all .NET global, t * To list global tools installed in a custom location, use the `--tool-path` option. * To list local tools, use the `--local` option or omit the `--global`, `--tool-path`, and `--local` options. -**Local tools are available starting with .NET Core SDK 3.0.** - ## Options diff --git a/docs/core/tools/dotnet-tool-restore.md b/docs/core/tools/dotnet-tool-restore.md index de5b0c70f3c9d..ee5d96f36a593 100644 --- a/docs/core/tools/dotnet-tool-restore.md +++ b/docs/core/tools/dotnet-tool-restore.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet tool restore -**This article applies to:** ✔️ .NET Core 3.0 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-tool-run.md b/docs/core/tools/dotnet-tool-run.md index fe17ffa466e5a..5cc58a660ca4e 100644 --- a/docs/core/tools/dotnet-tool-run.md +++ b/docs/core/tools/dotnet-tool-run.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet tool run -**This article applies to:** ✔️ .NET Core 3.0 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name diff --git a/docs/core/tools/dotnet-tool-uninstall.md b/docs/core/tools/dotnet-tool-uninstall.md index a8e007ee18b20..50c6b185ca8d2 100644 --- a/docs/core/tools/dotnet-tool-uninstall.md +++ b/docs/core/tools/dotnet-tool-uninstall.md @@ -5,7 +5,7 @@ ms.date: 02/14/2020 --- # dotnet tool uninstall -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -31,8 +31,6 @@ The `dotnet tool uninstall` command provides a way for you to uninstall .NET too * To uninstall a global tool that was installed in a custom location, use the `--tool-path` option. * To uninstall a local tool, omit the `--global` and `--tool-path` options. -**Local tools are available starting with .NET Core SDK 3.0.** - ## Arguments - **`PACKAGE_NAME`** diff --git a/docs/core/tools/dotnet-tool-update.md b/docs/core/tools/dotnet-tool-update.md index cbec40728ca6d..6d1988e74ef4e 100644 --- a/docs/core/tools/dotnet-tool-update.md +++ b/docs/core/tools/dotnet-tool-update.md @@ -5,7 +5,7 @@ ms.date: 07/08/2020 --- # dotnet tool update -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -44,8 +44,6 @@ The `dotnet tool update` command provides a way for you to update .NET tools on * To update a global tool that was installed in a custom location, use the `--tool-path` option. * To update a local tool, use the `--local` option. -**Local tools are available starting with .NET Core SDK 3.0.** - ## Arguments - **`PACKAGE_ID`** diff --git a/docs/core/tools/dotnet-vstest.md b/docs/core/tools/dotnet-vstest.md index a232994f4a192..f8c3fe3052b3e 100644 --- a/docs/core/tools/dotnet-vstest.md +++ b/docs/core/tools/dotnet-vstest.md @@ -5,7 +5,7 @@ ms.date: 02/27/2020 --- # dotnet vstest -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions > [!IMPORTANT] > The `dotnet vstest` command is superseded by `dotnet test`, which can now be used to run assemblies. See [dotnet test](dotnet-test.md). diff --git a/docs/core/tools/dotnet-watch.md b/docs/core/tools/dotnet-watch.md new file mode 100644 index 0000000000000..84831fcf37f1f --- /dev/null +++ b/docs/core/tools/dotnet-watch.md @@ -0,0 +1,257 @@ +--- +title: dotnet watch command +description: The dotnet watch command is a file watcher that restarts or hot reloads the specified application when changes in the source code are detected. +ms.date: 05/11/2022 +--- +# dotnet watch + +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions + +## Name + +`dotnet watch` - Restarts or [hot reloads](#hot-reload) the specified application when changes in the source code are detected. + +## Synopsis + +```dotnetcli +dotnet watch [--list] + [--no-hot-reload] [--non-interactive] + [--project ] + [-q|--quiet] [-v|--verbose] + [--version] + [--] + +dotnet watch -?|-h|--help +``` + +## Description + +The `dotnet watch` command is a file watcher. When it detects a change that is supported for [hot reload](#hot-reload), it hot reloads the specified application. When it detects an unsupported change, it restarts the application. This process enables fast iterative development from the command line. + +While running `dotnet watch`, you can force the app to rebuild and restart by pressing Ctrl+R in the command shell. This feature is available only while the app is running. For example, if you run `dotnet watch` on a console app that ends before you press Ctrl+R, pressing Ctrl+R has no effect. However, in that case `dotnet watch` is still watching files and will restart the app if a file is updated. + +## Arguments + + + +- **`forwarded arguments`** + + Arguments to pass to the child `dotnet` process. For example: `run` with options for [dotnet run](dotnet-run.md) or `test` with options for [dotnet test](dotnet-test.md). If the child command isn't specified, the default is `run` for `dotnet run`. + +## Options + +- **`--list`** + + Lists all discovered files without starting the watcher. + +- **`--no-hot-reload`** + + Suppress [hot reload](#hot-reload) for [supported apps](/visualstudio/debugger/hot-reload#supported-net-app-frameworks-and-scenarios). + +- **`--non-interactive`** + + Runs `dotnet watch` in non-interactive mode. Use this option to prevent console input from being requested. When hot reload is enabled and a [rude edit](#rude-edits) is detected, dotnet watch restarts the app. + +- **`--project `** + + Specifies the path of the project file to run (folder only or including the project file name). If not specified, it defaults to the current directory. + +- **`-q|--quiet`** + + Suppresses all output that is generated by the `dotnet watch` command except warnings and errors. The option is not passed on to child commands. For example, output from `dotnet restore` and `dotnet run` continues to be output. + +- **`-v|--verbose`** + + Shows verbose output for debugging. + +- **`--version`** + + Shows the version of `dotnet watch`. + +- **`--`** + + The [double-dash option ('--')](../../standard/commandline/syntax.md#the----token) can be used to delimit `dotnet watch` options from arguments that will be passed to the child process. Its use is optional. When the double-dash option isn't used, `dotnet watch` considers the first unrecognized argument to be the beginning of arguments that it should pass into the child `dotnet` process. + +## Environment variables + +`dotnet watch` uses the following environment variables: + +- **`DOTNET_HOTRELOAD_NAMEDPIPE_NAME`** + + This value is configured by `dotnet watch` when the app is to be launched, and it specifies the named pipe. + +- **`DOTNET_USE_POLLING_FILE_WATCHER`** + + When set to `1` or `true`, `dotnet watch` uses a polling file watcher instead of . Polling is required for some file systems, such as network shares, Docker mounted volumes, and other virtual file systems. The class uses `DOTNET_USE_POLLING_FILE_WATCHER` to determine whether the method will rely on the . + +- **`DOTNET_WATCH`** + + `dotnet watch` sets this variable to `1` on all child processes that it launches. + +- **`DOTNET_WATCH_AUTO_RELOAD_WS_HOSTNAME`** + + As part of `dotnet watch`, the browser refresh server mechanism reads this value to determine the WebSocket host environment. The value `127.0.0.1` is replaced by `localhost`, and the `http://` and `https://` schemes are replaced with `ws://` and `wss://` respectively. + +- **`DOTNET_WATCH_ITERATION`** + + `dotnet watch` sets this variable to `1` and increments by one each time a file is changed and the command restarts or hot reloads the application. + +- **`DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH`** + + When set to `1` or `true`, `dotnet watch` won't refresh browsers when it detects file changes. + +- **`DOTNET_WATCH_SUPPRESS_EMOJIS`** + + With the .NET SDK 6.0.300 and later, `dotnet watch` emits non-ASCII characters to the console, as shown in the following example: + + ```output + dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. + 💡 Press "Ctrl + R" to restart. + dotnet watch 🔧 Building... + dotnet watch 🚀 Started + dotnet watch ⌚ Exited + dotnet watch ⏳ Waiting for a file to change before restarting dotnet... + ``` + + On certain console hosts, these characters may appear garbled. To avoid seeing garbled characters, set this variable to `1` or `true`. + +- **`DOTNET_WATCH_SUPPRESS_LAUNCH_BROWSER`** + + When set to `1` or `true`, `dotnet watch` won't launch or refresh browsers for web apps that have `launchBrowser` configured in *launchSettings.json*. + +- **`DOTNET_WATCH_SUPPRESS_MSBUILD_INCREMENTALISM`** + + By default, `dotnet watch` optimizes the build by avoiding certain operations, such as running restore or re-evaluating the set of watched files on every file change. If this variable is set to `1` or `true`, these optimizations are disabled. + +- **`DOTNET_WATCH_SUPPRESS_STATIC_FILE_HANDLING`** + + When set to `1` or `true`, `dotnet watch` won't do special handling for static content files. `dotnet watch` sets MSBuild property `DotNetWatchContentFiles` to `false`. + +## Files watched by default + +`dotnet watch` watches all items in the `Watch` item group in the project file. By default, this group includes all items in the `Compile` and `EmbeddedResource` groups. `dotnet watch` also scans the entire graph of project references and watches all files within those projects. + +By default, the `Compile` and `EmbeddedResource` groups include all files matching the following glob patterns: + +* `**/*.cs` +* `*.csproj` +* `**/*.resx` +* Content files in web apps: `wwwroot/**` + +By default, *.config*, and *.json* files don't trigger a dotnet watch restart because the configuration system has its own mechanisms for handling configuration changes. + +Files can be added to the watch list or removed from the list by editing the project file. Files can be specified individually or by using glob patterns. + +## Watch additional files + +More files can be watched by adding items to the `Watch` group. For example, the following markup extends that group to include JavaScript files: + +```xml + + + +``` + +## Ignore specified files + +`dotnet watch` will ignore `Compile` and `EmbeddedResource` items that have the `Watch="false"` attribute, as shown in the following example: + +```xml + + + + +``` + +`dotnet watch` will ignore project references that have the `Watch="false"` attribute, as shown in the following example: + +```xml + + + +``` + +## Advanced configuration + +`dotnet watch` performs a design-time build to find items to watch. When this build is run, `dotnet watch` sets the property `DotNetWatchBuild=true`. This property can be used as shown in the following example: + +```xml + + + +``` + +## Hot Reload + +Starting in .NET 6, `dotnet watch` includes support for *hot reload*. Hot reload is a feature that lets you apply changes to a running app without having to rebuild and restart it. The changes may be to code files or static assets, such as stylesheet files and JavaScript files. This feature streamlines the local development experience, as it gives immediate feedback when you modify your app. + +For information about app types and .NET versions that support hot reload, see [Supported .NET app frameworks and scenarios](/visualstudio/debugger/hot-reload#supported-net-app-frameworks-and-scenarios). + +### Rude edits + +When a file is modified, `dotnet watch` determines if the app can be hot reloaded. If it can't be hot reloaded, the change is called a *rude edit* and `dotnet watch` asks if you want to restart the app: + +```dotnetcli +dotnet watch ⌚ Unable to apply hot reload because of a rude edit. + ❔ Do you want to restart your app - Yes (y) / No (n) / Always (a) / Never (v)? +``` + +* **Yes**: Restarts the app. +* **No**: Leaves the app running without the changes applied. +* **Always**: Restarts the app and doesn't prompt anymore for rude edits. +* **Never**: Leaves the app running without the changes applied and doesn't prompt anymore for rude edits. + +For information about what kinds of changes are considered rude edits, see [Edit code and continue debugging](/visualstudio/debugger/edit-and-continue) and [Unsupported changes to code](/visualstudio/debugger/supported-code-changes-csharp#unsupported-changes-to-code). + +To disable hot reload when you run `dotnet watch`, use the `--no-hot-reload` option, as shown in the following example: + +```.NET CLI +dotnet watch --no-hot-reload +``` + +## Examples + +- Run `dotnet run` for the project in the current directory whenever source code changes: + + ```dotnetcli + dotnet watch + ``` + + Or: + + ```dotnetcli + dotnet watch run + ``` + +- Run `dotnet test` for the project in the current directory whenever source code changes: + + ```dotnetcli + dotnet watch test + ``` + +- Run `dotnet run --project ./HelloWorld.csproj` whenever source code changes: + + ```dotnetcli + dotnet watch run --project ./HelloWorld.csproj + ``` + +- Run `dotnet run -- arg0` for the project in the current directory whenever source code changes: + + ```dotnetcli + dotnet watch run -- arg0 + ``` + + Or: + + ```dotnetcli + dotnet watch -- run arg0 + ``` + +## See also + +* [Tutorial: Develop ASP.NET Core apps using a file watcher](/aspnet/core/tutorials/dotnet-watch) +* [Hot reload in Visual Studio](/visualstudio/debugger/hot-reload) +* [Hot reload supported apps](/visualstudio/debugger/hot-reload#supported-net-app-frameworks-and-scenarios) +* [Hot reload supported code changes](/visualstudio/debugger/supported-code-changes-csharp) +* [Hot reload test execution](/visualstudio/test/test-execution-with-hot-reload) +* [Hot reload support for ASP.NET Core](/aspnet/core/test/hot-reload) diff --git a/docs/core/tools/dotnet.md b/docs/core/tools/dotnet.md index 0e04f4073a9e3..60a4396728073 100644 --- a/docs/core/tools/dotnet.md +++ b/docs/core/tools/dotnet.md @@ -1,11 +1,11 @@ --- title: dotnet command description: Learn about the dotnet command (the generic driver for the .NET CLI) and its usage. -ms.date: 07/19/2021 +ms.date: 05/06/2022 --- # dotnet command -**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions ## Name @@ -40,8 +40,6 @@ dotnet exec [--additionalprobingpath] [--additional-deps ] [arguments] ``` -`--roll-forward` is available since .NET Core 3.x. Use `--roll-forward-on-no-candidate-fx` for .NET Core 2.x. - ## Description The `dotnet` command has two functions: @@ -124,7 +122,7 @@ The following options are available when `dotnet` runs an application. For examp Path to a *runtimeconfig.json* file. A *runtimeconfig.json* file is a configuration file that contains run-time settings. For more information, see [.NET runtime configuration settings](../runtime-config/index.md#runtimeconfigjson). -- **`--roll-forward `** **Available starting with .NET Core SDK 3.0.** +- **`--roll-forward `** ** Controls how roll forward is applied to the app. The `SETTING` can be one of the following values. If not specified, `Minor` is the default. @@ -139,18 +137,6 @@ The following options are available when `dotnet` runs an application. For examp Roll forward behavior can also be configured in a project file property, a runtime configuration file property, and an environment variable. For more information, see [Major-version runtime roll forward](../whats-new/dotnet-core-3-0.md#major-version-runtime-roll-forward). -- **`--roll-forward-on-no-candidate-fx `** **Available in .NET Core 2.x SDK.** - - Defines behavior when the required shared framework is not available. `N` can be: - - - `0` - Disable even minor version roll forward. - - `1` - Roll forward on minor version, but not on major version. This is the default behavior. - - `2` - Roll forward on minor and major versions. - - For more information, see [Roll forward](../whats-new/dotnet-core-2-1.md#roll-forward). - - Starting with .NET Core 3.0, this option is superseded by `--roll-forward`, and that option should be used instead. - - **`--fx-version `** Version of the .NET runtime to use to run the application. @@ -221,26 +207,26 @@ Command | Function ### Global, tool-path, and local tools commands -Tools are console applications that are installed from NuGet packages and are invoked from the command prompt. You can write tools yourself or install tools written by third parties. Tools are also known as global tools, tool-path tools, and local tools. For more information, see [.NET tools overview](global-tools.md). Global and tool-path tools are available starting with .NET Core SDK 2.1. Local tools are available starting with .NET Core SDK 3.0. +Tools are console applications that are installed from NuGet packages and are invoked from the command prompt. You can write tools yourself or install tools written by third parties. Tools are also known as global tools, tool-path tools, and local tools. For more information, see [.NET tools overview](global-tools.md). Command | Function --- | --- [dotnet tool install](dotnet-tool-install.md) | Installs a tool on your machine. [dotnet tool list](dotnet-tool-list.md) | Lists all global, tool-path, or local tools currently installed on your machine. -[dotnet tool search](dotnet-tool-list.md) | Searches NuGet.org for tools that have the specified search term in their name or metadata. +[dotnet tool search](dotnet-tool-search.md) | Searches NuGet.org for tools that have the specified search term in their name or metadata. [dotnet tool uninstall](dotnet-tool-uninstall.md) | Uninstalls a tool from your machine. [dotnet tool update](dotnet-tool-update.md) | Updates a tool that is installed on your machine. ### Additional tools -Starting with .NET Core SDK 2.1.300, a number of tools that were available only on a per project basis using `DotnetCliToolReference` are now available as part of the .NET SDK. These tools are listed in the following table: +The following additional tools are available as part of the .NET SDK: | Tool | Function | | ------------------------------------------------- | ------------------------------------------------------------ | | dev-certs | Creates and manages development certificates. | | [ef](/ef/core/miscellaneous/cli/dotnet) | Entity Framework Core command-line tools. | | [user-secrets](/aspnet/core/security/app-secrets) | Manages development user secrets. | -| [watch](/aspnet/core/tutorials/dotnet-watch) | Starts a file watcher that runs a command when files change. | +| [watch](dotnet-watch.md) | A file watcher that restarts or hot reloads an application when it detects changes in the source code. | For more information about each tool, type `dotnet --help`. diff --git a/docs/core/tools/enable-tab-autocomplete.md b/docs/core/tools/enable-tab-autocomplete.md index 2ca11e6fc3e33..a132e17d9add4 100644 --- a/docs/core/tools/enable-tab-autocomplete.md +++ b/docs/core/tools/enable-tab-autocomplete.md @@ -61,17 +61,14 @@ To add tab completion to your **bash** shell for the .NET CLI, add the following ```bash # bash parameter completion for the dotnet CLI -_dotnet_bash_complete() +function _dotnet_bash_complete() { - local word=${COMP_WORDS[COMP_CWORD]} + local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n' + local candidates - local completions - completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)" - if [ $? -ne 0 ]; then - completions="" - fi + read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null) - COMPREPLY=( $(compgen -W "$completions" -- "$word") ) + read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur") } complete -f -F _dotnet_bash_complete dotnet diff --git a/docs/core/tools/local-tools-how-to-use.md b/docs/core/tools/local-tools-how-to-use.md index 1fe9be7c08c74..7e1729deed1ba 100644 --- a/docs/core/tools/local-tools-how-to-use.md +++ b/docs/core/tools/local-tools-how-to-use.md @@ -2,7 +2,7 @@ title: "Tutorial: Install and use .NET local tools" description: Learn how to install and use a .NET tool as a local tool. ms.topic: tutorial -ms.date: 12/11/2020 +ms.date: 05/06/2022 --- # Tutorial: Install and use a .NET local tool using the .NET CLI @@ -123,8 +123,6 @@ You typically install a local tool in the root directory of the repository. Afte } ``` -1. Replace `` with the name you used to create the project. - 1. Save your changes. Making this change is the same as getting the latest version from the repository after someone else installed the package `dotnetsay` for the project directory. diff --git a/docs/core/tools/sdk-errors/netsdk1005.md b/docs/core/tools/sdk-errors/netsdk1005.md index 33694265cf2c4..8ac15514572c8 100644 --- a/docs/core/tools/sdk-errors/netsdk1005.md +++ b/docs/core/tools/sdk-errors/netsdk1005.md @@ -23,3 +23,5 @@ Here are some actions you can take that may resolve the error: * Delete the *obj* folder before building the project. * Make sure that the missing target value is included in the `TargetFrameworks` property of your project. + +* If you're building a Docker image, make sure the *.dockerignore* file ignores the *bin* and *obj* directories. For more information, see GitHub pull request [dotnet/docs #29530](https://github.com/dotnet/docs/pull/29530). diff --git a/docs/core/tools/telemetry.md b/docs/core/tools/telemetry.md index 34c757bde54c3..9b17334ab6477 100644 --- a/docs/core/tools/telemetry.md +++ b/docs/core/tools/telemetry.md @@ -74,15 +74,24 @@ The telemetry feature collects the following data: | >=3.0.100 | On a CLI/SDK crash, the exception type and its stack trace (only CLI/SDK code is included in the stack trace sent). For more information, see [Crash exception telemetry](#crash-exception-telemetry). | | >=5.0.100 | Hashed TargetFrameworkVersion used for build (MSBuild property) | | >=5.0.100 | Hashed RuntimeIdentifier used for build (MSBuild property) | -| >=5.0.100 | Hashed SelfContained used for build (MSBuild property) | -| >=5.0.100 | Hashed UseApphost used for build (MSBuild property) | +| >=5.0.100 | Hashed SelfContained used for build (MSBuild property) | +| >=5.0.100 | Hashed UseApphost used for build (MSBuild property) | | >=5.0.100 | Hashed OutputType used for build (MSBuild property | +| >=5.0.201 | Hashed PublishReadyToRun used for build (MSBuild property) | +| >=5.0.201 | Hashed PublishTrimmed used for build (MSBuild property) | +| >=5.0.201 | Hashed PublishSingleFile used for build (MSBuild property) | | >=5.0.202 | Elapsed time from process start until entering the CLI program's main method, measuring host and runtime startup. | | >=5.0.202 | Elapsed time for the step that adds .NET Tools to the path on first run. | | >=5.0.202 | Elapsed time to display first time use notice on first run. | | >=5.0.202 | Elapsed time for generating ASP.NET Certificate on first run. | | >=5.0.202 | Elapsed time to parse the CLI input. | | >=6.0.100 | OS architecture | +| >=6.0.104 | Hashed PublishReadyToRunUseCrossgen2 used for build (MSBuild property) | +| >=6.0.104 | Hashed Crossgen2PackVersion used for build (MSBuild property) | +| >=6.0.104 | Hashed CompileListCount used for build (MSBuild property) | +| >=6.0.104 | Hashed _ReadyToRunCompilationFailures used for build (MSBuild property) | +| >=6.0.300 | If the CLI was invoked from a Continuous Integration environment. For more information, see [Continuous Integration Detection](#continuous-integration-detection).| +| >=7.0.100 | Hashed PublishAot used for build (MSBuild property) | ### Collected options @@ -145,6 +154,26 @@ at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryC at Microsoft.DotNet.Cli.Program.Main(String[] args) ``` +## Continuous Integration Detection + +In order to detect if the .NET CLI is running in a Continuous Integration environment, the .NET CLI probes for the presence and values of several well-known environment variables that common CI providers set. + +The full list of environment variables, and what is done with their values, is shown below. Note that in every case, the value of the environment variable is never collected, only used to set a boolean flag. + +| Variable(s) | Provider | Action | +| ----------- | -------- | ------ | +| TF_BUILD | Azure Pipelines | Parse boolean value | +| GITHUB_ACTIONS | GitHub Actions | Parse boolean value | +| APPVEYOR | Appveyor | Parse boolean value | +| CI | Many/Most | Parse boolean value | +| TRAVIS | Travis CI | Parse boolean value | +| CIRCLECI | Circle CI | Parse boolean value | +| CODEBUILD_BUILD_ID, AWS_REGION | Amazon Web Services CodeBuild | Check if all are present and non-null | +| BUILD_ID, BUILD_URL | Jenkins | Check if all are present and non-null | +| BUILD_ID, PROJECT_ID | Google Cloud Build | Check if all are present and non-null | +| TEAMCITY_VERSION | TeamCity | Check if present and non-null | +| JB_SPACE_API_URL | JetBrains Space | Check if present and non-null | + ## Avoid inadvertent disclosure of information .NET contributors and anyone else running a version of the .NET SDK that they built themselves should consider the path to their SDK source code. If a crash occurs while using a .NET SDK that is a custom debug build or configured with custom build symbol files, the SDK source file path from the build machine is collected as part of the stack trace and isn't hashed. diff --git a/docs/core/tutorials/snippets/library-with-visual-studio/csharp/StringLibraryTest/StringLibraryTest.csproj b/docs/core/tutorials/snippets/library-with-visual-studio/csharp/StringLibraryTest/StringLibraryTest.csproj index 5b4a7aec14842..97c7516a112f4 100644 --- a/docs/core/tutorials/snippets/library-with-visual-studio/csharp/StringLibraryTest/StringLibraryTest.csproj +++ b/docs/core/tutorials/snippets/library-with-visual-studio/csharp/StringLibraryTest/StringLibraryTest.csproj @@ -7,9 +7,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/docs/core/tutorials/snippets/library-with-visual-studio/vb/StringLibraryTest/StringLibraryTest.vbproj b/docs/core/tutorials/snippets/library-with-visual-studio/vb/StringLibraryTest/StringLibraryTest.vbproj index 0188dc19981dc..47a32a45f1354 100644 --- a/docs/core/tutorials/snippets/library-with-visual-studio/vb/StringLibraryTest/StringLibraryTest.vbproj +++ b/docs/core/tutorials/snippets/library-with-visual-studio/vb/StringLibraryTest/StringLibraryTest.vbproj @@ -8,9 +8,9 @@ - - - + + + diff --git a/docs/core/tutorials/with-visual-studio.md b/docs/core/tutorials/with-visual-studio.md index 6a142cde67cb8..a4be7f3920797 100644 --- a/docs/core/tutorials/with-visual-studio.md +++ b/docs/core/tutorials/with-visual-studio.md @@ -17,7 +17,7 @@ This tutorial shows how to create and run a .NET console application in Visual S ## Prerequisites -- [Visual Studio 2022 version 17.0.0 Preview](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2022) with the **.NET desktop development** workload installed. The .NET 6 SDK is automatically installed when you select this workload. +- [Visual Studio 2022 version 17.1 or later](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2022) with the **.NET desktop development** workload installed. The .NET 6 SDK is automatically installed when you select this workload. For more information, see [Install the .NET SDK with Visual Studio](../install/windows.md#install-with-visual-studio). diff --git a/docs/core/whats-new/dotnet-5.md b/docs/core/whats-new/dotnet-5.md index d451415cd824e..46ab26ef7fc6b 100644 --- a/docs/core/whats-new/dotnet-5.md +++ b/docs/core/whats-new/dotnet-5.md @@ -55,7 +55,7 @@ The original implementation of [Windows Communication Foundation (WCF)](../../fr - [System.ServiceModel.Primitives](https://www.nuget.org/packages/System.ServiceModel.Primitives) - [System.ServiceModel.Security](https://www.nuget.org/packages/System.ServiceModel.Security) -The community maintains the server components that complement the aforementioned client libraries. The GitHub repository can be found at [CoreWCF](https://github.com/CoreWCF/CoreWCF). The server components are _not_ officially supported by Microsoft. For an alternative to WCF, consider [gRPC](/aspnet/core/grpc). +The server components that complement the aforementioned client libraries are available through [CoreWCF](https://www.nuget.org/profiles/corewcf). As of April 2022, CoreWCF is officially supported by Microsoft. However, for an alternative to WCF, consider [gRPC](/aspnet/core/grpc). ## .NET 5 doesn't replace .NET Standard diff --git a/docs/csharp/fundamentals/functional/discards.md b/docs/csharp/fundamentals/functional/discards.md index d38142143ddec..6a6f9bc785590 100644 --- a/docs/csharp/fundamentals/functional/discards.md +++ b/docs/csharp/fundamentals/functional/discards.md @@ -9,7 +9,7 @@ f1_keywords: Starting with C# 7.0, C# supports discards, which are placeholder variables that are intentionally unused in application code. Discards are equivalent to unassigned variables; they don't have a value. A discard communicates intent to the compiler and others that read your code: You intended to ignore the result of an expression. You may want to ignore the result of an expression, one or more members of a tuple expression, an `out` parameter to a method, or the target of a pattern matching expression. -Because there's only a single discard variable, that variable may not even be allocated storage. Discards can reduce memory allocations. Discards make the intent of your code clear. They enhance its readability and maintainability. +Discards make the intent of your code clear. A discard indicates that our code never uses the variable. They enhance its readability and maintainability. You indicate that a variable is a discard by assigning it the underscore (`_`) as its name. For example, the following method call returns a tuple in which the first and second values are discards. `area` is a previously declared variable set to the third component returned by `GetCityInformation`: diff --git a/docs/csharp/fundamentals/functional/pattern-matching.md b/docs/csharp/fundamentals/functional/pattern-matching.md index d697b30bd3aea..cd6f79fd96710 100644 --- a/docs/csharp/fundamentals/functional/pattern-matching.md +++ b/docs/csharp/fundamentals/functional/pattern-matching.md @@ -1,7 +1,7 @@ --- title: Pattern matching overview - C# guide description: Learn about pattern matching expressions in C# -ms.date: 05/14/2021 +ms.date: 06/02/2022 --- # Pattern matching overview @@ -40,7 +40,11 @@ The previous example demonstrates a method dispatch based on the value of an enu :::code language="csharp" source="snippets/patterns/Simulation.cs" ID="PerformStringOperation"::: -The preceding example shows the same algorithm, but uses string values instead of an enum. You would use this scenario if your application responds to text commands instead of a regular data format. In all these examples, the *discard pattern* ensures that you handle every input. The compiler helps you by making sure every possible input value is handled. +The preceding example shows the same algorithm, but uses string values instead of an enum. You would use this scenario if your application responds to text commands instead of a regular data format. Starting with C# 11, you can also use a `Span` or a `ReadOnlySpan`to test for constant string values, as shown in the following sample: + +:::code language="csharp" source="snippets/patterns/Simulation.cs" ID="PerformSpanOperation"::: + +In all these examples, the *discard pattern* ensures that you handle every input. The compiler helps you by making sure every possible input value is handled. ## Relational patterns @@ -76,6 +80,12 @@ The preceding code demonstrates the [*positional pattern*](../../language-refere This article provided a tour of the kinds of code you can write with pattern matching in C#. The following articles show more examples of using patterns in scenarios, and the full vocabulary of patterns available to use. +## List patterns + +You can check elements in a list or an array using a *list pattern*. A list pattern provides a means to apply a pattern to any element of a sequence. In addition, you can apply the *discard pattern* (`_`) to match any element, or apply a *slice pattern* to match zero or more elements. The following example determines if an array matches the binary digits, or the start of a Fibonacci sequence: + +:::code language="csharp" source="snippets/patterns/OrderProcessor.cs" id="ListPattern"::: + ## See also - [Exploration: Use pattern matching to build your class behavior for better code](../../whats-new/tutorials/patterns-objects.md) diff --git a/docs/csharp/fundamentals/functional/snippets/patterns/OrderProcessor.cs b/docs/csharp/fundamentals/functional/snippets/patterns/OrderProcessor.cs index beadd062ae712..8b12bc3de15da 100644 --- a/docs/csharp/fundamentals/functional/snippets/patterns/OrderProcessor.cs +++ b/docs/csharp/fundamentals/functional/snippets/patterns/OrderProcessor.cs @@ -32,5 +32,25 @@ public decimal CalculateDiscount(Order order) => var someObject => 0m, }; // +} +class ListPattern +{ + // + public void MatchElements(int[] array) + { + if (array is [0,1]) + { + Console.WriteLine("Binary Digits"); + } + else if (array is [1,1,2,3,5,8, ..]) + { + Console.WriteLine("array looks like a Fibonacci sequence"); + } + else + { + Console.WriteLine("Array shape not recognized"); + } + } + // } diff --git a/docs/csharp/fundamentals/functional/snippets/patterns/Simulation.cs b/docs/csharp/fundamentals/functional/snippets/patterns/Simulation.cs index 8118fbbac3995..1190a77e68610 100644 --- a/docs/csharp/fundamentals/functional/snippets/patterns/Simulation.cs +++ b/docs/csharp/fundamentals/functional/snippets/patterns/Simulation.cs @@ -41,6 +41,18 @@ public State PerformOperation(string command) => }; // + // + public State PerformOperation(ReadOnlySpan command) => + command switch + { + "SystemTest" => RunDiagnostics(), + "Start" => StartSystem(), + "Stop" => StopSystem(), + "Reset" => ResetToReady(), + _ => throw new ArgumentException("Invalid string value for command", nameof(command)), + }; + // + // string WaterState(int tempInFahrenheit) => tempInFahrenheit switch diff --git a/docs/csharp/fundamentals/functional/snippets/patterns/patterns.csproj b/docs/csharp/fundamentals/functional/snippets/patterns/patterns.csproj index 3897747193834..8e2f6cfa77f3b 100644 --- a/docs/csharp/fundamentals/functional/snippets/patterns/patterns.csproj +++ b/docs/csharp/fundamentals/functional/snippets/patterns/patterns.csproj @@ -2,9 +2,10 @@ Exe - net6.0 + net7.0 enable enable + preview diff --git a/docs/csharp/fundamentals/tutorials/classes.md b/docs/csharp/fundamentals/tutorials/classes.md index 983601ce8dd99..7c56bbb478d29 100644 --- a/docs/csharp/fundamentals/tutorials/classes.md +++ b/docs/csharp/fundamentals/tutorials/classes.md @@ -9,7 +9,7 @@ In this tutorial, you'll build a console application and see the basic object-or ## Prerequisites -The tutorial expects that you have a machine set up for local development. On Windows, Linux, or macOS, you can use the .NET CLI to create, build, and run applications. On Windows, you can use Visual Studio 2019. For setup instructions, see [Set up your local environment](../../tour-of-csharp/tutorials/local-environment.md). +[!INCLUDE [Prerequisites](../../includes/prerequisites.md)] ## Create your application @@ -30,7 +30,7 @@ This file will contain the definition of a ***bank account***. Object Oriented p 1. It accepts deposits. 1. It accepts withdrawals. 1. The initial balance must be positive. -1. Withdrawals cannot result in a negative balance. +1. Withdrawals can't result in a negative balance. ## Define the bank account type @@ -57,13 +57,13 @@ public class BankAccount Before going on, let's take a look at what you've built. The `namespace` declaration provides a way to logically organize your code. This tutorial is relatively small, so you'll put all the code in one namespace. -`public class BankAccount` defines the class, or type, you are creating. Everything inside the `{` and `}` that follows the class declaration defines the state and behavior of the class. There are five ***members*** of the `BankAccount` class. The first three are ***properties***. Properties are data elements and can have code that enforces validation or other rules. The last two are ***methods***. Methods are blocks of code that perform a single function. Reading the names of each of the members should provide enough information for you or another developer to understand what the class does. +`public class BankAccount` defines the class, or type, you're creating. Everything inside the `{` and `}` that follows the class declaration defines the state and behavior of the class. There are five ***members*** of the `BankAccount` class. The first three are ***properties***. Properties are data elements and can have code that enforces validation or other rules. The last two are ***methods***. Methods are blocks of code that perform a single function. Reading the names of each of the members should provide enough information for you or another developer to understand what the class does. ## Open a new account The first feature to implement is to open a bank account. When a customer opens an account, they must supply an initial balance, and information about the owner or owners of that account. -Creating a new object of the `BankAccount` type means defining a ***constructor*** that assigns those values. A ***constructor*** is a member that has the same name as the class. It is used to initialize objects of that class type. Add the following constructor to the `BankAccount` type. Place the following code above the declaration of `MakeDeposit`: +Creating a new object of the `BankAccount` type means defining a ***constructor*** that assigns those values. A ***constructor*** is a member that has the same name as the class. It's used to initialize objects of that class type. Add the following constructor to the `BankAccount` type. Place the following code above the declaration of `MakeDeposit`: ```csharp public BankAccount(string name, decimal initialBalance) @@ -73,6 +73,18 @@ public BankAccount(string name, decimal initialBalance) } ``` +The preceding code identifies the properties of the object being constructed by including the `this` qualifier. That qualifier is usually optional and omitted. You could also have written: + +```csharp +public BankAccount(string name, decimal initialBalance) +{ + Owner = name; + Balance = initialBalance; +} +``` + +The `this` qualifier is only required when a local variable or parameter has the same name as that field or property. The `this` qualifier is omitted throughout the remainder of this article unless it's necessary. + Constructors are called when you create an object using [`new`](../../language-reference/operators/new-operator.md). Replace the line `Console.WriteLine("Hello World!");` in *Program.cs* with the following code (replace `` with your name): ```csharp @@ -84,7 +96,7 @@ Console.WriteLine($"Account {account.Number} was created for {account.Owner} wit Let's run what you've built so far. If you're using Visual Studio, Select **Start without debugging** from the **Debug** menu. If you're using a command line, type `dotnet run` in the directory where you've created your project. -Did you notice that the account number is blank? It's time to fix that. The account number should be assigned when the object is constructed. But it shouldn't be the responsibility of the caller to create it. The `BankAccount` class code should know how to assign new account numbers. A simple way to do this is to start with a 10-digit number. Increment it when each new account is created. Finally, store the current account number when an object is constructed. +Did you notice that the account number is blank? It's time to fix that. The account number should be assigned when the object is constructed. But it shouldn't be the responsibility of the caller to create it. The `BankAccount` class code should know how to assign new account numbers. A simple way is to start with a 10-digit number. Increment it when each new account is created. Finally, store the current account number when an object is constructed. Add a member declaration to the `BankAccount` class. Place the following line of code after the opening brace `{` at the beginning of the `BankAccount` class: @@ -92,7 +104,7 @@ Add a member declaration to the `BankAccount` class. Place the following line of private static int accountNumberSeed = 1234567890; ``` -This is a data member. It's `private`, which means it can only be accessed by code inside the `BankAccount` class. It's a way of separating the public responsibilities (like having an account number) from the private implementation (how account numbers are generated). It is also `static`, which means it is shared by all of the `BankAccount` objects. The value of a non-static variable is unique to each instance of the `BankAccount` object. Add the following two lines to the constructor to assign the account number. Place them after the line that says `this.Balance = initialBalance`: +The `accountNumberSeed` is a data member. It's `private`, which means it can only be accessed by code inside the `BankAccount` class. It's a way of separating the public responsibilities (like having an account number) from the private implementation (how account numbers are generated). It's also `static`, which means it's shared by all of the `BankAccount` objects. The value of a non-static variable is unique to each instance of the `BankAccount` object. Add the following two lines to the constructor to assign the account number. Place them after the line that says `this.Balance = initialBalance`: ```csharp this.Number = accountNumberSeed.ToString(); @@ -103,9 +115,9 @@ Type `dotnet run` to see the results. ## Create deposits and withdrawals -Your bank account class needs to accept deposits and withdrawals to work correctly. Let's implement deposits and withdrawals by creating a journal of every transaction for the account. That has a few advantages over simply updating the balance on each transaction. The history can be used to audit all transactions and manage daily balances. By computing the balance from the history of all transactions when needed, any errors in a single transaction that are fixed will be correctly reflected in the balance on the next computation. +Your bank account class needs to accept deposits and withdrawals to work correctly. Let's implement deposits and withdrawals by creating a journal of every transaction for the account. Tracking every transaction has a few advantages over simply updating the balance on each transaction. The history can be used to audit all transactions and manage daily balances. Computing the balance from the history of all transactions when needed ensures any errors in a single transaction that are fixed will be correctly reflected in the balance on the next computation. -Let's start by creating a new type to represent a transaction. This is a simple type that doesn't have any responsibilities. It needs a few properties. Create a new file named *Transaction.cs*. Add the following code to it: +Let's start by creating a new type to represent a transaction. The transaction is a simple type that doesn't have any responsibilities. It needs a few properties. Create a new file named *Transaction.cs*. Add the following code to it: :::code language="csharp" source="./snippets/introduction-to-classes/Transaction.cs"::: @@ -119,9 +131,9 @@ Now, let's correctly compute the `Balance`. The current balance can be found by This example shows an important aspect of ***properties***. You're now computing the balance when another programmer asks for the value. Your computation enumerates all transactions, and provides the sum as the current balance. -Next, implement the `MakeDeposit` and `MakeWithdrawal` methods. These methods will enforce the final two rules: that the initial balance must be positive, and that any withdrawal must not create a negative balance. +Next, implement the `MakeDeposit` and `MakeWithdrawal` methods. These methods will enforce the final two rules: the initial balance must be positive, and any withdrawal must not create a negative balance. -This introduces the concept of ***exceptions***. The standard way of indicating that a method cannot complete its work successfully is to throw an exception. The type of exception and the message associated with it describe the error. Here, the `MakeDeposit` method throws an exception if the amount of the deposit is not greater than 0. The `MakeWithdrawal` method throws an exception if the withdrawal amount is not greater than 0, or if applying the withdrawal results in a negative balance. Add the following code after the declaration of the `allTransactions` list: +These rules introduce the concept of ***exceptions***. The standard way of indicating that a method can't complete its work successfully is to throw an exception. The type of exception and the message associated with it describe the error. Here, the `MakeDeposit` method throws an exception if the amount of the deposit isn't greater than 0. The `MakeWithdrawal` method throws an exception if the withdrawal amount isn't greater than 0, or if applying the withdrawal results in a negative balance. Add the following code after the declaration of the `allTransactions` list: :::code language="csharp" source="./snippets/introduction-to-classes/BankAccount.cs" id="DepositAndWithdrawal"::: @@ -131,7 +143,7 @@ The constructor should get one change so that it adds an initial transaction, ra :::code language="csharp" source="./snippets/introduction-to-classes/BankAccount.cs" id="Constructor"::: - is a property that returns the current date and time. Test this by adding a few deposits and withdrawals in your `Main` method, following the code that creates a new `BankAccount`: + is a property that returns the current date and time. Test this code by adding a few deposits and withdrawals in your `Main` method, following the code that creates a new `BankAccount`: ```csharp account.MakeWithdrawal(500, DateTime.Now, "Rent payment"); @@ -140,7 +152,7 @@ account.MakeDeposit(100, DateTime.Now, "Friend paid me back"); Console.WriteLine(account.Balance); ``` -Next, test that you are catching error conditions by trying to create an account with a negative balance. Add the following code after the preceding code you just added: +Next, test that you're catching error conditions by trying to create an account with a negative balance. Add the following code after the preceding code you just added: ```csharp // Test that the initial balances must be positive. @@ -157,7 +169,7 @@ catch (ArgumentOutOfRangeException e) } ``` -You use the [`try` and `catch` statements](../../language-reference/keywords/try-catch.md) to mark a block of code that may throw exceptions and to catch those errors that you expect. You can use the same technique to test the code that throws an exception for a negative balance. Add the following code at the end of your `Main` method: +You use the [`try` and `catch` statements](../../language-reference/keywords/try-catch.md) to mark a block of code that may throw exceptions and to catch those errors that you expect. You can use the same technique to test the code that throws an exception for a negative balance. Add the following code before the declaration of `invalidAccount` in your `Main` method: ```csharp // Test for a negative balance. @@ -180,7 +192,7 @@ To finish this tutorial, you can write the `GetAccountHistory` method that creat :::code language="csharp" source="./snippets/introduction-to-classes/BankAccount.cs" id="History"::: -This uses the class to format a string that contains one line for each transaction. You've seen the string formatting code earlier in these tutorials. One new character is `\t`. That inserts a tab to format the output. +The history uses the class to format a string that contains one line for each transaction. You've seen the string formatting code earlier in these tutorials. One new character is `\t`. That inserts a tab to format the output. Add this line to test it in *Program.cs*: diff --git a/docs/csharp/fundamentals/tutorials/inheritance.md b/docs/csharp/fundamentals/tutorials/inheritance.md index 6eb42ceb44c21..bd0bbec84c35c 100644 --- a/docs/csharp/fundamentals/tutorials/inheritance.md +++ b/docs/csharp/fundamentals/tutorials/inheritance.md @@ -10,7 +10,7 @@ This tutorial introduces you to inheritance in C#. Inheritance is a feature of o ## Prerequisites -This tutorial assumes that you've installed the .NET SDK. Visit the [.NET Downloads](https://dotnet.microsoft.com/download) page to download it. You also need a code editor. This tutorial uses [Visual Studio Code](https://code.visualstudio.com), although you can use any code editor of your choice. +[!INCLUDE [Prerequisites](../../includes/prerequisites.md)] ## Running the examples diff --git a/docs/csharp/fundamentals/tutorials/oop.md b/docs/csharp/fundamentals/tutorials/oop.md index 5253fc26a0c62..b14634f1536e9 100644 --- a/docs/csharp/fundamentals/tutorials/oop.md +++ b/docs/csharp/fundamentals/tutorials/oop.md @@ -177,7 +177,7 @@ Run the program, and check the results. ## Summary -If you got stuck, you can see the source for this tutorial [in our GitHub repo](https://github.com/dotnet/docs/tree/main/docs/csharp/fundamentals/object-oriented/snippets/objects). +If you got stuck, you can see the source for this tutorial [in our GitHub repo](https://github.com/dotnet/docs/tree/main/docs/csharp/fundamentals/tutorials/snippets/object-oriented-programming). This tutorial demonstrated many of the techniques used in Object-Oriented programming: diff --git a/docs/csharp/fundamentals/tutorials/pattern-matching.md b/docs/csharp/fundamentals/tutorials/pattern-matching.md index 04a814428166a..bd6c57e20cbe6 100644 --- a/docs/csharp/fundamentals/tutorials/pattern-matching.md +++ b/docs/csharp/fundamentals/tutorials/pattern-matching.md @@ -18,7 +18,7 @@ In this tutorial, you'll learn how to: ## Prerequisites -You'll need to set up your machine to run .NET 6, which includes the C# 10 compiler. The C# 10 compiler is available starting with [Visual Studio 2022](https://visualstudio.microsoft.com/vs/preview/) or [.NET 6 SDK](https://dotnet.microsoft.com/download). +[!INCLUDE [Prerequisites](../../includes/prerequisites.md)] This tutorial assumes you're familiar with C# and .NET, including either Visual Studio or the .NET CLI. @@ -26,7 +26,7 @@ This tutorial assumes you're familiar with C# and .NET, including either Visual Modern development often includes integrating data from multiple sources and presenting information and insights from that data in a single cohesive application. You and your team won't have control or access for all the types that represent the incoming data. -The classic object-oriented design would call for creating types in your application that represent each data type from those multiple data sources. Then, your application would work with those new types, build inheritance hierarchies, create virtual methods, and implement abstractions. Those techniques work, and sometimes they are the best tools. Other times you can write less code. You can write more clear code using techniques that separate the data from the operations that manipulate that data. +The classic object-oriented design would call for creating types in your application that represent each data type from those multiple data sources. Then, your application would work with those new types, build inheritance hierarchies, create virtual methods, and implement abstractions. Those techniques work, and sometimes they're the best tools. Other times you can write less code. You can write more clear code using techniques that separate the data from the operations that manipulate that data. In this tutorial, you'll create and explore an application that takes incoming data from several external sources for a single scenario. You'll see how **pattern matching** provides an efficient way to consume and process that data in ways that weren't part of the original system. @@ -36,7 +36,7 @@ From that brief description, you may have quickly sketched out an object hierarc :::code language="csharp" source="./snippets/patterns/start/toll-calculator/ExternalSystems.cs"::: -You can download the starter code from the [dotnet/samples](https://github.com/dotnet/samples/tree/main/csharp/tutorials/patterns/start) GitHub repository. You can see that the vehicle classes are from different systems, and are in different namespaces. No common base class, other than `System.Object` can be leveraged. +You can download the starter code from the [dotnet/samples](https://github.com/dotnet/samples/tree/main/csharp/tutorials/patterns/start) GitHub repository. You can see that the vehicle classes are from different systems, and are in different namespaces. No common base class, other than `System.Object` can be used. ## Pattern matching designs @@ -45,7 +45,7 @@ The scenario used in this tutorial highlights the kinds of problems that pattern - The objects you need to work with aren't in an object hierarchy that matches your goals. You may be working with classes that are part of unrelated systems. - The functionality you're adding isn't part of the core abstraction for these classes. The toll paid by a vehicle *changes* for different types of vehicles, but the toll isn't a core function of the vehicle. -When the *shape* of the data and the *operations* on that data are not described together, the pattern matching features in C# make it easier to work with. +When the *shape* of the data and the *operations* on that data aren't described together, the pattern matching features in C# make it easier to work with. ## Implement the basic toll calculations diff --git a/docs/csharp/fundamentals/types/interfaces.md b/docs/csharp/fundamentals/types/interfaces.md index 5b4f80975d404..883a92419aef2 100644 --- a/docs/csharp/fundamentals/types/interfaces.md +++ b/docs/csharp/fundamentals/types/interfaces.md @@ -28,6 +28,9 @@ Interfaces can contain instance methods, properties, events, indexers, or any co To implement an interface member, the corresponding member of the implementing class must be public, non-static, and have the same name and signature as the interface member. +> [!NOTE] +> When an interface declares static members, a type implementing that interface may also declare static members with the same signature. Those are distinct and uniquely identified by the type declaring the member. The static member declared in a type *doesn't* override the static member declared in the interface. + A class or struct that implements an interface must provide an implementation for all declared members without a default implementation provide by the interface. However, if a base class implements an interface, any class that's derived from the base class inherits that implementation. The following example shows an implementation of the interface. The implementing class, `Car`, must provide an implementation of the method. diff --git a/docs/csharp/includes/prerequisites.md b/docs/csharp/includes/prerequisites.md new file mode 100644 index 0000000000000..ca3fa50213c80 --- /dev/null +++ b/docs/csharp/includes/prerequisites.md @@ -0,0 +1,10 @@ +--- +author: BillWagner +ms.author: wiwagn +ms.topic: include +ms.date: 04/26/2022 +--- + +- We recommend [Visual Studio](https://visualstudio.com) for Windows or Mac. You can download a free version from the [Visual Studio downloads page](https://visualstudio.microsoft.com/downloads). Visual Studio includes the .NET SDK. +- You can also use the [Visual Studio Code](https://code.visualstudio.com) editor. You'll need to install the latest [.NET SDK](https://dotnet.microsoft.com/download) separately. +- If you prefer a different editor, you need to install the latest [.NET SDK](https://dotnet.microsoft.com/download). diff --git a/docs/csharp/index.yml b/docs/csharp/index.yml index 843d9a1a4bb1f..632559217d860 100644 --- a/docs/csharp/index.yml +++ b/docs/csharp/index.yml @@ -161,7 +161,7 @@ landingContent: url: language-reference/operators/index.md - text: Configure language version url: language-reference/configure-language-version.md - - text: "C# language specification" + - text: "C# language specification - C# 7 draft in progress" url: ../../_csharpstandard/standard/README.md - title: "Stay in touch" diff --git a/docs/csharp/language-reference/attributes/nullable-analysis.md b/docs/csharp/language-reference/attributes/nullable-analysis.md index b113f52ccc97b..08737af337119 100644 --- a/docs/csharp/language-reference/attributes/nullable-analysis.md +++ b/docs/csharp/language-reference/attributes/nullable-analysis.md @@ -203,8 +203,6 @@ When the value of the argument matches the value of the `DoesNotReturnIf` constr ## Summary -[!INCLUDE [C# version alert](../../includes/csharp-version-alert.md)] - Adding nullable reference types provides an initial vocabulary to describe your APIs expectations for variables that could be `null`. The attributes provide a richer vocabulary to describe the null state of variables as preconditions and postconditions. These attributes more clearly describe your expectations and provide a better experience for the developers using your APIs. As you update libraries for a nullable context, add these attributes to guide users of your APIs to the correct usage. These attributes help you fully describe the null-state of arguments and return values. diff --git a/docs/csharp/language-reference/builtin-types/default-values.md b/docs/csharp/language-reference/builtin-types/default-values.md index 6817b035e931a..f348baa2add63 100644 --- a/docs/csharp/language-reference/builtin-types/default-values.md +++ b/docs/csharp/language-reference/builtin-types/default-values.md @@ -47,7 +47,7 @@ Console.WriteLine(n); // output: (0, 0) At run time, if the instance represents a value type, you can use the method to invoke the parameterless constructor to obtain the default value of the type. > [!NOTE] -> In C# 10 and later, a [structure type](struct.md) (which is a value type) may have an [explicit parameterless constructor](struct.md#parameterless-constructors-and-field-initializers) that may produce a non-default value of the type. Thus, we recommend using the `default` operator or the `default` literal to produce the default value of a type. +> In C# 10 and later, a [structure type](struct.md) (which is a value type) may have an [explicit parameterless constructor](struct.md#struct-initialization-and-default-values) that may produce a non-default value of the type. Thus, we recommend using the `default` operator or the `default` literal to produce the default value of a type. ## C# language specification diff --git a/docs/csharp/language-reference/builtin-types/nullable-reference-types.md b/docs/csharp/language-reference/builtin-types/nullable-reference-types.md index 2d6da54541d0a..b65bea0ab1c1b 100644 --- a/docs/csharp/language-reference/builtin-types/nullable-reference-types.md +++ b/docs/csharp/language-reference/builtin-types/nullable-reference-types.md @@ -10,6 +10,9 @@ ms.date: 09/08/2021 Nullable reference types are available beginning with C# 8.0, in code that has opted in to a *nullable aware context*. Nullable reference types, the null static analysis warnings, and the [null-forgiving operator](../operators/null-forgiving.md) are optional language features. All are turned off by default. A *nullable context* is controlled at the project level using build settings, or in code using pragmas. +> [!IMPORTANT] +> All project templates starting with .NET 6 (C# 10) enable the *nullable context* for the project. Projects created with earlier templates don't include this element, and these features are off unless you enable them in the project file or use pragmas. + In a nullable aware context: - A variable of a reference type `T` must be initialized with non-null, and may never be assigned a value that may be `null`. diff --git a/docs/csharp/language-reference/builtin-types/record.md b/docs/csharp/language-reference/builtin-types/record.md index 067fc2d79fcff..da42f050d9433 100644 --- a/docs/csharp/language-reference/builtin-types/record.md +++ b/docs/csharp/language-reference/builtin-types/record.md @@ -45,7 +45,7 @@ The preceding examples show some distinctions between records that are reference - A `record` or a `record class` declares a reference type. The `class` keyword is optional, but can add clarity for readers. A `record struct` declares a value type. - Positional properties are *immutable* in a `record class` and a `readonly record struct`. They're *mutable* in a `record struct`. -The remainder of this article discusses both `record class` and `record struct` types. The differences are detailed in each section. You should decide between a `record class` and a `record struct` similar to deciding between a `class` and a `struct`. The term *record* is used to describe behavior that applies to all record types. Either `record struct` or `record class` is used to describe behavior that applies to only struct or class types, respectively. The `record` type were introduced in C# 9; `record struct` types were introduced in C# 10. +The remainder of this article discusses both `record class` and `record struct` types. The differences are detailed in each section. You should decide between a `record class` and a `record struct` similar to deciding between a `class` and a `struct`. The term *record* is used to describe behavior that applies to all record types. Either `record struct` or `record class` is used to describe behavior that applies to only struct or class types, respectively. The `record` type was introduced in C# 9; `record struct` types were introduced in C# 10. ## Positional syntax for property definition diff --git a/docs/csharp/language-reference/builtin-types/reference-types.md b/docs/csharp/language-reference/builtin-types/reference-types.md index e0fd8f7fefd34..a6912e93f11a4 100644 --- a/docs/csharp/language-reference/builtin-types/reference-types.md +++ b/docs/csharp/language-reference/builtin-types/reference-types.md @@ -97,7 +97,7 @@ You can even include a sequence of three (or more) double quote characters. If y ```csharp """"" -This raw string literal has four """", count them: """" four! +This raw string literal has four """", count them: """" four! embedded quote characters in a sequence. That's why it starts and ends with five double quotes. @@ -132,7 +132,7 @@ Columns to the right of the ending quote sequence are preserved. This enables ra var json= """ { "prop": 0 - } + } """; ``` diff --git a/docs/csharp/language-reference/builtin-types/snippets/shared/StructType.cs b/docs/csharp/language-reference/builtin-types/snippets/shared/StructType.cs index a76b55c70a080..b54963f26903e 100644 --- a/docs/csharp/language-reference/builtin-types/snippets/shared/StructType.cs +++ b/docs/csharp/language-reference/builtin-types/snippets/shared/StructType.cs @@ -184,6 +184,11 @@ public Measurement(double value, string description) Value = value; Description = description; } + + public Measurement(string description) + { + Description = description; + } public double Value { get; init; } public string Description { get; init; } = "Ordinary measurement"; diff --git a/docs/csharp/language-reference/builtin-types/snippets/shared/builtin-types.csproj b/docs/csharp/language-reference/builtin-types/snippets/shared/builtin-types.csproj index e59369f68c56f..679ded2c2c095 100644 --- a/docs/csharp/language-reference/builtin-types/snippets/shared/builtin-types.csproj +++ b/docs/csharp/language-reference/builtin-types/snippets/shared/builtin-types.csproj @@ -2,14 +2,12 @@ Exe - net6 + net7 + preview enable builtin_types.Program true - AnyCPU;x86 - - - + AnyCPU diff --git a/docs/csharp/language-reference/builtin-types/struct.md b/docs/csharp/language-reference/builtin-types/struct.md index b555ca47e9019..52fb7230b3a87 100644 --- a/docs/csharp/language-reference/builtin-types/struct.md +++ b/docs/csharp/language-reference/builtin-types/struct.md @@ -16,7 +16,7 @@ A *structure type* (or *struct type*) is a [value type](value-types.md) that can [!code-csharp[struct example](snippets/shared/StructType.cs#StructExample)] -Structure types have *value semantics*. That is, a variable of a structure type contains an instance of the type. By default, variable values are copied on assignment, passing an argument to a method, and returning a method result. In the case of a structure-type variable, an instance of the type is copied. For more information, see [Value types](value-types.md). +Structure types have *value semantics*. That is, a variable of a structure type contains an instance of the type. By default, variable values are copied on assignment, passing an argument to a method, and returning a method result. For structure-type variables, an instance of the type is copied. For more information, see [Value types](value-types.md). Typically, you use structure types to design small data-centric types that provide little or no behavior. For example, .NET uses structure types to represent a number (both [integer](integral-numeric-types.md) and [real](floating-point-numeric-types.md)), a [Boolean value](bool.md), a [Unicode character](char.md), a [time instance](xref:System.DateTime). If you're focused on the behavior of a type, consider defining a [class](../keywords/class.md). Class types have *reference semantics*. That is, a variable of a class type contains a reference to an instance of the type, not the instance itself. @@ -42,7 +42,7 @@ The following code defines a `readonly` struct with init-only property setters, Beginning with C# 8.0, you can also use the `readonly` modifier to declare that an instance member doesn't modify the state of a struct. If you can't declare the whole structure type as `readonly`, use the `readonly` modifier to mark the instance members that don't modify the state of the struct. -Within a `readonly` instance member, you can't assign to structure's instance fields. However, a `readonly` member can call a non-`readonly` member. In that case the compiler creates a copy of the structure instance and calls the non-`readonly` member on that copy. As a result, the original structure instance is not modified. +Within a `readonly` instance member, you can't assign to structure's instance fields. However, a `readonly` member can call a non-`readonly` member. In that case the compiler creates a copy of the structure instance and calls the non-`readonly` member on that copy. As a result, the original structure instance isn't modified. Typically, you apply the `readonly` modifier to the following kinds of instance members: @@ -79,62 +79,53 @@ Beginning with C# 10, you can use the [`with` expression](../operators/with-expr ## `record` struct -Beginning with C# 10, you can define record structure types. Record types provide built-in functionality for encapsulating data. You can define both `record struct` and `readonly record struct` types. A record struct cannot be a [`ref` struct](#ref-struct). For more information and examples, see [Records](record.md). +Beginning with C# 10, you can define record structure types. Record types provide built-in functionality for encapsulating data. You can define both `record struct` and `readonly record struct` types. A record struct can't be a [`ref` struct](#ref-struct). For more information and examples, see [Records](record.md). -## Limitations with the design of a structure type - -When you design a structure type, you have the same capabilities as with a [class](../keywords/class.md) type, with the following exceptions: - -- You can't declare a parameterless constructor. Every structure type already provides an implicit parameterless constructor that produces the [default value](default-values.md) of the type. +## Struct initialization and default values - > [!NOTE] - > Beginning with C# 10, you can declare a parameterless constructor in a structure type. For more information, see the [Parameterless constructors and field initializers](#parameterless-constructors-and-field-initializers) section. - -- You can't initialize an instance field or property at its declaration. However, you can initialize a [static](../keywords/static.md) or [const](../keywords/const.md) field or a static property at its declaration. +A variable of a `struct` type directly contains the data for that `struct`. That creates a distinction between an uninitialized `struct`, which has its default value and an initialized `struct`, which stores values set by constructing it. For example consider the following code: - > [!NOTE] - > Beginning with C# 10, you can initialize an instance field or property at its declaration. For more information, see the [Parameterless constructors and field initializers](#parameterless-constructors-and-field-initializers) section. +:::code language="csharp" source="snippets/shared/StructType.cs" id="ParameterlessConstructor"::: -- A constructor of a structure type must initialize all instance fields of the type. +As the preceding example shows, the [default value expression](../operators/default.md) ignores a parameterless constructor and produces the [default value](default-values.md) of the structure type. Structure-type array instantiation also ignores a parameterless constructor and produces an array populated with the default values of a structure type. -- A structure type can't inherit from other class or structure type and it can't be the base of a class. However, a structure type can implement [interfaces](../keywords/interface.md). +The most common situation where you'll see default values is in arrays or in other collections where internal storage includes blocks of variables. The following example creates an array of 30 `TemperatureRange` structures, each of which has the default value: -- You can't declare a [finalizer](../../programming-guide/classes-and-structs/finalizers.md) within a structure type. +```csharp +// All elements have default values of 0: +TemperatureRange[] lastMonth = new TemperatureRange[30]; +``` -## Parameterless constructors and field initializers +All a struct's member fields must be *definitely assigned* when it's created because `struct` types directly store their data. The `default` value of a struct has *definitely assigned* all fields to 0. All fields must be definitely assigned when a constructor is invoked. You initialize fields using the following mechanisms: -Beginning with C# 10, you can declare a parameterless instance constructor in a structure type, as the following example shows: - -:::code language="csharp" source="snippets/shared/StructType.cs" id="ParameterlessConstructor"::: +- You can add *field initializers* to any field or auto implemented property. +- You can initialize any fields, or auto properties, in the body of the constructor. -As the preceding example shows, the [default value expression](../operators/default.md) ignores a parameterless constructor and produces the default value of a structure type, which is the value produced by setting all value-type fields to their [default values](default-values.md) (the 0-bit pattern) and all reference-type fields to `null`. Structure-type array instantiation also ignores a parameterless constructor and produces an array populated with the default values of a structure type. - -Beginning with C# 10, you can also initialize an instance field or property at its declaration, as the following example shows: +Beginning with C# 11, if you don't initialize all fields in a struct, the compiler adds code to the constructor that initializes those fields to the default value. The compiler performs its usual definite assignment analysis. Any fields that are accessed before being assigned, or not definitely assigned when the constructor finishes executing are assigned their default values before the constructor body executes. If `this` is accessed before all fields are assigned, the struct is initialized to the default value before the constructor body executes. :::code language="csharp" source="snippets/shared/StructType.cs" id="FieldInitializer"::: -If you don't declare a parameterless constructor explicitly, a structure type provides a parameterless constructor whose behavior is as follows: - -- If a structure type has no field initializers, an implicit parameterless constructor produces the default value of a structure type, regardless of field initializers, as the preceding example shows. -- If a structure type has field initializers, you must write an explicit parameterless constructor for the struct. It can, and often will, have an empty body. - -For more information, see the [Parameterless struct constructors](~/_csharplang/proposals/csharp-10.0/parameterless-struct-constructors.md) feature proposal note. +Every `struct` has a `public` parameterless constructor. If you write a parameterless constructor, it must be public. If you'd don't write a public parameterless constructor, the compiler generates one. The compiler generated parameterless constructor executes any field initializes, and produces the [default value](default-values.md) for all other fields. If you declare any field initializers, you must declare one explicit constructor. The one explicit constructor can be the parameterless constructor. It can have an empty body. For more information, see the [Parameterless struct constructors](~/_csharplang/proposals/csharp-10.0/parameterless-struct-constructors.md) feature proposal note. -## Instantiation of a structure type +If all instance fields of a structure type are accessible, you can also instantiate it without the `new` operator. In that case you must initialize all instance fields before the first use of the instance. The following example shows how to do that: -In C#, you must initialize a declared variable before it can be used. Because a structure-type variable can't be `null` (unless it's a variable of a [nullable value type](nullable-value-types.md)), you must instantiate an instance of the corresponding type. There are several ways to do that. +:::code language="csharp" source="snippets/shared/StructType.cs" id="SnippetWithoutNew"::: -Typically, you instantiate a structure type by calling an appropriate constructor with the [`new`](../operators/new-operator.md) operator. Every structure type has at least one constructor. That's an implicit parameterless constructor, which produces the [default value](default-values.md) of the type. You can also use a [default value expression](../operators/default.md) to produce the default value of a type. +In the case of the [built-in value types](value-types.md#built-in-value-types), use the corresponding literals to specify a value of the type. -If all instance fields of a structure type are accessible, you can also instantiate it without the `new` operator. In that case you must initialize all instance fields before the first use of the instance. The following example shows how to do that: +## Limitations with the design of a structure type -[!code-csharp[without new](snippets/shared/StructType.cs#WithoutNew)] +Structs have most of the capabilities of a [class](../keywords/class.md) type. There are some exceptions, and some exceptions that have been removed in more recent versions: -In the case of the [built-in value types](value-types.md#built-in-value-types), use the corresponding literals to specify a value of the type. +- A structure type can't inherit from other class or structure type and it can't be the base of a class. However, a structure type can implement [interfaces](../keywords/interface.md). +- You can't declare a [finalizer](../../programming-guide/classes-and-structs/finalizers.md) within a structure type. +- Prior to C# 11, a constructor of a structure type must initialize all instance fields of the type. +- Prior to C# 10, you can't declare a parameterless constructor. +- Prior to C# 10, you can't initialize an instance field or property at its declaration. ## Passing structure-type variables by reference -When you pass a structure-type variable to a method as an argument or return a structure-type value from a method, the whole instance of a structure type is copied. That can affect the performance of your code in high-performance scenarios that involve large structure types. You can avoid value copying by passing a structure-type variable by reference. Use the [`ref`](../keywords/ref.md#passing-an-argument-by-reference), [`out`](../keywords/out-parameter-modifier.md), or [`in`](../keywords/in-parameter-modifier.md) method parameter modifiers to indicate that an argument must be passed by reference. Use [ref returns](../../programming-guide/classes-and-structs/ref-returns.md) to return a method result by reference. For more information, see [Write safe and efficient C# code](../../write-safe-efficient-code.md). +When you pass a structure-type variable to a method as an argument or return a structure-type value from a method, the whole instance of a structure type is copied. Pass by value can affect the performance of your code in high-performance scenarios that involve large structure types. You can avoid value copying by passing a structure-type variable by reference. Use the [`ref`](../keywords/ref.md#passing-an-argument-by-reference), [`out`](../keywords/out-parameter-modifier.md), or [`in`](../keywords/in-parameter-modifier.md) method parameter modifiers to indicate that an argument must be passed by reference. Use [ref returns](../../programming-guide/classes-and-structs/ref-returns.md) to return a method result by reference. For more information, see [Write safe and efficient C# code](../../write-safe-efficient-code.md). ## `ref` struct @@ -146,7 +137,7 @@ Beginning with C# 7.2, you can use the `ref` modifier in the declaration of a st - A `ref` struct can't be boxed to or . - A `ref` struct can't be a type argument. - A `ref` struct variable can't be captured by a [lambda expression](../operators/lambda-expressions.md) or a [local function](../../programming-guide/classes-and-structs/local-functions.md). -- A `ref` struct variable can't be used in an [`async`](../keywords/async.md) method. However, you can use `ref` struct variables in synchronous methods, for example, in those that return or . +- A `ref` struct variable can't be used in an [`async`](../keywords/async.md) method. However, you can use `ref` struct variables in synchronous methods, for example, in methods that return or . - A `ref` struct variable can't be used in [iterators](../../iterators.md). Beginning with C# 8.0, you can define a disposable `ref` struct. To do that, ensure that a `ref` struct fits the [disposable pattern](~/_csharplang/proposals/csharp-8.0/using.md#pattern-based-using). That is, it has an instance or extension `Dispose` method, which is accessible, parameterless and has a `void` return type. diff --git a/docs/csharp/language-reference/compiler-messages/cs0433.md b/docs/csharp/language-reference/compiler-messages/cs0433.md index fb982161ce159..709380b9af52e 100644 --- a/docs/csharp/language-reference/compiler-messages/cs0433.md +++ b/docs/csharp/language-reference/compiler-messages/cs0433.md @@ -16,12 +16,10 @@ The type TypeName1 exists in both TypeName2 and TypeName3 To resolve this error, use the alias feature of the ([**References**](../compiler-options/inputs.md#references)) compiler option or do not reference one of your assemblies. -This error can also occur in ASP.NET Web Forms if: +This error can also occur if: * The `@ Page` directive has a `CodeFile` attribute when it should be a `CodeBehind` attribute. * Code is placed in an *App_Code* folder that shouldn't reside there. - - This error can also occur if code is in an APP_CODE folder that should not be in an APP_CODE folder. ## Examples diff --git a/docs/csharp/language-reference/compiler-messages/cs8892.md b/docs/csharp/language-reference/compiler-messages/cs8892.md deleted file mode 100644 index 6b2571abd903f..0000000000000 --- a/docs/csharp/language-reference/compiler-messages/cs8892.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -description: "Learn more about: Compiler warning (level 5) CS8892" -title: "Compiler warning (level 5) CS8892" -ms.date: 08/26/2020 -f1_keywords: - - "CS8892" -helpviewer_keywords: - - "CS8892" -author: Youssef1313 ---- - -# Compiler warning (level 5) CS8892 - -Method 'method' will not be used as an entry point because a synchronous entry point 'method' was found. - -This warning is generated on all async entry point candidates when you have multiple valid entry points, where they contain one or more synchronous entry point and one or more asynchronous entry points. - -Because async main was only supported starting with C# 7.1, this warning isn't generated for projects targeting a previous version. - -> [!NOTE] -> The compiler always uses the synchronous entry point. In case there are multiple synchronous entry points, you get a compiler error. - -## Example - -The following example generates CS8892: - -```csharp -using System; -using System.Threading.Tasks; - -public class Program -{ - // CS8892: Method 'Program.Main()' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found. - public static async Task Main() - { - await Task.Delay(1); - } - - public static void Main(string[] args) - { - Console.WriteLine(2); - } -} -``` - -## How to fix this warning - -Keep only the intended entry point for your program, and rename the others. - -```csharp -using System; -using System.Threading.Tasks; - -public class Program -{ - public static async Task SomeOtherNameAsync() - { - await Task.Delay(1); - } - - public static void Main(string[] args) - { - Console.WriteLine(2); - } -} -``` diff --git a/docs/csharp/language-reference/compiler-messages/index.md b/docs/csharp/language-reference/compiler-messages/index.md index 0c63ba0e18a87..0d94e90b8b8fb 100644 --- a/docs/csharp/language-reference/compiler-messages/index.md +++ b/docs/csharp/language-reference/compiler-messages/index.md @@ -26,4 +26,4 @@ For information about how to configure error and warning options in C#, see [C# - [C# Compiler Options](../compiler-options/index.md) - [Build Page, Project Designer (C#)](/visualstudio/ide/reference/build-page-project-designer-csharp) - [**WarningLevel** (C# Compiler Options)](../compiler-options/errors-warnings.md#warninglevel) -- [**DisabledWarnings** (C# Compiler Options)](../compiler-options/errors-warnings.md#disabledwarnings) +- [**NoWarn** (C# Compiler Options)](../compiler-options/errors-warnings.md#nowarn) diff --git a/docs/csharp/language-reference/compiler-messages/snippets/ImportedTypes/ImportedTypes.csproj b/docs/csharp/language-reference/compiler-messages/snippets/ImportedTypes/ImportedTypes.csproj new file mode 100644 index 0000000000000..132c02c59c236 --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/snippets/ImportedTypes/ImportedTypes.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/docs/csharp/language-reference/compiler-messages/snippets/ImportedTypes/Types.cs b/docs/csharp/language-reference/compiler-messages/snippets/ImportedTypes/Types.cs new file mode 100644 index 0000000000000..534a79ce7c41a --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/snippets/ImportedTypes/Types.cs @@ -0,0 +1,9 @@ +namespace ImportedTypes; + +// +public struct Struct +{ + private string data = String.Empty; + public Struct() { } +} +// diff --git a/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/Program.cs b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/Program.cs new file mode 100644 index 0000000000000..6e89e1c139292 --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/Program.cs @@ -0,0 +1,31 @@ +// See https://aka.ms/new-console-template for more information + +namespace WarningWaves; + +public static class Program +{ + // + public static void Main() + { + RunProgram(); + } + + // CS8892 + public static async Task Main(string[] args) + { + await RunProgramAsync(); + } + // + + private static void RunProgram() + { + WaveFive.Examples(); + } + + private static async Task RunProgramAsync() + { + RunProgram(); + await Task.Yield(); + } +} + diff --git a/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WarningWaves.csproj b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WarningWaves.csproj new file mode 100644 index 0000000000000..4494a6336e3c5 --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WarningWaves.csproj @@ -0,0 +1,16 @@ + + + + enable + Exe + net7.0 + enable + 7 + preview + + + + + + + diff --git a/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveFive.cs b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveFive.cs new file mode 100644 index 0000000000000..5b80ceb43326d --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveFive.cs @@ -0,0 +1,200 @@ +using System; +using ImportedTypes; + +namespace WarningWaves; + +public class WaveFive +{ + public class Src + { + public bool Select(Func selector) => true; + } + + public class Src2 + { + public int Select(Func selector) => 0; + } + + public static void Examples() + { + var w = new WaveFive(); + + w.M(w); + + QueryExpression(); + QueryExpressionNoWarn(); + + } + + private static void QueryExpression() + { + // + bool b = true; + var source = new Src(); + b = true; + source = new Src(); + var a = b && from c in source select c; + Console.WriteLine(a); + + var indexes = new Src2(); + int[] array = { 1, 2, 3, 4, 5, 6, 7 }; + var range = array[0..from c in indexes select c]; + // + } + + private static void QueryExpressionNoWarn() + { + // + bool b = true; + var source = new Src(); + b = true; + source = new Src(); + var a = b && (from c in source select c); + Console.WriteLine(a); + + var indexes = new Src2(); + int[] array = { 1, 2, 3, 4, 5, 6, 7 }; + var range = array[0..(from c in indexes select c)]; + // + } + // + static class StaticClass + { + public static void Thing() { } + } + + void M(object o) + { + // warning: cannot use a static type in 'is' or 'as' + if (o is StaticClass) + { + Console.WriteLine("Can't happen"); + } + else + { + Console.WriteLine("o is not an instance of a static class"); + } + } + // + + // + class Program + { + public static void M(S s) + { + if (s == null) { } // CS8073: The result of the expression is always 'false' + if (s != null) { } // CS8073: The result of the expression is always 'true' + } + } + + struct S + { + public static bool operator ==(S s1, S s2) => s1.Equals(s2); + public static bool operator !=(S s1, S s2) => !s1.Equals(s2); + public override bool Equals(object? other) + { + // Implementation elided + return false; + } + public override int GetHashCode() => 0; + + // Other details elided... + } + // + + // + public static class Utilities + { + // elided + } + + public interface IUtility + { + // CS8897 + public void SetUtility(Utilities u); + + // CS8898 + public Utilities GetUtility(); + } + // + + + // + public struct DefiniteAssignmentWarnings + { + // CS8880 + public Struct Property { get; } + // CS8881 + private Struct field; + + // CS8882 + public void Method(out Struct s) + { + + } + + public DefiniteAssignmentWarnings(int dummy) + { + // CS8883 + Struct v2 = Property; + // CS8884 + Struct v3 = field; + // CS8885: + DefiniteAssignmentWarnings p2 = this; + } + + public static void Method2(out Struct s1) + { + // CS8886 + var s2 = s1; + s1 = default; + } + + public static void UseLocalStruct() + { + Struct r1; + var r2 = r1; + } + } + // + + + // + public struct DefiniteAssignmentNoWarnings + { + // CS8880 + public Struct Property { get; } = default; + // CS8881 + private Struct field = default; + + // CS8882 + public void Method(out Struct s) + { + s = default; + } + + public DefiniteAssignmentNoWarnings(int dummy) + { + // CS8883 + Struct v2 = Property; + // CS8884 + Struct v3 = field; + // CS8885: + DefiniteAssignmentNoWarnings p2 = this; + } + + public static void Method2(out Struct s1) + { + // CS8886 + s1 = default; + var s2 = s1; + } + + public static void UseLocalStruct() + { + Struct r1 = default; + var r2 = r1; + } + } + // +} diff --git a/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveSeven.cs b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveSeven.cs new file mode 100644 index 0000000000000..fa8f3498e214b --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveSeven.cs @@ -0,0 +1,7 @@ +namespace WarningWaves; + +// +public class lowercasename +{ +} +// diff --git a/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveSix.cs b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveSix.cs new file mode 100644 index 0000000000000..5c800289b479b --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/snippets/WarningWaves/WaveSix.cs @@ -0,0 +1,44 @@ +namespace WarningWaves; +public class WaveSix +{ + // + public partial class PartialType + { + public partial void M1(int x); + + public partial T M2(string s) where T : struct; + + public partial void M3(string s); + + + public partial void M4(object o); + public partial void M5(dynamic o); + public partial void M6(string? s); + } + // + + // + public partial class PartialType + { + // Different parameter names: + public partial void M1(int y) { } + + // Different type parameter names: + public partial TResult M2(string s) where TResult : struct => default; + + // Relaxed nullability + public partial void M3(string? s) { } + + + // Mixing object and dynamic + public partial void M4(dynamic o) { } + + // Mixing object and dynamic + public partial void M5(object o) { } + + // Note: This generates CS8611 (nullability mismatch) not CS8826 + public partial void M6(string s) { } + } + // + +} diff --git a/docs/csharp/language-reference/compiler-messages/toc.yml b/docs/csharp/language-reference/compiler-messages/toc.yml index 5e020b10f08da..7ca0c7f577b82 100644 --- a/docs/csharp/language-reference/compiler-messages/toc.yml +++ b/docs/csharp/language-reference/compiler-messages/toc.yml @@ -1879,7 +1879,6 @@ items: href: cs1610.md - name: CS1712 href: ../../misc/cs1712.md -- name: Level 5 warning messages - items: - - name: CS8892 - href: cs8892.md +- name: Warning waves + href: warning-waves.md + displayName: CS7023,CS8073,CS8848,CS8880,CS8881,CS8882,CS8883,CS8884,CS8885,CS8886,CS8887,CS8892,CS8897,CS8898,CS8826,CS8981 diff --git a/docs/csharp/language-reference/compiler-messages/warning-waves.md b/docs/csharp/language-reference/compiler-messages/warning-waves.md new file mode 100644 index 0000000000000..7296949914f91 --- /dev/null +++ b/docs/csharp/language-reference/compiler-messages/warning-waves.md @@ -0,0 +1,165 @@ +--- +title: "C# Compiler warning waves" +description: "C# warning waves are optional warnings that can be reported on code where previously a warning wouldn't have been reported. They represent practices that could be harmful, or potentially elements that may be breaking changes in the future." +ms.date: 05/11/2022 +f1_keywords: + - "CS7023" + - "CS8073" + - "CS8848" + - "CS8880" + - "CS8881" + - "CS8882" + - "CS8883" + - "CS8884" + - "CS8885" + - "CS8886" + - "CS8887" + - "CS8892" + - "CS8897" + - "CS8898" + - "CS8826" + - "CS8981" +helpviewer_keywords: + - "CS7023" + - "CS8073" + - "CS8848" + - "CS8880" + - "CS8881" + - "CS8882" + - "CS8883" + - "CS8884" + - "CS8885" + - "CS8886" + - "CS8887" + - "CS8892" + - "CS8897" + - "CS8898" + - "CS8826" + - "CS8981" +--- +# C# Warning waves + +New warnings and errors may be introduced in each release of the C# compiler. When new warnings could be reported on existing code, those warnings are introduced under an opt-in system referred to as a *warning wave*. The opt-in system means that you shouldn't see new warnings on existing code without taking action to enable them. Warning waves are enabled using the [**AnalysisLevel**](../compiler-options/errors-warnings.md#analysis-level) element in your project file. When `true` is specified, enabled warning wave warnings generate errors. Warning wave 5 diagnostics were added in C# 9. Warning wave 6 diagnostics were added in C# 10. Warning wave 7 diagnostics were added in C# 11. + +## CS8981 - The type name only contains lower-cased ascii characters. + +*Warning wave 7* + +Any new keywords added for C# will be all lower-case ASCII characters. This warning ensures that none of your types conflict with future keywords. The following code produces CS8981: + +:::code language="csharp" source="./snippets/WarningWaves/WaveSeven.cs" id="NoLowercaseTypes"::: + +You can address this warning by renaming the type to include at least one non-lower case ASCII character, such as an upper case character, a digit, or an underscore. + +## CS8826 - Partial method declarations have signature differences. + +*Warning wave 6* + +This warning corrects some inconsistencies in reporting differences between partial method signatures. The compiler always reported an error when the partial method signatures created different CLR signatures. Now, the compiler reports CS8826 when the signatures are syntactically different C#. Consider the following partial class: + +:::code language="csharp" source="./snippets/WarningWaves/WaveSix.cs" id="PartialMethodDeclaration"::: + +The following partial class implementation generates several examples of CS8626: + +:::code language="csharp" source="./snippets/WarningWaves/WaveSix.cs" id="PartialMethodDefinition"::: + +> [!NOTE] +> If the implementation of a method uses a non-nullable reference type when the other declaration accepts nullable reference types, CS8611 is generated instead of CS8826. + +To fix any instance of these warnings, ensure the two signatures match. + +## CS7023 - A static type is used in an 'is' or 'as' expression. + +*Warning wave 5* + +The `is` and `as` expressions always return `false` for a static type because you can't create instances of a static type. The following code produces CS7023: + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="StaticTypeAsIs"::: + +The compiler reports this warning because the type test can never succeed. To correct this warning, remove the test and remove any code executed only if the test succeeded. In the preceding example, the `else` clause is always executed. The method body could be replaced by that single line: + +```csharp +Console.WriteLine("o is not an instance of a static class"); +``` + +## CS8073 - The result of the expression is always 'false' (or 'true'). + +*Warning wave 5* + +The `==` and `!=` operators always return `false` (or `true`) when comparing an instance of a `struct` type to `null`. The following code demonstrates this warning. Assume `S` is a `struct` that has defined `operator ==` and `operator !=`: + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="StructsArentNull"::: + +To fix this error, remove the null check and code that would execute if the object is `null`. + +## CS8848 - Operator 'from' can't be used here due to precedence. Use parentheses to disambiguate. + +*Warning wave 5* + +The following examples demonstrate this warning. The expression binds incorrectly because of the precedence of the operators. + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="QueryPrecedence"::: + +To fix this error, put parentheses around the query expression: + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="QueryPrecedenceNoWarn"::: + +## Members must be fully assigned, use of unassigned variable (CS8880, CS8881, CS8882, CS8883, CS8884, CS8885, CS8886, CS8887) + +*Warning wave 5* + +Several warnings improve the definite assignment analysis for `struct` types declared in imported assemblies. All these new warnings are generated when a struct in an imported assembly includes an inaccessible field (usually a `private` field) of a reference type, as shown in the following example: + +:::code language="csharp" source="snippets/ImportedTypes/Types.cs" id="DeclareImportedType"::: + +The following examples show the warnings generated from the improved definite assignment analysis: + +- CS8880: Auto-implemented property 'Property' must be fully assigned before control is returned to the caller. +- CS8881: Field 'field' must be fully assigned before control is returned to the caller. +- CS8882: The out parameter 'parameter' must be assigned to before control leaves the current method. +- CS8883: Use of possibly unassigned auto-implemented property 'Property'. +- CS8884: Use of possibly unassigned field 'Field' +- CS8885: The 'this' object can't be used before all its fields have been assigned. +- CS8886: Use of unassigned output parameter 'parameterName'. +- CS8887: Use of unassigned local variable 'variableName' + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="DefiniteAssignmentWarnings"::: + +You can fix any of these warnings by initializing or assigning the imported struct to its default value: + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="DefiniteAssignment"::: + +## CS8892 - Method will not be used as an entry point because a synchronous entry point 'method' was found. + +*Warning wave 5* + +This warning is generated on all async entry point candidates when you have multiple valid entry points, including one or more synchronous entry point. Because async main was only supported starting with C# 7.1, this warning isn't generated for projects targeting a previous version. + +The following example generates CS8892: + +:::code language="csharp" source="./snippets/WarningWaves/Program.cs" id="MultipleEntryPoints"::: + +> [!NOTE] +> The compiler always uses the synchronous entry point. In case there are multiple synchronous entry points, you get a compiler error. + +To fix this warning, remove or rename the asynchronous entry point. + +## CS8897 - Static types can't be used as parameters + +*Warning wave 5* + +Members of an interface can't declare parameters whose type is a static class. The following code demonstrates both CS8897 and CS8898: + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="StaticTypeInInterface"::: + +To fix this warning, change the parameter type or remove the method. + +## CS8898 - static types can't be used as return types + +*Warning wave 5* + +Members of an interface can't declare a return type that is a static class. The following code demonstrates both CS8897 and CS8898: + +:::code language="csharp" source="./snippets/WarningWaves/WaveFive.cs" id="StaticTypeInInterface"::: + +To fix this warning, change the return type or remove the method. diff --git a/docs/csharp/language-reference/compiler-options/errors-warnings.md b/docs/csharp/language-reference/compiler-options/errors-warnings.md index 79b945cfd10c5..82cdf53166193 100644 --- a/docs/csharp/language-reference/compiler-options/errors-warnings.md +++ b/docs/csharp/language-reference/compiler-options/errors-warnings.md @@ -1,7 +1,7 @@ --- description: "C# Compiler Options for errors and warnings. These options suppress or enable warnings, and control warnings as errors." title: "C# Compiler Options - errors and warnings" -ms.date: 03/12/2021 +ms.date: 05/11/2022 f1_keywords: - "cs.build.options" helpviewer_keywords: @@ -9,7 +9,7 @@ helpviewer_keywords: - "TreatWarningsAsErrors compiler option [C#]" - "WarningsAsErrors compiler option [C#]" - "WarningsNotAsErrors compiler option [C#]" - - "DisabledWarnings compiler option [C#]" + - "NoWarn compiler option [C#]" - "CodeAnalysisRuleSet compiler option [C#]" - "ErrorLog compiler option [C#]" - "ReportAnalyzer compiler option [C#]" @@ -19,10 +19,11 @@ helpviewer_keywords: The following options control how the compiler reports errors and warnings. The new MSBuild syntax is shown in **Bold**. The older *csc.exe* syntax is shown in `code style`. - **WarningLevel** / `-warn`: Set warning level. +- **AnalysisLevel**: Set optional warning level. - **TreatWarningsAsErrors** / `-warnaserror`: Treat all warnings as errors - **WarningsAsErrors** / `-warnaserror`: Treat one or more warnings as errors - **WarningsNotAsErrors** / `-warnnotaserror`: Treat one or more warnings not as errors -- **DisabledWarnings** / `-nowarn`: Set a list of disabled warnings. +- **NoWarn** / `-nowarn`: Set a list of disabled warnings. - **CodeAnalysisRuleSet** / `-ruleset`: Specify a ruleset file that disables specific diagnostics. - **ErrorLog** / `-errorlog`: Specify a file to log all compiler and analyzer diagnostics. - **ReportAnalyzer** / `-reportanalyzer`: Report additional analyzer information, such as execution time. @@ -37,19 +38,33 @@ The **WarningLevel** option specifies the warning level for the compiler to disp The element value is the warning level you want displayed for the compilation: Lower numbers show only high severity warnings. Higher numbers show more warnings. The value must be zero or a positive integer: -|Warning level|Meaning| -|-------------------|-------------| -|0|Turns off emission of all warning messages.| -|1|Displays severe warning messages.| -|2|Displays level 1 warnings plus certain, less-severe warnings, such as warnings about hiding class members.| -|3|Displays level 2 warnings plus certain, less-severe warnings, such as warnings about expressions that always evaluate to `true` or `false`.| -|4 (the default)|Displays all level 3 warnings plus informational warnings.| -|Greater than 4|Displays warnings with the specified value and all less-severe warnings. For more information, see [additional warnings](https://github.com/dotnet/roslyn/blob/main/docs/compilers/CSharp/Warnversion%20Warning%20Waves.md).| +| Warning level | Meaning | +|---------------|---------| +| 0 | Turns off emission of all warning messages. | +| 1 | Displays severe warning messages. | +| 2 | Displays level 1 warnings plus certain, less-severe warnings, such as warnings about hiding class members. | +| 3 | Displays level 2 warnings plus certain, less-severe warnings, such as warnings about expressions that always evaluate to `true` or `false`. | +| 4 (the default)|Displays all level 3 warnings plus informational warnings. | -> [!NOTE] -> To make sure you always have all warnings if the compiler is updated with new warning levels, put an arbitrary large value (for example, `9999`). +> [!WARNING] +> The compiler command line accepts values greater than 4 to enable [warning wave warnings](../compiler-messages/warning-waves.md). However, the .NET SDK sets the *WarningLevel* to match the *AnalysisLevel* in your project file. -To get information about an error or warning, you can look up the error code in the Help Index. For other ways to get information about an error or warning, see [C# Compiler Errors](../compiler-messages/index.md). Use [**TreatWarningsAsErrors**](#treatwarningsaserrors) to treat all warnings as errors. Use [**DisabledWarnings**](#disabledwarnings) to disable certain warnings. +To get information about an error or warning, you can look up the error code in the [Help Index](/visualstudio/help-viewer/install-manage-local-content). For other ways to get information about an error or warning, see [C# Compiler Errors](../compiler-messages/index.md). Use [**TreatWarningsAsErrors**](#treatwarningsaserrors) to treat all warnings as errors. Use [**DisabledWarnings**](#nowarn) to disable certain warnings. + +## Analysis level + +| Analysis level | Meaning | +|------------------|---------| +| 5 | Displays all optional [warning wave 5 warnings](../compiler-messages/warning-waves.md#cs7023---a-static-type-is-used-in-an-is-or-as-expression). | +| 6 | Displays all optional [warning wave 6 warnings](../compiler-messages/warning-waves.md#cs8826---partial-method-declarations-have-signature-differences). | +| 7 | Displays all optional [warning wave 7 warnings](../compiler-messages/warning-waves.md#cs8981---the-type-name-only-contains-lower-cased-ascii-characters). | +| latest (default) | Displays all informational warnings up to and including the current release. | +| preview | Displays all informational warnings up to and including the latest preview release. | +| none | Turns off all informational warnings. | + +For more information on optional warnings, see [Warning waves](../compiler-messages/warning-waves.md). + +To get information about an error or warning, you can look up the error code in the Help Index. For other ways to get information about an error or warning, see [C# Compiler Errors](../compiler-messages/index.md). Use [**TreatWarningsAsErrors**](#treatwarningsaserrors) to treat all warnings as errors. Use [**NoWarn**](#nowarn) to disable certain warnings. ## TreatWarningsAsErrors @@ -59,37 +74,40 @@ The **TreatWarningsAsErrors** option treats all warnings as errors. You can also true ``` -All warning messages are instead reported as errors. The build process halts (no output files are built). By default, **TreatWarningsAsErrors** isn't in effect, which means warnings don't prevent the generation of an output file. Optionally, if you want only a few specific warnings to be treated as errors, you may specify a comma-separated list of warning numbers to treat as errors. The set of all nullability warnings can be specified with the [**Nullable**](language.md#nullable) shorthand. Use [**WarningLevel**](#warninglevel) to specify the level of warnings that you want the compiler to display. Use [**DisabledWarnings**](#disabledwarnings) to disable certain warnings. +All warning messages are instead reported as errors. The build process halts (no output files are built). By default, **TreatWarningsAsErrors** isn't in effect, which means warnings don't prevent the generation of an output file. Optionally, if you want only a few specific warnings to be treated as errors, you may specify a comma-separated list of warning numbers to treat as errors. The set of all nullability warnings can be specified with the [**Nullable**](language.md#nullable) shorthand. Use [**WarningLevel**](#warninglevel) to specify the level of warnings that you want the compiler to display. Use [**NoWarn**](#nowarn) to disable certain warnings. + +> [!IMPORTANT] +> There are two subtle differences between using the `` element in your *csproj* file, and using the `warnaserror` MSBuild command line switch. *TreatWarningsAsErrors* only impacts the C# compiler, not any other MSBuild tasks in your *csproj* file. The `warnaserror` command line switch impacts all tasks. Secondly, the compiler doesn't produce any output on any warnings when *TreatWarningsAsErrors* is used. The compiler produces output when the `warnaserror` command line switch is used. ## WarningsAsErrors and WarningsNotAsErrors -The **WarningsAsErrors** and **WarningsNotAsErrors** options override the **TreatWarningsAsErrors** option for a list of warnings. +The **WarningsAsErrors** and **WarningsNotAsErrors** options override the **TreatWarningsAsErrors** option for a list of warnings. This option can be used with all *CS* warnings. The "CS" prefix is optional. You can use either the number, or "CS" followed by the error or warning number. For other elements that affect warnings, see the [Common MSBuild properties](/visualstudio/msbuild/common-msbuild-project-properties). Enable warnings 0219 and 0168 as errors: ```xml -0219,0168 +0219,CS0168 ``` Disable the same warnings as errors: ```xml -0219,0168 +0219,CS0168 ``` You use **WarningsAsErrors** to configure a set of warnings as errors. Use **WarningsNotAsErrors** to configure a set of warnings that should not be errors when you've set all warnings as errors. -## DisabledWarnings +## NoWarn -The **DisabledWarnings** option lets you suppress the compiler from displaying one or more warnings. Separate multiple warning numbers with a comma. +The **NoWarn** option lets you suppress the compiler from displaying one or more warnings. Separate multiple warning numbers with a comma. ```xml -number1, number2 +number1, number2 ``` -`number1`, `number2` Warning number(s) that you want the compiler to suppress. You specify the numeric part of the warning identifier. For example, if you want to suppress *CS0028*, you could specify `28`. The compiler silently ignores warning numbers passed to **DisabledWarnings** that were valid in previous releases, but that have been removed. For example, *CS0679* was valid in the compiler in Visual Studio .NET 2002 but was removed later. +`number1`, `number2` Warning number(s) that you want the compiler to suppress. You specify the numeric part of the warning identifier. For example, if you want to suppress *CS0028*, you could specify `28`. The compiler silently ignores warning numbers passed to **NoWarn** that were valid in previous releases, but that have been removed. For example, *CS0679* was valid in the compiler in Visual Studio .NET 2002 but was removed later. - The following warnings cannot be suppressed by the **DisabledWarnings** option: + The following warnings cannot be suppressed by the **NoWarn** option: - Compiler Warning (level 1) CS2002 - Compiler Warning (level 1) CS2023 @@ -115,6 +133,14 @@ Specify a file to log all compiler and analyzer diagnostics. The **ErrorLog** option causes the compiler to output a [Static Analysis Results Interchange Format (SARIF) log](https://github.com/microsoft/sarif-tutorials/blob/main/docs/1-Introduction.md#:~:text=What%20is%20SARIF%3F,for%20use%20by%20simpler%20tools). SARIF logs are typically read by tools that analyze the results from compiler and analyzer diagnostics. +You can specify the SARIF format using the `version` argument to the `ErrorLog` element: + +```XML +logVersion21.json,version=2.1 +``` + +The separator can be either a comma (`,`) or a semicolon (`;`). Valid values for version are: "1", "2", and "2.1". The default is "1". "2" and "2.1" both mean SARIF version 2.1.0. + ## ReportAnalyzer Report additional analyzer information, such as execution time. @@ -124,3 +150,6 @@ Report additional analyzer information, such as execution time. ``` The **ReportAnalyzer** option causes the compiler to emit extra MSBuild log information that details the performance characteristics of analyzers in the build. It's typically used by analyzer authors as part of validating the analyzer. + +> [!IMPORTANT] +> The extra log information generated by this flag is only generated when the `-verbosity:detailed` command line option is used. See the [switches](/visualstudio/msbuild/msbuild-command-line-reference#switches) article in the MSBuild documentation for more information. diff --git a/docs/csharp/language-reference/compiler-options/language.md b/docs/csharp/language-reference/compiler-options/language.md index 830626add8615..7631ee5600466 100644 --- a/docs/csharp/language-reference/compiler-options/language.md +++ b/docs/csharp/language-reference/compiler-options/language.md @@ -72,7 +72,7 @@ Metadata referenced by your C# application isn't subject to the **LangVersion** Because each version of the C# compiler contains extensions to the language specification, **LangVersion** doesn't give you the equivalent functionality of an earlier version of the compiler. -Additionally, while C# version updates generally coincide with major .NET Framework releases, the new syntax and features aren't necessarily tied to that specific framework version. While the new features definitely require a new compiler update that is also released alongside the C# revision, each specific feature has its own minimum .NET API or common language runtime requirements that may allow it to run on downlevel frameworks by including NuGet packages or other libraries. +Additionally, while C# version updates generally coincide with major .NET releases, the new syntax and features aren't necessarily tied to that specific framework version. While the new features definitely require a new compiler update that is also released alongside the C# revision, each specific feature has its own minimum .NET API or common language runtime requirements that may allow it to run on downlevel frameworks by including NuGet packages or other libraries. Regardless of which **LangVersion** setting you use, use the current version of the common language runtime to create your .exe or .dll. One exception is friend assemblies and [**ModuleAssemblyName**](advanced.md#moduleassemblyname), which work under **-langversion:ISO-1**. diff --git a/docs/csharp/language-reference/configure-language-version.md b/docs/csharp/language-reference/configure-language-version.md index 489b08d9568c2..2545eebdbe6b4 100644 --- a/docs/csharp/language-reference/configure-language-version.md +++ b/docs/csharp/language-reference/configure-language-version.md @@ -9,7 +9,7 @@ ms.date: 02/25/2022 The latest C# compiler determines a default language version based on your project's target framework or frameworks. Visual Studio doesn't provide a UI to change the value, but you can change it by editing the *csproj* file. The choice of default ensures that you use the latest language version compatible with your target framework. You benefit from access to the latest language features compatible with your project's target. This default choice also ensures you don't use a language that requires types or runtime behavior not available in your target framework. Choosing a language version newer than the default can cause hard to diagnose compile-time and runtime errors. -[C# 10](../whats-new/csharp-10.md) is supported only on .NET 6 and newer versions. [C# 9](../whats-new/csharp-9.md) is supported only on .NET 5 and newer versions. [C# 8.0](../whats-new/csharp-8.md) is supported only on .NET Core 3.x and newer versions. +[C# 11](../whats-new/csharp-11.md) is supported only on .NET 7 and newer versions. [C# 10](../whats-new/csharp-10.md) is supported only on .NET 6 and newer versions. [C# 9](../whats-new/csharp-9.md) is supported only on .NET 5 and newer versions. [C# 8.0](../whats-new/csharp-8.md) is supported only on .NET Core 3.x and newer versions. Check the [Visual Studio platform compatibility](/visualstudio/releases/2022/compatibility#-visual-studio-2022-support-for-net-development) page for details on which .NET versions are supported by versions of Visual Studio. Check the [Visual Studio for Mac platform compatibility](/visualstudio/mac/supported-versions-net) page for details on which .NET versions are supported by versions of Visual Studio for Mac. Check the [Mono page for C#](https://www.mono-project.com/docs/about-mono/languages/csharp/) for Mono compatibility with C# versions. @@ -19,7 +19,8 @@ The compiler determines a default based on these rules: | Target framework | version | C# language version default | |------------------|---------|-----------------------------| -| .NET | 6.x | C# 10 | +| .NET | 7.x | C# 11 | +| .NET | 6.x | C# 10 | | .NET | 5.x | C# 9.0 | | .NET Core | 3.x | C# 8.0 | | .NET Core | 2.x | C# 7.3 | diff --git a/docs/csharp/language-reference/keywords/checked-and-unchecked.md b/docs/csharp/language-reference/keywords/checked-and-unchecked.md index 08418f0fe4ec8..07ca733477bb3 100644 --- a/docs/csharp/language-reference/keywords/checked-and-unchecked.md +++ b/docs/csharp/language-reference/keywords/checked-and-unchecked.md @@ -1,7 +1,7 @@ --- description: "Checked and Unchecked - C# Reference" title: "Checked and Unchecked - C# Reference" -ms.date: 05/15/2018 +ms.date: 04/26/2022 helpviewer_keywords: - "operators [C#], checked and unchecked" - "exceptions [C#], overflow checking" @@ -9,28 +9,30 @@ helpviewer_keywords: - "overflow checking [C#]" - "unchecked statement [C#]" - "statements [C#], checked and unchecked" -ms.assetid: a84bc877-2c7f-4396-8735-1ce97c42f35e --- -# Checked and Unchecked (C# Reference) +# Checked and unchecked (C# Reference) -C# statements can execute in either checked or unchecked context. In a checked context, arithmetic overflow raises an exception. In an unchecked context, arithmetic overflow is ignored and the result is truncated by discarding any high-order bits that don't fit in the destination type. - -- [checked](checked.md) Specify checked context. - -- [unchecked](unchecked.md) Specify unchecked context. - - The following operations are affected by the overflow checking: - -- Expressions using the following predefined operators on integral types: - - `++`, `--`, unary `-`, `+`, `-`, `*`, `/` - -- Explicit numeric conversions between integral types, or from `float` or `double` to an integral type. - - If neither `checked` nor `unchecked` is specified, the default context for non-constant expressions (expressions that are evaluated at run time) is defined by the value of the [**CheckForOverflowUnderflow**](../compiler-options/language.md#checkforoverflowunderflow) compiler option. By default the value of that option is unset and arithmetic operations are executed in an unchecked context. +C# statements can execute in either checked or unchecked context. In a checked context, arithmetic overflow raises an exception. In an unchecked context, arithmetic overflow is ignored and the result is truncated by discarding any high-order bits that don't fit in the destination type. + +:::code language="csharp" interactive="try-dotnet-method" source="./snippets/CheckedUnchecked.cs" id="CheckedAndUnchecked"::: - For constant expressions (expressions that can be fully evaluated at compile time), the default context is always checked. Unless a constant expression is explicitly placed in an unchecked context, overflows that occur during the compile-time evaluation of the expression cause compile-time errors. +In checked mode, any constant expression that overflows or underflows generates a compiler error. Any expression that overflows at runtime throws an . In unchecked mode, it wraps from the maximum value to the minimum value. +- [checked](checked.md) Specify checked context. +- [unchecked](unchecked.md) Specify unchecked context. + +The following operations are affected by the overflow checking: + +- Expressions using the following predefined operators on integral types: + + `++`, `--`, unary `-`, `+`, `-`, `*`, `/` + +- Explicit numeric conversions between integral types, or from `float` or `double` to an integral type. + +If neither `checked` nor `unchecked` is specified, the default context for non-constant expressions (expressions that are evaluated at run time) is defined by the value of the [**CheckForOverflowUnderflow**](../compiler-options/language.md#checkforoverflowunderflow) compiler option. By default the value of that option is unset and arithmetic operations are executed in an unchecked context. + +For constant expressions (expressions that can be fully evaluated at compile time), the default context is always checked. Unless a constant expression is explicitly placed in an unchecked context, overflows that occur during the compile-time evaluation of the expression cause compile-time errors. + ## See also - [C# Reference](../index.md) diff --git a/docs/csharp/language-reference/keywords/event.md b/docs/csharp/language-reference/keywords/event.md index fa88382a5e99b..2d9f6800a1566 100644 --- a/docs/csharp/language-reference/keywords/event.md +++ b/docs/csharp/language-reference/keywords/event.md @@ -21,7 +21,7 @@ The following example shows how to declare and raise an event that uses + Console.WriteLine(int.MaxValue); // 2147483647 + Console.WriteLine($"0x{int.MaxValue:X}"); // 0x7FFFFFFF + + Console.WriteLine(unchecked (int.MaxValue+1)); // -2147483648 + Console.WriteLine($"0x{unchecked (int.MaxValue+1):X}"); // 0x80000000 + Console.WriteLine(int.MinValue); // -2147483648 + Console.WriteLine($"0x{int.MinValue:X}"); // 0x80000000 + + // Create overflow using compile-time constants: + // CS0220: The operation overflows at compile time in checked mode + // Console.WriteLine(checked (int.MaxValue+1)); + + try { + checked + { + var number = 1 + int.MaxValue / 2; + number += number; + } + } catch (OverflowException e) + { + Console.WriteLine("This operation overflows at runtime in checked mode."); + } + // + + } +} \ No newline at end of file diff --git a/docs/csharp/language-reference/keywords/snippets/Program.cs b/docs/csharp/language-reference/keywords/snippets/Program.cs index 9d82384fa6bd8..1ae8d2a150bb4 100644 --- a/docs/csharp/language-reference/keywords/snippets/Program.cs +++ b/docs/csharp/language-reference/keywords/snippets/Program.cs @@ -17,6 +17,8 @@ static async Task Main(string[] args) UsingStatements.Examples(); Console.WriteLine("================= try-catch Keyword Examples ======================"); await AsyncExceptionExamples.Examples(); + Console.WriteLine("================= try-catch Keyword Examples ======================"); + CheckedAndUnchecked.Examples(); } } } diff --git a/docs/csharp/language-reference/operators/delegate-operator.md b/docs/csharp/language-reference/operators/delegate-operator.md index 8148fba0ad196..dbb850267b032 100644 --- a/docs/csharp/language-reference/operators/delegate-operator.md +++ b/docs/csharp/language-reference/operators/delegate-operator.md @@ -54,7 +54,7 @@ Action a = StaticFunction; Before C# 11, you'd need to use a lambda expression to reuse a single delegate object: ```csharp -Action a = () = StaticFunction; +Action a = () => StaticFunction(); ``` ## C# language specification diff --git a/docs/csharp/language-reference/operators/index.md b/docs/csharp/language-reference/operators/index.md index 7417e2ce678e4..6fd7a02a4c6d9 100644 --- a/docs/csharp/language-reference/operators/index.md +++ b/docs/csharp/language-reference/operators/index.md @@ -94,7 +94,7 @@ The following table lists the C# operators starting with the highest precedence When operators have the same precedence, associativity of the operators determines the order in which the operations are performed: - *Left-associative* operators are evaluated in order from left to right. Except for the [assignment operators](assignment-operator.md) and the [null-coalescing operators](null-coalescing-operator.md), all binary operators are left-associative. For example, `a + b - c` is evaluated as `(a + b) - c`. -- *Right-associative* operators are evaluated in order from right to left. The assignment operators, the null-coalescing operators, and the [conditional operator `?:`](conditional-operator.md) are right-associative. For example, `x = y = z` is evaluated as `x = (y = z)`. +- *Right-associative* operators are evaluated in order from right to left. The assignment operators, the null-coalescing operators, lambdas, and the [conditional operator `?:`](conditional-operator.md) are right-associative. For example, `x = y = z` is evaluated as `x = (y = z)`. Use parentheses to change the order of evaluation imposed by operator associativity: diff --git a/docs/csharp/language-reference/operators/is.md b/docs/csharp/language-reference/operators/is.md index 099205d714f49..6f874c4d417dc 100644 --- a/docs/csharp/language-reference/operators/is.md +++ b/docs/csharp/language-reference/operators/is.md @@ -37,6 +37,10 @@ The `is` operator can be useful in the following scenarios: :::code language="csharp" source="snippets/shared/IsOperator.cs" id="NonNullCheck"::: +- Beginning with C# 11, you can use [list patterns](patterns.md#list-patterns) to match elements of a list or array. The following code checks arrays for integer values in expected positions: + + :::code language="csharp" source="snippets/shared/IsOperator.cs" id="ListPatterns"::: + > [!NOTE] > For the complete list of patterns supported by the `is` operator, see [Patterns](patterns.md). diff --git a/docs/csharp/language-reference/operators/null-forgiving.md b/docs/csharp/language-reference/operators/null-forgiving.md index f302542da01a7..e38ee70e89e8c 100644 --- a/docs/csharp/language-reference/operators/null-forgiving.md +++ b/docs/csharp/language-reference/operators/null-forgiving.md @@ -49,4 +49,3 @@ For more information, see [The null-forgiving operator](~/_csharplang/proposals/ - [C# reference](../index.md) - [C# operators and expressions](index.md) - [Tutorial: Design with nullable reference types](../../whats-new/tutorials/nullable-reference-types.md) -- [Simplified parameter null check](null-parameter-check.md) diff --git a/docs/csharp/language-reference/operators/null-parameter-check.md b/docs/csharp/language-reference/operators/null-parameter-check.md deleted file mode 100644 index 60b32958482a4..0000000000000 --- a/docs/csharp/language-reference/operators/null-parameter-check.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -title: "!! (null validation) operator - C# reference" -description: "Learn about simplified null-parameter checks. This operator instructs the compiler to add runtime checks that the argument used for a parameter isn't null." -ms.date: 03/30/2022 -f1_keywords: - - "!!_CSharpKeyword" -helpviewer_keywords: - - "null validation operator [C#]" - - "!! operator [C#]" ---- -# !! (null validation) operator (C# reference) - -The `!!` operator, introduced in C# 11, provides null validation parameter syntax. Adding `!!` to the parameter name in the declaration instructs the compiler to add a runtime check for that parameter. For example: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="BangBangExample"::: - -generates code similar to the following example: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="HandCodedExample"::: - -Multiple annotated parameters are checked in the order declared on the method. For example, the following code: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="MultipleParameters"::: - -generates code similar to the following example: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="HandCodedMultipleParms"::: - -It's intended for library authors to provide runtime checks. You should only add the `!!` operator on those parameters that require a null-check for safety. In the preceding example, the `message` parameter doesn't have a runtime null check. - -## Where `!!` can be applied - -There are a few rules that govern where you can add the `!!` operator on a parameter declaration: - -- The `!!` operator directs the compiler to add runtime behavior. It can't be applied to a declaration without an implementation. You can't add `!!` to the parameter of an abstract member, an interface method without an implementation, or a parameter on a delegate type declaration. -- The parameter type must be a type that can be compared to `null`. For example, the parameter can't be a non-nullable value type. If the parameter is a type parameter, it can't be constrained to be a non-nullable type (for example the `struct`, `notnull`, and `unmanaged` constraints are disallowed.) - -The following example demonstrates the preceding rules: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="NoAbstractMethods"::: - -## Constructors and !! - -In almost all cases, the code the compiler generates for `!!` on an argument is consistent with the preceding example. However, the null check is inserted before any code you write in the method. There are observable differences between a hand-coded null check and adding `!!` on the parameter of a constructor. When you hand-write the null check in the body of a constructor, that null check runs after any field initializers, constructor chains, and base class constructors are called. Consider the following code: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="HandCodedConstruction"::: - -If you call `new D1(null!)`, you'll see the following output: - -```dotnetcli -Creating identity string -In B constructor -Parameterless D constructor -``` - -The field initializer runs, the base constructor runs, and the chained constructor runs. All of them run before the check. Change the constructor to use the simplified null check operator, `!!` and none of the output will be printed: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="SimplifiedConstructorCheck"::: - -The compiler synthesizes the null check before the synthesized code that runs the field initializers and calls the chained and base constructors. - -## iterator methods and !! - -Iterator methods behave different when the `!!` operator provides the null check. Consider the following iterator method: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="IteratorMethod"::: - -When you call that method passing in a null argument as shows in the following example: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="Enumerate"::: - -The message ":::no-loc text="Enumerate values":::" is displayed before the exception is thrown. That's because the null check doesn't run until the first element in the sequence is requested. Instead, if you use the `!!` operator, the exception is thrown when `CharsIn` is called, not when the first element of the sequence is requested. - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="IteratorMethodSimplified"::: - -## async methods and !! - -Async methods and async iterators also change the source of the exception. Consider the following method with a hand written null check: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="AsyncMethod"::: - -If you call that method using `null` as the argument, the return value is a `Task` in the state. The exception will be thrown when the `Task` is awaited. If you switch to a simplified null check, the exception is thrown when `SumCharsIn` is called, not when the returned task is awaited. - -Finally, the same behavior occurs for an async enumerator method. In the following code, the null check runs when the first element is retrieved using `await foreach`: - -:::code language="csharp" source="./snippets/shared/NullParameterCheck.cs" id="AsyncIteratorMethod"::: - -If you replace the hand-written null check with a `!!`, the exception is thrown as soon as `CharsInAsync` is called, even if the sequence isn't enumerated yet. - -## Null parameter checks and nullable types - -With null state analysis, any parameter annotated with `!!` has an initial null state of *not null*. The compiler has already added a null check. The compiler generates a warning when you write a method where a parameter is nullable and you've added a null check. Consider the following example: - -```csharp -void Method(string? name!!) -{ - // ... -} -``` - -The compiler issues the warning *"Nullable type 'string?' is null-checked and will throw if null."* The signature indicates that the method should accept `null` as the argument for `name`, and yet throws when that argument is supplied. - -The `!!` operator instructs the compiler to add runtime null checks on a parameter. This complements the compile time annotations provided by nullable reference types. It can provide more resilience in your code. diff --git a/docs/csharp/language-reference/operators/patterns.md b/docs/csharp/language-reference/operators/patterns.md index a43381775dbb3..d111fc00b759b 100644 --- a/docs/csharp/language-reference/operators/patterns.md +++ b/docs/csharp/language-reference/operators/patterns.md @@ -1,7 +1,7 @@ --- title: "Patterns - C# reference" description: "Learn about the patterns supported by C# pattern matching expressions and statements." -ms.date: 08/23/2021 +ms.date: 06/02/2022 f1_keywords: - "and_CSharpKeyword" - "or_CSharpKeyword" @@ -70,6 +70,10 @@ Beginning with C# 9.0, for that purpose you can use a *type pattern*, as the fol Like a declaration pattern, a type pattern matches an expression when an expression result is non-null and its run-time type satisfies any of the conditions listed above. +You can also use this pattern for a clear, concise `null` check: + +:::code language="csharp" source="snippets/patterns/DeclarationAndTypePatterns.cs" id="NotNull"::: + For more information, see the [Declaration pattern](~/_csharplang/proposals/csharp-8.0/patterns.md#declaration-pattern) and [Type pattern](~/_csharplang/proposals/csharp-9.0/patterns3.md#type-patterns) sections of the feature proposal notes. ## Constant pattern @@ -81,12 +85,15 @@ Beginning with C# 7.0, you use a *constant pattern* to test if an expression res In a constant pattern, you can use any constant expression, such as: - an [integer](../builtin-types/integral-numeric-types.md) or [floating-point](../builtin-types/floating-point-numeric-types.md) numerical literal -- a [char](../builtin-types/char.md) or a [string](../builtin-types/reference-types.md#the-string-type) literal +- a [char](../builtin-types/char.md) +- a [string](../builtin-types/reference-types.md#the-string-type) literal. - a Boolean value `true` or `false` - an [enum](../builtin-types/enum.md) value - the name of a declared [const](../keywords/const.md) field or local - `null` +The expression must be a type that is convertible to the constant type, with one exception: An expression whose type is `Span` or `ReadOnlySpan` can be matched against constant strings in C# 11 and later versions. + Use a constant pattern to check for `null`, as the following example shows: :::code language="csharp" source="snippets/patterns/ConstantPattern.cs" id="NullCheck"::: @@ -127,7 +134,7 @@ Beginning with C# 9.0, you use the `not`, `and`, and `or` pattern combinators to :::code language="csharp" source="snippets/patterns/LogicalPatterns.cs" id="AndPattern"::: -- *Disjunctive* `or` pattern that matches an expression when either of patterns matches the expression, as the following example shows: +- *Disjunctive* `or` pattern that matches an expression when either pattern matches the expression, as the following example shows: :::code language="csharp" source="snippets/patterns/LogicalPatterns.cs" id="OrPattern"::: @@ -234,7 +241,7 @@ Beginning with C# 8.0, you use a *discard pattern* `_` to match any expression, In the preceding example, a discard pattern is used to handle `null` and any integer value that doesn't have the corresponding member of the enumeration. That guarantees that a `switch` expression in the example handles all possible input values. If you don't use a discard pattern in a `switch` expression and none of the expression's patterns matches an input, the runtime [throws an exception](switch-expression.md#non-exhaustive-switch-expressions). The compiler generates a warning if a `switch` expression doesn't handle all possible input values. -A discard pattern cannot be a pattern in an `is` expression or a `switch` statement. In those cases, to match any expression, use a [`var` pattern](#var-pattern) with a discard: `var _`. +A discard pattern can't be a pattern in an `is` expression or a `switch` statement. In those cases, to match any expression, use a [`var` pattern](#var-pattern) with a discard: `var _`. For more information, see the [Discard pattern](~/_csharplang/proposals/csharp-8.0/patterns.md#discard-pattern) section of the feature proposal note. @@ -244,6 +251,58 @@ Beginning with C# 9.0, you can put parentheses around any pattern. Typically, yo :::code language="csharp" source="snippets/patterns/LogicalPatterns.cs" id="ChangedPrecedence"::: +## List patterns + +Beginning with C# 11, you can match an array or a list to a *sequence* of patterns that match elements. You can apply any of the following patterns: + +- Any pattern can be applied to any element to check that an individual element matches certain characteristics. +- The discard pattern (`_`) matches a single element. +- The *range pattern* (`..`) can match zero or more elements in the sequence. At most one range pattern is allowed in a list pattern. +- The `var` pattern can capture a single element, or a range of elements. + +These rules are demonstrated using the following array declarations: + +:::code language="csharp" source="./snippets/patterns/ListPattern.cs" id="DeclareArrays"::: + +You can match the entire sequence by specifying all the elements and using values: + +:::code language="csharp" source="./snippets/patterns/ListPattern.cs" id="MatchEntireArray"::: + +You can match some elements in a sequence of a known length using the discard pattern (`_`) as a placeholder: + +:::code language="csharp" source="./snippets/patterns/ListPattern.cs" id="MatchElements"::: + +You can supply any number of values or placeholders anywhere in the sequence. If you aren't concerned with the length, you can use the *range* pattern to match zero or more elements: + +:::code language="csharp" source="./snippets/patterns/ListPattern.cs" id="MatchRange"::: + +The previous examples used the *constant pattern* to determine if an element is a given number. Any of those patterns could be replaced by a different pattern, such as a relational pattern: + +:::code language="csharp" source="./snippets/patterns/ListPattern.cs" id="RelationalMatch"::: + +List patterns are a valuable tool when data doesn't follow a regular structure. You can use pattern matching to test the shape and values of the data instead of transforming it into a set of objects. + +Consider the following excerpt from a text file containing bank transactions: + +```output +04-01-2020, DEPOSIT, Initial deposit, 2250.00 +04-15-2020, DEPOSIT, Refund, 125.65 +04-18-2020, DEPOSIT, Paycheck, 825.65 +04-22-2020, WITHDRAWAL, Debit, Groceries, 255.73 +05-01-2020, WITHDRAWAL, #1102, Rent, apt, 2100.00 +05-02-2020, INTEREST, 0.65 +05-07-2020, WITHDRAWAL, Debit, Movies, 12.57 +04-15-2020, FEE, 5.55 +``` + +It's a CSV format, but some of the rows have more columns than others. Even worse for processing, one column in the `WITHDRAWAL` type has user-generated text and can contain a comma in the text. A *list pattern* that includes the *discard* pattern, *constant* pattern and *var* pattern to capture the value processes data in this format: + +:::code language="csharp" source="./snippets/patterns/ListPattern.cs" id="DataRecordExample"::: + +The preceding example takes a string array, where each element is one field in the row. The switch expression keys on the second field, which determines the kind of transaction, and the number of remaining columns. Each row ensures the data is in the correct format. The discard pattern (`_`) skips the first field, with the date of the transaction. The second field matches the type of transaction. Remaining element matches skip to the field with the amount. The final match uses the *var* pattern to capture the string representation of the amount. The expression calculates the amount to add or subtract from the balance. + +*List patterns* enable you to match on the shape of a sequence of data elements. You use the *discard* and *range* patterns to match the location of elements. You use other patterns to match characteristics about individual elements. + ## C# language specification For more information, see the following feature proposal notes: diff --git a/docs/csharp/language-reference/operators/snippets/patterns/ConstantPattern.cs b/docs/csharp/language-reference/operators/snippets/patterns/ConstantPattern.cs index 22895fd4a4d9d..0fd857a43a5df 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/ConstantPattern.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/ConstantPattern.cs @@ -1,44 +1,41 @@ -using System; +namespace Patterns; -namespace Patterns +public static class ConstantPattern { - public static class ConstantPattern + public static void Examples() { - public static void Examples() - { - Console.WriteLine(GetGroupTicketPrice(2)); - } + Console.WriteLine(GetGroupTicketPrice(2)); + } - // - public static decimal GetGroupTicketPrice(int visitorCount) => visitorCount switch - { - 1 => 12.0m, - 2 => 20.0m, - 3 => 27.0m, - 4 => 32.0m, - 0 => 0.0m, - _ => throw new ArgumentException($"Not supported number of visitors: {visitorCount}", nameof(visitorCount)), - }; - // + // + public static decimal GetGroupTicketPrice(int visitorCount) => visitorCount switch + { + 1 => 12.0m, + 2 => 20.0m, + 3 => 27.0m, + 4 => 32.0m, + 0 => 0.0m, + _ => throw new ArgumentException($"Not supported number of visitors: {visitorCount}", nameof(visitorCount)), + }; + // - private static void NullCheck(object input) + private static void NullCheck(object input) + { + // + if (input is null) { - // - if (input is null) - { - return; - } - // + return; } + // + } - private static void NonNullCheck(object input) + private static void NonNullCheck(object input) + { + // + if (input is not null) { - // - if (input is not null) - { - // ... - } - // + // ... } + // } -} \ No newline at end of file +} diff --git a/docs/csharp/language-reference/operators/snippets/patterns/DeclarationAndTypePatterns.cs b/docs/csharp/language-reference/operators/snippets/patterns/DeclarationAndTypePatterns.cs index c9bb61622206c..cf4a31df4038d 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/DeclarationAndTypePatterns.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/DeclarationAndTypePatterns.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace Patterns +namespace Patterns { public static class DeclarationAndTypePatterns { @@ -10,8 +7,22 @@ public static void Examples() BasicExample(); ReferenceConversion(); NullableAndUnboxing(); + NotNullPattern(); } + private static void NotNullPattern() + { + object input = default; + // + if (input is not null) + { + Console.WriteLine(input); + } else + { + throw new ArgumentNullException(paramName: nameof(input), message: "Input should not be null"); + } + // + } private static void BasicExample() { // diff --git a/docs/csharp/language-reference/operators/snippets/patterns/DiscardPattern.cs b/docs/csharp/language-reference/operators/snippets/patterns/DiscardPattern.cs index 7499cc08f10d1..be4d989e74adc 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/DiscardPattern.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/DiscardPattern.cs @@ -1,33 +1,30 @@ -using System; +namespace Patterns; -namespace Patterns +public static class DiscardPattern { - public static class DiscardPattern + public static void Examples() { - public static void Examples() - { - BasicExample(); - } + BasicExample(); + } - private static void BasicExample() - { - // - Console.WriteLine(GetDiscountInPercent(DayOfWeek.Friday)); // output: 5.0 - Console.WriteLine(GetDiscountInPercent(null)); // output: 0.0 - Console.WriteLine(GetDiscountInPercent((DayOfWeek)10)); // output: 0.0 + private static void BasicExample() + { + // + Console.WriteLine(GetDiscountInPercent(DayOfWeek.Friday)); // output: 5.0 + Console.WriteLine(GetDiscountInPercent(null)); // output: 0.0 + Console.WriteLine(GetDiscountInPercent((DayOfWeek)10)); // output: 0.0 - static decimal GetDiscountInPercent(DayOfWeek? dayOfWeek) => dayOfWeek switch - { - DayOfWeek.Monday => 0.5m, - DayOfWeek.Tuesday => 12.5m, - DayOfWeek.Wednesday => 7.5m, - DayOfWeek.Thursday => 12.5m, - DayOfWeek.Friday => 5.0m, - DayOfWeek.Saturday => 2.5m, - DayOfWeek.Sunday => 2.0m, - _ => 0.0m, - }; - // - } + static decimal GetDiscountInPercent(DayOfWeek? dayOfWeek) => dayOfWeek switch + { + DayOfWeek.Monday => 0.5m, + DayOfWeek.Tuesday => 12.5m, + DayOfWeek.Wednesday => 7.5m, + DayOfWeek.Thursday => 12.5m, + DayOfWeek.Friday => 5.0m, + DayOfWeek.Saturday => 2.5m, + DayOfWeek.Sunday => 2.0m, + _ => 0.0m, + }; + // } -} \ No newline at end of file +} diff --git a/docs/csharp/language-reference/operators/snippets/patterns/ListPattern.cs b/docs/csharp/language-reference/operators/snippets/patterns/ListPattern.cs new file mode 100644 index 0000000000000..309edece18cdb --- /dev/null +++ b/docs/csharp/language-reference/operators/snippets/patterns/ListPattern.cs @@ -0,0 +1,79 @@ +namespace Patterns; + +public static class ListPattern +{ + static string[] records = + { + "04-01-2020, DEPOSIT, Initial deposit, 2250.00", + "04-15-2020, DEPOSIT, Refund, 125.65", + "04-18-2020, DEPOSIT, Paycheck, 125.65", + "04-22-2020, WITHDRAWAL, Debit, Groceries, 255.73", + "05-01-2020, WITHDRAWAL, #1102, Rent, apt, 2100.00", + "05-02-2020, INTEREST, 0.65", + "05-07-2020, WITHDRAWAL, Debit, Movies, 12.57", + "04-15-2020, FEE, 5.55", + }; + + + public static void Examples() + { + // + int[] one = { 1 }; + int[] odd = { 1, 3, 5 }; + int[] even = { 2, 4, 6 }; + int[] fib = { 1, 1, 2, 3, 5 }; + // + + Console.WriteLine("Match entire array"); + // + Console.WriteLine(odd is [1, 3, 5]); // true + Console.WriteLine(even is [1, 3, 5]); // false (values) + Console.WriteLine(one is [1, 3, 5]); // false (length) + // + + Console.WriteLine("Match elements"); + // + Console.WriteLine(odd is [1, _, _]); // true + Console.WriteLine(odd is [_, 3, _]); // true + Console.WriteLine(even is [_, _, 5]); // false (last value) + // + + Console.WriteLine("Match range"); + // + Console.WriteLine(odd is [1, .., 3, _]); // true + Console.WriteLine(fib is [1, .., 3, _]); // true + + Console.WriteLine(odd is [1, _, 5, ..]); // true + Console.WriteLine(fib is [1, _, 5, ..]); // false + // + + Console.WriteLine("Relational pattern"); + // + Console.WriteLine(odd is [_, >1, ..]); // true + Console.WriteLine(even is [_, >1, ..]); // true + Console.WriteLine(fib is [_, > 1, ..]); // false + // + + // + decimal balance = 0m; + foreach (var record in ReadRecords()) + { + balance += record switch + { + [_, "DEPOSIT", _, var amount] => decimal.Parse(amount), + [_, "WITHDRAWAL", .., var amount] => -decimal.Parse(amount), + [_, "INTEREST", var amount] => decimal.Parse(amount), + [_, "FEE", var fee] => decimal.Parse(fee), + _ => throw new InvalidOperationException($"Record {record} is not in the expected format!"), + }; + Console.WriteLine($"Record: {record}, New balance: {balance:C}"); + } + // + + IEnumerable ReadRecords() + { + foreach (var record in records) + yield return record.Split(',', StringSplitOptions.TrimEntries); ; + } + } +} diff --git a/docs/csharp/language-reference/operators/snippets/patterns/LogicalPatterns.cs b/docs/csharp/language-reference/operators/snippets/patterns/LogicalPatterns.cs index b32213ddc8fa2..7b1971fac366c 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/LogicalPatterns.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/LogicalPatterns.cs @@ -1,74 +1,71 @@ -using System; +namespace Patterns; -namespace Patterns +public static class LogicalPatterns { - public static class LogicalPatterns + public static void Examples() { - public static void Examples() - { - AndPattern(); - OrPattern(); - } + AndPattern(); + OrPattern(); + } - private static void NotPattern(object input) + private static void NotPattern(object input) + { + // + if (input is not null) { - // - if (input is not null) - { - // ... - } - // + // ... } + // + } + + private static void AndPattern() + { + // + Console.WriteLine(Classify(13)); // output: High + Console.WriteLine(Classify(-100)); // output: Too low + Console.WriteLine(Classify(5.7)); // output: Acceptable - private static void AndPattern() + static string Classify(double measurement) => measurement switch { - // - Console.WriteLine(Classify(13)); // output: High - Console.WriteLine(Classify(-100)); // output: Too low - Console.WriteLine(Classify(5.7)); // output: Acceptable + < -40.0 => "Too low", + >= -40.0 and < 0 => "Low", + >= 0 and < 10.0 => "Acceptable", + >= 10.0 and < 20.0 => "High", + >= 20.0 => "Too high", + double.NaN => "Unknown", + }; + // + } - static string Classify(double measurement) => measurement switch - { - < -40.0 => "Too low", - >= -40.0 and < 0 => "Low", - >= 0 and < 10.0 => "Acceptable", - >= 10.0 and < 20.0 => "High", - >= 20.0 => "Too high", - double.NaN => "Unknown", - }; - // - } + private static void OrPattern() + { + // + Console.WriteLine(GetCalendarSeason(new DateTime(2021, 1, 19))); // output: winter + Console.WriteLine(GetCalendarSeason(new DateTime(2021, 10, 9))); // output: autumn + Console.WriteLine(GetCalendarSeason(new DateTime(2021, 5, 11))); // output: spring - private static void OrPattern() + static string GetCalendarSeason(DateTime date) => date.Month switch { - // - Console.WriteLine(GetCalendarSeason(new DateTime(2021, 1, 19))); // output: winter - Console.WriteLine(GetCalendarSeason(new DateTime(2021, 10, 9))); // output: autumn - Console.WriteLine(GetCalendarSeason(new DateTime(2021, 5, 11))); // output: spring - - static string GetCalendarSeason(DateTime date) => date.Month switch - { - 3 or 4 or 5 => "spring", - 6 or 7 or 8 => "summer", - 9 or 10 or 11 => "autumn", - 12 or 1 or 2 => "winter", - _ => throw new ArgumentOutOfRangeException(nameof(date), $"Date with unexpected month: {date.Month}."), - }; - // - } + 3 or 4 or 5 => "spring", + 6 or 7 or 8 => "summer", + 9 or 10 or 11 => "autumn", + 12 or 1 or 2 => "winter", + _ => throw new ArgumentOutOfRangeException(nameof(date), $"Date with unexpected month: {date.Month}."), + }; + // + } - // - static bool IsLetter(char c) => c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z'); - // + // + static bool IsLetter(char c) => c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z'); + // - private static void ChangedPrecedence(object input) + private static void ChangedPrecedence(object input) + { + // + if (input is not (float or double)) { - // - if (input is not (float or double)) - { - return; - } - // + return; } + // } } diff --git a/docs/csharp/language-reference/operators/snippets/patterns/PositionalPattern.cs b/docs/csharp/language-reference/operators/snippets/patterns/PositionalPattern.cs index 5d4b436195da6..2a9a51889f533 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/PositionalPattern.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/PositionalPattern.cs @@ -1,101 +1,97 @@ -using System; -using System.Collections.Generic; +namespace Patterns; -namespace Patterns +public static class PositionalPattern { - public static class PositionalPattern + public static void Examples() { - public static void Examples() - { - UseIdentifiers(); - } + UseIdentifiers(); + } - // - public readonly struct Point - { - public int X { get; } - public int Y { get; } + // + public readonly struct Point + { + public int X { get; } + public int Y { get; } - public Point(int x, int y) => (X, Y) = (x, y); + public Point(int x, int y) => (X, Y) = (x, y); - public void Deconstruct(out int x, out int y) => (x, y) = (X, Y); - } + public void Deconstruct(out int x, out int y) => (x, y) = (X, Y); + } - static string Classify(Point point) => point switch + static string Classify(Point point) => point switch + { + (0, 0) => "Origin", + (1, 0) => "positive X basis end", + (0, 1) => "positive Y basis end", + _ => "Just a point", + }; + // + + // + static decimal GetGroupTicketPriceDiscount(int groupSize, DateTime visitDate) + => (groupSize, visitDate.DayOfWeek) switch { - (0, 0) => "Origin", - (1, 0) => "positive X basis end", - (0, 1) => "positive Y basis end", - _ => "Just a point", + (<= 0, _) => throw new ArgumentException("Group size must be positive."), + (_, DayOfWeek.Saturday or DayOfWeek.Sunday) => 0.0m, + (>= 5 and < 10, DayOfWeek.Monday) => 20.0m, + (>= 10, DayOfWeek.Monday) => 30.0m, + (>= 5 and < 10, _) => 12.0m, + (>= 10, _) => 15.0m, + _ => 0.0m, }; - // - - // - static decimal GetGroupTicketPriceDiscount(int groupSize, DateTime visitDate) - => (groupSize, visitDate.DayOfWeek) switch - { - (<= 0, _) => throw new ArgumentException("Group size must be positive."), - (_, DayOfWeek.Saturday or DayOfWeek.Sunday) => 0.0m, - (>= 5 and < 10, DayOfWeek.Monday) => 20.0m, - (>= 10, DayOfWeek.Monday) => 30.0m, - (>= 5 and < 10, _) => 12.0m, - (>= 10, _) => 15.0m, - _ => 0.0m, - }; - // + // - private static void UseIdentifiers() + private static void UseIdentifiers() + { + // + var numbers = new List { 1, 2, 3 }; + if (SumAndCount(numbers) is (Sum: var sum, Count: > 0)) { - // - var numbers = new List { 1, 2, 3 }; - if (SumAndCount(numbers) is (Sum: var sum, Count: > 0)) - { - Console.WriteLine($"Sum of [{string.Join(" ", numbers)}] is {sum}"); // output: Sum of [1 2 3] is 6 - } - - static (double Sum, int Count) SumAndCount(IEnumerable numbers) + Console.WriteLine($"Sum of [{string.Join(" ", numbers)}] is {sum}"); // output: Sum of [1 2 3] is 6 + } + + static (double Sum, int Count) SumAndCount(IEnumerable numbers) + { + int sum = 0; + int count = 0; + foreach (int number in numbers) { - int sum = 0; - int count = 0; - foreach (int number in numbers) - { - sum += number; - count++; - } - return (sum, count); + sum += number; + count++; } - // + return (sum, count); } + // + } - // - public record Point2D(int X, int Y); - public record Point3D(int X, int Y, int Z); + // + public record Point2D(int X, int Y); + public record Point3D(int X, int Y, int Z); - static string PrintIfAllCoordinatesArePositive(object point) => point switch - { - Point2D (> 0, > 0) p => p.ToString(), - Point3D (> 0, > 0, > 0) p => p.ToString(), - _ => string.Empty, - }; - // + static string PrintIfAllCoordinatesArePositive(object point) => point switch + { + Point2D (> 0, > 0) p => p.ToString(), + Point3D (> 0, > 0, > 0) p => p.ToString(), + _ => string.Empty, + }; + // - // - public record WeightedPoint(int X, int Y) - { - public double Weight { get; set; } - } + // + public record WeightedPoint(int X, int Y) + { + public double Weight { get; set; } + } - static bool IsInDomain(WeightedPoint point) => point is (>= 0, >= 0) { Weight: >= 0.0 }; - // + static bool IsInDomain(WeightedPoint point) => point is (>= 0, >= 0) { Weight: >= 0.0 }; + // - static void CompletePositionPattern(object input) + static void CompletePositionPattern(object input) + { + // + if (input is WeightedPoint (> 0, > 0) { Weight: > 0.0 } p) { - // - if (input is WeightedPoint (> 0, > 0) { Weight: > 0.0 } p) - { - // .. - } - // + // .. } + // } } diff --git a/docs/csharp/language-reference/operators/snippets/patterns/Program.cs b/docs/csharp/language-reference/operators/snippets/patterns/Program.cs index 47d112c528e96..4a121faca154d 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/Program.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/Program.cs @@ -1,42 +1,37 @@ -using System; - -namespace Patterns -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("--- Declaration and type patterns -----------"); - DeclarationAndTypePatterns.Examples(); - Console.WriteLine(); - - Console.WriteLine("--- Constant pattern ------------------------"); - ConstantPattern.Examples(); - Console.WriteLine(); - - Console.WriteLine("--- Relational patterns ---------------------"); - RelationalPatterns.Examples(); - Console.WriteLine(); - - Console.WriteLine("--- Logical patterns ------------------------"); - LogicalPatterns.Examples(); - Console.WriteLine(); - - Console.WriteLine("--- Property pattern ------------------------"); - PropertyPattern.Examples(); - Console.WriteLine(); - - Console.WriteLine("--- Positional pattern ----------------------"); - PositionalPattern.Examples(); - Console.WriteLine(); - - Console.WriteLine("--- var pattern -----------------------------"); - VarPattern.Examples(); - Console.WriteLine(); - - Console.WriteLine("--- Discard pattern -------------------------"); - DiscardPattern.Examples(); - Console.WriteLine(); - } - } -} +using Patterns; + +Console.WriteLine("--- Declaration and type patterns -----------"); +DeclarationAndTypePatterns.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- Constant pattern ------------------------"); +ConstantPattern.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- Relational patterns ---------------------"); +RelationalPatterns.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- Logical patterns ------------------------"); +LogicalPatterns.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- Property pattern ------------------------"); +PropertyPattern.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- Positional pattern ----------------------"); +PositionalPattern.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- var pattern -----------------------------"); +VarPattern.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- Discard pattern -------------------------"); +DiscardPattern.Examples(); +Console.WriteLine(); + +Console.WriteLine("--- List pattern -------------------------"); +ListPattern.Examples(); +Console.WriteLine(); diff --git a/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs b/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs index abb997988f5cb..1c1be24b28836 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/PropertyPattern.cs @@ -1,56 +1,51 @@ -using System; -using System.Collections.Generic; -using System.Linq; +namespace Patterns; -namespace Patterns +public static class PropertyPattern { - public static class PropertyPattern + public static void Examples() { - public static void Examples() - { - WithTypeCheck(); - } + WithTypeCheck(); + } + + // + static bool IsConferenceDay(DateTime date) => date is { Year: 2020, Month: 5, Day: 19 or 20 or 21 }; + // - // - static bool IsConferenceDay(DateTime date) => date is { Year: 2020, Month: 5, Day: 19 or 20 or 21 }; - // + private static void WithTypeCheck() + { + // + Console.WriteLine(TakeFive("Hello, world!")); // output: Hello + Console.WriteLine(TakeFive("Hi!")); // output: Hi! + Console.WriteLine(TakeFive(new[] { '1', '2', '3', '4', '5', '6', '7' })); // output: 12345 + Console.WriteLine(TakeFive(new[] { 'a', 'b', 'c' })); // output: abc - private static void WithTypeCheck() + static string TakeFive(object input) => input switch { - // - Console.WriteLine(TakeFive("Hello, world!")); // output: Hello - Console.WriteLine(TakeFive("Hi!")); // output: Hi! - Console.WriteLine(TakeFive(new[] { '1', '2', '3', '4', '5', '6', '7' })); // output: 12345 - Console.WriteLine(TakeFive(new[] { 'a', 'b', 'c' })); // output: abc - - static string TakeFive(object input) => input switch - { - string { Length: >= 5 } s => s.Substring(0, 5), - string s => s, - - ICollection { Count: >= 5 } symbols => new string(symbols.Take(5).ToArray()), - ICollection symbols => new string(symbols.ToArray()), - - null => throw new ArgumentNullException(nameof(input)), - _ => throw new ArgumentException("Not supported input type."), - }; - // - } - - // - public record Point(int X, int Y); - public record Segment(Point Start, Point End); + string { Length: >= 5 } s => s.Substring(0, 5), + string s => s, - static bool IsAnyEndOnXAxis(Segment segment) => - segment is { Start: { Y: 0 } } or { End: { Y: 0 } }; - // + ICollection { Count: >= 5 } symbols => new string(symbols.Take(5).ToArray()), + ICollection symbols => new string(symbols.ToArray()), - private static class Extended - { - // - static bool IsAnyEndOnXAxis(Segment segment) => - segment is { Start.Y: 0 } or { End.Y: 0 }; - // - } + null => throw new ArgumentNullException(nameof(input)), + _ => throw new ArgumentException("Not supported input type."), + }; + // + } + + // + public record Point(int X, int Y); + public record Segment(Point Start, Point End); + + static bool IsAnyEndOnXAxis(Segment segment) => + segment is { Start: { Y: 0 } } or { End: { Y: 0 } }; + // + + private static class Extended + { + // + static bool IsAnyEndOnXAxis(Segment segment) => + segment is { Start.Y: 0 } or { End.Y: 0 }; + // } -} \ No newline at end of file +} diff --git a/docs/csharp/language-reference/operators/snippets/patterns/RelationalPatterns.cs b/docs/csharp/language-reference/operators/snippets/patterns/RelationalPatterns.cs index 3b88638351c51..6d54d0a86701e 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/RelationalPatterns.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/RelationalPatterns.cs @@ -1,48 +1,45 @@ -using System; +namespace Patterns; -namespace Patterns +public static class RelationalPatterns { - public static class RelationalPatterns + public static void Examples() { - public static void Examples() - { - BasicExample(); - WithCombinators(); - } + BasicExample(); + WithCombinators(); + } + + private static void BasicExample() + { + // + Console.WriteLine(Classify(13)); // output: Too high + Console.WriteLine(Classify(double.NaN)); // output: Unknown + Console.WriteLine(Classify(2.4)); // output: Acceptable - private static void BasicExample() + static string Classify(double measurement) => measurement switch { - // - Console.WriteLine(Classify(13)); // output: Too high - Console.WriteLine(Classify(double.NaN)); // output: Unknown - Console.WriteLine(Classify(2.4)); // output: Acceptable + < -4.0 => "Too low", + > 10.0 => "Too high", + double.NaN => "Unknown", + _ => "Acceptable", + }; + // + } - static string Classify(double measurement) => measurement switch - { - < -4.0 => "Too low", - > 10.0 => "Too high", - double.NaN => "Unknown", - _ => "Acceptable", - }; - // - } + private static void WithCombinators() + { + // + Console.WriteLine(GetCalendarSeason(new DateTime(2021, 3, 14))); // output: spring + Console.WriteLine(GetCalendarSeason(new DateTime(2021, 7, 19))); // output: summer + Console.WriteLine(GetCalendarSeason(new DateTime(2021, 2, 17))); // output: winter - private static void WithCombinators() + static string GetCalendarSeason(DateTime date) => date.Month switch { - // - Console.WriteLine(GetCalendarSeason(new DateTime(2021, 3, 14))); // output: spring - Console.WriteLine(GetCalendarSeason(new DateTime(2021, 7, 19))); // output: summer - Console.WriteLine(GetCalendarSeason(new DateTime(2021, 2, 17))); // output: winter - - static string GetCalendarSeason(DateTime date) => date.Month switch - { - >= 3 and < 6 => "spring", - >= 6 and < 9 => "summer", - >= 9 and < 12 => "autumn", - 12 or (>= 1 and < 3) => "winter", - _ => throw new ArgumentOutOfRangeException(nameof(date), $"Date with unexpected month: {date.Month}."), - }; - // - } + >= 3 and < 6 => "spring", + >= 6 and < 9 => "summer", + >= 9 and < 12 => "autumn", + 12 or (>= 1 and < 3) => "winter", + _ => throw new ArgumentOutOfRangeException(nameof(date), $"Date with unexpected month: {date.Month}."), + }; + // } } diff --git a/docs/csharp/language-reference/operators/snippets/patterns/VarPattern.cs b/docs/csharp/language-reference/operators/snippets/patterns/VarPattern.cs index 6503aeaa64ac5..61c1e41955046 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/VarPattern.cs +++ b/docs/csharp/language-reference/operators/snippets/patterns/VarPattern.cs @@ -1,50 +1,45 @@ -using System; -using System.Collections.Generic; -using System.Linq; +namespace Patterns; -namespace Patterns +public static class VarPattern { - public static class VarPattern + public static void Examples() { - public static void Examples() - { - TestTransform(); - } + TestTransform(); + } - private static void KeepInterimResult() - { - // - static bool IsAcceptable(int id, int absLimit) => - SimulateDataFetch(id) is var results - && results.Min() >= -absLimit - && results.Max() <= absLimit; + private static void KeepInterimResult() + { + // + static bool IsAcceptable(int id, int absLimit) => + SimulateDataFetch(id) is var results + && results.Min() >= -absLimit + && results.Max() <= absLimit; - static int[] SimulateDataFetch(int id) - { - var rand = new Random(); - return Enumerable - .Range(start: 0, count: 5) - .Select(s => rand.Next(minValue: -10, maxValue: 11)) - .ToArray(); - } - // - } + static int[] SimulateDataFetch(int id) + { + var rand = new Random(); + return Enumerable + .Range(start: 0, count: 5) + .Select(s => rand.Next(minValue: -10, maxValue: 11)) + .ToArray(); + } + // + } - // - public record Point(int X, int Y); + // + public record Point(int X, int Y); - static Point Transform(Point point) => point switch - { - var (x, y) when x < y => new Point(-x, y), - var (x, y) when x > y => new Point(x, -y), - var (x, y) => new Point(x, y), - }; + static Point Transform(Point point) => point switch + { + var (x, y) when x < y => new Point(-x, y), + var (x, y) when x > y => new Point(x, -y), + var (x, y) => new Point(x, y), + }; - static void TestTransform() - { - Console.WriteLine(Transform(new Point(1, 2))); // output: Point { X = -1, Y = 2 } - Console.WriteLine(Transform(new Point(5, 2))); // output: Point { X = 5, Y = -2 } - } - // + static void TestTransform() + { + Console.WriteLine(Transform(new Point(1, 2))); // output: Point { X = -1, Y = 2 } + Console.WriteLine(Transform(new Point(5, 2))); // output: Point { X = 5, Y = -2 } } + // } diff --git a/docs/csharp/language-reference/operators/snippets/patterns/patterns.csproj b/docs/csharp/language-reference/operators/snippets/patterns/patterns.csproj index 00c24f2bca0c9..0f148cf03be54 100644 --- a/docs/csharp/language-reference/operators/snippets/patterns/patterns.csproj +++ b/docs/csharp/language-reference/operators/snippets/patterns/patterns.csproj @@ -2,10 +2,11 @@ Exe - net6.0 + enable + net7.0 enable Patterns - Patterns.Program + preview diff --git a/docs/csharp/language-reference/operators/snippets/shared/IsOperator.cs b/docs/csharp/language-reference/operators/snippets/shared/IsOperator.cs index 6a81e15437571..02ce8e316f0c2 100644 --- a/docs/csharp/language-reference/operators/snippets/shared/IsOperator.cs +++ b/docs/csharp/language-reference/operators/snippets/shared/IsOperator.cs @@ -7,6 +7,10 @@ public static class IsOperator public static void Examples() { DeclarationPattern(); + IsFirstFridayOfOctober(DateTime.Now); + NullCheck(default(object)); + NonNullCheck(new object()); + ListPattern(); } // @@ -46,5 +50,27 @@ private static void NonNullCheck(object result) } // } + + private static void ListPattern() + { + // + int[] empty = { }; + int[] one = { 1 }; + int[] odd = { 1, 3, 5 }; + int[] even = { 2, 4, 6 }; + int[] fib = { 1, 1, 2, 3, 5 }; + + Console.WriteLine(odd is [1, _, 2, ..]); // false + Console.WriteLine(fib is [1, _, 2, ..]); // true + Console.WriteLine(fib is [_, 1, 2, 3, ..]); // true + Console.WriteLine(fib is [.., 1, 2, 3, _ ]); // true + Console.WriteLine(even is [2, _, 6]); // true + Console.WriteLine(even is [2, .., 6]); // true + Console.WriteLine(odd is [.., 3, 5]); // true + Console.WriteLine(even is [.., 3, 5]); // false + Console.WriteLine(fib is [.., 3, 5]); // true + // + + } } } diff --git a/docs/csharp/language-reference/operators/snippets/shared/NullParameterCheck.cs b/docs/csharp/language-reference/operators/snippets/shared/NullParameterCheck.cs deleted file mode 100644 index 4b02221578594..0000000000000 --- a/docs/csharp/language-reference/operators/snippets/shared/NullParameterCheck.cs +++ /dev/null @@ -1,334 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace operators; -public class SimplifiedNullParameterCheck -{ - - // - void Method(string name!!) - { - // ... - } - // - - // - void Method(string firstName!!, string lastName!!, string? nickName, string message) - { - // ... - } - // -} - -public class NullParameterCheck -{ - - // - void Method(string name) - { - if (name is null) - { - throw new ArgumentNullException(nameof(name)); - } - // ... - } - // - - // - void Method(string firstName, string lastName, string? nickName, string? message) - { - if (firstName is null) - { - throw new ArgumentNullException(nameof(firstName)); - } - if (lastName is null) - { - throw new ArgumentNullException(nameof(lastName)); - } - // ... - } - // -} - -// -public abstract class AbstractClass -{ - // Simplified null parameter check not allowed: - public abstract void Method(string name); - - // Simplified null check not allowed for "defaultName" - // It could be added on a method or lambda that matches this - // delegate type: - public delegate void SetDefaultString(string defaultName); -} - -public interface IInterfaceMethods -{ - private static string defaultName = string.Empty; - - // Simplified null parameter check not allowed: - void Method(string name); - - // !! allowed because an implementation is supplied: - public static void SetDefaultName(string name!!) - { - defaultName = name; - } -} -// - - -public class Container -{ - void M(string? name!!) { } -} - -// -public class B -{ - public B() - { - Console.WriteLine("In B constructor"); - } -} - -public class D : B -{ - private string identity = CreateNextIdentityString(); - private string data; - - public D() - { - Console.WriteLine("Parameterless D constructor"); - } - public D(string arg) : this() - { - if (arg is null) throw new ArgumentNullException(nameof(arg)); - data = arg; - } - - private static string CreateNextIdentityString() - { - Console.WriteLine("Creating identity string"); - return DateTime.Now.Ticks.ToString(); - } -} -// - -public class Simplified -{ - public class D : B - { - private string identity = CreateNextIdentityString(); - private string data; - - public D() - { - Console.WriteLine("Parameterless D constructor"); - } - - // - public D(string arg!!) : this() - { - data = arg; - } - // - - private static string CreateNextIdentityString() - { - Console.WriteLine("Creating identity string"); - return DateTime.Now.Ticks.ToString(); - } - } - - public class Characterizer - { - // - public IEnumerable CharsIn(string data!!) - { - foreach (var ch in data) - { - yield return ch; - } - } - // - - // async - - public async Task SumCharsIn(string data!!) - { - await Task.Delay(500); - int sum = data.Sum(x => x); - return sum; - } - - // async enumerable - public async IAsyncEnumerable CharsInAsync(string data!!) - { - foreach (var ch in data) - { - if (ch % 5 == 0) - await Task.Delay(500); - yield return ch; - } - } - } - -} - -public class Characterizer -{ - // - public IEnumerable CharsIn(string data) - { - if (data is null) throw new ArgumentNullException(nameof(data)); - - foreach (var ch in data) - { - yield return ch; - } - } - // - - // async - // - public async Task SumCharsIn(string data) - { - if (data is null) throw new ArgumentNullException(nameof(data)); - - await Task.Delay(500); - int sum = data.Sum(x => x); - return sum; - } - // - - // async enumerable - // - public async IAsyncEnumerable CharsInAsync(string data) - { - if (data is null) throw new ArgumentNullException(nameof(data)); - - foreach (var ch in data) - { - if (ch % 5 == 0) - await Task.Delay(500); - yield return ch; - } - } - // -} - -public static class NullChecks -{ - public static async Task Examples() - { - try - { - Console.WriteLine("Hand coded null check"); - _ = new D(null!); - } catch (ArgumentNullException) - { - Console.WriteLine(); - } - try - { - Console.WriteLine("Simplified null check"); - _ = new Simplified.D(null!); - } - catch (ArgumentNullException) - { - Console.WriteLine(); - } - - - var characters = new Characterizer(); - try - { - // - Console.WriteLine("Call iterator"); - var sequence = characters.CharsIn(null!); - Console.WriteLine("Enumerate values"); - foreach (var c in sequence) - Console.WriteLine(c); - // - } - catch (ArgumentNullException) - { - Console.WriteLine("Exception caught"); - Console.WriteLine(); - } - - try - { - Console.WriteLine("Create task"); - var sumTask = characters.SumCharsIn(null!); - Console.WriteLine("await task"); - Console.WriteLine(await sumTask); - } - catch (ArgumentNullException) - { - Console.WriteLine("Exception caught"); - Console.WriteLine(); - } - - try - { - Console.WriteLine("Call async iterator"); - var sequenceAsync = characters.CharsInAsync(null!); - Console.WriteLine("Enumerate values"); - await foreach (var c in sequenceAsync) - Console.WriteLine(c); - } - catch (ArgumentNullException) - { - Console.WriteLine("Exception caught"); - Console.WriteLine(); - } - - var characters2 = new Simplified.Characterizer(); - try - { - Console.WriteLine("Call iterator"); - var sequence = characters2.CharsIn(null!); - Console.WriteLine("Enumerate values"); - foreach (var c in sequence) - Console.WriteLine(c); - } - catch (ArgumentNullException) - { - Console.WriteLine("Exception caught"); - Console.WriteLine(); - } - - try - { - Console.WriteLine("Create task"); - var sumTask = characters2.SumCharsIn(null!); - Console.WriteLine("await task"); - Console.WriteLine(await sumTask); - } - catch (ArgumentNullException) - { - Console.WriteLine("Exception caught"); - Console.WriteLine(); - } - - try - { - Console.WriteLine("Call async iterator"); - var sequenceAsync = characters2.CharsInAsync(null!); - Console.WriteLine("Enumerate values"); - await foreach (var c in sequenceAsync) - Console.WriteLine(c); - } - catch (ArgumentNullException) - { - Console.WriteLine("Exception caught"); - Console.WriteLine(); - } - } -} diff --git a/docs/csharp/language-reference/operators/snippets/shared/Program.cs b/docs/csharp/language-reference/operators/snippets/shared/Program.cs index fc3213257f88f..8f5083273d92c 100644 --- a/docs/csharp/language-reference/operators/snippets/shared/Program.cs +++ b/docs/csharp/language-reference/operators/snippets/shared/Program.cs @@ -115,11 +115,6 @@ static async Task Main(string[] args) Console.WriteLine("============= is operator example =============="); IsOperator.Examples(); Console.WriteLine(); - - Console.WriteLine("============= is operator example =============="); - await NullChecks.Examples(); - Console.WriteLine(); - } } } diff --git a/docs/csharp/language-reference/operators/snippets/shared/operators.csproj b/docs/csharp/language-reference/operators/snippets/shared/operators.csproj index 041d7f0ca5539..b3b8f76526762 100644 --- a/docs/csharp/language-reference/operators/snippets/shared/operators.csproj +++ b/docs/csharp/language-reference/operators/snippets/shared/operators.csproj @@ -2,15 +2,15 @@ Exe - net6.0 - preview + net7.0 enable operators.Program true + preview - + diff --git a/docs/csharp/language-reference/operators/switch-expression.md b/docs/csharp/language-reference/operators/switch-expression.md index b0b645c14b98f..a7d53a6e04ad2 100644 --- a/docs/csharp/language-reference/operators/switch-expression.md +++ b/docs/csharp/language-reference/operators/switch-expression.md @@ -43,7 +43,7 @@ The preceding example uses [property patterns](patterns.md#property-pattern) wit ## Non-exhaustive switch expressions -If none of a `switch` expression's patterns matches an input value, the runtime throws an exception. In .NET Core 3.0 and later versions, the exception is a . In .NET Framework, the exception is an . The compiler generates a warning if a `switch` expression doesn't handle all possible input values. +If none of a `switch` expression's patterns matches an input value, the runtime throws an exception. In .NET Core 3.0 and later versions, the exception is a . In .NET Framework, the exception is an . In most cases, the compiler generates a warning if a `switch` expression doesn't handle all possible input values. [List patterns](patterns.md#list-patterns) do not generate a warning when all possible inputs aren't handled. > [!TIP] > To guarantee that a `switch` expression handles all possible input values, provide a `switch` expression arm with a [discard pattern](patterns.md#discard-pattern). diff --git a/docs/csharp/language-reference/tokens/interpolated.md b/docs/csharp/language-reference/tokens/interpolated.md index e35b9e88bab80..e2290641920ae 100644 --- a/docs/csharp/language-reference/tokens/interpolated.md +++ b/docs/csharp/language-reference/tokens/interpolated.md @@ -94,6 +94,20 @@ The following example uses implicit conversion to diff --git a/docs/csharp/methods.md b/docs/csharp/methods.md index f86a0e78ed5c6..63c1caedaa5f0 100644 --- a/docs/csharp/methods.md +++ b/docs/csharp/methods.md @@ -8,7 +8,7 @@ ms.assetid: 577a8527-1081-4b36-9b9e-0685b6553c6e # Methods in C\# -A method is a code block that contains a series of statements. A program causes the statements to be executed by calling the method and specifying any required method arguments. In C#, every executed instruction is performed in the context of a method. The `Main` method is the entry point for every C# application and it is called by the common language runtime (CLR) when the program is started. +A method is a code block that contains a series of statements. A program causes the statements to be executed by calling the method and specifying any required method arguments. In C#, every executed instruction is performed in the context of a method. The `Main` method is the entry point for every C# application and it's called by the common language runtime (CLR) when the program is started. > [!NOTE] > This topic discusses named methods. For information about anonymous functions, see [Lambda expressions](language-reference/operators/lambda-expressions.md). @@ -34,17 +34,17 @@ The following example defines a class named `Motorcycle` that contains five meth [!code-csharp[csSnippets.Methods#40](../../samples/snippets/csharp/concepts/methods/methods40.cs#40)] -Note that the `Motorcycle` class includes an overloaded method, `Drive`. Two methods have the same name, but must be differentiated by their parameter types. +The `Motorcycle` class includes an overloaded method, `Drive`. Two methods have the same name, but must be differentiated by their parameter types. ## Method invocation -Methods can be either *instance* or *static*. Invoking an instance method requires that you instantiate an object and call the method on that object; an instance method operates on that instance and its data. You invoke a static method by referencing the name of the type to which the method belongs; static methods do not operate on instance data. Attempting to call a static method through an object instance generates a compiler error. +Methods can be either *instance* or *static*. Invoking an instance method requires that you instantiate an object and call the method on that object; an instance method operates on that instance and its data. You invoke a static method by referencing the name of the type to which the method belongs; static methods don't operate on instance data. Attempting to call a static method through an object instance generates a compiler error. -Calling a method is like accessing a field. After the object name (if you are calling an instance method) or the type name (if you are calling a `static` method), add a period, the name of the method, and parentheses. Arguments are listed within the parentheses and are separated by commas. +Calling a method is like accessing a field. After the object name (if you're calling an instance method) or the type name (if you're calling a `static` method), add a period, the name of the method, and parentheses. Arguments are listed within the parentheses and are separated by commas. -The method definition specifies the names and types of any parameters that are required. When a caller invokes the method, it provides concrete values, called arguments, for each parameter. The arguments must be compatible with the parameter type, but the argument name, if one is used in the calling code, does not have to be the same as the parameter named defined in the method. In the following example, the `Square` method includes a single parameter of type `int` named *i*. The first method call passes the `Square` method a variable of type `int` named *num*; the second, a numeric constant; and the third, an expression. +The method definition specifies the names and types of any parameters that are required. When a caller invokes the method, it provides concrete values, called arguments, for each parameter. The arguments must be compatible with the parameter type, but the argument name, if one is used in the calling code, doesn't have to be the same as the parameter named defined in the method. In the following example, the `Square` method includes a single parameter of type `int` named *i*. The first method call passes the `Square` method a variable of type `int` named *num*; the second, a numeric constant; and the third, an expression. [!code-csharp[csSnippets.Methods#74](../../samples/snippets/csharp/concepts/methods/params74.cs#74)] @@ -64,7 +64,7 @@ You can invoke a method using both positional arguments and named arguments. How ## Inherited and overridden methods -In addition to the members that are explicitly defined in a type, a type inherits members defined in its base classes. Since all types in the managed type system inherit directly or indirectly from the class, all types inherit its members, such as , , and . The following example defines a `Person` class, instantiates two `Person` objects, and calls the `Person.Equals` method to determine whether the two objects are equal. The `Equals` method, however, is not defined in the `Person` class; it is inherited from . +In addition to the members that are explicitly defined in a type, a type inherits members defined in its base classes. Since all types in the managed type system inherit directly or indirectly from the class, all types inherit its members, such as , , and . The following example defines a `Person` class, instantiates two `Person` objects, and calls the `Person.Equals` method to determine whether the two objects are equal. The `Equals` method, however, isn't defined in the `Person` class; it's inherited from . [!code-csharp[csSnippets.Methods#104](../../samples/snippets/csharp/concepts/methods/inherited1.cs#104)] @@ -90,7 +90,7 @@ The following example passes a value type to a method by value, and the called m When an object of a reference type is passed to a method by value, a reference to the object is passed by value. That is, the method receives not the object itself, but an argument that indicates the location of the object. If you change a member of the object by using this reference, the change is reflected in the object when control returns to the calling method. However, replacing the object passed to the method has no effect on the original object when control returns to the caller. -The following example defines a class (which is a reference type) named `SampleRefType`. It instantiates a `SampleRefType` object, assigns 44 to its `value` field, and passes the object to the `ModifyObject` method. This example does essentially the same thing as the previous example -- it passes an argument by value to a method. But because a reference type is used, the result is different. The modification that is made in `ModifyObject` to the `obj.value` field also changes the `value` field of the argument, `rt`, in the `Main` method to 33, as the output from the example shows. +The following example defines a class (which is a reference type) named `SampleRefType`. It instantiates a `SampleRefType` object, assigns 44 to its `value` field, and passes the object to the `ModifyObject` method. This example does essentially the same thing as the previous example—it passes an argument by value to a method. But because a reference type is used, the result is different. The modification that is made in `ModifyObject` to the `obj.value` field also changes the `value` field of the argument, `rt`, in the `Main` method to 33, as the output from the example shows. [!code-csharp[csSnippets.Methods#42](../../samples/snippets/csharp/concepts/methods/byvalue42.cs#42)] @@ -123,7 +123,7 @@ A caller can then invoke the method in either of four ways: - By passing `null`. - By not providing an argument to the parameter array. -The following example defines a method named `GetVowels` that returns all the vowels from a parameter array. The `Main` method illustrates all four ways of invoking the method. Callers are not required to supply any arguments for parameters that include the `params` modifier. In that case, the parameter is an empty array. +The following example defines a method named `GetVowels` that returns all the vowels from a parameter array. The `Main` method illustrates all four ways of invoking the method. Callers aren't required to supply any arguments for parameters that include the `params` modifier. In that case, the parameter is an empty array. [!code-csharp[csSnippets.Methods#75](~/samples/snippets/csharp/concepts/methods/params75.cs#75)] @@ -131,16 +131,16 @@ The following example defines a method named `GetVowels` that returns all the vo ## Optional parameters and arguments -A method definition can specify that its parameters are required or that they are optional. By default, parameters are required. Optional parameters are specified by including the parameter's default value in the method definition. When the method is called, if no argument is supplied for an optional parameter, the default value is used instead. +A method definition can specify that its parameters are required or that they're optional. By default, parameters are required. Optional parameters are specified by including the parameter's default value in the method definition. When the method is called, if no argument is supplied for an optional parameter, the default value is used instead. The parameter's default value must be assigned by one of the following kinds of expressions: - A constant, such as a literal string or number. - An expression of the form `default(SomeType)`, where `SomeType` can be either a value type or a reference type. If it's a reference type, it's effectively the same as specifying `null`. Beginning with C# 7.1, you can use the `default` literal, as the compiler can infer the type from the parameter's declaration. -- An expression of the form `new ValType()`, where `ValType` is a value type. Note that this invokes the value type's implicit parameterless constructor, which is not an actual member of the type. +- An expression of the form `new ValType()`, where `ValType` is a value type. This invokes the value type's implicit parameterless constructor, which isn't an actual member of the type. > [!NOTE] - > In C# 10 and later, when an expression of the form `new ValType()` invokes the explicitly defined parameterless constructor of a value type, the compiler generates an error as the default parameter value must be a compile-time constant. Use the `default(ValType)` expression or the `default` literal to provide the default parameter value. For more information about parameterless constructors, see the [Parameterless constructors and field initializers](language-reference/builtin-types/struct.md#parameterless-constructors-and-field-initializers) section of the [Structure types](language-reference/builtin-types/struct.md) article. + > In C# 10 and later, when an expression of the form `new ValType()` invokes the explicitly defined parameterless constructor of a value type, the compiler generates an error as the default parameter value must be a compile-time constant. Use the `default(ValType)` expression or the `default` literal to provide the default parameter value. For more information about parameterless constructors, see the [Struct initialization and default values](language-reference/builtin-types/struct.md#struct-initialization-and-default-values) section of the [Structure types](language-reference/builtin-types/struct.md) article. If a method includes both required and optional parameters, optional parameters are defined at the end of the parameter list, after all required parameters. @@ -160,13 +160,13 @@ The use of optional parameters affects *overload resolution*, or the way in whic - A method, indexer, or constructor is a candidate for execution if each of its parameters either is optional or corresponds, by name or by position, to a single argument in the calling statement, and that argument can be converted to the type of the parameter. - If more than one candidate is found, overload resolution rules for preferred conversions are applied to the arguments that are explicitly specified. Omitted arguments for optional parameters are ignored. -- If two candidates are judged to be equally good, preference goes to a candidate that does not have optional parameters for which arguments were omitted in the call. This is a consequence of a general preference in overload resolution for candidates that have fewer parameters. +- If two candidates are judged to be equally good, preference goes to a candidate that doesn't have optional parameters for which arguments were omitted in the call. This is a consequence of a general preference in overload resolution for candidates that have fewer parameters. ## Return values -Methods can return a value to the caller. If the return type (the type listed before the method name) is not `void`, the method can return the value by using the `return` keyword. A statement with the `return` keyword followed by a variable, constant, or expression that matches the return type will return that value to the method caller. Methods with a non-void return type are required to use the `return` keyword to return a value. The `return` keyword also stops the execution of the method. +Methods can return a value to the caller. If the return type (the type listed before the method name) isn't `void`, the method can return the value by using the `return` keyword. A statement with the `return` keyword followed by a variable, constant, or expression that matches the return type will return that value to the method caller. Methods with a non-void return type are required to use the `return` keyword to return a value. The `return` keyword also stops the execution of the method. If the return type is `void`, a `return` statement without a value is still useful to stop the execution of the method. Without the `return` keyword, the method will stop executing when it reaches the end of the code block. @@ -216,7 +216,7 @@ var person = GetPersonalInfo("111111111"); Console.WriteLine($"{person.FName} {person.LName}: age = {person.Age}"); ``` -If a method is passed an array as an argument and modifies the value of individual elements, it is not necessary for the method to return the array, although you may choose to do so for good style or functional flow of values. This is because C# passes all reference types by value, and the value of an array reference is the pointer to the array. In the following example, changes to the contents of the `values` array that are made in the `DoubleValues` method are observable by any code that has a reference to the array. +If a method is passed an array as an argument and modifies the value of individual elements, it isn't necessary for the method to return the array, although you may choose to do so for good style or functional flow of values. This is because C# passes all reference types by value, and the value of an array reference is the pointer to the array. In the following example, changes to the contents of the `values` array that are made in the `DoubleValues` method are observable by any code that has a reference to the array. [!code-csharp[csSnippets.Methods#101](../../samples/snippets/csharp/concepts/methods/returnarray1.cs#101)] @@ -226,10 +226,10 @@ If a method is passed an array as an argument and modifies the value of individu Ordinarily, there are two ways to add a method to an existing type: -- Modify the source code for that type. You cannot do this, of course, if you do not own the type's source code. And this becomes a breaking change if you also add any private data fields to support the method. -- Define the new method in a derived class. A method cannot be added in this way using inheritance for other types, such as structures and enumerations. Nor can it be used to "add" a method to a sealed class. +- Modify the source code for that type. You can't do this, of course, if you don't own the type's source code. And this becomes a breaking change if you also add any private data fields to support the method. +- Define the new method in a derived class. A method can't be added in this way using inheritance for other types, such as structures and enumerations. Nor can it be used to "add" a method to a sealed class. -Extension methods let you "add" a method to an existing type without modifying the type itself or implementing the new method in an inherited type. The extension method also does not have to reside in the same assembly as the type it extends. You call an extension method as if it were a defined member of a type. +Extension methods let you "add" a method to an existing type without modifying the type itself or implementing the new method in an inherited type. The extension method also doesn't have to reside in the same assembly as the type it extends. You call an extension method as if it were a defined member of a type. For more information, see [Extension Methods](programming-guide/classes-and-structs/extension-methods.md). @@ -239,14 +239,14 @@ For more information, see [Extension Methods](programming-guide/classes-and-stru By using the async feature, you can invoke asynchronous methods without using explicit callbacks or manually splitting your code across multiple methods or lambda expressions. -If you mark a method with the [async](language-reference/keywords/async.md) modifier, you can use the [await](language-reference/operators/await.md) operator in the method. When control reaches an `await` expression in the async method, control returns to the caller if the awaited task is not completed, and progress in the method with the `await` keyword is suspended until the awaited task completes. When the task is complete, execution can resume in the method. +If you mark a method with the [async](language-reference/keywords/async.md) modifier, you can use the [await](language-reference/operators/await.md) operator in the method. When control reaches an `await` expression in the async method, control returns to the caller if the awaited task isn't completed, and progress in the method with the `await` keyword is suspended until the awaited task completes. When the task is complete, execution can resume in the method. > [!NOTE] > An async method returns to the caller when either it encounters the first awaited object that's not yet complete or it gets to the end of the async method, whichever occurs first. An async method typically has a return type of , , or `void`. The `void` return type is used primarily to define event handlers, where a `void` return type is required. An async method that returns `void` can't be awaited, and the caller of a void-returning method can't catch exceptions that the method throws. Starting with C# 7.0, an async method can have [any task-like return type](language-reference/keywords/async.md#return-types). -In the following example, `DelayAsync` is an async method that has a return statement that returns an integer. Because it is an async method, its method declaration must have a return type of `Task`. Because the return type is `Task`, the evaluation of the `await` expression in `DoSomethingAsync` produces an integer, as the following `int result = await delayTask` statement demonstrates. +In the following example, `DelayAsync` is an async method that has a return statement that returns an integer. Because it's an async method, its method declaration must have a return type of `Task`. Because the return type is `Task`, the evaluation of the `await` expression in `DoSomethingAsync` produces an integer, as the following `int result = await delayTask` statement demonstrates. :::code language="csharp" source="programming-guide/classes-and-structs/snippets/classes-and-structs/methods/Program.cs"::: @@ -258,7 +258,7 @@ An async method can't declare any [in](language-reference/keywords/in-parameter- ## Expression-bodied members -It is common to have method definitions that simply return immediately with the result of an expression, or that have a single statement as the body of the method. There is a syntax shortcut for defining such methods using `=>`: +It's common to have method definitions that simply return immediately with the result of an expression, or that have a single statement as the body of the method. There's a syntax shortcut for defining such methods using `=>`: ```csharp public Point Move(int dx, int dy) => new Point(x + dx, y + dy); @@ -269,7 +269,7 @@ public string Name => First + " " + Last; public Customer this[long id] => store.LookupCustomer(id); ``` -If the method returns `void` or is an async method, the body of the method must be a statement expression (same as with lambdas). For properties and indexers, they must be read-only, and you do not use the `get` accessor keyword. +If the method returns `void` or is an async method, the body of the method must be a statement expression (same as with lambdas). For properties and indexers, they must be read-only, and you don't use the `get` accessor keyword. diff --git a/docs/csharp/misc/cs0568.md b/docs/csharp/misc/cs0568.md index 1e4030860d2bb..b56ddb78978c9 100644 --- a/docs/csharp/misc/cs0568.md +++ b/docs/csharp/misc/cs0568.md @@ -38,4 +38,4 @@ public class ClassX ``` > [!NOTE] -> Beginning with C# 10, a structure type can contain an explicit parameterless constructor. For more information, see the [Parameterless constructors and field initializers](../language-reference/builtin-types/struct.md#parameterless-constructors-and-field-initializers) section of the [Structure types](../language-reference/builtin-types/struct.md) article. +> Beginning with C# 10, a structure type can contain an explicit parameterless constructor. For more information, see the [Struct initialization and default values](../language-reference/builtin-types/struct.md#struct-initialization-and-default-values) section of the [Structure types](../language-reference/builtin-types/struct.md) article. diff --git a/docs/csharp/misc/cs0573.md b/docs/csharp/misc/cs0573.md index 01bb539a2b33d..8051bf8e6fa0d 100644 --- a/docs/csharp/misc/cs0573.md +++ b/docs/csharp/misc/cs0573.md @@ -12,10 +12,10 @@ ms.assetid: 10ef9625-44f1-4936-ada3-56938357aa01 'field declaration' : cannot have instance field initializers in structs - You cannot initialize an instance field of a [struct](../language-reference/builtin-types/struct.md). Fields of value types will be initialized to their default values, and reference-type fields will be initialized to `null`. + You can't initialize an instance field of a [struct](../language-reference/builtin-types/struct.md). Fields of value types will be initialized to their default values, and reference-type fields will be initialized to `null`. > [!NOTE] -> Beginning with C# 10, you can initialize a struct's instance field or property at its declaration. For more information, see the [Parameterless constructors and field initializers](../language-reference/builtin-types/struct.md#parameterless-constructors-and-field-initializers) section of the [Structure types](../language-reference/builtin-types/struct.md) article. +> Beginning with C# 10, you can initialize a struct's instance field or property at its declaration. For more information, see the [Struct initialization and default values](../language-reference/builtin-types/struct.md#struct-initialization-and-default-values) section of the [Structure types](../language-reference/builtin-types/struct.md) article. ## Example diff --git a/docs/csharp/misc/cs0642.md b/docs/csharp/misc/cs0642.md index 9f2688564613f..eb9ae89602f16 100644 --- a/docs/csharp/misc/cs0642.md +++ b/docs/csharp/misc/cs0642.md @@ -14,7 +14,7 @@ Possible mistaken empty statement A semicolon after a conditional statement may cause your code to execute differently than intended. - You can use **DisabledWarnings** compiler option or `#pragmas warning` to disable this warning; see [**DisabledWarnings** (C# Compiler Options)](../language-reference/compiler-options/errors-warnings.md#disabledwarnings) or [#pragma warning](../language-reference/preprocessor-directives.md#pragma-warning) for more information. + You can use **NoWarn** compiler option or `#pragmas warning` to disable this warning; see [**NoWarn** (C# Compiler Options)](../language-reference/compiler-options/errors-warnings.md#nowarn) or [#pragma warning](../language-reference/preprocessor-directives.md#pragma-warning) for more information. The following sample generates CS0642: diff --git a/docs/csharp/misc/cs1106.md b/docs/csharp/misc/cs1106.md index 57bae9870001c..3821a40e69304 100644 --- a/docs/csharp/misc/cs1106.md +++ b/docs/csharp/misc/cs1106.md @@ -22,7 +22,7 @@ Extension methods must be defined in a non generic static class. // cs1106.cs public class Extensions // CS1106 { - public static void Test(this System.String s) {} + public static void Test(this System.String s) { } } ``` diff --git a/docs/csharp/misc/cs2023.md b/docs/csharp/misc/cs2023.md index 2a83d8199d2ea..791b5b9aff3e1 100644 --- a/docs/csharp/misc/cs2023.md +++ b/docs/csharp/misc/cs2023.md @@ -14,4 +14,4 @@ Ignoring /noconfig option because it was specified in a response file The [-noconfig](../language-reference/compiler-options/miscellaneous.md#noconfig) compiler option was specified in a response file, which is not allowed. - This warning cannot be suppressed by the [**DisabledWarnings**](../language-reference/compiler-options/errors-warnings.md#disabledwarnings) option. + This warning cannot be suppressed by the [**NoWarn**](../language-reference/compiler-options/errors-warnings.md#nowarn) option. diff --git a/docs/csharp/misc/cs2029.md b/docs/csharp/misc/cs2029.md index 3e21f84247788..8edd0a690857a 100644 --- a/docs/csharp/misc/cs2029.md +++ b/docs/csharp/misc/cs2029.md @@ -14,4 +14,4 @@ Invalid value for '/define'; 'identifier' is not a valid identifier This warning occurs if the value that is used in the [**DefineConstants**](../language-reference/compiler-options/language.md#defineconstants) option has some invalid characters. - This warning cannot be suppressed by the [**DisabledWarnings**](../language-reference/compiler-options/errors-warnings.md#disabledwarnings) option. + This warning cannot be suppressed by the [**NoWarn**](../language-reference/compiler-options/errors-warnings.md#nowarn) option. diff --git a/docs/csharp/nullable-references.md b/docs/csharp/nullable-references.md index 767bd0fb508f4..415e4500f205c 100644 --- a/docs/csharp/nullable-references.md +++ b/docs/csharp/nullable-references.md @@ -136,7 +136,7 @@ name!.Length; Nullable reference types and nullable value types provide a similar semantic concept: A variable can represent a value or object, or that variable may be `null`. However, nullable reference types and nullable value types are implemented differently: nullable value types are implemented using , and nullable reference types are implemented by attributes read by the compiler. For example, `string?` and `string` are both represented by the same type: . However, `int?` and `int` are represented by `System.Nullable` and , respectively. -Nullable reference types are a compile time feature. That means it's possible for callers to ignore warnings, intentionally use `null` as an argument to a method expecting a non nullable reference. Library authors should include runtime checks against null argument values. The `!!` operator, introduced in C# 11, provides [simplified parameter null checks](language-reference/operators/null-parameter-check.md) on parameters. +Nullable reference types are a compile time feature. That means it's possible for callers to ignore warnings, intentionally use `null` as an argument to a method expecting a non nullable reference. Library authors should include runtime checks against null argument values. The is the preferred option for checking a parameter against null at run time. > [!IMPORTANT] > Enabling nullable annotations can change how Entity Framework Core determines if a data member is required. You can learn more details in the article on [Entity Framework Core Fundamentals: Working with Nullable Reference Types](/ef/core/miscellaneous/nullable-reference-types). diff --git a/docs/csharp/programming-guide/classes-and-structs/instance-constructors.md b/docs/csharp/programming-guide/classes-and-structs/instance-constructors.md index d48e859de858e..54d58488cc577 100644 --- a/docs/csharp/programming-guide/classes-and-structs/instance-constructors.md +++ b/docs/csharp/programming-guide/classes-and-structs/instance-constructors.md @@ -32,7 +32,7 @@ That constructor initializes instance fields and properties according to the cor A *structure* type always provides a parameterless constructor as follows: - In C# 9.0 and earlier, that is an implicit parameterless constructor that produces the [default value](../../language-reference/builtin-types/default-values.md) of a type. -- In C# 10 and later, that is either an implicit parameterless constructor that produces the default value of a type or an explicitly declared parameterless constructor. For more information, see the [Parameterless constructors and field initializers](../../language-reference/builtin-types/struct.md#parameterless-constructors-and-field-initializers) section of the [Structure types](../../language-reference/builtin-types/struct.md) article. +- In C# 10 and later, that is either an implicit parameterless constructor that produces the default value of a type or an explicitly declared parameterless constructor. For more information, see the [Struct initialization and default values](../../language-reference/builtin-types/struct.md#struct-initialization-and-default-values) section of the [Structure types](../../language-reference/builtin-types/struct.md) article. ## See also diff --git a/docs/csharp/programming-guide/classes-and-structs/using-constructors.md b/docs/csharp/programming-guide/classes-and-structs/using-constructors.md index 6285dd7253728..706a834ae3be1 100644 --- a/docs/csharp/programming-guide/classes-and-structs/using-constructors.md +++ b/docs/csharp/programming-guide/classes-and-structs/using-constructors.md @@ -8,7 +8,7 @@ ms.assetid: 464253b2-fd5d-469a-836d-df0fdf2a43f7 --- # Using Constructors (C# Programming Guide) -When a [class](../../language-reference/keywords/class.md) or [struct](../../language-reference/builtin-types/struct.md) is created, its constructor is called. Constructors have the same name as the class or struct, and they usually initialize the data members of the new object. +When a [class](../../language-reference/keywords/class.md) or [struct](../../language-reference/builtin-types/struct.md) is instantiated, its constructor is called. Constructors have the same name as the class or struct, and they usually initialize the data members of the new object. In the following example, a class named `Taxi` is defined by using a simple constructor. This class is then instantiated with the [new](../../language-reference/operators/new-operator.md) operator. The `Taxi` constructor is invoked by the `new` operator immediately after memory is allocated for the new object. @@ -24,7 +24,7 @@ When a [class](../../language-reference/keywords/class.md) or [struct](../../lan For more information, see [Private Constructors](./private-constructors.md). -Constructors for [struct](../../language-reference/builtin-types/struct.md) types resemble class constructors, but `structs` cannot contain an explicit parameterless constructor because one is provided automatically by the compiler. This constructor initializes each field in the `struct` to the [default value](../../language-reference/builtin-types/default-values.md). However, this parameterless constructor is only invoked if the `struct` is instantiated with `new`. For example, this code uses the parameterless constructor for , so that you are assured that the integer is initialized: +Constructors for [struct](../../language-reference/builtin-types/struct.md) types resemble class constructors, but `structs` can't contain an explicit parameterless constructor because one is provided automatically by the compiler. This constructor initializes each field in the `struct` to the [default value](../../language-reference/builtin-types/default-values.md). However, this parameterless constructor is only invoked if the `struct` is instantiated with `new`. For example, this code uses the parameterless constructor for , so that you're assured that the integer is initialized: ```csharp int i = new int(); @@ -32,9 +32,9 @@ Console.WriteLine(i); ``` > [!NOTE] -> Beginning with C# 10, a structure type can contain an explicit parameterless constructor. For more information, see the [Parameterless constructors and field initializers](../../language-reference/builtin-types/struct.md#parameterless-constructors-and-field-initializers) section of the [Structure types](../../language-reference/builtin-types/struct.md) article. +> Beginning with C# 10, a structure type can contain an explicit parameterless constructor. For more information, see the [Struct initialization and default values](../../language-reference/builtin-types/struct.md#struct-initialization-and-default-values) section of the [Structure types](../../language-reference/builtin-types/struct.md) article. -The following code, however, causes a compiler error because it does not use `new`, and because it tries to use an object that has not been initialized: +The following code, however, causes a compiler error because it doesn't use `new`, and because it tries to use an object that hasn't been initialized: ```csharp int i; @@ -50,7 +50,7 @@ b = 33; // Or assign it before using it. Console.WriteLine("{0}, {1}", a, b); ``` - So calling the parameterless constructor for a value type is not required. + So calling the parameterless constructor for a value type isn't required. Both classes and `structs` can define constructors that take parameters. Constructors that take parameters must be called through a `new` statement or a [base](../../language-reference/keywords/base.md) statement. Classes and `structs` can also define multiple constructors, and neither is required to define a parameterless constructor. For example: @@ -66,13 +66,13 @@ Console.WriteLine("{0}, {1}", a, b); In this example, the constructor for the base class is called before the block for the constructor is executed. The `base` keyword can be used with or without parameters. Any parameters to the constructor can be used as parameters to `base`, or as part of an expression. For more information, see [base](../../language-reference/keywords/base.md). - In a derived class, if a base-class constructor is not called explicitly by using the `base` keyword, the parameterless constructor, if there is one, is called implicitly. This means that the following constructor declarations are effectively the same: + In a derived class, if a base-class constructor isn't called explicitly by using the `base` keyword, the parameterless constructor, if there's one, is called implicitly. This means that the following constructor declarations are effectively the same: [!code-csharp[ManagerImplicitlyCallingParameterlessBaseConstructor#6](snippets/using-constructors/Program.cs#6)] [!code-csharp[ManagerExplicitlyCallingParameterlessBaseConstructor#7](snippets/using-constructors/Program.cs#7)] - If a base class does not offer a parameterless constructor, the derived class must make an explicit call to a base constructor by using `base`. + If a base class doesn't offer a parameterless constructor, the derived class must make an explicit call to a base constructor by using `base`. A constructor can invoke another constructor in the same object by using the [this](../../language-reference/keywords/this.md) keyword. Like `base`, `this` can be used with or without parameters, and any parameters in the constructor are available as parameters to `this`, or as part of an expression. For example, the second constructor in the previous example can be rewritten using `this`: diff --git a/docs/csharp/programming-guide/concepts/async/index.md b/docs/csharp/programming-guide/concepts/async/index.md index c1353a99970dd..d38d24a659644 100644 --- a/docs/csharp/programming-guide/concepts/async/index.md +++ b/docs/csharp/programming-guide/concepts/async/index.md @@ -1,17 +1,17 @@ --- title: Asynchronous programming in C# description: An overview of the C# language support for asynchronous programming using async, await, Task, and Task -ms.date: 06/04/2020 +ms.date: 05/17/2022 recommendations: false --- # Asynchronous programming with async and await The [Task asynchronous programming model (TAP)](task-asynchronous-programming-model.md) provides an abstraction over asynchronous code. You write code as a sequence of statements, just like always. You can read that code as though each statement completes before the next begins. The compiler performs many transformations because some of those statements may start work and return a that represents the ongoing work. -That's the goal of this syntax: enable code that reads like a sequence of statements, but executes in a much more complicated order based on external resource allocation and when tasks complete. It's analogous to how people give instructions for processes that include asynchronous tasks. Throughout this article, you'll use an example of instructions for making a breakfast to see how the `async` and `await` keywords make it easier to reason about code, that includes a series of asynchronous instructions. You'd write the instructions something like the following list to explain how to make a breakfast: +That's the goal of this syntax: enable code that reads like a sequence of statements, but executes in a much more complicated order based on external resource allocation and when tasks are complete. It's analogous to how people give instructions for processes that include asynchronous tasks. Throughout this article, you'll use an example of instructions for making breakfast to see how the `async` and `await` keywords make it easier to reason about code that includes a series of asynchronous instructions. You'd write the instructions something like the following list to explain how to make a breakfast: 1. Pour a cup of coffee. -1. Heat up a pan, then fry two eggs. +1. Heat a pan, then fry two eggs. 1. Fry three slices of bacon. 1. Toast two pieces of bread. 1. Add butter and jam to the toast. @@ -19,22 +19,19 @@ That's the goal of this syntax: enable code that reads like a sequence of statem If you have experience with cooking, you'd execute those instructions **asynchronously**. You'd start warming the pan for eggs, then start the bacon. You'd put the bread in the toaster, then start the eggs. At each step of the process, you'd start a task, then turn your attention to tasks that are ready for your attention. -Cooking breakfast is a good example of asynchronous work that isn't parallel. One person (or thread) can handle all these tasks. Continuing the breakfast analogy, one person can make breakfast asynchronously by starting the next task before the first completes. The cooking progresses whether or not someone is watching it. As soon as you start warming the pan for the eggs, you can begin frying the bacon. Once the bacon starts, you can put the bread into the toaster. +Cooking breakfast is a good example of asynchronous work that isn't parallel. One person (or thread) can handle all these tasks. Continuing the breakfast analogy, one person can make breakfast asynchronously by starting the next task before the first task completes. The cooking progresses whether or not someone is watching it. As soon as you start warming the pan for the eggs, you can begin frying the bacon. Once the bacon starts, you can put the bread into the toaster. -For a parallel algorithm, you'd need multiple cooks (or threads). One would make the eggs, one the bacon, and so on. Each one would be focused on just that one task. Each cook (or thread) would be blocked synchronously waiting for bacon to be ready to flip, or the toast to pop. +For a parallel algorithm, you'd need multiple cooks (or threads). One would make the eggs, one the bacon, and so on. Each one would be focused on just that one task. Each cook (or thread) would be blocked synchronously waiting for the bacon to be ready to flip, or the toast to pop. Now, consider those same instructions written as C# statements: -:::code language="csharp" source="snippets/index/AsyncBreakfast-starter/Program.cs" highlight="8-27"::: +:::code language="csharp" source="snippets/index/AsyncBreakfast-starter/Program.cs" highlight="8-34"::: :::image type="content" source="media/synchronous-breakfast.png" alt-text="synchronous breakfast"::: -The synchronously prepared breakfast, took roughly 30 minutes because the total is the sum of each individual task. +The synchronously prepared breakfast took roughly 30 minutes because the total is the sum of each task. -> [!NOTE] -> The `Coffee`, `Egg`, `Bacon`, `Toast`, and `Juice` classes are empty. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. - -Computers don't interpret those instructions the same way people do. The computer will block on each statement until the work is complete before moving on to the next statement. That creates an unsatisfying breakfast. The later tasks wouldn't be started until the earlier tasks had completed. It would take much longer to create the breakfast, and some items would have gotten cold before being served. +Computers don't interpret those instructions the same way people do. The computer will block on each statement until the work is complete before moving on to the next statement. That creates an unsatisfying breakfast. The later tasks wouldn't be started until the earlier tasks had been completed. It would take much longer to create the breakfast, and some items would have gotten cold before being served. If you want the computer to execute the above instructions asynchronously, you must write asynchronous code. @@ -56,6 +53,9 @@ Let's start by updating this code so that the thread doesn't block while tasks a > [!TIP] > The method bodies of the `FryEggsAsync`, `FryBaconAsync`, and `ToastBreadAsync` have all been updated to return `Task`, `Task`, and `Task` respectively. The methods are renamed from their original version to include the "Async" suffix. Their implementations are shown as part of the [final version](#final-version) later in this article. +> [!NOTE] +> The `Main` method returns `Task`, despite not having a `return` expression—this is by design. For more information, see [Evaluation of a void-returning async function](/dotnet/csharp/language-reference/language-specification/classes#14153-evaluation-of-a-void-returning-async-function). + This code doesn't block while the eggs or the bacon are cooking. This code won't start any other tasks though. You'd still put the toast in the toaster and stare at it until it pops. But at least, you'd respond to anyone that wanted your attention. In a restaurant where multiple orders are placed, the cook could start another breakfast while the first is cooking. Now, the thread working on the breakfast isn't blocked while awaiting any started task that hasn't yet finished. For some applications, this change is all that's needed. A GUI application still responds to the user with just this change. However, for this scenario, you want more. You don't want each of the component tasks to be executed sequentially. It's better to start each of the component tasks before awaiting the previous task's completion. @@ -64,7 +64,7 @@ Now, the thread working on the breakfast isn't blocked while awaiting any starte In many scenarios, you want to start several independent tasks immediately. Then, as each task finishes, you can continue other work that's ready. In the breakfast analogy, that's how you get breakfast done more quickly. You also get everything done close to the same time. You'll get a hot breakfast. -The and related types are classes you can use to reason about tasks that are in progress. That enables you to write code that more closely resembles the way you'd actually create breakfast. You'd start cooking the eggs, bacon, and toast at the same time. As each requires action, you'd turn your attention to that task, take care of the next action, then await for something else that requires your attention. +The and related types are classes you can use to reason about tasks that are in progress. That enables you to write code that more closely resembles the way you'd create breakfast. You'd start cooking the eggs, bacon, and toast at the same time. As each requires action, you'd turn your attention to that task, take care of the next action, then wait for something else that requires your attention. You start a task and hold on to the object that represents the work. You'll `await` each task before working with its result. @@ -122,7 +122,7 @@ Console.WriteLine("Breakfast is ready!"); The asynchronously prepared breakfast took roughly 20 minutes, this time savings is because some tasks ran concurrently. -The preceding code works better. You start all the asynchronous tasks at once. You await each task only when you need the results. The preceding code may be similar to code in a web application that makes requests of different microservices, then combines the results into a single page. You'll make all the requests immediately, then `await` all those tasks and compose the web page. +The preceding code works better. You start all the asynchronous tasks at once. You await each task only when you need the results. The preceding code may be similar to code in a web application that makes requests to different microservices, then combines the results into a single page. You'll make all the requests immediately, then `await` all those tasks and compose the web page. ## Composition with tasks @@ -195,7 +195,7 @@ Unhandled exception. System.InvalidOperationException: The toaster is on fire at AsyncBreakfast.Program.
(String[] args) ``` -Notice that there's quite a few tasks completing between when the toaster catches fire and the exception is observed. When a task that runs asynchronously throws an exception, that Task is ***faulted***. The Task object holds the exception thrown in the property. Faulted tasks throw an exception when they're awaited. +You'll notice quite a few tasks are completed between when the toaster catches fire and the exception is observed. When a task that runs asynchronously throws an exception, that Task is ***faulted***. The Task object holds the exception thrown in the property. Faulted tasks throw an exception when they're awaited. There are two important mechanisms to understand: how an exception is stored in a faulted task, and how an exception is unpackaged and rethrown when code awaits a faulted task. @@ -222,7 +222,7 @@ Console.WriteLine("Toast is ready"); Console.WriteLine("Breakfast is ready!"); ``` -Another option is to use , which returns a `Task` that completes when any of its arguments completes. You can await the returned task, knowing that it has already finished. The following code shows how you could use to await the first task to finish and then process its result. After processing the result from the completed task, you remove that completed task from the list of tasks passed to `WhenAny`. +Another option is to use , which returns a `Task` that completes when any of its arguments complete. You can await the returned task, knowing that it has already finished. The following code shows how you could use to await the first task to finish and then process its result. After processing the result from the completed task, you remove that completed task from the list of tasks passed to `WhenAny`. ```csharp var breakfastTasks = new List { eggsTask, baconTask, toastTask }; diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs index b8c1813fabf15..5ef08ea14136c 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs @@ -6,6 +6,13 @@ namespace AsyncBreakfast class Program { // + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + static async Task Main(string[] args) { Coffee cup = PourCoffee(); diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs index 55686db83691e..92cec48ad47aa 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs @@ -6,11 +6,18 @@ namespace AsyncBreakfast class Program { // + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + static async Task Main(string[] args) { Coffee cup = PourCoffee(); Console.WriteLine("coffee is ready"); - + var eggsTask = FryEggsAsync(2); var baconTask = FryBaconAsync(3); var toastTask = MakeToastWithButterAndJamAsync(2); diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs index 9a17dfcb7d76c..e1be280e688bd 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs @@ -4,6 +4,13 @@ namespace AsyncBreakfast { + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + class Program { static async Task Main(string[] args) @@ -97,7 +104,7 @@ private static async Task FryEggsAsync(int howMany) Console.WriteLine("cooking the eggs ..."); await Task.Delay(3000); Console.WriteLine("Put eggs on plate"); - + return new Egg(); } @@ -107,4 +114,4 @@ private static Coffee PourCoffee() return new Coffee(); } } -} \ No newline at end of file +} diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs index 7c4775de6ae17..6cbda6bba519c 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs @@ -3,6 +3,13 @@ namespace AsyncBreakfast { + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + class Program { static void Main(string[] args) @@ -32,10 +39,10 @@ private static Juice PourOJ() return new Juice(); } - private static void ApplyJam(Toast toast) => + private static void ApplyJam(Toast toast) => Console.WriteLine("Putting jam on the toast"); - private static void ApplyButter(Toast toast) => + private static void ApplyButter(Toast toast) => Console.WriteLine("Putting butter on the toast"); private static Toast ToastBread(int slices) @@ -85,4 +92,4 @@ private static Coffee PourCoffee() return new Coffee(); } } -} \ No newline at end of file +} diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/task-asynchronous-programming-model.md b/docs/csharp/programming-guide/concepts/async/task-asynchronous-programming-model.md index dc5d66e987930..7d37bf0fe1ff8 100644 --- a/docs/csharp/programming-guide/concepts/async/task-asynchronous-programming-model.md +++ b/docs/csharp/programming-guide/concepts/async/task-asynchronous-programming-model.md @@ -214,7 +214,7 @@ You can ignore the convention where an event, base class, or interface contract | Cancel tasks with a cancellation token as a signaling mechanism. | Shows how to add the following functionality to your async solution:

- [Cancel a list of tasks (C#)](cancel-an-async-task-or-a-list-of-tasks.md)
- [Cancel tasks after a period of time (C#)](cancel-async-tasks-after-a-period-of-time.md)
- [Process asynchronous task as they complete (C#)](start-multiple-async-tasks-and-process-them-as-they-complete.md) | | [Using async for file access (C#)](using-async-for-file-access.md) | Lists and demonstrates the benefits of using async and await to access files. | | [Task-based asynchronous pattern (TAP)](../../../../standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap.md) | Describes an asynchronous pattern, the pattern is based on the and types. | -| [Async Videos on Channel 9](https://channel9.msdn.com/search?term=async%20&type=All#pubDate=year&ch9Search&lang-en=en) | Provides links to a variety of videos about async programming. | +| [Async Videos on Channel 9](/shows/browse?terms=async) | Provides links to a variety of videos about async programming. | ## See also diff --git a/docs/csharp/programming-guide/concepts/linq/quantifier-operations.md b/docs/csharp/programming-guide/concepts/linq/quantifier-operations.md index 9819dd932699b..ca9c6e9611cff 100644 --- a/docs/csharp/programming-guide/concepts/linq/quantifier-operations.md +++ b/docs/csharp/programming-guide/concepts/linq/quantifier-operations.md @@ -8,7 +8,7 @@ ms.date: 03/30/2022 Quantifier operations return a value that indicates whether some or all of the elements in a sequence satisfy a condition. - The following illustration depicts two different quantifier operations on two different source sequences. The first operation asks if one or more of the elements are the character 'A', and the result is `true`. The second operation asks if all the elements are the character 'A', and the result is `true`. + The following illustration depicts two different quantifier operations on two different source sequences. The first operation asks if any of the elements are the character 'A'. The second operation asks if all the elements are the character 'A'. Both methods return `true` in this example. ![LINQ Quantifier Operations](./media/quantifier-operations/linq-quantifier-operations.png) diff --git a/docs/csharp/programming-guide/delegates/using-delegates.md b/docs/csharp/programming-guide/delegates/using-delegates.md index f085c69536617..20e70a7569746 100644 --- a/docs/csharp/programming-guide/delegates/using-delegates.md +++ b/docs/csharp/programming-guide/delegates/using-delegates.md @@ -18,7 +18,7 @@ A delegate object is normally constructed by providing the name of the method th [!code-csharp[csProgGuideDelegates#23](~/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideDelegates/CS/Delegates.cs#23)] -Delegate types are derived from the class in .NET. Delegate types are [sealed](../../language-reference/keywords/sealed.md)—they cannot be derived from— and it is not possible to derive custom classes from . Because the instantiated delegate is an object, it can be passed as a parameter, or assigned to a property. This allows a method to accept a delegate as a parameter, and call the delegate at some later time. This is known as an asynchronous callback, and is a common method of notifying a caller when a long process has completed. When a delegate is used in this fashion, the code using the delegate does not need any knowledge of the implementation of the method being used. The functionality is similar to the encapsulation interfaces provide. +Delegate types are derived from the class in .NET. Delegate types are [sealed](../../language-reference/keywords/sealed.md)—they cannot be derived from— and it is not possible to derive custom classes from . Because the instantiated delegate is an object, it can be passed as an argument, or assigned to a property. This allows a method to accept a delegate as a parameter, and call the delegate at some later time. This is known as an asynchronous callback, and is a common method of notifying a caller when a long process has completed. When a delegate is used in this fashion, the code using the delegate does not need any knowledge of the implementation of the method being used. The functionality is similar to the encapsulation interfaces provide. Another common use of callbacks is defining a custom comparison method and passing that delegate to a sort method. It allows the caller's code to become part of the sort algorithm. The following example method uses the `Del` type as a parameter: diff --git a/docs/csharp/programming-guide/strings/index.md b/docs/csharp/programming-guide/strings/index.md index 8eab568e6d3dd..d9391719e2f4e 100644 --- a/docs/csharp/programming-guide/strings/index.md +++ b/docs/csharp/programming-guide/strings/index.md @@ -117,6 +117,14 @@ Beginning with C# 11, you can combine *raw string literals* with string interpol :::code language="csharp" source="./snippets/StringInterpolation.cs" id="InterpolationExample"::: +### Verbatim String Interpolation + +C# also allows verbatim string interpolation, for example across multiple lines, using the `$@` or `@$` syntax. + +To interpret escape sequences literally, use a [verbatim](../../language-reference/tokens/verbatim.md) string literal. An interpolated verbatim string starts with the `$` character followed by the `@` character. Starting with C# 8.0, you can use the `$` and `@` tokens in any order: both `$@"..."` and `@$"..."` are valid interpolated verbatim strings. + +:::code language="csharp" source="./snippets/VerbatimStringInterpolation.cs" id="VerbatimStringInterpolation"::: + ### Composite formatting The utilizes placeholders in braces to create a format string. This example results in similar output to the string interpolation method used above. diff --git a/docs/csharp/programming-guide/strings/snippets/VerbatimStringInterpolation.cs b/docs/csharp/programming-guide/strings/snippets/VerbatimStringInterpolation.cs new file mode 100644 index 0000000000000..d7b7a37a5373c --- /dev/null +++ b/docs/csharp/programming-guide/strings/snippets/VerbatimStringInterpolation.cs @@ -0,0 +1,22 @@ +using System; + +namespace StringExamples; +public static class VerbatimInterpolation +{ + public static void VerbatimInterpolationExample() + { + // + var jh = (firstName: "Jupiter", lastName: "Hammon", born: 1711, published: 1761); + Console.WriteLine($@"{jh.firstName} {jh.lastName} + was an African American poet born in {jh.born}."); + Console.WriteLine(@$"He was first published in {jh.published} + at the age of {jh.published - jh.born}."); + + // Output: + // Jupiter Hammon + // was an African American poet born in 1711. + // He was first published in 1761 + // at the age of 50. + // + } +} diff --git a/docs/csharp/programming-guide/types/how-to-convert-a-string-to-a-number.md b/docs/csharp/programming-guide/types/how-to-convert-a-string-to-a-number.md index 6b95ec9760222..a4722330f8c70 100644 --- a/docs/csharp/programming-guide/types/how-to-convert-a-string-to-a-number.md +++ b/docs/csharp/programming-guide/types/how-to-convert-a-string-to-a-number.md @@ -10,6 +10,7 @@ helpviewer_keywords: ms.topic: how-to ms.custom: contperf-fy21q3 ms.assetid: 467b9979-86ee-4afd-b734-30299cda91e3 +adobe-target: true --- # How to convert a string to a number (C# Programming Guide) diff --git a/docs/csharp/roslyn-sdk/source-generators-overview.md b/docs/csharp/roslyn-sdk/source-generators-overview.md index ae204f3644060..84e6c66f5cd33 100644 --- a/docs/csharp/roslyn-sdk/source-generators-overview.md +++ b/docs/csharp/roslyn-sdk/source-generators-overview.md @@ -102,7 +102,7 @@ In this guide, you'll explore the creation of a source generator using the , and it represents a method or method-like symbol (including constructor, destructor, operator, or property/event accessor). The method returns the for the program's entry point. Other methods enable you to find any method symbol in a project. From this object, we can reason about the containing namespace (if one is present) and the type. The `source` in this example is an interpolated string that templates the source code to be generated, where the interpolated wholes are filled with the containing namespace and type information. The `source` is added to the `context` with a hint name. For this example, the generator creates a new generated source file that contains an implementation of the `partial` method in the console application. You can write source generators to add any source you'd like. + From the `context` object we can access the compilations' entry point, or `Main` method. The `mainMethod` instance is an , and it represents a method or method-like symbol (including constructor, destructor, operator, or property/event accessor). The method returns the for the program's entry point. Other methods enable you to find any method symbol in a project. From this object, we can reason about the containing namespace (if one is present) and the type. The `source` in this example is an interpolated string that templates the source code to be generated, where the interpolated holes are filled with the containing namespace and type information. The `source` is added to the `context` with a hint name. For this example, the generator creates a new generated source file that contains an implementation of the `partial` method in the console application. You can write source generators to add any source you'd like. > [!TIP] > The `hintName` parameter from the method can be any unique name. It's common to provide an explicit C# file extension such as `".g.cs"` or `".generated.cs"` for the name. The file name helps identify the file as being source generated. diff --git a/docs/csharp/toc.yml b/docs/csharp/toc.yml index 6433dc5a23cfc..31cdba2a18988 100644 --- a/docs/csharp/toc.yml +++ b/docs/csharp/toc.yml @@ -1163,9 +1163,6 @@ items: - name: "?? and ??= operators" href: language-reference/operators/null-coalescing-operator.md displayName: null-coalescing, assignment - - name: "!! (null parameter check) operator" - href: language-reference/operators/null-parameter-check.md - displayName: "!!, bang bang, null parameter" - name: => operator href: language-reference/operators/lambda-operator.md displayName: lambda, expression body definition @@ -1291,7 +1288,7 @@ items: href: language-reference/compiler-messages/index.md - name: Specifications items: - - name: C# 6.0 draft specification + - name: C# 7 draft specification items: - name: Detailed table of contents href: ../../_csharpstandard/standard/README.md @@ -1365,10 +1362,6 @@ items: href: ../../_csharplang/proposals/csharp-7.0/out-var.md - name: Throw expressions href: ../../_csharplang/proposals/csharp-7.0/throw-expression.md - - name: Binary literals - href: ../../_csharplang/proposals/csharp-7.0/binary-literals.md - - name: Digit separators - href: ../../_csharplang/proposals/csharp-7.0/digit-separators.md - name: Async task types href: ../../_csharplang/proposals/csharp-7.0/task-types.md - name: C# 7.1 features @@ -1393,8 +1386,6 @@ items: href: ../../_csharplang/proposals/csharp-7.2/private-protected.md - name: Conditional ref href: ../../_csharplang/proposals/csharp-7.2/conditional-ref.md - - name: Leading digit separator - href: ../../_csharplang/proposals/csharp-7.2/leading-separator.md - name: C# 7.3 features items: - name: Unmanaged generic type constraints diff --git a/docs/csharp/tour-of-csharp/features.md b/docs/csharp/tour-of-csharp/features.md index e0bc5ef78be3d..f7545c8f19400 100644 --- a/docs/csharp/tour-of-csharp/features.md +++ b/docs/csharp/tour-of-csharp/features.md @@ -60,7 +60,7 @@ An interpolated string is declared using the `$` token. String interpolation eva ## Pattern matching -The C# language provides [***pattern matching***](../fundamentals/functional/pattern-matching.md) expressions to query the state of an object and execute code based on that state. You can inspect types and the values of properties and fields to determine which action to take. The `switch` expression is the primary expression for pattern matching. +The C# language provides [***pattern matching***](../fundamentals/functional/pattern-matching.md) expressions to query the state of an object and execute code based on that state. You can inspect types and the values of properties and fields to determine which action to take. You can inspect the elements of a list or array as well. The `switch` expression is the primary expression for pattern matching. ## Delegates and lambda expressions diff --git a/docs/csharp/tour-of-csharp/tutorials/arrays-and-collections.md b/docs/csharp/tour-of-csharp/tutorials/arrays-and-collections.md index 5b0eb37b95dd3..628ee587ac36c 100644 --- a/docs/csharp/tour-of-csharp/tutorials/arrays-and-collections.md +++ b/docs/csharp/tour-of-csharp/tutorials/arrays-and-collections.md @@ -9,7 +9,7 @@ This introductory tutorial provides an introduction to the C# language and the b ## Prerequisites -The tutorial expects that you have a machine set up for local development. On Windows, Linux, or macOS, you can use the .NET CLI to create, build, and run applications. On macOS and Windows, you can use Visual Studio 2019. For setup instructions, see [Set up your local environment](local-environment.md). +The tutorial expects that you have a machine set up for local development. See [Set up your local environment](local-environment.md) for installation instructions and an overview of application development in .NET. If you prefer to run the code without having to set up a local environment, see the [interactive-in-browser version of this tutorial](list-collection.yml). diff --git a/docs/csharp/tour-of-csharp/tutorials/branches-and-loops-local.md b/docs/csharp/tour-of-csharp/tutorials/branches-and-loops-local.md index a093b48fccdd4..5b0ab9cade881 100644 --- a/docs/csharp/tour-of-csharp/tutorials/branches-and-loops-local.md +++ b/docs/csharp/tour-of-csharp/tutorials/branches-and-loops-local.md @@ -10,7 +10,7 @@ This tutorial teaches you how to write C# code that examines variables and chang ## Prerequisites -The tutorial expects that you have a machine set up for local development. On Windows, Linux, or macOS, you can use the .NET CLI to create, build, and run applications. On macoS and Windows, you can use Visual Studio 2019. For setup instructions, see [Set up your local environment](local-environment.md). +The tutorial expects that you have a machine set up for local development. See [Set up your local environment](local-environment.md) for installation instructions and an overview of application development in .NET. If you prefer to run the code without having to set up a local environment, see the [interactive-in-browser version of this tutorial](branches-and-loops.yml). diff --git a/docs/csharp/tour-of-csharp/tutorials/local-environment.md b/docs/csharp/tour-of-csharp/tutorials/local-environment.md index a8f98a5e08450..194338414dd57 100644 --- a/docs/csharp/tour-of-csharp/tutorials/local-environment.md +++ b/docs/csharp/tour-of-csharp/tutorials/local-environment.md @@ -5,12 +5,9 @@ ms.date: 02/02/2021 --- # Set up your local environment -The first step in running a tutorial on your machine is to set up a development environment. Choose one of the following alternatives: +The first step in running a tutorial on your machine is to set up a development environment. -* To use the .NET CLI and your choice of text or code editor, see the .NET tutorial [Hello World in 10 minutes](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro). The tutorial has instructions for setting up a development environment on Windows, Linux, or macOS. -* To use the .NET CLI and Visual Studio Code, install the [.NET SDK](https://dotnet.microsoft.com/download) and -[Visual Studio Code](https://code.visualstudio.com/). -* To use Visual Studio 2019, see [Tutorial: Create a simple C# console app in Visual Studio](/visualstudio/get-started/csharp/tutorial-console). +[!INCLUDE [Prerequisites](../../includes/prerequisites.md)] ## Basic application development flow diff --git a/docs/csharp/tour-of-csharp/tutorials/numbers-in-csharp-local.md b/docs/csharp/tour-of-csharp/tutorials/numbers-in-csharp-local.md index 5f6b6c840e548..f8f149ff2b0c0 100644 --- a/docs/csharp/tour-of-csharp/tutorials/numbers-in-csharp-local.md +++ b/docs/csharp/tour-of-csharp/tutorials/numbers-in-csharp-local.md @@ -10,7 +10,7 @@ This tutorial teaches you about the numeric types in C#. You'll write small amou ## Prerequisites -The tutorial expects that you have a machine set up for local development. On Windows, Linux, or macOS, you can use the .NET CLI to create, build, and run applications. On macOS or Windows, you can use Visual Studio 2019. For setup instructions, see [Set up your local environment](local-environment.md). +The tutorial expects that you have a machine set up for local development. See [Set up your local environment](local-environment.md) for installation instructions and an overview of application development in .NET. If you don't want to set up a local environment, see the [interactive-in-browser version of this tutorial](numbers-in-csharp.yml). diff --git a/docs/csharp/whats-new/csharp-10.md b/docs/csharp/whats-new/csharp-10.md index a38832863b5ae..6e34167576473 100644 --- a/docs/csharp/whats-new/csharp-10.md +++ b/docs/csharp/whats-new/csharp-10.md @@ -21,6 +21,7 @@ C# 10 adds the following features and enhancements to the C# language: - [Allow `AsyncMethodBuilder` attribute on methods](#allow-asyncmethodbuilder-attribute-on-methods) - [CallerArgumentExpression attribute](#callerargumentexpression-attribute-diagnostics) - [Enhanced `#line` pragma](#enhanced-line-pragma) +- [Warning wave 6](../language-reference/compiler-messages/warning-waves.md#cs8826---partial-method-declarations-have-signature-differences) C# 10 is supported on **.NET 6**. For more information, see [C# language versioning](../language-reference/configure-language-version.md). @@ -34,7 +35,7 @@ You can declare value type records using the [`record struct` or `readonly recor C# 10 introduces the following improvements related to structure types: -- You can declare an instance parameterless constructor in a structure type and initialize an instance field or property at its declaration. For more information, see the [Parameterless constructors and field initializers](../language-reference/builtin-types/struct.md#parameterless-constructors-and-field-initializers) section of the [Structure types](../language-reference/builtin-types/struct.md) article. +- You can declare an instance parameterless constructor in a structure type and initialize an instance field or property at its declaration. For more information, see the [Struct initialization and default values](../language-reference/builtin-types/struct.md#struct-initialization-and-default-values) section of the [Structure types](../language-reference/builtin-types/struct.md) article. - A left-hand operand of the [`with` expression](../language-reference/operators/with-expression.md) can be of any structure type or an anonymous (reference) type. ## Interpolated string handler diff --git a/docs/csharp/whats-new/csharp-11.md b/docs/csharp/whats-new/csharp-11.md index 2e8c4c9709d5f..9870ef7c65513 100644 --- a/docs/csharp/whats-new/csharp-11.md +++ b/docs/csharp/whats-new/csharp-11.md @@ -1,26 +1,32 @@ --- title: What's new in C# 11 - C# Guide description: Get an overview of the new features coming in C# 11. -ms.date: 04/15/2022 +ms.date: 06/02/2022 --- # What's new in C# 11 -Beginning with the .NET 6.0.200 SDK or Visual Studio 2022 version 17.1, preview features in C# are available for you to try. - > [!IMPORTANT] > These are currently preview features. You must [set `` to `preview`](../language-reference/compiler-options/language.md#langversion) to enable these features. Any feature may change before its final release. These features may not all be released in C# 11. Some may remain in a preview phase for longer based on feedback on the feature. -The following features are available in the 6.0.200 version of the .NET SDK. They're available in Visual Studio 2022 version 17.2. +The following features are available in Visual Studio 2022 version 17.3: + +- [auto-default structs](#auto-default-struct) +- [pattern match `Span` on a constant `string`](#pattern-match-spanchar-or-readonlyspanchar-on-a-constant-string) + +The following features are available in Visual Studio 2022 version 17.2: + +- [Raw string literals](#raw-string-literals). +- [Improved method group conversion to delegate](#improved-method-group-conversion-to-delegate) +- [Warning wave 7](../language-reference/compiler-messages/warning-waves.md#cs8981---the-type-name-only-contains-lower-cased-ascii-characters) + +The following features are available in Visual Studio 2022 version 17.1: - [Generic attributes](#generic-attributes). - [static abstract members in interfaces](#static-abstract-members-in-interfaces). - [Newlines in string interpolation expressions](#newlines-in-string-interpolations). -- [Simplified parameter null checks](#simplified-parameter-null-checks). -- [Improved method group conversion to delegate](#improved-method-group-conversion-to-delegate) -- [Raw string literals](#raw-string-literals). +- [List patterns](#list-patterns). -You can download the latest .NET 6 SDK from the [.NET downloads page](https://dotnet.microsoft.com/download). You can also download [Visual Studio 2022](https://visualstudio.microsoft.com/vs/), which includes the .NET 6 SDK. -You can also try all these features with the preview release of the .NET 7 SDK, which can be downloaded from the [all .NET downloads](https://dotnet.microsoft.com/download/dotnet) page. +You can download the latest [Visual Studio 2022](https://visualstudio.microsoft.com/vs/). You can also try all these features with the preview release of the .NET 7 SDK, which can be downloaded from the [all .NET downloads](https://dotnet.microsoft.com/download/dotnet) page. ## Generic attributes @@ -96,31 +102,11 @@ The text inside the `{` and `}` characters for a string interpolation can now sp You can learn more about the newlines feature in the [string interpolations](../language-reference/tokens/interpolated.md) article in the language reference. -## Simplified parameter null checks - -The `!!` operator provides null validation parameter syntax. Adding `!!` to a parameter declaration instructs the compiler to add a runtime check for that parameter. For example: - -``` csharp -void Method(string name!!) -{ - // ... -} -``` +## List patterns -generates code similar to the following example: +*List patterns* extend pattern matching to match sequences of elements in a list or an array. For example, `sequence is [1, 2, 3]` is `true` when the `sequence` is an array or a list of three integers (1, 2, and 3). You can match elements using any pattern, including constant, type, property and relational patterns. The discard pattern (`_`) matches any single element, and the new *range pattern* (`..`) matches any sequence of zero or more elements. -``` csharp -void Method(string name) -{ - if (name is null) - { - throw new ArgumentNullException(nameof(name)); - } - // ... -} -``` - -This feature provides a concise syntax for runtime null parameter checking. It's intended for library authors to provide runtime checks even when APIs have been annotated for nullable reference types. These checks can simplify the necessary validation. You can learn more in the language reference article on [null parameter checks](../language-reference/operators/null-parameter-check.md). +You can learn more details about list patterns in the [pattern matching](../language-reference/operators/patterns.md#list-patterns) article in the language reference. ## Improved method group conversion to delegate @@ -132,7 +118,7 @@ Previous versions of the standard prohibited the compiler from reusing the deleg ## Raw string literals -*Raw string literals* are a new format for string literals. Raw string literals can contain arbitrary text, including whitespace, new lines, embedded quotes, and other special characters without requiring escape sequences. A raw string literal starts with at least three double-quote (""") characters. It ends with the same number of double-quote characters. Typically, a raw string literal uses three double quotes on a single line to start the string, and three double quotes on a separate line to end the string. The newlines following the opening quote and preceding the closing quote are not included in the final content: +*Raw string literals* are a new format for string literals. Raw string literals can contain arbitrary text, including whitespace, new lines, embedded quotes, and other special characters without requiring escape sequences. A raw string literal starts with at least three double-quote (""") characters. It ends with the same number of double-quote characters. Typically, a raw string literal uses three double quotes on a single line to start the string, and three double quotes on a separate line to end the string. The newlines following the opening quote and preceding the closing quote aren't included in the final content: ```csharp string longMessage = """ @@ -156,3 +142,11 @@ var location = $$""" The preceding example specifies that two braces starts and end an interpolation. The third repeated opening and closing brace are included in the output string. You can learn more about raw string literals in the article on [strings in the programming guide](../programming-guide/strings/index.md), and the language reference articles on [string literals](../language-reference/builtin-types/reference-types.md#string-literals) and [interpolated strings](../language-reference/tokens/interpolated.md). + +## Auto-default struct + +The C# 11 compiler ensures that all fields of a `struct` type are initialized to their default value as part of executing a constructor. This change means any field or auto property not initialized by a constructor is automatically initialized by the compiler. Structs where the constructor doesn't definitely assign all fields now compile, and any fields not explicitly initialized are set to their default value. You can read more about how this change affects struct initialization in the article on [structs](../language-reference/builtin-types/struct.md#struct-initialization-and-default-values). + +## Pattern match `Span` or `ReadOnlySpan` on a constant `string` + +You've been able to test if a `string` had a specific constant value using pattern matching for several releases. Now, you can use the same pattern matching logic with variables that are `Span` or `ReadOnlySpan`. diff --git a/docs/csharp/whats-new/csharp-9.md b/docs/csharp/whats-new/csharp-9.md index f611abd3945e1..9a8a7cfd1e5d1 100644 --- a/docs/csharp/whats-new/csharp-9.md +++ b/docs/csharp/whats-new/csharp-9.md @@ -26,6 +26,7 @@ C# 9.0 adds the following features and enhancements to the C# language: - [Support for code generators](#support-for-code-generators) - [Module initializers](~/_csharplang/proposals/csharp-9.0/module-initializers.md) - [New features for partial methods](~/_csharplang/proposals/csharp-9.0/extending-partial-methods.md) +- [Warning wave 5](../language-reference/compiler-messages/warning-waves.md#cs7023---a-static-type-is-used-in-an-is-or-as-expression) C# 9.0 is supported on **.NET 5**. For more information, see [C# language versioning](../language-reference/configure-language-version.md). @@ -197,7 +198,7 @@ For more information, see [Top-level statements](../fundamentals/program-structu C# 9 includes new pattern matching improvements: -- ***Type patterns*** match a variable is a type +- ***Type patterns*** match an object matches a particular type - ***Parenthesized patterns*** enforce or emphasize the precedence of pattern combinations - ***Conjunctive `and` patterns*** require both patterns to match - ***Disjunctive `or` patterns*** require either pattern to match diff --git a/docs/csharp/whats-new/tutorials/ranges-indexes.md b/docs/csharp/whats-new/tutorials/ranges-indexes.md index 7a4846d539d4b..186bedaa4fd88 100644 --- a/docs/csharp/whats-new/tutorials/ranges-indexes.md +++ b/docs/csharp/whats-new/tutorials/ranges-indexes.md @@ -36,7 +36,7 @@ string[] words = new string[] "quick", // 1 ^8 "brown", // 2 ^7 "fox", // 3 ^6 - "jumped", // 4 ^5 + "jumps", // 4 ^5 "over", // 5 ^4 "the", // 6 ^3 "lazy", // 7 ^2 @@ -50,7 +50,7 @@ You can retrieve the last word with the `^1` index. Add the following code below A range specifies the *start* and *end* of a range. Ranges are exclusive, meaning the *end* isn't included in the range. The range `[0..^0]` represents the entire range, just as `[0..sequence.Length]` represents the entire range. -The following code creates a subrange with the words "quick", "brown", and "fox". It includes `words[1]` through `words[3]`. The element `words[4]` isn't in the range. Add the following code to the same method. Copy and paste it at the bottom of the interactive window. +The following code creates a subrange with the words "quick", "brown", and "fox". It includes `words[1]` through `words[3]`. The element `words[4]` isn't in the range. [!code-csharp[Range](~/samples/snippets/csharp/tutorials/RangesIndexes/IndicesAndRanges.cs#IndicesAndRanges_Range)] @@ -98,3 +98,23 @@ In all cases, the range operator for allocates an array to s You'll often use ranges and indices when you want to analyze a portion of a larger sequence. The new syntax is clearer in reading exactly what portion of the sequence is involved. The local function `MovingAverage` takes a as its argument. The method then enumerates just that range when calculating the min, max, and average. Try the following code in your project: [!code-csharp[MovingAverages](~/samples/snippets/csharp/tutorials/RangesIndexes/IndicesAndRanges.cs#IndicesAndRanges_MovingAverage)] + +## A Note on Range Indices and Arrays + +When taking a range from an array, the result is an array that is copied from the initial array, rather than referenced. Modifying values in the resulting array will not change values in the initial array. + +For example: + +```csharp +var arrayOfFiveItems = new[] { 1, 2, 3, 4, 5 }; + +var firstThreeItems = arrayOfFiveItems[..3]; // contains 1,2,3 +firstThreeItems[0] = 11; // now contains 11,2,3 + +Console.WriteLine(string.Join(",", firstThreeItems)); +Console.WriteLine(string.Join(",", arrayOfFiveItems)); + +// output: +// 11,2,3 +// 1,2,3,4,5 +``` diff --git a/docs/csharp/whats-new/tutorials/top-level-statements.md b/docs/csharp/whats-new/tutorials/top-level-statements.md index 804d1499b4053..5f59b7d805c8e 100644 --- a/docs/csharp/whats-new/tutorials/top-level-statements.md +++ b/docs/csharp/whats-new/tutorials/top-level-statements.md @@ -15,7 +15,7 @@ In this tutorial, you'll learn how to: ## Prerequisites -You'll need to set up your machine to run .NET 6, which includes the C# 10 compiler. The C# 10 compiler is available starting with [Visual Studio 2022](https://visualstudio.microsoft.com/vs/preview/) or [.NET 6 SDK](https://dot.net/get-dotnet6). +You'll need to set up your machine to run .NET 6, which includes the C# 10 compiler. The C# 10 compiler is available starting with [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) or [.NET 6 SDK](https://dot.net/get-dotnet6). This tutorial assumes you're familiar with C# and .NET, including either Visual Studio or the .NET CLI. diff --git a/docs/devops/create-dotnet-github-action.md b/docs/devops/create-dotnet-github-action.md index 6c4c343523b99..999ce59dc76a9 100644 --- a/docs/devops/create-dotnet-github-action.md +++ b/docs/devops/create-dotnet-github-action.md @@ -3,7 +3,7 @@ title: "Tutorial: Create a GitHub Action with .NET" description: Learn how to create a GitHub Action with a containerized .NET app. author: IEvangelist ms.author: dapine -ms.date: 02/16/2022 +ms.date: 05/18/2022 ms.topic: tutorial recommendations: false --- @@ -78,7 +78,7 @@ GitHub Actions support two variations of app development, either - JavaScript (optionally [TypeScript](https://www.typescriptlang.org)) - Docker container (any app that runs on [Docker](https://docs.github.com/actions/creating-actions/creating-a-docker-container-action)) -Since .NET is *not* natively supported by GitHub Actions, the .NET app needs to be containerized. For more information, see [Containerize a .NET app](../core/docker/build-container.md). +The virtual environment where the GitHub Action is hosted may or may not have .NET installed. For information about what is preinstalled in the target environment, see [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). While it's possible to run .NET CLI commands from the GitHub Action workflows, for a more fully functioning .NET-based GitHub Action, we recommend that you containerize the app. For more information, see [Containerize a .NET app](../core/docker/build-container.md). ### The Dockerfile @@ -125,6 +125,12 @@ The preceding *action.yml* file defines: For more information, see [Metadata syntax for GitHub Actions](https://docs.github.com/actions/creating-actions/metadata-syntax-for-github-actions). +### Pre-defined environment variables + +With GitHub Actions, you'll get a lot of [environment variables](https://docs.github.com/actions/learn-github-actions/environment-variables#default-environment-variables) by default. For instance, the variable `GITHUB_REF` will always contain a reference to the branch or tag that triggered the workflow run. `GITHUB_REPOSITORY` has the owner and repository name, for example, `dotnet/docs`. + +You should explore the pre-defined environment variables and use them accordingly. + ## Workflow composition With the [.NET app containerized](#prepare-the-net-app-for-github-actions), and the [action inputs and outputs](#define-action-inputs-and-outputs) defined, you're ready to consume the action. GitHub Actions are *not* required to be published in the GitHub Marketplace to be used. Workflows are defined in the *.github/workflows* directory of a repository as YAML files. @@ -184,13 +190,35 @@ The workflow specifies that `on` a `push` to the `main` branch, the action is tr :::image type="content" source="media/action-log.png" lightbox="media/action-log.png" border="true" alt-text=".NET code metrics - GitHub Action log"::: -## See also +## Performance improvements + +If you followed along the sample, you might have noticed that every time this action is used, it will do a **docker build** for that image. So, every trigger is faced with some time to build the container before running it. Before releasing your GitHub Action to the marketplace, you should: - +1. (automatically) Build the Docker image +2. Push the docker image to the GitHub Container Registry (or any other public container registry) +3. Change the action to not build the image, but to use an image from a public registry. + +```yaml +# Rest of action.yml content removed for readability +# using Dockerfile +runs: + using: 'docker' + image: 'Dockerfile' # Change this line +# using container image from public registry +runs: + using: 'docker' + image: 'docker://ghcr.io/some-user/some-registry' # Starting with docker:// is important!! +``` + +For more information, see [GitHub Docs: Working with the Container registry](https://docs.github.com/packages/working-with-a-github-packages-registry/working-with-the-container-registry). + +## See also - [.NET Generic Host](../core/extensions/generic-host.md) - [Dependency injection in .NET](../core/extensions/dependency-injection.md) +- [DevOps for ASP.NET Core Developers](../architecture/devops-for-aspnet-developers/index.md) - [Code metrics values](/visualstudio/code-quality/code-metrics-values) +- [Open-source GitHub Action build in .NET](https://github.com/svrooij/dotnet-feeder/) with a [workflow](https://github.com/svrooij/dotnet-feeder/blob/main/.github/workflows/build.yml) for building and pushing the docker image automatically. ## Next steps diff --git a/docs/framework/configure-apps/file-schema/index.md b/docs/framework/configure-apps/file-schema/index.md index 5f4084041455a..02854940cdc57 100644 --- a/docs/framework/configure-apps/file-schema/index.md +++ b/docs/framework/configure-apps/file-schema/index.md @@ -1,6 +1,6 @@ --- -description: "Learn more about: Configuration file schema for the .NET Framework" -title: "Configuration file schema for the .NET Framework" +description: "Learn more about: Configuration file schema for .NET Framework" +title: "Configuration file schema for .NET Framework" ms.date: "05/01/2017" helpviewer_keywords: - ".NET Framework application configuration, configuration schema" @@ -23,7 +23,7 @@ helpviewer_keywords: - "configuration file reference [.NET Framework]" ms.assetid: 69003d39-dc8a-460c-a6be-e6d93e690b38 --- -# Configuration file schema for the .NET Framework +# Configuration file schema for .NET Framework Configuration files are standard XML files that you can use to change settings and set policies for your apps. The .NET Framework configuration schema consists of elements that you can use in configuration files to control the behavior of your apps. The table of contents for this section reflects the schema hierarchy for startup, runtime, network, and other types of configuration settings. diff --git a/docs/framework/configure-apps/file-schema/runtime/add-element-for-namedcaches.md b/docs/framework/configure-apps/file-schema/runtime/add-element-for-namedcaches.md index c41eb1151e805..8ed72e12f166f 100644 --- a/docs/framework/configure-apps/file-schema/runtime/add-element-for-namedcaches.md +++ b/docs/framework/configure-apps/file-schema/runtime/add-element-for-namedcaches.md @@ -80,4 +80,5 @@ Adds a `namedCache` entry to the `namedCaches` collection for a memory cache. ## See also +- [Configure apps by using configuration files](../../index.md) - [\ Element (Cache Settings)](namedcaches-element-cache-settings.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element.md b/docs/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element.md index f944ea4336f9d..5219ba4c11a8d 100644 --- a/docs/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element.md @@ -109,6 +109,7 @@ Specifies that the Windows identity always flows across asynchronous points, reg ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [\ Element](legacyimpersonationpolicy-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element.md b/docs/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element.md index c5e69e858185c..a7093281262c9 100644 --- a/docs/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element.md @@ -1,7 +1,7 @@ --- -description: "Learn more about: element" +description: "Learn more about the AppContextSwitchOverrides element that defines switches used by AppContext to provide an opt-out mechanism for new functionality." title: "AppContextSwitchOverrides Element" -ms.date: "04/18/2019" +ms.date: 05/31/2022 helpviewer_keywords: - "AppContextSwitchOverrides" - "compatibility switches" @@ -117,6 +117,7 @@ Defines one or more switches used by the class to provi |`Switch.System.Windows.Data.Binding.`
`IListIndexerHidesCustomIndexer`|Controls whether custom IList indexers are used incorrectly (`true`) or correctly (`false`) by the class.|.NET Framework 4.8| |`Switch.System.Windows.DoNotScaleForDpiChanges`|Determines whether DPI changes occur on a per-system (a value of `false`) or per-monitor basis (a value of `true`).|.NET Framework 4.6.2| |`Switch.System.Windows.`
`DoNotUsePresentationDpiCapabilityTier2OrGreater`|Controls whether improvements in sizing of controls in a when WPF is run in per-monitor aware mode are disabled (`true`) or enabled (`false`).|.NET Framework 4.8| +|`Switch.System.Windows.Forms.`
`DisconnectUiaProvidersOnWmDestroy`|Controls whether providers are disconnected when the corresponding control window is destroyed (`true`) or not (`false`). This switch provides an opt-in to a security fix to address a leak of objects.|.NET Framework 4.8| |`Switch.System.Windows.Forms.`
`DomainUpDown.UseLegacyScrolling`|Determines whether the developer needs to specially handle the action when control text is present. `true` to handle the action; `false` for the and actions to be properly in sync.|.NET Framework 4.7.2| |`Switch.System.Windows.Forms.`
`DontSupportReentrantFilterMessage`|Opts out of the code that allows a custom implementation to safely filter messages without throwing an exception when the method is called. For more information, see [Mitigation: Custom IMessageFilter.PreFilterMessage Implementations](../../../migration-guide/mitigation-custom-imessagefilter-prefiltermessage-implementations.md).|.NET Framework 4.6.1| |`Switch.System.Windows.Forms.`
`UseLegacyContextMenuStripSourceControlValue`|Determines whether the property returns the source control when the user opens the menu from a nested control. `true` to return `null`, the legacy behavior; `false` to return the source control.|.NET Framework 4.7.2| @@ -134,9 +135,9 @@ Defines one or more switches used by the class to provi |`Switch.System.Xml.`
`IgnoreEmptyKeySequences`|Controls whether empty key sequences in compound keys are ignored by XSD schema validation. For more information, see [Mitigation: XML Schema Validation](../../../migration-guide/mitigation-xml-schema-validation.md).|.NET Framework 4.6| > [!NOTE] -> Instead of adding an `AppContextSwitchOverrides` element to an application configuration file, you can also set the switches programmatically by calling the `static` (in C#) or `Shared` (in Visual Basic) method. +> Instead of adding an `AppContextSwitchOverrides` element to an application configuration file, you can also set the switches programmatically by calling the method. - Library developers can also define custom switches to allow callers to opt out of changed functionality introduced in later versions of their libraries. For more information, see the class. + Library developers can also define custom switches to allow callers to opt out of changed functionality introduced in later versions of their libraries. For more information, see the class. ## Switches in ASP.NET apps @@ -153,7 +154,7 @@ The following example uses the `` element to add two settings to the ` @@ -176,6 +177,7 @@ The following example uses the `` element to add two settings to the ` - [\ Element](runtime-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/appdomainmanagerassembly-element.md b/docs/framework/configure-apps/file-schema/runtime/appdomainmanagerassembly-element.md index b2f7ed8ef7f36..249c4d3f2bd26 100644 --- a/docs/framework/configure-apps/file-schema/runtime/appdomainmanagerassembly-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/appdomainmanagerassembly-element.md @@ -73,6 +73,7 @@ Specifies the assembly that provides the application domain manager for the defa ## See also +- [Configure apps by using configuration files](../../index.md) - - - [\ Element](appdomainmanagertype-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/appdomainmanagertype-element.md b/docs/framework/configure-apps/file-schema/runtime/appdomainmanagertype-element.md index cdfc0923cb918..bcf5f8c97823c 100644 --- a/docs/framework/configure-apps/file-schema/runtime/appdomainmanagertype-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/appdomainmanagertype-element.md @@ -73,6 +73,7 @@ Specifies the type that serves as the application domain manager for the default ## See also +- [Configure apps by using configuration files](../../index.md) - - - [\ Element](appdomainmanagerassembly-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/appdomainresourcemonitoring-element.md b/docs/framework/configure-apps/file-schema/runtime/appdomainresourcemonitoring-element.md index 9cf1a9c357119..4c811bca4251b 100644 --- a/docs/framework/configure-apps/file-schema/runtime/appdomainresourcemonitoring-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/appdomainresourcemonitoring-element.md @@ -72,6 +72,7 @@ Instructs the runtime to collect statistics on all application domains in the pr ## See also +- [Configure apps by using configuration files](../../index.md) - - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/assemblybinding-element-for-runtime.md b/docs/framework/configure-apps/file-schema/runtime/assemblybinding-element-for-runtime.md index 11532aaced9a1..ccafd5736e7a0 100644 --- a/docs/framework/configure-apps/file-schema/runtime/assemblybinding-element-for-runtime.md +++ b/docs/framework/configure-apps/file-schema/runtime/assemblybinding-element-for-runtime.md @@ -90,6 +90,7 @@ Contains information about assembly version redirection and the locations of ass ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Redirecting Assembly Versions](../../redirect-assembly-versions.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/assemblyidentity-element-for-runtime.md b/docs/framework/configure-apps/file-schema/runtime/assemblyidentity-element-for-runtime.md index 8b26983a7768a..5462ac1c8a741 100644 --- a/docs/framework/configure-apps/file-schema/runtime/assemblyidentity-element-for-runtime.md +++ b/docs/framework/configure-apps/file-schema/runtime/assemblyidentity-element-for-runtime.md @@ -121,6 +121,7 @@ culture="assembly culture"/> ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Redirecting Assembly Versions](../../redirect-assembly-versions.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/bindingredirect-element.md b/docs/framework/configure-apps/file-schema/runtime/bindingredirect-element.md index 1cf788c4e2065..a750ddbcf4978 100644 --- a/docs/framework/configure-apps/file-schema/runtime/bindingredirect-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/bindingredirect-element.md @@ -85,6 +85,7 @@ newVersion="new assembly version"/> ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Redirecting Assembly Versions](../../redirect-assembly-versions.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/bypasstrustedappstrongnames-element.md b/docs/framework/configure-apps/file-schema/runtime/bypasstrustedappstrongnames-element.md index 33020bfc06109..d0a30158d9f54 100644 --- a/docs/framework/configure-apps/file-schema/runtime/bypasstrustedappstrongnames-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/bypasstrustedappstrongnames-element.md @@ -83,6 +83,7 @@ The following example shows how to specify the behavior that validates the stron ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [How to: Disable the strong-name bypass feature](../../../../standard/assembly/disable-strong-name-bypass-feature.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/clear-element-for-namedcaches.md b/docs/framework/configure-apps/file-schema/runtime/clear-element-for-namedcaches.md index f4fc87ce4cc16..1481f214833dd 100644 --- a/docs/framework/configure-apps/file-schema/runtime/clear-element-for-namedcaches.md +++ b/docs/framework/configure-apps/file-schema/runtime/clear-element-for-namedcaches.md @@ -54,4 +54,5 @@ Clears all `namedCache` entries in the `namedCaches` collection for a memory cac ## See also +- [Configure apps by using configuration files](../../index.md) - [\ Element (Cache Settings)](namedcaches-element-cache-settings.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/codebase-element.md b/docs/framework/configure-apps/file-schema/runtime/codebase-element.md index d8d5959af1ff4..873770abdd510 100644 --- a/docs/framework/configure-apps/file-schema/runtime/codebase-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/codebase-element.md @@ -90,7 +90,8 @@ The following example shows how to specify where the runtime can find an assembl ## See also -- [Runtime settings schema](index.md) +- [Configure apps by using configuration files](../../index.md) +- [Runtime Settings Schema](index.md) - [Configuration file schema](../index.md) - [Specify an assembly's location](../../../../standard/assembly/location.md) - [How the runtime locates assemblies](../../../deployment/how-the-runtime-locates-assemblies.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/compatsortnlsversion-element.md b/docs/framework/configure-apps/file-schema/runtime/compatsortnlsversion-element.md index de587587e15e6..1147b57435621 100644 --- a/docs/framework/configure-apps/file-schema/runtime/compatsortnlsversion-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/compatsortnlsversion-element.md @@ -93,5 +93,6 @@ sta equals a in the sort order. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/crst-disablespinwait-element.md b/docs/framework/configure-apps/file-schema/runtime/crst-disablespinwait-element.md index e28d626e1dc51..b3043c57729ad 100644 --- a/docs/framework/configure-apps/file-schema/runtime/crst-disablespinwait-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/crst-disablespinwait-element.md @@ -63,5 +63,6 @@ The following example disables spin-waiting in critical sections when contended. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/dependentassembly-element.md b/docs/framework/configure-apps/file-schema/runtime/dependentassembly-element.md index 0889b25cba485..2e854fba34c9f 100644 --- a/docs/framework/configure-apps/file-schema/runtime/dependentassembly-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/dependentassembly-element.md @@ -79,6 +79,7 @@ Encapsulates binding policy and assembly location for each assembly. Use one `de ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Redirecting Assembly Versions](../../redirect-assembly-versions.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/developmentmode-element.md b/docs/framework/configure-apps/file-schema/runtime/developmentmode-element.md index 07a5651159246..80e8272e38c06 100644 --- a/docs/framework/configure-apps/file-schema/runtime/developmentmode-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/developmentmode-element.md @@ -71,6 +71,7 @@ Specifies whether the runtime searches for assemblies in directories specified b ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [How to: Locate Assemblies by Using DEVPATH](../../how-to-locate-assemblies-by-using-devpath.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/disablecachingbindingfailures-element.md b/docs/framework/configure-apps/file-schema/runtime/disablecachingbindingfailures-element.md index 643066868feb4..1f6cde902dfb4 100644 --- a/docs/framework/configure-apps/file-schema/runtime/disablecachingbindingfailures-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/disablecachingbindingfailures-element.md @@ -80,6 +80,7 @@ Specifies whether to disable the caching of binding failures that occur because ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [How the Runtime Locates Assemblies](../../../deployment/how-the-runtime-locates-assemblies.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/disablecommitthreadstack-element.md b/docs/framework/configure-apps/file-schema/runtime/disablecommitthreadstack-element.md index db3e4d0b0a4b7..452cdadcb39b1 100644 --- a/docs/framework/configure-apps/file-schema/runtime/disablecommitthreadstack-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/disablecommitthreadstack-element.md @@ -73,5 +73,6 @@ Specifies whether the full thread stack is committed when a thread is started. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/disablefusionupdatesfromadmanager-element.md b/docs/framework/configure-apps/file-schema/runtime/disablefusionupdatesfromadmanager-element.md index b78746b288f76..af9f9518fc97b 100644 --- a/docs/framework/configure-apps/file-schema/runtime/disablefusionupdatesfromadmanager-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/disablefusionupdatesfromadmanager-element.md @@ -75,6 +75,7 @@ Specifies whether the default behavior, which is to allow the runtime host to ov ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [How the Runtime Locates Assemblies](../../../deployment/how-the-runtime-locates-assemblies.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/disablestackoverflowprobing-element.md b/docs/framework/configure-apps/file-schema/runtime/disablestackoverflowprobing-element.md new file mode 100644 index 0000000000000..79e31380824fc --- /dev/null +++ b/docs/framework/configure-apps/file-schema/runtime/disablestackoverflowprobing-element.md @@ -0,0 +1,48 @@ +--- +description: "Learn more about the element" +title: " Element" +ms.date: 04/20/2022 +--- +# \ Element + +Specifies whether stack-overflow probing is disabled. + +[**\**](../configuration-element.md)\ +  [**\**](runtime-element.md)\ +    **\** + +## Syntax + +```xml + +``` + +## Attribute + +| Attribute | Description | +|-----------|--------------------------------------------------------------------------------------| +| `enabled` | Required attribute.

Specifies whether stack-overflow probing is disabled. | + +### enabled Attribute + +| Value | Description | +|-------|-------------------------------------| +| true | Stack-overflow probing is enabled. | +| false | Stack-overflow probing is disabled. | + +### Parent Elements + +|Element|Description| +|-------------|-----------------| +|`configuration`|The root element in every configuration file used by the common language runtime and .NET Framework applications.| +|`runtime`|Contains information about runtime initialization options.| + +## Remarks + +The `` specifies whether stack-overflow probing is disabled. If you specify a very small stack size when constructing a by calling , you might need to disable stack-overflow probing. When the stack is severely constrained, the probing can itself cause a stack overflow. + +## See also + +- [Configure apps by using configuration files](../../index.md) +- [\ Element](runtime-element.md) +- [\ Element](../configuration-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/enableampmparseadjustment-element.md b/docs/framework/configure-apps/file-schema/runtime/enableampmparseadjustment-element.md index ac641e5c7d706..2c87a847f0ed5 100644 --- a/docs/framework/configure-apps/file-schema/runtime/enableampmparseadjustment-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/enableampmparseadjustment-element.md @@ -80,5 +80,6 @@ Determines whether date and time parsing methods use an adjusted set of rules to ## See also +- [Configure apps by using configuration files](../../index.md) - [\ Element](runtime-element.md) - [\ Element](../configuration-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/enforcefipspolicy-element.md b/docs/framework/configure-apps/file-schema/runtime/enforcefipspolicy-element.md index 8a6c543306228..60e8f05ea4da0 100644 --- a/docs/framework/configure-apps/file-schema/runtime/enforcefipspolicy-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/enforcefipspolicy-element.md @@ -71,6 +71,7 @@ Specifies whether to enforce a computer configuration requirement that cryptogra ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Cryptography Model](../../../../standard/security/cryptography-model.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/etwenable-element.md b/docs/framework/configure-apps/file-schema/runtime/etwenable-element.md index 6d10813f3c8fd..7be7c687937a5 100644 --- a/docs/framework/configure-apps/file-schema/runtime/etwenable-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/etwenable-element.md @@ -70,6 +70,7 @@ Specifies whether to enable event tracing for Windows (ETW) for common language ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Controlling .NET Framework Logging](../../../performance/controlling-logging.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/forceperformancecounteruniquesharedmemoryreads-element.md b/docs/framework/configure-apps/file-schema/runtime/forceperformancecounteruniquesharedmemoryreads-element.md index 5f0fc5b0ef6d1..bfee73d57e241 100644 --- a/docs/framework/configure-apps/file-schema/runtime/forceperformancecounteruniquesharedmemoryreads-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/forceperformancecounteruniquesharedmemoryreads-element.md @@ -79,5 +79,6 @@ enabled="true|false"/> ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element.md b/docs/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element.md index cbfdcd14944f1..f28332ea7f021 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element.md @@ -47,7 +47,7 @@ None. ## Remarks - Using this element in your application configuration file enables arrays that are larger than 2 GB in size, but does not change other limits on object size or array size: + Using this element in your [application configuration file](../../index.md) enables arrays that are larger than 2 GB in size, but does not change other limits on object size or array size: - The maximum number of elements in an array is . @@ -60,7 +60,7 @@ None. ## Example - The following example shows how to enable this feature for an application. + The following *app.config* file snippet shows how to enable this feature for a .NET Framework application. ```xml @@ -76,5 +76,6 @@ None. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gcconcurrent-element.md b/docs/framework/configure-apps/file-schema/runtime/gcconcurrent-element.md index 6f6a5ae717c7c..36458d2ac9964 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gcconcurrent-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gcconcurrent-element.md @@ -93,6 +93,7 @@ The following example enables background garbage collection: ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Fundamentals of Garbage Collection](../../../../standard/garbage-collection/fundamentals.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gcconservememory-element.md b/docs/framework/configure-apps/file-schema/runtime/gcconservememory-element.md index d74d9d20f3ef0..99bea4da1239c 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gcconservememory-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gcconservememory-element.md @@ -53,6 +53,7 @@ This setting was introduced in .NET Framework 4.8. ## See also +- [Configure apps by using configuration files](../../index.md) - [Run-time settings schema](index.md) - [Configuration file schema](../index.md) - [Fundamentals of garbage collection](../../../../standard/garbage-collection/fundamentals.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gccpugroup-element.md b/docs/framework/configure-apps/file-schema/runtime/gccpugroup-element.md index b5fef4fc006f7..27d190bd95534 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gccpugroup-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gccpugroup-element.md @@ -72,6 +72,7 @@ The following example shows how to enable garbage collection for multiple CPU gr ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Disable concurrent garbage collection](gcconcurrent-element.md#to-disable-background-garbage-collection) diff --git a/docs/framework/configure-apps/file-schema/runtime/gcheapaffinitizemask-element.md b/docs/framework/configure-apps/file-schema/runtime/gcheapaffinitizemask-element.md index 2f6e05fc40245..5f6053246f995 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gcheapaffinitizemask-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gcheapaffinitizemask-element.md @@ -82,6 +82,7 @@ The following example indicates that an application uses server GC with 10 heaps ## See also +- [Configure apps by using configuration files](../../index.md) - - [GCNoAffinitize element](gcnoaffinitize-element.md) - [GCHeapCount element](gcheapcount-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gcheapcount-element.md b/docs/framework/configure-apps/file-schema/runtime/gcheapcount-element.md index 6e2d54e9a8ef5..2abf7c6bf0e14 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gcheapcount-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gcheapcount-element.md @@ -90,6 +90,7 @@ The following example does not affinitize server GC threads and limits the numbe ## See also +- [Configure apps by using configuration files](../../index.md) - - [GCNoAffinitize element](gcnoaffinitize-element.md) - [GCHeapAffinitizeMask element](gcheapaffinitizemask-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gclohthreshold-element.md b/docs/framework/configure-apps/file-schema/runtime/gclohthreshold-element.md index d44d98d5081d2..8a1aee433476a 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gclohthreshold-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gclohthreshold-element.md @@ -50,6 +50,7 @@ This setting was introduced in .NET Framework 4.8. ## See also +- [Configure apps by using configuration files](../../index.md) - [Run-time settings schema](index.md) - [Configuration file schema](../index.md) - [Fundamentals of garbage collection](../../../../standard/garbage-collection/fundamentals.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gcnoaffinitize-element.md b/docs/framework/configure-apps/file-schema/runtime/gcnoaffinitize-element.md index 0eaee47c550e4..0a465461abf1b 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gcnoaffinitize-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gcnoaffinitize-element.md @@ -84,6 +84,7 @@ The following example does not affinitize server GC threads and limits the numbe ## See also +- [Configure apps by using configuration files](../../index.md) - - [GCHeapAffinitizeMask element](gcheapaffinitizemask-element.md) - [GCHeapCount element](gcheapcount-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/gcserver-element.md b/docs/framework/configure-apps/file-schema/runtime/gcserver-element.md index ea5b00a670eb4..77bf77e7fa3d3 100644 --- a/docs/framework/configure-apps/file-schema/runtime/gcserver-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/gcserver-element.md @@ -86,6 +86,7 @@ The following example enables server garbage collection: ## See also +- [Configure apps by using configuration files](../../index.md) - - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/generatepublisherevidence-element.md b/docs/framework/configure-apps/file-schema/runtime/generatepublisherevidence-element.md index bfd513cc86460..9e6b3295e8670 100644 --- a/docs/framework/configure-apps/file-schema/runtime/generatepublisherevidence-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/generatepublisherevidence-element.md @@ -15,6 +15,8 @@ Specifies whether the runtime creates ev   [**\**](runtime-element.md)\     **\** +[!INCLUDE [cas-deprecated](../../../../../includes/cas-deprecated.md)] + ## Syntax ```xml @@ -78,5 +80,6 @@ Specifies whether the runtime creates ev ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/index.md b/docs/framework/configure-apps/file-schema/runtime/index.md index 2c89f6160668c..b48d8e8aad1e4 100644 --- a/docs/framework/configure-apps/file-schema/runtime/index.md +++ b/docs/framework/configure-apps/file-schema/runtime/index.md @@ -1,16 +1,16 @@ --- -description: "Learn more about: Run-time settings schema" +description: "Learn more about: Runtime settings schema" title: "Runtime Settings Schema" -ms.date: "03/30/2017" +ms.date: 04/20/2022 helpviewer_keywords: - "schema runtime settings" - "configuration schema [.NET Framework], runtime settings" - "runtime settings schema" ms.assetid: f04816ab-110d-4e28-9283-845d6d9a4a68 --- -# Run-time settings schema +# Runtime settings schema -Run-time settings are used by the common language runtime to configure applications that target the .NET Framework. +Runtime settings are used by the common language runtime to configure applications that target .NET Framework. This article shows the schema for runtime settings in an [application configuration file](../../index.md). ## The \ section and its parent and child elements @@ -36,6 +36,7 @@ Run-time settings are used by the common language runtime to configure applicati     [\](disablecachingbindingfailures-element.md)\     [\](disablecommitthreadstack-element.md)\     [\](disablefusionupdatesfromadmanager-element.md)\ +    [\](disablestackoverflowprobing-element.md)\     [\](enableampmparseadjustment-element.md)\     [\](enforcefipspolicy-element.md)\     [\](etwenable-element.md)\ @@ -93,6 +94,7 @@ Run-time settings are used by the common language runtime to configure applicati |[\](disablecachingbindingfailures-element.md)|Specifies whether the caching of binding failures, which is the default behavior in the .NET Framework 2.0, is disabled.| |[\](disablecommitthreadstack-element.md)|Specifies whether the full thread stack is committed when a thread starts.| |[\](disablefusionupdatesfromadmanager-element.md)|Specifies whether the default behavior, which is to allow the runtime host to override configuration settings for an application domain, is disabled.| +|[\](disablestackoverflowprobing-element.md)|Specifies whether stack-overflow probing is disabled.| |[\](enableampmparseadjustment-element.md)|Determines whether date and time parsing methods use an adjusted set of rules to parse date strings that contain only a day, month, hour, and AM/PM designator.| |[\](enforcefipspolicy-element.md)|Specifies whether to enforce a computer configuration requirement that cryptographic algorithms must comply with the Federal Information Processing Standards (FIPS).| |[\](etwenable-element.md)|Specifies whether to enable event tracing for Windows (ETW) for common language runtime events.| diff --git a/docs/framework/configure-apps/file-schema/runtime/legacycorruptedstateexceptionspolicy-element.md b/docs/framework/configure-apps/file-schema/runtime/legacycorruptedstateexceptionspolicy-element.md index 01057ddba7ca0..742183aaeff47 100644 --- a/docs/framework/configure-apps/file-schema/runtime/legacycorruptedstateexceptionspolicy-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/legacycorruptedstateexceptionspolicy-element.md @@ -77,6 +77,7 @@ Specifies whether the common language runtime allows managed code to catch acces ## See also +- [Configure apps by using configuration files](../../index.md) - - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/legacyimpersonationpolicy-element.md b/docs/framework/configure-apps/file-schema/runtime/legacyimpersonationpolicy-element.md index d23f209afd2bc..17f5ba1e5ddc7 100644 --- a/docs/framework/configure-apps/file-schema/runtime/legacyimpersonationpolicy-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/legacyimpersonationpolicy-element.md @@ -116,6 +116,7 @@ Specifies that the Windows identity does not flow across asynchronous points, re ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [\ Element](alwaysflowimpersonationpolicy-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/loadfromremotesources-element.md b/docs/framework/configure-apps/file-schema/runtime/loadfromremotesources-element.md index 2ea4549acdc6f..e9c0db67c516a 100644 --- a/docs/framework/configure-apps/file-schema/runtime/loadfromremotesources-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/loadfromremotesources-element.md @@ -113,6 +113,7 @@ The following example shows how to grant full trust to assemblies loaded from re ## See also +- [Configure apps by using configuration files](../../index.md) - [More Implicit Uses of CAS Policy: loadFromRemoteSources](/archive/blogs/shawnfa/more-implicit-uses-of-cas-policy-loadfromremotesources) - [How to: Run Partially Trusted Code in a Sandbox](/previous-versions/dotnet/framework/code-access-security/how-to-run-partially-trusted-code-in-a-sandbox) - [Runtime Settings Schema](index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/memorycache-element-cache-settings.md b/docs/framework/configure-apps/file-schema/runtime/memorycache-element-cache-settings.md index e15acf1d5503f..42f8af861e424 100644 --- a/docs/framework/configure-apps/file-schema/runtime/memorycache-element-cache-settings.md +++ b/docs/framework/configure-apps/file-schema/runtime/memorycache-element-cache-settings.md @@ -93,6 +93,7 @@ Defines an element that is used to configure a cache that is based on the - [\ Element (Cache Settings)](system-runtime-caching-element-cache-settings.md) - [\ Element (Cache Settings)](namedcaches-element-cache-settings.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/namedcaches-element-cache-settings.md b/docs/framework/configure-apps/file-schema/runtime/namedcaches-element-cache-settings.md index 6f93ce7259884..4eb767c890134 100644 --- a/docs/framework/configure-apps/file-schema/runtime/namedcaches-element-cache-settings.md +++ b/docs/framework/configure-apps/file-schema/runtime/namedcaches-element-cache-settings.md @@ -91,4 +91,5 @@ Specifies a collection of configuration settings for the named Element (Cache Settings)](memorycache-element-cache-settings.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/netfx40-legacysecuritypolicy-element.md b/docs/framework/configure-apps/file-schema/runtime/netfx40-legacysecuritypolicy-element.md index 64e45a3741667..e541e94682f2b 100644 --- a/docs/framework/configure-apps/file-schema/runtime/netfx40-legacysecuritypolicy-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/netfx40-legacysecuritypolicy-element.md @@ -13,7 +13,9 @@ Specifies whether the runtime uses legacy code access security (CAS) policy. [**\**](../configuration-element.md)\   [**\**](runtime-element.md)\ -    **\** +    **\** + +[!INCLUDE [cas-deprecated](../../../../../includes/cas-deprecated.md)] ## Syntax @@ -85,5 +87,6 @@ The following example shows how to enable legacy CAS policy for an application. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/netfx40-pinvokestackresilience-element.md b/docs/framework/configure-apps/file-schema/runtime/netfx40-pinvokestackresilience-element.md index b9aba7ab25ca5..5d75281993a14 100644 --- a/docs/framework/configure-apps/file-schema/runtime/netfx40-pinvokestackresilience-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/netfx40-pinvokestackresilience-element.md @@ -77,6 +77,7 @@ The following example shows how to opt into increased resilience against incorre ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [pInvokeStackImbalance](../../../debug-trace-profile/pinvokestackimbalance-mda.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/netfx45-cultureawarecomparergethashcode-longstrings-element.md b/docs/framework/configure-apps/file-schema/runtime/netfx45-cultureawarecomparergethashcode-longstrings-element.md index c637a9745d0d9..5d39728b2f797 100644 --- a/docs/framework/configure-apps/file-schema/runtime/netfx45-cultureawarecomparergethashcode-longstrings-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/netfx45-cultureawarecomparergethashcode-longstrings-element.md @@ -60,6 +60,7 @@ By default, the common language runtime allocates a variable amount of memory fo ## See also +- [Configure apps by using configuration files](../../index.md) - - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/prefercominsteadofmanagedremoting-element.md b/docs/framework/configure-apps/file-schema/runtime/prefercominsteadofmanagedremoting-element.md index 869fdcb04c85e..d0b627421512d 100644 --- a/docs/framework/configure-apps/file-schema/runtime/prefercominsteadofmanagedremoting-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/prefercominsteadofmanagedremoting-element.md @@ -73,5 +73,6 @@ Specifies whether the runtime will use COM interop instead of remoting for all c ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/probing-element.md b/docs/framework/configure-apps/file-schema/runtime/probing-element.md index 523e60e6e2e5b..4cb3008f1179d 100644 --- a/docs/framework/configure-apps/file-schema/runtime/probing-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/probing-element.md @@ -64,7 +64,8 @@ None. ## See also -- [Runtime settings schema](index.md) +- [Configure apps by using configuration files](../../index.md) +- [Runtime Settings Schema](index.md) - [Configuration file schema](../index.md) - [Specify an assembly's location](../../../../standard/assembly/location.md) - [How the runtime locates assemblies](../../../deployment/how-the-runtime-locates-assemblies.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/publisherpolicy-element.md b/docs/framework/configure-apps/file-schema/runtime/publisherpolicy-element.md index f5527d6391455..43ca25ec3b6fa 100644 --- a/docs/framework/configure-apps/file-schema/runtime/publisherpolicy-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/publisherpolicy-element.md @@ -87,6 +87,7 @@ None. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [How the Runtime Locates Assemblies](../../../deployment/how-the-runtime-locates-assemblies.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/qualifyassembly-element.md b/docs/framework/configure-apps/file-schema/runtime/qualifyassembly-element.md index 140decc71787d..6aa83cac437d1 100644 --- a/docs/framework/configure-apps/file-schema/runtime/qualifyassembly-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/qualifyassembly-element.md @@ -75,6 +75,7 @@ Specifies the full name of the assembly that should be dynamically loaded when a ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [How the Runtime Locates Assemblies](../../../deployment/how-the-runtime-locates-assemblies.md) - [Partial Assembly References](/previous-versions/dotnet/netframework-4.0/0a7zy9z5(v=vs.100)) diff --git a/docs/framework/configure-apps/file-schema/runtime/relativebindforresources-element.md b/docs/framework/configure-apps/file-schema/runtime/relativebindforresources-element.md index dc37c25aa493f..1a44e78565c26 100644 --- a/docs/framework/configure-apps/file-schema/runtime/relativebindforresources-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/relativebindforresources-element.md @@ -67,6 +67,7 @@ Setting the `enabled` attribute of the `` element to ` ## See also +- [Configure apps by using configuration files](../../index.md) - [Package and deploy resources](../../../../core/extensions/package-and-deploy-resources.md) - [Runtime settings schema](index.md) - [Configuration file schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/remove-element-for-namedcaches.md b/docs/framework/configure-apps/file-schema/runtime/remove-element-for-namedcaches.md index 6af04e7922483..17742b00a2dd1 100644 --- a/docs/framework/configure-apps/file-schema/runtime/remove-element-for-namedcaches.md +++ b/docs/framework/configure-apps/file-schema/runtime/remove-element-for-namedcaches.md @@ -54,4 +54,5 @@ Removes a named cache entry from the `namedCaches` collection for a memory cache ## See also +- [Configure apps by using configuration files](../../index.md) - [\ Element (Cache Settings)](namedcaches-element-cache-settings.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/runtime-element.md b/docs/framework/configure-apps/file-schema/runtime/runtime-element.md index 1dbe0ed2ec3ac..fd7608338e928 100644 --- a/docs/framework/configure-apps/file-schema/runtime/runtime-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/runtime-element.md @@ -49,6 +49,7 @@ None. |[\](disablecachingbindingfailures-element.md)|Specifies whether the caching of binding failures, which is the default behavior in the .NET Framework version 2.0, is disabled.| |[\](disablecommitthreadstack-element.md)|Specifies whether the full thread stack is committed when a thread is started.| |[\](disablefusionupdatesfromadmanager-element.md)|Specifies whether the default behavior, which is to allow the runtime host to override configuration settings for an application domain, is disabled.| +|[\](disablestackoverflowprobing-element.md)|Specifies whether stack-overflow probing is disabled.| |[\](enableampmparseadjustment-element.md)|Determines whether date and time parsing methods use an adjusted set of rules to parse date strings that contain only a day, month, hour, and AM/PM designator.| |[\](enforcefipspolicy-element.md)|Specifies whether to enforce a computer configuration requirement that cryptographic algorithms must comply with the Federal Information Processing Standards (FIPS).| |[\](etwenable-element.md)|Specifies whether to enable event tracing for Windows (ETW) for common language runtime events.| @@ -91,9 +92,10 @@ None. The child elements in the [\](runtime-element.md) section of a configuration file are used by the common language runtime to configure how an application executes. For example, the [\](gcserver-element.md) element determines whether the garbage collector uses workstation garbage collection or server garbage collection, the [\](userandomizedstringhashalgorithm-element.md) element determines whether the common language runtime calculates hash codes for string on a per-application or a per-application domain basis, and the `AppContextSwitchOverrides` element allows library users to opt in or opt out of changed functionality provided by a library. -The elements in the [\](runtime-element.md) section are read automatically by the common language runtime at application startup. You can also define the configuration file for a non-default application domain by supplying its name to the property; its settings are read automatically when the application domain is loaded. You should rarely, if ever, have a need to directly read the settings in the [\](runtime-element.md) section in your application's configuration file. +The elements in the [\](runtime-element.md) section are read automatically by the common language runtime at application startup. You can also define the configuration file for a non-default application domain by supplying its name to the property; its settings are read automatically when the application domain is loaded. You should rarely, if ever, have a need to directly read the settings in the [\](runtime-element.md) section of your application's configuration file. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/shadowcopyverifybytimestamp-element.md b/docs/framework/configure-apps/file-schema/runtime/shadowcopyverifybytimestamp-element.md index e2b6417c34534..9013f32b4a805 100644 --- a/docs/framework/configure-apps/file-schema/runtime/shadowcopyverifybytimestamp-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/shadowcopyverifybytimestamp-element.md @@ -67,6 +67,7 @@ Specifies whether shadow copying uses the default startup behavior introduced in ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [Shadow Copying Assemblies](../../../app-domains/shadow-copy-assemblies.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/supportportability-element.md b/docs/framework/configure-apps/file-schema/runtime/supportportability-element.md index d67b10dab3ba1..a8975846e8fea 100644 --- a/docs/framework/configure-apps/file-schema/runtime/supportportability-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/supportportability-element.md @@ -78,5 +78,6 @@ The following example enables an application to have references to both the .NET ## See also +- [Configure apps by using configuration files](../../index.md) - [-appconfig (C# Compiler Options)](../../../../csharp/language-reference/compiler-options/advanced.md#applicationconfiguration) - [.NET Framework Assembly Unification Overview](/previous-versions/dotnet/netframework-4.0/db7849ey(v=vs.100)) diff --git a/docs/framework/configure-apps/file-schema/runtime/system-runtime-caching-element-cache-settings.md b/docs/framework/configure-apps/file-schema/runtime/system-runtime-caching-element-cache-settings.md index 6fd0d5e2dcd49..d0a931d767b91 100644 --- a/docs/framework/configure-apps/file-schema/runtime/system-runtime-caching-element-cache-settings.md +++ b/docs/framework/configure-apps/file-schema/runtime/system-runtime-caching-element-cache-settings.md @@ -73,4 +73,5 @@ The `cacheMemoryLimitMegabytes` attribute and the `physicalMemoryPercentage` att ## See also +- [Configure apps by using configuration files](../../index.md) - [\ Element (Cache Settings)](memorycache-element-cache-settings.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/thread-useallcpugroups-element.md b/docs/framework/configure-apps/file-schema/runtime/thread-useallcpugroups-element.md index 935c75dbc96e0..32b75b270bad4 100644 --- a/docs/framework/configure-apps/file-schema/runtime/thread-useallcpugroups-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/thread-useallcpugroups-element.md @@ -67,6 +67,7 @@ The following example shows how to enable support for multiple CPU groups. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) - [\ Element](gccpugroup-element.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/throwunobservedtaskexceptions-element.md b/docs/framework/configure-apps/file-schema/runtime/throwunobservedtaskexceptions-element.md index 927ebdb27b47a..d113b14126fea 100644 --- a/docs/framework/configure-apps/file-schema/runtime/throwunobservedtaskexceptions-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/throwunobservedtaskexceptions-element.md @@ -90,5 +90,6 @@ Specifies whether unhandled task exceptions should terminate a running process. ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/timespan-legacyformatmode-element.md b/docs/framework/configure-apps/file-schema/runtime/timespan-legacyformatmode-element.md index 8f1d9eb099fde..f5c116176f680 100644 --- a/docs/framework/configure-apps/file-schema/runtime/timespan-legacyformatmode-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/timespan-legacyformatmode-element.md @@ -93,5 +93,6 @@ However, if you add the following configuration file to the example's directory ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/toc.yml b/docs/framework/configure-apps/file-schema/runtime/toc.yml index 3b1a47c35954d..6dd46c157e8ba 100644 --- a/docs/framework/configure-apps/file-schema/runtime/toc.yml +++ b/docs/framework/configure-apps/file-schema/runtime/toc.yml @@ -1,6 +1,7 @@ -- name: Run-time settings schema +items: +- name: Runtime settings schema href: index.md -- name: Run-time configuration +- name: Runtime configuration items: - name: element href: runtime-element.md @@ -48,6 +49,8 @@ href: disablecommitthreadstack-element.md - name: element href: disablefusionupdatesfromadmanager-element.md + - name: element + href: disablestackoverflowprobing-element.md - name: element href: enableampmparseadjustment-element.md - name: element @@ -106,7 +109,7 @@ href: userandomizedstringhashalgorithm-element.md - name: element href: usesmallinternalthreadstacks-element.md -- name: Run-time caching +- name: Runtime caching items: - name: element href: system-runtime-caching-element-cache-settings.md diff --git a/docs/framework/configure-apps/file-schema/runtime/uselegacyjit-element.md b/docs/framework/configure-apps/file-schema/runtime/uselegacyjit-element.md index f47c479d13885..c35ead63321d1 100644 --- a/docs/framework/configure-apps/file-schema/runtime/uselegacyjit-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/uselegacyjit-element.md @@ -89,6 +89,7 @@ The following configuration file disables compilation with the new 64-bit JIT co ## See also +- [Configure apps by using configuration files](../../index.md) - [\ Element](runtime-element.md) - [\ Element](../configuration-element.md) - [Mitigation: New 64-bit JIT Compiler](../../../migration-guide/mitigation-new-64-bit-jit-compiler.md) diff --git a/docs/framework/configure-apps/file-schema/runtime/userandomizedstringhashalgorithm-element.md b/docs/framework/configure-apps/file-schema/runtime/userandomizedstringhashalgorithm-element.md index 29b92b2a3341a..c7efa7834bfd6 100644 --- a/docs/framework/configure-apps/file-schema/runtime/userandomizedstringhashalgorithm-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/userandomizedstringhashalgorithm-element.md @@ -95,6 +95,7 @@ String 'This is a string.' in domain 'NewDomain': 75CC8236 ## See also +- [Configure apps by using configuration files](../../index.md) - - - diff --git a/docs/framework/configure-apps/file-schema/runtime/usesmallinternalthreadstacks-element.md b/docs/framework/configure-apps/file-schema/runtime/usesmallinternalthreadstacks-element.md index 50357319b476a..9af91b719d9d5 100644 --- a/docs/framework/configure-apps/file-schema/runtime/usesmallinternalthreadstacks-element.md +++ b/docs/framework/configure-apps/file-schema/runtime/usesmallinternalthreadstacks-element.md @@ -72,5 +72,6 @@ Requests that the common language runtime (CLR) reduce memory use by specifying ## See also +- [Configure apps by using configuration files](../../index.md) - [Runtime Settings Schema](index.md) - [Configuration File Schema](../index.md) diff --git a/docs/framework/configure-apps/index.md b/docs/framework/configure-apps/index.md index 05fc57d9961dd..e3b2338d87aad 100644 --- a/docs/framework/configure-apps/index.md +++ b/docs/framework/configure-apps/index.md @@ -50,7 +50,7 @@ This article describes the syntax of configuration files and provides informatio ## Machine configuration files - The machine configuration file, Machine.config, contains settings that apply to an entire computer. This file is located in the %*runtime install path*%\Config directory. Machine.config contains configuration settings for machine-wide assembly binding, built-in [remoting channels](/previous-versions/dotnet/netframework-4.0/dkfd3wha(v=vs.100)), and ASP.NET. + The machine configuration file, *Machine.config*, contains settings that apply to an entire computer. This file is located in the %*runtime install path*%\Config directory. *Machine.config* contains configuration settings for machine-wide assembly binding, built-in [remoting channels](/previous-versions/dotnet/netframework-4.0/dkfd3wha(v=vs.100)), and ASP.NET. The configuration system first looks in the machine configuration file for the [**\** element](./file-schema/appsettings/index.md) and other configuration sections that a developer might define. It then looks in the application configuration file. To keep the machine configuration file manageable, it is best to put these settings in the application configuration file. However, putting the settings in the machine configuration file can make your system more maintainable. For example, if you have a third-party component that both your client and server application uses, it is easier to put the settings for that component in one place. In this case, the machine configuration file is the appropriate place for the settings, so you don't have the same settings in two different files. diff --git a/docs/framework/data/adonet/code-access-security.md b/docs/framework/data/adonet/code-access-security.md index f530510a4357f..e2d2c822f154b 100644 --- a/docs/framework/data/adonet/code-access-security.md +++ b/docs/framework/data/adonet/code-access-security.md @@ -9,9 +9,11 @@ ms.assetid: 93e099eb-daa1-4f1e-b031-c1e10a996f88 --- # Code Access Security and ADO.NET -The .NET Framework offers role-based security as well as code access security (CAS), both of which are implemented using a common infrastructure supplied by the common language runtime (CLR). In the world of unmanaged code, most applications execute with the permissions of the user or principal. As a result, computer systems can be damaged and private data compromised when malicious or error-filled software is run by a user with elevated privileges. +.NET Framework offers role-based security as well as code access security (CAS), both of which are implemented using a common infrastructure supplied by the common language runtime (CLR). In the world of unmanaged code, most applications execute with the permissions of the user or principal. As a result, computer systems can be damaged and private data compromised when malicious or error-filled software is run by a user with elevated privileges. - By contrast, managed code executing in the .NET Framework includes code access security, which applies to code alone. Whether the code is allowed to run or not depends on the code's origin or other aspects of the code's identity, not solely the identity of the principal. This reduces the likelihood that managed code can be misused. + By contrast, managed code executing in .NET Framework includes code access security, which applies to code alone. Whether the code is allowed to run or not depends on the code's origin or other aspects of the code's identity, not solely the identity of the principal. This reduces the likelihood that managed code can be misused. + +[!INCLUDE [cas-deprecated](../../../../includes/cas-deprecated.md)] ## Code Access Permissions diff --git a/docs/framework/data/adonet/dataset-datatable-dataview/creating-a-datatable.md b/docs/framework/data/adonet/dataset-datatable-dataview/creating-a-datatable.md index e7afae07a73e2..d8c08b72c493e 100644 --- a/docs/framework/data/adonet/dataset-datatable-dataview/creating-a-datatable.md +++ b/docs/framework/data/adonet/dataset-datatable-dataview/creating-a-datatable.md @@ -11,7 +11,7 @@ ms.assetid: eecf9d78-60e3-4fdc-8de0-e56c13a89414 A , which represents one table of in-memory relational data, can be created and used independently, or can be used by other .NET Framework objects, most commonly as a member of a . - You can create a **DataTable** object by using the appropriate **DataTable** constructor. You can add it to the **DataSet** by using the **Add** method to add it to the **DataTable** object's **Tables** collection. + You can create a **DataTable** object by using the appropriate **DataTable** constructor. You can add it to the **DataSet** by using the **Add** method to add it to the **DataSet** object's **Tables** collection. You can also create **DataTable** objects within a **DataSet** by using the **Fill** or **FillSchema** methods of the **DataAdapter** object, or from a predefined or inferred XML schema using the **ReadXml**, **ReadXmlSchema**, or **InferXmlSchema** methods of the **DataSet**. Note that after you have added a **DataTable** as a member of the **Tables** collection of one **DataSet**, you cannot add it to the collection of tables of any other **DataSet**. diff --git a/docs/framework/data/adonet/secure-client-applications.md b/docs/framework/data/adonet/secure-client-applications.md index 258c1b5117aca..ddb159d7601fc 100644 --- a/docs/framework/data/adonet/secure-client-applications.md +++ b/docs/framework/data/adonet/secure-client-applications.md @@ -28,16 +28,14 @@ Applications typically consist of many parts that must all be protected from vul Describes how to use the class to check the validity of user input. ## Windows Applications - - In the past, Windows applications generally ran with full permissions. The .NET Framework provides the infrastructure to restrict code executing in a Windows application by using code access security (CAS). However, CAS alone is not enough to protect your application. - [Windows Forms Security](/dotnet/desktop/winforms/windows-forms-security) + [Windows Forms Security](/dotnet/desktop/winforms/windows-forms-security)\ Discusses how to secure Windows Forms applications and provides links to related topics. - [Windows Forms and Unmanaged Applications](/dotnet/desktop/winforms/advanced/windows-forms-and-unmanaged-applications) + [Windows Forms and Unmanaged Applications](/dotnet/desktop/winforms/advanced/windows-forms-and-unmanaged-applications)\ Describes how to interact with unmanaged applications in a Windows Forms application. - [ClickOnce Deployment for Windows Forms](/dotnet/desktop/winforms/clickonce-deployment-for-windows-forms) + [ClickOnce Deployment for Windows Forms](/dotnet/desktop/winforms/clickonce-deployment-for-windows-forms)\ Describes how to use `ClickOnce` deployment in a Windows Forms application and discusses the security implications. ## ASP.NET and XML Web Services diff --git a/docs/framework/data/adonet/side-by-side-execution.md b/docs/framework/data/adonet/side-by-side-execution.md index e815c3f6ae547..6b6024843a2fb 100644 --- a/docs/framework/data/adonet/side-by-side-execution.md +++ b/docs/framework/data/adonet/side-by-side-execution.md @@ -30,13 +30,11 @@ Side-by-side execution in the .NET Framework is the ability to execute an applic If you have an application developed for the .NET Framework version 2.0 or later that uses the data provider to connect to your data source, and you want to run that application on the .NET Framework version 1.0, you must download the data provider and install it on the .NET Framework version 1.0 system. -## Code Access Security - - The .NET Framework data providers in the .NET Framework version 1.0 (, ) are required to run with FullTrust permission. Any attempt to use the .NET Framework k data providers from the .NET Framework version 1.0 in a zone with less than FullTrust permission causes a . +## Code Access Security - However, starting with the .NET Framework version 2.0, all of the .NET Framework data providers can be used in partially trusted zones. In addition, a new security feature was added to the .NET Framework data providers in the .NET Framework version 1.1. This feature enables you to restrict what connection strings can be used in a particular security zone. You can also disable the use of blank passwords for a particular security zone. For more information, see [Code Access Security and ADO.NET](code-access-security.md). + Starting with .NET Framework version 2.0, all of the .NET Framework data providers can be used in partially trusted zones. In addition, a new security feature was added to the .NET Framework data providers in .NET Framework version 1.1. This feature enables you to restrict what connection strings can be used in a particular security zone. You can also disable the use of blank passwords for a particular security zone. For more information, see [Code Access Security and ADO.NET](code-access-security.md). - Because each installation of the .NET Framework has a separate Security.config file, there are no compatibility issues with security settings. However, if your application depends on the additional security capabilities of ADO.NET included in the .NET Framework version 1.1 and later, you will not be able to distribute it to a version 1.0 system. + Because each installation of .NET Framework has a separate Security.config file, there are no compatibility issues with security settings. However, if your application depends on the additional security capabilities of ADO.NET included in .NET Framework version 1.1 and later, you will not be able to distribute it to a version 1.0 system. ## SqlCommand Execution diff --git a/docs/framework/data/adonet/sql/introduction-to-sql-server-clr-integration.md b/docs/framework/data/adonet/sql/introduction-to-sql-server-clr-integration.md index 186063f872998..eec96702dbc03 100644 --- a/docs/framework/data/adonet/sql/introduction-to-sql-server-clr-integration.md +++ b/docs/framework/data/adonet/sql/introduction-to-sql-server-clr-integration.md @@ -6,11 +6,13 @@ ms.assetid: 551d2290-ed80-49be-b377-44b32444da1c --- # Introduction to SQL Server CLR Integration -The common language runtime (CLR) is the heart of the Microsoft .NET Framework and provides the execution environment for all .NET Framework code. Code that runs within the CLR is referred to as managed code. The CLR provides various functions and services required for program execution, including just-in-time (JIT) compilation, allocating and managing memory, enforcing type safety, exception handling, thread management, and security. +The common language runtime (CLR) is the heart of .NET Framework and provides the execution environment for all .NET Framework code. Code that runs within the CLR is referred to as managed code. The CLR provides various functions and services required for program execution, including just-in-time (JIT) compilation, allocating and managing memory, enforcing type safety, exception handling, thread management, and security. With the CLR hosted in Microsoft SQL Server (called CLR integration), you can author stored procedures, triggers, user-defined functions, user-defined types, and user-defined aggregates in managed code. Because managed code compiles to native code prior to execution, you can achieve significant performance increases in some scenarios. - Managed code uses Code Access Security (CAS), code links, and application domains to prevent assemblies from performing certain operations. SQL Server uses CAS to help secure the managed code and prevent compromise of the operating system or database server. +Managed code running on .NET Framework uses Code Access Security (CAS), code links, and application domains to prevent assemblies from performing certain operations. SQL Server uses CAS to help secure the managed code and prevent compromise of the operating system or database server. + +[!INCLUDE [cas-deprecated](../../../../../includes/cas-deprecated.md)] This section is meant to provide only enough information to get started programming with SQL Server CLR integration, and is not meant to be comprehensive. For more detailed information, see [Common Language Runtime (CLR) Integration Overview](/sql/relational-databases/clr-integration/common-language-runtime-integration-overview). diff --git a/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md b/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md index f716cf762bb7a..03a6e820b7be5 100644 --- a/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md +++ b/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md @@ -6,11 +6,11 @@ ms.assetid: 61e0b396-09d7-4e13-9711-7dcbcbd103a0 --- # SqlClient Support for High Availability, Disaster Recovery -This topic discusses SqlClient support (added in .NET Framework 4.5) for high-availability, disaster recovery with the Always On features -- Always On availability groups (AGs) and Always On failover cluster instances (FCIs) with SQL Server 2012 or later. For more information about either Always On feature, see SQL Server Books Online. +This article discusses SqlClient support (added in .NET Framework 4.5) for high-availability, disaster recovery with the Always On features -- Always On availability groups (AGs) and Always On failover cluster instances (FCIs) with SQL Server 2012 or later. You can now specify an availability group listener or the name of an FCI in the connection property. If a SqlClient application is connected to a database that fails over, the original connection is broken and the application must open a new connection to continue work after the failover. - If you are not connecting to an AG or FCI, and if multiple IP addresses are associated with a hostname, SqlClient will iterate sequentially through all IP addresses associated with DNS entry. This can be time consuming if the first IP address returned by DNS server is not bound to any network interface card (NIC). When connecting an FCI, or to the listener of an availability group, SqlClient attempts to establish connections to all IP addresses in parallel and if a connection attempt succeeds, the driver discards any pending connection attempts. + If you are not connecting to an AG or FCI, and if multiple IP addresses are associated with a hostname, SqlClient will iterate sequentially through all IP addresses associated with DNS entry. This can be time consuming if the first IP address returned by DNS server is not bound to any network interface card (NIC). When connecting an FCI, or to the listener of an availability group, SqlClient attempts to establish connections to all IP addresses in parallel. If a connection attempt succeeds, the driver discards any pending connection attempts. > [!NOTE] > Increasing connection timeout and implementing connection retry logic will increase the probability that an application will connect to an availability group. Also, because a connection can fail because of a failover, you should implement connection retry logic, retrying a failed connection until it reconnects. @@ -23,12 +23,12 @@ This topic discusses SqlClient support (added in .NET Framework 4.5) for high-av You can programmatically modify these connection string keywords with: -1. +- -2. +- > [!NOTE] -> Setting `MultiSubnetFailover` to `true` isn't required with .NET Framework 4.6.1 or later versions. +> Setting `MultiSubnetFailover` to `true` isn't required with .NET Framework 4.6.1 - 4.8. It is required in .NET Core and .NET 5+. ## Connecting With MultiSubnetFailover @@ -56,9 +56,9 @@ This topic discusses SqlClient support (added in .NET Framework 4.5) for high-av If read-only routing is not in effect, connecting to a secondary replica location will fail in the following situations: -1. If the secondary replica location is not configured to accept connections. +- If the secondary replica location is not configured to accept connections. -2. If an application uses `ApplicationIntent=ReadWrite` (discussed below) and the secondary replica location is configured for read-only access. +- If an application uses `ApplicationIntent=ReadWrite` (discussed below) and the secondary replica location is configured for read-only access. is not supported on read-only secondary replicas. diff --git a/docs/framework/deployment/index.md b/docs/framework/deployment/index.md index 48ad6c2e9fb9e..2d99ee8c1707c 100644 --- a/docs/framework/deployment/index.md +++ b/docs/framework/deployment/index.md @@ -149,7 +149,7 @@ The .NET Framework provides the following options for distributing applications: To determine where to deploy your application's assemblies so they can be found by the runtime, see [How the Runtime Locates Assemblies](how-the-runtime-locates-assemblies.md). -Security considerations can also affect how you deploy your application. Security permissions are granted to managed code according to where the code is located. Deploying an application or component to a location where it receives little trust, such as the Internet, limits what the application or component can do. For more information about deployment and security considerations, see [Code Access Security Basics](/previous-versions/dotnet/framework/code-access-security/code-access-security-basics). +Security considerations can also affect how you deploy your application. Security permissions are granted to managed code according to where the code is located. Deploying an application or component to a location where it receives little trust, such as the internet, limits what the application or component can do. ## Related Topics diff --git a/docs/framework/interop/copying-and-pinning.md b/docs/framework/interop/copying-and-pinning.md index 4c1f04159ee4c..3b9098f231d5a 100644 --- a/docs/framework/interop/copying-and-pinning.md +++ b/docs/framework/interop/copying-and-pinning.md @@ -1,7 +1,7 @@ --- title: "Copying and Pinning" description: Review how the interop marshaller can copy or pin data that's being marshalled. Copying data places a copy of data from one memory location into another location. -ms.date: "03/30/2017" +ms.date: 05/12/2022 helpviewer_keywords: - "pinning, interop marshalling" - "copying, interop marshalling" @@ -11,7 +11,7 @@ ms.assetid: 0059f576-e460-4e70-b257-668870e420b8 --- # Copying and Pinning -When marshalling data, the interop marshallercan copy or pin the data being marshalled. Copying the data places a copy of data from one memory location in another memory location. The following illustration shows the differences between copying a value type and copying a type passed by reference from managed to unmanaged memory. +When marshalling data, the interop marshaller can copy or pin the data being marshalled. Copying the data places a copy of data from one memory location in another memory location. The following illustration shows the differences between copying a value type and copying a type passed by reference from managed to unmanaged memory. ![Diagram that shows how value and reference types are copied.](./media/copying-and-pinning/interop-marshal-copy.gif) @@ -19,7 +19,7 @@ Method arguments passed by value are marshalled to unmanaged code as values on t ![Diagram showing reference types passed by value and by reference.](./media/copying-and-pinning/interop-marshal-reference-pin.gif) -Pinning temporarily locks the data in its current memory location, thus keeping it from being relocated by the common language runtime's garbage collector. The marshaller pins data to reduce the overhead of copying and enhance performance. The type of the data determines whether it is copied or pinned during the marshalling process. Pinning is automatically performed during marshalling for objects such as , however you can also manually pin memory using the class. +Pinning temporarily locks the data in its current memory location, thus keeping it from being relocated by the common language runtime's garbage collector. The marshaller pins data to reduce the overhead of copying and enhance performance. The type of the data determines whether it is copied or pinned during the marshalling process. Pinning is automatically performed during marshalling for objects such as , however you can also manually pin memory using the class. ## Formatted Blittable Classes @@ -56,22 +56,22 @@ Reference types have the following conditional behavior: To avoid unnecessarily copying and conversion, these types are marshalled as In parameters. You must explicitly apply the **InAttribute** and **OutAttribute** attributes to an argument for the caller to see changes made by the callee. -- If a reference type is passed by value and it has only members of blittable types, it can be pinned during marshalling and any changes made to the members of the type by the callee are seen by the caller. Apply **InAttribute** and **OutAttribute** explicitly if you want this behavior. Without these directional attributes, the interop marshallerdoes not export directional information to the type library (it exports as In, which is the default) and this can cause problems with COM cross-apartment marshalling. +- If a reference type is passed by value and it has only members of blittable types, it can be pinned during marshalling and any changes made to the members of the type by the callee are seen by the caller. Apply **InAttribute** and **OutAttribute** explicitly if you want this behavior. Without these directional attributes, the interop marshaller does not export directional information to the type library (it exports as In, which is the default) and this can cause problems with COM cross-apartment marshalling. - If a reference type is passed by reference, it will be marshalled as In/Out by default. ## System.String and System.Text.StringBuilder -When data is marshalled to unmanaged code by value or by reference, the marshallertypically copies the data to a secondary buffer (possibly converting character sets during the copy) and passes a reference to the buffer to the callee. Unless the reference is a **BSTR** allocated with **SysAllocString**, the reference is always allocated with **CoTaskMemAlloc**. +When data is marshalled to unmanaged code by value or by reference, the marshaller typically copies the data to a secondary buffer (possibly converting character sets during the copy) and passes a reference to the buffer to the callee. Unless the reference is a **BSTR** allocated with **SysAllocString**, the reference is always allocated with **CoTaskMemAlloc**. -As an optimization when either string type is marshalled by value (such as a Unicode character string), the marshallerpasses the callee a direct pointer to managed strings in the internal Unicode buffer instead of copying it to a new buffer. +As an optimization when either or is marshalled by value (such as a Unicode character string), the marshaller passes the callee a direct pointer to managed strings in the internal Unicode buffer instead of copying it to a new buffer. > [!CAUTION] > When a string is passed by value, the callee must never alter the reference passed by the marshaller. Doing so can corrupt the managed heap. -When a is passed by reference, the marshaller copies the contents the string to a secondary buffer before making the call. It then copies the contents of the buffer into a new string on return from the call. This technique ensures that the immutable managed string remains unaltered. +When a is passed by reference, the marshaller copies the contents of the string to a secondary buffer before making the call. It then copies the contents of the buffer into a new string on return from the call. This technique ensures that the immutable managed string remains unaltered. -When a is passed by value, the marshaller passes a reference to a temporary copy of the internal buffer of the **StringBuilder** to the caller. The caller and callee must agree on the size of the buffer. The caller is responsible for creating a **StringBuilder** of adequate length. The callee must take the necessary precautions to ensure that the buffer is not overrun. **StringBuilder** is an exception to the rule that reference types passed by value are passed as In parameters by default. It is always passed as In/Out. +When a is passed by value, the marshaller passes a reference to a temporary copy of the internal buffer of the **StringBuilder** to the caller. The caller and callee must agree on the size of the buffer. The caller is responsible for creating a **StringBuilder** of adequate length. The callee must take the necessary precautions to ensure that the buffer is not overrun. **StringBuilder** is an exception to the rule that reference types passed by value are passed as `In` parameters by default. `StringBuilder` is always passed as `In`/`Out`. ## See also diff --git a/docs/framework/interop/default-marshalling-behavior.md b/docs/framework/interop/default-marshalling-behavior.md index c6637a4c62b31..5bb0bc880a1a2 100644 --- a/docs/framework/interop/default-marshalling-behavior.md +++ b/docs/framework/interop/default-marshalling-behavior.md @@ -350,7 +350,7 @@ interface _Graphics { } ``` - The same rules used to marshal values and references to platform invoke calls are used when marshalling through COM interfaces. For example, when an instance of the `Point` value type is passed from the .NET Framework to COM, the `Point` is passed by value. If the `Point` value type is passed by reference, a pointer to a `Point` is passed on the stack. The interop marshallerdoes not support higher levels of indirection (**Point** \*\*) in either direction. + The same rules used to marshal values and references to platform invoke calls are used when marshalling through COM interfaces. For example, when an instance of the `Point` value type is passed from the .NET Framework to COM, the `Point` is passed by value. If the `Point` value type is passed by reference, a pointer to a `Point` is passed on the stack. The interop marshaller does not support higher levels of indirection (**Point** \*\*) in either direction. > [!NOTE] > Structures having the enumeration value set to **Explicit** cannot be used in COM interop because the exported type library cannot express an explicit layout. diff --git a/docs/framework/interop/default-marshalling-for-arrays.md b/docs/framework/interop/default-marshalling-for-arrays.md index 9a9b9ff99f4f5..e4fb1a21f4a61 100644 --- a/docs/framework/interop/default-marshalling-for-arrays.md +++ b/docs/framework/interop/default-marshalling-for-arrays.md @@ -171,7 +171,7 @@ void New3(ref String ar); [MarshalAs(UnmanagedType.LPArray, SizeConst=128)] int[] ar ); ``` - When marshalling arrays from unmanaged code to managed code, the marshallerchecks the **MarshalAsAttribute** associated with the parameter to determine the array size. If the array size is not specified, only one element is marshalled. + When marshalling arrays from unmanaged code to managed code, the marshaller checks the **MarshalAsAttribute** associated with the parameter to determine the array size. If the array size is not specified, only one element is marshalled. > [!NOTE] > The **MarshalAsAttribute** has no effect on marshalling managed arrays to unmanaged code. In that direction, the array size is determined by examination. There is no way to marshal a subset of a managed array. diff --git a/docs/framework/interop/default-marshalling-for-objects.md b/docs/framework/interop/default-marshalling-for-objects.md index 006a069727426..eea2b3596c068 100644 --- a/docs/framework/interop/default-marshalling-for-objects.md +++ b/docs/framework/interop/default-marshalling-for-objects.md @@ -296,12 +296,12 @@ To propagate changes back to the caller, the parameters must be passed by refere **Default behavior for marshalling a variant with the VT_BYREF flag set** -- A variant being passed to managed code by value can have the **VT_BYREF** flag set to indicate that the variant contains a reference instead of a value. In this case, the variant is still marshalled to an object because the variant is being passed by value. The marshallerautomatically dereferences the contents of the variant and copies it into a newly created object before making the call. The object is then passed into the managed function; however, on return from the call, the object is not propagated back into the original variant. Changes made to the managed object are lost. +- A variant being passed to managed code by value can have the **VT_BYREF** flag set to indicate that the variant contains a reference instead of a value. In this case, the variant is still marshalled to an object because the variant is being passed by value. The marshaller automatically dereferences the contents of the variant and copies it into a newly created object before making the call. The object is then passed into the managed function; however, on return from the call, the object is not propagated back into the original variant. Changes made to the managed object are lost. > [!CAUTION] > There is no way to change the value of a variant passed by value, even if the variant has the **VT_BYREF** flag set. -- A variant being passed to managed code by reference can also have the **VT_BYREF** flag set to indicate that the variant contains another reference. If it does, the variant is marshalled to a **ref** object because the variant is being passed by reference. The marshallerautomatically dereferences the contents of the variant and copies it into a newly created object before making the call. On return from the call, the value of the object is propagated back to the reference within the original variant only if the object is the same type as the object passed in. That is, propagation does not change the type of a variant with the **VT_BYREF** flag set. If the type of the object is changed during the call, an occurs on return from the call. +- A variant being passed to managed code by reference can also have the **VT_BYREF** flag set to indicate that the variant contains another reference. If it does, the variant is marshalled to a **ref** object because the variant is being passed by reference. The marshaller automatically dereferences the contents of the variant and copies it into a newly created object before making the call. On return from the call, the value of the object is propagated back to the reference within the original variant only if the object is the same type as the object passed in. That is, propagation does not change the type of a variant with the **VT_BYREF** flag set. If the type of the object is changed during the call, an occurs on return from the call. The following table summarizes the propagation rules for variants and objects. diff --git a/docs/framework/interop/default-marshalling-for-strings.md b/docs/framework/interop/default-marshalling-for-strings.md index bfd5b039faf1f..752025773934f 100644 --- a/docs/framework/interop/default-marshalling-for-strings.md +++ b/docs/framework/interop/default-marshalling-for-strings.md @@ -16,15 +16,15 @@ Both the and attribute provides several enumeration values to marshal strings to COM interfaces. -|Enumeration type|Description of unmanaged format| -|----------------------|-------------------------------------| -|`UnmanagedType.BStr` (default)|A COM-style `BSTR` with a prefixed length and Unicode characters.| -|`UnmanagedType.LPStr`|A pointer to a null-terminated array of ANSI characters.| -|`UnmanagedType.LPWStr`|A pointer to a null-terminated array of Unicode characters.| +| Enumeration type | Description of unmanaged format | +|--------------------------------|-------------------------------------------------------------------| +| `UnmanagedType.BStr` (default) | A COM-style `BSTR` with a prefixed length and Unicode characters. | +| `UnmanagedType.LPStr` | A pointer to a null-terminated array of ANSI characters. | +| `UnmanagedType.LPWStr` | A pointer to a null-terminated array of Unicode characters. | This table applies to . For , the only options allowed are `UnmanagedType.LPStr` and `UnmanagedType.LPWStr`. @@ -73,7 +73,7 @@ interface IStringWorker : IDispatch }; ``` -## Strings Used in Platform Invoke +## Strings used in platform invoke When the CharSet is Unicode or a string argument is explicitly marked as [MarshalAs(UnmanagedType.LPWSTR)] and the string is passed by value (not `ref` or `out`), the string is pinned and used directly by native code. Otherwise, platform invoke copies string arguments, converting from the .NET Framework format (Unicode) to the platform unmanaged format. Strings are immutable and are not copied back from unmanaged memory to managed memory when the call returns. @@ -81,16 +81,16 @@ Native code is only responsible for releasing the memory when the string is pass The following table lists the marshalling options for strings when marshalled as a method argument of a platform invoke call. The attribute provides several enumeration values to marshal strings. -|Enumeration type|Description of unmanaged format| -|----------------------|-------------------------------------| -|`UnmanagedType.AnsiBStr`|A COM-style `BSTR` with a prefixed length and ANSI characters.| -|`UnmanagedType.BStr`|A COM-style `BSTR` with a prefixed length and Unicode characters.| -|`UnmanagedType.LPStr` (default)|A pointer to a null-terminated array of ANSI characters.| -|`UnmanagedType.LPTStr`|A pointer to a null-terminated array of platform-dependent characters.| -|`UnmanagedType.LPUTF8Str`|A pointer to a null-terminated array of UTF-8 encoded characters.| -|`UnmanagedType.LPWStr`|A pointer to a null-terminated array of Unicode characters.| -|`UnmanagedType.TBStr`|A COM-style `BSTR` with a prefixed length and platform-dependent characters.| -|`VBByRefStr`|A value that enables Visual Basic .NET to change a string in unmanaged code and have the results reflected in managed code. This value is supported only for platform invoke. This is the default value in Visual Basic for `ByVal` strings.| +| Enumeration type | Description of unmanaged format | +|---------------------------------|------------------------------------------------------------------------------| +| `UnmanagedType.AnsiBStr` | A COM-style `BSTR` with a prefixed length and ANSI characters. | +| `UnmanagedType.BStr` | A COM-style `BSTR` with a prefixed length and Unicode characters. | +| `UnmanagedType.LPStr` (default) | A pointer to a null-terminated array of ANSI characters. | +| `UnmanagedType.LPTStr` | A pointer to a null-terminated array of platform-dependent characters. | +| `UnmanagedType.LPUTF8Str` | A pointer to a null-terminated array of UTF-8 encoded characters. | +| `UnmanagedType.LPWStr` | A pointer to a null-terminated array of Unicode characters. | +| `UnmanagedType.TBStr` | A COM-style `BSTR` with a prefixed length and platform-dependent characters. | +| `VBByRefStr` | A value that enables Visual Basic to change a string in unmanaged code and have the results reflected in managed code. This value is supported only for platform invoke. This is the default value in Visual Basic for `ByVal` strings. | This table applies to . For , the only options allowed are `LPStr`, `LPTStr`, and `LPWStr`. @@ -135,18 +135,18 @@ Class StringLibAPI End Class ``` -## Strings Used in Structures +## Strings used in structures Strings are valid members of structures; however, buffers are invalid in structures. The following table shows the marshalling options for the data type when the type is marshalled as a field. The attribute provides several enumeration values to marshal strings to a field. -|Enumeration type|Description of unmanaged format| -|----------------------|-------------------------------------| -|`UnmanagedType.BStr`|A COM-style `BSTR` with a prefixed length and Unicode characters.| -|`UnmanagedType.LPStr` (default)|A pointer to a null-terminated array of ANSI characters.| -|`UnmanagedType.LPTStr`|A pointer to a null-terminated array of platform-dependent characters.| -|`UnmanagedType.LPUTF8Str`|A pointer to a null-terminated array of UTF-8 encoded characters.| -|`UnmanagedType.LPWStr`|A pointer to a null-terminated array of Unicode characters.| -|`UnmanagedType.ByValTStr`|A fixed-length array of characters; the array's type is determined by the character set of the containing structure.| +| Enumeration type | Description of unmanaged format | +|---------------------------------|------------------------------------------------------------------------| +| `UnmanagedType.BStr` | A COM-style `BSTR` with a prefixed length and Unicode characters. | +| `UnmanagedType.LPStr` (default) | A pointer to a null-terminated array of ANSI characters. | +| `UnmanagedType.LPTStr` | A pointer to a null-terminated array of platform-dependent characters. | +| `UnmanagedType.LPUTF8Str` | A pointer to a null-terminated array of UTF-8 encoded characters. | +| `UnmanagedType.LPWStr` | A pointer to a null-terminated array of Unicode characters. | +| `UnmanagedType.ByValTStr` | A fixed-length array of characters; the array's type is determined by the character set of the containing structure.| The `ByValTStr` type is used for inline, fixed-length character arrays that appear within a structure. Other types apply to string references contained within structures that contain pointers to strings. @@ -223,13 +223,13 @@ Structure StringInfoT End Structure ``` -## Fixed-Length String Buffers +## Fixed-length string buffers In some circumstances, a fixed-length character buffer must be passed into unmanaged code to be manipulated. Simply passing a string does not work in this case because the callee cannot modify the contents of the passed buffer. Even if the string is passed by reference, there is no way to initialize the buffer to a given size. -The solution is to pass a as the argument instead of a . The buffer created when marshalling a `StringBuilder` can be dereferenced and modified by the callee, provided it does not exceed the capacity of the `StringBuilder`. It can also be initialized to a fixed length. For example, if you initialize a `StringBuilder` buffer to a capacity of `N`, the marshallerprovides a buffer of size (`N`+1) characters. The +1 accounts for the fact that the unmanaged string has a null terminator while `StringBuilder` does not. +The solution is to pass a `byte[]` or `char[]`, depending on expected encoding, as the argument instead of a . The array, when marked with `[Out]`, can be dereferenced and modified by the callee, provided it does not exceed the capacity of the allocated array. -For example, the Windows [`GetWindowText`](/windows/desktop/api/winuser/nf-winuser-getwindowtextw) API function (defined in *winuser.h*) requires that the caller pass a fixed-length character buffer to which the function writes the window's text. `LpString` points to a caller-allocated buffer of size `nMaxCount`. The caller is expected to allocate the buffer and set the `nMaxCount` argument to the size of the allocated buffer. The following example shows the `GetWindowText` function declaration as defined in *winuser.h*. +For example, the Windows [`GetWindowText`](/windows/desktop/api/winuser/nf-winuser-getwindowtextw) API function (defined in *winuser.h*) requires that the caller pass a fixed-length character buffer to which the function writes the window's text. The `lpString` argument points to a caller-allocated buffer of size `nMaxCount`. The caller is expected to allocate the buffer and set the `nMaxCount` argument to the size of the allocated buffer. The following example shows the `GetWindowText` function declaration as defined in *winuser.h*. ```cpp int GetWindowText( @@ -239,49 +239,56 @@ int GetWindowText( ); ``` -A `StringBuilder` can be dereferenced and modified by the callee, provided it does not exceed the capacity of the `StringBuilder`. The following code example demonstrates how `StringBuilder` can be initialized to a fixed length. +A `char[]` can be dereferenced and modified by the callee. The following code example demonstrates how `ArrayPool` can be used to pre-allocate a `char[]`. ```csharp using System; +using System.Buffers; using System.Runtime.InteropServices; -using System.Text; internal static class NativeMethods { - [DllImport("User32.dll")] - internal static extern void GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); + [DllImport("User32.dll", CharSet = CharSet.Unicode)] + public static extern void GetWindowText(IntPtr hWnd, [Out] char[] lpString, int nMaxCount); } public class Window { internal IntPtr h; // Internal handle to Window. - public String GetText() + public string GetText() { - StringBuilder sb = new StringBuilder(256); - NativeMethods.GetWindowText(h, sb, sb.Capacity + 1); - return sb.ToString(); + char[] buffer = ArrayPool.Shared.Rent(256 + 1); + NativeMethods.GetWindowText(h, buffer, buffer.Length); + return new string(buffer); } } ``` ```vb -Imports System.Text +Imports System +Imports System.Buffers +Imports System.Runtime.InteropServices Friend Class NativeMethods - Friend Declare Auto Sub GetWindowText Lib "User32.dll" _ - (hWnd As IntPtr, lpString As StringBuilder, nMaxCount As Integer) + Public Declare Auto Sub GetWindowText Lib "User32.dll" _ + (hWnd As IntPtr, lpString() As Char, nMaxCount As Integer) End Class Public Class Window Friend h As IntPtr ' Friend handle to Window. Public Function GetText() As String - Dim sb As New StringBuilder(256) - NativeMethods.GetWindowText(h, sb, sb.Capacity + 1) - Return sb.ToString() + Dim buffer() As Char = ArrayPool(Of Char).Shared.Rent(256 + 1) + NativeMethods.GetWindowText(h, buffer, buffer.Length) + Return New String(buffer) End Function End Class ``` +Another solution is to pass a as the argument instead of a . The buffer created when marshalling a `StringBuilder` can be dereferenced and modified by the callee, provided it does not exceed the capacity of the `StringBuilder`. It can also be initialized to a fixed length. For example, if you initialize a `StringBuilder` buffer to a capacity of `N`, the marshaller provides a buffer of size (`N`+1) characters. The +1 accounts for the fact that the unmanaged string has a null terminator while `StringBuilder` does not. + +> [!NOTE] +> In general, passing `StringBuilder` arguments is not recommended if you're concerned about performance. For more information, see [String parameters](../../standard/native-interop/best-practices.md#string-parameters). + ## See also - [Default Marshalling Behavior](default-marshalling-behavior.md) diff --git a/docs/framework/interop/toc.yml b/docs/framework/interop/toc.yml index c20ab6d00319a..24fd7b45aa8ab 100644 --- a/docs/framework/interop/toc.yml +++ b/docs/framework/interop/toc.yml @@ -53,21 +53,21 @@ - name: "How to: Implement Callback Functions" href: how-to-implement-callback-functions.md - name: Interop Marshaling - href: /dotnet/framework/interop/interop-marshalling + href: interop-marshalling.md items: - name: Default Marshalling Behavior - href: /dotnet/framework/interop/default-marshalling-behavior + href: default-marshalling-behavior.md items: - name: Blittable and Non-Blittable Types href: blittable-and-non-blittable-types.md - name: Copying and Pinning href: copying-and-pinning.md - name: Default Marshalling for Arrays - href: /dotnet/framework/interop/default-marshalling-for-arrays + href: default-marshalling-for-arrays.md - name: Default Marshalling for Objects - href: /dotnet/framework/interop/default-marshalling-for-objects + href: default-marshalling-for-objects.md - name: Default Marshalling for Strings - href: /dotnet/framework/interop/default-marshalling-for-strings + href: default-marshalling-for-strings.md - name: Marshalling Data with Platform Invoke href: marshalling-data-with-platform-invoke.md items: diff --git a/docs/framework/migration-guide/versions-and-dependencies.md b/docs/framework/migration-guide/versions-and-dependencies.md index 78448fff2b64b..13d2d047f3b03 100644 --- a/docs/framework/migration-guide/versions-and-dependencies.md +++ b/docs/framework/migration-guide/versions-and-dependencies.md @@ -58,7 +58,7 @@ Jump to: | | Versions | |-|-| |**CLR**|4| -|**Windows**|✔️ 11
✔️ 10 May 2021 Update
✔️ 10 October 2020 Update
✔️ 10 May 2020 Update
✔️ 10 November 2019 Update
✔️ 10 May 2019 Update
➕ 10 October 2018 Update (Version 1809)
➕ 10 April 2018 Update (Version 1803)
➕ 10 Fall Creators Update (Version 1709)
➕ 10 Creators Update (Version 1703)
➕ 10 Anniversary Update (Version 1607)
➕ 8.1
➕7| +|**Windows**|✔️ 11
✔️ 10 November 2021 Update
✔️ 10 May 2021 Update
✔️ 10 October 2020 Update
✔️ 10 May 2020 Update
✔️ 10 November 2019 Update
✔️ 10 May 2019 Update
➕ 10 October 2018 Update (Version 1809)
➕ 10 April 2018 Update (Version 1803)
➕ 10 Fall Creators Update (Version 1709)
➕ 10 Creators Update (Version 1703)
➕ 10 Anniversary Update (Version 1607)
➕ 8.1
➕7| |**Windows Server**|✔️ Windows Server 2022
➕ Windows Server 2019
➕ Windows Server, version 1809
➕ Windows Server, version 1803
➕ 2016
➕ 2012 R2
➕ 2012
➕ 2008 R2 SP1| To determine the installed .NET version, use the following `Release` DWORD: @@ -139,7 +139,7 @@ For more information, see [instructions](how-to-determine-which-versions-are-ins |--------------------|------------------------------------------------------------------------------------------------------------| | **CLR** | 4 | | **Windows** | ✔️ 10 Anniversary Update (Version 1607)
➕ 10 November Update (Version 1511)
➕ 10
➕ 8.1
➕ 7 | -| **Windows Server** | ✔️ 2016

➕ 2012 R2
➕ 2012
➕ 2008 R2 SP1 | +| **Windows Server** | ✔️ 2016

➕ 2012 R2
➕ 2012
➕ 2008 R2 SP1
➕ 2008 SP2 | To determine the installed .NET version, use the following `Release` DWORD: diff --git a/docs/framework/network-programming/ftp.md b/docs/framework/network-programming/ftp.md index fe69ffa20f389..32eaf7604a767 100644 --- a/docs/framework/network-programming/ftp.md +++ b/docs/framework/network-programming/ftp.md @@ -1,6 +1,7 @@ --- -title: "FTP - .NET" -description: Learn about the comprehensive support for the FTP protocol that the .NET Framework provides by using the FtpWebRequest and FtpWebResponse classes. +title: "FTP - .NET Framework" +titleSuffix: "" +description: Learn about the comprehensive support for the FTP protocol that .NET Framework provides with the FtpWebRequest and FtpWebResponse classes. ms.date: "03/30/2017" helpviewer_keywords: - "FTP" @@ -8,7 +9,7 @@ ms.assetid: 9b43f8b4-89d7-46a7-89fc-71aca916dd32 --- # FTP -The .NET Framework provides comprehensive support for the FTP protocol with the and classes. These classes are derived from and . In most cases, the and classes provide all that is necessary to make the request, but if you need access to the FTP-specific features exposed as properties, you can typecast these classes to or . +.NET Framework provides comprehensive support for the FTP protocol with the and classes. These classes are derived from and . In most cases, the and classes provide all that's necessary to make the request, but if you need access to the FTP-specific features exposed as properties, you can typecast these classes to or . > [!NOTE] > This article is specific to projects that target .NET Framework. For projects that target .NET 6 and later versions, [FTP is no longer supported](../../core/compatibility/networking/6.0/webrequest-deprecated.md). diff --git a/docs/framework/network-programming/how-to-download-files-with-ftp.md b/docs/framework/network-programming/how-to-download-files-with-ftp.md index fe4cd8d467db2..2592ed74e3004 100644 --- a/docs/framework/network-programming/how-to-download-files-with-ftp.md +++ b/docs/framework/network-programming/how-to-download-files-with-ftp.md @@ -11,6 +11,9 @@ ms.assetid: 892548b8-954a-4f6a-9bca-2ae620c3700f This sample shows how to download a file from an FTP server. +> [!NOTE] +> This article is specific to projects that target .NET Framework. For projects that target .NET 6 and later versions, [FTP is no longer supported](../../core/compatibility/networking/6.0/webrequest-deprecated.md). + ## Example ```csharp diff --git a/docs/framework/network-programming/how-to-list-directory-contents-with-ftp.md b/docs/framework/network-programming/how-to-list-directory-contents-with-ftp.md index 7cf7cb5e51498..6d81817724f98 100644 --- a/docs/framework/network-programming/how-to-list-directory-contents-with-ftp.md +++ b/docs/framework/network-programming/how-to-list-directory-contents-with-ftp.md @@ -11,6 +11,9 @@ ms.assetid: 130c64c9-7b7f-4672-9b3b-d946bd2616c5 This sample shows how to list the directory contents of an FTP server. +> [!NOTE] +> This article is specific to projects that target .NET Framework. For projects that target .NET 6 and later versions, [FTP is no longer supported](../../core/compatibility/networking/6.0/webrequest-deprecated.md). + ## Example ```csharp diff --git a/docs/framework/network-programming/how-to-upload-files-with-ftp.md b/docs/framework/network-programming/how-to-upload-files-with-ftp.md index 17505105a36bf..6189d455b34db 100644 --- a/docs/framework/network-programming/how-to-upload-files-with-ftp.md +++ b/docs/framework/network-programming/how-to-upload-files-with-ftp.md @@ -1,7 +1,7 @@ --- title: "How to: Upload files with FTP" description: "This article shows a sample of how to upload a file to an FTP server." -ms.date: "06/26/2018" +ms.date: 05/13/2022 dev_langs: - "csharp" - "vb" @@ -11,12 +11,16 @@ ms.assetid: e40f17c5-dd12-4c62-9dbf-00ab491382dc This sample shows how to upload a file to an FTP server. +> [!NOTE] +> This article is specific to projects that target .NET Framework. For projects that target .NET 6 and later versions, [FTP is no longer supported](../../core/compatibility/networking/6.0/webrequest-deprecated.md). + ## Example ```csharp using System; using System.IO; using System.Net; +using System.Threading.Tasks; namespace Examples.System.Net { @@ -32,12 +36,17 @@ namespace Examples.System.Net request.Credentials = new NetworkCredential("anonymous", "janeDoe@contoso.com"); // Copy the contents of the file to the request stream. - await using FileStream fileStream = File.Open("testfile.txt", FileMode.Open, FileAccess.Read); - await using Stream requestStream = request.GetRequestStream(); - await fileStream.CopyToAsync(requestStream); - - using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); - Console.WriteLine($"Upload File Complete, status {response.StatusDescription}"); + using (FileStream fileStream = File.Open("testfile.txt", FileMode.Open, FileAccess.Read)) + { + using (Stream requestStream = request.GetRequestStream()) + { + await fileStream.CopyToAsync(requestStream); + using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) + { + Console.WriteLine($"Upload File Complete, status {response.StatusDescription}"); + } + } + } } } } diff --git a/docs/framework/network-programming/tls.md b/docs/framework/network-programming/tls.md index 24573828c7584..402653dc53ed6 100644 --- a/docs/framework/network-programming/tls.md +++ b/docs/framework/network-programming/tls.md @@ -146,7 +146,7 @@ The switches have the same effect whether you're doing HTTP networking (: SchUseStrongCrypto` registry key has a value of type DWORD. A value of 1 causes your app to use strong cryptography. The strong cryptography uses more secure network protocols (TLS 1.2, TLS 1.1, and TLS 1.0) and blocks protocols that are not secure. A value of 0 disables strong cryptography. For more information, see [The SCH_USE_STRONG_CRYPTO flag](#the-sch_use_strong_crypto-flag). +The `HKEY_LOCAL_MACHINE\SOFTWARE\[Wow6432Node\]Microsoft\.NETFramework\: SchUseStrongCrypto` registry key has a value of type DWORD. A value of 1 causes your app to use strong cryptography. The strong cryptography uses more secure network protocols (TLS 1.2, TLS 1.1, and TLS 1.0) and blocks protocols that are not secure. A value of 0 disables strong cryptography. For more information, see [The SCH_USE_STRONG_CRYPTO flag](#the-sch_use_strong_crypto-flag). This registry setting affects only client (outgoing) connections in your application. If your app targets .NET Framework 4.6 or later versions, this key defaults to a value of 1. That's a secure default that we recommend. If your app targets .NET Framework 4.5.2 or earlier versions, the key defaults to 0. In that case, you should explicitly set its value to 1. @@ -235,12 +235,12 @@ Start with the `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProv ## The SCH_USE_STRONG_CRYPTO flag -When it's enabled (by default, by [an `AppContext` switch](#switchsystemnetdontenableschusestrongcrypto), or [by the Windows Registry](#schusestrongcrypto)), the .NET Framework uses the `SCH_USE_STRONG_CRYPTO` flag when your app requests a TLS security protocol. .NET Framework passes the flag to `Schannel`to instruct it to disable known weak cryptographic algorithms, cipher suites, and TLS/SSL protocol versions that may be otherwise enabled for better interoperability. For more information, see: +When it's enabled (by default, by [an `AppContext` switch](#switchsystemnetdontenableschusestrongcrypto), or [by the Windows Registry](#schusestrongcrypto)), the .NET Framework uses the `SCH_USE_STRONG_CRYPTO` flag when your app initiates a TLS connection to a server. .NET Framework passes the flag to `Schannel` to instruct it to disable known weak cryptographic algorithms, cipher suites, and TLS/SSL protocol versions that may be otherwise enabled for better interoperability. For more information, see: - [Secure Channel](/windows/desktop/SecAuthN/secure-channel) - [SCHANNEL_CRED structure](/windows/win32/api/schannel/ns-schannel-schannel_cred) -The `SCH_USE_STRONG_CRYPTO` flag is also passed to `Schannel` when you explicitly use the `Tls` (TLS 1.0), `Tls11`, or `Tls12` enumerated values of or . +The `SCH_USE_STRONG_CRYPTO` flag is also passed to `Schannel` for client (outgoing) connections when you explicitly use the `Tls` (TLS 1.0), `Tls11`, or `Tls12` enumerated values of or . The `SCH_USE_STRONG_CRYPTO` flag is used only for connections where your application acts the role of the client. You can disable weak protocols and algorithms when your applications acts the role of the server by configuring the machine-wide `Schannel` registry settings. ## Security updates diff --git a/docs/framework/network-programming/using-an-asynchronous-server-socket.md b/docs/framework/network-programming/using-an-asynchronous-server-socket.md index 8faacafe1b2d7..7551fa6b04624 100644 --- a/docs/framework/network-programming/using-an-asynchronous-server-socket.md +++ b/docs/framework/network-programming/using-an-asynchronous-server-socket.md @@ -238,7 +238,7 @@ End Sub 'ReadCallback public static void ReadCallback(IAsyncResult ar) { StateObject state = (StateObject) ar.AsyncState; - Socket handler = state.WorkSocket; + Socket handler = state.workSocket; // Read data from the client socket. int read = handler.EndReceive(ar); diff --git a/docs/framework/performance/index.md b/docs/framework/performance/index.md index b5a412a008a11..60f2a710f747b 100644 --- a/docs/framework/performance/index.md +++ b/docs/framework/performance/index.md @@ -31,7 +31,7 @@ If you want to create apps with great performance, you should design and plan fo |----------|-----------------| |Visual Studio Performance Analysis|Use to analyze the CPU usage of your .NET Framework apps that will be deployed to computers that are running the Windows operating system.

This tool is available from the **Debug** menu in Visual Studio after you open a project. For more information, see [Performance Explorer](/visualstudio/profiling/performance-explorer). **Note:** Use Windows Phone Application Analysis (see next row) when targeting Windows Phone.| |Windows Phone Application Analysis|Use to analyze the CPU and memory, network data transfer rate, app responsiveness, and battery consumption in your Windows Phone apps.

This tool is available from the **Debug** menu for a Windows Phone project in Visual Studio after you install the [Windows Phone SDK](https://go.microsoft.com/fwlink/?LinkId=265773). For more information, see [App profiling for Windows Phone 8](/previous-versions/windows/apps/jj215908(v=vs.105)).| -|[PerfView](https://www.microsoft.com/download/details.aspx?id=28567)|Use to identify CPU and memory-related performance issues. This tool uses event tracing for Windows (ETW) and CLR profiling APIs to provide advanced memory and CPU investigations as well as information about garbage collection and JIT compilation. For more information about how to use PerfView, see the tutorial and help files that are included with the app, [Channel 9 video tutorials](https://channel9.msdn.com/Series/PerfView-Tutorial), and [blog posts](/archive/blogs/vancem/).

For memory-specific issues, see [Using PerfView for Memory Investigations](/shows/perfview-tutorial/9-net-memory-investigation-basics-of-gc-heap-snapshots).| +|[PerfView](https://www.microsoft.com/download/details.aspx?id=28567)|Use to identify CPU and memory-related performance issues. This tool uses event tracing for Windows (ETW) and CLR profiling APIs to provide advanced memory and CPU investigations as well as information about garbage collection and JIT compilation. For more information about how to use PerfView, see the [blog posts](/archive/blogs/vancem/).

For memory-specific issues, see Using PerfView for Memory Investigations.| |[Windows Performance Analyzer](https://www.microsoft.com/p/windows-performance-analyzer/9n0w1b2bxgnz?activetab=pivot:overviewtab)|Use to determine overall system performance such as your app's memory and storage use when multiple apps are running on the same computer. This tool is available from the download center as part of the Windows Assessment and Deployment Kit (ADK) for Windows 8. For more information, see [Windows Performance Analyzer](/windows-hardware/test/wpt/windows-performance-analyzer).| ### Event tracing for Windows (ETW) diff --git a/docs/framework/performance/sql-server-programming-and-host-protection-attributes.md b/docs/framework/performance/sql-server-programming-and-host-protection-attributes.md index 49e8f7ca2ed26..bf87070ec56d7 100644 --- a/docs/framework/performance/sql-server-programming-and-host-protection-attributes.md +++ b/docs/framework/performance/sql-server-programming-and-host-protection-attributes.md @@ -16,7 +16,9 @@ ms.assetid: 7dfa36b4-e773-4c75-a3ff-ff1af3ce4c4f --- # SQL Server Programming and Host Protection Attributes -The ability to load and execute managed code in a SQL Server host requires meeting the host's requirements for both code access security and host resource protection. The code access security requirements are specified by one of three SQL Server permission sets: SAFE, EXTERNAL-ACCESS, or UNSAFE. Code executing within the SAFE or EXTERNAL-ACCESS permission sets must avoid certain types or members that have the attribute applied. The is not a security permission as much as a reliability guarantee in that it identifies specific code constructs, either types or methods, that the host may disallow. The use of the enforces a programming model that helps protect the stability of the host. +The ability to load and execute managed code in a SQL Server host requires meeting the host's requirements for both code access security and host resource protection. The code access security requirements are specified by one of three SQL Server permission sets: SAFE, EXTERNAL-ACCESS, or UNSAFE. Code executing within the SAFE or EXTERNAL-ACCESS permission sets must avoid certain types or members that have the attribute applied. The is not a security permission as much as a reliability guarantee in that it identifies specific code constructs, either types or methods, that the host may disallow. The use of the enforces a programming model that helps protect the stability of the host. + +[!INCLUDE [cas-deprecated](../../../includes/cas-deprecated.md)] ## Host Protection Attributes diff --git a/docs/framework/tools/caspol-exe-code-access-security-policy-tool.md b/docs/framework/tools/caspol-exe-code-access-security-policy-tool.md index c2b607f4a4e78..0063532746b23 100644 --- a/docs/framework/tools/caspol-exe-code-access-security-policy-tool.md +++ b/docs/framework/tools/caspol-exe-code-access-security-policy-tool.md @@ -24,10 +24,12 @@ The Code Access Security (CAS) Policy tool (Caspol.exe) enables users and admini > [!IMPORTANT] > Starting with .NET Framework 4, Caspol.exe does not affect CAS policy unless the [\ element](../configure-apps/file-schema/runtime/netfx40-legacysecuritypolicy-element.md) is set to `true`. Any settings shown or modified by CasPol.exe will only affect applications that opt into using CAS policy. +[!INCLUDE [cas-deprecated](../../../includes/cas-deprecated.md)] + > [!NOTE] > 64-bit computers include both 64-bit and 32-bit versions of security policy. To ensure that your policy changes apply to both 32-bit and 64-bit applications, run both the 32-bit and 64-bit versions of Caspol.exe. - The Code Access Security Policy tool is automatically installed with .NET Framework and with Visual Studio. You can find Caspol.exe in %windir%\Microsoft.NET\Framework\\*version* on 32-bit systems or %windir%\Microsoft.NET\Framework64\\*version* on 64-bit systems. (For example, the location is %windir%\Microsoft.NET\Framework64\v4.030319\caspol.exe for .NET Framework 4 on a 64-bit system.) Multiple versions of the tool might be installed if your computer is running multiple versions of .NET Framework side by side. You can run the tool from the installation directory. However, we recommend that you use [Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell](/visualstudio/ide/reference/command-prompt-powershell), which does not require you to navigate to the installation folder. + The Code Access Security Policy tool is automatically installed with .NET Framework and with Visual Studio. You can find Caspol.exe in %windir%\Microsoft.NET\Framework\\*version* on 32-bit systems or %windir%\Microsoft.NET\Framework64\\*version* on 64-bit systems. (For example, the location is %windir%\Microsoft.NET\Framework64\v4.030319\caspol.exe for .NET Framework 4 on a 64-bit system.) Multiple versions of the tool might be installed if your computer is running multiple versions of .NET Framework side by side. You can run the tool from the installation directory. However, we recommend that you use [Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell](/visualstudio/ide/reference/command-prompt-powershell), which doesn't require you to navigate to the installation folder. At the command prompt, type the following: @@ -41,35 +43,35 @@ caspol [options] |Option|Description| |------------|-----------------| -|**-addfulltrust** *assembly_file*

or

**-af** *assembly_file*|Adds an assembly that implements a custom security object (such as a custom permission or a custom membership condition) to the full trust assembly list for a specific policy level. The *assembly_file* argument specifies the assembly to add. This file must be signed with a [strong name](../../standard/assembly/strong-named.md). You can sign an assembly with a strong name using the [Strong Name Tool (Sn.exe)](sn-exe-strong-name-tool.md).

Whenever a permission set containing a custom permission is added to policy, the assembly implementing the custom permission must be added to the full trust list for that policy level. Assemblies that implement custom security objects (such as custom code groups or membership conditions) used in a security policy (such as the machine policy) should always be added to the full trust assembly list. **Caution:** If the assembly implementing the custom security object references other assemblies, you must first add the referenced assemblies to the full trust assembly list. Custom security objects created using Visual Basic, C++, and JScript reference either Microsoft.VisualBasic.dll, Microsoft.VisualC.dll, or Microsoft.JScript.dll, respectively. These assemblies are not in the full trust assembly list by default. You must add the appropriate assembly to the full trust list before you add a custom security object. Failure to do so will break the security system, causing all assemblies to fail to load. In this situation, the Caspol.exe **-all -reset** option will not repair security. To repair security, you must manually edit the security files to remove the custom security object.| -|**-addgroup** {*parent_label | parent_name*} *mship pset_name* [*flags*]

or

**-ag** {*parent_label | parent_name*} *mship pset_name* [*flags*]|Adds a new code group to the code group hierarchy. You can specify either the *parent_label* or *parent_name*. The *parent_label* argument specifies the label (such as 1. or 1.1.) of the code group that is the parent of the code group being added. The *parent_name* argument specifies the name of the code group that is the parent of the code group being added. Because *parent_label* and *parent_name* can be used interchangeably, Caspol.exe must be able to distinguish between them. Therefore, *parent_name* cannot begin with a number. Additionally, *parent_name* can only contain A-Z, 0-9 and the underscore character.

The *mship* argument specifies the membership condition for the new code group. For more information, see the table of *mship* arguments later in this section.

The *pset_name* argument is the name of the permission set that will be associated with the new code group. You can also set one or more *flags* for the new group. For more information, see the table of *flags* arguments later in this section.| -|**-addpset** {*psfile* | *psfile* p*set_name*}

or

**-ap** {*named*_*psfile* | *psfile* *pset_name*}|Adds a new named permission set to policy. The permission set must be authored in XML and stored in an .xml file. If the XML file contains the name of the permission set, only that file (*psfile*) is specified. If the XML file does not contain the permission set name, you must specify both the XML file name (*psfile*) and the permission set name (*pset_name*).

Note that all permissions used in a permission set must be defined in assemblies contained in the global assembly cache.| +|**-addfulltrust** *assembly_file*

or

**-af** *assembly_file*|Adds an assembly that implements a custom security object (such as a custom permission or a custom membership condition) to the full trust assembly list for a specific policy level. The *assembly_file* argument specifies the assembly to add. This file must be signed with a [strong name](../../standard/assembly/strong-named.md). You can sign an assembly with a strong name using the [Strong Name Tool (Sn.exe)](sn-exe-strong-name-tool.md).

Whenever a permission set containing a custom permission is added to policy, the assembly implementing the custom permission must be added to the full trust list for that policy level. Assemblies that implement custom security objects (such as custom code groups or membership conditions) used in a security policy (such as the machine policy) should always be added to the full trust assembly list. **Caution:** If the assembly implementing the custom security object references other assemblies, you must first add the referenced assemblies to the full trust assembly list. Custom security objects created using Visual Basic, C++, and JScript reference either Microsoft.VisualBasic.dll, Microsoft.VisualC.dll, or Microsoft.JScript.dll, respectively. These assemblies aren't in the full trust assembly list by default. You must add the appropriate assembly to the full trust list before you add a custom security object. Failure to do so will break the security system, causing all assemblies to fail to load. In this situation, the Caspol.exe **-all -reset** option won't repair security. To repair security, you must manually edit the security files to remove the custom security object.| +|**-addgroup** {*parent_label | parent_name*} *mship pset_name* [*flags*]

or

**-ag** {*parent_label | parent_name*} *mship pset_name* [*flags*]|Adds a new code group to the code group hierarchy. You can specify either the *parent_label* or *parent_name*. The *parent_label* argument specifies the label (such as 1. or 1.1.) of the code group that is the parent of the code group being added. The *parent_name* argument specifies the name of the code group that is the parent of the code group being added. Because *parent_label* and *parent_name* can be used interchangeably, Caspol.exe must be able to distinguish between them. Therefore, *parent_name* can't begin with a number. Additionally, *parent_name* can only contain A-Z, 0-9 and the underscore character.

The *mship* argument specifies the membership condition for the new code group. For more information, see the table of *mship* arguments later in this section.

The *pset_name* argument is the name of the permission set that will be associated with the new code group. You can also set one or more *flags* for the new group. For more information, see the table of *flags* arguments later in this section.| +|**-addpset** {*psfile* | *psfile* p*set_name*}

or

**-ap** {*named*_*psfile* | *psfile* *pset_name*}|Adds a new named permission set to policy. The permission set must be authored in XML and stored in an .xml file. If the XML file contains the name of the permission set, only that file (*psfile*) is specified. If the XML file doesn't contain the permission set name, you must specify both the XML file name (*psfile*) and the permission set name (*pset_name*).

All permissions used in a permission set must be defined in assemblies contained in the global assembly cache.| |**-a**[**ll**]|Indicates that all options following this one apply to the machine, user, and enterprise policies. The **-all** option always refers to the policy of the currently logged-on user. See the **-customall** option to refer to the user policy of a user other than the current user.| |**-chggroup** {*label |name*} {*mship* | *pset_name* |

*flags* `}`

or

**-cg** {*label |name*} {*mship* | *pset_name* |

*flags* `}`|Changes a code group's membership condition, permission set, or the settings of the **exclusive**, **levelfinal**, **name**, or **description** flags. You can specify either the *label* or *name*. The *label* argument specifies the label (such as 1. or 1.1.) of the code group. The *name* argument specifies the name of the code group to change. Because *label* and *name* can be used interchangeably, Caspol.exe must be able to distinguish between them. Therefore, *name* cannot begin with a number. Additionally, *name* can only contain A-Z, 0-9 and the underscore character.

The *pset_name* argument specifies the name of the permission set to associate with the code group. See the tables later in this section for information on the *mship* and *flags* arguments.| -|**-chgpset** *psfile pset_name*

or

**-cp** *psfile pset_name*|Changes a named permission set. The *psfile* argument supplies the new definition for the permission set; it is a serialized permission set file in XML format. The *pset_name* argument specifies the name of the permission set you want to change.| +|**-chgpset** *psfile pset_name*

or

**-cp** *psfile pset_name*|Changes a named permission set. The *psfile* argument supplies the new definition for the permission set; it's a serialized permission set file in XML format. The *pset_name* argument specifies the name of the permission set you want to change.| |**-customall** *path*

or

**-ca** *path*|Indicates that all options following this one apply to the machine, enterprise, and the specified custom user policies. You must specify the location of the custom user's security configuration file with the *path* argument.| -|**-cu**[**stomuser**] *path*|Allows the administration of a custom user policy that does not belong to the user on whose behalf Caspol.exe is currently running. You must specify the location of the custom user's security configuration file with the *path* argument.| -|**-enterprise**

or

**-en**|Indicates that all options following this one apply to the enterprise level policy. Users who are not enterprise administrators do not have sufficient rights to modify the enterprise policy, although they can view it. In non-enterprise scenarios, this policy, by default, does not interfere with machine and user policy.| +|**-cu**[**stomuser**] *path*|Allows the administration of a custom user policy that doesn't belong to the user on whose behalf Caspol.exe is currently running. You must specify the location of the custom user's security configuration file with the *path* argument.| +|**-enterprise**

or

**-en**|Indicates that all options following this one apply to the enterprise level policy. Users who aren't enterprise administrators don't have sufficient rights to modify the enterprise policy, although they can view it. In non-enterprise scenarios, this policy, by default, doesn't interfere with machine and user policy.| |**-e**[**xecution**] {**on** | **off**}|Turns on or off the mechanism that checks for the permission to run before code starts to execute. **Note:** This switch is removed in .NET Framework 4 and later versions. -|**-f**[**orce**]|Suppresses the tool's self-destruct test and changes the policy as specified by the user. Normally, Caspol.exe checks whether any policy changes would prevent Caspol.exe itself from running properly; if so, Caspol.exe does not save the policy change and prints an error message. To force Caspol.exe to change policy even if this prevents Caspol.exe itself from running, use the **–force** option.| +|**-f**[**orce**]|Suppresses the tool's self-destruct test and changes the policy as specified by the user. Normally, Caspol.exe checks whether any policy changes would prevent Caspol.exe itself from running properly; if so, Caspol.exe doesn't save the policy change and prints an error message. To force Caspol.exe to change policy even if this prevents Caspol.exe itself from running, use the **–force** option.| |**-h**[**elp**]|Displays command syntax and options for Caspol.exe.| -|**-l**[**ist**]|Lists the code group hierarchy and the permission sets for the specified machine, user, enterprise, or all policy levels. Caspol.exe displays the code group's label first, followed by the name, if it is not null.| +|**-l**[**ist**]|Lists the code group hierarchy and the permission sets for the specified machine, user, enterprise, or all policy levels. Caspol.exe displays the code group's label first, followed by the name, if it isn't null.| |**-listdescription**

or

**-ld**|Lists all code group descriptions for the specified policy level.| |**-listfulltrust**

or

**-lf**|Lists the contents of the full trust assembly list for the specified policy level.| -|**-listgroups**

or

**-lg**|Displays the code groups of the specified policy level or all policy levels. Caspol.exe displays the code group's label first, followed by the name, if it is not null.| +|**-listgroups**

or

**-lg**|Displays the code groups of the specified policy level or all policy levels. Caspol.exe displays the code group's label first, followed by the name, if it isn't null.| |**-listpset** or **-lp**|Displays the permission sets for the specified policy level or all policy levels.| -|**-m**[**achine**]|Indicates that all options following this one apply to the machine level policy. Users who are not administrators do not have sufficient rights to modify the machine policy, although they can view it. For administrators, **-machine** is the default.| +|**-m**[**achine**]|Indicates that all options following this one apply to the machine level policy. Users who aren't administrators don't have sufficient rights to modify the machine policy, although they can view it. For administrators, **-machine** is the default.| |**-polchgprompt** {**on** | **off**}

or

**-pp** {**on** | **off**}|Enables or disables the prompt that is displayed whenever Caspol.exe is run using an option that would cause policy changes.| |**-quiet**

or

**-q**|Temporarily disables the prompt that is normally displayed for an option that causes policy changes. The global change prompt setting does not change. Use the option only on a single command basis to avoid disabling the prompt for all Caspol.exe commands.| |**-r**[**ecover**]|Recovers policy from a backup file. Whenever a policy change is made, Caspol.exe stores the old policy in a backup file.| -|**-remfulltrust** *assembly_file*

or

**-rf** *assembly_file*|Removes an assembly from the full trust list of a policy level. This operation should be performed if a permission set that contains a custom permission is no longer used by policy. However, you should remove an assembly that implements a custom permission from the full trust list only if the assembly does not implement any other custom permissions that are still being used. When you remove an assembly from the list, you should also remove any other assemblies that it depends on.| +|**-remfulltrust** *assembly_file*

or

**-rf** *assembly_file*|Removes an assembly from the full trust list of a policy level. This operation should be performed if a permission set that contains a custom permission is no longer used by policy. However, you should remove an assembly that implements a custom permission from the full trust list only if the assembly doesn't implement any other custom permissions that are still being used. When you remove an assembly from the list, you should also remove any other assemblies that it depends on.| |**-remgroup** {*label |name*}

or

**-rg** {l*abel | name*}|Removes the code group specified by either its label or name. If the specified code group has child code groups, Caspol.exe also removes all the child code groups.| -|**-rempset** *pset_name*

or

**-rp** *pset_name*|Removes the specified permission set from policy. The *pset_name* argument indicates which permission set to remove. Caspol.exe removes the permission set only if it is not associated with any code group. The default (built-in) permission sets cannot be removed.| +|**-rempset** *pset_name*

or

**-rp** *pset_name*|Removes the specified permission set from policy. The *pset_name* argument indicates which permission set to remove. Caspol.exe removes the permission set only if it isn't associated with any code group. The default (built-in) permission sets can't be removed.| |**-reset**

or

**-rs**|Returns policy to its default state and persists it to disk. This is useful whenever a changed policy seems to be beyond repair and you want to start over with the installation defaults. Resetting can also be convenient when you want to use the default policy as a starting point for modifications to specific security configuration files. For more information, see [Manually Editing the Security Configuration Files](#cpgrfcodeaccesssecuritypolicyutilitycaspolexeanchor1).| |**-resetlockdown**

or

**-rsld**|Returns policy to a more restrictive version of the default state and persists it to disk; creates a backup of the previous machine policy and persists it to a file called `security.config.bac`. The locked down policy is similar to the default policy, except that the policy grants no permission to code from the `Local Intranet`, `Trusted Sites`, and `Internet` zones and the corresponding code groups have no child code groups.| |**-resolvegroup** *assembly_file*

or

**-rsg** *assembly_file*|Shows the code groups that a specific assembly (*assembly_file*) belongs to. By default, this option displays the machine, user, and enterprise policy levels to which the assembly belongs. To view only one policy level, use this option with either the **-machine**, **-user**, or **-enterprise** option.| |**-resolveperm** *assembly_file*

or

**-rsp** *assembly_file*|Displays all permissions that the specified (or default) level of security policy would grant the assembly if the assembly were allowed to run. The *assembly_file* argument specifies the assembly. If you specify the **-all** option, Caspol.exe calculates the permissions for the assembly based on user, machine, and enterprise policy; otherwise, default behavior rules apply.| -|**-s**[**ecurity**] {**on** | **off**}|Turns code access security on or off. Specifying the **-s off** option does not disable role-based security. **Note:** This switch is removed in .NET Framework 4 and later versions. **Caution:** When code access security is disabled, all code access demands succeed. Disabling code access security makes the system vulnerable to attacks by malicious code such as viruses and worms. Turning off security gains some extra performance but should only be done when other security measures have been taken to help make sure overall system security is not breached. Examples of other security precautions include disconnecting from public networks, physically securing computers, and so on.| +|**-s**[**ecurity**] {**on** | **off**}|Turns code access security on or off. Specifying the **-s off** option does not disable role-based security. **Note:** This switch is removed in .NET Framework 4 and later versions. **Caution:** When code access security is disabled, all code access demands succeed. Disabling code access security makes the system vulnerable to attacks by malicious code such as viruses and worms. Turning off security gains some extra performance but should only be done when other security measures have been taken to help make sure overall system security isn't breached. Examples of other security precautions include disconnecting from public networks, physically securing computers, and so on.| |**-u**[**ser**]|Indicates that all options following this one apply to the user level policy for the user on whose behalf Caspol.exe is running. For nonadministrative users, **-user** is the default.| |**-?**|Displays command syntax and options for Caspol.exe.| @@ -84,7 +86,7 @@ caspol [options] |**-pub** { **-cert** *cert_file_name* |

**-file** *signed_file_name* | **-hex** *hex_string* }|Specifies code that has the given software publisher, as denoted by a certificate file, a signature on a file, or the hexadecimal representation of an X509 certificate. For more information about this membership condition, see .| |**-site** *website*|Specifies code that has the given site of origin. For example:

`-site** www.proseware.com`

For more information about this membership condition, see .| |**-strong -file** *file_name* {*name* | **-noname**} {*version* | **-noversion**}|Specifies code that has a specific strong name, as designated by the file name, the assembly name as a string, and the assembly version in the format *major*.*minor*.*build*.*revision*. For example:

**-strong -file** myAssembly.exe myAssembly 1.2.3.4

For more information about this membership condition, see .| -|**-url** *URL*|Specifies code that originates from the given URL. The URL must include a protocol, such as `http://` or `ftp://`. Additionally, a wildcard character (\*) can be used to specify multiple assemblies from a particular URL. **Note:** Because a URL can be identified using multiple names, using a URL as a membership condition is not a safe way to ascertain the identity of code. Where possible, use a strong name membership condition, a publisher membership condition, or the hash membership condition.

For more information about this membership condition, see .| +|**-url** *URL*|Specifies code that originates from the given URL. The URL must include a protocol, such as `http://` or `ftp://`. Additionally, a wildcard character (\*) can be used to specify multiple assemblies from a particular URL. **Note:** Because a URL can be identified using multiple names, using a URL as a membership condition isn't a safe way to ascertain the identity of code. Where possible, use a strong name membership condition, a publisher membership condition, or the hash membership condition.

For more information about this membership condition, see .| |**-zone** *zonename*|Specifies code with the given zone of origin. The *zonename* argument can be one of the following values: **MyComputer**, **Intranet**, **Trusted**, **Internet**, or **Untrusted**. For more information about this membership condition, see the Class.| The *flags* argument, which can be used with the **–addgroup** and **–chggroup** options, is specified using one of the following. @@ -92,7 +94,7 @@ caspol [options] |Argument|Description| |--------------|-----------------| |**-description** "*description*"|If used with the **–addgroup** option, specifies the description for a code group to add. If used with the **–chggroup** option, specifies the description for a code group to edit. The *description* argument must be enclosed in double quotes.| -|**-exclusive** {**on**|**off**}|When set to **on**, indicates that only the permission set associated with the code group you are adding or modifying is considered when some code fits the membership condition of the code group. When this option is set to **off**, Caspol.exe considers the permission sets of all matching code groups in the policy level.| +|**-exclusive** {**on**|**off**}|When set to **on**, indicates that only the permission set associated with the code group you're adding or modifying is considered when some code fits the membership condition of the code group. When this option is set to **off**, Caspol.exe considers the permission sets of all matching code groups in the policy level.| |**-levelfinal** {**on**|**off**}|When set to **on**, indicates that no policy level below the level in which the added or modified code group occurs is considered. This option is typically used at the machine policy level. For example, if you set this flag for a code group at the machine level and some code matches this code group's membership condition, Caspol.exe does not calculate or apply the user level policy for this code.| |**-name** "*name*"|If used with the **–addgroup** option, specifies the scripting name for a code group to add. If used with the **-chggroup** option, specifies the scripting name for a code group to edit. The *name* argument must be enclosed in double quotes. The *name* argument cannot begin with a number, and can only contain A-Z, 0-9, and the underscore character. Code groups can be referred to by this *name* instead of by their numeric label. The *name* is also highly useful for scripting purposes.| @@ -116,7 +118,7 @@ caspol [options] When a user without administrative rights runs Caspol.exe, all options refer to the user level policy unless the **–machine** option is specified. When an administrator runs Caspol.exe, all options refer to the machine policy unless the **–user** option is specified. - Caspol.exe must be granted the equivalent of the **Everything** permission set to function. The tool has a protective mechanism that prevents policy from being modified in ways that would prevent Caspol.exe from being granted the permissions it needs to run. If you try to make such changes, Caspol.exe notifies you that the requested policy change will break the tool, and the policy change is rejected. You can turn this protective mechanism off for a given command by using the **–force** option. + Caspol.exe must be granted the equivalent of the **Everything** permission set to function. The tool has a protective mechanism that prevents policy from being modified in ways that would prevent Caspol.exe from being granted the permissions it needs to run. If you try to make such changes, Caspol.exe notifies you that the requested policy change will break the tool, and the policy change is rejected. You can turn off this protective mechanism for a given command by using the **–force** option. @@ -124,7 +126,7 @@ caspol [options] Three security configuration files correspond to the three policy levels supported by Caspol.exe: one for the machine policy, one for a given user's policy, and one for the enterprise policy. These files are created on disk only when machine, user, or enterprise policy is changed using Caspol.exe. You can use the **–reset** option in Caspol.exe to save the default security policy to disk, if needed. - In most cases, manually editing the security configuration files is not recommended. But there might be scenarios in which modifying these files becomes necessary, such as when an administrator wants to edit the security configuration for a particular user. + In most cases, manually editing the security configuration files isn't recommended. But there might be scenarios in which modifying these files becomes necessary, such as when an administrator wants to edit the security configuration for a particular user. ## Examples @@ -180,7 +182,7 @@ caspol -chggroup 1.2.1. -zone Internet -exclusive on **-chgpset** - The following command changes the permission set with name `Mypset` to the permission set contained in `newpset.xml`. Note that the current release does not support changing permission sets that are being used by the code group hierarchy. + The following command changes the permission set with name `Mypset` to the permission set contained in `newpset.xml`. Note that the current release doesn't support changing permission sets that are being used by the code group hierarchy. ```console caspol -chgpset Mypset newpset.xml diff --git a/docs/framework/tools/corflags-exe-corflags-conversion-tool.md b/docs/framework/tools/corflags-exe-corflags-conversion-tool.md index 117b3346f3c60..dd8f13b04ecdc 100644 --- a/docs/framework/tools/corflags-exe-corflags-conversion-tool.md +++ b/docs/framework/tools/corflags-exe-corflags-conversion-tool.md @@ -45,8 +45,10 @@ CorFlags.exe assembly [options] ## Remarks - If no options are specified, the CorFlags Conversion tool displays the flags for the specified assembly. - +If no options are specified, the CorFlags Conversion tool displays the flags for the specified assembly. + +For more information, see section **II.25.3.3.1 Runtime flags** of the [ECMA-335 specification](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/). For information about the PE flag, see [Optional Header (Image Only)](/windows/win32/debug/pe-format#optional-header-image-only). + ## See also - [Tools](index.md) diff --git a/docs/framework/tools/ngen-exe-native-image-generator.md b/docs/framework/tools/ngen-exe-native-image-generator.md index 76cfb5a1ea743..0e5a7beba2404 100644 --- a/docs/framework/tools/ngen-exe-native-image-generator.md +++ b/docs/framework/tools/ngen-exe-native-image-generator.md @@ -27,7 +27,7 @@ The Native Image Generator (Ngen.exe) is a tool that improves the performance of > [!NOTE] > Ngen.exe compiles native images for assemblies that target the .NET Framework only. The equivalent native image generator for .NET Core is [CrossGen](https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/crossgen.md). -Changes to Ngen.exe in the .NET Framework 4: +Changes to Ngen.exe in .NET Framework 4: - Ngen.exe now compiles assemblies with full trust, and code access security (CAS) policy is no longer evaluated. @@ -73,7 +73,7 @@ The following table shows the syntax of each `action`. For descriptions of the i |Action|Description| |------------|-----------------| |`install` [`assemblyName` | `assemblyPath`] [`scenarios`] [`config`] [`/queue`[`:`{`1`|`2`|`3`}]]|Generate native images for an assembly and its dependencies and install the images in the native image cache.

If `/queue` is specified, the action is queued for the native image service. The default priority is 3. See the [Priority Levels](#PriorityTable) table.| -|`uninstall` [`assemblyName` | `assemblyPath`] [`scenarios`] [`config`]|Delete the native images of an assembly and its dependencies from the native image cache.

To uninstall a single image and its dependencies, use the same command-line arguments that were used to install the image. **Note:** Starting with the .NET Framework 4, the action `uninstall` * is no longer supported.| +|`uninstall` [`assemblyName` | `assemblyPath`] [`scenarios`] [`config`]|Delete the native images of an assembly and its dependencies from the native image cache.

To uninstall a single image and its dependencies, use the same command-line arguments that were used to install the image. **Note:** Starting with .NET Framework 4, the action `uninstall` * is no longer supported.| |`update` [`/queue`]|Update native images that have become invalid.

If `/queue` is specified, the updates are queued for the native image service. Updates are always scheduled at priority 3, so they run when the computer is idle.| |`display` [`assemblyName` | `assemblyPath`]|Display the state of the native images for an assembly and its dependencies.

If no argument is supplied, everything in the native image cache is displayed.| |`executeQueuedItems` [1|2|3]

-or-

`eqi` [1|2|3]|Execute queued compilation jobs.

If a priority is specified, compilation jobs with greater or equal priority are executed. If no priority is specified, all queued compilation jobs are executed.| @@ -133,9 +133,9 @@ The following table shows the syntax of each `action`. For descriptions of the i To run Ngen.exe, you must have administrative privileges. > [!CAUTION] -> Do not run Ngen.exe on assemblies that are not fully trusted. Starting with the .NET Framework 4, Ngen.exe compiles assemblies with full trust, and code access security (CAS) policy is no longer evaluated. +> Do not run Ngen.exe on assemblies that are not fully trusted. Starting with .NET Framework 4, Ngen.exe compiles assemblies with full trust, and code access security (CAS) policy is no longer evaluated. -Starting with the .NET Framework 4, the native images that are generated with Ngen.exe can no longer be loaded into applications that are running in partial trust. Instead, the just-in-time (JIT) compiler is invoked. +Starting with .NET Framework 4, the native images that are generated with Ngen.exe can no longer be loaded into applications that are running in partial trust. Instead, the just-in-time (JIT) compiler is invoked. Ngen.exe generates native images for the assembly specified by the `assemblyname` argument to the `install` action and all its dependencies. Dependencies are determined from references in the assembly manifest. The only scenario in which you need to install a dependency separately is when the application loads it using reflection, for example by calling the method. @@ -558,7 +558,7 @@ The native image task is registered once for each CPU architecture supported on |NET Framework NGEN v4.0.30319|Yes|Yes| |NET Framework NGEN v4.0.30319 64|No|Yes| -The native image task is available in the .NET Framework 4.5 and later versions, when running on Windows 8 or later. On earlier versions of Windows, the .NET Framework uses the [Native Image Service](#native-image-service). +The native image task is available in .NET Framework 4.5 and later versions, when running on Windows 8 or later. On earlier versions of Windows, the .NET Framework uses the [Native Image Service](#native-image-service). ### Task Lifetime diff --git a/docs/framework/ui-automation/find-a-ui-automation-element-based-on-a-property-condition.md b/docs/framework/ui-automation/find-a-ui-automation-element-based-on-a-property-condition.md index 75ee943895bd2..0d2be21fd39a1 100644 --- a/docs/framework/ui-automation/find-a-ui-automation-element-based-on-a-property-condition.md +++ b/docs/framework/ui-automation/find-a-ui-automation-element-based-on-a-property-condition.md @@ -15,17 +15,17 @@ ms.topic: how-to > [!NOTE] > This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the namespace. For the latest information about UI Automation, see [Windows Automation API: UI Automation](/windows/win32/winauto/entry-uiauto-win32). - This topic contains example code that shows how to locate an element within the UI Automation tree based on a specific property or properties. +This article contains example code that shows how to locate an element within the UI Automation tree based on a specific property or properties. ## Example - In the following example, a set of property conditions are specified that identify a certain element (or elements) of interest in the tree. A search for all matching elements is then performed with the method that incorporates a series of boolean operations to limit the number of matching elements. + In the following example, a set of property conditions are specified that identify a certain element (or elements) of interest in the tree. A search for all matching elements is then performed with the method that incorporates a series of Boolean operations to limit the number of matching elements. > [!NOTE] > When searching from the , you should try to obtain only direct children. A search for descendants might iterate through hundreds or even thousands of elements, possibly resulting in a stack overflow. If you are attempting to obtain a specific element at a lower level, you should start your search from the application window or from a container at a lower level. - [!code-csharp[InvokePatternApp#1100](../../../samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.cs#1100)] - [!code-vb[InvokePatternApp#1100](../../../samples/snippets/visualbasic/VS_Snippets_Wpf/InvokePatternApp/VisualBasic/Client.vb#1100)] +[!code-csharp[InvokePatternApp#1100](../../../samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.cs#1100)] +[!code-vb[InvokePatternApp#1100](../../../samples/snippets/visualbasic/VS_Snippets_Wpf/InvokePatternApp/VisualBasic/InvokePatternClient/Client.vb#1100)] ## See also diff --git a/docs/framework/ui-automation/invoke-a-control-using-ui-automation.md b/docs/framework/ui-automation/invoke-a-control-using-ui-automation.md index d4ee495a65e7f..b581c51dafc4d 100644 --- a/docs/framework/ui-automation/invoke-a-control-using-ui-automation.md +++ b/docs/framework/ui-automation/invoke-a-control-using-ui-automation.md @@ -30,10 +30,10 @@ ms.topic: how-to This example uses the method of the class to generate an object and invoke a control by using the method. - [!code-csharp[InvokePatternApp#1100](../../../samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.cs#1100)] - [!code-vb[InvokePatternApp#1100](../../../samples/snippets/visualbasic/VS_Snippets_Wpf/InvokePatternApp/VisualBasic/Client.vb#1100)] -[!code-csharp[InvokePatternApp#1102](../../../samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.cs#1102)] -[!code-vb[InvokePatternApp#1102](../../../samples/snippets/visualbasic/VS_Snippets_Wpf/InvokePatternApp/VisualBasic/Client.vb#1102)] +[!code-csharp[InvokePatternApp#1100](../../../samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.cs#1100)] +[!code-vb[InvokePatternApp#1100](../../../samples/snippets/visualbasic/VS_Snippets_Wpf/InvokePatternApp/VisualBasic/InvokePatternClient/Client.vb#1100)] +[!code-csharp[InvokePatternApp#1102](../../../samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.cs#1102)] +[!code-vb[InvokePatternApp#1102](../../../samples/snippets/visualbasic/VS_Snippets_Wpf/InvokePatternApp/VisualBasic/InvokePatternClient/Client.vb#1102)] ## See also diff --git a/docs/framework/unmanaged-api/debugging/closeclrenumeration-function-for-silverlight.md b/docs/framework/unmanaged-api/debugging/closeclrenumeration-function-for-silverlight.md new file mode 100644 index 0000000000000..f21f5cdda34d3 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/closeclrenumeration-function-for-silverlight.md @@ -0,0 +1,65 @@ +--- +description: "Learn more about: CloseCLREnumeration Function for Silverlight" +title: "CloseCLREnumeration Function for Silverlight" +ms.date: "03/30/2017" +api_name: + - "CloseCLREnumeration" +api_location: + - "dbgshim.dll" +api_type: + - "COM" +f1_keywords: + - "CloseCLREnumeration" +helpviewer_keywords: + - "debugging API [Silverlight]" + - "Silverlight, debugging" + - "CloseCLR Enumeration function" +ms.assetid: 5e3c3958-80bb-43b1-a96b-dd3e6dbd9cd7 +topic_type: + - "apiref" +--- +# CloseCLREnumeration Function for Silverlight + +Closes any valid common language runtime (CLR) continue-startup events located in an array of handles returned by the [EnumerateCLRs function](enumerateclrs-function.md), and frees the memory for the handle and string path arrays. + +## Syntax + +```cpp +HRESULT CloseCLREnumeration ( + [in] DWORD pHandleArray, + [in] LPWSTR** pStringArray, + [in] DWORD* dwArrayLength +); +``` + +## Parameters + + `pHandleArray` + [in] Pointer to the array of event handles returned from the [EnumerateCLRs function](enumerateclrs-function.md). + + `pStringArray` + [in] Pointer to the array of CLR string paths returned from the [EnumerateCLRs function](enumerateclrs-function.md). + + `dwArrayLength` + [in] DWORD that contains the size (length) of either `pHandleArray` or `pStringArray` (they are the same). + +## Return Value + + S_OK + Handles opened by the [EnumerateCLRs function](enumerateclrs-function.md) are closed, and memory allocated for the handle and string arrays is freed. + + E_INVALIDARG + The length of `pHandleArray` does not match the length that is passed in `dwArrayLength`. + + E_FAIL (or other E_ return codes) + The function is unable to free the memory for `pHandleArray` and `pStringArray`. + +## Requirements + + **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll + + **.NET Framework Versions:** 3.5 SP1 diff --git a/docs/framework/unmanaged-api/debugging/closeclrenumeration-function.md b/docs/framework/unmanaged-api/debugging/closeclrenumeration-function.md index ba0ed12dbbea5..df27180ddbb0c 100644 --- a/docs/framework/unmanaged-api/debugging/closeclrenumeration-function.md +++ b/docs/framework/unmanaged-api/debugging/closeclrenumeration-function.md @@ -1,18 +1,18 @@ --- description: "Learn more about: CloseCLREnumeration Function" title: "CloseCLREnumeration Function" -ms.date: "03/30/2017" +ms.date: "03/21/2022" api_name: - "CloseCLREnumeration" api_location: - "dbgshim.dll" -api_type: - - "COM" + - "libdbgshim.so" + - "libdbgshim.dylib" f1_keywords: - "CloseCLREnumeration" helpviewer_keywords: - - "debugging API [Silverlight]" - - "Silverlight, debugging" + - "debugging API [.NET Core]" + - ".NET Core, debugging" - "CloseCLR Enumeration function" ms.assetid: 5e3c3958-80bb-43b1-a96b-dd3e6dbd9cd7 topic_type: @@ -34,13 +34,13 @@ HRESULT CloseCLREnumeration ( ## Parameters - `pHandleArray` + `pHandleArray`\ [in] Pointer to the array of event handles returned from the [EnumerateCLRs function](enumerateclrs-function.md). - `pStringArray` + `pStringArray`\ [in] Pointer to the array of CLR string paths returned from the [EnumerateCLRs function](enumerateclrs-function.md). - `dwArrayLength` + `dwArrayLength`\ [in] DWORD that contains the size (length) of either `pHandleArray` or `pStringArray` (they are the same). ## Return Value @@ -56,10 +56,10 @@ HRESULT CloseCLREnumeration ( ## Requirements - **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). **Header:** dbgshim.h - **Library:** dbgshim.dll + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib - **.NET Framework Versions:** 3.5 SP1 + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/closeresumehandle-function.md b/docs/framework/unmanaged-api/debugging/closeresumehandle-function.md new file mode 100644 index 0000000000000..deaef9351713b --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/closeresumehandle-function.md @@ -0,0 +1,54 @@ +--- +description: "Learn more about: CloseResumeHandle Function" +title: "CloseResumeHandle Function" +ms.date: "03/21/2022" +api_name: + - "CloseResumeHandle" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +f1_keywords: + - "CloseResumeHandle" +helpviewer_keywords: + - "debugging API [.NET Core]" + - ".NET Core, debugging" + - "CloseResumeHandle function" +ms.assetid: 5e3c3958-80bb-43b1-a96b-dd3e6dbd9cd7 +topic_type: + - "apiref" +--- +# CloseResumeHandle Function + +Closes the handle returned by the [CreateProcessForLaunch function](createprocessforlaunch-function.md). + +## Syntax + +```cpp +HRESULT CloseResumeHandle ( + [in] HANDLE hResumeHandle +); +``` + +## Parameters + + `hResumeHandle`\ + [in] The resume handle returned by [CreateProcessForLaunch function](createprocessforlaunch-function.md). + +## Return Value + + S_OK + The handle was successfully closed. + + E_FAIL (or other E_ return codes) + The handle was invalid. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/clrcreateinstance-function.md b/docs/framework/unmanaged-api/debugging/clrcreateinstance-function.md new file mode 100644 index 0000000000000..112796ade8025 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/clrcreateinstance-function.md @@ -0,0 +1,85 @@ +--- +description: "Learn more about: CLRCreateInstance for .NET Core Function" +title: "CLRCreateInstance for .NET Core Function" +ms.date: "03/25/2022" +api_name: + - "CLRCreateInstance" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +api_type: + - "COM" +f1_keywords: + - "CLRCreateInstance" + - "CreateInterface" +helpviewer_keywords: + - "CLRCreateInstance function [.NET Core Debugging]" + - "CreateInterface function" +ms.assetid: 5de13327-96c6-4697-a89e-b8bf40717855 +topic_type: + - "apiref" +--- +# CLRCreateInstance for .NET Core Function + +Provides the [ICLRDebugging](iclrdebugging-interface.md) interface. + +## Syntax + +```cpp +HRESULT CLRCreateInstance ( + [in] REFCLSID clsid, + [in] REFIID riid, + [out] LPVOID * ppInterface +); +``` + +## Parameters + + `clsid` + [in] Supports only the CLSID_CLRDebugging class identifier. + + `riid` + [in] Supports only the IID_ICLRDebugging interface identifiers. + + `ppInterface` + [out] A [ICLRDebugging](iclrdebugging-interface.md) instance. + +## Return Value + + This method returns the following specific HRESULTs as well as HRESULT errors that indicate method failure. + +|HRESULT|Description| +|-------------|-----------------| +|S_OK|The method completed successfully.| +|E_POINTER|`ppInterface` is null.| + +## Remarks + + The following table shows the supported combinations for `clsid` and `riid`. + +|`clsid`|`riid`| +|--------------|------------| +|CLSID_CLRDebugging|IID_ICLRDebugging| + + The following code shows how to use `CLRCreateInstance` to get to get the interface: + +```cpp +#include +#pragma comment(lib, "mscoree.lib") + +ICLRDebugging *pCLRDebugging = NULL; +HRESULT hr; +hr = CLRCreateInstance (CLSID_CLRDebugging, IID_ICLRDebugging, + (LPVOID*)&pCLRDebugging); +``` + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion-function.md b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion-function.md new file mode 100644 index 0000000000000..60a577b1c4c67 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion-function.md @@ -0,0 +1,67 @@ +--- +description: "Learn more about: CreateDebuggingInterfaceFromVersion Function for .NET Core" +title: "CreateDebuggingInterfaceFromVersion Function for .NET Core" +ms.date: "03/21/2022" +f1_keywords: + - "CreateDebuggingInterfaceFromVersion" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +helpviewer_keywords: + - "CreateDebuggingInterfaceFromVersion function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# CreateDebuggingInterfaceFromVersion Function for .NET Core + +Accepts a common language runtime (CLR) version string that is returned from the [CreateVersionStringFromModule function](createversionstringfrommodule-function.md), and returns a corresponding debugger interface (typically, [ICorDebug](icordebug-interface.md)). + +## Syntax + +```cpp +HRESULT CreateDebuggingInterfaceFromVersion ( + [in] LPCWSTR szDebuggeeVersion, + [out] IUnknown** ppCordb, +); +``` + +## Parameters + + `szDebuggeeVersion`\ + [in] Version string of the CLR in the target debuggee, which is returned by the [CreateVersionStringFromModule function](createversionstringfrommodule-function.md). + + `ppCordb`\ + [out] Pointer to a pointer to a COM object (`IUnknown`). This object will be cast to an [ICorDebug](icordebug-interface.md) object before it is returned. + +## Return Value + + `S_OK`\ + `ppCordb` references a valid object that implements the [ICorDebug interface](icordebug-interface.md) interface. + + `E_INVALIDARG`\ + Either `szDebuggeeVersion` or `ppCordb` is null. + + `CORDBG_E_DEBUG_COMPONENT_MISSING`\ + A component that is necessary for CLR debugging cannot be located. Either _mscordbi.dll_ or _mscordaccore.dll_ was not found in the same directory as the target CoreCLR.dll. + + `CORDBG_E_INCOMPATIBLE_PROTOCOL`\ + Either mscordbi.dll or mscordaccore.dll is not the same version as the target CoreCLR.dll. + + `E_FAIL` (or other `E_` return codes)\ + Unable to return an [ICorDebug interface](icordebug-interface.md). + +## Remarks + + The interface that is returned provides the facilities for attaching to a CLR in a target process and debugging the managed code that the CLR is running. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion2-function.md b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion2-function.md new file mode 100644 index 0000000000000..02797467fed21 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion2-function.md @@ -0,0 +1,75 @@ +--- +description: "Learn more about: CreateDebuggingInterfaceFromVersion2 Function" +title: "CreateDebuggingInterfaceFromVersion2 Function" +ms.date: "03/21/2022" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +f1_keywords: + - "CreateDebuggingInterfaceFromVersion2" +helpviewer_keywords: + - "CreateDebuggingInterfaceFromVersion2 function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# CreateDebuggingInterfaceFromVersion2 Function for .NET Core + +Accepts a common language runtime (CLR) version string that is returned from the [CreateVersionStringFromModule](createversionstringfrommodule-function.md) function, and returns a corresponding debugger interface (typically, [ICorDebug](icordebug-interface.md)). + +## Syntax + +```cpp +HRESULT CreateDebuggingInterfaceFromVersion2 ( + [in] int iDebuggerVersion, + [in] LPCWSTR szDebuggeeVersion, + [in] LPCWSTR szApplicationGroupId, + [out] IUnknown** ppCordb, +); +``` + +## Parameters + + `iDebuggerVersion`\ + [in] The version of interface the debugger expects. + + `szDebuggeeVersion`\ + [in] Version string of the CLR in the target debuggee, which is returned by the [CreateVersionStringFromModule](createversionstringfrommodule-function.md) function. + + `szApplicationGroupId`\ + [in] A string representing the application group ID of a sandboxed process running in macOS. Pass NULL if the process is not running in a sandbox on macOS or on other platforms. + + `ppCordb`\ + [out] Pointer to a pointer to a COM object (`IUnknown`). This object will be cast to an [ICorDebug](icordebug-interface.md) object before it is returned. + +## Return Value + + `S_OK`\ + `ppCordb` references a valid object that implements the [ICorDebug interface](icordebug-interface.md) interface. + + `E_INVALIDARG`\ + Either `szDebuggeeVersion` or `ppCordb` is null. + + `CORDBG_E_DEBUG_COMPONENT_MISSING`\ + A component that is necessary for CLR debugging cannot be located. Either _mscordbi.dll_ or _mscordaccore.dll_ was not found in the same directory as the target CoreCLR.dll. + + `CORDBG_E_INCOMPATIBLE_PROTOCOL`\ + Either mscordbi.dll or mscordaccore.dll is not the same version as the target CoreCLR.dll. + + `E_FAIL` (or other `E_` return codes)\ + Unable to return an [ICorDebug interface](icordebug-interface.md). + +## Remarks + + The interface that is returned provides the facilities for attaching to a CLR in a target process and debugging the managed code that the CLR is running. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_31](../../../../includes/net-core-31-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion3-function.md b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion3-function.md new file mode 100644 index 0000000000000..b27dd7a816f22 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversion3-function.md @@ -0,0 +1,79 @@ +--- +description: "Learn more about: CreateDebuggingInterfaceFromVersion3 Function" +title: "CreateDebuggingInterfaceFromVersion3 Function" +ms.date: "03/21/2022" +f1_keywords: + - "CreateDebuggingInterfaceFromVersion3" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +helpviewer_keywords: + - "CreateDebuggingInterfaceFromVersion3 function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# CreateDebuggingInterfaceFromVersion3 Function for .NET Core + +Accepts a common language runtime (CLR) version string that is returned from the [CreateVersionStringFromModule](createversionstringfrommodule-function.md) function, and returns a corresponding debugger interface (typically, [ICorDebug](icordebug-interface.md)). + +## Syntax + +```cpp +HRESULT CreateDebuggingInterfaceFromVersion3 ( + [in] int iDebuggerVersion, + [in] LPCWSTR szDebuggeeVersion, + [in] LPCWSTR szApplicationGroupId, + [in] ICLRDebuggingLibraryProvider3* pLibraryProvider, + [out] IUnknown** ppCordb, +); +``` + +## Parameters + + `iDebuggerVersion`\ + [in] The version of interface the debugger expects. + + `szDebuggeeVersion`\ + [in] Version string of the CLR in the target debuggee, which is returned by the [CreateVersionStringFromModule](createversionstringfrommodule-function.md) function. + + `szApplicationGroupId`\ + [in] A string representing the application group ID of a sandboxed process running in macOS. Pass NULL if the process is not running in a sandbox on macOS or on other platforms. + + `pLibraryProvider`\ + [in] A callback interface instance for locating DBI and DAC. See [ICLRDebuggingLibraryProvider3](iclrdebugginglibraryprovider3-interface.md) interface. + + `ppCordb`\ + [out] Pointer to a pointer to a COM object (`IUnknown`). This object will be cast to an [ICorDebug](icordebug-interface.md) object before it is returned. + +## Return Value + + `S_OK`\ + `ppCordb` references a valid object that implements the [ICorDebug interface](icordebug-interface.md) interface. + + `E_INVALIDARG`\ + Either `szDebuggeeVersion` or `ppCordb` is null. + + `CORDBG_E_DEBUG_COMPONENT_MISSING`\ + A component that is necessary for CLR debugging cannot be located. Either _mscordbi.dll_ or _mscordaccore.dll_ was not found in the same directory as the target CoreCLR.dll. + + `CORDBG_E_INCOMPATIBLE_PROTOCOL`\ + Either mscordbi.dll or mscordaccore.dll is not the same version as the target CoreCLR.dll. + + `E_FAIL` (or other `E_` return codes)\ + Unable to return an [ICorDebug interface](icordebug-interface.md). + +## Remarks + + The interface that is returned provides the facilities for attaching to a CLR in a target process and debugging the managed code that the CLR is running. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_60](../../../../includes/net-core-60-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversionex-function.md b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversionex-function.md new file mode 100644 index 0000000000000..1a2fd1ed8f976 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/createdebugginginterfacefromversionex-function.md @@ -0,0 +1,71 @@ +--- +description: "Learn more about: CreateDebuggingInterfaceFromVersionEx Function" +title: "CreateDebuggingInterfaceFromVersionEx Function" +ms.date: "03/21/2022" +f1_keywords: + - "CreateDebuggingInterfaceFromVersionEx" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +helpviewer_keywords: + - "CreateDebuggingInterfaceFromVersionEx function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# CreateDebuggingInterfaceFromVersionEx Function for .NET Core + +Accepts a common language runtime (CLR) version string that is returned from the [CreateVersionStringFromModule](createversionstringfrommodule-function.md) function, and returns a corresponding debugger interface (typically, [ICorDebug](icordebug-interface.md)). + +## Syntax + +```cpp +HRESULT CreateDebuggingInterfaceFromVersionEx ( + [in] int iDebuggerVersion, + [in] LPCWSTR szDebuggeeVersion, + [out] IUnknown** ppCordb, +); +``` + +## Parameters + + `iDebuggerVersion`\ + [in] The version of interface the debugger expects. + + `szDebuggeeVersion`\ + [in] Version string of the CLR in the target debuggee, which is returned by the [CreateVersionStringFromModule](createversionstringfrommodule-function.md) function. + + `ppCordb`\ + [out] Pointer to a pointer to a COM object (`IUnknown`). This object will be cast to an [ICorDebug](icordebug-interface.md) object before it is returned. + +## Return Value + + `S_OK`\ + `ppCordb` references a valid object that implements the [ICorDebug interface](icordebug-interface.md) interface. + + `E_INVALIDARG`\ + Either `szDebuggeeVersion` or `ppCordb` is null. + + `CORDBG_E_DEBUG_COMPONENT_MISSING`\ + A component that is necessary for CLR debugging cannot be located. Either _mscordbi.dll_ or _mscordaccore.dll_ was not found in the same directory as the target CoreCLR.dll. + + `CORDBG_E_INCOMPATIBLE_PROTOCOL`\ + Either mscordbi.dll or mscordaccore.dll is not the same version as the target CoreCLR.dll. + + `E_FAIL` (or other `E_` return codes)\ + Unable to return an [ICorDebug interface](icordebug-interface.md). + +## Remarks + + The interface that is returned provides the facilities for attaching to a CLR in a target process and debugging the managed code that the CLR is running. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/createprocessforlaunch-function.md b/docs/framework/unmanaged-api/debugging/createprocessforlaunch-function.md new file mode 100644 index 0000000000000..4e458ca15c921 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/createprocessforlaunch-function.md @@ -0,0 +1,78 @@ +--- +description: "Learn more about: CreateProcessForLaunch Function" +title: "CreateProcessForLaunch Function" +ms.date: "03/21/2022" +api_name: + - "CreateProcessForLaunch" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +f1_keywords: + - "CreateProcessForLaunch" +helpviewer_keywords: + - "debugging API [.NET Core]" + - ".NET Core, debugging" + - "CreateProcessForLaunch function" +ms.assetid: 3d2fe9bd-75ef-4364-84a6-da1e1994ac1a +topic_type: + - "apiref" +--- +# CreateProcessForLaunch Function + +A subset of the Windows CreateProcess that can be supported cross-platform. + +## Syntax + +```cpp +HRESULT CreateProcessForLaunch ( + [in] LPWSTR lpCommandLine, + [in] BOOL bSuspendProcess, + [in] LPVOID lpEnvironment, + [in] LPCWSTR lpCurrentDirectory, + [out] PDWORD pProcessId, + [out] HANDLE *pResumeHandle +); +``` + +## Parameters + + `lpCommandLine`\ + [in] The command line to be executed. + + `bSuspendProcess`\ + [in] If this parameter is TRUE, suspend the process for launch. + + `lpEnvironment`\ + [in, optional] A pointer to the environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process. + + `lpCurrentDirectory`\ + [in, optional] The full path to the current directory for the process. If this parameter is NULL, the new process will have the same current drive and directory as the calling process. + + `pProcessId`\ + [out] The id to identify the process created. + + `pResumeHandle`\ + [out] The handle to use with ResumeProcess to resume the process if bSuspendProcess is TRUE. + +## Return Value + + S_OK + The process was successfully created. + + E_FAIL (or other E_ return codes) + The launch failed. + +## Remarks + +See the Win32 CreateProcess API for more details. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/createversionstringfrommodule-function-for-silverlight.md b/docs/framework/unmanaged-api/debugging/createversionstringfrommodule-function-for-silverlight.md new file mode 100644 index 0000000000000..94256e6e88684 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/createversionstringfrommodule-function-for-silverlight.md @@ -0,0 +1,84 @@ +--- +description: "Learn more about: CreateVersionStringFromModule Function for Silverlight" +title: "CreateVersionStringFromModule Function for Silverlight" +ms.date: "03/30/2017" +api_name: + - "CreateVersionStringFromModule" +api_location: + - "dbgshim.dll" +f1_keywords: + - "CreateVersionStringFromModule" +helpviewer_keywords: + - "debugging API [Silverlight]" + - "Silverlight, debugging" + - "CreateVersionStringFromModule function" +ms.assetid: 3d2fe9bd-75ef-4364-84a6-da1e1994ac1a +topic_type: + - "apiref" +--- +# CreateVersionStringFromModule Function for Silverlight + +Creates a version string from a common language runtime (CLR) path in a target process. + +## Syntax + +```cpp +HRESULT CreateVersionStringFromModule ( + [in] DWORD pidDebuggee, + [in] LPCWSTR szModuleName, + [out, size_is(cchBuffer), + length_is(*pdwLength)] LPWSTR Buffer, + [in] DWORD cchBuffer, + [out] DWORD* pdwLength +); +``` + +## Parameters + + `pidDebuggee` + [in] Identifier of the process in which the target CLR is loaded. + + `szModuleName` + [in] Full or relative path to the target CLR that is loaded in the process. + + `pBuffer` + [out] Return buffer for storing the version string for the target CLR. + + `cchBuffer` + [in] Size of `pBuffer`. + + `pdwLength` + [out] Length of the version string returned by `pBuffer`. + +## Return Value + + S_OK + The version string for the target CLR was successfully returned in `pBuffer`. + + E_INVALIDARG + `szModuleName` is null, or either `pBuffer` or `cchBuffer` is null. `pBuffer` and `cchBuffer` must both be null or non-null. + + HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) + `pdwLength` is greater than `cchBuffer`. This may be an expected result if you have passed null for both `pBuffer` and `cchBuffer`, and queried the necessary buffer size by using `pdwLength`. + + HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND) + `szModuleName` does not contain a path to a valid CLR in the target process. + + E_FAIL (or other E_ return codes) + `pidDebuggee` does not refer to a valid process, or other failure. + +## Remarks + + This function accepts a CLR process that is identified by `pidDebuggee` and a string path that is specified by `szModuleName`. The version string is returned in the buffer that `pBuffer` points to. This string is opaque to the function user; that is, there is no intrinsic meaning in the version string itself. It is used solely in the context of this function and the [CreateDebuggingInterfaceFromVersion function](createdebugginginterfacefromversion-function-for-silverlight.md). + + This function should be called twice. When you call it the first time, pass null for both `pBuffer` and `cchBuffer`. When you do this, the size of the buffer necessary for `pBuffer` will be returned in `pdwLength`. You can then call the function a second time, and pass the buffer in `pBuffer` and its size in `cchBuffer`. + +## Requirements + + **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll + + **.NET Framework Versions:** 3.5 SP1 diff --git a/docs/framework/unmanaged-api/debugging/createversionstringfrommodule-function.md b/docs/framework/unmanaged-api/debugging/createversionstringfrommodule-function.md index 60d2150a7f620..7752e39b97884 100644 --- a/docs/framework/unmanaged-api/debugging/createversionstringfrommodule-function.md +++ b/docs/framework/unmanaged-api/debugging/createversionstringfrommodule-function.md @@ -1,18 +1,18 @@ --- description: "Learn more about: CreateVersionStringFromModule Function" title: "CreateVersionStringFromModule Function" -ms.date: "03/30/2017" +ms.date: "03/21/2022" api_name: - "CreateVersionStringFromModule" api_location: - "dbgshim.dll" -api_type: - - "COM" + - "libdbgshim.so" + - "libdbgshim.dylib" f1_keywords: - "CreateVersionStringFromModule" helpviewer_keywords: - - "debugging API [Silverlight]" - - "Silverlight, debugging" + - "debugging API [.NET Core]" + - ".NET Core, debugging" - "CreateVersionStringFromModule function" ms.assetid: 3d2fe9bd-75ef-4364-84a6-da1e1994ac1a topic_type: @@ -29,7 +29,7 @@ HRESULT CreateVersionStringFromModule ( [in] DWORD pidDebuggee, [in] LPCWSTR szModuleName, [out, size_is(cchBuffer), - length_is(*pdwLength)] LPWSTR Buffer, + length_is(*pdwLength)] LPWSTR Buffer, [in] DWORD cchBuffer, [out] DWORD* pdwLength ); @@ -37,19 +37,19 @@ HRESULT CreateVersionStringFromModule ( ## Parameters - `pidDebuggee` + `pidDebuggee`\ [in] Identifier of the process in which the target CLR is loaded. - `szModuleName` + `szModuleName`\ [in] Full or relative path to the target CLR that is loaded in the process. - `pBuffer` + `pBuffer`\ [out] Return buffer for storing the version string for the target CLR. - `cchBuffer` + `cchBuffer`\ [in] Size of `pBuffer`. - `pdwLength` + `pdwLength`\ [out] Length of the version string returned by `pBuffer`. ## Return Value @@ -71,16 +71,16 @@ HRESULT CreateVersionStringFromModule ( ## Remarks - This function accepts a CLR process that is identified by `pidDebuggee` and a string path that is specified by `szModuleName`. The version string is returned in the buffer that `pBuffer` points to. This string is opaque to the function user; that is, there is no intrinsic meaning in the version string itself. It is used solely in the context of this function and the [CreateDebuggingInterfaceFromVersion function](createdebugginginterfacefromversion-function-for-silverlight.md). + This function accepts a CLR process that is identified by `pidDebuggee` and a string path that is specified by `szModuleName`. The version string is returned in the buffer that `pBuffer` points to. This string is opaque to the function user; that is, there is no intrinsic meaning in the version string itself. It is used solely in the context of this function and the [CreateDebuggingInterfaceFromVersion function](createdebugginginterfacefromversion-function.md). This function should be called twice. When you call it the first time, pass null for both `pBuffer` and `cchBuffer`. When you do this, the size of the buffer necessary for `pBuffer` will be returned in `pdwLength`. You can then call the function a second time, and pass the buffer in `pBuffer` and its size in `cchBuffer`. ## Requirements - **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). **Header:** dbgshim.h - **Library:** dbgshim.dll + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib - **.NET Framework Versions:** 3.5 SP1 + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/debugging-enumerations.md b/docs/framework/unmanaged-api/debugging/debugging-enumerations.md index 8d4622c68d8a0..28c9442cc01e9 100644 --- a/docs/framework/unmanaged-api/debugging/debugging-enumerations.md +++ b/docs/framework/unmanaged-api/debugging/debugging-enumerations.md @@ -127,6 +127,9 @@ This section describes the unmanaged enumerations that the debugging API uses. [LogSwitchCallReason Enumeration](logswitchcallreason-enumeration.md) Indicates the operation that was performed on a debugging/tracing switch. + + [LIBRARY_PROVIDER_INDEX_TYPE Enumeration](libraryproviderindextype-enumeration.md) + The type of index information passed to a library provider. [VariableLocationType Enumeration](variablelocationtype-enumeration.md) Indicates the native location type of a variable. diff --git a/docs/framework/unmanaged-api/debugging/dotnet-debugging.md b/docs/framework/unmanaged-api/debugging/dotnet-debugging.md new file mode 100644 index 0000000000000..17be5b7777ce5 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/dotnet-debugging.md @@ -0,0 +1,70 @@ +--- +description: "Learn more about: .NET Core Debugging" +title: ".NET Core Debugging" +ms.date: "03/21/2022" +helpviewer_keywords: + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 5e903e04-17d0-4014-ac9a-a43330ec8b1c +--- +# .NET Core Debugging + +The topics in this section describe the environment and interfaces that the common language runtime (CLR) provides to support debugging .NET applications that are running on the Windows, Linux or macOS operating systems. + +## In This Section + + [CreateProcessForLaunch Function](createprocessforlaunch-function.md) + A subset of the Windows CreateProcess that can be supported cross-platform. + + [ResumeProcess Function](resumeprocess-function.md) + Resumes the process using the resume handle returned by the [CreateProcessForLaunch function](createprocessforlaunch-function.md). + + [CloseResumeHandle Function](closeresumehandle-function.md) + Closes the handle returned by the [CreateProcessForLaunch function](createprocessforlaunch-function.md). + + [RegisterForRuntimeStartup Function](registerforruntimestartup-function.md) + Executes the callback when the .NET Core runtime starts in the specified process. + + [RegisterForRuntimeStartupEx Function](registerforruntimestartupex-function.md) + Executes the callback when the .NET Core runtime starts in the specified process. + + [RegisterForRuntimeStartup3 Function](registerforruntimestartup3-function.md) + Executes the callback when the .NET Core runtime starts in the specified process. + + [UnregisterForRuntimeStartup Function](unregisterforruntimestartup-function.md) + Stops/cancels runtime startup notification. + + [EnumerateCLRs Function](enumerateclrs-function.md) + Provides a mechanism for enumerating the CLRs in a process. + + [CloseCLREnumeration Function](closeclrenumeration-function.md) + Closes any valid CLR continue-startup events located in an array of handles returned by the [EnumerateCLRs Function](enumerateclrs-function.md), and frees the memory for the handle and string path arrays. + + [CreateVersionStringFromModule Function](createversionstringfrommodule-function.md) + Creates a version string from a CLR path in a target process. + + [CreateDebuggingInterfaceFromVersion Function](createdebugginginterfacefromversion-function.md) + Accepts a CLR version string returned from [CreateVersionStringFromModule Function](createversionstringfrommodule-function.md)function, and returns a corresponding debugger interface. + + [CreateDebuggingInterfaceFromVersionEx Function](createdebugginginterfacefromversionex-function.md) + Accepts a CLR version string returned from [CreateVersionStringFromModule Function](createversionstringfrommodule-function.md)function, and returns a corresponding debugger interface. + + [CreateDebuggingInterfaceFromVersion2 Function](createdebugginginterfacefromversion2-function.md) + Accepts a CLR version string returned from [CreateVersionStringFromModule Function](createversionstringfrommodule-function.md)function, and returns a corresponding debugger interface. + + [CreateDebuggingInterfaceFromVersion3 Function](createdebugginginterfacefromversion3-function.md) + Accepts a CLR version string returned from [CreateVersionStringFromModule Function](createversionstringfrommodule-function.md)function, and returns a corresponding debugger interface. + + [GetStartupNotificationEvent Function](getstartupnotificationevent-function.md) + Creates or opens an event handle that will be signaled upon by any common language runtime (CLR) that is loading in the specified target process. + + [CLRCreateInstance Function](clrcreateinstance-function.md) + Provides the [ICLRDebugging](iclrdebugging-interface.md) interface. + +## See also + +- [Debugging Coclasses](debugging-coclasses.md) +- [Debugging Interfaces](debugging-interfaces.md) +- [Debugging Global Static Functions](debugging-global-static-functions.md) +- [Debugging Enumerations](debugging-enumerations.md) +- [Debugging Structures](debugging-structures.md) diff --git a/docs/framework/unmanaged-api/debugging/enumerateclrs-function-for-silverlight.md b/docs/framework/unmanaged-api/debugging/enumerateclrs-function-for-silverlight.md new file mode 100644 index 0000000000000..ed1b3a5c84da7 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/enumerateclrs-function-for-silverlight.md @@ -0,0 +1,80 @@ +--- +description: "Learn more about: EnumerateCLRs Function for Silverlight" +title: "EnumerateCLRs Function for Silverlight" +ms.date: "03/30/2017" +api_name: + - "EnumerateCLRs" +api_location: + - "dbgshim.dll" +f1_keywords: + - "EnumerateCLRs" +helpviewer_keywords: + - "debugging API [Silverlight]" + - "Silverlight, debugging" + - "EnumerateCLRs function" +ms.assetid: f8d50cb3-ec4f-4529-8fe3-bd61fd28e13c +topic_type: + - "apiref" +--- +# EnumerateCLRs Function for Silverlight + +Provides a mechanism for enumerating the CLRs in a process. + +## Syntax + +```cpp +HRESULT EnumerateCLRs ( + [in] DWORD debuggeePID, + [out] HANDLE** ppHandleArrayOut, + [out] LPWSTR** ppStringArrayOut, + [out] DWORD* pdwArrayLengthOut +); +``` + +## Parameters + + `debuggeePID` + [in] Process identifier of the process from which loaded CLRs will be enumerated. + + `ppHandleArrayOut` + [out] Pointer to an array containing event handles that are used to continue a CLR startup. Each handle in the array is not guaranteed to be valid. If valid, the handle is to be used as the continue-startup event for the corresponding runtime located in the same index of `ppStringArrayOut`. + + `ppStringArrayOut` + [out] Pointer to an array of strings that specify full paths to CLRs loaded in the process. + + `pdwArrayLengthOut` + [out] Pointer to a DWORD that contains the length of the equally sized `ppHandleArrayOut` and `pdwArrayLengthOut`. + +## Return Value + + S_OK + The number of CLRs in the process was successfully determined, and the corresponding handle and path arrays were properly filled. + + E_INVALIDARG + Either `ppHandleArrayOut` or `ppStringArrayOut` is null, or `pdwArrayLengthOut` is null. + + E_OUTOFMEMORY + The function is unable to allocate enough memory for the handle and path arrays. + + E_FAIL (or other E_ return codes) + Unable to enumerate loaded CLRs. + +## Remarks + + For a target process that is identified by `debuggeePID`, the function returns an array of paths, `ppStringArrayOut`, to CLRs loaded in the process; an array of event handles, `ppHandleArrayOut`, which may contain a continue-startup event for the CLR at the same index; and the size of the arrays, `pdwArrayLengthOut`, which specifies the number of CLRs that are loaded. + + On the Windows operating system, `debuggeePID` maps to an OS process identifier. + + The memory for `ppHandleArrayOut` and `ppStringArrayOut` are allocated by this function. To free the memory allocated, you must call [CloseCLREnumeration Function](closeclrenumeration-function.md). + + This function can be called with both array parameters set to null in order to return the count of CLRs in the target process. From this count, a caller can infer the size of the buffer that will be created: `(sizeof(HANDLE) * count) + (sizeof(LPWSTR) * count) + (sizeof(WCHAR*) * count * MAX_PATH)`. + +## Requirements + + **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll + + **.NET Framework Versions:** 3.5 SP1 diff --git a/docs/framework/unmanaged-api/debugging/enumerateclrs-function.md b/docs/framework/unmanaged-api/debugging/enumerateclrs-function.md index c31f08678942f..f4ef5d7f0c99c 100644 --- a/docs/framework/unmanaged-api/debugging/enumerateclrs-function.md +++ b/docs/framework/unmanaged-api/debugging/enumerateclrs-function.md @@ -1,18 +1,18 @@ --- description: "Learn more about: EnumerateCLRs Function" title: "EnumerateCLRs Function" -ms.date: "03/30/2017" +ms.date: "03/21/2022" api_name: - "EnumerateCLRs" api_location: - "dbgshim.dll" -api_type: - - "COM" + - "libdbgshim.so" + - "libdbgshim.dylib" f1_keywords: - "EnumerateCLRs" helpviewer_keywords: - - "debugging API [Silverlight]" - - "Silverlight, debugging" + - "debugging API [.NET Core]" + - ".NET Core, debugging" - "EnumerateCLRs function" ms.assetid: f8d50cb3-ec4f-4529-8fe3-bd61fd28e13c topic_type: @@ -35,16 +35,16 @@ HRESULT EnumerateCLRs ( ## Parameters - `debuggeePID` + `debuggeePID`\ [in] Process identifier of the process from which loaded CLRs will be enumerated. - `ppHandleArrayOut` + `ppHandleArrayOut`\ [out] Pointer to an array containing event handles that are used to continue a CLR startup. Each handle in the array is not guaranteed to be valid. If valid, the handle is to be used as the continue-startup event for the corresponding runtime located in the same index of `ppStringArrayOut`. - `ppStringArrayOut` + `ppStringArrayOut`\ [out] Pointer to an array of strings that specify full paths to CLRs loaded in the process. - `pdwArrayLengthOut` + `pdwArrayLengthOut`\ [out] Pointer to a DWORD that contains the length of the equally sized `ppHandleArrayOut` and `pdwArrayLengthOut`. ## Return Value @@ -73,10 +73,10 @@ HRESULT EnumerateCLRs ( ## Requirements - **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). **Header:** dbgshim.h - **Library:** dbgshim.dll + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib - **.NET Framework Versions:** 3.5 SP1 + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/getstartupnotificationevent-function-for-silverlight.md b/docs/framework/unmanaged-api/debugging/getstartupnotificationevent-function-for-silverlight.md new file mode 100644 index 0000000000000..adcfbee44af49 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/getstartupnotificationevent-function-for-silverlight.md @@ -0,0 +1,66 @@ +--- +description: "Learn more about: GetStartupNotificationEvent Function for Silverlight" +title: "GetStartupNotificationEvent Function for Silverlight" +ms.date: "03/30/2017" +api_name: + - "GetStartupNotificationEvent" +api_location: + - "dbgshim.dll" +f1_keywords: + - "GetStartupNotificationEvent" +helpviewer_keywords: + - "GetStartupNotificationEvent function" + - "debugging API [Silverlight]" + - "Silverlight, debugging" +ms.assetid: c94b1b61-045a-4695-bacd-0f18c5acc246 +topic_type: + - "apiref" +--- +# GetStartupNotificationEvent Function for Silverlight + +Creates or opens an event handle that will be signaled upon by any common language runtime (CLR) that is loading in the specified target process. + +## Syntax + +```cpp +HRESULT GetStartupNotificationEvent + ( + [in] DWORD debuggeePID, + [out] HANDLE* phStartupEvent + ); +``` + +## Parameters + + `debuggeePID` + [in] Process identifier of the target process from which to receive CLR startup notifications. + + `phStartupEvent` + [out] A pointer to a handle that will be signaled by a CLR on startup. + +## Return Value + + S_OK + Successfully obtained the handle to the startup notification event. + + E_INVALIDARG + `phStartupEvent` is null or `debuggeePID` does not refer to a process that is currently running. + + E_FAIL (or other E_ return codes) + Unable to obtain the handle to the startup notification event. + +## Remarks + + On the Windows operating system, `debuggeePID` maps to an OS process identifier. + + The event is signaled before any managed code is executed by the CLR that signaled the event. + +## Requirements + + **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll + + **.NET Framework Versions:** 3.5 SP1 diff --git a/docs/framework/unmanaged-api/debugging/getstartupnotificationevent-function.md b/docs/framework/unmanaged-api/debugging/getstartupnotificationevent-function.md index e76836fc7bb06..168ab71c13565 100644 --- a/docs/framework/unmanaged-api/debugging/getstartupnotificationevent-function.md +++ b/docs/framework/unmanaged-api/debugging/getstartupnotificationevent-function.md @@ -1,43 +1,40 @@ --- description: "Learn more about: GetStartupNotificationEvent Function" title: "GetStartupNotificationEvent Function" -ms.date: "03/30/2017" +ms.date: "03/21/2022" api_name: - "GetStartupNotificationEvent" api_location: - "dbgshim.dll" -api_type: - - "COM" f1_keywords: - "GetStartupNotificationEvent" helpviewer_keywords: - "GetStartupNotificationEvent function" - - "debugging API [Silverlight]" - - "Silverlight, debugging" + - "debugging API [.NET Core]" + - ".NET Core, debugging" ms.assetid: c94b1b61-045a-4695-bacd-0f18c5acc246 topic_type: - "apiref" --- # GetStartupNotificationEvent Function -Creates or opens an event handle that will be signaled upon by any common language runtime (CLR) that is loading in the specified target process. +Creates or opens an event handle that will be signaled upon by any common language runtime (CLR) that is loading in the specified target process. This API is Windows only. ## Syntax ```cpp -HRESULT GetStartupNotificationEvent - ( +HRESULT GetStartupNotificationEvent ( [in] DWORD debuggeePID, [out] HANDLE* phStartupEvent - ); +); ``` ## Parameters - `debuggeePID` + `debuggeePID`\ [in] Process identifier of the target process from which to receive CLR startup notifications. - `phStartupEvent` + `phStartupEvent`\ [out] A pointer to a handle that will be signaled by a CLR on startup. ## Return Value @@ -59,10 +56,10 @@ HRESULT GetStartupNotificationEvent ## Requirements - **Platforms:** See [System Requirements](../../get-started/system-requirements.md). + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). **Header:** dbgshim.h **Library:** dbgshim.dll - **.NET Framework Versions:** 3.5 SP1 + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/iclrdebugging-openvirtualprocess-method.md b/docs/framework/unmanaged-api/debugging/iclrdebugging-openvirtualprocess-method.md index 03f71e58590b9..9ac03b7fa1fbc 100644 --- a/docs/framework/unmanaged-api/debugging/iclrdebugging-openvirtualprocess-method.md +++ b/docs/framework/unmanaged-api/debugging/iclrdebugging-openvirtualprocess-method.md @@ -92,6 +92,8 @@ HRESULT OpenVirtualProcess( **Library:** CorGuids.lib **.NET Framework Versions:** [!INCLUDE[net_current_v40plus](../../../../includes/net-current-v40plus-md.md)] + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] ## See also diff --git a/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider-providelibrary-method.md b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider-providelibrary-method.md index f7a9b28c2add9..245bb1519a2aa 100644 --- a/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider-providelibrary-method.md +++ b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider-providelibrary-method.md @@ -39,7 +39,7 @@ HRESULT ProvideLibrary( `dwTimestamp` \ [in] The date time stamp stored in the COFF file header of PE files. -`pLibraryProvider` \ +`dwSizeOfImage` \ [in] The `SizeOfImage` field stored in the COFF optional file header of PE files. `hModule` \ diff --git a/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-interface.md b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-interface.md new file mode 100644 index 0000000000000..a61eb3516ad34 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-interface.md @@ -0,0 +1,44 @@ +--- +description: "Learn more about: ICLRDebuggingLibraryProvider2 Interface" +title: "ICLRDebuggingLibraryProvider2 Interface" +ms.date: "03/30/2017" +api_name: + - "ICLRDebuggingLibraryProvider2" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +api_type: + - "COM" +f1_keywords: + - "ICLRDebuggingLibraryProvider2" +helpviewer_keywords: + - "ICLRDebuggingLibraryProvider2 interface [.NET Core debugging]" +ms.assetid: 67739617-6add-41a9-9de5-a3200c3109ce +topic_type: + - "apiref" +--- +# ICLRDebuggingLibraryProvider2 Interface + +Includes the [ProvideLibrary2](iclrdebugginglibraryprovider2-providelibrary2-method.md) method, which allows the debugger to provide a path to a version-specific debugging library. + +## Methods + +|Method|Description| +|------------|-----------------| +|[ProvideLibrary2](iclrdebugginglibraryprovider2-providelibrary2-method.md)|Allows the debugger to provide a path to a version-specific debugging library.| + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] + +## See also + +- [Debugging Interfaces](debugging-interfaces.md) +- [Debugging](index.md) diff --git a/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-providelibrary2-method.md b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-providelibrary2-method.md new file mode 100644 index 0000000000000..d3ebf0d6aeec2 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-providelibrary2-method.md @@ -0,0 +1,84 @@ +--- +description: "Learn more about: ICLRDebuggingLibraryProvider2::ProvideLibrary2 Method" +title: "ICLRDebuggingLibraryProvider2::ProvideLibrary2 Method" +ms.date: "03/30/2017" +api_name: + - "ICLRDebuggingLibraryProvider2.ProvideLibrary2 Method" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +api_type: + - "COM" +f1_keywords: + - "ICLRDebuggingLibraryProvider2::ProvideLibrary2" +helpviewer_keywords: + - "ProvideLibrary method [.NET Core debugging]" + - "ICLRDebuggingLibraryProvider2::ProvideLibrary2 method [.NET Core debugging]" +ms.assetid: 86f06245-9517-49be-8d8c-ca5deaf34c02 +topic_type: + - "apiref" +--- +# ICLRDebuggingLibraryProvider2::ProvideLibrary2 Method + +Allows the debugger to provide a path to a version-specific common language runtime (CLR) debugging library. + +## Syntax + +```cpp +HRESULT ProvideLibrary2 ( + [in] const WCHAR* pwszFileName, + [in] DWORD dwTimestamp, + [in] DWORD dwSizeOfImage, + [out] LPWSTR* ppResolvedModulePath); +``` + +## Parameters + +`pwszFilename` \ +[in] The name of the module being requested. + +`dwTimestamp` \ +[in] The date time stamp stored in the COFF file header of PE files. + +`dwSizeOfImage` \ +[in] The `SizeOfImage` field stored in the COFF optional file header of PE files. + +`ppResolvedModulePath` \ +[out] This is a null terminated path to the module dll. On Windows it should be allocated with CoTaskMemAlloc. On Unix it should be allocated with malloc. Failure leaves it untouched. See security note below! + +## Return Value + +This method returns the following specific HRESULTs as well as HRESULT errors that indicate method failure. + +|HRESULT|Description| +|-------------|-----------------| +|S_OK|The method completed successfully.| + +## Exceptions + +## Remarks + +`ProvideLibrary2` allows the debugger to provide modules that are needed for debugging specific CLR files such as mscordbi.dll and mscordacwks.dll. + +The debugger may use any available means to locate or procure the debugging module. + +> [!IMPORTANT] +> This feature allows the API caller to provide modules that contain executable, and possibly malicious, code. As a security precaution, the caller should not use `ProvideLibrary2` to distribute any code that it is not willing to execute itself. +> +> If a serious security issue is discovered in an already released library, such as mscordbi.dll or mscordacwks.dll, the shim can be patched to recognize the bad versions of the files. The shim can then issue requests for the patched versions of the files and reject the bad versions if they are provided in response to any request. This can occur only if the user has patched to a new version of the shim. Unpatched versions will remain vulnerable. + +## Requirements + +**Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + +**Header:** dbgshim.h + +**Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + +**.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] + +## See also + +- [Debugging Interfaces](debugging-interfaces.md) +- [Debugging](index.md) diff --git a/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-interface.md b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-interface.md new file mode 100644 index 0000000000000..0c45cfae3bde0 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-interface.md @@ -0,0 +1,45 @@ +--- +description: "Learn more about: ICLRDebuggingLibraryProvider3 Interface" +title: "ICLRDebuggingLibraryProvider3 Interface" +ms.date: "03/30/2017" +api_name: + - "ICLRDebuggingLibraryProvider3" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +api_type: + - "COM" +f1_keywords: + - "ICLRDebuggingLibraryProvider3" +helpviewer_keywords: + - "ICLRDebuggingLibraryProvider3 interface [.NET Core debugging]" +ms.assetid: 67739617-6add-41a9-9de5-a3200c3109ce +topic_type: + - "apiref" +--- +# ICLRDebuggingLibraryProvider3 Interface + +Includes callback methods that allow common language runtime version-specific debugging libraries to be located and loaded on demand for .NET Core regular and single-file applications. This interface is required by the [RegisterForRuntimeStartup3](registerforruntimestartup3-function.md) and [CreateDebuggingInterfaceFromVersion3](createdebugginginterfacefromversion3-function.md) methods. It is supported by the ICLRDebugging::OpenVirtualProcess method aquired with dbgshim's [CLRCreateInstance](clrcreateinstance-function.md) API. + +## Methods + +|Method|Description| +|------------|-----------------| +|[ProvideWindowsLibrary](iclrdebugginglibraryprovider3-providewindowslibrary-method.md)|Allows the debugger to provide a path to a version-specific Windows debugging library.| +|[ProvideUnixLibrary](iclrdebugginglibraryprovider3-provideunixlibrary-method.md)|Allows the debugger to provide a path to a version-specific Linux or macOS debugging library.| + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_60](../../../../includes/net-core-60-md.md)] + +## See also + +- [Debugging Interfaces](debugging-interfaces.md) +- [Debugging](index.md) diff --git a/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-provideunixlibrary-method.md b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-provideunixlibrary-method.md new file mode 100644 index 0000000000000..b18e61e1a0bd6 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-provideunixlibrary-method.md @@ -0,0 +1,92 @@ +--- +description: "Learn more about: ICLRDebuggingLibraryProvider3::ProvideUnixLibrary Method" +title: "ICLRDebuggingLibraryProvider3::ProvideUnixLibrary Method" +ms.date: "03/30/2017" +api_name: + - "ICLRDebuggingLibraryProvider3.ProvideUnixLibrary Method" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +api_type: + - "COM" +f1_keywords: + - "ICLRDebuggingLibraryProvider3::ProvideUnixLibrary" +helpviewer_keywords: + - "ProvideUnixLibrary method [.NET Core debugging]" + - "ICLRDebuggingLibraryProvider3::ProvideUnixLibrary method [.NET Core debugging]" +ms.assetid: 86f06245-9517-49be-8d8c-ca5deaf34c02 +topic_type: + - "apiref" +--- +# ICLRDebuggingLibraryProvider3::ProvideUnixLibrary Method + +Allows the debugger to provide a path to a version-specific common language runtime (CLR) debugging library on macOS and Linux. + +## Syntax + +```cpp +HRESULT ProvideUnixLibrary ( + [in] const WCHAR* pwszFileName, + [in] const WCHAR* pwszRuntimeModule, + [in] LIBRARY_PROVIDER_INDEX_TYPE indexType, + [in] BYTE* pbBuildId, + [in] int iBuildIdSize, + [out] LPWSTR* ppResolvedModulePath); +``` + +## Parameters + +`pwszFilename` \ +[in] The name of the module being requested. + +`pwszRuntimeModule` \ +[in] The runtime or single-file module path. + +`indexType` \ +[in] The type of index information (pBuildId) provided. See [LIBRARY_PROVIDER_INDEX_TYPE](libraryproviderindextype-enumeration.md) enum. + +`pbBuildId` \ +[in] The Linux or macOS module build id. Can be null if something went wrong retrieving the build id. + +`iBuildIdSize` \ +[in] The number of bytes in the pbBuildId array. Can be 0 if something went wrong retrieving the build id. + +`ppResolvedModulePath` \ +[out] This is a null terminated path to the module dll. On Unix it should be allocated with CoTaskMemAlloc. On Unix it should be allocated with malloc. Failure leaves it untouched. See security note below! + +## Return Value + +This method returns the following specific HRESULTs as well as HRESULT errors that indicate method failure. + +|HRESULT|Description| +|-------------|-----------------| +|S_OK|The method completed successfully.| + +## Exceptions + +## Remarks + +`ProvideUnixLibrary` allows the debugger to provide modules that are needed for debugging specific CLR files such as mscordbi.dll and mscordacwks.dll. + +The debugger may use any available means to locate or procure the debugging module. + +> [!IMPORTANT] +> This feature allows the API caller to provide modules that contain executable, and possibly malicious, code. As a security precaution, the caller should not use `ProvideUnixLibrary` to distribute any code that it is not willing to execute itself. +> +> If a serious security issue is discovered in an already released library, such as mscordbi.dll or mscordacwks.dll, the shim can be patched to recognize the bad versions of the files. The shim can then issue requests for the patched versions of the files and reject the bad versions if they are provided in response to any request. This can occur only if the user has patched to a new version of the shim. Unpatched versions will remain vulnerable. + +## Requirements + +**Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + +**Header:** dbgshim.h + +**Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + +**.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] + +## See also + +- [Debugging Interfaces](debugging-interfaces.md) +- [Debugging](index.md) diff --git a/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-providewindowslibrary-method.md b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-providewindowslibrary-method.md new file mode 100644 index 0000000000000..32be031ce0df0 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-providewindowslibrary-method.md @@ -0,0 +1,92 @@ +--- +description: "Learn more about: ICLRDebuggingLibraryProvider3::ProvideWindowsLibrary Method" +title: "ICLRDebuggingLibraryProvider3::ProvideWindowsLibrary Method" +ms.date: "03/30/2017" +api_name: + - "ICLRDebuggingLibraryProvider3.ProvideWindowsLibrary Method" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +api_type: + - "COM" +f1_keywords: + - "ICLRDebuggingLibraryProvider3::ProvideWindowsLibrary" +helpviewer_keywords: + - "ProvideWindowsLibrary method [.NET Core debugging]" + - "ICLRDebuggingLibraryProvider3::ProvideWindowsLibrary method [.NET Core debugging]" +ms.assetid: 86f06245-9517-49be-8d8c-ca5deaf34c02 +topic_type: + - "apiref" +--- +# ICLRDebuggingLibraryProvider3::ProvideWindowsLibrary Method + +Gets a library provider callback interface that allows common language runtime (CLR) version-specific debugging libraries to be located and loaded on demand. + +## Syntax + +```cpp +HRESULT ProvideWindowsLibrary ( + [in] const WCHAR* pwszFileName, + [in] const WCHAR* pwszRuntimeModule, + [in] LIBRARY_PROVIDER_INDEX_TYPE indexType, + [in] DWORD dwTimestamp, + [in] DWORD dwSizeOfImage, + [out] LPWSTR* ppResolvedModulePath); +``` + +## Parameters + +`pwszFilename` \ +[in] The name of the module being requested. + +`pwszRuntimeModule` \ +[in] The runtime or single-file module path. + +`indexType` \ +[in] The type of index information (dwTimestamp/dwSizeOfImage) provided. See [LIBRARY_PROVIDER_INDEX_TYPE](libraryproviderindextype-enumeration.md) enum. + +`dwTimestamp` \ +[in] The date time stamp stored in the COFF file header of PE files. + +`dwSizeOfImage` \ +[in] The `SizeOfImage` field stored in the COFF optional file header of PE files. + +`ppResolvedModulePath` \ +[out] This is a null terminated path to the module dll. On Windows it should be allocated with CoTaskMemAlloc. On Unix it should be allocated with malloc. Failure leaves it untouched. See security note below! + +## Return Value + +This method returns the following specific HRESULTs as well as HRESULT errors that indicate method failure. + +|HRESULT|Description| +|-------------|-----------------| +|S_OK|The method completed successfully.| + +## Exceptions + +## Remarks + +`ProvideWindowsLibrary` allows the debugger to provide modules that are needed for debugging specific CLR files such as mscordbi.dll and mscordacwks.dll. + +The debugger may use any available means to locate or procure the debugging module. + +> [!IMPORTANT] +> This feature allows the API caller to provide modules that contain executable, and possibly malicious, code. As a security precaution, the caller should not use `ProvideWindowsLibrary` to distribute any code that it is not willing to execute itself. +> +> If a serious security issue is discovered in an already released library, such as mscordbi.dll or mscordacwks.dll, the shim can be patched to recognize the bad versions of the files. The shim can then issue requests for the patched versions of the files and reject the bad versions if they are provided in response to any request. This can occur only if the user has patched to a new version of the shim. Unpatched versions will remain vulnerable. + +## Requirements + +**Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + +**Header:** dbgshim.h + +**Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + +**.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] + +## See also + +- [Debugging Interfaces](debugging-interfaces.md) +- [Debugging](index.md) diff --git a/docs/framework/unmanaged-api/debugging/libraryproviderindextype-enumeration.md b/docs/framework/unmanaged-api/debugging/libraryproviderindextype-enumeration.md new file mode 100644 index 0000000000000..7d5f045c115d9 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/libraryproviderindextype-enumeration.md @@ -0,0 +1,61 @@ +--- +description: "Learn more about: LIBRARY_PROVIDER_INDEX_TYPE Enumeration" +title: "LIBRARY_PROVIDER_INDEX_TYPE Enumeration" +ms.date: "03/30/2017" +api_name: + - "LIBRARY_PROVIDER_INDEX_TYPE" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +api_type: + - "COM" +f1_keywords: + - "LIBRARY_PROVIDER_INDEX_TYPE" +helpviewer_keywords: + - "LIBRARY_PROVIDER_INDEX_TYPE enumeration [.NET Core debugging]" +ms.assetid: a6ac2531-ddfe-46fd-88fe-8b1eabe0b255 +topic_type: + - "apiref" +--- +# LIBRARY_PROVIDER_INDEX_TYPE Enumeration + +The type of index information passed to the library provider is either the identity of the requested module or of the runtime (coreclr) module. + +## Syntax + +```cpp +typedef enum +{ + Unknown = 0, + Identity = 1, + Runtime = 2, +} LIBRARY_PROVIDER_INDEX_TYPE; +``` + +## Members + +|Member|Description| +|------------|-----------------| +|`Unknown`|Invalid index type.| +|`Identity`|The index information of the requested module.| +|`Runtime`|The runtime module's index information.| + +## Remarks + +The "index information" is the timestamp/file size on Windows or the build id on Linux/MacOS. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_60](../../../../includes/net-core-60-md.md)] + +## See also + +- [Debugging Enumerations](debugging-enumerations.md) +- [Debugging](index.md) diff --git a/docs/framework/unmanaged-api/debugging/pstartup_callback-function-pointer.md b/docs/framework/unmanaged-api/debugging/pstartup_callback-function-pointer.md new file mode 100644 index 0000000000000..42231430d6113 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/pstartup_callback-function-pointer.md @@ -0,0 +1,67 @@ +--- +description: "Learn more about: PSTARTUP_CALLBACK Function Pointer" +title: "PSTARTUP_CALLBACK Function Pointer" +ms.date: "03/30/2017" +api_name: + - "PSTARTUP_CALLBACK" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +f1_keywords: + - "PSTARTUP_CALLBACK" +helpviewer_keywords: + - "PSTARTUP_CALLBACK function pointer [.NET Core debugging]" +ms.assetid: 5c66ac57-d751-4de5-af9f-26ceb949af8b +topic_type: + - "apiref" +--- +# PSTARTUP_CALLBACK Function Pointer + +Points to a function that is called when the .NET Core runtime has started for the [RegisterForRuntimeStartup](registerforruntimestartup-function.md) API. + +## Syntax + +```cpp +typedef VOID (*PSTARTUP_CALLBACK)( + IUnknown *pCordb, + PVOID parameter, + HRESULT hr); +``` + +## Parameters + + `pCordb`\ + [in] Pointer to a pointer to a COM object (`IUnknown`). This object will be cast to an [ICorDebug](icordebug-interface.md) object before it is returned. + + `parameter`\ + [in] The `parameter' value passed to RegisterForRuntimeStartup. + + `hr`\ + [in] The result of the operation. + + `S_OK`\ + `pCordb` references a valid object that implements the [ICorDebug interface](icordebug-interface.md) interface. + + `CORDBG_E_DEBUG_COMPONENT_MISSING`\ + A component that is necessary for CLR debugging cannot be located. Either _mscordbi.dll_ or _mscordaccore.dll_ was not found in the same directory as the target CoreCLR.dll. + + `CORDBG_E_INCOMPATIBLE_PROTOCOL`\ + Either mscordbi.dll or mscordaccore.dll is not the same version as the target CoreCLR.dll. + + `E_FAIL` (or other `E_` return codes)\ + Unable to return an [ICorDebug interface](icordebug-interface.md). + +## Remarks + +The interface that is provided has the facilities for attaching to a CLR in a target process and debugging the managed code that the CLR is running. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/registerforruntimestartup-function.md b/docs/framework/unmanaged-api/debugging/registerforruntimestartup-function.md new file mode 100644 index 0000000000000..f2de404599641 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/registerforruntimestartup-function.md @@ -0,0 +1,69 @@ +--- +description: "Learn more about: RegisterForRuntimeStartup Function" +title: "RegisterForRuntimeStartup Function" +ms.date: "03/21/2022" +f1_keywords: + - "RegisterForRuntimeStartup" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +helpviewer_keywords: + - "RegisterForRuntimeStartup function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# RegisterForRuntimeStartup Function for .NET Core + +Executes the callback when the .NET Core runtime starts in the specified process. + +## Syntax + +```cpp +HRESULT RegisterForRuntimeStartup ( + [in] DWORD dwProcessId, + [in] PSTARTUP_CALLBACK pfnCallback, + [in] PVOID parameter, + [out] PVOID *ppUnregisterToken) +); +``` + +## Parameters + + `dwProcessId`\ + [in] The process id of the target process. + + `pfnCallback`\ + [in] A callback that is invoked when the runtime starts. See [PSTARTUP_CALLBACK](pstartup_callback-function-pointer.md) function pointer. + + `parameter`\ + [in] data pointer passed to pfnCallback. + + `ppUnregisterToken`\ + [out] pointer to return the [UnregisterForRuntimeStartup](unregisterforruntimestartup-function.md) token. + +## Return Value + + `S_OK`\ + The startup callback was successfully registered. + + `E_INVALIDARG`\ + Either `pfnCallback` or `ppUnregisterToken` is null. + + `E_FAIL` (or other `E_` return codes)\ + Callback registration failed. + +## Remarks + +The callback is passed the proper ICorDebug instance for the version of the runtime or an error if something fails. This API works for launch and attach (and even the attach scenario if the runtime hasn't been loaded yet) equally on both xplat and Windows. The callback is always called on a separate thread. This API returns immediately. The callback is invoked when the coreclr runtime module is loaded during early initialization. The runtime is blocked during initialization until the callback returns. If the runtime is already loaded in the process (as in the normal attach case), the callback is executed and the runtime is not blocked. The callback is always invoked on a separate thread and this API returns immediately. Only the first coreclr module instance found in the target process is currently supported. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/registerforruntimestartup3-function.md b/docs/framework/unmanaged-api/debugging/registerforruntimestartup3-function.md new file mode 100644 index 0000000000000..ab1c242a129fd --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/registerforruntimestartup3-function.md @@ -0,0 +1,79 @@ +--- +description: "Learn more about: RegisterForRuntimeStartup3 Function" +title: "RegisterForRuntimeStartup3 Function" +ms.date: "03/21/2022" +f1_keywords: + - "RegisterForRuntimeStartup3" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +helpviewer_keywords: + - "RegisterForRuntimeStartup3 function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# RegisterForRuntimeStartup3 Function for .NET Core + +Executes the callback when the .NET Core runtime starts in the specified process. + +## Syntax + +```cpp +HRESULT RegisterForRuntimeStartup3 ( + [in] DWORD dwProcessId, + [in] LPCWSTR lpApplicationGroupId, + [in] ICLRDebuggingLibraryProvider3* pLibraryProvider, + [in] PSTARTUP_CALLBACK pfnCallback, + [in] PVOID parameter, + [out] PVOID *ppUnregisterToken) +); +``` + +## Parameters + + `dwProcessId`\ + [in] The process id of the target process. + + `lpApplicationGroupId`\ + [in] A string representing the application group ID of a sandboxed process running in Mac. Pass NULL if the process is not running in a sandbox and other platforms. + + `pLibraryProvider`\ + [in] A callback interface instance for locating DBI and DAC. See [ICLRDebuggingLibraryProvider3](iclrdebugginglibraryprovider3-interface.md) interface. + + `pfnCallback`\ + [in] A callback that is invoked when the runtime starts. See [PSTARTUP_CALLBACK](pstartup_callback-function-pointer.md) function pointer. + + `parameter`\ + [in] data pointer passed to pfnCallback. + + `ppUnregisterToken`\ + [out] pointer to return the [UnregisterForRuntimeStartup](unregisterforruntimestartup-function.md) token. + +## Return Value + + `S_OK`\ + The startup callback was successfully registered. + + `E_INVALIDARG`\ + Either `pfnCallback` or `ppUnregisterToken` is null. + + `E_FAIL` (or other `E_` return codes)\ + Callback registration failed. + +## Remarks + +The callback is passed the proper ICorDebug instance for the version of the runtime or an error if something fails. This API works for launch and attach (and even the attach scenario if the runtime hasn't been loaded yet) equally on both xplat and Windows. The callback is always called on a separate thread. This API returns immediately. The callback is invoked when the coreclr runtime module is loaded during early initialization. The runtime is blocked during initialization until the callback returns. If the runtime is already loaded in the process (as in the normal attach case), the callback is executed and the runtime is not blocked. The callback is always invoked on a separate thread and this API returns immediately. Only the first coreclr module instance found in the target process is currently supported. + +This is the only register function that works for single-file applications. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_60](../../../../includes/net-core-60-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/registerforruntimestartupex-function.md b/docs/framework/unmanaged-api/debugging/registerforruntimestartupex-function.md new file mode 100644 index 0000000000000..31418ce413a83 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/registerforruntimestartupex-function.md @@ -0,0 +1,73 @@ +--- +description: "Learn more about: RegisterForRuntimeStartupEx Function" +title: "RegisterForRuntimeStartupEx Function" +ms.date: "03/21/2022" +f1_keywords: + - "RegisterForRuntimeStartupEx" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +helpviewer_keywords: + - "RegisterForRuntimeStartupEx function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# RegisterForRuntimeStartupEx Function for .NET Core + +Executes the callback when the .NET Core runtime starts in the specified process. + +## Syntax + +```cpp +HRESULT RegisterForRuntimeStartupEx ( + [in] DWORD dwProcessId, + [in] LPCWSTR lpApplicationGroupId, + [in] PSTARTUP_CALLBACK pfnCallback, + [in] PVOID parameter, + [out] PVOID *ppUnregisterToken) +); +``` + +## Parameters + + `dwProcessId`\ + [in] The process id of the target process. + + `lpApplicationGroupId`\ + [in] A string representing the application group ID of a sandboxed process running in Mac. Pass NULL if the process is not running in a sandbox and other platforms. + + `pfnCallback`\ + [in] A callback that is invoked when the runtime starts. See [PSTARTUP_CALLBACK](pstartup_callback-function-pointer.md) function pointer. + + `parameter`\ + [in] data pointer passed to pfnCallback. + + `ppUnregisterToken`\ + [out] pointer to return the [UnregisterForRuntimeStartup](unregisterforruntimestartup-function.md) token. + +## Return Value + + `S_OK`\ + The startup callback was successfully registered. + + `E_INVALIDARG`\ + Either `pfnCallback` or `ppUnregisterToken` is null. + + `E_FAIL` (or other `E_` return codes)\ + Callback registration failed. + +## Remarks + +The callback is passed the proper ICorDebug instance for the version of the runtime or an error if something fails. This API works for launch and attach (and even the attach scenario if the runtime hasn't been loaded yet) equally on both xplat and Windows. The callback is always called on a separate thread. This API returns immediately. The callback is invoked when the coreclr runtime module is loaded during early initialization. The runtime is blocked during initialization until the callback returns. If the runtime is already loaded in the process (as in the normal attach case), the callback is executed and the runtime is not blocked. The callback is always invoked on a separate thread and this API returns immediately. Only the first coreclr module instance found in the target process is currently supported. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/resumeprocess-function.md b/docs/framework/unmanaged-api/debugging/resumeprocess-function.md new file mode 100644 index 0000000000000..73c4f93d67f92 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/resumeprocess-function.md @@ -0,0 +1,54 @@ +--- +description: "Learn more about: ResumeProcess Function" +title: "ResumeProcess Function" +ms.date: "03/21/2022" +api_name: + - "ResumeProcess" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +f1_keywords: + - "ResumeProcess" +helpviewer_keywords: + - "debugging API [.NET Core]" + - ".NET Core, debugging" + - "ResumeProcess function" +ms.assetid: 5e3c3958-80bb-43b1-a96b-dd3e6dbd9cd7 +topic_type: + - "apiref" +--- +# ResumeProcess Function + +Resumes the process using the resume handle returned by the [CreateProcessForLaunch function](createprocessforlaunch-function.md). + +## Syntax + +```cpp +HRESULT ResumeProcess ( + [in] HANDLE hResumeHandle +); +``` + +## Parameters + + `hResumeHandle`\ + [in] The resume handle returned by [CreateProcessForLaunch function](createprocessforlaunch-function.md). + +## Return Value + + S_OK + The process was successfully resumed. + + E_FAIL (or other E_ return codes) + The handle was invalid or the function failed. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/unmanaged-api/debugging/silverlight-debugging.md b/docs/framework/unmanaged-api/debugging/silverlight-debugging.md index 7616e588783e9..e619f02716163 100644 --- a/docs/framework/unmanaged-api/debugging/silverlight-debugging.md +++ b/docs/framework/unmanaged-api/debugging/silverlight-debugging.md @@ -13,10 +13,10 @@ The topics in this section describe the environment and interfaces that the comm ## In This Section - [EnumerateCLRs Function](enumerateclrs-function.md) + [EnumerateCLRs Function](enumerateclrs-function-for-silverlight.md) Provides a mechanism for enumerating the CLRs in a process. - [CloseCLREnumeration Function](closeclrenumeration-function.md) + [CloseCLREnumeration Function](closeclrenumeration-function-for-silverlight.md) Closes any valid CLR continue-startup events located in an array of handles returned by the [EnumerateCLRs Function](enumerateclrs-function.md), and frees the memory for the handle and string path arrays. [CreateCoreClrDebugTarget Function](createcoreclrdebugtarget-function.md) @@ -25,11 +25,11 @@ The topics in this section describe the environment and interfaces that the comm [CreateCordbObject Function](createcordbobject-function.md) Creates a debugger interface that provides functionality for instantiating a managed debugging session on a remote process. - [CreateVersionStringFromModule Function](createversionstringfrommodule-function.md) + [CreateVersionStringFromModule Function](createversionstringfrommodule-function-for-silverlight.md) Creates a version string from a CLR path in a target process. [CreateDebuggingInterfaceFromVersion Function](createdebugginginterfacefromversion-function-for-silverlight.md) - Accepts a CLR version string returned from [CreateVersionStringFromModule Function](createversionstringfrommodule-function.md)function, and returns a corresponding debugger interface. + Accepts a CLR version string returned from [CreateVersionStringFromModule](createversionstringfrommodule-function.md) function, and returns a corresponding debugger interface. [CoreClrDebugProcInfo Structure](coreclrdebugprocinfo-structure.md) Represents a process that is running on a remote machine. @@ -37,7 +37,7 @@ The topics in this section describe the environment and interfaces that the comm [CoreClrDebugRuntimeInfo Structure](coreclrdebugruntimeinfo-structure.md) Represents a CLR instance that is loaded in a process on a remote machine. - [GetStartupNotificationEvent Function](getstartupnotificationevent-function.md) + [GetStartupNotificationEvent Function](getstartupnotificationevent-function-for-silverlight.md) Creates or opens an event handle that will be signaled upon by any common language runtime (CLR) that is loading in the specified target process. [ICoreClrDebugTarget Interface](icoreclrdebugtarget-interface.md) diff --git a/docs/framework/unmanaged-api/debugging/toc.yml b/docs/framework/unmanaged-api/debugging/toc.yml index 72ba7039d5d1b..3166a5830fd0f 100644 --- a/docs/framework/unmanaged-api/debugging/toc.yml +++ b/docs/framework/unmanaged-api/debugging/toc.yml @@ -1,3 +1,4 @@ +items: - name: Debugging href: index.md items: @@ -72,6 +73,18 @@ items: - name: ProvideLibrary Method href: iclrdebugginglibraryprovider-providelibrary-method.md + - name: ICLRDebuggingLibraryProvider2 Interface + href: iclrdebugginglibraryprovider2-interface.md + items: + - name: ProvideLibrary2 Method + href: iclrdebugginglibraryprovider2-providelibrary2-method.md + - name: ICLRDebuggingLibraryProvider3 Interface + href: iclrdebugginglibraryprovider3-interface.md + items: + - name: ProvideWindowsLibrary Method + href: iclrdebugginglibraryprovider3-providewindowslibrary-method.md + - name: ProvideUnixLibrary Method + href: iclrdebugginglibraryprovider3-provideunixlibrary-method.md - name: ICLRMetadataLocator Interface href: iclrmetadatalocator-interface.md items: @@ -1480,6 +1493,8 @@ href: clrdatacreateinstance-function.md - name: PFN_CLRDataCreateInstance Function Pointer href: pfn-clrdatacreateinstance-function-pointer.md + - name: PSTARTUP_CALLBACK Function Pointer + href: pstartup_callback-function-pointer.md - name: Debugging Enumerations href: debugging-enumerations.md items: @@ -1557,6 +1572,8 @@ href: corgcreferencetype-enumeration.md - name: ILCodeKind Enumeration href: ilcodekind-enumeration.md + - name: LIBRARY_PROVIDER_INDEX_TYPE Enumeration + href: libraryproviderindextype-enumeration.md - name: LoggingLevelEnum Enumeration href: logginglevelenum-enumeration.md - name: LogSwitchCallReason Enumeration @@ -1623,17 +1640,53 @@ href: dacprejitdata-structure.md - name: StackTrace_SimpleContext Structure href: stacktrace-simplecontext-structure.md + - name: .NET Core Debugging + href: dotnet-debugging.md + items: + - name: CLRCreateInstance Function + href: clrcreateinstance-function.md + - name: CloseCLREnumeration Function + href: closeclrenumeration-function.md + - name: CloseResumeHandle Function + href: closeresumehandle-function.md + - name: CreateVersionStringFromModule Function + href: createversionstringfrommodule-function.md + - name: CreateDebuggingInterfaceFromVersion Function + href: createdebugginginterfacefromversion-function.md + - name: CreateDebuggingInterfaceFromVersionEx Function + href: createdebugginginterfacefromversionex-function.md + - name: CreateDebuggingInterfaceFromVersion2 Function + href: createdebugginginterfacefromversion2-function.md + - name: CreateDebuggingInterfaceFromVersion3 Function + href: createdebugginginterfacefromversion3-function.md + - name: CreateProcessForLaunch Function + - name: CreateProcessForLaunch Function + href: createprocessforlaunch-function.md + - name: EnumerateCLRs Function + href: enumerateclrs-function.md + - name: GetStartupNotificationEvent Function + href: getstartupnotificationevent-function.md + - name: RegisterForRuntimeStartup Function + href: registerforruntimestartup-function.md + - name: RegisterForRuntimeStartupEx Function + href: registerforruntimestartupex-function.md + - name: RegisterForRuntimeStartup3 Function + href: registerforruntimestartup3-function.md + - name: ResumeProcess Function + href: resumeprocess-function.md + - name: UnregisterForRuntimeStartup Function + href: unregisterforruntimestartup-function.md - name: Silverlight Debugging href: silverlight-debugging.md items: - name: CloseCLREnumeration Function - href: closeclrenumeration-function.md + href: closeclrenumeration-function-for-silverlight.md - name: CreateCoreClrDebugTarget Function href: createcoreclrdebugtarget-function.md - name: CreateCordbObject Function href: createcordbobject-function.md - name: CreateVersionStringFromModule Function - href: createversionstringfrommodule-function.md + href: createversionstringfrommodule-function-for-silverlight.md - name: CreateDebuggingInterfaceFromVersion Function href: createdebugginginterfacefromversion-function-for-silverlight.md - name: CoreClrDebugProcInfo Structure @@ -1641,9 +1694,9 @@ - name: CoreClrDebugRuntimeInfo Structure href: coreclrdebugruntimeinfo-structure.md - name: EnumerateCLRs Function - href: enumerateclrs-function.md + href: enumerateclrs-function-for-silverlight.md - name: GetStartupNotificationEvent Function - href: getstartupnotificationevent-function.md + href: getstartupnotificationevent-function-for-silverlight.md - name: ICoreClrDebugTarget Interface href: icoreclrdebugtarget-interface.md items: diff --git a/docs/framework/unmanaged-api/debugging/unregisterforruntimestartup-function.md b/docs/framework/unmanaged-api/debugging/unregisterforruntimestartup-function.md new file mode 100644 index 0000000000000..921615f70c138 --- /dev/null +++ b/docs/framework/unmanaged-api/debugging/unregisterforruntimestartup-function.md @@ -0,0 +1,54 @@ +--- +description: "Learn more about: UnregisterForRuntimeStartup Function" +title: "UnregisterForRuntimeStartup Function" +ms.date: "03/21/2022" +f1_keywords: + - "UnregisterForRuntimeStartup" +api_location: + - "dbgshim.dll" + - "libdbgshim.so" + - "libdbgshim.dylib" +helpviewer_keywords: + - "UnregisterForRuntimeStartup function" + - "debugging API [.NET Core]" + - ".NET Core, debugging" +ms.assetid: 35c7a18f-133a-4584-bd25-bb338568b0c6 +--- +# UnregisterForRuntimeStartup Function for .NET Core + +Stops/cancels runtime startup notification. + +## Syntax + +```cpp +HRESULT UnregisterForRuntimeStartup ( + [in] PVOID pUnregisterToken) +); +``` + +## Parameters + + `pUnregisterToken`\ + [in] The token from the [RegisterForRuntimeStartup](registerforruntimestartup-function.md) APIs. + +## Return Value + + `S_OK`\ + The runtime startup callback was successfully unregistered. + + `E_FAIL` (or other `E_` return codes)\ + Unregister failed. + +## Remarks + +This API needs to be called during the debugger's shutdown to cleanup the internal data. It can be called in the startup callback. Otherwise, it will block until the callback thread finishes and no more callbacks will be initiated after this API returns. + +## Requirements + + **Platforms:** See [.NET Core supported operating systems](../../../core/install/windows.md?pivots=os-windows). + + **Header:** dbgshim.h + + **Library:** dbgshim.dll, libdbgshim.so, libdbgshim.dylib + + **.NET Versions:** [!INCLUDE[net_core_21](../../../../includes/net-core-21-md.md)] diff --git a/docs/framework/wcf/deploying-wcf-applications-with-clickonce.md b/docs/framework/wcf/deploying-wcf-applications-with-clickonce.md index f798fda59456c..c053ac54ac0dc 100644 --- a/docs/framework/wcf/deploying-wcf-applications-with-clickonce.md +++ b/docs/framework/wcf/deploying-wcf-applications-with-clickonce.md @@ -6,7 +6,9 @@ ms.assetid: 1a11feee-2a47-4d3e-a28a-ad69d5ff93e0 --- # Deploying WCF Applications with ClickOnce -Client applications using Windows Communication Foundation (WCF) may be deployed using ClickOnce technology. This technology allows them to take advantage of the runtime security protections provided by Code Access Security, provided that they are digitally signed with a trusted certificate. The certificate used to sign the ClickOnce application must reside in the Trusted Publisher store, and the local security policy on the client machine must be configured to grant Full Trust permissions to applications signed with the publisher's certificate. +Client applications using Windows Communication Foundation (WCF) may be deployed using ClickOnce technology. This technology allows them to take advantage of the runtime security protections provided by Code Access Security, provided that they are digitally signed with a trusted certificate. The certificate used to sign the ClickOnce application must reside in the Trusted Publisher store, and the local security policy on the client machine must be configured to grant Full Trust permissions to applications signed with the publisher's certificate. + +[!INCLUDE [cas-deprecated](../../../includes/cas-deprecated.md)] For information on configuring ClickOnce applications and trusted publishers, see [Configuring ClickOnce Trusted Publishers](/previous-versions/dotnet/articles/ms996418(v=msdn.10)). diff --git a/docs/framework/wcf/feature-details/best-practices-for-security-in-wcf.md b/docs/framework/wcf/feature-details/best-practices-for-security-in-wcf.md index 3cb08d7590250..19e14342762d9 100644 --- a/docs/framework/wcf/feature-details/best-practices-for-security-in-wcf.md +++ b/docs/framework/wcf/feature-details/best-practices-for-security-in-wcf.md @@ -33,7 +33,7 @@ The following sections list the best practices to consider when creating secure ## Always Revert After Impersonation - When using APIs that enable impersonation of a client, be sure to revert to the original identity. For example, when using the and , use the C# `using` statement or the Visual Basic`Using` statement, as shown in the following code. The class implements the interface, and therefore the common language runtime (CLR) automatically reverts to the original identity once the code leaves the `using` block. + When using APIs that enable impersonation of a client, be sure to revert to the original identity. For example, when using the and , use the C# `using` statement or the Visual Basic `Using` statement, as shown in the following code. The class implements the interface, and therefore the common language runtime (CLR) automatically reverts to the original identity once the code leaves the `using` block. [!code-csharp[c_SecurityBestPractices#1](../../../../samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/source.cs#1)] [!code-vb[c_SecurityBestPractices#1](../../../../samples/snippets/visualbasic/VS_Snippets_CFX/c_securitybestpractices/vb/source.vb#1)] diff --git a/docs/framework/wcf/feature-details/interoperability-and-integration.md b/docs/framework/wcf/feature-details/interoperability-and-integration.md index 58714b9b35108..04b1395d62ce3 100644 --- a/docs/framework/wcf/feature-details/interoperability-and-integration.md +++ b/docs/framework/wcf/feature-details/interoperability-and-integration.md @@ -11,37 +11,34 @@ This section covers interoperability and integration with Windows Communication ## In This Section [Web Services Protocols Interoperability Guide](web-services-protocols-interoperability-guide.md) - WCF is built to interoperate with Web services that support a set of specifications known as the Web services specifications. This topic lists specifications that are supported and the bindings that support them. + WCF is built to interoperate with Web services that support a set of specifications known as the Web services specifications. This topic lists specifications that are supported and the bindings that support them. [Integrating with COM+ Applications](integrating-with-com-plus-applications.md) - Discusses how COM+ applications can be exposed as WCF services. + Discusses how COM+ applications can be exposed as WCF services. [Integrating with COM Applications](integrating-with-com-applications.md) - Discusses the various methods for COM applications to call WCF services. + Discusses the various methods for COM applications to call WCF services. [Migrating .NET Remoting Applications to WCF](migrating-net-remoting-applications-to-wcf.md) - Describes how WCF can be used with .NET Framework remoting. + Describes how WCF can be used with .NET Framework remoting. [Interoperability with Web Services Enhancements 3.0](interoperability-with-web-services-enhancements-3-0.md) - Describes how WCF can be used with Web services implemented with Web Services Enhancements (WSE) 3.0. + Describes how WCF can be used with Web services implemented with Web Services Enhancements (WSE) 3.0. [Migrating WSE 3.0 Web Services to WCF](migrating-wse-3-0-web-services-to-wcf.md) - Describes how to migrate a WSE 3.0 Web service to a WCF service. + Describes how to migrate a WSE 3.0 Web service to a WCF service. [Interoperability with ASP.NET Web Services](interop-with-aspnet-web-services.md) - Describes how WCF can interoperate with ASP.NET Web services. + Describes how WCF can interoperate with ASP.NET Web services. [Migrating ASP.NET Web Services to WCF](migrating-aspnet-web-services-to-wcf.md) - Describes how to migrate an ASP.NET Web service to a WCF service. + Describes how to migrate an ASP.NET Web service to a WCF service. [Migrating ASP.NET Web Services to WCF](migrating-aspnet-web-services-to-wcf.md) - Describes how to migrate an ASP.NET Web service to a WCF service. - - [Migrating ASP.NET Web Services to WCF](migrating-aspnet-web-services-to-wcf.md) - Describes how to migrate an ASP.NET Web service to a WCF service. + Describes how to migrate an ASP.NET Web service to a WCF service. [Interoperability with POX Applications](interoperability-with-pox-applications.md) - Describes how WCF provides both services and clients that use "Plain Old XML" (POX) messages. + Describes how WCF provides both services and clients that use "Plain Old XML" (POX) messages. ## Reference diff --git a/docs/framework/wcf/feature-details/partial-trust-best-practices.md b/docs/framework/wcf/feature-details/partial-trust-best-practices.md index bd0c23d3b415c..a90359b0a9334 100644 --- a/docs/framework/wcf/feature-details/partial-trust-best-practices.md +++ b/docs/framework/wcf/feature-details/partial-trust-best-practices.md @@ -4,15 +4,15 @@ title: "Partial Trust Best Practices" ms.date: "03/30/2017" ms.assetid: 0d052bc0-5b98-4c50-8bb5-270cc8a8b145 --- -# Partial Trust Best Practices +# Partial trust best practices -This topic describes best practices when running Windows Communication Foundation (WCF) in a partial trust environment. +This article describes best practices when running Windows Communication Foundation (WCF) in a partial trust environment. ## Serialization -Apply the following practices when using the in a partially-trusted application. +Apply the following practices when using the in a partially trusted application. -- All serializable types must be explicitly marked with the `[DataContract]` attribute. The following techniques are not supported in a partial trust environment: +- All serializable types must be explicitly marked with the `[DataContract]` attribute. The following techniques aren't supported in a partial trust environment: - Marking classes to be serialized with the . @@ -20,13 +20,13 @@ Apply the following practices when using the are supported. -- `[DataContract]` types implemented in assemblies marked with the must not perform security-related actions in the type constructor, as the does not call the constructor of the newly-instantiated object during deserialization. Specifically, the following common security techniques must be avoided for `[DataContract]` types: +- `[DataContract]` types implemented in assemblies marked with the must not perform security-related actions in the type constructor, as the does not call the constructor of the newly instantiated object during deserialization. Specifically, the following common security techniques must be avoided for `[DataContract]` types: - Attempting to restrict partial trust access by making the type's constructor internal or private. @@ -42,25 +42,27 @@ The following best practices apply for types that implement interface must be `public`. -## Using WCF from Fully-Trusted Platform Code that Allows Calls from Partially Trusted Callers +## Using WCF from Fully Trusted Platform Code that Allows Calls from Partially Trusted Callers The WCF partial trust security model assumes that any caller of a WCF public method or property is running in the code access security (CAS) context of the hosting application. WCF also assumes that only one application security context exists for each , and that this context is established at creation time by a trusted host (for example, by a call to or by the ASP.NET Application Manager). -This security model applies to user-written applications that cannot assert additional CAS permissions, such as user code running in a Medium Trust ASP.NET application. However, fully-trusted platform code (for example, a third-party assembly that is installed in the global assembly cache and accepts calls from partially-trusted code) must take explicit care when calling into WCF on behalf of a partially-trusted application to avoid introducing application-level security vulnerabilities. +[!INCLUDE [cas-deprecated](../../../../includes/cas-deprecated.md)] -Full-trust code should avoid altering the CAS permission set of the current thread (by calling , , or ) prior to calling WCF APIs on behalf of partially-trusted code. Asserting, denying, or otherwise creating a thread-specific permission context that is independent of the application-level security context can result in unexpected behavior. Depending on the application, this behavior may result in application-level security vulnerabilities. +This security model applies to user-written applications that can't assert additional CAS permissions, such as user code running in a Medium Trust ASP.NET application. However, fully trusted platform code (for example, a third-party assembly that is installed in the global assembly cache and accepts calls from partially trusted code) must take explicit care when calling into WCF on behalf of a partially trusted application to avoid introducing application-level security vulnerabilities. + +Full-trust code should avoid altering the CAS permission set of the current thread (by calling , , or ) prior to calling WCF APIs on behalf of partially trusted code. Asserting, denying, or otherwise creating a thread-specific permission context that is independent of the application-level security context can result in unexpected behavior. Depending on the application, this behavior may result in application-level security vulnerabilities. Code that calls into WCF using a thread-specific permission context must be prepared to handle the following situations that may arise: - The thread-specific security context may not be maintained for the duration of the operation, which results in potential security exceptions. -- Internal WCF code as well as any user-provided callbacks may run in a different security context than the one under which the call was originally initiated. These contexts include: +- Internal WCF code and any user-provided callbacks may run in a different security context than the one under which the call was originally initiated. These contexts include: - The application permission context. - Any thread-specific permission context previously created by other user threads used to call into WCF during the lifetime of the currently running . -WCF guarantees that partially-trusted code cannot obtain full-trust permissions unless such permissions are asserted by a fully-trusted component prior to calling into WCF public APIs. However, it does not guarantee that the effects of asserting full trust is isolated to a particular thread, operation, or user action. +WCF guarantees that partially trusted code can't obtain full-trust permissions unless such permissions are asserted by a fully trusted component prior to calling into WCF public APIs. However, it doesn't guarantee that the effects of asserting full trust are isolated to a particular thread, operation, or user action. As a best practice, avoid creating thread-specific permission context by calling , , or . Instead, grant or deny the privilege to the application itself, so that no , , or is required. diff --git a/docs/framework/wcf/feature-details/partial-trust.md b/docs/framework/wcf/feature-details/partial-trust.md index dc7d0e8f142be..7e110dc65cce8 100644 --- a/docs/framework/wcf/feature-details/partial-trust.md +++ b/docs/framework/wcf/feature-details/partial-trust.md @@ -4,9 +4,11 @@ title: "Partial Trust" ms.date: "03/30/2017" ms.assetid: 489b1587-9909-4d0e-8c1a-5e83c8f8292b --- -# Partial Trust +# Partial trust -Starting with the .NET Framework 3.5, partially trusted callers can access public types and methods implemented in , , and . This section describes supported scenarios for using Windows Communication Foundation (WCF) within a partially trusted application as well as the limited subset of WCF functionality available to applications running with reduced code access security (CAS) permissions. +Starting with .NET Framework 3.5, partially trusted callers can access public types and methods implemented in , , and . This section describes supported scenarios for using Windows Communication Foundation (WCF) within a partially trusted application. It also describes the limited subset of WCF functionality available to applications running with reduced code access security (CAS) permissions. + +[!INCLUDE [cas-deprecated](../../../../includes/cas-deprecated.md)] ## In This Section @@ -14,7 +16,7 @@ Starting with the .NET Framework 3.5, partially trusted callers can access publi Describes the main partial trust scenarios for running WCF. [Partial Trust Feature Compatibility](partial-trust-feature-compatibility.md) - Describes the WCF features that cannot be used with partial trust. + Describes the WCF features that can't be used with partial trust. [Partial Trust Best Practices](partial-trust-best-practices.md) Contains best practices for using WCF in partially trusted applications. diff --git a/docs/framework/wcf/feature-details/security-considerations-for-data.md b/docs/framework/wcf/feature-details/security-considerations-for-data.md index dca3262b04e45..9c1a52cec2712 100644 --- a/docs/framework/wcf/feature-details/security-considerations-for-data.md +++ b/docs/framework/wcf/feature-details/security-considerations-for-data.md @@ -36,6 +36,8 @@ You should ensure that no malicious code is plugged in to the various extensibil Note that when running in partial trust, the data contract serialization infrastructure supports only a limited subset of the data contract programming model - for example, private data members or types using the attribute are not supported. For more information, see [Partial Trust](partial-trust.md). +[!INCLUDE [cas-deprecated](../../../../includes/cas-deprecated.md)] + ## Avoiding Unintentional Information Disclosure When designing serializable types with security in mind, information disclosure is a possible concern. diff --git a/docs/framework/wcf/feature-details/supported-deployment-scenarios.md b/docs/framework/wcf/feature-details/supported-deployment-scenarios.md index d3af2cf9d3760..82c99ab337374 100644 --- a/docs/framework/wcf/feature-details/supported-deployment-scenarios.md +++ b/docs/framework/wcf/feature-details/supported-deployment-scenarios.md @@ -40,7 +40,6 @@ WCF can be used to communicate with remote servers from within partially trusted ## See also -- [Code Access Security](/previous-versions/dotnet/framework/code-access-security/code-access-security) - [Windows Presentation Foundation Browser-Hosted Applications Overview](/dotnet/desktop/wpf/app-development/wpf-xaml-browser-applications-overview) - [Partial Trust](partial-trust.md) - [ASP.NET Trust Levels and Policy Files](/previous-versions/wyts434y(v=vs.140)) diff --git a/docs/framework/wcf/whats-new.md b/docs/framework/wcf/whats-new.md index 2b714cf1d0522..2fa3f4c657783 100644 --- a/docs/framework/wcf/whats-new.md +++ b/docs/framework/wcf/whats-new.md @@ -118,7 +118,7 @@ Support has been added to allow for WCF services with Internationalized Domain N ## HttpClient -A new class called has been added to make working with HTTP requests much easier. For more info, see [Making apps social and connected with HTTP services](https://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-581T). +A new class called has been added to make working with HTTP requests much easier. For more info, see and [Guidelines for using HTTP clients](../../fundamentals/networking/httpclient-guidelines.md). ## Configuration IntelliSense diff --git a/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md b/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md index a4622920094df..41761a3fd7f04 100644 --- a/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md +++ b/docs/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer.md @@ -101,7 +101,17 @@ To set up a simple polling mechanism, use the namespace: + + ```csharp + using System.Timers; + ``` + + ```vb + Imports System.Timers + ``` + +2. Add the following code in the `MyNewService.OnStart` event to set up the polling mechanism: ```csharp // Set up a timer that triggers every minute. @@ -119,17 +129,17 @@ To set up a simple polling mechanism, use the namespace: +3. In the `MyNewService` class, add a member variable. It contains the identifier of the next event to write into the event log: ```csharp - using System.Timers; + private int eventId = 1; ``` ```vb - Imports System.Timers + Private eventId As Integer = 1 ``` -3. In the `MyNewService` class, add the `OnTimer` method to handle the event: +4. In the `MyNewService` class, add the `OnTimer` method to handle the event: ```csharp public void OnTimer(object sender, ElapsedEventArgs args) @@ -147,16 +157,6 @@ To set up a simple polling mechanism, use the . ### Define what occurs when the service is stopped diff --git a/docs/fsharp/get-started/get-started-command-line.md b/docs/fsharp/get-started/get-started-command-line.md index 397190c14f68b..ca1fb25a89b07 100644 --- a/docs/fsharp/get-started/get-started-command-line.md +++ b/docs/fsharp/get-started/get-started-command-line.md @@ -15,7 +15,7 @@ This article assumes that you know how to use a command line and have a preferre ## Build a simple multi-project solution -Open a command prompt/terminal and use the [dotnet new](../../core/tools/dotnet-new.md) command to create new solution file called `FSharpSample`: +Open a command prompt/terminal and use the [dotnet new](../../core/tools/dotnet-new.md) command to create a new solution file called `FSharpSample`: ```dotnetcli dotnet new sln -o FSharpSample @@ -32,7 +32,7 @@ FSharpSample Change directories to *FSharpSample*. -Use the `dotnet new` command, create a class library project in the **src** folder named Library. +Use the `dotnet new` command to create a class library project in the **src** folder named Library. ```dotnetcli dotnet new classlib -lang "F#" -o src/Library @@ -71,7 +71,7 @@ Run `dotnet build` to build the project. Unresolved dependencies will be restore ### Write a console application that consumes the class library -Use the `dotnet new` command, create a console application in the **src** folder named App. +Use the `dotnet new` command to create a console application in the **src** folder named App. ```dotnetcli dotnet new console -lang "F#" -o src/App @@ -120,7 +120,7 @@ Add the `App` project to the `FSharpSample` solution using the `dotnet sln add` dotnet sln add src/App/App.fsproj ``` -Restore the NuGet dependencies, `dotnet restore` and run `dotnet build` to build the project. +Restore the NuGet dependencies with `dotnet restore` and run `dotnet build` to build the project. Change directory to the `src/App` console project and run the project passing `Hello World` as arguments: diff --git a/docs/fsharp/get-started/get-started-vscode.md b/docs/fsharp/get-started/get-started-vscode.md index edc611a95fc33..858c48003898f 100644 --- a/docs/fsharp/get-started/get-started-vscode.md +++ b/docs/fsharp/get-started/get-started-vscode.md @@ -24,7 +24,7 @@ cd FirstIonideProject code . ``` -After the project loads on Visual Studio Code, you should see the F# Solution Explorer pane on the left-hand side of your window open. This means Ionide has successfully loaded the project you just created. You can write code in the editor before this point in time, but once this happens, everything has finished loading. +After the project loads in Visual Studio Code, you should see the F# Solution Explorer pane on the left-hand side of your window open. This means Ionide has successfully loaded the project you just created. You can write code in the editor before this point in time, but once this happens, everything has finished loading. ### Write your first script @@ -43,7 +43,7 @@ Highlight the entire function (it should be 11 lines long). Once it's highlighte This did three things: 1. It started the FSI process. -2. It sent the code you highlighted over the FSI process. +2. It sent the code you highlighted over to the FSI process. 3. The FSI process evaluated the code you sent over. Because what you sent over was a [function](../language-reference/functions/index.md), you can now call that function with FSI! In the interactive window, type the following: diff --git a/docs/fsharp/get-started/index.md b/docs/fsharp/get-started/index.md index 3c830cdc53c72..29ee4c6829299 100644 --- a/docs/fsharp/get-started/index.md +++ b/docs/fsharp/get-started/index.md @@ -17,11 +17,11 @@ There are multiple guides on how to install and use F# for the first time on you | macOS | [Get started with VS for Mac](get-started-with-visual-studio-for-mac.md) | [Get started with Visual Studio Code](get-started-vscode.md) | [Get started with the .NET CLI](get-started-command-line.md) | | Linux | N/A | [Get started with Visual Studio Code](get-started-vscode.md) | [Get started with the .NET CLI](get-started-command-line.md) | -In general, there is no specific that is better than the rest. We recommend trying all ways to use F# on your machine to see what you like the best! +In general, there is no specific way that is better than the rest. We recommend trying all ways to use F# on your machine to see what you like the best! ## Get started online If you'd rather not install F# and .NET on your machine, you can also get started with F# in the browser: -* [Introduction to F# on Binder](https://mybinder.org/v2/gh/dotnet/interactive/main?urlpath=lab) is a [Jupyter notebook](https://jupyter.org/) on hosted via the free [Binder](https://mybinder.org/) service. No sign-up needed! +* [Introduction to F# on Binder](https://mybinder.org/v2/gh/dotnet/interactive/main?urlpath=lab) is a [Jupyter notebook](https://jupyter.org/) hosted via the free [Binder](https://mybinder.org/) service. No sign-up needed! * [The Fable REPL](https://fable.io/repl/) is an interactive, in-browser REPL that uses [Fable](https://fable.io/) to translate F# code into JavaScript. Check out the numerous samples that range from F# basics to a fully fledged video game all executing in your browser! diff --git a/docs/fsharp/get-started/media/getting-started-vscode/vscode-fsi.png b/docs/fsharp/get-started/media/getting-started-vscode/vscode-fsi.png index 4262ff22ffe4f..2ce7e94743216 100644 Binary files a/docs/fsharp/get-started/media/getting-started-vscode/vscode-fsi.png and b/docs/fsharp/get-started/media/getting-started-vscode/vscode-fsi.png differ diff --git a/docs/fsharp/language-reference/arrays.md b/docs/fsharp/language-reference/arrays.md index 48b2ef267d223..e89719d2e66f7 100644 --- a/docs/fsharp/language-reference/arrays.md +++ b/docs/fsharp/language-reference/arrays.md @@ -35,7 +35,7 @@ To create an array in which all the elements are initialized to zero, use `Array ## Access elements -You can access array elements by using a dot operator (`.`) and brackets (`[` and `]`). +You can access array elements by using brackets (`[` and `]`). The original dot syntax (`.[index]`) is still supported but no longer recommended as of F# 6.0. [!code-fsharp[Main](~/samples/snippets/fsharp/arrays/snippet5.fs)] diff --git a/docs/fsharp/language-reference/compiler-options.md b/docs/fsharp/language-reference/compiler-options.md index d9c7bc0547f4e..b8877ade31c94 100644 --- a/docs/fsharp/language-reference/compiler-options.md +++ b/docs/fsharp/language-reference/compiler-options.md @@ -5,7 +5,7 @@ ms.date: 11/04/2021 --- # Compiler options -This topic describes compiler command-line options for the F# compiler, fsc.exe. +This article describes compiler command-line options for the F# compiler. The command `dotnet build` invokes the F# compiler on F# project files. F# project files are noted with the `.fsproj` extension. The compilation environment can also be controlled by setting the project properties. For projects targeting .NET Core, the "Other flags" property, `...` in `.fsproj`, is used for specifying extra command-line options. @@ -40,7 +40,7 @@ The following table shows compiler options listed alphabetically. Some of the F# |`--nologo`|Doesn't show the banner text when launching the compiler.| |`--nooptimizationdata`|Instructs the compiler to only include optimization essential for implementing inlined constructs. Inhibits cross-module inlining but improves binary compatibility.| |`--nowin32manifest`|Instructs the compiler to omit the default Win32 manifest.| -|`--nowarn:warning-number-list`|Disables specific warnings listed by number. Separate each warning number by a comma. You can discover the warning number for any warning from the compilation output.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/nowarn (C# Compiler Options)](../../csharp/language-reference/compiler-options/errors-warnings.md#disabledwarnings).| +|`--nowarn:warning-number-list`|Disables specific warnings listed by number. Separate each warning number by a comma. You can discover the warning number for any warning from the compilation output.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/nowarn (C# Compiler Options)](../../csharp/language-reference/compiler-options/errors-warnings.md#nowarn).| |--optimize[+|-][optimization-option-list]

-O[+|-] [optimization-option-list]|Enables or disables optimizations. Some optimization options can be disabled or enabled selectively by listing them. These are: `nojitoptimize`, `nojittracking`, `nolocaloptimize`, `nocrossoptimize`, `notailcalls`.| |`--out:output-filename`

`-o:output-filename`|Specifies the name of the compiled assembly or module.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/out (C# Compiler Options)](../../csharp/language-reference/compiler-options/output.md#outputassembly).| |`--pathmap:path=sourcePath,...`|Specifies how to map physical paths to source path names output by the compiler.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/pathmap (C# Compiler Options)](../../csharp/language-reference/compiler-options/advanced.md#pathmap).| diff --git a/docs/fsharp/language-reference/computation-expressions.md b/docs/fsharp/language-reference/computation-expressions.md index c32715130c6ff..f7d4d9f5f36ff 100644 --- a/docs/fsharp/language-reference/computation-expressions.md +++ b/docs/fsharp/language-reference/computation-expressions.md @@ -309,7 +309,7 @@ module Eventually = | Done value -> result (Ok value) | NotYetDone work -> NotYetDone (fun () -> - let res = try Ok(work()) with | exn -> Exception exn + let res = try Ok(work()) with | exn -> Error exn match res with | Ok cont -> catch cont // note, a tailcall | Error exn -> result (Error exn)) diff --git a/docs/fsharp/language-reference/fixed.md b/docs/fsharp/language-reference/fixed.md index 977086d47375a..d3a1838ff0aa0 100644 --- a/docs/fsharp/language-reference/fixed.md +++ b/docs/fsharp/language-reference/fixed.md @@ -17,7 +17,7 @@ use ptr = fixed expression This extends the syntax of expressions to allow extracting a pointer and binding it to a name which is prevented from being collected or moved during garbage-collection. -A pointer from an expression is fixed via the `fixed` keyword is bound to an identifier via the `use` keyword. The semantics of this are similar to resource management via the `use` keyword. The pointer is fixed while it is in scope, and once it is out of scope, it is no longer fixed. `fixed` cannot be used outside the context of a `use` binding. You must bind the pointer to a name with `use`. +A pointer from an expression is fixed via the `fixed` keyword and is bound to an identifier via the `use` keyword. The semantics of this are similar to resource management via the `use` keyword. The pointer is fixed while it is in scope, and once it is out of scope, it is no longer fixed. `fixed` cannot be used outside the context of a `use` binding. You must bind the pointer to a name with `use`. Use of `fixed` must occur within an expression in a function or a method. It cannot be used at a script-level or module-level scope. diff --git a/docs/fsharp/language-reference/functions/let-bindings.md b/docs/fsharp/language-reference/functions/let-bindings.md index 9b46778fd7cad..d1793f07c6c05 100644 --- a/docs/fsharp/language-reference/functions/let-bindings.md +++ b/docs/fsharp/language-reference/functions/let-bindings.md @@ -88,7 +88,7 @@ The scope of an entity declared with a let binding is limited to the portion of Normally, functions in modules must be qualified by the name of the module when used by client code. For example, if a module `Module1` has a function `function1`, users would specify `Module1.function1` to refer to the function. -Users of a module may use an import declaration to make the functions within that module available for use without being qualified by the module name. In the example just mentioned, users of the module can in that case open the module by using the import declaration open `Module1` and thereafter refer to `function1` directly. +Users of a module may use an import declaration to make the functions within that module available for use without being qualified by the module name. In the example just mentioned, users of the module can in that case open the module by using the import declaration `open Module1` and thereafter refer to `function1` directly. ```fsharp module Module1 = diff --git a/docs/fsharp/language-reference/index.md b/docs/fsharp/language-reference/index.md index 0e08771f9ab47..49142018c5cf1 100644 --- a/docs/fsharp/language-reference/index.md +++ b/docs/fsharp/language-reference/index.md @@ -18,7 +18,7 @@ The following table shows reference articles related to organizing your F# code. |[`open` Declarations](import-declarations-the-open-keyword.md)|Learn about how `open` works. An `open` declaration specifies a module, namespace, or type whose elements you can reference without using a fully qualified name.| |[Signatures](signature-files.md)|Learn about signatures and signature files. A signature file contains information about the public signatures of a set of F# program elements, such as types, namespaces, and modules. It can be used to specify the accessibility of these program elements.| |[Access Control](access-control.md)|Learn about access control in F#. Access control means declaring what clients are able to use certain program elements, such as types, methods, functions, and so on.| -|[XML Documentation](xml-documentation.md)|Learn about support for generating documentation files for XML doc comments, also known as triple slash comments. You can produce documentation from code comments in F# as in other .NET languages.| +|[XML Documentation](xml-documentation.md)|Learn about support for generating documentation files from XML doc comments, also known as triple slash comments. You can produce documentation from code comments in F# as in other .NET languages.| ## Literals and Strings diff --git a/docs/fsharp/language-reference/interpolated-strings.md b/docs/fsharp/language-reference/interpolated-strings.md index d86d4baf7ff4a..832c305be4512 100644 --- a/docs/fsharp/language-reference/interpolated-strings.md +++ b/docs/fsharp/language-reference/interpolated-strings.md @@ -86,7 +86,7 @@ let pi = $"{System.Math.PI:N4}" // "3.1416" let now = $"{System.DateTime.UtcNow:``yyyyMMdd``}" // e.g. "20220210" ``` -If a .NET alignment contains an unusual character, then it can be escaped using double-backticks: +If a .NET-style specifier contains an unusual character, then it can be escaped using double-backticks: ```fsharp let nowDashes = $"{System.DateTime.UtcNow:``yyyy-MM-dd``}" // e.g. "2022-02-10" diff --git a/docs/fsharp/language-reference/literals.md b/docs/fsharp/language-reference/literals.md index aedddf9f6d70a..0acc6e93a5297 100644 --- a/docs/fsharp/language-reference/literals.md +++ b/docs/fsharp/language-reference/literals.md @@ -62,11 +62,11 @@ let Literal3 = System.IO.FileAccess.Read ||| System.IO.FileAccess.Write Unicode strings can contain explicit encodings that you can specify by using `\u` followed by a 16-bit hexadecimal code (0000 - FFFF), or UTF-32 encodings that you can specify by using `\U` followed by a 32-bit hexadecimal code that represents any Unicode code point (00000000 - 0010FFFF). -The use of other bitwise operators other than `|||` isn't allowed. +The use of bitwise operators other than `|||` isn't allowed. ## Integers in other bases -Signed 32-bit integers can also be specified in hexadecimal, octal, or binary using a `0x`, `0o` or `0b` prefix respectively. +Signed 32-bit integers can also be specified in hexadecimal, octal, or binary using a `0x`, `0o` or `0b` prefix, respectively. ```fsharp let numbers = (0x9F, 0o77, 0b1010) diff --git a/docs/fsharp/language-reference/members/indexed-properties.md b/docs/fsharp/language-reference/members/indexed-properties.md index e8032c4bc2b16..9945931eb4142 100644 --- a/docs/fsharp/language-reference/members/indexed-properties.md +++ b/docs/fsharp/language-reference/members/indexed-properties.md @@ -45,7 +45,7 @@ member self-identifier.Item The forms of the previous syntax show how to define indexed properties that have both a `get` and a `set` method, have a `get` method only, or have a `set` method only. You can also combine both the syntax shown for get only and the syntax shown for set only, and produce a property that has both get and set. This latter form allows you to put different accessibility modifiers and attributes on the get and set methods. -By using the name `Item`, the compiler treats the property as a default indexed property. A *default indexed property* is a property that you can access by using array-like syntax on the object instance. For example, if `o` is an object of the type that defines this property, the syntax `o[index]` is used to access the property. The syntax `o[index]` (with an extra `.`) may also be used and is required for language versions prior to F# 6. +By using the name `Item`, the compiler treats the property as a default indexed property. A *default indexed property* is a property that you can access by using array-like syntax on the object instance. For example, if `o` is an object of the type that defines this property, the syntax `o[index]` is used to access the property. The syntax for accessing a non-default indexed property is to provide the name of the property and the index in parentheses, just like a regular member. For example, if the property on `o` is called `Ordinal`, you write `o.Ordinal(index)` to access it. diff --git a/docs/fsharp/language-reference/task-expressions.md b/docs/fsharp/language-reference/task-expressions.md index 973b8185fe71e..bff6cb52068fa 100644 --- a/docs/fsharp/language-reference/task-expressions.md +++ b/docs/fsharp/language-reference/task-expressions.md @@ -24,7 +24,7 @@ In a task expression, some expressions and operations are synchronous, and some The following code shows the difference between `let` and `let!`. The line of code that uses `let` just creates a task as an object that you can await later by using, for example, `task.Wait()` or `task.Result`. The line of code that uses `let!` starts the task and awaits its result. ```fsharp -// let just stores the result as an task. +// let just stores the result as a task. let (result1 : Task) = stream.ReadAsync(buffer, offset, count, cancellationToken) // let! completes the asynchronous operation and returns the data. let! (result2 : int) = stream.ReadAsync(buffer, offset, count, cancellationToken) diff --git a/docs/fsharp/language-reference/type-extensions.md b/docs/fsharp/language-reference/type-extensions.md index f475e1ea9f4b7..8e1df6915ea1f 100644 --- a/docs/fsharp/language-reference/type-extensions.md +++ b/docs/fsharp/language-reference/type-extensions.md @@ -1,6 +1,6 @@ --- title: Type Extensions -description: Learn how F# type extensions allow you add new members to a previously defined object type. +description: Learn how F# type extensions allow you to add new members to a previously defined object type. ms.date: 02/05/2020 --- # Type extensions diff --git a/docs/fsharp/style-guide/formatting.md b/docs/fsharp/style-guide/formatting.md index bf5a35a438f08..dae5ead4bfbda 100644 --- a/docs/fsharp/style-guide/formatting.md +++ b/docs/fsharp/style-guide/formatting.md @@ -85,7 +85,7 @@ let myOtherVeryLongValueName = The primary reasons for avoiding this are: * Important code is moved far to the right -* There is less width left for the actual code +* There's less width left for the actual code * Renaming can break the alignment ### Avoid extraneous white space @@ -175,7 +175,7 @@ let update model msg = | _ -> model, [ msg ] ``` -In summary, prefer parenthesized tuple instantiations, but when using tuples for pattern matching or a return value, it is considered fine to avoid parentheses. +In summary, prefer parenthesized tuple instantiations, but when using tuples for pattern matching or a return value, it's considered fine to avoid parentheses. ### Formatting application expressions @@ -245,7 +245,7 @@ SomeClass.Invoke () String.Format (x.IngredientName, x.Quantity) ``` -You may need to pass arguments to a function on a new line, as a matter of readability or because the list of arguments or the argument names are too long. In that case, indent one level: +You may need to pass arguments to a function on a new line as a matter of readability or because the list of arguments or the argument names are too long. In that case, indent one level: ```fsharp // ✔️ OK @@ -488,7 +488,7 @@ let subtractThenAdd x = x - 1 + 3 ``` Failing to surround a binary `-` operator, when combined with certain formatting choices, could lead to interpreting it as a unary `-`. -Unary `-` operators should always be immediately followed by the value they are negating: +Unary `-` operators should always be immediately followed by the value they negate: ```fsharp // ✔️ OK @@ -515,6 +515,20 @@ let function1 arg1 arg2 arg3 arg4 = arg3 + arg4 ``` +This rule also applies to units of measures in types and constant annotations: + +```fsharp +// ✔️ OK +type Test = + { WorkHoursPerWeek: uint
} + static member create = { WorkHoursPerWeek = 40u
} + +// ❌ Not OK +type Test = + { WorkHoursPerWeek: uint
} + static member create = { WorkHoursPerWeek = 40u
} +``` + The following operators are defined in the F# standard library and should be used instead of defining equivalents. Using these operators is recommended as it tends to make code more readable and idiomatic. The following list summarizes the recommended F# operators. ```fsharp @@ -842,7 +856,7 @@ let rainbow2 = ``` You may want to dedicate separate lines for the braces and indent one scope to the right with the expression, however -code formatters may . In some special cases, such as wrapping a value with an optional without parentheses, you may need to keep a brace on one line: +code formatters may reformat it. In some special cases, such as wrapping a value with an optional without parentheses, you may need to keep a brace on one line: ```fsharp // ✔️ OK @@ -989,7 +1003,7 @@ let makeStreamReader x = new System.IO.StreamReader(path = x) let makeStreamReader x = new System.IO.StreamReader(path=x) ``` -When pattern matching using discriminated unions, named patterns are formatted similarly, e.g. +When pattern matching using discriminated unions, named patterns are formatted similarly, for example. ```fsharp type Data = @@ -1070,6 +1084,35 @@ let v = expr.[ idx ] let y = myList.[ 0 .. 1 ] ``` +### Formatting quoted expressions + +The delimiter symbols (`<@` , `@>`, `<@@`, `@@>`) should be placed on separate lines if the quoted expression is a multi-line expression. + +```fsharp +// ✔️ OK +<@ + let f x = x + 10 + f 20 +@> + +// ❌ Not OK +<@ let f x = x + 10 + f 20 +@> +``` + +In single-line expressions the delimiter symbols should be placed on the same line as the expression itself. + +```fsharp +// ✔️ OK +<@ 1 + 1 @> + +// ❌ Not OK +<@ + 1 + 1 +@> +``` + ## Formatting declarations This section discusses formatting declarations of different kinds. @@ -1337,7 +1380,7 @@ type PostalAddress = member x.ZipAndCity = $"{x.Zip} {x.City}" ``` -Placing the opening token on a new line and the closing token on a new line is preferable if you are declaring interface implementations or members on the record: +Placing the opening token on a new line and the closing token on a new line is preferable if you're declaring interface implementations or members on the record: ```fsharp // ✔️ OK @@ -1467,7 +1510,7 @@ module A2 = ### Formatting do declarations In type declarations, module declarations and computation expressions, the use of `do` or `do!` is sometimes required for side-effecting operations. -When these span multiple lines, use indentation and a new line to keep the indentation consistent with `let`/`let!`. Here is an example using `do` in a class: +When these span multiple lines, use indentation and a new line to keep the indentation consistent with `let`/`let!`. Here's an example using `do` in a class: ```fsharp // ✔️ OK @@ -1493,7 +1536,7 @@ type Foo () = |> theQuickBrownFoxJumpedOverTheLazyDog ``` -Here is an example with `do!` using two spaces of indentation (because with `do!` there is coincidentally no difference between the approaches when using four spaces of indentation): +Here's an example with `do!` using two spaces of indentation (because with `do!` there is coincidentally no difference between the approaches when using four spaces of indentation): ```fsharp // ✔️ OK @@ -1637,7 +1680,7 @@ When writing full function types in signatures, it is sometimes necessary to spl over multiple lines. The return type is always indented. For a tupled function, the arguments are separated by `*`, -placed at the end of each line. +placed at the end of each line. For example, consider a function with the following implementation: @@ -1840,6 +1883,6 @@ type MyRecord = When applied to a parameter, they must be on the same line and separated by a `;` separator. -### Acknowledgements +### Acknowledgments These guidelines are based on [A comprehensive guide to F# Formatting Conventions](https://github.com/dungpa/fantomas/blob/master/docs/FormattingConventions.md) by [Anh-Dung Phan](https://github.com/dungpa). diff --git a/docs/fsharp/using-fsharp-on-azure/table-storage.md b/docs/fsharp/using-fsharp-on-azure/table-storage.md index 6691f2b2adff4..bb72293ccb630 100644 --- a/docs/fsharp/using-fsharp-on-azure/table-storage.md +++ b/docs/fsharp/using-fsharp-on-azure/table-storage.md @@ -29,7 +29,7 @@ This tutorial shows how to write F# code to do some common tasks using Azure Tab ## Prerequisites -To use this guide, you must first [create an Azure storage account](/azure/storage/storage-create-storage-account) or [Azure Cosmos DB account](https://azure.microsoft.com/try/cosmosdb/). +To use this guide, you must first [create an Azure storage account](/azure/storage/storage-create-storage-account) or [Azure Cosmos DB account](https://azure.microsoft.com/free/cosmos-db/). ## Create an F\# script and start F\# interactive diff --git a/docs/fsharp/what-is-fsharp.md b/docs/fsharp/what-is-fsharp.md index fcfad389bf17e..5a4721b440100 100644 --- a/docs/fsharp/what-is-fsharp.md +++ b/docs/fsharp/what-is-fsharp.md @@ -77,9 +77,9 @@ let handleWithdrawal amount = // The F# compiler enforces accounting for each case! match w with - | Success s -> printfn "Successfully withdrew %f{s.Amount}" - | InsufficientFunds f -> printfn "Failed: balance is %f{f.Balance}" - | CardExpired d -> printfn "Failed: card expired on {d}" + | Success s -> printfn $"Successfully withdrew %f{s.Amount}" + | InsufficientFunds f -> printfn $"Failed: balance is %f{f.Balance}" + | CardExpired d -> printfn $"Failed: card expired on {d}" | UndisclosedFailure -> printfn "Failed: unknown :(" ``` diff --git a/docs/fundamentals/code-analysis/code-quality-rule-options.md b/docs/fundamentals/code-analysis/code-quality-rule-options.md index 96c5a9715726c..6b0166ded0591 100644 --- a/docs/fundamentals/code-analysis/code-quality-rule-options.md +++ b/docs/fundamentals/code-analysis/code-quality-rule-options.md @@ -1,13 +1,22 @@ --- title: Code quality rule configuration options description: Learn how to specify additional configuration options for code quality rules. -ms.date: 09/24/2020 +ms.date: 06/09/2022 no-loc: ["EditorConfig"] --- # Code quality rule configuration options The *code quality* rules have additional configuration options, besides just [configuring their severity](configuration-options.md#severity-level). For example, each code quality analyzer can be configured to only apply to specific parts of your codebase. You specify these options by adding key-value pairs to the same [EditorConfig](https://editorconfig.org) file where you specify rule severities and general editor preferences. +> [!NOTE] +> This article does not detail how to configure a rule's severity. The *.editorconfig* option to set a rule's severity has a different prefix (`dotnet_diagnostic`) to the options described here (`dotnet_code_quality`). In addition, the options described here pertain to code quality rules only, whereas the severity option applies to code style rules as well. As a quick reference, you can configure a rule's severity using the following option syntax: +> +> ```ini +> dotnet_diagnostic..severity = +> ``` +> +> However, for detailed information about configuring rule severity, see [Severity level](configuration-options.md#severity-level). + ## Option scopes Each refining option can be configured for all rules, for a category of rules (for example, Security or Design), or for a specific rule. diff --git a/docs/fundamentals/code-analysis/configuration-files.md b/docs/fundamentals/code-analysis/configuration-files.md index 179227aeb86f8..679ba8cb2b1f8 100644 --- a/docs/fundamentals/code-analysis/configuration-files.md +++ b/docs/fundamentals/code-analysis/configuration-files.md @@ -34,7 +34,7 @@ You can apply EditorConfig file conventions to a folder, a project, or an entire If you have an existing *.editorconfig* file for editor settings such as indent size or whether to trim trailing whitespace, you can place your code analysis configuration options in the same file. > [!TIP] -> Visual Studio provides an *.editorconfig* item template that makes is easy to add one of these files to your project. For more information, see [Add an EditorConfig file to a project](/visualstudio/ide/create-portable-custom-editor-options#add-an-editorconfig-file-to-a-project). +> Visual Studio provides an *.editorconfig* item template that makes it easy to add one of these files to your project. For more information, see [Add an EditorConfig file to a project](/visualstudio/ide/create-portable-custom-editor-options#add-an-editorconfig-file-to-a-project). ### Example @@ -97,7 +97,7 @@ Consider the following naming recommendations: - MSBuild tooling-generated global config files should be named *<%Target_Name%>_Generated.globalconfig* or similar. > [!NOTE] -> The top-level entry `is_global = true` is required even when the file is named `.globalconfig`. +> The top-level entry `is_global = true` is not required when the file is named `.globalconfig`, but it is recommended for clarity. ### Example diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1060.md b/docs/fundamentals/code-analysis/quality-rules/ca1060.md index 55c7c6178507d..53818e7080f19 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1060.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1060.md @@ -43,9 +43,9 @@ These classes are declared as `internal` (`Friend` in Visual Basic) and declare To fix a violation of this rule, move the method to the appropriate **NativeMethods** class. For most applications, moving P/Invokes to a new class that is named **NativeMethods** is enough. -However, if you are developing libraries for use in other applications, you should consider defining two other classes that are called **SafeNativeMethods** and **UnsafeNativeMethods**. These classes resemble the **NativeMethods** class; however, they are marked by using a special attribute called **SuppressUnmanagedCodeSecurityAttribute**. When this attribute is applied, the runtime does not perform a full stack walk to make sure that all callers have the **UnmanagedCode** permission. The runtime ordinarily checks for this permission at startup. Because the check is not performed, it can greatly improve performance for calls to these unmanaged methods, It also enables code that has limited permissions to call these methods. +However, if you are developing libraries for use in other applications, you should consider defining two other classes that are called **SafeNativeMethods** and **UnsafeNativeMethods**. These classes resemble the **NativeMethods** class; however, they are marked by using a special attribute called **SuppressUnmanagedCodeSecurityAttribute**. When this attribute is applied, the runtime does not perform a full stack walk to make sure that all callers have the **UnmanagedCode** permission. The runtime ordinarily checks for this permission at startup. Because the check is not performed, it can greatly improve performance for calls to these unmanaged methods. It also enables code that has limited permissions to call these methods. -However, you should use this attribute with great care. It can have serious security implications if it is implemented incorrectly.. +However, you should use this attribute with great care. It can have serious security implications if it is implemented incorrectly. For information about how to implement the methods, see the **NativeMethods** example, **SafeNativeMethods** example, and **UnsafeNativeMethods** example. @@ -73,7 +73,7 @@ The following example shows an **Interaction.Beep** method that wraps the **Mess ## SafeNativeMethods example -P/Invoke methods that can be safely exposed to any application and that do not have any side effects should be put in a class that is named **SafeNativeMethods**. You do not have to demand permissions and you do not have to pay much attention to where they are called from. +P/Invoke methods that can be safely exposed to any application and that do not have any side effects should be put in a class that is named **SafeNativeMethods**. You do not have to pay much attention to where they are called from. The following example shows an **Environment.TickCount** property that wraps the **GetTickCount** function from kernel32.dll. @@ -83,7 +83,7 @@ The following example shows an **Environment.TickCount** property that wraps the ## UnsafeNativeMethods example -P/Invoke methods that cannot be safely called and that could cause side effects should be put in a class that is named **UnsafeNativeMethods**. These methods should be rigorously checked to make sure that they are not exposed to the user unintentionally. Alternatively, the methods should have another permission that is demanded instead of **UnmanagedCode** when they use them. +P/Invoke methods that cannot be safely called and that could cause side effects should be put in a class that is named **UnsafeNativeMethods**. These methods should be rigorously checked to make sure that they are not exposed to the user unintentionally. The following example shows a **Cursor.Hide** method that wraps the **ShowCursor** function from user32.dll. diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1062.md b/docs/fundamentals/code-analysis/quality-rules/ca1062.md index 2091e2c333522..8e6edf2765885 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1062.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1062.md @@ -32,7 +32,7 @@ You can [configure](#configure-code-to-analyze) this rule to exclude certain typ ## Rule description -All reference arguments that are passed to externally visible methods should be checked against `null`. If appropriate, throw a when the argument is `null`. +All reference arguments that are passed to externally visible methods should be checked against `null`. If appropriate, throw an when the argument is `null`. If a method can be called from an unknown assembly because it is declared public or protected, you should validate all parameters of the method. If the method is designed to be called only by known assemblies, mark the method `internal` and apply the attribute to the assembly that contains the method. @@ -167,7 +167,7 @@ End Namespace ## Example 2 -Copy constructors that populate field or properties that are reference objects can also violate rule CA1062. The violation occurs because the copied object that's passed to the copy constructor might be `null` (`Nothing` in Visual Basic). To resolve the violation, use a `static` (`Shared` in Visual Basic) method to check that the copied object is not null. +Copy constructors that populate fields or properties that are reference objects can also violate rule CA1062. The violation occurs because the copied object that's passed to the copy constructor might be `null` (`Nothing` in Visual Basic). To resolve the violation, use a `static` (`Shared` in Visual Basic) method to check that the copied object is not null. In the following `Person` class example, the `other` object that is passed to the `Person` copy constructor might be `null`. diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1305.md b/docs/fundamentals/code-analysis/quality-rules/ca1305.md index 9c66dbb9955de..f667d76b46bb1 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1305.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1305.md @@ -24,7 +24,7 @@ dev_langs: ## Cause -A method or constructor calls one or more members that have overloads that accept a parameter, and the method or constructor does not call the overload that takes the parameter. +A call is made to a method that has an overload that accepts a parameter, and that overload isn't called. This rule ignores calls to .NET methods that are documented as ignoring the parameter. The rule also ignores the following methods: diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1416.md b/docs/fundamentals/code-analysis/quality-rules/ca1416.md index e9a60c087d3b9..d05f6ddd3f54b 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1416.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1416.md @@ -265,7 +265,7 @@ The recommended way to deal with violations is to make sure you only call platfo ## When to suppress warnings -Referencing platform-specific APIs without a proper platform context or guard is not recommended. However, you can suppress these diagnostics by the usual means (``, .editorconfig file, or `#pragma`): +Referencing platform-specific APIs without a proper platform context or guard is not recommended. However, you can suppress these diagnostics using `#pragma` or the [**NoWarn**](../../../csharp/language-reference/compiler-options/errors-warnings.md#nowarn) compiler flag, or by [setting the rule's severity](../configuration-options.md#severity-level) to `none` in an _.editorconfig_ file. ```csharp [SupportedOSPlatform("linux")] diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1806.md b/docs/fundamentals/code-analysis/quality-rules/ca1806.md index eeb9c7d62502e..e5d0f8ee6aeed 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1806.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1806.md @@ -1,7 +1,7 @@ --- title: "CA1806: Do not ignore method results (code analysis)" description: "Learn about code analysis rule CA1806: Do not ignore method results" -ms.date: 06/08/2020 +ms.date: 06/08/2022 ms.topic: reference f1_keywords: - CA1806 @@ -17,11 +17,11 @@ dev_langs: --- # CA1806: Do not ignore method results -| | Value | -|-|-| -| **Rule ID** |CA1806| -| **Category** |[Usage](usage-warnings.md)| -| **Fix is breaking or non-breaking** |Non-breaking| +| | Value | +|-------------------------------------|----------------------------------------| +| **Rule ID** | CA1806 | +| **Category** | [Performance](performance-warnings.md) | +| **Fix is breaking or non-breaking** | Non-breaking | ## Cause @@ -31,43 +31,66 @@ There are several possible reasons for this warning: - A method that creates and returns a new string is called and the new string is never used. -- A COM or P/Invoke method that returns a `HRESULT` or error code that is never used. +- A COM or P/Invoke method that returns a `HRESULT` or error code that's never used. -- A language-integrated query (LINQ) method that returns a result that is never used. +- A language-integrated query (LINQ) method that returns a result that's never used. ## Rule description Unnecessary object creation and the associated garbage collection of the unused object degrade performance. -Strings are immutable and methods such as String.ToUpper returns a new instance of a string instead of modifying the instance of the string in the calling method. +Strings are immutable and methods such as return a new instance of a string instead of modifying the instance of the string in the calling method. -Ignoring `HRESULT` or error code can lead to unexpected behavior in error conditions or to low-resource conditions. +Ignoring `HRESULT` or an error code can lead to low-resource conditions or unexpected behavior in error conditions. LINQ methods are known to not have side effects, and the result should not be ignored. ## How to fix violations -If method A creates a new instance of B object that is never used, pass the instance as an argument to another method or assign the instance to a variable. If the object creation is unnecessary, remove it. +If a method creates a new instance of an object that's never used, pass the instance as an argument to another method or assign the instance to a variable. If the object creation is unnecessary, remove it. -or- -If method A calls method B, but does not use the new string instance that the method B returns, pass the instance as an argument to another method, assign the instance to a variable. Or remove the call if it is unnecessary. +If method A calls method B but does not use the new string instance that method B returns, pass the instance as an argument to another method or assign the instance to a variable. Or remove the call if it's unnecessary. -or- -If method A calls method B, but does not use the `HRESULT` or error code that the method returns, use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method. +If method A calls method B but does not use the `HRESULT` or error code that the method returns, use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method. -or- -If a LINQ method A calls method B, but does not use the result, use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method. +If a LINQ method A calls method B but does not use the result, use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method. ## When to suppress warnings Do not suppress a warning from this rule unless the act of creating the object serves some purpose. +## Configure code to analyze + +Use the following option to configure which parts of your codebase to run this rule on. + +### Additional methods to enforce + +You can configure this rule to check that results from additional custom APIs are used. Specify one or more methods as the *value* of the `additional_use_results_methods` option. To specify multiple method names, separate them with `|`. The allowable formats for the method name are: + +- Method name only (which will include all methods with that name, regardless of their containing type or namespace). +- Fully qualified name in the [documentation ID format](/dotnet/csharp/language-reference/language-specification/documentation-comments#d4-processing-the-documentation-file), with an optional `M:` prefix. + +For example, to specify that rule CA1806 should also check that the result from a method named `MyMethod1` is used, add the following key-value pair to an *.editorconfig* file in your project. + +```ini +dotnet_code_quality.CA1806.additional_use_results_methods = MyMethod1 +``` + +Or, use the fully qualified name to disambiguate or ensure that only a specific method with that name is included. + +```ini +dotnet_code_quality.CA1806.additional_use_results_methods = M:MyNamespace.MyType.MyMethod1(ParamType) +``` + ## Example 1 -The following example shows a class that ignores the result of calling String.Trim. +The following example shows a class that ignores the result of calling . :::code language="csharp" source="snippets/csharp/all-rules/ca1806.cs" id="snippet1"::: @@ -75,7 +98,7 @@ The following example shows a class that ignores the result of calling String.Tr ## Example 2 -The following example fixes the previous violation by assigning the result of String.Trim back to the variable it was called on. +The following example fixes the [Example 1](#example-1) violation by assigning the result of back to the variable it was called on. :::code language="csharp" source="snippets/csharp/all-rules/ca1806.cs" id="snippet2"::: @@ -92,13 +115,11 @@ The following example shows a method that does not use an object that it creates ## Example 4 -The following example fixes the previous violation by removing the unnecessary creation of an object. +The following example fixes the [Example 3](#example-3) violation by removing the unnecessary creation of an object. :::code language="csharp" source="snippets/csharp/all-rules/ca1806.cs" id="snippet4"::: diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1812.md b/docs/fundamentals/code-analysis/quality-rules/ca1812.md index 7a19f8d977b97..d51a96fb44d97 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1812.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1812.md @@ -62,7 +62,7 @@ It is safe to suppress a warning from this rule. We recommend that you suppress - The class is created automatically by the runtime or ASP.NET. Some examples of automatically created classes are those that implement or . -- The class is passed as a type parameter that has a [`new` constraint](../../../csharp/language-reference/keywords/new-constraint.md). The following example will be flagged by rule CA1812: +- The class is used as a type parameter in a class definition and has a [`new` constraint](../../../csharp/language-reference/keywords/new-constraint.md). The following example will be flagged by rule CA1812: ```csharp internal class MyClass diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1838.md b/docs/fundamentals/code-analysis/quality-rules/ca1838.md index cd5495a0dbe57..2e19870293947 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1838.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1838.md @@ -35,6 +35,8 @@ Marshalling of `StringBuilder` always creates a native buffer copy, resulting in By default, `StringBuilder` is `In` and `Out`. +For more information about marshalling strings, see [Default marshalling for strings](../../../framework/interop/default-marshalling-for-strings.md). + This rule is disabled by default, because it can require case-by-case analysis of whether the violation is of interest and potentially non-trivial refactoring to address the violation. Users can explicitly enable this rule by [configuring its severity](../configuration-options.md#severity-level). ## How to fix violations @@ -145,8 +147,9 @@ Suppress a violation of this rule if you're not concerned about the performance ## See also -- [Performance rules](performance-warnings.md) +- [Default marshalling for strings](../../../framework/interop/default-marshalling-for-strings.md) - [Native interoperability best practices](../../../standard/native-interop/best-practices.md) - - [stackalloc](../../../csharp/language-reference/operators/stackalloc.md) - [Charsets](../../../standard/native-interop/charset.md) +- [Performance rules](performance-warnings.md) diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1854.md b/docs/fundamentals/code-analysis/quality-rules/ca1854.md new file mode 100644 index 0000000000000..43856dca96902 --- /dev/null +++ b/docs/fundamentals/code-analysis/quality-rules/ca1854.md @@ -0,0 +1,89 @@ +--- +title: "CA1854: Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method" +description: "Learn about code analyzer rule CA1854 - Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method" +ms.date: 06/01/2022 +ms.topic: reference +f1_keywords: + - CA1854 +helpviewer_keywords: + - CA1854 +author: CollinAlpert +ms.author: gewarren +dev_langs: +- CSharp +- VB +--- + +# CA1854: Prefer the `IDictionary.TryGetValue(TKey, out TValue)` method + +| | Value | +|-|-| +| **Rule ID** |CA1854| +| **Category** |[Performance](performance-warnings.md)| +| **Fix is breaking or non-breaking** |Non-breaking| + +## Cause + +An `IDictionary` element access that's guarded by a `IDictionary.ContainsKey` check. + +## Rule description + +When an element of an `IDictionary` is accessed, the indexer implementation checks for a null value by calling the `IDictionary.ContainsKey` method. If you also call `IDictionary.ContainsKey` in an `if` clause to guard a value lookup, two lookups are performed when only one is needed. + +## How to fix violations + +Replace the `IDictionary.ContainsKey` invocation and element access with a call to the `IDictionary.TryGetValue` method. + +**Violation**: + +```csharp +public string? GetValue(string key) +{ + if (_dictionary.ContainsKey(key)) + { + return _dictionary[key]; + } + + return null; +} +``` + +```vb +Public Function GetValue(key As String) As String + If _dictionary.ContainsKey(key) Then + Return _dictionary(key) + End If + + Return Nothing +End Function +``` + +**Fix**: + +```csharp +public string? GetValue(string key) +{ + if (_dictionary.TryGetValue(key, out string? value)) + { + return value; + } + + return null; +} +``` + +```vb +Public Function GetValue(key As String) As String + Dim value as String + + If _dictionary.TryGetValue(key, value) Then + Return value + End If + + Return Nothing +End Function +``` + +## When to suppress warnings + +It's safe to suppress this warning if you're using a custom implementation of `IDictionary` that avoids a value lookup when performing the `IDictionary.ContainsKey` check. diff --git a/docs/fundamentals/code-analysis/quality-rules/ca2000.md b/docs/fundamentals/code-analysis/quality-rules/ca2000.md index 637e3b1ec1db0..002bd8377b485 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca2000.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca2000.md @@ -52,14 +52,14 @@ To fix a violation of this rule, call on th You can use the [`using` statement](../../../csharp/language-reference/keywords/using-statement.md) ([`Using`](../../../visual-basic/language-reference/statements/using-statement.md) in Visual Basic) to wrap objects that implement . Objects that are wrapped in this manner are automatically disposed at the end of the `using` block. However, the following situations should not or cannot be handled with a `using` statement: -- To return a disposable object, the object must constructed in a `try/finally` block outside of a `using` block. +- To return a disposable object, the object must be constructed in a `try/finally` block outside of a `using` block. - Do not initialize members of a disposable object in the constructor of a `using` statement. - When constructors that are protected by only one exception handler are nested in the [acquisition part of a `using` statement](../../../csharp/language-reference/keywords/using-statement.md), a failure in the outer constructor can result in the object created by the nested constructor never being closed. In the following example, a failure in the constructor can result in the object never being closed. CA2000 flags a violation of the rule in this case. ```csharp - using (StreamReader sr = new StreamReader(new FileStream("C:\myfile.txt", FileMode.Create))) + using (StreamReader sr = new StreamReader(new FileStream("C:/myfile.txt", FileMode.Create))) { ... } ``` diff --git a/docs/fundamentals/code-analysis/quality-rules/ca2255.md b/docs/fundamentals/code-analysis/quality-rules/ca2255.md index 87e2acaf1c821..2f0f182228253 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca2255.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca2255.md @@ -29,7 +29,7 @@ Module initializers are intended to be used by application code to ensure an app ## How to fix violations -Instead of using methods with the , a library should expose methods that can be used to initialize any components within the library, and allow the application to invoke the method during application initialization. +Instead of using methods marked with , the library should expose methods that can be used to initialize any components within the library and allow the application to invoke the method during application initialization. ## When to suppress warnings diff --git a/docs/fundamentals/code-analysis/quality-rules/index.md b/docs/fundamentals/code-analysis/quality-rules/index.md index 2796fadf41f6f..66611f3b3e521 100644 --- a/docs/fundamentals/code-analysis/quality-rules/index.md +++ b/docs/fundamentals/code-analysis/quality-rules/index.md @@ -145,6 +145,7 @@ The following table lists code quality analysis rules. > | [CA1849: Call async methods when in an async method](ca1849.md) | In a method which is already asynchronous, calls to other methods should be to their async versions, where they exist. | > | [CA1850: Prefer static `HashData` method over `ComputeHash`](ca1850.md) | It's more efficient to use the static `HashData` method over creating and managing a `HashAlgorithm` instance to call `ComputeHash`. | > | [CA1851: Possible multiple enumerations of `IEnumerable` collection](ca1851.md) | Possible multiple enumerations of `IEnumerable` collection. Consider using an implementation that avoids multiple enumerations. | +> | [CA1854: Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method](ca1854.md) | Prefer 'TryGetValue' over a Dictionary indexer access guarded by a 'ContainsKey' check. 'ContainsKey' and the indexer both look up the key, so using 'TryGetValue' avoids the extra lookup. | > | [CA2000: Dispose objects before losing scope](ca2000.md) | Because an exceptional event might occur that will prevent the finalizer of an object from running, the object should be explicitly disposed before all references to it are out of scope. | > |[CA2002: Do not lock on objects with weak identity](ca2002.md) |An object is said to have a weak identity when it can be directly accessed across application domain boundaries. A thread that tries to acquire a lock on an object that has a weak identity can be blocked by a second thread in a different application domain that has a lock on the same object. | > | [CA2007: Do not directly await a Task](ca2007.md) | An asynchronous method [awaits](../../../csharp/language-reference/operators/await.md) a directly. When an asynchronous method awaits a directly, continuation occurs in the same thread that created the task. This behavior can be costly in terms of performance and can result in a deadlock on the UI thread. Consider calling to signal your intention for continuation. | diff --git a/docs/fundamentals/code-analysis/quality-rules/performance-warnings.md b/docs/fundamentals/code-analysis/quality-rules/performance-warnings.md index a22ebdf442d5d..26f82bb1fa259 100644 --- a/docs/fundamentals/code-analysis/quality-rules/performance-warnings.md +++ b/docs/fundamentals/code-analysis/quality-rules/performance-warnings.md @@ -62,3 +62,4 @@ Performance rules support high-performance libraries and applications. | [CA1849: Call async methods when in an async method](ca1849.md) | In a method which is already asynchronous, calls to other methods should be to their async versions, where they exist. | | [CA1850: Prefer static `HashData` method over `ComputeHash`](ca1850.md) | It's more efficient to use the static `HashData` method over creating and managing a `HashAlgorithm` instance to call `ComputeHash`. | | [CA1851: Possible multiple enumerations of `IEnumerable` collection](ca1851.md) | Possible multiple enumerations of `IEnumerable` collection. Consider using an implementation that avoids multiple enumerations. | +| [CA1854: Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method](ca1854.md) | Prefer 'TryGetValue' over a Dictionary indexer access guarded by a 'ContainsKey' check. 'ContainsKey' and the indexer both look up the key, so using 'TryGetValue' avoids the extra lookup. | diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/.editorconfig b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/.editorconfig new file mode 100644 index 0000000000000..8b9bc7fe4a78a --- /dev/null +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/.editorconfig @@ -0,0 +1,11 @@ +# All files +[*] + +# CS0659: Type overrides Object.Equals(object o) but does not override Object.GetHashCode() +dotnet_diagnostic.CS0659.severity = suggestion + +# CS0108: Member hides inherited member; missing new keyword +dotnet_diagnostic.CS0108.severity = suggestion + +# CA1822: Mark members as static +dotnet_diagnostic.CA1822.severity = none diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj index 925fabcecb1a3..df344f18cf563 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj @@ -11,4 +11,8 @@ + + + + diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs index bb0e340b29b58..d4018a7e60e34 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs @@ -62,14 +62,8 @@ internal static class SafeNativeMethods // public static class Cursor { - // Callers do not require UnmanagedCode permission, however, - // they do require UIPermissionWindow.AllWindows. public static void Hide() { - // Need to demand an appropriate permission - // in place of UnmanagedCode permission as - // ShowCursor is not considered a safe method. - new UIPermission(UIPermissionWindow.AllWindows).Demand(); UnsafeNativeMethods.ShowCursor(false); } } diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs index ca6ee7f279f6c..ec498926ac995 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs @@ -1,4 +1,6 @@ -namespace ca1802 +using System; + +namespace ca1802 { // // This class violates the rule. @@ -7,6 +9,11 @@ public class UseReadOnly static readonly int x = 3; static readonly double y = x + 2.1; static readonly string s = "readonly"; + + public void Print() + { + Console.WriteLine(s); + } } // This class satisfies the rule. diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs index d61e6935daf47..13b7b0c9abd94 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Resources; namespace ca1810 @@ -16,6 +17,11 @@ static StaticConstructor() new ResourceManager("strings", Assembly.GetExecutingAssembly()); resourceString = stringManager.GetString("string"); } + + public void Print() + { + Console.WriteLine(someInteger); + } } public class NoStaticConstructor @@ -29,6 +35,11 @@ static string InitializeResourceString() new ResourceManager("strings", Assembly.GetExecutingAssembly()); return stringManager.GetString("string"); } + + public void Print() + { + Console.WriteLine(someInteger); + } } // } diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs index dee2689166e87..8d174b21a76f4 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs @@ -3,6 +3,7 @@ namespace ca2109 { +#pragma warning disable SYSLIB0003 // public class HandleEvents { @@ -21,4 +22,5 @@ public static void SomeActionHappened(Object sender, EventArgs e) } } // +#pragma warning restore SYSLIB0003 } diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs index 5a6fe593f20f5..a470dc7d89e70 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.Serialization; -using System.Security.Permissions; namespace ca2229 { @@ -26,8 +25,6 @@ protected SerializationConstructorsRequired( } // The following method serializes the instance. - [SecurityPermission(SecurityAction.LinkDemand, - Flags = SecurityPermissionFlag.SerializationFormatter)] void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs index c8c1db5854b18..790905851a3f9 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; -using System.Security.Permissions; namespace ca2237 { @@ -20,8 +19,6 @@ protected BaseType( baseValue = info.GetInt32("baseValue"); } - [SecurityPermissionAttribute(SecurityAction.Demand, - SerializationFormatter = true)] public virtual void GetObjectData( SerializationInfo info, StreamingContext context) { diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs index 20d549ac6295f..70480e0727350 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs @@ -5,7 +5,7 @@ namespace ca2242 // class NaNTests { - static double zero; + static double zero = 0; static void Main() { diff --git a/docs/fundamentals/code-analysis/style-rules/ide0063.md b/docs/fundamentals/code-analysis/style-rules/ide0063.md index ed932c957d983..da4da620a795f 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0063.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0063.md @@ -1,7 +1,7 @@ --- title: "IDE0063: Use simple 'using' statement" -description: "Learn about code analysis rule IDE0063: Use simple 'using' statement" -ms.date: 09/30/2020 +description: "Learn about code analysis rule IDE0063, which recommends a 'using' declaration instead of a 'using' statement" +ms.date: 03/18/2022 ms.topic: reference f1_keywords: - IDE0063 @@ -26,14 +26,14 @@ dev_langs: ## Overview -This style rule concerns the use of `using` statements without curly braces. This alternative syntax was introduced in C# 8.0. +This style rule concerns the use of `using` statements without curly braces, also known as `using` declarations. This [alternative syntax](~/_csharplang/proposals/csharp-8.0/using.md) was introduced in C# 8.0. ## csharp_prefer_simple_using_statement | Property | Value | |--------------------------|---------------------------------------------------------------------------------------------------------------------------| | **Option name** | csharp_prefer_simple_using_statement | -| **Option values** | `true` - Prefer to use a *simple* `using` statement

`false` - Don't prefer to use a *simple* `using` statement | +| **Option values** | `true` - Prefer to use a `using` declaration

`false` - Prefer to use a `using` statement with curly braces | | **Default option value** | `true` | ### Example diff --git a/docs/fundamentals/code-analysis/suppress-warnings.md b/docs/fundamentals/code-analysis/suppress-warnings.md index 214f9862756b4..3a10c5b893d0f 100644 --- a/docs/fundamentals/code-analysis/suppress-warnings.md +++ b/docs/fundamentals/code-analysis/suppress-warnings.md @@ -1,7 +1,7 @@ --- title: Suppress code analysis warnings description: Learn the different ways you can suppress .NET code analysis violations. -ms.date: 01/28/2021 +ms.date: 06/09/2022 ms-topic: how-to dev_langs: - CSharp @@ -12,7 +12,7 @@ helpviewer_keywords: --- # How to suppress code analysis warnings -This article covers the various ways you can suppress warnings from code analysis when you build your .NET app. +This article covers the various ways you can suppress warnings from code analysis when you build your .NET app. You can suppress code quality rules, code style rules, and third-party analyzer rules using the information provided here. > [!TIP] > If you're using Visual Studio as your development environment, the *light bulb* menu provides options that generate the code to suppress warnings for you. For more information, see [Suppress violations](/visualstudio/code-quality/use-roslyn-analyzers?#suppress-violations). diff --git a/docs/fundamentals/index.yml b/docs/fundamentals/index.yml index c35017a17ca93..eb917b289fb77 100644 --- a/docs/fundamentals/index.yml +++ b/docs/fundamentals/index.yml @@ -152,8 +152,8 @@ landingContent: url: ../core/extensions/workers.md - text: Caching in .NET url: ../core/extensions/caching.md - - text: HTTP with .NET - url: ../core/extensions/http-client.md + - text: HTTP in .NET + url: networking/httpclient-guidelines.md - text: Localization in .NET url: ../core/extensions/localization.md - text: File globbing in .NET diff --git a/docs/fundamentals/networking/httpclient-guidelines.md b/docs/fundamentals/networking/httpclient-guidelines.md new file mode 100644 index 0000000000000..ba9824b6bc3ff --- /dev/null +++ b/docs/fundamentals/networking/httpclient-guidelines.md @@ -0,0 +1,35 @@ +--- +title: HttpClient guidelines for .NET +description: Learn about using HttpClient instances to send HTTP requests and how you can manage clients using IHttpClientFactory in your .NET apps. +author: gewarren +ms.author: gewarren +ms.date: 05/19/2022 +--- +# Guidelines for using HttpClient + +The class sends HTTP requests and receives HTTP responses from a resource identified by a URI. An instance is a collection of settings that's applied to all requests executed by that instance, and each instance uses its own connection pool, which isolates its requests from others. Starting in .NET Core 2.1, the class provides the implementation, making behavior consistent across all platforms. + +If you're using .NET 5+ (including .NET Core), there are some considerations to keep in mind if you're using . + +## DNS behavior + + only resolves DNS entries when a connection is created. It does not track any time to live (TTL) durations specified by the DNS server. If DNS entries change regularly, which can happen in some container scenarios, the client won't respect those updates. To solve this issue, you can limit the lifetime of the connection by setting the property, so that DNS lookup is required when the connection is replaced. + +## Pooled connections + +In .NET Framework, disposing objects does not impact connection management. However, in .NET Core, the connection pool is linked to the client's underlying . When the instance is disposed, it disposes all previously used connections. If you later send a request to the same server, a new connection is created. There's also a performance penalty because it needs a new TCP port. If the rate of requests is high, or if there are any firewall limitations, that can **exhaust the available sockets** because of default TCP cleanup timers. + +## Recommended use + +- In .NET Framework, you can create a new each time you need to send a request. +- In .NET Core and .NET 5+: + - Use a static or singleton with set to a desired interval, such as two minutes, depending on expected DNS changes. This solves both the socket exhaustion and DNS changes problems without adding the overhead of . If you need to be able to mock your handler, you can register it separately. + - Using , you can have multiple, differently configured clients for different use cases. If its lifetime hasn't expired, an instance may be reused from the pool when the factory creates a new instance. This reuse avoids any socket exhaustion issues. If you desire the configurability that provides, we recommend using the [typed-client approach](../../core/extensions/http-client.md#typed-clients). However, be aware that the clients created by the factory are intended to be short-lived, and once the client is created, the factory no longer has control over it. + + > [!TIP] + > If your app requires cookies, consider disabling automatic cookie handling or avoiding . Pooling the instances results in sharing of objects. Unanticipated object sharing often results in incorrect code. + +## See also + +- [Make HTTP requests using IHttpClientFactory](/aspnet/core/fundamentals/http-requests) +- [Use IHttpClientFactory to implement resilient HTTP requests](../../architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests.md) diff --git a/docs/fundamentals/package-validation/diagnostic-ids.md b/docs/fundamentals/package-validation/diagnostic-ids.md index 5ff22e4d9fe48..65ca524bd659f 100644 --- a/docs/fundamentals/package-validation/diagnostic-ids.md +++ b/docs/fundamentals/package-validation/diagnostic-ids.md @@ -28,6 +28,8 @@ This reference article lists all the error codes generated by package validation | CP0007 | A base type on the class hierarchy was removed from one of the compared sides. | Add the base type back (a new base type can be introduced in the hierarchy if that's intended).| | CP0008 | A base interface was removed from the interface hierarchy from one of the compared sides. | Add the interface back to the hierarchy. | | CP0009 | A type that was unsealed on one side was annotated as sealed on the other compared side. | Remove the sealed annotation from the type. | +| CP0010 | The underlying type of an enum changed from one side to the other. | Change the underlying type back to what it was previously. | +| CP0011 | The value of a member in an enum changed from one side to the other. | Change the value of the member back to what it was previously. | | CP1001 | A matching assembly could not be found in the search directories. (Not applicable for Package Validation, only when using API Compat directly.) | Provide the search directory when loading matching assemblies using the `AssemblySymbolLoader`. | | CP1002 | A reference assembly was not found when loading the assemblies to compare in the resolved directories for the current target framework. | Include the directory path where that assembly can be found using the following MSBuild item: ``. | | CP1003 | There was no search directory provided for the target framework moniker that the package validation is running API Compat for. | Provide the search directory to find references for that target framework using the following MSBuild item: ``. diff --git a/docs/fundamentals/syslib-diagnostics/syslib0006.md b/docs/fundamentals/syslib-diagnostics/syslib0006.md index e696e7bceac84..33686a898b3a1 100644 --- a/docs/fundamentals/syslib-diagnostics/syslib0006.md +++ b/docs/fundamentals/syslib-diagnostics/syslib0006.md @@ -10,6 +10,8 @@ The following APIs are marked obsolete, starting in .NET 5. Use of these APIs ge - - +When you call to abort a thread other than the current thread, you don't know what code has executed or failed to execute when the is thrown. You also cannot be certain of the state of your application or any application and user state that it's responsible for preserving. For example, calling may prevent the execution of static constructors or the release of managed or unmanaged resources. For this reason, always throws a on .NET Core and .NET 5+. + ## Workarounds Use a to abort processing of a unit of work instead of calling . The following example illustrates the use of . diff --git a/docs/fundamentals/syslib-diagnostics/syslib1001.md b/docs/fundamentals/syslib-diagnostics/syslib1001.md index adae9932b3fd9..0558e74361e4a 100644 --- a/docs/fundamentals/syslib-diagnostics/syslib1001.md +++ b/docs/fundamentals/syslib-diagnostics/syslib1001.md @@ -6,7 +6,7 @@ ms.date: 05/07/2021 # SYSLIB1001: Logging method names can't start with an underscore -The name a of method annotated with the `LoggerMessageAttribute` starts with an underscore character. This is not allowed, as it may result in conflicting symbol names with respect to the automatically generated code. +The name of a method annotated with the `LoggerMessageAttribute` starts with an underscore character. This is not allowed, as it may result in conflicting symbol names with respect to the automatically generated code. ## Workarounds diff --git a/docs/fundamentals/syslib-diagnostics/syslib1003.md b/docs/fundamentals/syslib-diagnostics/syslib1003.md index 971f3c6ffc9ec..7f49c633f9097 100644 --- a/docs/fundamentals/syslib-diagnostics/syslib1003.md +++ b/docs/fundamentals/syslib-diagnostics/syslib1003.md @@ -6,7 +6,7 @@ ms.date: 05/07/2021 # SYSLIB1003: Logging method parameter names can't start with an underscore -The name a of parameter of a method annotated with the `LoggerMessageAttribute` starts with an underscore character. This is not allowed as it may result in conflicting symbol names with respect to the automatically generated code. +The name of a parameter of a method annotated with the `LoggerMessageAttribute` starts with an underscore character. This is not allowed as it may result in conflicting symbol names with respect to the automatically generated code. ## Workarounds diff --git a/docs/fundamentals/toc.yml b/docs/fundamentals/toc.yml index df2154f1ab3df..3bc03b6b62fd7 100644 --- a/docs/fundamentals/toc.yml +++ b/docs/fundamentals/toc.yml @@ -350,6 +350,9 @@ items: href: ../core/tools/dotnet-tool-update.md - name: dotnet vstest href: ../core/tools/dotnet-vstest.md + - name: dotnet watch + displayName: hot reload + href: ../core/tools/dotnet-watch.md - name: dotnet workload items: - name: dotnet workload install @@ -621,6 +624,8 @@ items: href: ../core/diagnostics/index.md - name: Managed debuggers href: ../core/diagnostics/managed-debuggers.md + - name: Diagnostic port + href: ../core/diagnostics/diagnostic-port.md - name: Dumps items: - name: Overview @@ -630,8 +635,6 @@ items: href: ../core/diagnostics/debug-linux-dumps.md - name: SOS debugger extension href: ../core/diagnostics/sos-debugging-extension.md - - name: EventPipe - href: ../core/diagnostics/eventpipe.md - name: Logging and tracing items: - name: Overview @@ -639,16 +642,6 @@ items: href: ../core/diagnostics/logging-tracing.md - name: Well-known event providers href: ../core/diagnostics/well-known-event-providers.md - - name: Distributed tracing - items: - - name: Overview - href: ../core/diagnostics/distributed-tracing.md - - name: Concepts - href: ../core/diagnostics/distributed-tracing-concepts.md - - name: Instrumentation - href: ../core/diagnostics/distributed-tracing-instrumentation-walkthroughs.md - - name: Collection - href: ../core/diagnostics/distributed-tracing-collection-walkthroughs.md - name: Event Source items: - name: Overview @@ -661,6 +654,12 @@ items: href: ../core/diagnostics/eventsource-collect-and-view-traces.md - name: Activity IDs href: ../core/diagnostics/eventsource-activity-ids.md + - name: DiagnosticSource and DiagnosticListener + items: + - name: Getting started + href: ../core/diagnostics/diagnosticsource-diagnosticlistener.md + - name: EventPipe + href: ../core/diagnostics/eventpipe.md - name: Metrics items: - name: Overview @@ -681,6 +680,16 @@ items: href: ../core/diagnostics/event-counter-perf.md - name: Compare metric APIs href: ../core/diagnostics/compare-metric-apis.md + - name: Distributed tracing + items: + - name: Overview + href: ../core/diagnostics/distributed-tracing.md + - name: Concepts + href: ../core/diagnostics/distributed-tracing-concepts.md + - name: Instrumentation + href: ../core/diagnostics/distributed-tracing-instrumentation-walkthroughs.md + - name: Collection + href: ../core/diagnostics/distributed-tracing-collection-walkthroughs.md - name: Symbols href: ../core/diagnostics/symbols.md - name: Microsoft.Diagnostics.NETCore.Client library @@ -742,6 +751,8 @@ items: href: ../core/diagnostics/debug-highcpu.md - name: Debug deadlock href: ../core/diagnostics/debug-deadlock.md + - name: Debug ThreadPool starvation + href: ../core/diagnostics/debug-threadpool-starvation.md - name: Debug a StackOverflow href: ../core/diagnostics/debug-stackoverflow.md - name: Code analysis @@ -1064,6 +1075,8 @@ items: href: code-analysis/quality-rules/ca1850.md - name: CA1851 href: code-analysis/quality-rules/ca1851.md + - name: CA1854 + href: code-analysis/quality-rules/ca1854.md - name: SingleFile rules items: - name: Overview @@ -1664,6 +1677,7 @@ items: - name: Configure .NET Runtime items: - name: Settings + displayName: runtime configuration, configure runtime, configuration settings href: ../core/runtime-config/index.md - name: Compilation settings href: ../core/runtime-config/compilation.md @@ -2488,10 +2502,15 @@ items: href: ../core/extensions/console-log-formatter.md - name: HostBuilder (generic host) href: ../core/extensions/generic-host.md - - name: HTTP with .NET - href: ../core/extensions/http-client.md - - name: HTTP/3 with .NET - href: ../core/extensions/httpclient-http3.md + - name: Networking + items: + - name: HTTP clients in .NET + displayName: networking, httpclient + href: networking/httpclient-guidelines.md + - name: IHttpClientFactory + href: ../core/extensions/http-client.md + - name: HTTP/3 with .NET + href: ../core/extensions/httpclient-http3.md - name: File globbing in .NET href: ../core/extensions/file-globbing.md - name: Primitives library in .NET @@ -2820,17 +2839,19 @@ items: - name: P/Invoke href: ../standard/native-interop/pinvoke.md - name: Type marshalling - href: /dotnet/standard/native-interop/type-marshalling + href: ../standard/native-interop/type-marshalling.md - name: Customize structure marshalling - href: /dotnet/standard/native-interop/customize-struct-marshalling + href: ../standard/native-interop/customize-struct-marshalling.md - name: Customize parameter marshalling - href: /dotnet/standard/native-interop/customize-parameter-marshalling - - name: Cross platform P/Invoke + href: ../standard/native-interop/customize-parameter-marshalling.md + - name: Cross-platform P/Invoke href: ../standard/native-interop/cross-platform.md - name: Interop guidance href: ../standard/native-interop/best-practices.md - name: Charsets and marshalling href: ../standard/native-interop/charset.md + - name: Disabled marshalling + href: ../standard/native-interop/disabled-marshalling.md - name: Expose .NET components to COM href: ../core/native-interop/expose-components-to-com.md - name: Host .NET from native code @@ -2986,6 +3007,8 @@ items: href: ../core/porting/upgrade-assistant-wpf-framework.md - name: Windows Forms href: ../core/porting/upgrade-assistant-winforms-framework.md + - name: Universal Windows Platform + href: ../core/porting/upgrade-assistant-uwp-framework.md - name: ASP.NET Core href: ../core/porting/upgrade-assistant-aspnetmvc.md - name: Telemetry diff --git a/docs/index.yml b/docs/index.yml index 33d52f0b36656..b74461bf9bd10 100644 --- a/docs/index.yml +++ b/docs/index.yml @@ -209,6 +209,8 @@ additionalContent: # Card - title: Mobile links: + - url: /dotnet/maui + text: .NET Multi-platform App UI (.NET MAUI) - url: /xamarin/xamarin-forms text: Xamarin.Forms - url: /xamarin/ios @@ -230,8 +232,10 @@ additionalContent: text: Windows Forms (.NET 5+) - url: /dotnet/desktop/winforms/?view=netframeworkdesktop-4.8&preserve-view=true text: Windows Forms (.NET Framework) + - url: /dotnet/maui + text: .NET Multi-platform App UI (.NET MAUI) - url: /xamarin/mac - text: Xamarin for macOS + text: Xamarin for macOS # Card - title: Microservices links: diff --git a/docs/orleans/deployment/azure-web-apps-with-azure-cloud-services.md b/docs/orleans/deployment/azure-web-apps-with-azure-cloud-services.md deleted file mode 100644 index 47a9787d92ff4..0000000000000 --- a/docs/orleans/deployment/azure-web-apps-with-azure-cloud-services.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: Use Azure Web Apps with Azure Cloud Services -description: Learn how to use Azure Web Apps with Azure Cloud Services in .NET Orleans. -ms.date: 03/09/2022 ---- - -# Use Azure Web Apps with Azure Cloud Services - -If you would like to connect to an Azure Cloud Services silo from an [Azure Web App](/azure/app-service/overview) rather than a Web Role hosted within the same cloud service you can. - -For this to work securely you will need to assign both the Azure Web App and the Worker Role hosting the Silo to an [Azure Virtual Network](/azure/virtual-network). - -First we'll setup the Azure Web App, you can follow [this guide](https://azure.microsoft.com/blog/azure-websites-virtual-network-integration) which will create the virtual network and assign it to the Azure Web App. - -Now we can assign the cloud service to the virtual network by modifying the `ServiceConfiguration` file. - -```xml - - - - - - - - - - -``` - -Also make sure the Silo endpoints are configured. - -```xml - - - - -``` - -You can now connect from the Web App to the rest of the cluster. - -### Potential issues - -If the Web App is having difficulty connecting to the Silo: - -* Make sure you have at least **two roles**, or two instances of one role in your Azure Cloud Service, or the `InternalEndpoint` firewall rules may not be generated. -* Check that both the Web App and the Silo are using the same `ClusterId` and `ServiceId`. -* Make sure the network security group is set up to allow internal virtual network connections. If you haven't got one you can create and assign one easily using the following PowerShell: - -```azurepowershell -New-AzureNetworkSecurityGroup -Name "Default" -Location "North Europe" -Get-AzureNetworkSecurityGroup -Name "Default" | Set-AzureNetworkSecurityGroupToSubnet -VirtualNetworkName "virtual-network-name" -SubnetName "subnet-name" -``` diff --git a/docs/orleans/deployment/consul-deployment.md b/docs/orleans/deployment/consul-deployment.md index c46a837d962e6..3c0084465d764 100644 --- a/docs/orleans/deployment/consul-deployment.md +++ b/docs/orleans/deployment/consul-deployment.md @@ -10,7 +10,7 @@ ms.date: 03/09/2022 There is a very detailed overview of Consul including comparisons with similar solutions [here](https://www.consul.io/intro/index.html). -Consul is written in GO and is [open source](https://github.com/hashicorp/consul); compiled downloads are available for [Mac OS X, FreeBSD, Linux, Solaris and Windows](https://www.consul.io/downloads.html) +Consul is written in Go and is [open source](https://github.com/hashicorp/consul); compiled downloads are available for [Mac OS X, FreeBSD, Linux, Solaris and Windows](https://www.consul.io/downloads.html) ## Why choose Consul? @@ -18,7 +18,7 @@ As an [Orleans Membership Provider](../implementation/cluster-management.md), Co ## Set up Consul -There is very extensive documentation available on [Consul.io](https://www.consul.io) about setting up a stable Consul cluster and it doesn't make sense to repeat that here; however, for your convenience, we include this guide so you can very quickly get Orleans running with a standalone Consul agent. +There's extensive documentation available on [Consul.io](https://www.consul.io) about setting up a stable Consul cluster, and it doesn't make sense to repeat that here. However, for your convenience, we include this guide so you can quickly get Orleans running with a standalone Consul agent. 1. Create a folder to install Consul into, (for example _C:\Consul_). 1. Create a subfolder: _C:\Consul\Data_ (Consul will not create this if it doesn't exist). @@ -43,7 +43,7 @@ There is very extensive documentation available on [Consul.io](https://www.consu ## Configure Orleans -There is currently a known issue with the "Custom" membership provider _OrleansConfiguration.xml_ configuration file that will fail to parse correctly. For this reason, you have to provide a placeholder SystemStore in the XML and then configure the provider in code before starting the silo. +There is a known issue with the "Custom" membership provider _OrleansConfiguration.xml_ configuration file that will fail to parse correctly. For this reason, you have to provide a placeholder SystemStore in the XML and then configure the provider in code before starting the silo. **OrleansConfiguration.xml** @@ -101,11 +101,11 @@ Alternatively, you could configure the silo entirely in code. The client configu ## Client SDK -If you are interested in using Consul for your service discovery there are [Client SDKs](https://www.consul.io/downloads_tools.html) for most popular languages. +If you are interested in using Consul for your service discovery, there are [Client SDKs](https://www.consul.io/downloads_tools.html) for most popular languages. ## Implementation detail -The Membership Table Provider makes use of [Consul's Key/Value store](https://www.consul.io/intro/getting-started/kv.html) functionality with CAS. When each Silo starts it registers two KV entries, one which contains the Silo details and one which holds the last time the Silo reported it was alive (the latter refers to diagnostics "I am alive" entries and not to failure detection heartbeats which are sent directly between the silos and are not written into the table). All writes to the table are performed with CAS to provide concurrency control, as necessitated by Orleans's [Cluster Management Protocol](../implementation/cluster-management.md). +The Membership Table Provider makes use of [Consul's Key/Value store](https://www.consul.io/intro/getting-started/kv.html) functionality with Check-And-Set (CAS) operations. When each Silo starts, it registers two KV entries, one that contains the Silo details and one that holds the last time the Silo reported it was alive (the latter refers to diagnostics "I am alive" entries and not to failure detection heartbeats, which are sent directly between the silos and are not written into the table). All writes to the table are performed with CAS to provide concurrency control, as necessitated by Orleans's [Cluster Management Protocol](../implementation/cluster-management.md). Once the Silo is running, you can view these entries in your web browser at `http://localhost:8500/v1/kv/?keys`, which will display something like: diff --git a/docs/orleans/deployment/deploy-to-azure-app-service.md b/docs/orleans/deployment/deploy-to-azure-app-service.md new file mode 100644 index 0000000000000..62fd14c459f1b --- /dev/null +++ b/docs/orleans/deployment/deploy-to-azure-app-service.md @@ -0,0 +1,481 @@ +--- +title: Deploy Orleans to Azure App Service +description: Learn how to deploy an Orleans shopping cart app to Azure App Service. +ms.date: 05/02/2022 +ms.topic: tutorial +--- + +# Deploy Orleans to Azure App Service + +In this tutorial, you learn how to deploy an Orleans shopping cart app to Azure App Service. The tutorial walks you through a sample application that supports the following features: + +- **Shopping cart**: A simple shopping cart application that uses Orleans for its cross-platform framework support, and its scalable distributed applications capabilities. + + - **Inventory management**: Edit and/or create product inventory. + - **Shop inventory**: Explore purchasable products and add them to your cart. + - **Cart**: View a summary of all the items in your cart, and manage these items; either removing or changing the quantity of each item. + +With an understanding of the app and its features, you will then learn how to deploy the app to Azure App Service using GitHub Actions, the .NET and Azure CLIs, and Azure Bicep. Additionally, you'll learn how to configure the virtual network for the app within Azure. + +In this tutorial, you learn how to: + +> [!div class="checklist"] +> +> - Deploy an Orleans application to Azure App Service +> - Automate deployment using GitHub Actions and Azure Bicep +> - Configure the virtual network for the app within Azure + +## Prerequisites + +- A [GitHub account](https://github.com/join) +- [Read an introduction to Orleans](../overview.md) +- The [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet) +- The [Azure CLI](/cli/azure/install-azure-cli) +- A .NET integrated development environment (IDE) + - Feel free to use [Visual Studio 2022](https://visualstudio.microsoft.com) or [Visual Studio Code](https://code.visualstudio.com) + +## Run the app locally + +To run the app locally, fork the [Azure Samples: Orleans Cluster on Azure App Service](https://github.com/Azure-Samples/Orleans-Cluster-on-Azure-App-Service) repository and clone it to your local machine. Once cloned, open the solution in an IDE of your choice. If you're using Visual Studio, right-click the **Orleans.ShoppingCart.Silo** project and select **Set As Startup Project**, then run the app. Otherwise you can run the app using the following .NET CLI command: + +```dotnetcli +dotnet run --project Silo\Orleans.ShoppingCart.Silo.csproj +``` + +For more information, see [dotnet run](../../core/tools/dotnet-run.md). With the app running, you can navigate around and you're free to test out its capabilities. All of the app's functionality when running locally relies on in-memory persistence, local clustering, and it uses the [Bogus NuGet](https://www.nuget.org/packages/Bogus) package to generate fake products. Stop the app either by selecting the **Stop Debugging** option in Visual Studio or by pressing Ctrl+C in the .NET CLI. + +## Inside the shopping cart app + +Orleans is a reliable and scalable framework for building distributed applications. For this tutorial, you will deploy a simple shopping cart app built using Orleans to Azure App Service. The app exposes the ability to manage inventory, add and remove items in a cart, and shop available products. The client is built using Blazor with a server hosting model. The app is architected as follows: + +:::image type="content" source="media/shopping-cart-app-arch.png" lightbox="media/shopping-cart-app-arch.png" alt-text="Orleans: Shopping Cart sample app architecture."::: + +The preceding diagram shows that the client is the server-side Blazor app. It's composed of several services that consume a corresponding Orleans grain. Each service pairs with an Orleans grain as follows: + +- `InventoryService`: Consumes the `IInventoryGrain` where inventory is partitioned by product category. +- `ProductService`: Consumes the `IProductGrain` where a single product is tethered to a single grain instance by `Id`. +- `ShoppingCartService`: Consumes the `IShoppingCartGrain` where a single user only has a single shopping cart instance regardless of consuming clients. + +The solution contains three projects: + +- `Orleans.ShoppingCart.Abstractions`: A class library that defines the models and the interfaces for the app. +- `Orleans.ShoppingCart.Grains`: A class library that defines the grains that implement the app's business logic. +- `Orleans.ShoppingCart.Silos`: A server-side Blazor app that hosts the Orleans silo. + +### The client user experience + +The shopping cart client app has several pages, each of which represents a different user experience. The app's UI is built using the [MudBlazor NuGet](https://www.nuget.org/packages/MudBlazor) package. + +**Home page** + +A few simple phrases for the user to understand the app's purpose, and add context to each navigation menu item. + +:::image type="content" source="media/home-page.png" lightbox="media/home-page.png" alt-text="Orleans: Shopping Cart sample app, home page."::: + +**Shop inventory page** + +A page that displays all of the products that are available for purchase. Items can be added to the cart from this page. + +:::image type="content" source="media/shop-inventory-page.png" lightbox="media/shop-inventory-page.png" alt-text="Orleans: Shopping Cart sample app, shop inventory page."::: + +**Empty cart page** + +When you haven't added anything to your cart, the page renders a message that indicates that you have no items in your cart. + +:::image type="content" source="media/empty-shopping-cart-page.png" lightbox="media/empty-shopping-cart-page.png" alt-text="Orleans: Shopping Cart sample app, empty cart page."::: + +**Items added to cart while on the shop inventory page** + +When items are added to your cart while on the shop inventory page, the app displays a message that indicates the item was added to the cart. + +:::image type="content" source="media/shop-inventory-items-added-page.png" lightbox="media/shop-inventory-items-added-page.png" alt-text="Orleans: Shopping Cart sample app, items added to cart while on shop inventory page."::: + +**Product management page** + +A user can manage inventory from this page. Products can be added, edited, and removed from the inventory. + +:::image type="content" source="media/product-management-page.png" lightbox="media/product-management-page.png" alt-text="Orleans: Shopping Cart sample app, product management page."::: + +**Product management page create new dialog** + +When a user clicks the **Create new product** button, the app displays a dialog that allows the user to create a new product. + +:::image type="content" source="media/product-management-page-new.png" lightbox="media/product-management-page-new.png" alt-text="Orleans: Shopping Cart sample app, product management page - create new product dialog."::: + +**Items in cart page** + +When items are in your cart, you can view them and change their quantity, and even remove them from the cart. The user is shown a summary of the items in the cart and the pretax total cost. + +:::image type="content" source="media/items-in-shopping-cart-page.png" lightbox="media/items-in-shopping-cart-page.png" alt-text="Orleans: Shopping Cart sample app, items in cart page."::: + +> [!IMPORTANT] +> When this app runs locally, in a development environment, the app will use localhost clustering, in-memory storage, and a local silo. It also seeds the inventory with fake data that is automatically generated using the [Bogus NuGet](https://www.nuget.org/packages/bogus) package. This is all intentional to demonstrate the functionality. + +## Deploy to Azure App Service + +A typical Orleans application consists of a cluster of server processes (silos) where grains live, and a set of client processes, usually web servers, that receive external requests, turn them into grain method calls and return results. Hence, the first thing one needs to do to run an Orleans application is to start a cluster of silos. For testing purposes, a cluster can consist of a single silo. + +> [!NOTE] +> For a reliable production deployment, you'd want more than one silo in a cluster for fault tolerance and scale. + +Before deploying the app to Azure App Service, you need to create an Azure Resource Group (or you could choose to use an existing one). To create a new Azure Resource Group, use one of the following articles: + +- [Azure Portal](/azure/azure-resource-manager/management/manage-resource-groups-portal#create-resource-groups) +- [Azure CLI](/azure/azure-resource-manager/management/manage-resource-groups-cli#create-resource-groups) +- [Azure PowerShell](/azure/azure-resource-manager/management/manage-resource-groups-powershell#create-resource-groups) + +Make note of the resource group name you choose, you'll need it later to deploy the app. + +### Create a service principal + +To automate the deployment of the app, you'll need to create a service principal. This is a Microsoft account that has permissions to manage Azure resources on your behalf. + +```azurecli +az ad sp create-for-rbac --sdk-auth --role Contributor \ + --name "" --scopes /subscriptions/ +``` + +The JSON credentials created will look similar to the following, but with actual values for your client, subscription, and tenant: + +```json +{ + "clientId": "", + "clientSecret": "", + "subscriptionId": "", + "tenantId": "", + "activeDirectoryEndpointUrl": "https://login.microsoftonline.com/", + "resourceManagerEndpointUrl": "https://brazilus.management.azure.com", + "activeDirectoryGraphResourceId": "https://graph.windows.net/", + "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/", + "galleryEndpointUrl": "https://gallery.azure.com", + "managementEndpointUrl": "https://management.core.windows.net" +} +``` + +Copy the output of the command into your clipboard, and continue to the next step. + +### Create a GitHub secret + +GitHub provides a mechanism for creating encrypted secrets. The secrets that you create are available to use in GitHub Actions workflows. You're going to see how a GitHub Actions can be used to automate the deployment of the app, in conjunction with Azure Bicep. Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. For more information, see [What is Bicep](/azure/azure-resource-manager/bicep/overview?tabs=bicep). Using the output from the [Create a service principal](#create-a-service-principal) step, you'll need to create a GitHub secret named `AZURE_CREDENTIALS` with the JSON-formatted credentials. + +Within the GitHub repository, select **Settings** > **Secrets** > **Create a new secret**. Enter the name `AZURE_CREDENTIALS` and paste the JSON credentials from the previous step into the **Value** field. + +:::image type="content" source="media/github-secret.png" alt-text="GitHub Repository: Settings > Secrets" lightbox="media/github-secret.png"::: + +For more information, see [GitHub: Encrypted Secrets](https://docs.github.com/actions/security-guides/encrypted-secrets). + +### Prepare for Azure deployment + +The app will need to be packaged for deployment. In the `Orleans.ShoppingCart.Silos` project, we define a `Target` element that runs after the `Publish` step. This will zip the publish directory into a _silo.zip_ file: + +```xml + + + + +``` + +There are many ways to deploy a .NET app to Azure App Service. In this tutorial, you use GitHub Actions, Azure Bicep, and the .NET and Azure CLIs. Consider the _./github/workflows/deploy.yml_ file in the root of the GitHub repository: + +```yml +name: Deploy to Azure App Service + +on: + push: + branches: + - main + +env: + UNIQUE_APP_NAME: cartify + AZURE_RESOURCE_GROUP_NAME: orleans-resourcegroup + AZURE_RESOURCE_GROUP_LOCATION: centralus + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + + - name: .NET publish shopping cart app + run: dotnet publish ./Silo/Orleans.ShoppingCart.Silo.csproj --configuration Release + + - name: Login to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Flex bicep + run: | + az deployment group create \ + --resource-group ${{ env.AZURE_RESOURCE_GROUP_NAME }} \ + --template-file '.github/workflows/flex/main.bicep' \ + --parameters location=${{ env.AZURE_RESOURCE_GROUP_LOCATION }} \ + appName=${{ env.UNIQUE_APP_NAME }} \ + --debug + + - name: Webapp deploy + run: | + az webapp deploy --name ${{ env.UNIQUE_APP_NAME }} \ + --resource-group ${{ env.AZURE_RESOURCE_GROUP_NAME }} \ + --clean true --restart true \ + --type zip --src-path silo.zip --debug +``` + +The preceding GitHub workflow will: + +- Publish the shopping cart app as a zip file, using the [dotnet publish](../../core/tools/dotnet-publish.md) command. +- Login to Azure using the credentials from the [Create a service principal](#create-a-service-principal) step. +- Evaluate the _main.bicep_ file and start a deployment group using [az deployment group create](/cli/azure/deployment/group#az-deployment-group-create). +- Deploy the _silo.zip_ file to Azure App Service using [az webapp deploy](/cli/azure/webapp#az-webapp-deploy). + +The workflow is triggered by a push to the _main_ branch. For more information, see [GitHub Actions and .NET](../../devops/github-actions-overview.md). + +> [!TIP] +> If you encounter issues when running the workflow, you might need to verify that the service principal has all the required provider namespaces registered. The following provider namespaces are required: +> +> - `Microsoft.Web` +> - `Microsoft.Network` +> - `Microsoft.OperationalInsights` +> - `Microsoft.Insights` +> - `Microsoft.Storage` +> +> For more information, see [Resolve errors for resource provider registration](/azure/azure-resource-manager/troubleshooting/error-register-resource-provider?tabs=azure-cli). + +Azure imposes naming restrictions and conventions for resources. You need to update the _deploy.yml_ file values for the following: + +- `UNIQUE_APP_NAME` +- `AZURE_RESOURCE_GROUP_NAME` +- `AZURE_RESOURCE_GROUP_LOCATION` + +Set these values to your unique app name and your Azure resource group name and location. + +For more information, see [Naming rules and restrictions for Azure resources](/azure/azure-resource-manager/management/resource-name-rules). + +## Explore the Bicep templates + +When the `az deployment group create` command is run, it will evaluate the _main.bicep_ file. This file contains the Azure resources that you want to deploy. One way to think of this step is that it _provisions_ all of the resources for deployment. + +> [!IMPORTANT] +> If you're using Visual Studio Code, the bicep authoring experience is improved when using the [Bicep Extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep). + +There are many bicep files, each containing either resources or modules (collections of resources). The _main.bicep_ file is the entry point and is comprised primarily of `module` definitions: + +```bicep +param appName string +param location string = resourceGroup().location + +module storageModule 'storage.bicep' = { + name: 'orleansStorageModule' + params: { + name: '${appName}storage' + location: location + } +} + +module logsModule 'logs-and-insights.bicep' = { + name: 'orleansLogModule' + params: { + operationalInsightsName: '${appName}-logs' + appInsightsName: '${appName}-insights' + location: location + } +} + +resource vnet 'Microsoft.Network/virtualNetworks@2021-05-01' = { + name: '${appName}-vnet' + location: location + properties: { + addressSpace: { + addressPrefixes: [ + '172.17.0.0/16' + ] + } + subnets: [ + { + name: 'default' + properties: { + addressPrefix: '172.17.0.0/24' + delegations: [ + { + name: 'delegation' + properties: { + serviceName: 'Microsoft.Web/serverFarms' + } + } + ] + } + } + ] + } +} + +module siloModule 'app-service.bicep' = { + name: 'orleansSiloModule' + params: { + appName: appName + location: location + vnetSubnetId: vnet.properties.subnets[0].id + appInsightsConnectionString: logsModule.outputs.appInsightsConnectionString + appInsightsInstrumentationKey: logsModule.outputs.appInsightsInstrumentationKey + storageConnectionString: storageModule.outputs.connectionString + } +} +``` + +The preceding bicep file defines the following: + +- Two parameters for the resource group name and the app name. +- The `storageModule` definition, which defines the storage account. +- The `logsModule` definition, which defines the Azure Log Analytics and Application Insights resources. +- The `vnet` resource, which defines the virtual network. +- The `siloModule` definition, which defines the Azure App Service. + +One very important `resource` is that of the Virtual Network. The `vnet` resource enables the Azure App Service to communicate with the Orleans cluster. + +Whenever a `module` is encountered in the bicep file, it is evaluated via another bicep file that contains the resource definitions. The first encountered module was the `storageModule`, which is defined in the _storage.bicep_ file: + +```bicep +param name string +param location string + +resource storage 'Microsoft.Storage/storageAccounts@2021-08-01' = { + name: name + location: location + kind: 'StorageV2' + sku: { + name: 'Standard_LRS' + } +} + +var key = listKeys(storage.name, storage.apiVersion).keys[0].value +var protocol = 'DefaultEndpointsProtocol=https' +var accountBits = 'AccountName=${storage.name};AccountKey=${key}' +var endpointSuffix = 'EndpointSuffix=${environment().suffixes.storage}' + +output connectionString string = '${protocol};${accountBits};${endpointSuffix}' +``` + +Bicep files accept parameters, which are declared using the `param` keyword. Likewise, they can also declare outputs using the `output` keyword. The storage `resource` relies on the `Microsoft.Storage/storageAccounts@2021-08-01` type and version. It will be provisioned in the resource group's location, as a `StorageV2` and `Standard_LRS` SKU. The storage bicep defines its connection string as an `output`. This `connectionString` is later used by the silo bicep to connect to the storage account. + +Next, the _logs-and-analytics.bicep_ file defines the Azure Log Analytics and Application Insights resources: + +```bicep +param operationalInsightsName string +param appInsightsName string +param location string + +resource appInsights 'Microsoft.Insights/components@2020-02-02' = { + name: appInsightsName + location: location + kind: 'web' + properties: { + Application_Type: 'web' + WorkspaceResourceId: logs.id + } +} + +resource logs 'Microsoft.OperationalInsights/workspaces@2021-06-01' = { + name: operationalInsightsName + location: location + properties: { + retentionInDays: 30 + features: { + searchVersion: 1 + } + sku: { + name: 'PerGB2018' + } + } +} + +output appInsightsInstrumentationKey string = appInsights.properties.InstrumentationKey +output appInsightsConnectionString string = appInsights.properties.ConnectionString +``` + +This bicep file defines the Azure Log Analytics and Application Insights resources. The `appInsights` resource is a `web` type, and the `logs` resource is a `PerGB2018` type. Both the `appInsights` resource and the `logs` resource are provisioned in the resource group's location. The `appInsights` resource is linked to the `logs` resource via the `WorkspaceResourceId` property. There are two outputs defined in this bicep, used later by the App Service `module`. + +Finally, the _app-service.bicep_ file defines the Azure App Service resource: + +```bicep +param appName string +param location string +param vnetSubnetId string +param appInsightsInstrumentationKey string +param appInsightsConnectionString string +param storageConnectionString string + +resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = { + name: '${appName}-plan' + location: location + kind: 'app' + sku: { + name: 'S1' + capacity: 1 + } +} + +resource appService 'Microsoft.Web/sites@2021-03-01' = { + name: appName + location: location + kind: 'app' + properties: { + serverFarmId: appServicePlan.id + virtualNetworkSubnetId: vnetSubnetId + httpsOnly: true + siteConfig: { + vnetPrivatePortsCount: 2 + webSocketsEnabled: true + netFrameworkVersion: 'v6.0' + appSettings: [ + { + name: 'APPINSIGHTS_INSTRUMENTATIONKEY' + value: appInsightsInstrumentationKey + } + { + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' + value: appInsightsConnectionString + } + { + name: 'ORLEANS_AZURE_STORAGE_CONNECTION_STRING' + value: storageConnectionString + } + ] + alwaysOn: true + } + } +} + +resource appServiceConfig 'Microsoft.Web/sites/config@2021-03-01' = { + name: '${appService.name}/metadata' + properties: { + CURRENT_STACK: 'dotnet' + } +} +``` + +This bicep file configures the Azure App Service as a .NET 6 application. Both the `appServicePlan` resource and the `appService` resource are provisioned in the resource group's location. The `appService` resource is configured to use the `S1` SKU, with a capacity of `1`. Additionally the resource is configured to use the `vnetSubnetId` subnet, and to use HTTPS. It also configures the `appInsightsInstrumentationKey` instrumentation key, the `appInsightsConnectionString` connection string, and the `storageConnectionString` connection string. These are used by the shopping cart app. + +The aforementioned Visual Studio Code extension for Bicep includes a visualizer. All of these bicep files are visualized as follows: + +:::image type="content" source="media/shopping-cart-flexing.png" alt-text="Orleans: Shopping cart sample app bicep provisioning visualizer rendering." lightbox="media/shopping-cart-flexing.png"::: + +## Summary + +As you update the source code and `push` changes to the `main` branch of the repository, the _deploy.yml_ workflow will run. It will provision the resources defined in the bicep files and deploy the application. The application can be expanded upon to include new features, such as authentication, or to support multiple instances of the application. The primary objective of this workflow is to demonstrate the ability to provision and deploy resources in a single step. + +In addition to the visualizer from the bicep extension, the Azure portal resource group page would look similar to the following example after provisioning and deploying the application: + +:::image type="content" source="media/shopping-cart-resources.png" alt-text="Azure Portal: Orleans shopping cart sample app resources." lightbox="media/shopping-cart-resources.png"::: + +## See also + +- [Orleans deployment overview](index.md) +- [GitHub Actions and .NET](../../devops/github-actions-overview.md) +- [Quickstart: Deploy an ASP.NET web app](/azure/app-service/quickstart-dotnetcore) +- [Integrate your app with an Azure virtual network](/azure/app-service/overview-vnet-integration) +- [Enable virtual network integration in Azure App Service](/azure/app-service/configure-vnet-integration-enable) diff --git a/docs/orleans/deployment/index.md b/docs/orleans/deployment/index.md index a81ae3eecb193..14e02c36aceb0 100644 --- a/docs/orleans/deployment/index.md +++ b/docs/orleans/deployment/index.md @@ -61,3 +61,8 @@ await client.Connect(); ## Production configurations The configuration examples we used here are for testing silos and clients running on the same machine as `localhost`. In production, silos and clients usually run on different servers and are configured with one of the reliable cluster configuration options. You can find more about that in the [Configuration guide](../host/configuration-guide/index.md) and in the description of [Cluster management](../implementation/cluster-management.md). + +## Next steps + +> [!div class="nextstepaction"] +> [Deploy Orleans to Azure App Service](deploy-to-azure-app-service.md) diff --git a/docs/orleans/deployment/media/empty-shopping-cart-page.png b/docs/orleans/deployment/media/empty-shopping-cart-page.png new file mode 100644 index 0000000000000..badff09ea8d53 Binary files /dev/null and b/docs/orleans/deployment/media/empty-shopping-cart-page.png differ diff --git a/docs/orleans/deployment/media/github-secret.png b/docs/orleans/deployment/media/github-secret.png new file mode 100644 index 0000000000000..12f1178fe54a7 Binary files /dev/null and b/docs/orleans/deployment/media/github-secret.png differ diff --git a/docs/orleans/deployment/media/home-page.png b/docs/orleans/deployment/media/home-page.png new file mode 100644 index 0000000000000..b8d21616debb2 Binary files /dev/null and b/docs/orleans/deployment/media/home-page.png differ diff --git a/docs/orleans/deployment/media/items-in-shopping-cart-page.png b/docs/orleans/deployment/media/items-in-shopping-cart-page.png new file mode 100644 index 0000000000000..a8e4d3978bad3 Binary files /dev/null and b/docs/orleans/deployment/media/items-in-shopping-cart-page.png differ diff --git a/docs/orleans/deployment/media/product-management-page-new.png b/docs/orleans/deployment/media/product-management-page-new.png new file mode 100644 index 0000000000000..1a81b48d81b27 Binary files /dev/null and b/docs/orleans/deployment/media/product-management-page-new.png differ diff --git a/docs/orleans/deployment/media/product-management-page.png b/docs/orleans/deployment/media/product-management-page.png new file mode 100644 index 0000000000000..e6037453fec4d Binary files /dev/null and b/docs/orleans/deployment/media/product-management-page.png differ diff --git a/docs/orleans/deployment/media/shop-inventory-items-added-page.png b/docs/orleans/deployment/media/shop-inventory-items-added-page.png new file mode 100644 index 0000000000000..4ca95337b86d6 Binary files /dev/null and b/docs/orleans/deployment/media/shop-inventory-items-added-page.png differ diff --git a/docs/orleans/deployment/media/shop-inventory-page.png b/docs/orleans/deployment/media/shop-inventory-page.png new file mode 100644 index 0000000000000..4ad5cf9920295 Binary files /dev/null and b/docs/orleans/deployment/media/shop-inventory-page.png differ diff --git a/docs/orleans/deployment/media/shopping-cart-app-arch.png b/docs/orleans/deployment/media/shopping-cart-app-arch.png new file mode 100644 index 0000000000000..18022b26d21c7 Binary files /dev/null and b/docs/orleans/deployment/media/shopping-cart-app-arch.png differ diff --git a/docs/orleans/deployment/media/shopping-cart-flexing.png b/docs/orleans/deployment/media/shopping-cart-flexing.png new file mode 100644 index 0000000000000..d8cf309646b1f Binary files /dev/null and b/docs/orleans/deployment/media/shopping-cart-flexing.png differ diff --git a/docs/orleans/deployment/media/shopping-cart-resources.png b/docs/orleans/deployment/media/shopping-cart-resources.png new file mode 100644 index 0000000000000..b989974635f07 Binary files /dev/null and b/docs/orleans/deployment/media/shopping-cart-resources.png differ diff --git a/docs/orleans/grains/grain-versioning/deploying-new-versions-of-grains.md b/docs/orleans/grains/grain-versioning/deploying-new-versions-of-grains.md index 6526e669fea81..d07afc9d33f45 100644 --- a/docs/orleans/grains/grain-versioning/deploying-new-versions-of-grains.md +++ b/docs/orleans/grains/grain-versioning/deploying-new-versions-of-grains.md @@ -56,7 +56,7 @@ var silo = new HostBuilder() }) }) .Build(); - + ``` Suggested deployment steps: diff --git a/docs/orleans/grains/grainservices.md b/docs/orleans/grains/grainservices.md index 607ff8072b254..59f6c50be8de0 100644 --- a/docs/orleans/grains/grainservices.md +++ b/docs/orleans/grains/grainservices.md @@ -76,7 +76,7 @@ A is a special grain; one that has no identi } ``` -1. Inject the grain service client into the other grains that need it. The `GrainServiceClient` does not guarantee to access the `GrainService` on the local silo. Your command could potentially be sent to the `GrainService` on any silo in the cluster. +1. Inject the grain service client into the other grains that need it. The `GrainServiceClient` is not guaranteed to access the `GrainService` on the local silo. Your command could potentially be sent to the `GrainService` on any silo in the cluster. ```csharp public class MyNormalGrain: Grain, INormalGrain diff --git a/docs/orleans/host/configuration-guide/shutting-down-orleans.md b/docs/orleans/host/configuration-guide/shutting-down-orleans.md index e6f79f9ece334..cc30c92764186 100644 --- a/docs/orleans/host/configuration-guide/shutting-down-orleans.md +++ b/docs/orleans/host/configuration-guide/shutting-down-orleans.md @@ -64,7 +64,7 @@ static ISiloHost CreateSilo() => new HostBuilder() }) .Build(); -static async Task StopSiloAsync() +static async Task StopSiloAsync() { await s_silo.StopAsync(); s_siloStopped.Set(); diff --git a/docs/orleans/index.yml b/docs/orleans/index.yml index 2ddae06c330e8..63bf7c5bd9186 100644 --- a/docs/orleans/index.yml +++ b/docs/orleans/index.yml @@ -90,8 +90,8 @@ conceptualContent: text: Consul deployment url: deployment/consul-deployment.md - itemType: concept - text: Azure deployment - url: deployment/azure-web-apps-with-azure-cloud-services.md + text: Azure App Service + url: deployment/deploy-to-azure-app-service.md - itemType: concept text: Multi-cluster deployment url: deployment/multi-cluster-support/overview.md diff --git a/docs/orleans/media/cluster-silo-grain-relationship.svg b/docs/orleans/media/cluster-silo-grain-relationship.svg new file mode 100644 index 0000000000000..2231cdefb9c0a --- /dev/null +++ b/docs/orleans/media/cluster-silo-grain-relationship.svg @@ -0,0 +1,16 @@ + + + + + + + Cluster (1/n)SiloSiloSiloGrainsGrainsGrains \ No newline at end of file diff --git a/docs/orleans/media/grain-lifecycle.svg b/docs/orleans/media/grain-lifecycle.svg new file mode 100644 index 0000000000000..618dc6a4b95cf --- /dev/null +++ b/docs/orleans/media/grain-lifecycle.svg @@ -0,0 +1,14 @@ + + + + + Active in memoryDeactivatingPersistedActivating \ No newline at end of file diff --git a/docs/orleans/media/managed-lifecycle.png b/docs/orleans/media/managed-lifecycle.png deleted file mode 100644 index 8268f61e049d5..0000000000000 Binary files a/docs/orleans/media/managed-lifecycle.png and /dev/null differ diff --git a/docs/orleans/overview.md b/docs/orleans/overview.md index 7317537c8f8c2..6d94dc9337a2f 100644 --- a/docs/orleans/overview.md +++ b/docs/orleans/overview.md @@ -1,147 +1,85 @@ --- title: Orleans overview description: An introduction to .NET Orleans. -ms.date: 03/10/2022 +ms.date: 05/10/2022 --- # Microsoft Orleans -Orleans is a cross-platform framework for building robust, scalable distributed applications. It builds on the developer productivity of .NET and brings it to the world of distributed applications, such as cloud services. Orleans scales from a single on-premises server to globally distributed, highly-available applications in the cloud. +Orleans is a cross-platform framework for building robust, scalable distributed applications. Distributed applications are defined as apps that span more than a single process, often beyond hardware boundaries using peer-to-peer communication. Orleans scales from a single on-premises server to globally distributed, highly available applications in the cloud. Orleans extends familiar concepts and C# idioms to multi-server environments. Orleans is designed to scale elastically. When a host joins a cluster, it can accept new activations. When a host leaves the cluster, either because of scale down or a machine failure, the previous activations on that host will be reactivated on the remaining hosts as needed. An Orleans cluster can be scaled down to a single host. The same properties that enable elastic scalability also enable fault tolerance. The cluster automatically detects and quickly recovers from failures. -Orleans extends familiar concepts like objects, interfaces, `async` and `await`, and try/catch to multi-server environments. Accordingly, it helps developers experienced with single-server applications transition to building resilient, scalable cloud services and other distributed applications. For this reason, Orleans has often been referred to as "Distributed .NET". +One of the primary design objectives of Orleans is to simplify the complexities of distributed application development by providing a common set of patterns and APIs. Developers familiar with single-server application development can easily transition to building resilient, scalable cloud-native services and other distributed applications using Orleans. For this reason, Orleans has often been referred to as "Distributed .NET" and is the framework of choice when building cloud-native apps. Orleans runs anywhere that .NET is supported. This includes hosting on Linux, Windows, and macOS. Orleans apps can be deployed to Kubernetes, virtual machines, and PaaS services such as [Azure App Service](/azure/app-service/overview) and [Azure Container Apps](/azure/container-apps/overview). -It was created by [Microsoft Research](https://research.microsoft.com/projects/orleans/) and introduced the [Virtual Actor Model](https://research.microsoft.com/apps/pubs/default.aspx?id=210931) as a novel approach to building a new generation of distributed systems for the Cloud era. The core contribution of Orleans is its programming model which tames the complexity inherent to highly-parallel distributed systems without restricting capabilities or imposing onerous constraints on the developer. +## The "Actor Model" -## An Introduction to Orleans +Orleans is based on the "actor model". The actor model originated in the early 1970s and is now a core component of Orleans. The actor model is a programming model in which each _actor_ is a lightweight, concurrent, immutable object that encapsulates a piece of state and corresponding behavior. Actors communicate exclusively with each other using asynchronous messages. Orleans notably invented the _Virtual Actor_ abstraction, wherein actors exist perpetually. - -> [!VIDEO https://aka.ms/docs/player?show=reactor&ep=an-introduction-to-orleans] - - -## Grains - -:::image type="content" source="media/grain-formulation.svg" alt-text="A grain is composed of a stable identity, behavior, and state."::: - -The fundamental building block in any Orleans application is a *grain*. Grains are entities comprising user-defined identity, behavior, and state. Grain identities are user-defined keys that make grains always available for invocation. Grains can be invoked by other grains or by external clients such as Web frontend via strongly-typed communication interfaces (contracts). Each grain is an instance of a class that implements one or more of these interfaces. - -Grains can have volatile or persistent state data that can be stored in any storage system. As such, grains implicitly partition application states, enabling automatic scalability and simplifying recovery from failures. Grain state is kept in memory while the grain is active, leading to lower latency and less load on data stores. - -:::image type="content" source="media/managed-lifecycle.png" alt-text="The managed lifecycle of an Orleans grain."::: - -Instantiation of grains is automatically performed on demand by the Orleans runtime. Grains that are not used for a while are automatically removed from memory to free up resources. This is possible because of their stable identity, which allows invoking grains whether they are already loaded into memory or not. This also allows for transparent recovery from failure because the caller does not need to know on which server a grain is instantiated at any point in time. Grains have a managed lifecycle, with the Orleans runtime responsible for activating/deactivating, and placing/locating grains as needed. This allows the developer to write code as if all grains are always in-memory. - -Taken together, the stable identity, statefulness, and managing the lifecycle of grains are core factors that make systems built on Orleans scalable, performant, and reliable without forcing developers to write complex distributed systems code. - -### Example scenario: IoT backend +> [!NOTE] +> Actors are purely logical entities that _always_ exist, virtually. An actor cannot be explicitly created nor destroyed, and its virtual existence is unaffected by the failure of a server that executes it. Since actors always exist, they are always addressable. -Consider a cloud backend for an [Internet of Things](https://en.wikipedia.org/wiki/Internet_of_things) system. This application needs to process incoming device data. Then it must filter, aggregate, and process this information, as well as enable sending commands to devices. In Orleans, it is natural to model each device as a grain which becomes a *digital twin* of the physical device it corresponds to. These grains keep the latest device data in memory so that they can be quickly queried and processed without the need to communicate with the physical device directly. By observing streams of time-series data from the device, the grain can detect changes in conditions, such as measurements exceeding a threshold, and trigger an action. +This is a novel approach to building a new generation of distributed applications for the Cloud era. The Orleans programming model tames the complexity inherent to highly parallel distributed applications _without_ restricting capabilities or imposing constraints on the developer. -A simple thermostat could be modeled as follows: +For more information, see [Orleans: Virtual Actors](https://www.microsoft.com/research/project/orleans-virtual-actors) via Microsoft Research. A virtual actor is represented as an Orleans grain. -```csharp -public interface IThermostat : IGrainWithStringKey -{ - Task> OnUpdate(ThermostatStatus update); -} -``` +## What are Grains? -Events arriving from the thermostat can be sent to its grain by invoking the `OnUpdate` method, which optionally returns a command to the device. +The grain is one of several Orleans primitives. In terms of the actor model, a grain is a virtual actor. The fundamental building block in any Orleans application is a *grain*. Grains are entities comprising user-defined identity, behavior, and state. Consider the following visual representation of a grain: -```csharp -var thermostat = client.GetGrain(id); -return await thermostat.OnUpdate(update); -``` +:::image type="content" source="media/grain-formulation.svg" lightbox="media/grain-formulation.svg" alt-text="A grain is composed of a stable identity, behavior, and state."::: -The same thermostat grain can implement a separate interface for control systems to interact with: +Grain identities are user-defined keys that make grains always available for invocation. Grains can be invoked by other grains or by any number of external clients. Each grain is an instance of a class that implements one or more of the following interfaces: -```csharp -public interface IThermostatControl : IGrainWithStringKey -{ - Task GetStatus(); +- : Marker interface for grains with `Guid` keys. +- : Marker interface for grains with `Int64` keys. +- : Marker interface for grains with `string` keys. +- : Marker interface for grains with compound keys. +- : Marker interface for grains with compound keys. - Task UpdateConfiguration(ThermostatConfiguration config); -} -``` +Grains can have volatile or persistent state data that can be stored in any storage system. As such, grains implicitly partition application states, enabling automatic scalability and simplifying recovery from failures. The grain state is kept in memory while the grain is active, leading to lower latency and less load on data stores. -These two interfaces (`IThermostat` and `IThermostatControl`) are implemented by a single implementation class: +:::image type="content" source="media/grain-lifecycle.svg" lightbox="media/grain-lifecycle.svg" alt-text="The managed lifecycle of an Orleans grain."::: -```csharp -public class ThermostatGrain : Grain, IThermostat, IThermostatControl -{ - private ThermostatStatus _status; - private List _commands; +Instantiation of grains is automatically performed on demand by the Orleans runtime. Grains that aren't used for a while are automatically removed from memory to free up resources. This is possible because of their stable identity, which allows invoking grains whether they're already loaded into memory or not. This also allows for transparent recovery from failure because the caller doesn't need to know on which server a grain is instantiated at any point in time. Grains have a managed lifecycle, with the Orleans runtime responsible for activating/deactivating, and placing/locating grains as needed. This allows the developer to write code as if all grains are always in-memory. - public Task> OnUpdate(ThermostatStatus status) - { - _status = status; - var result = _commands; - _commands = new List(); - return Task.FromResult(result); - } +## What are Silos? - public Task GetStatus() => Task.FromResult(_status); +A silo is another example of an Orleans primitive. A silo hosts one or more grains. The Orleans runtime is what implements the programming model for applications. - public Task UpdateConfiguration(ThermostatConfiguration config) - { - _commands.Add(new ConfigUpdateCommand(config)); - return Task.CompletedTask; - } -} -``` +Typically, a group of silos runs as a cluster for scalability and fault tolerance. When run as a cluster, silos coordinate with each other to distribute work and detect and recover from failures. The runtime enables grains hosted in the cluster to communicate with each other as if they are within a single process. To help visualize the relationship between clusters, silos and grains, consider the following diagram: -The grain class above does not persist in its state. Examples demonstrating state persistence are available in the [documentation](grains/grain-persistence/index.md). +:::image type="content" source="media/cluster-silo-grain-relationship.svg" lightbox="media/cluster-silo-grain-relationship.svg" alt-text="A cluster has one or more silos, and a silo has one or more grains."::: -## Orleans runtime +The preceding diagram shows the relationship between clusters, silos, and grains. You can have any number of clusters, each cluster has one or more silos, and each silo has one or more grains. -The Orleans runtime is what implements the programming model for applications. The main component of the runtime is the *silo*, which is responsible for hosting grains. +In addition to the core programming model, silos provide grains with a set of runtime services such as timers, reminders (persistent timers), persistence, transactions, streams, and more. For more information, see [What can I do with Orleans?](#what-can-i-do-with-orleans) -Typically, a group of silos runs as a cluster for scalability and fault tolerance. When run as a cluster, silos coordinate with each other to distribute work, detect and recover from failures. The runtime enables grains hosted in the cluster to communicate with each other as if they are within a single process. +Web apps and other external clients call grains in the cluster using the client library, which automatically manages network communication. Clients can also be co-hosted in the same process with silos for simplicity. -In addition to the core programming model, silos provide grains with a set of runtime services such as timers, reminders (persistent timers), persistence, transactions, streams, and more. See [Features](#features) for more detail. +## What can I do with Orleans? -Web frontends and other external clients call grains in the cluster using the client library, which automatically manages network communication. Clients can also be co-hosted in the same process with silos for simplicity. - -Orleans is compatible with .NET Standard 2.0 and above, running on Windows, Linux, and macOS. - -## Features +Orleans is a framework for building cloud-native apps and should be considered whenever you're building .NET apps that would eventually need to scale. There are seemingly endless ways to use Orleans, but the following are some of the most common ways; Gaming, Banking, Chat apps, GPS tracking, Stock trading, Shopping carts, Voting apps, and more. Orleans is used by Microsoft in Azure, Xbox, Skype, Halo, PlayFab, Gears of War, and many other internal services. Orleans has many features that make it easy to use for a variety of applications. ### Persistence -Orleans provides a simple persistence model which ensures that state is available to a grain before requests are processed and that consistency is maintained. Grains can have multiple named persistent data objects. For example, there might be one called "profile" for a user's profile and one called "inventory" for their inventory. This state can be stored in any storage system. Using the above example, profile data may be stored in one database and inventory in another. +Orleans provides a simple persistence model that ensures the state is available before processing a request, and that its consistency is maintained. Grains can have multiple named persistent data objects. For example, there might be one called "profile" for a user's profile and one called "inventory" for their inventory. This state can be stored in any storage system. -While a grain is running, this state is kept in memory so that read requests can be served without accessing storage. When the grain updates its state, a `state.WriteStateAsync()` call ensures that the backing store is updated for durability and consistency. +While a grain is running, the state is kept in memory so that read requests can be served without accessing storage. When the grain updates its state, calling ensures that the backing store is updated for durability and consistency. For more information, see the [Grain persistence](grains/grain-persistence/index.md). -### Distributed ACID transactions - -In addition to the simple persistence model described above, grains can have a *transactional state*. Multiple grains can participate in [ACID](https://en.wikipedia.org/wiki/ACID) transactions together regardless of where their state is ultimately stored. Transactions in Orleans are distributed and decentralized (there is no central transaction manager or transaction coordinator) and have [serializable isolation](https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels). - -For more information on transactions in Orleans, see the [documentation](grains/transactions.md) and the [Microsoft Research technical report](https://www.microsoft.com/research/publication/transactions-distributed-actors-cloud-2/). - -### Streams - -Streams help developers to process a series of data items in near-real-time. Streams in Orleans are *managed*; Streams do not need to be created or registered before a grain or client publishes to a stream or subscribes to a stream. This allows for greater decoupling of stream producers and consumers from each other and the infrastructure. - -Stream processing is reliable: grains can store checkpoints (cursors) and reset to a stored checkpoint during activation or at any subsequent time. Streams support batch delivery of messages to consumers to improve efficiency and recovery performance. - -Streams are backed by queueing services such as Azure Event Hubs, Amazon Kinesis, and others. - -An arbitrary number of streams can be multiplexed onto a smaller number of queues and the responsibility for processing these queues is balanced evenly across the cluster. - ### Timers and reminders -Reminders are a durable scheduling mechanism for grains. They can be used to ensure that some action is completed at a future point even if the grain is not currently activated at that time. Timers are the non-durable counterpart to reminders and can be used for high-frequency events which do not require reliability. +Reminders are a durable scheduling mechanism for grains. They can be used to ensure that some action is completed at a future point even if the grain isn't currently activated at that time. Timers are the non-durable counterpart to reminders and can be used for high-frequency events, which don't require reliability. -For more information, see the [Timers and reminders](grains/timers-and-reminders.md) documentation. +For more information, see [Timers and reminders](grains/timers-and-reminders.md). ### Flexible grain placement When a grain is activated in Orleans, the runtime decides which server (silo) to activate that grain on. This is called grain placement. -The placement process in Orleans is fully configurable. Developers can choose from a set of out-of-the-box placement policies such as random, prefer-local, and load-based, or custom logic can be configured. This allows for full flexibility in deciding where grains are created. For example, grains can be placed on a server close to resources which they need to operate against or other grains with which they communicate. +The placement process in Orleans is fully configurable. Developers can choose from a set of out-of-the-box placement policies such as random, prefer-local, and load-based, or custom logic can be configured. This allows for full flexibility in deciding where grains are created. For example, grains can be placed on a server close to resources that they need to operate against or other grains with which they communicate. -For more information see the [Grain placement](grains/grain-placement.md) documentation. +For more information, see [Grain placement](grains/grain-placement.md). ### Grain versioning and heterogeneous clusters @@ -149,42 +87,47 @@ Upgrading production systems in a manner that safely accounts for changes can be The cluster maintains a mapping of which grain implementations are available on which silos in the cluster and the versions of those implementations. This version of the information is used by the runtime in conjunction with placement strategies to make placement decisions when routing calls to grains. In addition, to safely update a versioned grain, this also enables heterogeneous clusters, where different silos have different sets of grain implementations available. -For more information, see the [Grain Versioning](grains/grain-versioning/grain-versioning.md) documentation. +For more information, see [Grain Versioning](grains/grain-versioning/grain-versioning.md). -### Elastic scalability and fault tolerance +### Stateless workers -Orleans is designed to scale elastically. When a silo joins a cluster it can accept new activations. When a silo leaves the cluster, either because of scale down or a machine failure, the grains which were activated on that silo will be re-activated on the remaining silos as needed. An Orleans cluster can be scaled down to a single silo. +Stateless workers are specially marked grains that don't have any associated state and can be activated on multiple silos simultaneously. This enables increased parallelism for stateless functions. -The same properties which enable elastic scalability also enable fault tolerance. The cluster automatically detects and quickly recovers from failures. +For more information, see [stateless worker grains](grains/stateless-worker-grains.md). -### Run anywhere +### Grain call filters -Orleans runs anywhere that .NET is supported. This includes hosting on Linux, Windows, and macOS. Orleans apps can be deployed to Kubernetes, virtual machines, and PaaS services such as Azure Cloud Services. +A [grain call filter](grains/interceptors.md) is logic that's common to many grains. Orleans supports filters for both incoming and outgoing calls. Filters for authorization, logging and telemetry, and error handling are all considered common. -### Stateless workers +### Request context -Stateless workers are specially marked grains that don't have any associated state and can be activated on multiple silos simultaneously. This enables increased parallelism for stateless functions. +Metadata and other information can be passed with a series of requests using the [request context](grains/request-context.md). Request context can be used for holding distributed tracing information or any other user-defined values. -For more information, see the [stateless worker grains](grains/stateless-worker-grains.md) documentation. +### Distributed ACID transactions -### Grain call filters +In addition to the simple persistence model described above, grains can have a *transactional state*. Multiple grains can participate in [ACID](/windows/win32/cossdk/acid-properties) transactions together regardless of where their state is ultimately stored. Transactions in Orleans are distributed and decentralized (there is no central transaction manager or transaction coordinator) and have [serializable isolation](https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels). -A call filter for a grain, is logic that is common to many grains can be expressed as [grain call filters](grains/interceptors.md). Orleans supports filters for both incoming and outgoing calls. Some common uses of filters are authorization, logging and telemetry, and error handling. +For more information on transactions, see [Transactions](grains/transactions.md). -### Request context +### Streams -Metadata and other information can be passed along a series of requests using [request context](grains/request-context.md). Request context can be used for holding distributed tracing information or any other user-defined values. +Streams help developers to process a series of data items in near-real-time. Orleans streams are *managed*; streams don't need to be created or registered before a grain or client publishes, or subscribes to a stream. This allows for greater decoupling of stream producers and consumers from each other and the infrastructure. + +Stream processing is reliable: grains can store checkpoints (cursors) and reset to a stored checkpoint during activation or at any subsequent time. Streams support batch delivery of messages to consumers to improve efficiency and recovery performance. -## Getting Started +Streams are backed by queueing services such as Azure Event Hubs, Amazon Kinesis, and others. -Please see the [getting started tutorial](tutorials-and-samples/tutorial-1.md). +An arbitrary number of streams can be multiplexed onto a smaller number of queues and the responsibility for processing these queues is balanced evenly across the cluster. -## Origin of Orleans +## Introduction to Orleans video -Orleans was created at [Microsoft Research and designed for use in the cloud](https://www.microsoft.com/research/publication/orleans-distributed-virtual-actors-for-programmability-and-scalability/). Since 2011, it has been used extensively in the cloud and on-premises by several Microsoft product groups, most notably by game studios, such as 343 Industries and The Coalition as a platform for cloud services behind Halo and Gears of War games, as well as by several other companies. +If you're interested in a video introduction to Orleans, check out the following video: -Orleans was open-sourced in January 2015 and attracted many developers that formed [one of the most vibrant open source communities in the .NET ecosystem](https://mattwarren.org/2016/11/23/open-source-net-2-years-later/). + +> [!VIDEO https://aka.ms/docs/player?show=reactor&ep=an-introduction-to-orleans] + -In an active collaboration between the developer community and the Orleans team at Microsoft, features are added and improved daily. Microsoft Research continues to partner with the Orleans team to bring new major features, such as [geo-distribution](https://www.microsoft.com/research/publication/geo-distribution-actor-based-services/), [indexing](https://www.microsoft.com/research/publication/indexing-in-an-actor-oriented-database/), and [distributed transactions](https://www.microsoft.com/research/publication/transactions-distributed-actors-cloud-2/), that are pushing the state of the art. +## Next steps -Orleans has become the framework of choice for building distributed systems and cloud services for many .NET developers. +> [!div class="nextstepaction"] +> [Tutorial: Create a minimal Orleans application](tutorials-and-samples/tutorial-1.md) diff --git a/docs/orleans/streaming/index.md b/docs/orleans/streaming/index.md index 6392a8f7707b7..32b9cb4f74db6 100644 --- a/docs/orleans/streaming/index.md +++ b/docs/orleans/streaming/index.md @@ -6,7 +6,7 @@ ms.date: 03/21/2022 # Streaming with Orleans -Orleans v.1.0.0 added support for streaming extensions to the programming model. Streaming extensions provide a set of abstractions and APIs that make thinking about and working with streams simpler and more robust. Streaming extensions allow developers to write reactive applications that operate on a sequence of events in a structured way. The extensibility model of stream providers makes the programming model compatible with and portable across a wide range of existing queuing technologies, such as [Event Hubs](https://azure.microsoft.com/services/event-hubs/), [ServiceBus](https://azure.microsoft.com/services/service-bus/), [Azure Queues](https://azure.microsoft.com/documentation/articles/storage-dotnet-how-to-use-queues/), and [Apache Kafka](https://kafka.apache.org/). There is no need to write special code or run dedicated processes to interact with such queues. +Orleans v.1.0.0 added support for streaming extensions to the programming model. Streaming extensions provide a set of abstractions and APIs that make thinking about and working with streams simpler and more robust. Streaming extensions allow developers to write reactive applications that operate on a sequence of events in a structured way. The extensibility model of stream providers makes the programming model compatible with and portable across a wide range of existing queuing technologies, such as [Event Hubs](https://azure.microsoft.com/services/event-hubs/), [ServiceBus](https://azure.microsoft.com/services/service-bus/), [Azure Queues](/azure/storage/queues/storage-dotnet-how-to-use-queues), and [Apache Kafka](https://kafka.apache.org/). There is no need to write special code or run dedicated processes to interact with such queues. ## Why should I care? diff --git a/docs/orleans/toc.yml b/docs/orleans/toc.yml index 98ba48a639a3e..bba99cdfa448c 100644 --- a/docs/orleans/toc.yml +++ b/docs/orleans/toc.yml @@ -150,14 +150,14 @@ items: items: - name: Running the app href: deployment/index.md + - name: Azure App Service + href: deployment/deploy-to-azure-app-service.md - name: Kubernetes href: deployment/kubernetes.md - name: Service fabric href: deployment/service-fabric.md - name: Handle failures href: deployment/handling-failures.md - - name: Using Azure Web Apps with Azure Cloud Services - href: deployment/azure-web-apps-with-azure-cloud-services.md - name: Troubleshooting Azure Cloud Services deployments href: deployment/troubleshooting-azure-cloud-services-deployments.md - name: Consul deployments diff --git a/docs/standard/analyzers/portability-analyzer.md b/docs/standard/analyzers/portability-analyzer.md index 02c5601b4c83e..8db34821d9ea4 100644 --- a/docs/standard/analyzers/portability-analyzer.md +++ b/docs/standard/analyzers/portability-analyzer.md @@ -1,7 +1,7 @@ --- title: The .NET Portability Analyzer - .NET description: Learn how to use the .NET Portability Analyzer tool to evaluate how portable your code is among the various .NET implementations, including .NET Core, .NET Standard, UWP, and Xamarin. -ms.date: 05/04/2021 +ms.date: 04/22/2022 ms.assetid: 0375250f-5704-4993-a6d5-e21c499cea1e --- @@ -21,7 +21,12 @@ Once you've converted your project to target the new platform, like .NET Core, y ## How to use the .NET Portability Analyzer -To begin using the .NET Portability Analyzer in Visual Studio, you first need to download and install the extension from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=ConnieYau.NETPortabilityAnalyzer). It works on Visual Studio 2017 and later versions. Configure it in Visual Studio via **Analyze** > **Portability Analyzer Settings** and select your Target Platforms, which are the .NET platforms/versions that you want to evaluate the portability gaps comparing with the platform/version that your current assembly is built with. +To begin using the .NET Portability Analyzer in Visual Studio, you first need to download and install the extension from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=ConnieYau.NETPortabilityAnalyzer). It works on Visual Studio 2017 and Visual Studio 2019 versions. + +> [!IMPORTANT] +> The .NET Portability Analyzer is not supported in Visual Studio 2022. + +Configure it in Visual Studio via **Analyze** > **Portability Analyzer Settings** and select your Target Platforms, which are the .NET platforms/versions that you want to evaluate the portability gaps comparing with the platform/version that your current assembly is built with. ![Screenshot of portability analyzer.](./media/portability-analyzer/portability-screenshot.png) @@ -102,4 +107,4 @@ The **Details** section of the report lists the APIs missing from any of the sel You may find a Missing Assemblies section in your report. This section contains a list of assemblies that are referenced by your analyzed assemblies and were not analyzed. If it's an assembly that you own, include it in the API portability analyzer run so that you can get a detailed, API-level portability report for it. If it's a third-party library, check if there is a newer version that supports your target platform, and consider moving to the newer version. Eventually, the list should include all the third-party assemblies that your app depends on that have a version supporting your target platform. -For more information on the .NET Portability Analyzer, visit the [GitHub documentation](https://github.com/Microsoft/dotnet-apiport#documentation) and [A Brief Look at the .NET Portability Analyzer](https://channel9.msdn.com/Blogs/Seth-Juarez/A-Brief-Look-at-the-NET-Portability-Analyzer) Channel 9 video. +For more information on the .NET Portability Analyzer, visit the [GitHub documentation](https://github.com/Microsoft/dotnet-apiport#documentation). diff --git a/docs/standard/assembly/delay-sign.md b/docs/standard/assembly/delay-sign.md index 22c68d7ffb00c..4e2d82e19e520 100644 --- a/docs/standard/assembly/delay-sign.md +++ b/docs/standard/assembly/delay-sign.md @@ -49,21 +49,21 @@ To delay-sign an assembly: 3. The compiler inserts the public key into the assembly manifest and reserves space in the PE file for the full strong name signature. The real public key must be stored while the assembly is built so that other assemblies that reference this assembly can obtain the key to store in their own assembly reference. -4. Because the assembly does not have a valid strong name signature, the verification of that signature must be turned off. You can do this by using the **–Vr** option with the Strong Name tool. +4. Because the assembly does not have a valid strong name signature, the verification of that signature must be turned off. You can do this by using the **-Vr** option with the Strong Name tool. The following example turns off verification for an assembly called *myAssembly.dll*. ```console - sn –Vr myAssembly.dll + sn -Vr myAssembly.dll ``` - To turn off verification on platforms where you can't run the Strong Name tool, such as Advanced RISC Machine (ARM) microprocessors, use the **–Vk** option to create a registry file. Import the registry file into the registry on the computer where you want to turn off verification. The following example creates a registry file for `myAssembly.dll`. + To turn off verification on platforms where you can't run the Strong Name tool, such as Advanced RISC Machine (ARM) microprocessors, use the **-Vk** option to create a registry file. Import the registry file into the registry on the computer where you want to turn off verification. The following example creates a registry file for `myAssembly.dll`. ```console - sn –Vk myRegFile.reg myAssembly.dll + sn -Vk myRegFile.reg myAssembly.dll ``` - With either the **–Vr** or **–Vk** option, you can optionally include an *.snk* file for test key signing. + With either the **-Vr** or **-Vk** option, you can optionally include an *.snk* file for test key signing. > [!WARNING] > Do not rely on strong names for security. They provide a unique identity only. @@ -71,7 +71,7 @@ To delay-sign an assembly: > [!NOTE] > If you use delay signing during development with Visual Studio on a 64-bit computer, and you compile an assembly for **Any CPU**, you might have to apply the **-Vr** option twice. (In Visual Studio, **Any CPU** is a value of the **Platform Target** build property; when you compile from the command line, it is the default.) To run your application from the command line or from File Explorer, use the 64-bit version of the [Sn.exe (Strong Name tool)](../../framework/tools/sn-exe-strong-name-tool.md) to apply the **-Vr** option to the assembly. To load the assembly into Visual Studio at design time (for example, if the assembly contains components that are used by other assemblies in your application), use the 32-bit version of the strong-name tool. This is because the just-in-time (JIT) compiler compiles the assembly to 64-bit native code when the assembly is run from the command line, and to 32-bit native code when the assembly is loaded into the design-time environment. -5. Later, usually just before shipping, you submit the assembly to your organization's signing authority for the actual strong name signing using the **–R** option with the Strong Name tool. +5. Later, usually just before shipping, you submit the assembly to your organization's signing authority for the actual strong name signing using the **-R** option with the Strong Name tool. The following example signs an assembly called *myAssembly.dll* with a strong name using the *sgKey.snk* key pair. diff --git a/docs/standard/assembly/security-considerations.md b/docs/standard/assembly/security-considerations.md index 5b79bc466306c..803a98067e3c2 100644 --- a/docs/standard/assembly/security-considerations.md +++ b/docs/standard/assembly/security-considerations.md @@ -54,7 +54,7 @@ When you build an assembly, you can specify a set of permissions that the assemb The common language runtime also performs a hash verification; the assembly manifest contains a list of all files that make up the assembly, including a hash of each file as it existed when the manifest was built. As each file is loaded, its contents are hashed and compared with the hash value stored in the manifest. If the two hashes do not match, the assembly fails to load. - Because strong naming and signing using [SignTool.exe (Sign Tool)](../../framework/tools/signtool-exe.md) guarantee integrity, you can base code access security policy on these two forms of assembly evidence. Strong naming and signing using [SignTool.exe (Sign Tool)](../../framework/tools/signtool-exe.md) guarantee integrity through digital signatures and certificates. All the technologies mentioned—hash verification, strong naming, and signing using [SignTool.exe (Sign Tool)](../../framework/tools/signtool-exe.md)—work together to ensure that the assembly has not been altered in any way. + Strong naming and signing using [SignTool.exe (Sign Tool)](../../framework/tools/signtool-exe.md) guarantee integrity through digital signatures and certificates. All the technologies mentioned, that is, hash verification, strong naming, and signing using [SignTool.exe (Sign Tool)](../../framework/tools/signtool-exe.md), work together to ensure that the assembly has not been altered in any way. ## See also diff --git a/docs/standard/base-types/anchors-in-regular-expressions.md b/docs/standard/base-types/anchors-in-regular-expressions.md index 1a97e2db89828..6c44d7995aefa 100644 --- a/docs/standard/base-types/anchors-in-regular-expressions.md +++ b/docs/standard/base-types/anchors-in-regular-expressions.md @@ -27,7 +27,7 @@ Anchors, or atomic zero-width assertions, specify a position in the string where |`\A`|The match must occur at the beginning of the string only (no multiline support). For more information, see [Start of String Only](#start-of-string-only-a).| |`\Z`|The match must occur at the end of the string, or before `\n` at the end of the string. For more information, see [End of String or Before Ending Newline](#end-of-string-or-before-ending-newline-z).| |`\z`|The match must occur at the end of the string only. For more information, see [End of String Only](#end-of-string-only-z).| -|`\G`|The match must start at the position where the previous match ended. For more information, see [Contiguous Matches](#contiguous-matches-g).| +|`\G`|The match must start at the position where the previous match ended, or if there was no previous match, at the position in the string where matching started. For more information, see [Contiguous Matches](#contiguous-matches-g).| |`\b`|The match must occur on a word boundary. For more information, see [Word Boundary](#word-boundary-b).| |`\B`|The match must not occur on a word boundary. For more information, see [Non-Word Boundary](#non-word-boundary-b).| @@ -100,7 +100,7 @@ Anchors, or atomic zero-width assertions, specify a position in the string where ## Contiguous Matches: \G - The `\G` anchor specifies that a match must occur at the point where the previous match ended. When you use this anchor with the or method, it ensures that all matches are contiguous. + The `\G` anchor specifies that a match must occur at the point where the previous match ended, or if there was no previous match, at the position in the string where matching started. When you use this anchor with the or method, it ensures that all matches are contiguous. The following example uses a regular expression to extract the names of rodent species from a comma-delimited string. diff --git a/docs/standard/base-types/backtracking-in-regular-expressions.md b/docs/standard/base-types/backtracking-in-regular-expressions.md index ed38924b7dfb6..ab3f8c9c8a73c 100644 --- a/docs/standard/base-types/backtracking-in-regular-expressions.md +++ b/docs/standard/base-types/backtracking-in-regular-expressions.md @@ -2,10 +2,10 @@ title: Backtracking in .NET Regular Expressions description: Learn how to control backtracking in regular expression pattern matching. ms.date: "11/12/2018" -dev_langs: +dev_langs: - "csharp" - "vb" -helpviewer_keywords: +helpviewer_keywords: - ".NET regular expressions, backtracking" - "alternative matching patterns" - "optional matching patterns" @@ -19,177 +19,185 @@ ms.assetid: 34df1152-0b22-4a1c-a76c-3c28c47b70d8 --- # Backtracking in Regular Expressions -Backtracking occurs when a regular expression pattern contains optional [quantifiers](quantifiers-in-regular-expressions.md) or [alternation constructs](alternation-constructs-in-regular-expressions.md), and the regular expression engine returns to a previous saved state to continue its search for a match. Backtracking is central to the power of regular expressions; it makes it possible for expressions to be powerful and flexible, and to match very complex patterns. At the same time, this power comes at a cost. Backtracking is often the single most important factor that affects the performance of the regular expression engine. Fortunately, the developer has control over the behavior of the regular expression engine and how it uses backtracking. This topic explains how backtracking works and how it can be controlled. - +Backtracking occurs when a regular expression pattern contains optional [quantifiers](quantifiers-in-regular-expressions.md) or [alternation constructs](alternation-constructs-in-regular-expressions.md), and the regular expression engine returns to a previous saved state to continue its search for a match. Backtracking is central to the power of regular expressions; it makes it possible for expressions to be powerful and flexible, and to match very complex patterns. At the same time, this power comes at a cost. Backtracking is often the single most important factor that affects the performance of the regular expression engine. Fortunately, the developer has control over the behavior of the regular expression engine and how it uses backtracking. This topic explains how backtracking works and how it can be controlled. + > [!NOTE] -> In general, a Nondeterministic Finite Automaton (NFA) engine like .NET regular expression engine places the responsibility for crafting efficient, fast regular expressions on the developer. +> In general, a Nondeterministic Finite Automaton (NFA) engine like .NET regular expression engine places the responsibility for crafting efficient, fast regular expressions on the developer. + +## Linear Comparison Without Backtracking + + If a regular expression pattern has no optional quantifiers or alternation constructs, the regular expression engine executes in linear time. That is, after the regular expression engine matches the first language element in the pattern with text in the input string, it tries to match the next language element in the pattern with the next character or group of characters in the input string. This continues until the match either succeeds or fails. In either case, the regular expression engine advances by one character at a time in the input string. -## Linear Comparison Without Backtracking + The following example provides an illustration. The regular expression `e{2}\w\b` looks for two occurrences of the letter "e" followed by any word character followed by a word boundary. - If a regular expression pattern has no optional quantifiers or alternation constructs, the regular expression engine executes in linear time. That is, after the regular expression engine matches the first language element in the pattern with text in the input string, it tries to match the next language element in the pattern with the next character or group of characters in the input string. This continues until the match either succeeds or fails. In either case, the regular expression engine advances by one character at a time in the input string. - - The following example provides an illustration. The regular expression `e{2}\w\b` looks for two occurrences of the letter "e" followed by any word character followed by a word boundary. - [!code-csharp[Conceptual.RegularExpressions.Backtracking#1](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/cs/backtracking1.cs#1)] - [!code-vb[Conceptual.RegularExpressions.Backtracking#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking1.vb#1)] - - Although this regular expression includes the quantifier `{2}`, it is evaluated in a linear manner. The regular expression engine does not backtrack because `{2}` is not an optional quantifier; it specifies an exact number and not a variable number of times that the previous subexpression must match. As a result, the regular expression engine tries to match the regular expression pattern with the input string as shown in the following table. - -|Operation|Position in pattern|Position in string|Result| -|---------------|-------------------------|------------------------|------------| -|1|e|"needing a reed" (index 0)|No match.| -|2|e|"eeding a reed" (index 1)|Possible match.| -|3|e{2}|"eding a reed" (index 2)|Possible match.| -|4|\w|"ding a reed" (index 3)|Possible match.| -|5|\b|"ing a reed" (index 4)|Possible match fails.| -|6|e|"eding a reed" (index 2)|Possible match.| -|7|e{2}|"ding a reed" (index 3)|Possible match fails.| -|8|e|"ding a reed" (index 3)|Match fails.| -|9|e|"ing a reed" (index 4)|No match.| -|10|e|"ng a reed" (index 5)|No match.| -|11|e|"g a reed" (index 6)|No match.| -|12|e|" a reed" (index 7)|No match.| -|13|e|"a reed" (index 8)|No match.| -|14|e|" reed" (index 9)|No match.| -|15|e|"reed" (index 10)|No match| -|16|e|"eed" (index 11)|Possible match.| -|17|e{2}|"ed" (index 12)|Possible match.| -|18|\w|"d" (index 13)|Possible match.| -|19|\b|"" (index 14)|Match.| - + [!code-vb[Conceptual.RegularExpressions.Backtracking#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking1.vb#1)] + + Although this regular expression includes the quantifier `{2}`, it is evaluated in a linear manner. The regular expression engine does not backtrack because `{2}` is not an optional quantifier; it specifies an exact number and not a variable number of times that the previous subexpression must match. As a result, the regular expression engine tries to match the regular expression pattern with the input string as shown in the following table. + +|Operation|Position in pattern|Position in string|Result| +|---------------|-------------------------|------------------------|------------| +|1|e|"needing a reed" (index 0)|No match.| +|2|e|"eeding a reed" (index 1)|Possible match.| +|3|e{2}|"eding a reed" (index 2)|Possible match.| +|4|\w|"ding a reed" (index 3)|Possible match.| +|5|\b|"ing a reed" (index 4)|Possible match fails.| +|6|e|"eding a reed" (index 2)|Possible match.| +|7|e{2}|"ding a reed" (index 3)|Possible match fails.| +|8|e|"ding a reed" (index 3)|Match fails.| +|9|e|"ing a reed" (index 4)|No match.| +|10|e|"ng a reed" (index 5)|No match.| +|11|e|"g a reed" (index 6)|No match.| +|12|e|" a reed" (index 7)|No match.| +|13|e|"a reed" (index 8)|No match.| +|14|e|" reed" (index 9)|No match.| +|15|e|"reed" (index 10)|No match| +|16|e|"eed" (index 11)|Possible match.| +|17|e{2}|"ed" (index 12)|Possible match.| +|18|\w|"d" (index 13)|Possible match.| +|19|\b|"" (index 14)|Match.| + If a regular expression pattern includes no optional quantifiers or alternation constructs, the maximum number of comparisons required to match the regular expression pattern with the input string is roughly equivalent to the number of characters in the input string. In this case, the regular expression engine uses 19 comparisons to identify possible matches in this 13-character string. In other words, the regular expression engine runs in near-linear time if it contains no optional quantifiers or alternation constructs. -## Backtracking with Optional Quantifiers or Alternation Constructs +## Backtracking with Optional Quantifiers or Alternation Constructs + + When a regular expression includes optional quantifiers or alternation constructs, the evaluation of the input string is no longer linear. Pattern matching with an NFA engine is driven by the language elements in the regular expression and not by the characters to be matched in the input string. Therefore, the regular expression engine tries to fully match optional or alternative subexpressions. When it advances to the next language element in the subexpression and the match is unsuccessful, the regular expression engine can abandon a portion of its successful match and return to an earlier saved state in the interest of matching the regular expression as a whole with the input string. This process of returning to a previous saved state to find a match is known as backtracking. + + For example, consider the regular expression pattern `.*(es)`, which matches the characters "es" and all the characters that precede it. As the following example shows, if the input string is "Essential services are provided by regular expressions.", the pattern matches the whole string up to and including the "es" in "expressions". - When a regular expression includes optional quantifiers or alternation constructs, the evaluation of the input string is no longer linear. Pattern matching with an NFA engine is driven by the language elements in the regular expression and not by the characters to be matched in the input string. Therefore, the regular expression engine tries to fully match optional or alternative subexpressions. When it advances to the next language element in the subexpression and the match is unsuccessful, the regular expression engine can abandon a portion of its successful match and return to an earlier saved state in the interest of matching the regular expression as a whole with the input string. This process of returning to a previous saved state to find a match is known as backtracking. - - For example, consider the regular expression pattern `.*(es)`, which matches the characters "es" and all the characters that precede it. As the following example shows, if the input string is "Essential services are provided by regular expressions.", the pattern matches the whole string up to and including the "es" in "expressions". - [!code-csharp[Conceptual.RegularExpressions.Backtracking#2](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/cs/backtracking2.cs#2)] - [!code-vb[Conceptual.RegularExpressions.Backtracking#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking2.vb#2)] - - To do this, the regular expression engine uses backtracking as follows: - -- It matches the `.*` (which matches zero, one, or more occurrences of any character) with the whole input string. - -- It attempts to match "e" in the regular expression pattern. However, the input string has no remaining characters available to match. - -- It backtracks to its last successful match, "Essential services are provided by regular expressions", and attempts to match "e" with the period at the end of the sentence. The match fails. - -- It continues to backtrack to a previous successful match one character at a time until the tentatively matched substring is "Essential services are provided by regular expr". It then compares the "e" in the pattern to the second "e" in "expressions" and finds a match. - -- It compares "s" in the pattern to the "s" that follows the matched "e" character (the first "s" in "expressions"). The match is successful. - + [!code-vb[Conceptual.RegularExpressions.Backtracking#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking2.vb#2)] + + To do this, the regular expression engine uses backtracking as follows: + +- It matches the `.*` (which matches zero, one, or more occurrences of any character) with the whole input string. + +- It attempts to match "e" in the regular expression pattern. However, the input string has no remaining characters available to match. + +- It backtracks to its last successful match, "Essential services are provided by regular expressions", and attempts to match "e" with the period at the end of the sentence. The match fails. + +- It continues to backtrack to a previous successful match one character at a time until the tentatively matched substring is "Essential services are provided by regular expr". It then compares the "e" in the pattern to the second "e" in "expressions" and finds a match. + +- It compares "s" in the pattern to the "s" that follows the matched "e" character (the first "s" in "expressions"). The match is successful. + When you use backtracking, matching the regular expression pattern with the input string, which is 55 characters long, requires 67 comparison operations. Generally, if a regular expression pattern has a single alternation construct or a single optional quantifier, the number of comparison operations required to match the pattern is more than twice the number of characters in the input string. -## Backtracking with Nested Optional Quantifiers +## Backtracking with Nested Optional Quantifiers + + The number of comparison operations required to match a regular expression pattern can increase exponentially if the pattern includes a large number of alternation constructs, if it includes nested alternation constructs, or, most commonly, if it includes nested optional quantifiers. For example, the regular expression pattern `^(a+)+$` is designed to match a complete string that contains one or more "a" characters. The example provides two input strings of identical length, but only the first string matches the pattern. The class is used to determine how long the match operation takes. - The number of comparison operations required to match a regular expression pattern can increase exponentially if the pattern includes a large number of alternation constructs, if it includes nested alternation constructs, or, most commonly, if it includes nested optional quantifiers. For example, the regular expression pattern `^(a+)+$` is designed to match a complete string that contains one or more "a" characters. The example provides two input strings of identical length, but only the first string matches the pattern. The class is used to determine how long the match operation takes. - [!code-csharp[Conceptual.RegularExpressions.Backtracking#3](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/cs/backtracking3.cs#3)] - [!code-vb[Conceptual.RegularExpressions.Backtracking#3](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking3.vb#3)] - - As the output from the example shows, the regular expression engine took about twice as long to find that an input string did not match the pattern as it did to identify a matching string. This is because an unsuccessful match always represents a worst-case scenario. The regular expression engine must use the regular expression to follow all possible paths through the data before it can conclude that the match is unsuccessful, and the nested parentheses create many additional paths through the data. The regular expression engine concludes that the second string did not match the pattern by doing the following: - -- It checks that it was at the beginning of the string, and then matches the first five characters in the string with the pattern `a+`. It then determines that there are no additional groups of "a" characters in the string. Finally, it tests for the end of the string. Because one additional character remains in the string, the match fails. This failed match requires 9 comparisons. The regular expression engine also saves state information from its matches of "a" (which we will call match 1), "aa" (match 2), "aaa" (match 3), and "aaaa" (match 4). - -- It returns to the previously saved match 4. It determines that there is one additional "a" character to assign to an additional captured group. Finally, it tests for the end of the string. Because one additional character remains in the string, the match fails. This failed match requires 4 comparisons. So far, a total of 13 comparisons have been performed. - -- It returns to the previously saved match 3. It determines that there are two additional "a" characters to assign to an additional captured group. However, the end-of-string test fails. It then returns to match3 and tries to match the two additional "a" characters in two additional captured groups. The end-of-string test still fails. These failed matches require 12 comparisons. So far, a total of 25 comparisons have been performed. - + [!code-vb[Conceptual.RegularExpressions.Backtracking#3](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking3.vb#3)] + + As the output from the example shows, the regular expression engine took about twice as long to find that an input string did not match the pattern as it did to identify a matching string. This is because an unsuccessful match always represents a worst-case scenario. The regular expression engine must use the regular expression to follow all possible paths through the data before it can conclude that the match is unsuccessful, and the nested parentheses create many additional paths through the data. The regular expression engine concludes that the second string did not match the pattern by doing the following: + +- It checks that it was at the beginning of the string, and then matches the first five characters in the string with the pattern `a+`. It then determines that there are no additional groups of "a" characters in the string. Finally, it tests for the end of the string. Because one additional character remains in the string, the match fails. This failed match requires 9 comparisons. The regular expression engine also saves state information from its matches of "a" (which we will call match 1), "aa" (match 2), "aaa" (match 3), and "aaaa" (match 4). + +- It returns to the previously saved match 4. It determines that there is one additional "a" character to assign to an additional captured group. Finally, it tests for the end of the string. Because one additional character remains in the string, the match fails. This failed match requires 4 comparisons. So far, a total of 13 comparisons have been performed. + +- It returns to the previously saved match 3. It determines that there are two additional "a" characters to assign to an additional captured group. However, the end-of-string test fails. It then returns to match3 and tries to match the two additional "a" characters in two additional captured groups. The end-of-string test still fails. These failed matches require 12 comparisons. So far, a total of 25 comparisons have been performed. + Comparison of the input string with the regular expression continues in this way until the regular expression engine has tried all possible combinations of matches, and then concludes that there is no match. Because of the nested quantifiers, this comparison is an O(2n) or an exponential operation, where *n* is the number of characters in the input string. This means that in the worst case, an input string of 30 characters requires approximately 1,073,741,824 comparisons, and an input string of 40 characters requires approximately 1,099,511,627,776 comparisons. If you use strings of these or even greater lengths, regular expression methods can take an extremely long time to complete when they process input that does not match the regular expression pattern. -## Controlling Backtracking +## Controlling Backtracking + + Backtracking lets you create powerful, flexible regular expressions. However, as the previous section showed, these benefits may be coupled with unacceptably poor performance. To prevent excessive backtracking, you should define a time-out interval when you instantiate a object or call a static regular expression matching method. This is discussed in the next section. In addition, .NET supports three regular expression language elements that limit or suppress backtracking and that support complex regular expressions with little or no performance penalty: [atomic groups](#atomic-groups), [lookbehind assertions](#lookbehind-assertions), and [lookahead assertions](#lookahead-assertions). For more information about each language element, see [Grouping Constructs](grouping-constructs-in-regular-expressions.md). + +### Defining a Time-out Interval + + Starting with the .NET Framework 4.5, you can set a time-out value that represents the longest interval the regular expression engine will search for a single match before it abandons the attempt and throws a exception. You specify the time-out interval by supplying a value to the constructor for instance regular expressions. In addition, each static pattern matching method has an overload with a parameter that allows you to specify a time-out value. + +If you do not set a time-out value explicitly, the default time-out value is determined as follows: - Backtracking lets you create powerful, flexible regular expressions. However, as the previous section showed, these benefits may be coupled with unacceptably poor performance. To prevent excessive backtracking, you should define a time-out interval when you instantiate a object or call a static regular expression matching method. This is discussed in the next section. In addition, .NET supports three regular expression language elements that limit or suppress backtracking and that support complex regular expressions with little or no performance penalty: [atomic groups](#atomic-groups), [lookbehind assertions](#lookbehind-assertions), and [lookahead assertions](#lookahead-assertions). For more information about each language element, see [Grouping Constructs](grouping-constructs-in-regular-expressions.md). +- By using the application-wide time-out value, if one exists. This can be any time-out value that applies to the application domain in which the object is instantiated or the static method call is made. You can set the application-wide time-out value by calling the method to assign the string representation of a value to the "REGEX_DEFAULT_MATCH_TIMEOUT" property. -### Defining a Time-out Interval +- By using the value , if no application-wide time-out value has been set. + + By default, the time-out interval is set to and the regular expression engine does not time out. - Starting with the .NET Framework 4.5, you can set a time-out value that represents the longest interval the regular expression engine will search for a single match before it abandons the attempt and throws a exception. You specify the time-out interval by supplying a value to the constructor for instance regular expressions. In addition, each static pattern matching method has an overload with a parameter that allows you to specify a time-out value. By default, the time-out interval is set to and the regular expression engine does not time out. - > [!IMPORTANT] -> We recommend that you always set a time-out interval if your regular expression relies on backtracking. - - A exception indicates that the regular expression engine was unable to find a match within the specified time-out interval but does not indicate why the exception was thrown. The reason might be excessive backtracking, but it is also possible that the time-out interval was set too low given the system load at the time the exception was thrown. When you handle the exception, you can choose to abandon further matches with the input string or increase the time-out interval and retry the matching operation. - - For example, the following code calls the constructor to instantiate a object with a time-out value of one second. The regular expression pattern `(a+)+$`, which matches one or more sequences of one or more "a" characters at the end of a line, is subject to excessive backtracking. If a is thrown, the example increases the time-out value up to a maximum interval of three seconds. After that, it abandons the attempt to match the pattern. - +> We recommend that you always set a time-out interval if your regular expression relies on backtracking. + + A exception indicates that the regular expression engine was unable to find a match within the specified time-out interval but does not indicate why the exception was thrown. The reason might be excessive backtracking, but it is also possible that the time-out interval was set too low given the system load at the time the exception was thrown. When you handle the exception, you can choose to abandon further matches with the input string or increase the time-out interval and retry the matching operation. + + For example, the following code calls the constructor to instantiate a object with a time-out value of one second. The regular expression pattern `(a+)+$`, which matches one or more sequences of one or more "a" characters at the end of a line, is subject to excessive backtracking. If a is thrown, the example increases the time-out value up to a maximum interval of three seconds. After that, it abandons the attempt to match the pattern. + [!code-csharp[System.Text.RegularExpressions.Regex.ctor#1](../../../samples/snippets/csharp/VS_Snippets_CLR_System/system.text.regularexpressions.regex.ctor/cs/ctor1.cs#1)] - [!code-vb[System.Text.RegularExpressions.Regex.ctor#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.regex.ctor/vb/ctor1.vb#1)] + [!code-vb[System.Text.RegularExpressions.Regex.ctor#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.regex.ctor/vb/ctor1.vb#1)] ### Atomic groups The `(?>` *subexpression*`)` language element suppresses backtracking into the subexpression. Once it has successfully matched, it will not give up any part of its match to subsequent backtracking. For example, in the pattern `(?>\w*\d*)1`, if the `1` cannot be matched, the `\d*` will not give up any of its match even if that means it would allow the `1` to successfully match. Atomic groups can help prevent the performance problems associated with failed matches. - - The following example illustrates how suppressing backtracking improves performance when using nested quantifiers. It measures the time required for the regular expression engine to determine that an input string does not match two regular expressions. The first regular expression uses backtracking to attempt to match a string that contains one or more occurrences of one or more hexadecimal digits, followed by a colon, followed by one or more hexadecimal digits, followed by two colons. The second regular expression is identical to the first, except that it disables backtracking. As the output from the example shows, the performance improvement from disabling backtracking is significant. - + + The following example illustrates how suppressing backtracking improves performance when using nested quantifiers. It measures the time required for the regular expression engine to determine that an input string does not match two regular expressions. The first regular expression uses backtracking to attempt to match a string that contains one or more occurrences of one or more hexadecimal digits, followed by a colon, followed by one or more hexadecimal digits, followed by two colons. The second regular expression is identical to the first, except that it disables backtracking. As the output from the example shows, the performance improvement from disabling backtracking is significant. + [!code-csharp[Conceptual.RegularExpressions.Backtracking#4](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/cs/backtracking4.cs#4)] - [!code-vb[Conceptual.RegularExpressions.Backtracking#4](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking4.vb#4)] + [!code-vb[Conceptual.RegularExpressions.Backtracking#4](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking4.vb#4)] -### Lookbehind Assertions +### Lookbehind Assertions + + .NET includes two language elements, `(?<=`*subexpression*`)` and `(? method. - .NET includes two language elements, `(?<=`*subexpression*`)` and `(? method. - [!code-csharp[Conceptual.RegularExpressions.Backtracking#5](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/cs/backtracking5.cs#5)] - [!code-vb[Conceptual.RegularExpressions.Backtracking#5](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking5.vb#5)] - - The first regular expression pattern, `^[0-9A-Z]([-.\w]*[0-9A-Z])*@`, is defined as shown in the following table. - -|Pattern|Description| -|-------------|-----------------| -|`^`|Start the match at the beginning of the string.| -|`[0-9A-Z]`|Match an alphanumeric character. This comparison is case-insensitive, because the method is called with the option.| -|`[-.\w]*`|Match zero, one, or more occurrences of a hyphen, period, or word character.| -|`[0-9A-Z]`|Match an alphanumeric character.| -|`([-.\w]*[0-9A-Z])*`|Match zero or more occurrences of the combination of zero or more hyphens, periods, or word characters, followed by an alphanumeric character. This is the first capturing group.| -|`@`|Match an at sign ("\@").| - - The second regular expression pattern, `^[0-9A-Z][-.\w]*(?<=[0-9A-Z])@`, uses a positive lookbehind assertion. It is defined as shown in the following table. - -|Pattern|Description| -|-------------|-----------------| -|`^`|Start the match at the beginning of the string.| -|`[0-9A-Z]`|Match an alphanumeric character. This comparison is case-insensitive, because the method is called with the option.| -|`[-.\w]*`|Match zero or more occurrences of a hyphen, period, or word character.| -|`(?<=[0-9A-Z])`|Look back at the last matched character and continue the match if it is alphanumeric. Note that alphanumeric characters are a subset of the set that consists of periods, hyphens, and all word characters.| -|`@`|Match an at sign ("\@").| - -### Lookahead Assertions - - .NET includes two language elements, `(?=`*subexpression*`)` and `(?!`*subexpression*`)`, that match the next character or characters in the input string. Both language elements are zero-width assertions; that is, they determine whether the character or characters that immediately follow the current character can be matched by *subexpression*, without advancing or backtracking. - - `(?=` *subexpression* `)` is a positive lookahead assertion; that is, the character or characters after the current position must match *subexpression*. `(?!`*subexpression*`)` is a negative lookahead assertion; that is, the character or characters after the current position must not match *subexpression*. Both positive and negative lookahead assertions are most useful when *subexpression* is a subset of the next subexpression. - - The following example uses two equivalent regular expression patterns that validate a fully qualified type name. The first pattern is subject to poor performance because of excessive backtracking. The second modifies the first regular expression by replacing a nested quantifier with a positive lookahead assertion. The output from the example displays the execution time of the method. - + [!code-vb[Conceptual.RegularExpressions.Backtracking#5](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking5.vb#5)] + + The first regular expression pattern, `^[0-9A-Z]([-.\w]*[0-9A-Z])*@`, is defined as shown in the following table. + +|Pattern|Description| +|-------------|-----------------| +|`^`|Start the match at the beginning of the string.| +|`[0-9A-Z]`|Match an alphanumeric character. This comparison is case-insensitive, because the method is called with the option.| +|`[-.\w]*`|Match zero, one, or more occurrences of a hyphen, period, or word character.| +|`[0-9A-Z]`|Match an alphanumeric character.| +|`([-.\w]*[0-9A-Z])*`|Match zero or more occurrences of the combination of zero or more hyphens, periods, or word characters, followed by an alphanumeric character. This is the first capturing group.| +|`@`|Match an at sign ("\@").| + + The second regular expression pattern, `^[0-9A-Z][-.\w]*(?<=[0-9A-Z])@`, uses a positive lookbehind assertion. It is defined as shown in the following table. + +|Pattern|Description| +|-------------|-----------------| +|`^`|Start the match at the beginning of the string.| +|`[0-9A-Z]`|Match an alphanumeric character. This comparison is case-insensitive, because the method is called with the option.| +|`[-.\w]*`|Match zero or more occurrences of a hyphen, period, or word character.| +|`(?<=[0-9A-Z])`|Look back at the last matched character and continue the match if it is alphanumeric. Note that alphanumeric characters are a subset of the set that consists of periods, hyphens, and all word characters.| +|`@`|Match an at sign ("\@").| + +### Lookahead Assertions + + .NET includes two language elements, `(?=`*subexpression*`)` and `(?!`*subexpression*`)`, that match the next character or characters in the input string. Both language elements are zero-width assertions; that is, they determine whether the character or characters that immediately follow the current character can be matched by *subexpression*, without advancing or backtracking. + + `(?=` *subexpression* `)` is a positive lookahead assertion; that is, the character or characters after the current position must match *subexpression*. `(?!`*subexpression*`)` is a negative lookahead assertion; that is, the character or characters after the current position must not match *subexpression*. Both positive and negative lookahead assertions are most useful when *subexpression* is a subset of the next subexpression. + + The following example uses two equivalent regular expression patterns that validate a fully qualified type name. The first pattern is subject to poor performance because of excessive backtracking. The second modifies the first regular expression by replacing a nested quantifier with a positive lookahead assertion. The output from the example displays the execution time of the method. + [!code-csharp[Conceptual.RegularExpressions.Backtracking#6](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/cs/backtracking6.cs#6)] - [!code-vb[Conceptual.RegularExpressions.Backtracking#6](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking6.vb#6)] - - The first regular expression pattern, `^(([A-Z]\w*)+\.)*[A-Z]\w*$`, is defined as shown in the following table. - -|Pattern|Description| -|-------------|-----------------| -|`^`|Start the match at the beginning of the string.| -|`([A-Z]\w*)+\.`|Match an alphabetical character (A-Z) followed by zero or more word characters one or more times, followed by a period. This comparison is case-insensitive, because the method is called with the option.| -|`(([A-Z]\w*)+\.)*`|Match the previous pattern zero or more times.| -|`[A-Z]\w*`|Match an alphabetical character followed by zero or more word characters.| -|`$`|End the match at the end of the input string.| - - The second regular expression pattern, `^((?=[A-Z])\w+\.)*[A-Z]\w*$`, uses a positive lookahead assertion. It is defined as shown in the following table. - -|Pattern|Description| -|-------------|-----------------| -|`^`|Start the match at the beginning of the string.| -|`(?=[A-Z])`|Look ahead to the first character and continue the match if it is alphabetical (A-Z). This comparison is case-insensitive, because the method is called with the option.| -|`\w+\.`|Match one or more word characters followed by a period.| -|`((?=[A-Z])\w+\.)*`|Match the pattern of one or more word characters followed by a period zero or more times. The initial word character must be alphabetical.| -|`[A-Z]\w*`|Match an alphabetical character followed by zero or more word characters.| -|`$`|End the match at the end of the input string.| - + [!code-vb[Conceptual.RegularExpressions.Backtracking#6](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regularexpressions.backtracking/vb/backtracking6.vb#6)] + + The first regular expression pattern, `^(([A-Z]\w*)+\.)*[A-Z]\w*$`, is defined as shown in the following table. + +|Pattern|Description| +|-------------|-----------------| +|`^`|Start the match at the beginning of the string.| +|`([A-Z]\w*)+\.`|Match an alphabetical character (A-Z) followed by zero or more word characters one or more times, followed by a period. This comparison is case-insensitive, because the method is called with the option.| +|`(([A-Z]\w*)+\.)*`|Match the previous pattern zero or more times.| +|`[A-Z]\w*`|Match an alphabetical character followed by zero or more word characters.| +|`$`|End the match at the end of the input string.| + + The second regular expression pattern, `^((?=[A-Z])\w+\.)*[A-Z]\w*$`, uses a positive lookahead assertion. It is defined as shown in the following table. + +|Pattern|Description| +|-------------|-----------------| +|`^`|Start the match at the beginning of the string.| +|`(?=[A-Z])`|Look ahead to the first character and continue the match if it is alphabetical (A-Z). This comparison is case-insensitive, because the method is called with the option.| +|`\w+\.`|Match one or more word characters followed by a period.| +|`((?=[A-Z])\w+\.)*`|Match the pattern of one or more word characters followed by a period zero or more times. The initial word character must be alphabetical.| +|`[A-Z]\w*`|Match an alphabetical character followed by zero or more word characters.| +|`$`|End the match at the end of the input string.| + ## See also - [.NET Regular Expressions](regular-expressions.md) diff --git a/docs/standard/base-types/changing-case.md b/docs/standard/base-types/changing-case.md index f3917bae6ee00..109bf81b946c8 100644 --- a/docs/standard/base-types/changing-case.md +++ b/docs/standard/base-types/changing-case.md @@ -26,15 +26,13 @@ If you write an application that accepts input from a user, you can never be sur | | Converts a string to title case. | > [!WARNING] -> Note that the and methods should not be used to convert strings in order to compare them or test them for equality. For more information, see the [Comparing strings of mixed case](#Comparing) section. - - +> The and methods should not be used to convert strings in order to compare them or test them for equality. For more information, see the [Compare strings of mixed case](#compare-strings-of-mixed-case) section. ## Compare strings of mixed case To compare strings of mixed case to determine their ordering, call one of the overloads of the method with a `comparisonType` parameter, and provide a value of either , , or for the `comparisonType` argument. For a comparison using a specific culture other than the current culture, call an overload of the method with both a `culture` and `options` parameter, and provide a value of as the `options` argument. -To compare strings of mixed case to determine whether they are equal, their, call one of the overloads of the method with a `comparisonType` parameter, and provide a value of either , , or for the `comparisonType` argument. +To compare strings of mixed case to determine whether they're equal, call one of the overloads of the method with a `comparisonType` parameter, and provide a value of either , , or for the `comparisonType` argument. For more information, see [Best practices for using strings](best-practices-strings.md). @@ -45,7 +43,7 @@ The method changes [!code-csharp[Strings.ChangingCase#1](../../../samples/snippets/csharp/VS_Snippets_CLR/Strings.ChangingCase/cs/Example.cs#1)] [!code-vb[Strings.ChangingCase#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/Strings.ChangingCase/vb/Example.vb#1)] -The preceding example is culture-sensitive by default; it applies the casing conventions of the current culture. To perform a culture-insensitive case change or to apply the casing conventions of a particular culture, use the method overload and supply a value of or a object that represents the specified culture to the _culture_ parameter. For an example that demonstrates how to use the method to perform a culture-insensitive case change, see [Perform culture-insensitive case changes](../../core/extensions/performing-culture-insensitive-case-changes.md). +The preceding example is culture-sensitive by default; it applies the casing conventions of the current culture. To perform a culture-insensitive case change or to apply the casing conventions of a particular culture, use the method overload and supply a value of or a object that represents the specified culture to the `culture` parameter. For an example that demonstrates how to use the method to perform a culture-insensitive case change, see [Perform culture-insensitive case changes](../../core/extensions/performing-culture-insensitive-case-changes.md). ## `ToLower` method @@ -54,7 +52,7 @@ The method is simil [!code-csharp[Strings.ChangingCase#2](../../../samples/snippets/csharp/VS_Snippets_CLR/Strings.ChangingCase/cs/Example.cs#2)] [!code-vb[Strings.ChangingCase#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/Strings.ChangingCase/vb/Example.vb#2)] -The preceding example is culture-sensitive by default; it applies the casing conventions of the current culture. To perform a culture-insensitive case change or to apply the casing conventions of a particular culture, use the method overload and supply a value of or a object that represents the specified culture to the _culture_ parameter. For an example that demonstrates how to use the method to perform a culture-insensitive case change, see [Perform culture-insensitive case changes](../../core/extensions/performing-culture-insensitive-case-changes.md). +The preceding example is culture-sensitive by default; it applies the casing conventions of the current culture. To perform a culture-insensitive case change or to apply the casing conventions of a particular culture, use the method overload and supply a value of or a object that represents the specified culture to the `culture` parameter. For an example that demonstrates how to use the method to perform a culture-insensitive case change, see [Perform culture-insensitive case changes](../../core/extensions/performing-culture-insensitive-case-changes.md). ## `ToTitleCase` method diff --git a/docs/standard/base-types/character-classes-in-regular-expressions.md b/docs/standard/base-types/character-classes-in-regular-expressions.md index ad8a40d86fbc3..93c42306d23e0 100644 --- a/docs/standard/base-types/character-classes-in-regular-expressions.md +++ b/docs/standard/base-types/character-classes-in-regular-expressions.md @@ -396,7 +396,7 @@ where *firstCharacter* is the character that begins the range and *lastCharacter ## Supported Unicode general categories - Unicode defines the general categories listed in the following table. For more information, see the "UCD File Format" and "General Category Values" subtopics at the [Unicode Character Database](https://www.unicode.org/reports/tr44/). + Unicode defines the general categories listed in the following table. For more information, see the "UCD File Format" and "General Category Values" subtopics at the [Unicode Character Database](https://www.unicode.org/reports/tr44/), Sec. 5.7.1, Table 12. |Category|Description| |--------------|-----------------| @@ -409,7 +409,7 @@ where *firstCharacter* is the character that begins the range and *lastCharacter |`Mn`|Mark, Nonspacing| |`Mc`|Mark, Spacing Combining| |`Me`|Mark, Enclosing| -|`M`|All diacritic marks. This includes the `Mn`, `Mc`, and `Me` categories.| +|`M`|All combining marks. This includes the `Mn`, `Mc`, and `Me` categories.| |`Nd`|Number, Decimal Digit| |`Nl`|Number, Letter| |`No`|Number, Other| @@ -435,8 +435,8 @@ where *firstCharacter* is the character that begins the range and *lastCharacter |`Cf`|Other, Format| |`Cs`|Other, Surrogate| |`Co`|Other, Private Use| -|`Cn`|Other, Not Assigned (no characters have this property)| -|`C`|All control characters. This includes the `Cc`, `Cf`, `Cs`, `Co`, and `Cn` categories.| +|`Cn`|Other, Not Assigned or Noncharacter| +|`C`|All other characters. This includes the `Cc`, `Cf`, `Cs`, `Co`, and `Cn` categories.| You can determine the Unicode category of any particular character by passing that character to the method. The following example uses the method to determine the category of each element in an array that contains selected Latin characters. diff --git a/docs/standard/base-types/custom-date-and-time-format-strings.md b/docs/standard/base-types/custom-date-and-time-format-strings.md index 3dd4221ac4872..b8bdc92b455d8 100644 --- a/docs/standard/base-types/custom-date-and-time-format-strings.md +++ b/docs/standard/base-types/custom-date-and-time-format-strings.md @@ -1,7 +1,7 @@ --- title: "Custom date and time format strings" description: Learn to use custom date and time format strings to convert DateTime or DateTimeOffset values into text representations, or to parse strings for dates & times. -ms.date: "03/30/2017" +ms.date: 05/12/2022 ms.topic: reference dev_langs: - "csharp" @@ -356,7 +356,7 @@ The following example includes the "HH" custom format specifier in a custom form The "K" custom format specifier represents the time zone information of a date and time value. When this format specifier is used with values, the result string is defined by the value of the property: -- For the local time zone (a property value of ), this specifier is equivalent to the "zzz" specifier and produces a result string containing the local offset from Coordinated Universal Time (UTC); for example, "-07:00". +- For the local time zone (a property value of ), this specifier produces a result string containing the local offset from Coordinated Universal Time (UTC); for example, "-07:00". - For a UTC time (a property value of ), the result string includes a "Z" character to represent a UTC date. @@ -577,11 +577,17 @@ The following example includes the "yyyyy" custom format specifier in a custom f ### The "z" custom format specifier -With values, the "z" custom format specifier represents the signed offset of the local operating system's time zone from Coordinated Universal Time (UTC), measured in hours. It doesn't reflect the value of an instance's property. For this reason, the "z" format specifier is not recommended for use with values. +With values, the "z" custom format specifier represents the signed offset of the specified time zone from Coordinated Universal Time (UTC), measured in hours. The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted *without* a leading zero. -With values, this format specifier represents the value's offset from UTC in hours. +The following table shows how the offset value changes depending on . + +| value | Offset value | +| - | - | +| | The signed offset of the local operating system's time zone from UTC. | +| | The signed offset of the local operating system's time zone from UTC. | +| | `+0` on .NET Core and .NET 5+.

On .NET Framework, the signed offset of the local operating system's time zone from UTC. | -The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted without a leading zero. +With values, this format specifier represents the value's offset from UTC in hours. If the "z" format specifier is used without other custom format specifiers, it's interpreted as a standard date and time format specifier and throws a . For more information about using a single format specifier, see [Using Single Custom Format Specifiers](#UsingSingleSpecifiers) later in this article. @@ -594,11 +600,17 @@ The following example includes the "z" custom format specifier in a custom forma ### The "zz" custom format specifier -With values, the "zz" custom format specifier represents the signed offset of the local operating system's time zone from UTC, measured in hours. It doesn't reflect the value of an instance's property. For this reason, the "zz" format specifier is not recommended for use with values. +With values, the "zz" custom format specifier represents the signed offset of the specified time zone from UTC, measured in hours. The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted *with* a leading zero. -With values, this format specifier represents the value's offset from UTC in hours. +The following table shows how the offset value changes depending on . -The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted with a leading zero. +| value | Offset value | +| - | - | +| | The signed offset of the local operating system's time zone from UTC. | +| | The signed offset of the local operating system's time zone from UTC. | +| | `+00` on .NET Core and .NET 5+.

On .NET Framework, the signed offset of the local operating system's time zone from UTC. | + +With values, this format specifier represents the value's offset from UTC in hours. The following example includes the "zz" custom format specifier in a custom format string. @@ -609,11 +621,17 @@ The following example includes the "zz" custom format specifier in a custom form ### The "zzz" custom format specifier -With values, the "zzz" custom format specifier represents the signed offset of the local operating system's time zone from UTC, measured in hours and minutes. It doesn't reflect the value of an instance's property. For this reason, the "zzz" format specifier is not recommended for use with values. +With values, the "zzz" custom format specifier represents the signed offset of the specified time zone from UTC, measured in hours and minutes. The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted with a leading zero. -With values, this format specifier represents the value's offset from UTC in hours and minutes. +The following table shows how the offset value changes depending on . -The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted with a leading zero. +| value | Offset value | +| - | - | +| | The signed offset of the local operating system's time zone from UTC. | +| | The signed offset of the local operating system's time zone from UTC. | +| | `+00:00` on .NET Core and .NET 5+.

On .NET Framework, the signed offset of the local operating system's time zone from UTC. | + +With values, this format specifier represents the value's offset from UTC in hours and minutes. The following example includes the "zzz" custom format specifier in a custom format string. @@ -695,7 +713,7 @@ The following example includes the literal characters "pst" (for Pacific Standar ### Using single custom format specifiers -A custom date and time format string consists of two or more characters. Date and time formatting methods interpret any single-character string as a standard date and time format string. If they don't recognize the character as a valid format specifier, they throw a . For example, a format string that consists only of the specifier "h" is interpreted as a standard date and time format string. However, in this particular case, an exception is thrown because there is no "h" standard date and timeformat specifier. +A custom date and time format string consists of two or more characters. Date and time formatting methods interpret any single-character string as a standard date and time format string. If they don't recognize the character as a valid format specifier, they throw a . For example, a format string that consists only of the specifier "h" is interpreted as a standard date and time format string. However, in this particular case, an exception is thrown because there is no "h" standard date and time format specifier. To use any of the custom date and time format specifiers as the only specifier in a format string (that is, to use the "d", "f", "F", "g", "h", "H", "K", "m", "M", "s", "t", "y", "z", ":", or "/" custom format specifier by itself), include a space before or after the specifier, or include a percent ("%") format specifier before the single custom date and time specifier. diff --git a/docs/standard/base-types/regular-expression-language-quick-reference.md b/docs/standard/base-types/regular-expression-language-quick-reference.md index bd75a0b87c2e0..ea62f2b29a235 100644 --- a/docs/standard/base-types/regular-expression-language-quick-reference.md +++ b/docs/standard/base-types/regular-expression-language-quick-reference.md @@ -77,7 +77,7 @@ Anchors, or atomic zero-width assertions, cause a match to succeed or fail depen |`\A`|The match must occur at the start of the string.|`\A\d{3}`|`"901"` in `"901-333-"`| |`\Z`|The match must occur at the end of the string or before `\n` at the end of the string.|`-\d{3}\Z`|`"-333"` in `"-901-333"`| |`\z`|The match must occur at the end of the string.|`-\d{3}\z`|`"-333"` in `"-901-333"`| -|`\G`|The match must occur at the point where the previous match ended.|`\G\(\d\)`|`"(1)"`, `"(3)"`, `"(5)"` in `"(1)(3)(5)[7](9)"`| +|`\G`|The match must occur at the point where the previous match ended, or if there was no previous match, at the position in the string where matching started.|`\G\(\d\)`|`"(1)"`, `"(3)"`, `"(5)"` in `"(1)(3)(5)[7](9)"`| |`\b`|The match must occur on a boundary between a `\w` (alphanumeric) and a `\W` (nonalphanumeric) character.|`\b\w+\s\w+\b`|`"them theme"`, `"them them"` in `"them theme them them"`| |`\B`|The match must not occur on a `\b` boundary.|`\Bend\w*\b`|`"ends"`, `"ender"` in `"end sends endure lender"`| diff --git a/docs/standard/base-types/regular-expression-options.md b/docs/standard/base-types/regular-expression-options.md index 2ec8cbb42e123..6efd6eb59b593 100644 --- a/docs/standard/base-types/regular-expression-options.md +++ b/docs/standard/base-types/regular-expression-options.md @@ -1,7 +1,7 @@ --- -title: "Regular Expression Options" +title: Options for regular expression description: Learn how to use regular expression options in .NET, such as case-insensitive matching, multiline mode, and right-to-left mode. -ms.date: "03/30/2017" +ms.date: 06/02/2022 dev_langs: - "csharp" - "vb" @@ -11,12 +11,11 @@ helpviewer_keywords: - ".NET regular expressions, options" - "inline option constructs" - "options parameter" -ms.assetid: c82dc689-7e82-4767-a18d-cd24ce5f05e9 --- -# Regular Expression Options +# Regular expression options -By default, the comparison of an input string with any literal characters in a regular expression pattern is case sensitive, white space in a regular expression pattern is interpreted as literal white-space characters, and capturing groups in a regular expression are named implicitly as well as explicitly. You can modify these and several other aspects of default regular expression behavior by specifying regular expression options. These options, which are listed in the following table, can be included inline as part of the regular expression pattern, or they can be supplied to a class constructor or static pattern matching method as a enumeration value. +By default, the comparison of an input string with any literal characters in a regular expression pattern is case sensitive, white space in a regular expression pattern is interpreted as literal white-space characters, and capturing groups in a regular expression are named implicitly as well as explicitly. You can modify these and several other aspects of default regular expression behavior by specifying regular expression options. Some of these options, which are listed in the following table, can be included inline as part of the regular expression pattern, or they can be supplied to a class constructor or static pattern matching method as a enumeration value. |RegexOptions member|Inline character|Effect| |-------------------------|----------------------|------------| @@ -29,9 +28,10 @@ By default, the comparison of an input string with any literal characters in a r ||`x`|Exclude unescaped white space from the pattern, and enable comments after a number sign (`#`). For more information, see [Ignore White Space](#ignore-white-space).| ||Not available|Change the search direction. Search moves from right to left instead of from left to right. For more information, see [Right-to-Left Mode](#right-to-left-mode).| ||Not available|Enable ECMAScript-compliant behavior for the expression. For more information, see [ECMAScript Matching Behavior](#ecmascript-matching-behavior).| -||Not available|Ignore cultural differences in language. For more information, see [Comparison Using the Invariant Culture](#comparison-using-the-invariant-culture).| +||Not available|Ignore cultural differences in language. For more information, see [Comparison Using the Invariant Culture](#compare-using-the-invariant-culture).| +||Not available|Match using an approach that avoids backtracking and guarantees linear-time processing in the length of the input. (Available in .NET 7 and later versions.)| -## Specifying the Options +## Specify options You can specify options for regular expressions in one of three ways: @@ -87,7 +87,7 @@ The following five regular expression options can be set using the `options` par - -## Determining the Options +## Determine options You can determine which options were provided to a object when it was instantiated by retrieving the value of the read-only property. This property is particularly useful for determining the options that are defined for a compiled regular expression created by the method. @@ -103,7 +103,7 @@ To test for option indicates that no options have been specified, and the regular expression engine uses its default behavior. This includes the following: @@ -128,7 +128,7 @@ The option represents the default behavior of the regular expression engine, it is rarely explicitly specified in a method call. A constructor or static pattern-matching method without an `options` parameter is called instead. -## Case-Insensitive Matching +## Case-insensitive matching The option, or the `i` inline option, provides case-insensitive matching. By default, the casing conventions of the current culture are used. @@ -142,7 +142,7 @@ The following example modifies the regular expression pattern from the previous [!code-csharp[Conceptual.Regex.Language.Options#2](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/case2.cs#2)] [!code-vb[Conceptual.Regex.Language.Options#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regex.language.options/vb/case2.vb#2)] -## Multiline Mode +## Multiline mode The option, or the `m` inline option, enables the regular expression engine to handle an input string that consists of multiple lines. It changes the interpretation of the `^` and `$` language elements so that they match the beginning and end of a line, instead of the beginning and end of the input string. @@ -169,7 +169,7 @@ The following example is equivalent to the previous one, except that it uses the [!code-csharp[Conceptual.Regex.Language.Options#4](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline2.cs#4)] [!code-vb[Conceptual.Regex.Language.Options#4](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regex.language.options/vb/multiline2.vb#4)] -## Single-line Mode +## Single-line mode The option, or the `s` inline option, causes the regular expression engine to treat the input string as if it consists of a single line. It does this by changing the behavior of the period (`.`) language element so that it matches every character, instead of matching every character except for the newline character `\n` or `\u000A`. @@ -185,7 +185,7 @@ The following example is equivalent to the previous one, except that it uses the [!code-csharp[Conceptual.Regex.Language.Options#5](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/singleline1.cs#5)] [!code-vb[Conceptual.Regex.Language.Options#5](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regex.language.options/vb/singleline1.vb#5)] -## Explicit Captures Only +## Explicit captures only By default, capturing groups are defined by the use of parentheses in the regular expression pattern. Named groups are assigned a name or number by the `(?<`*name*`>`*subexpression*`)` language option, whereas unnamed groups are accessible by index. In the object, unnamed groups precede named groups. @@ -223,7 +223,7 @@ Finally, you can use the inline group element `(?n:)` to suppress automatic capt [!code-csharp[Conceptual.Regex.Language.Options#11](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit3.cs#11)] [!code-vb[Conceptual.Regex.Language.Options#11](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regex.language.options/vb/explicit3.vb#11)] -## Compiled Regular Expressions +## Compiled regular expressions By default, regular expressions in .NET are interpreted. When a object is instantiated or a static method is called, the regular expression pattern is parsed into a set of custom opcodes, and an interpreter uses these opcodes to run the regular expression. This involves a tradeoff: The cost of initializing the regular expression engine is minimized at the expense of run-time performance. @@ -245,7 +245,7 @@ However, this improvement in performance occurs only under the following conditi > [!NOTE] > The option is unrelated to the method, which creates a special-purpose assembly that contains predefined compiled regular expressions. -## Ignore White Space +## Ignore white space By default, white space in a regular expression pattern is significant; it forces the regular expression engine to match a white-space character in the input string. Because of this, the regular expression "`\b\w+\s`" and "`\b\w+` " are roughly equivalent regular expressions. In addition, when the number sign (#) is encountered in a regular expression pattern, it is interpreted as a literal character to be matched. @@ -283,34 +283,47 @@ The following example uses the inline option `(?x)` to ignore pattern white spac [!code-csharp[Conceptual.Regex.Language.Options#13](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace2.cs#13)] [!code-vb[Conceptual.Regex.Language.Options#13](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regex.language.options/vb/whitespace2.vb#13)] -## Right-to-Left Mode +## Right-to-left mode -By default, the regular expression engine searches from left to right. You can reverse the search direction by using the option. The search automatically begins at the last character position of the string. For pattern-matching methods that include a starting position parameter, such as , the starting position is the index of the rightmost character position at which the search is to begin. +By default, the regular expression engine searches from left to right. You can reverse the search direction by using the option. The right-to-left search automatically begins at the last character position of the string. For pattern-matching methods that include a starting position parameter, such as , the specified starting position is the index of the rightmost character position at which the search is to begin. > [!NOTE] > Right-to-left pattern mode is available only by supplying the value to the `options` parameter of a class constructor or static pattern-matching method. It is not available as an inline option. -The option changes the search direction only; it does not interpret the regular expression pattern from right to left. For example, the regular expression `\bb\w+\s` matches words that begin with the letter "b" and are followed by a white-space character. In the following example, the input string consists of three words that include one or more "b" characters. The first word begins with "b", the second ends with "b", and the third includes two "b" characters in the middle of the word. As the output from the example shows, only the first word matches the regular expression pattern. +### Example + +The regular expression `\bb\w+\s` matches words with two or more characters that begin with the letter "b" and are followed by a white-space character. In the following example, the input string consists of three words that include one or more "b" characters. The first and second words begin with "b" and the third word ends with "b". As the output from the right-to-left search example shows, only the first and second words match the regular expression pattern, with the second word being matched first. [!code-csharp[Conceptual.Regex.Language.Options#17](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft1.cs#17)] [!code-vb[Conceptual.Regex.Language.Options#17](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regex.language.options/vb/righttoleft1.vb#17)] -Also note that the lookahead assertion (the `(?=`*subexpression*`)` language element) and the lookbehind assertion (the `(?<=`*subexpression*`)` language element) do not change direction. The lookahead assertions look to the right; the lookbehind assertions look to the left. For example, the regular expression `(?<=\d{1,2}\s)\w+,?\s\d{4}` uses the lookbehind assertion to test for a date that precedes a month name. The regular expression then matches the month and the year. For information on lookahead and lookbehind assertions, see [Grouping Constructs](grouping-constructs-in-regular-expressions.md). +### Evaluation order + +The option changes the search direction and also reverses the order in which the regular expression pattern is evaluated. In a right-to-left search, the search pattern is read from right to left. This distinction is important because it can affect things like capture groups and [backreferences](backreference-constructs-in-regular-expressions.md). For example, the expression `Regex.Match("abcabc", @"\1(abc)", RegexOptions.RightToLeft)` finds a match `abcabc`, but in a left-to-right search (`Regex.Match("abcabc", @"\1(abc)", RegexOptions.None)`), no match is found. That's because the `(abc)` element must be evaluated before the numbered capturing group element (`\1`) for a match to be found. + +### Lookahead and lookbehind assertions + +The location of a match for a lookahead (`(?=subexpression)`) or lookbehind (`(?<=subexpression)`) assertion doesn't change in a right-to-left search. The lookahead assertions look to the right of the current match location; the lookbehind assertions look to the left of the current match location. + +> [!TIP] +> Whether a search is right-to-left or not, lookbehinds are implemented using a right-to-left search starting at the current match location. + +For example, the regular expression `(?<=\d{1,2}\s)\w+,\s\d{4}` uses the lookbehind assertion to test for a date that precedes a month name. The regular expression then matches the month and the year. For information on lookahead and lookbehind assertions, see [Grouping Constructs](grouping-constructs-in-regular-expressions.md). [!code-csharp[Conceptual.Regex.Language.Options#18](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft2.cs#18)] [!code-vb[Conceptual.Regex.Language.Options#18](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.regex.language.options/vb/righttoleft2.vb#18)] The regular expression pattern is defined as shown in the following table. -|Pattern|Description| -|-------------|-----------------| -|`(?<=\d{1,2}\s)`|The beginning of the match must be preceded by one or two decimal digits followed by a space.| -|`\w+`|Match one or more word characters.| -|`,?`|Match zero or one comma characters.| -|`\s`|Match a white-space character.| -|`\d{4}`|Match four decimal digits.| +| Pattern | Description | +|------------------|-----------------------------------------------------------------------------------------------| +| `(?<=\d{1,2}\s)` | The beginning of the match must be preceded by one or two decimal digits followed by a space. | +| `\w+` | Match one or more word characters. | +| `,` | Match one comma character. | +| `\s` | Match a white-space character. | +| `\d{4}` | Match four decimal digits. | -## ECMAScript Matching Behavior +## ECMAScript matching behavior By default, the regular expression engine uses canonical behavior when matching a regular expression pattern to input text. However, you can instruct the regular expression engine to use ECMAScript matching behavior by specifying the option. @@ -350,7 +363,7 @@ The behavior of ECMAScript and canonical regular expressions differs in three ar |`\` followed by a digit from 1 to 9, followed by no additional decimal digits,|Interpret as a backreference. For example, `\9` always means backreference 9, even if a ninth capturing group does not exist. If the capturing group does not exist, the regular expression parser throws an .|If a single decimal digit capturing group exists, backreference to that digit. Otherwise, interpret the value as a literal.| |`\` followed by a digit from 1 to 9, followed by additional decimal digits|Interpret the digits as a decimal value. If that capturing group exists, interpret the expression as a backreference.

Otherwise, interpret the leading octal digits up to octal 377; that is, consider only the low 8 bits of the value. Interpret the remaining digits as literals. For example, in the expression `\3000`, if capturing group 300 exists, interpret as backreference 300; if capturing group 300 does not exist, interpret as octal 300 followed by 0.|Interpret as a backreference by converting as many digits as possible to a decimal value that can refer to a capture. If no digits can be converted, interpret as an octal by using the leading octal digits up to octal 377; interpret the remaining digits as literals.| -## Comparison Using the Invariant Culture +## Compare using the invariant culture By default, when the regular expression engine performs case-insensitive comparisons, it uses the casing conventions of the current culture to determine equivalent uppercase and lowercase characters. diff --git a/docs/standard/base-types/snippets/character-encoding-introduction/csharp/CountTextElements.cs b/docs/standard/base-types/snippets/character-encoding-introduction/csharp/CountTextElements.cs index ddf028e08f930..ae763538c512f 100644 --- a/docs/standard/base-types/snippets/character-encoding-introduction/csharp/CountTextElements.cs +++ b/docs/standard/base-types/snippets/character-encoding-introduction/csharp/CountTextElements.cs @@ -9,7 +9,7 @@ partial class CountTextElements public static void Run() { // - PrintTextElementCount("á"); + PrintTextElementCount("a"); // Number of chars: 1 // Number of runes: 1 // Number of text elements: 1 @@ -41,8 +41,8 @@ static void PrintTextElementCount(string s) } Console.WriteLine($"Number of text elements: {textElementCount}"); - // } + // } } } diff --git a/docs/standard/base-types/standard-numeric-format-strings.md b/docs/standard/base-types/standard-numeric-format-strings.md index 0c68e57fcb32c..3800f556da8cb 100644 --- a/docs/standard/base-types/standard-numeric-format-strings.md +++ b/docs/standard/base-types/standard-numeric-format-strings.md @@ -283,7 +283,7 @@ The following example formats floating-point values with the percent format spec The round-trip ("R") format specifier attempts to ensure that a numeric value that is converted to a string is parsed back into the same numeric value. This format is supported only for the , , , and types. -For values, the "R" format specifier in some cases fails to successfully round-trip the original value. For both and values, it also offers relatively poor performance. Instead, we recommend that you use the ["G17"](#GFormatString) format specifier for values and the ["G9"](#GFormatString) format specifier to successfully round-trip values. +In .NET Framework and in .NET Core versions earlier than 3.0, the "R" format specifier fails to successfully round-trip values in some cases. For both and values, the "R" format specifier offers relatively poor performance. Instead, we recommend that you use the ["G17"](#GFormatString) format specifier for values and the ["G9"](#GFormatString) format specifier to successfully round-trip values. When a value is formatted using this specifier, its string representation contains all the significant digits in the value. diff --git a/docs/standard/choosing-core-framework-server.md b/docs/standard/choosing-core-framework-server.md index 60ce47299586e..b08e0a36f668a 100644 --- a/docs/standard/choosing-core-framework-server.md +++ b/docs/standard/choosing-core-framework-server.md @@ -87,8 +87,6 @@ Some .NET Framework technologies aren't available in .NET. The following list sh - ASP.NET Web Pages applications: ASP.NET Web Pages aren't included in ASP.NET Core. -- WCF services implementation. Even when there's a [WCF client library](https://github.com/dotnet/wcf) to consume WCF services from .NET, WCF server implementation is currently only available in .NET Framework. - - Workflow-related services: Windows Workflow Foundation (WF), Workflow Services (WCF + WF in a single service), and WCF Data Services (formerly known as "ADO.NET Data Services") are only available in .NET Framework. - Language support: Visual Basic and F# are currently supported in .NET, but not for all project types. For a list of supported project templates, see [Template options for dotnet new](../core/tools/dotnet-new.md#arguments). diff --git a/docs/standard/commandline/define-commands.md b/docs/standard/commandline/define-commands.md index dcf8fda205725..7f74ed8f56665 100644 --- a/docs/standard/commandline/define-commands.md +++ b/docs/standard/commandline/define-commands.md @@ -210,7 +210,7 @@ Options: ## Option and argument validation -For information about argument validation and how to customize it, see the following sections in the [Model binding](model-binding.md) article: +For information about argument validation and how to customize it, see the following sections in the [Parameter binding](model-binding.md) article: * [Built-in type and arity argument validation](model-binding.md#built-in-argument-validation) * [Custom validation and binding](model-binding.md#custom-validation-and-binding) @@ -218,4 +218,4 @@ For information about argument validation and how to customize it, see the follo ## See also * [System.CommandLine overview](index.md) -* [Model binding](model-binding.md) +* [Parameter binding](model-binding.md) diff --git a/docs/standard/commandline/dependency-injection.md b/docs/standard/commandline/dependency-injection.md index e0007a478eb35..ef4b3d9134829 100644 --- a/docs/standard/commandline/dependency-injection.md +++ b/docs/standard/commandline/dependency-injection.md @@ -1,7 +1,7 @@ --- title: How to configure dependency injection in System.CommandLine description: "Learn how to configure dependency injection in System.CommandLine." -ms.date: 04/07/2022 +ms.date: 05/22/2022 no-loc: [System.CommandLine] helpviewer_keywords: - "command line interface" @@ -13,7 +13,7 @@ ms.topic: how-to [!INCLUDE [scl-preview](../../../includes/scl-preview.md)] -Use a [custom binder](model-binding.md#model-binding-more-than-16-options-and-arguments) to inject custom types into a command handler. +Use a [custom binder](model-binding.md#parameter-binding-more-than-8-options-and-arguments) to inject custom types into a command handler. We recommend handler-specific dependency injection (DI) for the following reasons: diff --git a/docs/standard/commandline/get-started-tutorial.md b/docs/standard/commandline/get-started-tutorial.md index 6c1f0b01331ce..a82a294d530f5 100644 --- a/docs/standard/commandline/get-started-tutorial.md +++ b/docs/standard/commandline/get-started-tutorial.md @@ -390,7 +390,7 @@ Build the project, and then try the following commands. Submit a nonexistent file to `--file` with the `read` command, and you get an error message instead of an exception and stack trace: ```console -scl read --file nofile +scl quotes read --file nofile ``` ```output diff --git a/docs/standard/commandline/handle-termination.md b/docs/standard/commandline/handle-termination.md index c0fe0726e8f8f..f6852215ac308 100644 --- a/docs/standard/commandline/handle-termination.md +++ b/docs/standard/commandline/handle-termination.md @@ -1,7 +1,7 @@ --- title: How to handle termination in System.CommandLine description: "Learn how to handle termination in apps that are built with the System.Commandline library." -ms.date: 04/07/2022 +ms.date: 05/24/2022 no-loc: [System.CommandLine] helpviewer_keywords: - "command line interface" @@ -17,6 +17,8 @@ To handle termination, inject a instan :::code language="csharp" source="snippets/handle-termination/csharp/Program.cs" id="mainandhandler" ::: +The preceding code uses a `SetHandler` overload that gets an [InvocationContext](model-binding.md#invocationcontext) instance rather than one or more `IValueDescriptor` objects. The `InvocationContext` is used to get the `CancellationToken` and [ParseResult](model-binding.md#parseresult) objects. `ParseResult` can provide argument or option values. + Cancellation actions can also be added directly using the method. For information about an alternative way to set the process exit code, see [Set exit codes](model-binding.md#set-exit-codes). diff --git a/docs/standard/commandline/model-binding.md b/docs/standard/commandline/model-binding.md index c3b1b963ca076..da25dc50a5741 100644 --- a/docs/standard/commandline/model-binding.md +++ b/docs/standard/commandline/model-binding.md @@ -1,7 +1,7 @@ --- title: How to bind arguments to handlers in System.CommandLine description: "Learn how to do model-binding in apps that are built with the System.Commandline library." -ms.date: 04/07/2022 +ms.date: 05/24/2022 no-loc: [System.CommandLine] helpviewer_keywords: - "command line interface" @@ -13,7 +13,7 @@ ms.topic: how-to [!INCLUDE [scl-preview](../../../includes/scl-preview.md)] -The process of parsing arguments and providing them to command handler code is called *model binding*. `System.CommandLine` has the ability to bind many argument types built in. For example, integers, enums, and file system objects such as and can be bound. Several `System.CommandLine` types can also be bound. +The process of parsing arguments and providing them to command handler code is called *parameter binding*. `System.CommandLine` has the ability to bind many argument types built in. For example, integers, enums, and file system objects such as and can be bound. Several `System.CommandLine` types can also be bound. ## Built-in argument validation @@ -45,7 +45,7 @@ This behavior can be overridden by setting : @@ -66,11 +66,19 @@ The variables that follow the lambda represent the option and argument objects t * If the out-of-order options or arguments are of different types, a run-time exception is thrown. For example, an `int` might appear where a `string` should be in the list of sources. * If the out-of-order options or arguments are of the same type, the handler silently gets the wrong values in the parameters provided to it. For example, `string` option `x` might appear where `string` option `y` should be in the list of sources. In that case, the variable for the option `y` value gets the option `x` value. -There are overloads of that support up to 16 parameters, with both synchronous and asynchronous signatures. +There are overloads of that support up to 8 parameters, with both synchronous and asynchronous signatures. -## Model binding more than 16 options and arguments +## Parameter binding more than 8 options and arguments -To handle more than 16 options, or to construct a custom type from multiple options, create a *custom binder*. The binder lets you combine multiple option or argument values into a complex type and pass that into a single handler parameter. Suppose you have a `Person` type: +To handle more than 8 options, or to construct a custom type from multiple options, you can use `InvocationContext` or a custom binder. + +### Use `InvocationContext` + +A overload provides access to the object, and you can use `InvocationContext` to get any number of option and argument values. For examples, see [Set exit codes](#set-exit-codes) and [Handle termination](handle-termination.md). + +### Use a custom binder + +A custom binder lets you combine multiple option or argument values into a complex type and pass that into a single handler parameter. Suppose you have a `Person` type: :::code language="csharp" source="snippets/model-binding/csharp/ComplexType.cs" id="persontype" ::: @@ -92,7 +100,7 @@ There are -returning [Func](xref:System.Func%6 :::code language="csharp" source="snippets/model-binding/csharp/ReturnExitCode.cs" id="returnexitcode" ::: -However, if the lambda itself needs to be async, you can't return a `Task`. In that case, use . You can get the `InvocationContext` instance injected into your lambda just by including it as one of the parameters, as in the following example: +However, if the lambda itself needs to be async, you can't return a `Task`. In that case, use . You can get the `InvocationContext` instance injected into your lambda by using a SetHandler overload that specifies the `InvocationContext` as the sole parameter. This `SetHandler` overload doesn't let you specify `IValueDescriptor` objects, but you can get option and argument values from the [ParseResult](#parseresult) property of `InvocationContext`, as shown in the following example: :::code language="csharp" source="snippets/model-binding/csharp/ContextExitCode.cs" id="contextexitcode" ::: @@ -181,16 +189,18 @@ Besides the file system types and `Uri`, the following types are supported: * `ulong` * `ushort` -## Inject System.CommandLine types +## Use System.CommandLine objects -`System.CommandLine` allows you to use some types in handlers by adding parameters for them to the handler signature. The available types include: +There's a `SetHandler` overload that gives you access to the object. That object can then be used to access other `System.CommandLine` objects. For example, you have access to the following objects: +* * * -* * -Other types can be injected by using custom binders. For more information, see [Dependency injection](dependency-injection.md). +### `InvocationContext` + +For examples, see [Set exit codes](#set-exit-codes) and [Handle termination](handle-termination.md). ### `CancellationToken` @@ -198,20 +208,16 @@ For information about how to use , see ### `IConsole` - makes testing as well as many extensibility scenarios easier than using `System.Console`. - -### `InvocationContext` - -For an example, see [Set exit codes](#set-exit-codes). + makes testing as well as many extensibility scenarios easier than using `System.Console`. It's available in the property. ### `ParseResult` - is a singleton structure that represents the results of parsing the command line input. You can use it to check for the presence of options or arguments on the command line or to get the property. This property contains a list of the [tokens](syntax.md#tokens) that were parsed but didn't match any configured command, option, or argument. +The object is available in the property. It's a singleton structure that represents the results of parsing the command line input. You can use it to check for the presence of options or arguments on the command line or to get the property. This property contains a list of the [tokens](syntax.md#tokens) that were parsed but didn't match any configured command, option, or argument. The list of unmatched tokens is useful in commands that behave like wrappers. A wrapper command takes a set of [tokens](syntax.md#tokens) and forwards them to another command or app. The `sudo` command in Linux is an example. It takes the name of a user to impersonate followed by a command to run. For example: ```console -sudo -u admin apt update +sudo -u admin apt update ``` This command line would run the `apt update` command as the user `admin`. diff --git a/docs/standard/commandline/snippets/customize-help/csharp/Program.cs b/docs/standard/commandline/snippets/customize-help/csharp/Program.cs index 40208d55422e6..848911cc9e190 100644 --- a/docs/standard/commandline/snippets/customize-help/csharp/Program.cs +++ b/docs/standard/commandline/snippets/customize-help/csharp/Program.cs @@ -37,8 +37,7 @@ static async Task Original(string[] args) foregroundColorOption }; - rootCommand.SetHandler( - (FileInfo file, bool lightMode, ConsoleColor color) => + rootCommand.SetHandler((file, lightMode, color) => { Console.BackgroundColor = lightMode ? ConsoleColor.White: ConsoleColor.Black; Console.ForegroundColor = color; @@ -77,8 +76,7 @@ static async Task First2Columns(string[] args) foregroundColorOption }; - rootCommand.SetHandler( - (FileInfo file, bool lightMode, ConsoleColor color) => + rootCommand.SetHandler((file, lightMode, color) => { Console.BackgroundColor = lightMode ? ConsoleColor.Black : ConsoleColor.White; Console.ForegroundColor = color; @@ -134,8 +132,7 @@ static async Task DescriptionSection(string[] args) foregroundColorOption }; - rootCommand.SetHandler( - (FileInfo file, bool lightMode, ConsoleColor color) => + rootCommand.SetHandler((file, lightMode, color) => { Console.BackgroundColor = lightMode ? ConsoleColor.Black : ConsoleColor.White; Console.ForegroundColor = color; diff --git a/docs/standard/commandline/snippets/customize-help/csharp/scl.csproj b/docs/standard/commandline/snippets/customize-help/csharp/scl.csproj index 3f1115d17e89e..4f7117d133d44 100644 --- a/docs/standard/commandline/snippets/customize-help/csharp/scl.csproj +++ b/docs/standard/commandline/snippets/customize-help/csharp/scl.csproj @@ -11,7 +11,7 @@ - + diff --git a/docs/standard/commandline/snippets/define-commands/csharp/Program2.cs b/docs/standard/commandline/snippets/define-commands/csharp/Program2.cs index 7a107d4dc8a4e..a4299fce16cf6 100644 --- a/docs/standard/commandline/snippets/define-commands/csharp/Program2.cs +++ b/docs/standard/commandline/snippets/define-commands/csharp/Program2.cs @@ -27,12 +27,12 @@ static async Task DefineArguments(string[] args) rootCommand.Add(delayArgument); rootCommand.Add(messageArgument); - rootCommand.SetHandler((int delayArgumentValue, string messageArgumentValue) => - { - Console.WriteLine($" argument = {delayArgumentValue}"); - Console.WriteLine($" argument = {messageArgumentValue}"); - }, - delayArgument, messageArgument); + rootCommand.SetHandler((delayArgumentValue, messageArgumentValue) => + { + Console.WriteLine($" argument = {delayArgumentValue}"); + Console.WriteLine($" argument = {messageArgumentValue}"); + }, + delayArgument, messageArgument); await rootCommand.InvokeAsync(args); // @@ -51,9 +51,9 @@ static async Task DefineCommands(string[] args) // sub1aCommand.SetHandler(() => - { - Console.WriteLine(sub1aCommand.Description); - }); + { + Console.WriteLine(sub1aCommand.Description); + }); await rootCommand.InvokeAsync(args); } @@ -72,12 +72,12 @@ static async Task DefineOptions(string[] args) rootCommand.Add(delayOption); rootCommand.Add(messageOption); - rootCommand.SetHandler((int delayOptionValue, string messageOptionValue) => - { - Console.WriteLine($"--delay = {delayOptionValue}"); - Console.WriteLine($"--message = {messageOptionValue}"); - }, - delayOption, messageOption); + rootCommand.SetHandler((delayOptionValue, messageOptionValue) => + { + Console.WriteLine($"--delay = {delayOptionValue}"); + Console.WriteLine($"--message = {messageOptionValue}"); + }, + delayOption, messageOption); // await rootCommand.InvokeAsync(args); @@ -103,11 +103,11 @@ static async Task GlobalOption(string[] args) var subCommand1a = new Command("sub1a", "Second level subcommand"); subCommand1.Add(subCommand1a); - subCommand1a.SetHandler((int delayOptionValue) => - { - Console.WriteLine($"--delay = {delayOptionValue}"); - }, - delayOption); + subCommand1a.SetHandler((delayOptionValue) => + { + Console.WriteLine($"--delay = {delayOptionValue}"); + }, + delayOption); await rootCommand.InvokeAsync(args); // @@ -125,12 +125,12 @@ static async Task RequiredOption(string[] args) var command = new RootCommand(); command.Add(endpointOption); - command.SetHandler( - (Uri? uri) => + command.SetHandler((uri) => { Console.WriteLine(uri?.GetType()); Console.WriteLine(uri?.ToString()); - }, endpointOption); + }, + endpointOption); await command.InvokeAsync(args); // @@ -145,12 +145,12 @@ static async Task HiddenOption(string[] args) var command = new RootCommand(); command.Add(endpointOption); - command.SetHandler( - (Uri? uri) => + command.SetHandler((uri) => { Console.WriteLine(uri?.GetType()); Console.WriteLine(uri?.ToString()); - }, endpointOption); + }, + endpointOption); await command.InvokeAsync(args); // @@ -177,11 +177,11 @@ static async Task FromAmong(string[] args) var rootCommand = new RootCommand("Static list example"); rootCommand.Add(languageOption); - rootCommand.SetHandler((string languageOptionValue) => - { - Console.WriteLine($"--language = {languageOptionValue}"); - }, - languageOption); + rootCommand.SetHandler((languageOptionValue) => + { + Console.WriteLine($"--language = {languageOptionValue}"); + }, + languageOption); await rootCommand.InvokeAsync(args); Console.WriteLine("Request help, provide a valid language, provide an invalid language."); diff --git a/docs/standard/commandline/snippets/define-commands/csharp/scl.csproj b/docs/standard/commandline/snippets/define-commands/csharp/scl.csproj index e0f014f1a3e32..8460bcc1462bf 100644 --- a/docs/standard/commandline/snippets/define-commands/csharp/scl.csproj +++ b/docs/standard/commandline/snippets/define-commands/csharp/scl.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/standard/commandline/snippets/dependency-injection/csharp/Program.cs b/docs/standard/commandline/snippets/dependency-injection/csharp/Program.cs index c3108a548aeb0..7c8533bf2d844 100644 --- a/docs/standard/commandline/snippets/dependency-injection/csharp/Program.cs +++ b/docs/standard/commandline/snippets/dependency-injection/csharp/Program.cs @@ -15,11 +15,11 @@ static async Task Main(string[] args) rootCommand.Add(fileOption); // - rootCommand.SetHandler(async (FileInfo fileOptionValue, ILogger logger) => - { - await DoRootCommand(fileOptionValue, logger); - }, - fileOption, new MyCustomBinder()); + rootCommand.SetHandler(async (fileOptionValue, logger) => + { + await DoRootCommand(fileOptionValue!, logger); + }, + fileOption, new MyCustomBinder()); // await rootCommand.InvokeAsync("--file scl.runtimeconfig.json"); @@ -40,7 +40,7 @@ protected override ILogger GetBoundValue( ILogger GetLogger(BindingContext bindingContext) { - var loggerFactory = LoggerFactory.Create( + ILoggerFactory loggerFactory = LoggerFactory.Create( builder => builder.AddConsole()); ILogger logger = loggerFactory.CreateLogger("LoggerCategory"); return logger; diff --git a/docs/standard/commandline/snippets/dependency-injection/csharp/scl.csproj b/docs/standard/commandline/snippets/dependency-injection/csharp/scl.csproj index e9388657730ea..0cc4630529b16 100644 --- a/docs/standard/commandline/snippets/dependency-injection/csharp/scl.csproj +++ b/docs/standard/commandline/snippets/dependency-injection/csharp/scl.csproj @@ -10,7 +10,7 @@ - + diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/Program.cs b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/Program.cs index 01513bcfd813a..10128ed253e7c 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/Program.cs +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/Program.cs @@ -17,11 +17,10 @@ static async Task Main(string[] args) // // - rootCommand.SetHandler( - (FileInfo file) => - { - ReadFile(file); - }, + rootCommand.SetHandler((file) => + { + ReadFile(file!); + }, fileOption); // diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/scl.csproj b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/scl.csproj index 4a5471f8dc29f..ac2f142320337 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/scl.csproj +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/scl.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Program.cs b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Program.cs index 3abcd329d26e3..196e7e8c10e43 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Program.cs +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Program.cs @@ -37,19 +37,18 @@ static int Main(string[] args) { fileOption, delayOption, - fgcolorOption, + fgcolorOption, lightModeOption }; rootCommand.AddCommand(readCommand); // // - readCommand.SetHandler(async - (FileInfo file, int delay, ConsoleColor fgcolor, bool lightMode) => - { - await ReadFile(file, delay, fgcolor, lightMode); - }, - fileOption, delayOption, fgcolorOption, lightModeOption); + readCommand.SetHandler(async (file, delay, fgcolor, lightMode) => + { + await ReadFile(file!, delay, fgcolor, lightMode); + }, + fileOption, delayOption, fgcolorOption, lightModeOption); // return rootCommand.InvokeAsync(args).Result; diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Properties/launchSettings.json b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Properties/launchSettings.json index c78d0b3e63eb5..77cd81d59d1f1 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Properties/launchSettings.json +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "scl": { "commandName": "Project", - "commandLineArgs": "read --file nofile" + "commandLineArgs": "read --file sampleQuotes.txt" } } -} \ No newline at end of file +} diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/scl.csproj b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/scl.csproj index 62e53967d5c91..84bd0d3e68274 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/scl.csproj +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/scl.csproj @@ -14,7 +14,7 @@ - + diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Program.cs b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Program.cs index 93f7fb0a0202e..3623ca0af4141 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Program.cs +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Program.cs @@ -19,7 +19,7 @@ static async Task Main(string[] args) return new FileInfo("sampleQuotes.txt"); } - var filePath = result.Tokens.Single().Value; + string? filePath = result.Tokens.Single().Value; if (!File.Exists(filePath)) { result.ErrorMessage = "File does not exist"; @@ -87,25 +87,22 @@ static async Task Main(string[] args) quotesCommand.AddCommand(addCommand); // - readCommand.SetHandler(async - (FileInfo file, int delay, ConsoleColor fgcolor, bool lightMode) => - { - await ReadFile(file, delay, fgcolor, lightMode); - }, - fileOption, delayOption, fgcolorOption, lightModeOption); + readCommand.SetHandler(async (file, delay, fgcolor, lightMode) => + { + await ReadFile(file!, delay, fgcolor, lightMode); + }, + fileOption, delayOption, fgcolorOption, lightModeOption); // - deleteCommand.SetHandler( - (FileInfo file, string[] searchTerms) => + deleteCommand.SetHandler((file, searchTerms) => { - DeleteFromFile(file, searchTerms); + DeleteFromFile(file!, searchTerms); }, fileOption, searchTermsOption); - addCommand.SetHandler( - (FileInfo file, string quote, string byline) => + addCommand.SetHandler((file, quote, byline) => { - AddToFile(file, quote, byline); + AddToFile(file!, quote, byline); }, fileOption, quoteArgument, bylineArgument); // @@ -137,7 +134,7 @@ internal static void DeleteFromFile(FileInfo file, string[] searchTerms) internal static void AddToFile(FileInfo file, string quote, string byline) { Console.WriteLine("Adding to file"); - using var writer = file.AppendText(); + using StreamWriter? writer = file.AppendText(); writer.WriteLine($"{Environment.NewLine}{Environment.NewLine}{quote}"); writer.WriteLine($"{Environment.NewLine}-{byline}"); writer.Flush(); diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Properties/launchSettings.json b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Properties/launchSettings.json index b04c9f9bcaf89..90f173acb47fb 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Properties/launchSettings.json +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "scl": { "commandName": "Project", - "commandLineArgs": "quotes" + "commandLineArgs": "quotes read --file sampleQuotes.txt" } } -} \ No newline at end of file +} diff --git a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/scl.csproj b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/scl.csproj index 5455045d667c5..d1152e4fe0d90 100644 --- a/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/scl.csproj +++ b/docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/scl.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/standard/commandline/snippets/handle-termination/csharp/Program.cs b/docs/standard/commandline/snippets/handle-termination/csharp/Program.cs index eb9be2079fcb3..547f2fba162b7 100644 --- a/docs/standard/commandline/snippets/handle-termination/csharp/Program.cs +++ b/docs/standard/commandline/snippets/handle-termination/csharp/Program.cs @@ -12,13 +12,12 @@ static async Task Main(string[] args) var rootCommand = new RootCommand("Handle termination example"); rootCommand.Add(urlOption); - rootCommand.SetHandler(async ( - string urlOptionValue, - CancellationToken token) => - { - returnCode = await DoRootCommand(urlOptionValue, token); - }, - urlOption); + rootCommand.SetHandler(async (context) => + { + string? urlOptionValue = context.ParseResult.GetValueForOption(urlOption); + var token = context.GetCancellationToken(); + returnCode = await DoRootCommand(urlOptionValue, token); + }); await rootCommand.InvokeAsync(args); @@ -26,7 +25,7 @@ static async Task Main(string[] args) } public static async Task DoRootCommand( - string urlOptionValue, CancellationToken cancellationToken) + string? urlOptionValue, CancellationToken cancellationToken) { try { diff --git a/docs/standard/commandline/snippets/handle-termination/csharp/scl.csproj b/docs/standard/commandline/snippets/handle-termination/csharp/scl.csproj index 1733b3d1aa9cf..d33a8a8394da9 100644 --- a/docs/standard/commandline/snippets/handle-termination/csharp/scl.csproj +++ b/docs/standard/commandline/snippets/handle-termination/csharp/scl.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/standard/commandline/snippets/model-binding/csharp/AddValidator.cs b/docs/standard/commandline/snippets/model-binding/csharp/AddValidator.cs index 9b4852a0f8835..d8c9f99a5db76 100644 --- a/docs/standard/commandline/snippets/model-binding/csharp/AddValidator.cs +++ b/docs/standard/commandline/snippets/model-binding/csharp/AddValidator.cs @@ -21,11 +21,11 @@ internal static async Task Main(string[] args) var rootCommand = new RootCommand(); rootCommand.Add(delayOption); - rootCommand.SetHandler((int delayOptionValue) => - { - Console.WriteLine($"--delay = {delayOptionValue}"); - }, - delayOption); + rootCommand.SetHandler((delayOptionValue) => + { + Console.WriteLine($"--delay = {delayOptionValue}"); + }, + delayOption); await rootCommand.InvokeAsync(args); } diff --git a/docs/standard/commandline/snippets/model-binding/csharp/ComplexType.cs b/docs/standard/commandline/snippets/model-binding/csharp/ComplexType.cs index 946e123b6ad9e..d38eb0dea4890 100644 --- a/docs/standard/commandline/snippets/model-binding/csharp/ComplexType.cs +++ b/docs/standard/commandline/snippets/model-binding/csharp/ComplexType.cs @@ -19,7 +19,7 @@ internal static async Task Main(string[] args) var lastNameOption = new Option( name: "--last-name", - description: "Person.FirstName"); + description: "Person.LastName"); var rootCommand = new RootCommand(); rootCommand.Add(fileOption); @@ -27,17 +27,17 @@ internal static async Task Main(string[] args) rootCommand.Add(lastNameOption); // - rootCommand.SetHandler((FileInfo fileOptionValue, Person person) => - { - DoRootCommand(fileOptionValue, person); - }, - fileOption, new PersonBinder(firstNameOption, lastNameOption)); + rootCommand.SetHandler((fileOptionValue, person) => + { + DoRootCommand(fileOptionValue, person); + }, + fileOption, new PersonBinder(firstNameOption, lastNameOption)); // await rootCommand.InvokeAsync(args); } - public static void DoRootCommand(FileInfo aFile, Person aPerson) + public static void DoRootCommand(FileInfo? aFile, Person aPerson) { Console.WriteLine($"File = {aFile?.FullName}"); Console.WriteLine($"Person = {aPerson?.FirstName} {aPerson?.LastName}"); diff --git a/docs/standard/commandline/snippets/model-binding/csharp/ContextExitCode.cs b/docs/standard/commandline/snippets/model-binding/csharp/ContextExitCode.cs index 2ab6452feeb17..9a70fbc6bf27f 100644 --- a/docs/standard/commandline/snippets/model-binding/csharp/ContextExitCode.cs +++ b/docs/standard/commandline/snippets/model-binding/csharp/ContextExitCode.cs @@ -11,19 +11,20 @@ static async Task Main(string[] args) var delayOption = new Option("--delay"); var messageOption = new Option("--message"); - var rootCommand = new RootCommand("Model binding example"); + var rootCommand = new RootCommand("Parameter binding example"); rootCommand.Add(delayOption); rootCommand.Add(messageOption); - rootCommand.SetHandler(async - (int delayOptionValue, string messageOptionValue, InvocationContext ctx) => + rootCommand.SetHandler(async (context) => { + int delayOptionValue = context.ParseResult.GetValueForOption(delayOption); + string? messageOptionValue = context.ParseResult.GetValueForOption(messageOption); + Console.WriteLine($"--delay = {delayOptionValue}"); await Task.Delay(delayOptionValue); Console.WriteLine($"--message = {messageOptionValue}"); - ctx.ExitCode = 100; - }, - delayOption, messageOption); + context.ExitCode = 100; + }); return await rootCommand.InvokeAsync(args); } diff --git a/docs/standard/commandline/snippets/model-binding/csharp/ParseArgument.cs b/docs/standard/commandline/snippets/model-binding/csharp/ParseArgument.cs index 48310ecb57e82..63feaed21f9e8 100644 --- a/docs/standard/commandline/snippets/model-binding/csharp/ParseArgument.cs +++ b/docs/standard/commandline/snippets/model-binding/csharp/ParseArgument.cs @@ -63,12 +63,12 @@ internal static async Task Main(string[] args) rootCommand.Add(delayOption); rootCommand.Add(personOption); - rootCommand.SetHandler((int delayOptionValue, Person personOptionValue) => - { - Console.WriteLine($"Delay = {delayOptionValue}"); - Console.WriteLine($"Person = {personOptionValue?.FirstName} {personOptionValue?.LastName}"); - }, - delayOption, personOption); + rootCommand.SetHandler((delayOptionValue, personOptionValue) => + { + Console.WriteLine($"Delay = {delayOptionValue}"); + Console.WriteLine($"Person = {personOptionValue?.FirstName} {personOptionValue?.LastName}"); + }, + delayOption, personOption); await rootCommand.InvokeAsync(args); } diff --git a/docs/standard/commandline/snippets/model-binding/csharp/Program.cs b/docs/standard/commandline/snippets/model-binding/csharp/Program.cs index c9aafa64b5589..8ac46f5d67715 100644 --- a/docs/standard/commandline/snippets/model-binding/csharp/Program.cs +++ b/docs/standard/commandline/snippets/model-binding/csharp/Program.cs @@ -1,5 +1,4 @@ using System.CommandLine; -using System.Runtime.CompilerServices; class Program { @@ -25,13 +24,13 @@ static async Task IntAndString(string[] args) var messageOption = new Option ("--message", "An option whose argument is parsed as a string."); - var rootCommand = new RootCommand("Model binding example"); + var rootCommand = new RootCommand("Parameter binding example"); rootCommand.Add(delayOption); rootCommand.Add(messageOption); rootCommand.SetHandler( // - (int delayOptionValue, string messageOptionValue) => + (delayOptionValue, messageOptionValue) => { DisplayIntAndString(delayOptionValue, messageOptionValue); }, @@ -62,7 +61,7 @@ static async Task Enum(string[] args) var rootCommand = new RootCommand("Enum binding example"); rootCommand.Add(colorOption); - rootCommand.SetHandler((ConsoleColor colorOptionValue) => + rootCommand.SetHandler((colorOptionValue) => { Console.WriteLine(colorOptionValue); }, colorOption); @@ -80,16 +79,16 @@ static async Task ArraysAndLists(string[] args) var command = new RootCommand("IEnumerable binding example"); command.Add(itemsOption); - command.SetHandler( - (IEnumerable items) => + command.SetHandler((items) => { Console.WriteLine(items.GetType()); - foreach (var item in items) + foreach (string item in items) { Console.WriteLine(item); } - }, itemsOption); + }, + itemsOption); await command.InvokeAsync(args); // @@ -104,8 +103,7 @@ static async Task FileSystemInfoExample(string[] args) var command = new RootCommand(); command.Add(fileOrDirectoryOption); - command.SetHandler( - (FileSystemInfo? fileSystemInfo) => + command.SetHandler((fileSystemInfo) => { switch (fileSystemInfo) { @@ -119,7 +117,8 @@ static async Task FileSystemInfoExample(string[] args) Console.WriteLine("Not a valid file or directory name."); break; } - }, fileOrDirectoryOption); + }, + fileOrDirectoryOption); await command.InvokeAsync(args); // @@ -136,8 +135,7 @@ static async Task FileInfoExample(string[] args) var command = new RootCommand(); command.Add(fileOption); - command.SetHandler( - (FileInfo? file) => + command.SetHandler((file) => { if (file is not null) { @@ -147,7 +145,8 @@ static async Task FileInfoExample(string[] args) { Console.WriteLine("Not a valid file name."); } - }, fileOption); + }, + fileOption); await command.InvokeAsync(args); // @@ -163,11 +162,11 @@ static async Task Uri(string[] args) var command = new RootCommand(); command.Add(endpointOption); - command.SetHandler( - (Uri? uri) => + command.SetHandler((uri) => { Console.WriteLine($"URL: {uri?.ToString()}"); - }, endpointOption); + }, + endpointOption); await command.InvokeAsync(args); // @@ -177,22 +176,23 @@ static async Task Uri(string[] args) static async Task OnlyTakeExample(string[] args) { // + var arg1 = new Argument(name: "arg1", parse: result => + { + result.OnlyTake(2);//System.CommandLine.Parsing.ArgumentResult.OnlyTake + return result.Tokens.Select(t => t.Value).ToArray(); + }); + var arg2 = new Argument("arg2"); + var rootCommand = new RootCommand { - new Argument(name: "arg1", parse: result => - { - result.OnlyTake(2);//System.CommandLine.Parsing.ArgumentResult.OnlyTake - return result.Tokens.Select(t => t.Value).ToArray(); - }), - new Argument("arg2") + arg1, arg2 }; - rootCommand.SetHandler( - (string[] arg1, string[] arg2) => + rootCommand.SetHandler((arg1Value, arg2Value) => { - Console.WriteLine($"arg1 = {String.Concat(arg1)}"); - Console.WriteLine($"arg2 = {String.Concat(arg2)}"); + Console.WriteLine($"arg1 = {String.Concat(arg1Value)}"); + Console.WriteLine($"arg2 = {String.Concat(arg2Value)}"); }, - rootCommand.Arguments[0], rootCommand.Arguments[1]); + arg1, arg2); await rootCommand.InvokeAsync(args); // await rootCommand.InvokeAsync("1 2 3 4 5"); diff --git a/docs/standard/commandline/snippets/model-binding/csharp/ReturnExitCode.cs b/docs/standard/commandline/snippets/model-binding/csharp/ReturnExitCode.cs index a28a205f23ab1..375bc95806e73 100644 --- a/docs/standard/commandline/snippets/model-binding/csharp/ReturnExitCode.cs +++ b/docs/standard/commandline/snippets/model-binding/csharp/ReturnExitCode.cs @@ -10,17 +10,17 @@ static async Task Main(string[] args) var delayOption = new Option("--delay"); var messageOption = new Option("--message"); - var rootCommand = new RootCommand("Model binding example"); + var rootCommand = new RootCommand("Parameter binding example"); rootCommand.Add(delayOption); rootCommand.Add(messageOption); - rootCommand.SetHandler((int delayOptionValue, string messageOptionValue) => - { - Console.WriteLine($"--delay = {delayOptionValue}"); - Console.WriteLine($"--message = {messageOptionValue}"); - return Task.FromResult(100); - }, - delayOption, messageOption); + rootCommand.SetHandler((delayOptionValue, messageOptionValue) => + { + Console.WriteLine($"--delay = {delayOptionValue}"); + Console.WriteLine($"--message = {messageOptionValue}"); + return Task.FromResult(100); + }, + delayOption, messageOption); return await rootCommand.InvokeAsync(args); } diff --git a/docs/standard/commandline/snippets/model-binding/csharp/scl.csproj b/docs/standard/commandline/snippets/model-binding/csharp/scl.csproj index d831c4629b560..4a6a64b1b37da 100644 --- a/docs/standard/commandline/snippets/model-binding/csharp/scl.csproj +++ b/docs/standard/commandline/snippets/model-binding/csharp/scl.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/standard/commandline/snippets/tab-completion/csharp/Program.cs b/docs/standard/commandline/snippets/tab-completion/csharp/Program.cs index dcb59b9caa56a..1051756a3e906 100644 --- a/docs/standard/commandline/snippets/tab-completion/csharp/Program.cs +++ b/docs/standard/commandline/snippets/tab-completion/csharp/Program.cs @@ -34,9 +34,11 @@ class DateCommand : Command }); // - this.SetHandler((string subject, DateTime date) => { - Console.WriteLine($"Scheduled \"{subject}\" for {date}"); - }, subjectArgument, dateOption); + this.SetHandler((subject, date) => + { + Console.WriteLine($"Scheduled \"{subject}\" for {date}"); + }, + subjectArgument, dateOption); } } // diff --git a/docs/standard/commandline/snippets/tab-completion/csharp/scl.csproj b/docs/standard/commandline/snippets/tab-completion/csharp/scl.csproj index 2f0c27ba2fa0c..a5b8ae617b3b0 100644 --- a/docs/standard/commandline/snippets/tab-completion/csharp/scl.csproj +++ b/docs/standard/commandline/snippets/tab-completion/csharp/scl.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/standard/commandline/snippets/use-middleware/csharp/Program.cs b/docs/standard/commandline/snippets/use-middleware/csharp/Program.cs index 84f163678c199..91baf07cc7dda 100644 --- a/docs/standard/commandline/snippets/use-middleware/csharp/Program.cs +++ b/docs/standard/commandline/snippets/use-middleware/csharp/Program.cs @@ -14,11 +14,11 @@ static async Task Main(string[] args) rootCommand.Add(delayOption); rootCommand.Add(messageOption); - rootCommand.SetHandler((int delayOptionValue, string messageOptionValue) => - { - DoRootCommand(delayOptionValue, messageOptionValue); - }, - delayOption, messageOption); + rootCommand.SetHandler((delayOptionValue, messageOptionValue) => + { + DoRootCommand(delayOptionValue, messageOptionValue); + }, + delayOption, messageOption); // var commandLineBuilder = new CommandLineBuilder(rootCommand); diff --git a/docs/standard/commandline/snippets/use-middleware/csharp/scl.csproj b/docs/standard/commandline/snippets/use-middleware/csharp/scl.csproj index 1733b3d1aa9cf..d33a8a8394da9 100644 --- a/docs/standard/commandline/snippets/use-middleware/csharp/scl.csproj +++ b/docs/standard/commandline/snippets/use-middleware/csharp/scl.csproj @@ -8,7 +8,7 @@ - + diff --git a/docs/standard/commandline/syntax.md b/docs/standard/commandline/syntax.md index 9ab1ffdc1ef27..52a1ad7325b4d 100644 --- a/docs/standard/commandline/syntax.md +++ b/docs/standard/commandline/syntax.md @@ -1,7 +1,7 @@ --- title: Command-line syntax overview for System.CommandLine description: "An introduction to the command-line syntax that the System.CommandLine library recognizes by default. Mentions exceptions where syntax in the .NET CLI differs. Provides guidance for designing a command-line interface." -ms.date: 04/07/2022 +ms.date: 05/24/2022 no-loc: [System.CommandLine] helpviewer_keywords: - "command line interface" @@ -129,14 +129,14 @@ You can provide options before arguments or arguments before options on the comm ```dotnetcli dotnet add package System.CommandLine --prerelease -dotnet add package --prerelease System.CommandLine +dotnet add package --prerelease System.CommandLine ``` Options can be specified in any order. The following commands are equivalent: ```dotnetcli dotnet add package System.CommandLine --prerelease --no-restore --source https://api.nuget.org/v3/index.json -dotnet add package System.CommandLine --source https://api.nuget.org/v3/index.json --no-restore --prerelease +dotnet add package System.CommandLine --source https://api.nuget.org/v3/index.json --no-restore --prerelease ``` When there are multiple arguments, the order does matter. The following commands are not necessarily equivalent: @@ -366,7 +366,9 @@ A *response file* is a file that contains a set of [tokens](syntax.md#tokens) fo * To invoke a command-line app by specifying input that is longer than the character limit of the terminal. * To invoke the same command repeatedly without retyping the whole line. -To use a response file, enter the file name prefixed by an `@` sign wherever in the line you want to insert commands, options, and arguments. The following lines are equivalent: +To use a response file, enter the file name prefixed by an `@` sign wherever in the line you want to insert commands, options, and arguments. The *.rsp* file extension is a common convention, but you can use any file extension. + +The following lines are equivalent: ```dotnetcli dotnet build --no-restore --output ./build-output/ @@ -378,7 +380,7 @@ Contents of *sample1.rsp*: ```console build ---no-restore +--no-restore --output ./build-output/ ``` @@ -389,7 +391,13 @@ Contents of *sample2.rsp*: --no-restore ``` -By default, tokens in a response file are delimited by line breaks, not by spaces. A response file line that includes embedded spaces is passed to the app as a single token with embedded spaces. +Here are syntax rules that determine how the text in a response file is interpreted: + +* Tokens are delimited by spaces. A line that contains *Good morning!* is treated as two tokens, *Good* and *morning!*. +* Multiple tokens enclosed in quotes are interpreted as a single token. A line that contains *"Good morning!"* is treated as one token, *Good morning!*. +* Any text between a `#` symbol and the end of the line is treated as a comment and ignored. +* Tokens prefixed with `@` can reference additional response files. +* The response file can have multiple lines of text. The lines are concatenated and interpreted as a sequence of tokens. ## Directives diff --git a/docs/standard/data/xml/how-to-migrate-your-xsltransform-code.md b/docs/standard/data/xml/how-to-migrate-your-xsltransform-code.md index 60def2caf2712..079c3a8089001 100644 --- a/docs/standard/data/xml/how-to-migrate-your-xsltransform-code.md +++ b/docs/standard/data/xml/how-to-migrate-your-xsltransform-code.md @@ -9,9 +9,11 @@ ms.assetid: 910beb2f-cfb3-4e8e-9936-f7e0c5f4064a --- # How to: Migrate Your XslTransform Code -The new XSLT classes have been designed to be very similar to the existing classes. The class replaces the class. Style sheets are compiled using the method. Transforms are executed using the method. The following procedures show common XSLT tasks, and compare the code using the class versus the class. +The class replaced the class. This newer class was designed to be very similar to . Style sheets are compiled using the method. Transforms are executed using the method. + +The following procedures show common XSLT tasks, and compare the code using the class versus the class. -### To transform a file and output to a URI +## To transform a file and output to a URI - Code using the class. @@ -23,7 +25,7 @@ The new XSLT classes have been designed to be very similar to the existing class [!code-csharp[XML_Migration#10](../../../../samples/snippets/csharp/VS_Snippets_Data/XML_Migration/CS/migration.cs#10)] [!code-vb[XML_Migration#10](../../../../samples/snippets/visualbasic/VS_Snippets_Data/XML_Migration/VB/migration.vb#10)] -### To compile a style sheet and use a resolver with default credentials +## To compile a style sheet and use a resolver with default credentials - Code using the class. @@ -35,7 +37,7 @@ The new XSLT classes have been designed to be very similar to the existing class [!code-csharp[XML_Migration#12](../../../../samples/snippets/csharp/VS_Snippets_Data/XML_Migration/CS/migration.cs#12)] [!code-vb[XML_Migration#12](../../../../samples/snippets/visualbasic/VS_Snippets_Data/XML_Migration/VB/migration.vb#12)] -### To use an XSLT parameter +## To use an XSLT parameter - Code using the class. @@ -47,7 +49,10 @@ The new XSLT classes have been designed to be very similar to the existing class [!code-csharp[XML_Migration#14](../../../../samples/snippets/csharp/VS_Snippets_Data/XML_Migration/CS/migration.cs#14)] [!code-vb[XML_Migration#14](../../../../samples/snippets/visualbasic/VS_Snippets_Data/XML_Migration/VB/migration.vb#14)] -### To enable XSLT scripting +## To enable XSLT scripting + +> [!NOTE] +> Script blocks are supported only in .NET Framework. They are _not_ supported on .NET Core or .NET 5 or later. - Code using the class. @@ -59,7 +64,7 @@ The new XSLT classes have been designed to be very similar to the existing class [!code-csharp[XML_Migration#16](../../../../samples/snippets/csharp/VS_Snippets_Data/XML_Migration/CS/migration.cs#16)] [!code-vb[XML_Migration#16](../../../../samples/snippets/visualbasic/VS_Snippets_Data/XML_Migration/VB/migration.vb#16)] -### To load the results into a DOM object +## To load the results into a DOM object - Code using the class. @@ -74,7 +79,7 @@ The new XSLT classes have been designed to be very similar to the existing class [!code-csharp[XML_Migration#20](../../../../samples/snippets/csharp/VS_Snippets_Data/XML_Migration/CS/migration.cs#20)] [!code-vb[XML_Migration#20](../../../../samples/snippets/visualbasic/VS_Snippets_Data/XML_Migration/VB/migration.vb#20)] -### To stream the results into another data store +## To stream the results into another data store - Code using the class. diff --git a/docs/standard/data/xml/how-to-perform-an-xslt-transformation-by-using-an-assembly.md b/docs/standard/data/xml/how-to-perform-an-xslt-transformation-by-using-an-assembly.md index 5a74d7a668cd8..bee1de026379b 100644 --- a/docs/standard/data/xml/how-to-perform-an-xslt-transformation-by-using-an-assembly.md +++ b/docs/standard/data/xml/how-to-perform-an-xslt-transformation-by-using-an-assembly.md @@ -7,11 +7,14 @@ dev_langs: - "vb" ms.assetid: 76ee440b-d134-4f8f-8262-b917ad6dcbf6 --- -# How to: Perform an XSLT Transformation by Using an Assembly +# How to: Perform an XSLT transformation by using an assembly -The XSLT compiler (xsltc.exe) compiles XSLT style sheets and generates an assembly. The assembly can be passed directly into the method. +> [!NOTE] +> Script blocks are supported only in .NET Framework. They are _not_ supported on .NET Core or .NET 5 or later. + +The XSLT compiler (xsltc.exe) compiles XSLT style sheets and generates an assembly. The assembly can be passed directly into the method. -### To copy the XML and XSLT files to your local computer +## To copy the XML and XSLT files to your local computer - Copy the XSLT file to your local computer and name it Transform.xsl. @@ -123,21 +126,21 @@ The XSLT compiler (xsltc.exe) compiles XSLT style sheets and generates an assemb ``` -### To compile the style sheet with the script enabled. - -1. Executing the following command from the command line creates two assemblies named `Transform.dll` and `Transform_Script1.dll` (This is the default behavior. Unless otherwise specified, the name of the class and the assembly defaults to the name of the main style sheet): +## To compile the style sheet with the script enabled - ```console - xsltc /settings:script+ Transform.xsl - ``` +The following command creates two assemblies named `Transform.dll` and `Transform_Script1.dll`. This is the default behavior. Unless otherwise specified, the name of the class and the assembly defaults to the name of the main style sheet. - The following command explicitly sets the class name to Transform: +```console +xsltc /settings:script+ Transform.xsl +``` - ```console - xsltc /settings:script+ /class:Transform Transform.xsl - ``` +The following command explicitly sets the class name to Transform: + +```console +xsltc /settings:script+ /class:Transform Transform.xsl +``` -### To include the compiled assembly as a reference when you compile your code. +## To include the compiled assembly as a reference when you compile your code 1. You can include an assembly in Visual Studio by adding a reference in the Solution Explorer, or from the command line. @@ -153,7 +156,7 @@ The XSLT compiler (xsltc.exe) compiles XSLT style sheets and generates an assemb vbc myCode.vb /r:system.dll;system.xml.dll;Transform.dll ``` -### To use the compiled assembly in your code. +## To use the compiled assembly in your code The following example shows how to execute the XSLT transformation by using the compiled style sheet. @@ -172,7 +175,7 @@ with xslt.Load(System.Reflection.Assembly.Load("Transform").GetType("Transform")); ``` -in the example above. For more information on the Assembly.Load method, see . +For more information on the `Assembly.Load` method, see . ## See also diff --git a/docs/standard/data/xml/migrating-from-the-xsltransform-class.md b/docs/standard/data/xml/migrating-from-the-xsltransform-class.md index eb59d6d47c86e..49d014f221d24 100644 --- a/docs/standard/data/xml/migrating-from-the-xsltransform-class.md +++ b/docs/standard/data/xml/migrating-from-the-xsltransform-class.md @@ -27,6 +27,9 @@ The class also includes other optimiz By default, the class disables support for the XSLT `document()` function and embedded scripting. These features can be enabled by creating an object that has the features enabled and passing it to the method. The following example shows how to enable scripting and perform an XSLT transformation. +> [!NOTE] +> Script blocks are supported only in .NET Framework. They are _not_ supported on .NET Core or .NET 5 or later. + [!code-csharp[XML_Migration#16](../../../../samples/snippets/csharp/VS_Snippets_Data/XML_Migration/CS/migration.cs#16)] [!code-vb[XML_Migration#16](../../../../samples/snippets/visualbasic/VS_Snippets_Data/XML_Migration/VB/migration.vb#16)] diff --git a/docs/standard/data/xml/xslt-compiler-xsltc-exe.md b/docs/standard/data/xml/xslt-compiler-xsltc-exe.md index fdbf9baaeec44..898625314d860 100644 --- a/docs/standard/data/xml/xslt-compiler-xsltc-exe.md +++ b/docs/standard/data/xml/xslt-compiler-xsltc-exe.md @@ -6,7 +6,10 @@ ms.assetid: 672a5ac8-8305-4d28-ba10-11089c2c0924 --- # XSLT Compiler (xsltc.exe) -The XSLT compiler (xsltc.exe) compiles XSLT style sheets and generates an assembly. The compiled style sheet can then be passed directly into the method. You cannot generate signed assemblies with xsltc.exe. +The XSLT compiler (xsltc.exe) compiles XSLT style sheets and generates an assembly. The compiled style sheet can then be passed directly into the method. You cannot generate signed assemblies with xsltc.exe. + +> [!NOTE] +> Script blocks are supported only in .NET Framework. They are _not_ supported on .NET Core or .NET 5 or later. The xsltc.exe tool is included with Visual Studio. For more information, see the [Visual Studio Downloads](https://aka.ms/vsdownload?utm_source=mscom&utm_campaign=msdocs). @@ -27,7 +30,7 @@ xsltc [options] [/class:] [[/class:] ...] |Option|Description| |------------|-----------------| |`/c[lass]:` `name`|Specifies the name of the class for the following style sheet. The class name can be fully qualified.

The class name defaults to the name of the style sheet. For example, if the style sheet customers.xsl is compiled, the default class name is customers.| -|`/debug[`+|-`]`|Specifies whether to generate debugging information.

Specifying `+` or `/debug`, causes the compiler to generate debugging information and put it in a program database (PDB) file. The name of the generated PDB file is `assemblyName`.pdb.

Specifying `-`, which is in effect if you do not specify `/debug`, causes no debug information to be created. A retail assembly is generated. **Note:** Compiling in debug mode can affect XSLT performance significantly.| +|`/debug[`+|-`]`|Specifies whether to generate debugging information.

Specifying `+` or `/debug`, causes the compiler to generate debugging information and put it in a program database (PDB) file. The name of the generated PDB file is `assemblyName`.pdb.

Specifying `-`, which is in effect if you don't specify `/debug`, causes no debug information to be created. A retail assembly is generated. **Note:** Compiling in debug mode can affect XSLT performance significantly.| |`/help`|Displays command syntax and options for the tool.| |`/nologo`|Suppresses the compiler copyright message from displaying.| |`/platform:` `string`|Specifies the platforms that the assembly can be run on. The following describes the valid platform values:

`x86` compiles your assembly to be run by the 32-bit, x86-compatible common language runtime

`x64` compiles your assembly to be run by the 64-bit common language runtime on a computer that supports the AMD64 or EM64T instruction set.

Itanium compiles your assembly to be run by the 64-bit common language runtime on a computer that has an Itanium processor.

`anycpu` compiles your assembly to run on any platform. This is the default.| @@ -43,7 +46,7 @@ xsltc [options] [/class:] [[/class:] ...] > [!NOTE] > You must also include the compiled assembly as a reference in your application. - The xsltc.exe tool does not validate the class (`/class:`*name*) or assembly (`/out:`*assemblyName*) names. Errors are thrown by the common language runtime if the names are not valid. + The xsltc.exe tool does not validate the class (`/class:`*name*) or assembly (`/out:`*assemblyName*) names. Errors are thrown by the common language runtime if the names aren't valid. ## Examples @@ -59,7 +62,7 @@ xsltc booksort.xsl xsltc booksort.xsl /debug ``` - The following command compiles a style sheet that contains an msxsl:script element and creates two assemblies named calc.dll and calc_Script1.dll. + The following command compiles a style sheet that contains an `msxsl:script` element and creates two assemblies named calc.dll and calc_Script1.dll. ```console xsltc /settings:script+ calc.xsl diff --git a/docs/standard/data/xml/xslt-security-considerations.md b/docs/standard/data/xml/xslt-security-considerations.md index b08d7867748c3..0cce081841bf8 100644 --- a/docs/standard/data/xml/xslt-security-considerations.md +++ b/docs/standard/data/xml/xslt-security-considerations.md @@ -22,7 +22,10 @@ The XSLT language has a rich set of features that give you a great deal of power ### Style Sheet Scripts - Scripts can be embedded in a style sheet using the `msxsl:script` extension element. Script support is an optional feature on the class that is disabled by default. Scripting can be enabled by setting the property to `true` and passing the object to the method. + Scripts can be embedded in a style sheet using the `msxsl:script` extension element. Script support is an optional feature on the class that is disabled by default. Scripting can be enabled by setting the property to `true` and passing the object to the method. + +> [!NOTE] +> Script blocks are supported only in .NET Framework. They are _not_ supported on .NET Core or .NET 5 or later. #### Guidelines @@ -59,4 +62,3 @@ The XSLT language has a rich set of features that give you a great deal of power - [XSLT Transformations](xslt-transformations.md) - [Resolving External Resources During XSLT Processing](resolving-external-resources-during-xslt-processing.md) -- [Code Access Security](/previous-versions/dotnet/framework/code-access-security/code-access-security) diff --git a/docs/standard/datetime/instantiating-a-datetimeoffset-object.md b/docs/standard/datetime/instantiating-a-datetimeoffset-object.md index 5abd4042808f6..9aa1cd5330e9c 100644 --- a/docs/standard/datetime/instantiating-a-datetimeoffset-object.md +++ b/docs/standard/datetime/instantiating-a-datetimeoffset-object.md @@ -62,7 +62,7 @@ The second constructor that creates a object from a ## Implicit type conversion -The type supports one implicit type conversion: from a value to a value. (An implicit type conversion is a conversion from one type to another that does not require an explicit cast (in C#) or conversion (in Visual Basic) and that does not lose information. It makes code like the following possible. +The type supports one *implicit* type conversion: from a value to a value. (An implicit type conversion is a conversion from one type to another that does not require an explicit cast (in C#) or conversion (in Visual Basic) and that does not lose information.) It makes code like the following possible. [!code-csharp[System.DateTimeOffset.Conceptual.Instantiate#6](../../../samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTimeOffset.Conceptual.Instantiate/cs/Instantiate.cs#6)] [!code-vb[System.DateTimeOffset.Conceptual.Instantiate#6](../../../samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTimeOffset.Conceptual.Instantiate/vb/Instantiate.vb#6)] diff --git a/docs/standard/garbage-collection/fundamentals.md b/docs/standard/garbage-collection/fundamentals.md index 88106755a3fd9..7dff1a8a2fbcf 100644 --- a/docs/standard/garbage-collection/fundamentals.md +++ b/docs/standard/garbage-collection/fundamentals.md @@ -199,7 +199,7 @@ The following illustration shows a thread that triggers a garbage collection and For most of the objects that your application creates, you can rely on garbage collection to automatically perform the necessary memory management tasks. However, unmanaged resources require explicit cleanup. The most common type of unmanaged resource is an object that wraps an operating system resource, such as a file handle, window handle, or network connection. Although the garbage collector is able to track the lifetime of a managed object that encapsulates an unmanaged resource, it doesn't have specific knowledge about how to clean up the resource. -When you create an object that encapsulates an unmanaged resource, it's recommended that you provide the necessary code to clean up the unmanaged resource in a public `Dispose` method. By providing a `Dispose` method, you enable users of your object to explicitly free its memory when they are finished with the object. When you use an object that encapsulates an unmanaged resource, make sure to call `Dispose` as necessary. +When you define an object that encapsulates an unmanaged resource, it's recommended that you provide the necessary code to clean up the unmanaged resource in a public `Dispose` method. By providing a `Dispose` method, you enable users of your object to explicitly release the resource when they're finished with the object. When you use an object that encapsulates an unmanaged resource, make sure to call `Dispose` as necessary. You must also provide a way for your unmanaged resources to be released in case a consumer of your type forgets to call `Dispose`. You can either use a safe handle to wrap the unmanaged resource, or override the method. diff --git a/docs/standard/garbage-collection/unmanaged.md b/docs/standard/garbage-collection/unmanaged.md index 61be52a2cd10e..8d94555d44ce6 100644 --- a/docs/standard/garbage-collection/unmanaged.md +++ b/docs/standard/garbage-collection/unmanaged.md @@ -16,7 +16,7 @@ ms.assetid: a17b0066-71c2-4ba4-9822-8e19332fc213 # Cleaning up unmanaged resources -For the majority of the objects that your app creates, you can rely on the [.NET garbage collector](index.md) to handle memory management. However, when you create objects that include unmanaged resources, you must explicitly release those resources when you finish using them. The most common types of unmanaged resources are objects that wrap operating system resources, such as files, windows, network connections, or database connections. Although the garbage collector is able to track the lifetime of an object that encapsulates an unmanaged resource, it doesn't know how to release and clean up the unmanaged resource. +For a majority of the objects that your app creates, you can rely on the [.NET garbage collector](index.md) to handle memory management. However, when you create objects that include unmanaged resources, you must explicitly release those resources when you finish using them. The most common types of unmanaged resources are objects that wrap operating system resources, such as files, windows, network connections, or database connections. Although the garbage collector is able to track the lifetime of an object that encapsulates an unmanaged resource, it doesn't know how to release and clean up the unmanaged resource. If your types use unmanaged resources, you should do the following: diff --git a/docs/standard/garbage-collection/workstation-server-gc.md b/docs/standard/garbage-collection/workstation-server-gc.md index c1b48fb556675..4cda1217c82a3 100644 --- a/docs/standard/garbage-collection/workstation-server-gc.md +++ b/docs/standard/garbage-collection/workstation-server-gc.md @@ -34,7 +34,7 @@ The following are threading and performance considerations for workstation garba - The collection occurs on the user thread that triggered the garbage collection and remains at the same priority. Because user threads typically run at normal priority, the garbage collector (which runs on a normal priority thread) must compete with other threads for CPU time. (Threads that run native code are not suspended on either server or workstation garbage collection.) -- Workstation garbage collection is always used on a computer that has only one processor, regardless of the [configuration setting](../../core/runtime-config/garbage-collector.md#workstation-vs-server). +- Workstation garbage collection is always used on a computer that has only one logical CPU, regardless of the [configuration setting](../../core/runtime-config/garbage-collector.md#workstation-vs-server). ### Server GC @@ -42,13 +42,13 @@ The following are threading and performance considerations for server garbage co - The collection occurs on multiple dedicated threads that are running at `THREAD_PRIORITY_HIGHEST` priority level. -- A heap and a dedicated thread to perform garbage collection are provided for each CPU, and the heaps are collected at the same time. Each heap contains a small object heap and a large object heap, and all heaps can be accessed by user code. Objects on different heaps can refer to each other. +- A heap and a dedicated thread to perform garbage collection are provided for each logical CPU, and the heaps are collected at the same time. Each heap contains a small object heap and a large object heap, and all heaps can be accessed by user code. Objects on different heaps can refer to each other. - Because multiple garbage collection threads work together, server garbage collection is faster than workstation garbage collection on the same size heap. - Server garbage collection often has larger size segments. However, this is only a generalization: segment size is implementation-specific and is subject to change. Don't make assumptions about the size of segments allocated by the garbage collector when tuning your app. -- Server garbage collection can be resource-intensive. For example, imagine that there are 12 processes that use server GC running on a computer that has four processors. If all the processes happen to collect garbage at the same time, they would interfere with each other, as there would be 12 threads scheduled on the same processor. If the processes are active, it's not a good idea to have them all use server GC. +- Server garbage collection can be resource-intensive. For example, imagine that there are 12 processes that use server GC running on a computer that has four logical CPUs. If all the processes happen to collect garbage at the same time, they would interfere with each other, as there would be 12 threads scheduled on the same logical CPU. If the processes are active, it's not a good idea to have them all use server GC. If you're running hundreds of instances of an application, consider using workstation garbage collection with concurrent garbage collection disabled. This will result in less context switching, which can improve performance. diff --git a/docs/standard/io/pipelines.md b/docs/standard/io/pipelines.md index a2c8c3d803a3c..1b9054bd1cf12 100644 --- a/docs/standard/io/pipelines.md +++ b/docs/standard/io/pipelines.md @@ -1,7 +1,7 @@ --- title: I/O pipelines - .NET description: Learn how to efficiently use I/O pipelines in .NET and avoid problems in your code. -ms.date: 08/27/2020 +ms.date: 05/09/2022 helpviewer_keywords: - "Pipelines" - "Pipelines I/O" @@ -14,6 +14,8 @@ ms.author: riande is a library that is designed to make it easier to do high-performance I/O in .NET. It's a library targeting .NET Standard that works on all .NET implementations. +The library is available in the [System.IO.Pipelines](https://www.nuget.org/packages/System.IO.Pipelines) Nuget package. + ## What problem does System.IO.Pipelines solve @@ -334,6 +336,18 @@ The previous method of writing uses the buffers provided by the `PipeWriter`. It * Calling `GetMemory` or `GetSpan` while there's an incomplete call to `FlushAsync` isn't safe. * Calling `Complete` or `CompleteAsync` while there's unflushed data can result in memory corruption. +## Tips for using PipeReader and PipeWriter + +The following tips will help you use the classes successfully: + +* Always complete the [PipeReader](xref:System.IO.Pipelines.PipeReader.Complete%2A?displayProperty=nameWithType) and [PipeWriter](xref:System.IO.Pipelines.PipeWriter.Complete%2A?displayProperty=nameWithType), including an exception where applicable. +* Always call after calling . +* Periodically `await` while writing, and always check . Abort writing if `IsCompleted` is `true`, as that indicates the reader is completed and no longer cares about what is written. +* Do call after writing something that you want the `PipeReader` to have access to. +* Do not call `FlushAsync` if the reader can't start until `FlushAsync` finishes, as that may cause a deadlock. +* Ensure that only one context "owns" a `PipeReader` or `PipeWriter` or accesses them. These types are not thread-safe. +* Never access a after calling `AdvanceTo` or completing the `PipeReader`. + ## IDuplexPipe The is a contract for types that support both reading and writing. For example, a network connection would be represented by an `IDuplexPipe`. diff --git a/docs/standard/library-guidance/sourcelink.md b/docs/standard/library-guidance/sourcelink.md index e82a84e217d80..eabc4fd9495db 100644 --- a/docs/standard/library-guidance/sourcelink.md +++ b/docs/standard/library-guidance/sourcelink.md @@ -16,7 +16,7 @@ Source Link is a technology that enables source code debugging of .NET assemblie Instructions for using Source Link can be found on the [dotnet/sourcelink](https://github.com/dotnet/sourcelink/blob/main/README.md) GitHub repository. -You can use [NuGet Package Explorer](https://github.com/NuGetPackageExplorer/NuGetPackageExplorer) to confirm that the Source Link metadata has been successfully embedded in the package. Check the `Repository` metadata is present with a commit identifier and that .pdb files are located with each target's .dll. +You can use the [NuGet Package Explorer](https://github.com/NuGetPackageExplorer/NuGetPackageExplorer) desktop app or the [nuget.info](https://nuget.info/) website to confirm that the Source Link metadata has been successfully embedded in the package. Verify that the `Repository` metadata is present with a commit identifier and that .pdb files are located with each target's .dll. ![Source Link in NuGet Package Explorer](./media/sourcelink/nuget-package-explorer-sourcelink.png "Source Link in NuGet Package Explorer") diff --git a/docs/standard/linq/find-child-elements-based-position.md b/docs/standard/linq/find-child-elements-based-position.md index a6ed78d74e7a8..45a23d51d5ad6 100644 --- a/docs/standard/linq/find-child-elements-based-position.md +++ b/docs/standard/linq/find-child-elements-based-position.md @@ -1,6 +1,6 @@ --- title: How to find child elements based on position - LINQ to XML -description: "Learn how to find find elements based on element position. Three methods are shown: one that uses XPathEvaluate, two that use LINQ to XML query." +description: "Learn how to find elements based on element position. Three methods are shown: one that uses XPathEvaluate, two that use LINQ to XML query." ms.date: 07/20/2015 dev_langs: - "csharp" diff --git a/docs/standard/linq/find-immediate-preceding-sibling.md b/docs/standard/linq/find-immediate-preceding-sibling.md index 9d11d79a504d8..edd9bda49d732 100644 --- a/docs/standard/linq/find-immediate-preceding-sibling.md +++ b/docs/standard/linq/find-immediate-preceding-sibling.md @@ -1,6 +1,6 @@ --- title: How to find the immediate preceding sibling - LINQ to XML -description: "Learn how to find find the sibling that immediately precedes a node. Two methods are shown: one uses XPathEvaluate, the other uses LINQ to XML query." +description: "Learn how to find the sibling that immediately precedes a node. Two methods are shown: one uses XPathEvaluate, the other uses LINQ to XML query." ms.date: 07/20/2015 dev_langs: - "csharp" diff --git a/docs/standard/linq/find-preceding-siblings.md b/docs/standard/linq/find-preceding-siblings.md index 39a43f535084d..dfc47c382c3a7 100644 --- a/docs/standard/linq/find-preceding-siblings.md +++ b/docs/standard/linq/find-preceding-siblings.md @@ -1,6 +1,6 @@ --- title: How to find preceding siblings - LINQ to XML -description: "Learn how to to find sibling elements that precede a given element. Two methods are shown: one uses XPathSelectElements along the preceding-sibling axis, the other uses XNode.ElementsBeforeSelf." +description: "Learn how to find sibling elements that precede a given element. Two methods are shown: one uses XPathSelectElements along the preceding-sibling axis, the other uses XNode.ElementsBeforeSelf." ms.date: 07/20/2015 dev_langs: - "csharp" diff --git a/docs/standard/memory-and-spans/memory-t-usage-guidelines.md b/docs/standard/memory-and-spans/memory-t-usage-guidelines.md index f2e33ff6380ff..8cf0cf3e1dd6e 100644 --- a/docs/standard/memory-and-spans/memory-t-usage-guidelines.md +++ b/docs/standard/memory-and-spans/memory-t-usage-guidelines.md @@ -131,7 +131,7 @@ In fact, if we combine this rule and Rule #1, we can do even better and rewrite void DisplayBufferToConsole(ReadOnlySpan buffer); ``` -The `DisplayBufferToConsole` method now works with virtually every buffer type imaginable: `T[]`, storage allocated with [stackalloc](../../csharp/language-reference/operators/stackalloc.md), and so on. You can even pass a directly into it! +The `DisplayBufferToConsole` method now works with virtually every buffer type imaginable: `T[]`, storage allocated with [stackalloc](../../csharp/language-reference/operators/stackalloc.md), and so on. You can even pass a directly into it! For more information, see GitHub issue [dotnet/docs #25551](https://github.com/dotnet/docs/issues/25551). **Rule #3: If your method accepts Memory\ and returns `void`, you must not use the Memory\ instance after your method returns.** diff --git a/docs/standard/native-interop/apply-interop-attributes.md b/docs/standard/native-interop/apply-interop-attributes.md index 394712d7c80a1..6c8b3f663e324 100644 --- a/docs/standard/native-interop/apply-interop-attributes.md +++ b/docs/standard/native-interop/apply-interop-attributes.md @@ -27,7 +27,7 @@ The namespace provides three categories of |Attribute|Description| |---------------|-----------------| -||Specifies whether the type should be marshalled using the Automation marshalleror a custom proxy and stub.| +||Specifies whether the type should be marshalled using the Automation marshaller or a custom proxy and stub.| ||Controls the type of interface generated for a class.| ||Identifies the CLSID of the original coclass imported from a type library.

COM interop tools typically apply this attribute.| ||Indicates that a coclass or interface definition was imported from a COM type library. The runtime uses this flag to know how to activate and marshal the type. This attribute prohibits the type from being exported back to a type library.

COM interop tools typically apply this attribute.| diff --git a/docs/standard/native-interop/best-practices.md b/docs/standard/native-interop/best-practices.md index 297d0c71556e0..f66146a73422b 100644 --- a/docs/standard/native-interop/best-practices.md +++ b/docs/standard/native-interop/best-practices.md @@ -23,20 +23,22 @@ The guidance in this section applies to all interop scenarios. | Setting | Default | Recommendation | Details | |---------|---------|----------------|---------| -| | `true` | keep default | When this is explicitly set to false, failed HRESULT return values will be turned into exceptions (and the return value in the definition becomes null as a result).| -| | `false` | depends on the API | Set this to true if the API uses GetLastError and use Marshal.GetLastWin32Error to get the value. If the API sets a condition that says it has an error, get the error before making other calls to avoid inadvertently having it overwritten.| +| | `true` | Keep default | When this is explicitly set to false, failed HRESULT return values will be turned into exceptions (and the return value in the definition becomes null as a result).| +| | `false` | Depends on the API | Set this to true if the API uses GetLastError and use Marshal.GetLastWin32Error to get the value. If the API sets a condition that says it has an error, get the error before making other calls to avoid inadvertently having it overwritten.| | | Compiler-defined (specified in the [charset documentation](./charset.md)) | Explicitly use `CharSet.Unicode` or `CharSet.Ansi` when strings or characters are present in the definition | This specifies marshalling behavior of strings and what `ExactSpelling` does when `false`. Note that `CharSet.Ansi` is actually UTF8 on Unix. _Most_ of the time Windows uses Unicode while Unix uses UTF8. See more information on the [documentation on charsets](./charset.md). | -| | `false` | `true` | Set this to true and gain a slight perf benefit as the runtime will not look for alternate function names with either an "A" or "W" suffix depending on the value of the `CharSet` setting ("A" for `CharSet.Ansi` and "W" for `CharSet.Unicode`). | +| | `false` | `true` | Set this to true and gain a slight perf benefit as the runtime will not look for alternate function names with either an "A" or "W" suffix depending on the value of the `CharSet` setting ("A" for `CharSet.Ansi` and "W" for `CharSet.Unicode`). | ## String parameters When the CharSet is Unicode or the argument is explicitly marked as `[MarshalAs(UnmanagedType.LPWSTR)]` _and_ the string is passed by value (not `ref` or `out`), the string will be pinned and used directly by native code (rather than copied). -Remember to mark the `[DllImport]` as `Charset.Unicode` unless you explicitly want ANSI treatment of your strings. - ❌ DO NOT use `[Out] string` parameters. String parameters passed by value with the `[Out]` attribute can destabilize the runtime if the string is an interned string. See more information about string interning in the documentation for . -❌ AVOID `StringBuilder` parameters. `StringBuilder` marshalling *always* creates a native buffer copy. As such, it can be extremely inefficient. Take the typical scenario of calling a Windows API that takes a string: +✔️ CONSIDER setting the `CharSet` property in `[DllImport]` so the runtime knows the expected string encoding. + +✔️ CONSIDER `char[]` or `byte[]` arrays from an `ArrayPool` when native code is expected to fill a character buffer. This requires passing the argument as `[Out]`. + +✔️ CONSIDER avoiding `StringBuilder` parameters. `StringBuilder` marshalling *always* creates a native buffer copy. As such, it can be extremely inefficient. Take the typical scenario of calling a Windows API that takes a string: 1. Create a `StringBuilder` of the desired capacity (allocates managed capacity) **{1}**. 2. Invoke: @@ -45,15 +47,13 @@ Remember to mark the `[DllImport]` as `Charset.Unicode` unless you explicitly wa 3. Copies the native buffer into a newly allocated managed array if `[Out]` **{3}** _(also the default for `StringBuilder`)_. 3. `ToString()` allocates yet another managed array **{4}**. -That is *{4}* allocations to get a string out of native code. The best you can do to limit this is to reuse the `StringBuilder` -in another call, but this still only saves *1* allocation. It's much better to use and cache a character buffer from `ArrayPool`. You can then get down to just the allocation for the `ToString()` on subsequent calls. +That's **{4}** allocations to get a string out of native code. The best you can do to limit this is to reuse the `StringBuilder` +in another call, but this still only saves one allocation. It's much better to use and cache a character buffer from `ArrayPool`. You can then get down to just the allocation for the `ToString()` on subsequent calls. The other issue with `StringBuilder` is that it always copies the return buffer back up to the first null. If the passed back string isn't terminated or is a double-null-terminated string, your P/Invoke is incorrect at best. If you *do* use `StringBuilder`, one last gotcha is that the capacity does **not** include a hidden null, which is always accounted for in interop. It's common for people to get this wrong as most APIs want the size of the buffer *including* the null. This can result in wasted/unnecessary allocations. Additionally, this gotcha prevents the runtime from optimizing `StringBuilder` marshalling to minimize copies. -✔️ CONSIDER using `char[]`s from an `ArrayPool`. - For more information on string marshalling, see [Default Marshalling for Strings](../../framework/interop/default-marshalling-for-strings.md) and [Customizing string marshalling](customize-parameter-marshalling.md#customizing-string-parameters). > __Windows Specific__ @@ -130,7 +130,7 @@ You can see if a type is blittable or contains blittable contents by attempting ### Blittable types when runtime marshalling is disabled -When [runtime marshalling is disabled](disabled-marshalling.md), the rules for which types are blittable are significantly simpler. All types that are [C# `unmanaged`](../../csharp/language-reference/builtin-types/unmanaged-types.md) types and do not have any fields that are marked with `[StructLayout(LayoutKind.Auto)]` are blittable. All types that are not C# `unmanaged` types are not blittable. The concept of types with blittable contents, such as arrays or strings, does not apply when runtime marshalling is disabled. Any type that is not considered blittable by the aforementioned rule is unsupported when runtime marshalling is disabled. +When [runtime marshalling is disabled](disabled-marshalling.md), the rules for which types are blittable are significantly simpler. All types that are [C# `unmanaged`](../../csharp/language-reference/builtin-types/unmanaged-types.md) types and don't have any fields that are marked with `[StructLayout(LayoutKind.Auto)]` are blittable. All types that are not C# `unmanaged` types are not blittable. The concept of types with blittable contents, such as arrays or strings, does not apply when runtime marshalling is disabled. Any type that is not considered blittable by the aforementioned rule is unsupported when runtime marshalling is disabled. These rules differ from the built-in system primarily in situations where `bool` and `char` are used. When marshalling is disabled, `bool` is passed as a 1-byte value and not normalized and `char` is always passed as a 2-byte value. When runtime marshalling is enabled, `bool` can map to a 1, 2, or 4-byte value and is always normalized, and `char` maps to either a 1 or 2-byte value depending on the [`CharSet`](charset.md). diff --git a/docs/standard/native-interop/customize-parameter-marshalling.md b/docs/standard/native-interop/customize-parameter-marshalling.md index 6ec029da37d6f..aa27992d87d16 100644 --- a/docs/standard/native-interop/customize-parameter-marshalling.md +++ b/docs/standard/native-interop/customize-parameter-marshalling.md @@ -5,7 +5,7 @@ ms.date: 01/18/2019 ms.topic: how-to --- -# Customizing parameter marshalling +# Customize parameter marshalling When the .NET runtime's default parameter marshalling behavior doesn't do what you want, use can use the attribute to customize how your parameters are marshalled. These customization features do not apply when [runtime marshalling is disabled](disabled-marshalling.md). @@ -13,7 +13,7 @@ When the .NET runtime's default parameter marshalling behavior doesn't do what y .NET has a variety of formats for marshalling strings. These methods are split into distinct sections on C-style strings and Windows-centric string formats. -### C-Style strings +### C-style strings Each of these formats passes a null-terminated string to native code. They differ by the encoding of the native string. @@ -38,9 +38,9 @@ If you're interacting with WinRT APIs, you can use the unmanaged type. The default type of the elements of the `SAFEARRAY` can be seen in the table on [customizing `object` fields](customize-struct-marshalling.md#marshal-systemobject). You can use the and fields to customize the exact element type of the `SAFEARRAY`. -## Customizing boolean or decimal parameters +## Customizing Boolean or decimal parameters -For information on marshalling boolean or decimal parameters, see [Customizing structure marshalling](customize-struct-marshalling.md). +For information on marshalling Boolean or decimal parameters, see [Customizing structure marshalling](customize-struct-marshalling.md). ## Customizing object parameters (Windows-only) diff --git a/docs/standard/native-interop/customize-struct-marshalling.md b/docs/standard/native-interop/customize-struct-marshalling.md index ea7566a9cb84e..ffd8bc1ff7e51 100644 --- a/docs/standard/native-interop/customize-struct-marshalling.md +++ b/docs/standard/native-interop/customize-struct-marshalling.md @@ -21,9 +21,9 @@ Sometimes the default marshalling rules for structures aren't exactly what you n ❌ AVOID using `LayoutKind.Explicit` when marshalling structures on non-Windows platforms if you need to target runtimes before .NET Core 3.0. The .NET Core runtime before 3.0 doesn't support passing explicit structures by value to native functions on Intel or AMD 64-bit non-Windows systems. However, the runtime supports passing explicit structures by reference on all platforms. -## Customizing boolean field marshalling +## Customizing Boolean field marshalling -Native code has many different boolean representations. On Windows alone, there are three ways to represent boolean values. The runtime doesn't know the native definition of your structure, so the best it can do is make a guess on how to marshal your boolean values. The .NET runtime provides a way to indicate how to marshal your boolean field. The following examples show how to marshal .NET `bool` to different native boolean types. +Native code has many different Boolean representations. On Windows alone, there are three ways to represent Boolean values. The runtime doesn't know the native definition of your structure, so the best it can do is make a guess on how to marshal your Boolean values. The .NET runtime provides a way to indicate how to marshal your Boolean field. The following examples show how to marshal .NET `bool` to different native Boolean types. Boolean values default to marshalling as a native 4-byte Win32 [`BOOL`](/windows/desktop/winprog/windows-data-types#BOOL) value as shown in the following example: @@ -75,7 +75,7 @@ struct CBool }; ``` -On Windows, you can use the value to tell the runtime to marshal your boolean value to a 2-byte `VARIANT_BOOL` value: +On Windows, you can use the value to tell the runtime to marshal your Boolean value to a 2-byte `VARIANT_BOOL` value: ```csharp public struct VariantBool diff --git a/docs/standard/native-interop/disabled-marshalling.md b/docs/standard/native-interop/disabled-marshalling.md index ced8b0c705af9..bf7d226bd76b9 100644 --- a/docs/standard/native-interop/disabled-marshalling.md +++ b/docs/standard/native-interop/disabled-marshalling.md @@ -6,7 +6,7 @@ ms.date: 01/12/2022 # Disabled runtime marshalling -When the [`System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute`](xref:System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute) attribute is applied to an assembly, the runtime disables most built-in support for data marshalling between managed and native representations. This document describes the features that are disabled and how .NET types map to native types when marshalling is disabled. +When the [`System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute`](xref:System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute) attribute is applied to an assembly, the runtime disables most built-in support for data marshalling between managed and native representations. This article describes the features that are disabled and how .NET types map to native types when marshalling is disabled. ## Scenarios where marshalling is disabled @@ -16,7 +16,7 @@ When the `DisableRuntimeMarshallingAttribute` is applied to an assembly, it affe When the `DisableRuntimeMarshallingAttribute` is applied to an assembly, the following attributes will have no effect or throw an exception: -- [`LCIDConversionAttribute`](xref:System.Runtime.InteropServices.LCIDConversionAttribute) on a P/Invoke or a delegate +- on a P/Invoke or a delegate - `SetLastError=true` on a P/Invoke - `ThrowOnUnmappableChar=true` on a P/Invoke - `BestFitMapping=true` on a P/Invoke diff --git a/docs/standard/native-interop/type-marshalling.md b/docs/standard/native-interop/type-marshalling.md index db6104a6c0a26..331aa03736fb6 100644 --- a/docs/standard/native-interop/type-marshalling.md +++ b/docs/standard/native-interop/type-marshalling.md @@ -15,7 +15,7 @@ Marshalling is needed because the types in the managed and unmanaged code are di static extern int MethodA([MarshalAs(UnmanagedType.LPStr)] string parameter); ``` -If the [`System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute`](xref:System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute) attribute is applied to the assembly, the below rules do not apply. See the documentation on [disabled runtime marshalling](disabled-marshalling.md) for information on how .NET values are exposed to native code when this attribute is applied. +If you apply the [`System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute`](xref:System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute) attribute to the assembly, the rules in the following section don't apply. For information on how .NET values are exposed to native code when this attribute is applied, see [disabled runtime marshalling](disabled-marshalling.md). ## Default rules for marshalling common types diff --git a/docs/standard/numerics.md b/docs/standard/numerics.md index 77193327e5f84..49c102fca3c92 100644 --- a/docs/standard/numerics.md +++ b/docs/standard/numerics.md @@ -17,6 +17,8 @@ ms.assetid: dfebc18e-acde-4510-9fa7-9a0f4aa3bd11 .NET provides a range of numeric integer and floating-point primitives, as well as: +- , which represents a half-precision floating-point number. +- , which represents a decimal floating-point number. - , which is an integral type with no theoretical upper or lower bound. - , which represents complex numbers. - A set of SIMD-enabled types in the namespace. @@ -60,14 +62,14 @@ The structure is ## Floating-point types -.NET includes the following primitive floating-point types: +.NET includes the following floating-point types: -|Type|Size (in bytes)|Approximate range|Notes| -|-|-|-|-| -||2|±65504|Introduced in .NET 5| -||4|±3.4 x 1038|| -||8|±1.7 × 10308|| -||16|±7.9228 x 1028|| +| Type | Size (in bytes) | Approximate range | Primitive? | Notes | +|----------------------------------------------------|-----------------|---------------------------|------------|----------------------| +| | 2 | ±65504 | No | Introduced in .NET 5 | +| | 4 | ±3.4 x 1038 | Yes | +| | 8 | ±1.7 × 10308 | Yes | +| | 16 | ±7.9228 x 1028 | No | The , , and types support special values that represent not-a-number and infinity. For example, the type provides the following values: , , and . You use the , , , and methods to test for these special values. diff --git a/docs/standard/parallel-programming/exception-handling-task-parallel-library.md b/docs/standard/parallel-programming/exception-handling-task-parallel-library.md index ba1d7bbd3f190..5ad0122830ec1 100644 --- a/docs/standard/parallel-programming/exception-handling-task-parallel-library.md +++ b/docs/standard/parallel-programming/exception-handling-task-parallel-library.md @@ -1,7 +1,7 @@ --- title: "Exception handling (Task Parallel Library)" description: Explore exception handling using the Task Parallel Library (TPL) in .NET. See nested aggregate exceptions, inner exceptions, unobserved task exceptions, & more. -ms.date: 04/20/2020 +ms.date: 06/08/2022 dev_langs: - "csharp" - "vb" @@ -27,6 +27,9 @@ If you do not want to call the [!CAUTION] +> The preceding example code includes a `while` loop that polls the task's property to determine when the task has completed. This should never be done in production code as it is very inefficient. + If you do not wait on a task that propagates an exception, or access its property, the exception is escalated according to the .NET exception policy when the task is garbage-collected. When exceptions are allowed to bubble up back to the joining thread, it is possible that a task may continue to process some items after the exception is raised. @@ -92,6 +95,12 @@ In a meaningful application, the continuation delegate could log detailed inform Use a [`try-catch`](../../csharp/language-reference/keywords/try-catch.md) statement to handle and observe thrown exceptions. Alternatively, observe the exception by accessing the property. +> [!IMPORTANT] +> The cannot be explicitly caught when using the following expressions: +> +> - `await task` +> - `task.GetAwaiter().GetResult()` + ## UnobservedTaskException event In some scenarios, such as when hosting untrusted plug-ins, benign exceptions might be common, and it might be too difficult to manually observe them all. In these cases, you can handle the event. The instance that is passed to your handler can be used to prevent the unobserved exception from being propagated back to the joining thread. diff --git a/docs/standard/parallel-programming/how-to-perform-action-when-a-dataflow-block-receives-data.md b/docs/standard/parallel-programming/how-to-perform-action-when-a-dataflow-block-receives-data.md index a505017d8e626..9cb9b9682e007 100644 --- a/docs/standard/parallel-programming/how-to-perform-action-when-a-dataflow-block-receives-data.md +++ b/docs/standard/parallel-programming/how-to-perform-action-when-a-dataflow-block-receives-data.md @@ -29,7 +29,7 @@ ms.assetid: fc2585dc-965e-4632-ace7-73dd02684ed3 ## Robust Programming - This example provides a delegate of type to the object to perform the task of the dataflow block synchronously. To enable the dataflow block to behave asynchronously, provide a delegate of type to the dataflow block. When a dataflow block behaves asynchronously, the task of the dataflow block is complete only when the returned object finishes. The following example modifies the `CountBytes` method and uses the [async](../../csharp/language-reference/keywords/async.md) and [await](../../csharp/language-reference/operators/await.md) operators ([Async](../../visual-basic/language-reference/modifiers/async.md) and [Await](../../visual-basic/language-reference/operators/await-operator.md) in Visual Basic) to asynchronously compute the total number of bytes that are zero in the provided file. The method performs file read operations asynchronously. + This example provides a delegate of type to the object to perform the task of the dataflow block synchronously. To enable the dataflow block to behave asynchronously, provide a delegate of type `Func>` to the dataflow block. When a dataflow block behaves asynchronously, the task of the dataflow block is complete only when the returned object finishes. The following example modifies the `CountBytes` method and uses the [async](../../csharp/language-reference/keywords/async.md) and [await](../../csharp/language-reference/operators/await.md) operators ([Async](../../visual-basic/language-reference/modifiers/async.md) and [Await](../../visual-basic/language-reference/operators/await-operator.md) in Visual Basic) to asynchronously compute the total number of bytes that are zero in the provided file. The method performs file read operations asynchronously. [!code-csharp[TPLDataflow_ExecutionBlocks#2](../../../samples/snippets/csharp/VS_Snippets_Misc/tpldataflow_executionblocks/cs/dataflowexecutionblocks.cs#2)] [!code-vb[TPLDataflow_ExecutionBlocks#2](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_executionblocks/vb/dataflowexecutionblocks.vb#2)] diff --git a/docs/standard/parallel-programming/how-to-write-messages-to-and-read-messages-from-a-dataflow-block.md b/docs/standard/parallel-programming/how-to-write-messages-to-and-read-messages-from-a-dataflow-block.md index d89fc1b5a9450..52473d2b66dd2 100644 --- a/docs/standard/parallel-programming/how-to-write-messages-to-and-read-messages-from-a-dataflow-block.md +++ b/docs/standard/parallel-programming/how-to-write-messages-to-and-read-messages-from-a-dataflow-block.md @@ -29,7 +29,7 @@ You can also use the method acts synchronously, the object in the previous examples receives all data before the second loop reads data. The following example extends the first example by using to read from and write to the message block concurrently. Because performs actions concurrently, the values are not written to the object in any specific order. +Because the method acts synchronously, the object in the previous examples receives all data before the second loop reads data. The following example extends the first example by using to read from and write to the message block concurrently. Because awaits all the asynchronous operations that are executing concurrently, the values are not written to the object in any specific order. :::code language="csharp" source="../../../samples/snippets/csharp/VS_Snippets_Misc/tpldataflow_readwrite/cs/dataflowreadwrite.cs" id="4"::: :::code language="vb" source="../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpldataflow_readwrite/vb/dataflowreadwrite.vb" id="4"::: diff --git a/docs/standard/runtime-libraries-overview.md b/docs/standard/runtime-libraries-overview.md index 16a3b9807f706..ac93c78fe2355 100644 --- a/docs/standard/runtime-libraries-overview.md +++ b/docs/standard/runtime-libraries-overview.md @@ -24,10 +24,12 @@ Some libraries are provided in NuGet packages rather than included in the runtim | [Dependency injection](../core/extensions/dependency-injection.md) | [`Microsoft.Extensions.DependencyInjection`][di] | | [File globbing](../core/extensions/file-globbing.md) | [`Microsoft.Extensions.FileSystemGlobbing`][fsg] | | [Generic Host](../core/extensions/generic-host.md) | [`Microsoft.Extensions.Hosting`][host] | -| [HTTP](../core/extensions/http-client.md) | [`Microsoft.Extensions.Http`][http] | +| [HTTP](../core/extensions/http-client.md) | [`Microsoft.Extensions.Http`]1[http] | | [Localization](../core/extensions/localization.md) | [`Microsoft.Extensions.Localization`][loc] | | [Logging](../core/extensions/logging.md) | [`Microsoft.Extensions.Logging`][log] | +1For some target frameworks, including `net6.0`, these types are part of the shared framework and don't need to be installed separately. + [configuration]: https://www.nuget.org/packages/Microsoft.Extensions.Configuration [di]: https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection [fsg]: https://www.nuget.org/packages/Microsoft.Extensions.FileSystemGlobbing diff --git a/docs/standard/security/key-security-concepts.md b/docs/standard/security/key-security-concepts.md index 55470189b7395..e8851fb1488b6 100644 --- a/docs/standard/security/key-security-concepts.md +++ b/docs/standard/security/key-security-concepts.md @@ -29,7 +29,7 @@ During just-in-time (JIT) compilation, an optional verification process examines Although verification of type safety is not mandatory to run managed code, type safety plays a crucial role in assembly isolation and security enforcement. When code is type safe, the common language runtime can completely isolate assemblies from each other. This isolation helps ensure that assemblies cannot adversely affect each other and it increases application reliability. Type-safe components can execute safely in the same process even if they are trusted at different levels. When code is not type safe, unwanted side effects can occur. For example, the runtime cannot prevent managed code from calling into native (unmanaged) code and performing malicious operations. When code is type safe, the runtime's security enforcement mechanism ensures that it does not access native code unless it has permission to do so. All code that is not type safe must have been granted with the passed enum member to run. -For more information, see [Code Access Security Basics](/previous-versions/dotnet/framework/code-access-security/code-access-security-basics). +[!INCLUDE [cas-deprecated](../../../includes/cas-deprecated.md)] ## Principal diff --git a/docs/standard/serialization/custom-serialization.md b/docs/standard/serialization/custom-serialization.md index 90c81d236ed9e..194a52f5a1507 100644 --- a/docs/standard/serialization/custom-serialization.md +++ b/docs/standard/serialization/custom-serialization.md @@ -1,7 +1,7 @@ --- title: "Custom serialization" description: Custom serialization is controlling the serialization and deserialization of a type. Controlling serialization can ensure serialization compatibility. -ms.date: "03/30/2017" +ms.date: 04/21/2022 dev_langs: - "csharp" - "vb" @@ -26,7 +26,7 @@ Custom serialization is the process of controlling the serialization and deseria [!INCLUDE [binary-serialization-warning](../../../includes/binary-serialization-warning.md)] > [!IMPORTANT] -> In versions previous to .NET Framework 4.0, serialization of custom user data in a partially trusted assembly was accomplished using `GetObjectData`. Starting with version 4.0, that method is marked with the attribute, which prevents execution in partially trusted assemblies. To work around this condition, implement the interface. +> In versions previous to .NET Framework 4.0, serialization of custom user data in a partially trusted assembly was accomplished using `GetObjectData`. In .NET Framework version 4.0 - 4.8, that method is marked with the attribute, which prevents execution in partially trusted assemblies. To work around this condition, implement the interface. ## Running custom methods during and after serialization @@ -50,7 +50,7 @@ The recommended way to run custom methods during and after serialization is to a In addition, you should not use default serialization on a class that is marked with the [Serializable](xref:System.SerializableAttribute) attribute and has declarative or imperative security at the class level or on its constructors. Instead, these classes should always implement the interface. - Implementing involves implementing the `GetObjectData` method and a special constructor that is used when the object is deserialized. The following sample code shows how to implement on the `MyObject` class from a previous section. + Implementing involves implementing the `GetObjectData` method and a special constructor that's used when the object is deserialized. The following sample code shows how to implement on the `MyObject` class from a previous section. ```csharp [Serializable] @@ -71,7 +71,6 @@ public class MyObject : ISerializable str = info.GetString("k"); } - [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("i", n1); @@ -98,7 +97,6 @@ Public Class MyObject str = info.GetString("k") End Sub 'New - _ Public Overridable Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) info.AddValue("i", n1) info.AddValue("j", n2) @@ -107,17 +105,13 @@ Public Class MyObject End Class ``` - When **GetObjectData** is called during serialization, you are responsible for populating the provided with the method call. Add the variables to be serialized as name and value pairs. Any text can be used as the name. You have the freedom to decide which member variables are added to the , provided that sufficient data is serialized to restore the object during deserialization. Derived classes should call the **GetObjectData** method on the base object if the latter implements . + When **GetObjectData** is called during serialization, you are responsible for populating the provided with the method call. Add the variables to be serialized as name and value pairs. Any text can be used as the name. You have the freedom to decide which member variables are added to the , provided that sufficient data is serialized to restore the object during deserialization. Derived classes should call the **GetObjectData** method on the base object if the latter implements . - Note that serialization can allow other code to see or modify object instance data that is otherwise inaccessible. Therefore, code that performs serialization requires the [SecurityPermission](xref:System.Security.Permissions.SecurityPermissionAttribute) with the flag specified. Under default policy, this permission is not given to Internet-downloaded or intranet code; only code on the local computer is granted this permission. The **GetObjectData** method must be explicitly protected either by demanding the [SecurityPermission](xref:System.Security.Permissions.SecurityPermissionAttribute) with the flag specified or by demanding other permissions that specifically help protect private data. - - If a private field stores sensitive information, you should demand the appropriate permissions on **GetObjectData** to protect the data. Remember that code that has been granted [SecurityPermission](xref:System.Security.Permissions.SecurityPermissionAttribute) with the **SerializationFormatter** flag specified can view and modify the data stored in private fields. A malicious caller granted this [SecurityPermission](xref:System.Security.Permissions.SecurityPermissionAttribute) can view data such as hidden directory locations or granted permissions and use the data to exploit a security vulnerability on the computer. For a complete list of the security permission flags you can specify, see the [SecurityPermissionFlag Enumeration](xref:System.Security.Permissions.SecurityPermissionFlag). - - It's important to stress that when is added to a class you must implement both **GetObjectData** and the special constructor. The compiler warns you if **GetObjectData** is missing. However, because it is impossible to enforce the implementation of a constructor, no warning is provided if the constructor is absent, and an exception is thrown when an attempt is made to deserialize a class without the constructor. + It's important to stress that when is added to a class, you must implement both **GetObjectData** and the special constructor. The compiler warns you if **GetObjectData** is missing. However, because it is impossible to enforce the implementation of a constructor, no warning is provided if the constructor is absent, and an exception is thrown when an attempt is made to deserialize a class without the constructor. The current design was favored above a method to get around potential security and versioning problems. For example, a `SetObjectData` method must be public if it is defined as part of an interface; thus users must write code to defend against having the **SetObjectData** method called multiple times. Otherwise, a malicious application that calls the **SetObjectData** method on an object in the process of executing an operation can cause potential problems. - During deserialization, is passed to the class using the constructor provided for this purpose. Any visibility constraints placed on the constructor are ignored when the object is deserialized; so you can mark the class as public, protected, internal, or private. However, it is a best practice to make the constructor protected unless the class is sealed, in which case the constructor should be marked private. The constructor should also perform thorough input validation. To avoid misuse by malicious code, the constructor should enforce the same security checks and permissions required to obtain an instance of the class using any other constructor. If you do not follow this recommendation, malicious code can preserialize an object, obtain control with the [SecurityPermission](xref:System.Security.Permissions.SecurityPermissionAttribute) with the flag specified and deserialize the object on a client computer bypassing any security that would have been applied during standard instance construction using a public constructor. + During deserialization, is passed to the class using the constructor provided for this purpose. Any visibility constraints placed on the constructor are ignored when the object is deserialized; so you can mark the class as public, protected, internal, or private. However, it is a best practice to make the constructor protected unless the class is sealed, in which case the constructor should be marked private. The constructor should also perform thorough input validation. To restore the state of the object, simply retrieve the values of the variables from using the names used during serialization. If the base class implements , the base constructor should be called to allow the base object to restore its variables. @@ -140,7 +134,6 @@ public class ObjectTwo : MyObject num = si.GetInt32("num"); } - [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo si, StreamingContext context) { base.GetObjectData(si,context); @@ -165,7 +158,6 @@ Public Class ObjectTwo num = si.GetInt32("num") End Sub - _ Public Overrides Sub GetObjectData(ByVal si As SerializationInfo, ByVal context As StreamingContext) MyBase.GetObjectData(si, context) si.AddValue("num", num) diff --git a/docs/standard/serialization/serialization-guidelines.md b/docs/standard/serialization/serialization-guidelines.md index 446c9268f0542..bdf7b8e09540c 100644 --- a/docs/standard/serialization/serialization-guidelines.md +++ b/docs/standard/serialization/serialization-guidelines.md @@ -133,11 +133,6 @@ This article lists the guidelines to consider when designing an API to be serial [!code-csharp[SerializationGuidelines#10](../../../samples/snippets/csharp/VS_Snippets_CFX/serializationguidelines/cs/source.cs#10)] [!code-vb[SerializationGuidelines#10](../../../samples/snippets/visualbasic/VS_Snippets_CFX/serializationguidelines/vb/source.vb#10)] -5. DO apply a link demand to **ISerializable.GetObjectData** implementation. This ensures that only fully trusted core and the runtime serializer have access to the member. - - [!code-csharp[SerializationGuidelines#11](../../../samples/snippets/csharp/VS_Snippets_CFX/serializationguidelines/cs/source.cs#11)] - [!code-vb[SerializationGuidelines#11](../../../samples/snippets/visualbasic/VS_Snippets_CFX/serializationguidelines/vb/source.vb#11)] - ## See also - [Using Data Contracts](../../framework/wcf/feature-details/using-data-contracts.md) diff --git a/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/GetDefaultConverter.cs b/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/GetDefaultConverter.cs new file mode 100644 index 0000000000000..398b71c817042 --- /dev/null +++ b/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/GetDefaultConverter.cs @@ -0,0 +1,55 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace GetDefaultConverter; + +public class WeatherForecast +{ + public DateTime Date { get; set; } + public int TemperatureC { get; set; } + public string? Summary { get; set; } +} + +// +public class MyCustomConverter : JsonConverter +{ + private readonly static JsonConverter s_defaultConverter = + (JsonConverter)JsonSerializerOptions.Default.GetConverter(typeof(int)); + + // Custom serialization logic + public override void Write( + Utf8JsonWriter writer, int value, JsonSerializerOptions options) + { + writer.WriteStringValue(value.ToString()); + } + + // Fall back to default deserialization logic + public override int Read( + ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + return s_defaultConverter.Read(ref reader, typeToConvert, options); + } +} +// + +public class Program +{ + public static void Main() + { + var weatherForecast = new WeatherForecast + { + Date = DateTime.Parse("2019-08-01"), + TemperatureC = 25, + Summary = "Hot", + }; + + var options = new JsonSerializerOptions { WriteIndented = true }; + options.Converters.Add(new MyCustomConverter()); + + string jsonString = JsonSerializer.Serialize(weatherForecast, options); + Console.WriteLine(jsonString); + + weatherForecast = JsonSerializer.Deserialize(jsonString); + Console.WriteLine(weatherForecast!.TemperatureC); + } +} diff --git a/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/Program.cs b/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/Program.cs new file mode 100644 index 0000000000000..11c2f56e9f8be --- /dev/null +++ b/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/Program.cs @@ -0,0 +1,9 @@ +namespace SystemTextJsonSamples; +public class Program +{ + static void Main() + { + Console.WriteLine("\n============================= Get system default converter\n"); + GetDefaultConverter.Program.Main(); + } +} diff --git a/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/SystemTextJsonSamples.csproj b/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/SystemTextJsonSamples.csproj new file mode 100644 index 0000000000000..d0da09096fc8a --- /dev/null +++ b/docs/standard/serialization/snippets/system-text-json-converters-how-to/csharp/SystemTextJsonSamples.csproj @@ -0,0 +1,11 @@ + + + + Exe + net7.0 + enable + enable + SystemTextJsonSamples.Program + + + diff --git a/docs/standard/serialization/system-text-json-configure-options.md b/docs/standard/serialization/system-text-json-configure-options.md index 6543fbf9dfa41..1ea8c25231ac9 100644 --- a/docs/standard/serialization/system-text-json-configure-options.md +++ b/docs/standard/serialization/system-text-json-configure-options.md @@ -1,7 +1,7 @@ --- title: How to instantiate JsonSerializerOptions with System.Text.Json description: "Learn how to avoid performance issues and how to use available constructors for JsonSerializerOptions instances." -ms.date: 03/28/2022 +ms.date: 05/12/2022 no-loc: [System.Text.Json, Newtonsoft.Json] zone_pivot_groups: dotnet-version dev_langs: @@ -35,7 +35,9 @@ The size of the metadata cache in a `JsonSerializerOptions` instance depends on ::: zone pivot="dotnet-7-0" -If the instance of `JsonSerializerOptions` that you need to use is the default instance (has all of the default settings and the default converters), use the property rather than creating an options instance. +## The `JsonSerializerOptions.Default` property + +If the instance of `JsonSerializerOptions` that you need to use is the default instance (has all of the default settings and the default converters), use the property rather than creating an options instance. For more information, see [Use default system converter](system-text-json-converters-how-to.md#use-default-system-converter). ::: zone-end @@ -46,6 +48,9 @@ There is a [JsonSerializerOptions constructor](xref:System.Text.Json.JsonSeriali :::code language="csharp" source="snippets/system-text-json-how-to-5-0/csharp/CopyOptions.cs" highlight="28"::: :::code language="vb" source="snippets/system-text-json-how-to-5-0/vb/CopyOptions.vb" ::: + +The metadata cache of the existing `JsonSerializerOptions` instance isn't copied to the new instance. So using this constructor is not the same as reusing an existing instance of `JsonSerializerOptions`. + ::: zone-end ::: zone pivot="dotnet-core-3-1" diff --git a/docs/standard/serialization/system-text-json-converters-how-to.md b/docs/standard/serialization/system-text-json-converters-how-to.md index 2582d4eb9ae59..c500d6ab5cf15 100644 --- a/docs/standard/serialization/system-text-json-converters-how-to.md +++ b/docs/standard/serialization/system-text-json-converters-how-to.md @@ -1,7 +1,7 @@ --- title: "How to write custom converters for JSON serialization - .NET" description: "Learn how to create custom converters for the JSON serialization classes that are provided in the System.Text.Json namespace." -ms.date: 12/04/2021 +ms.date: 05/12/2022 no-loc: [System.Text.Json, Newtonsoft.Json] zone_pivot_groups: dotnet-version helpviewer_keywords: @@ -24,12 +24,23 @@ A *converter* is a class that converts an object or a value to and from JSON. Th You can also write custom converters to customize or extend `System.Text.Json` with functionality not included in the current release. The following scenarios are covered later in this article: -::: zone pivot="dotnet-5-0,dotnet-7-0,dotnet-6-0" +::: zone pivot="dotnet-7-0" + +* [Deserialize inferred types to object properties](#deserialize-inferred-types-to-object-properties). +* [Support polymorphic deserialization](#support-polymorphic-deserialization). +* [Support round-trip for Stack\](#support-round-trip-for-stackt). +* [Support enum string value deserialization](#support-enum-string-value-deserialization). +* [Use default system converter](#use-default-system-converter). + +::: zone-end + +::: zone pivot="dotnet-5-0,dotnet-6-0" * [Deserialize inferred types to object properties](#deserialize-inferred-types-to-object-properties). * [Support polymorphic deserialization](#support-polymorphic-deserialization). * [Support round-trip for Stack\](#support-round-trip-for-stackt). * [Support enum string value deserialization](#support-enum-string-value-deserialization). + ::: zone-end ::: zone pivot="dotnet-core-3-1" @@ -222,12 +233,23 @@ A built-in converter is chosen only if no applicable custom converter is registe The following sections provide converter samples that address some common scenarios that built-in functionality doesn't handle. -::: zone pivot="dotnet-5-0,dotnet-7-0,dotnet-6-0" +::: zone pivot="dotnet-7-0" * [Deserialize inferred types to object properties](#deserialize-inferred-types-to-object-properties). * [Support polymorphic deserialization](#support-polymorphic-deserialization). * [Support round-trip for Stack\](#support-round-trip-for-stackt). * [Support enum string value deserialization](#support-enum-string-value-deserialization). +* [Use default system converter](#use-default-system-converter). + +::: zone-end + +::: zone pivot="dotnet-5-0,dotnet-6-0" + +* [Deserialize inferred types to object properties](#deserialize-inferred-types-to-object-properties). +* [Support polymorphic deserialization](#support-polymorphic-deserialization). +* [Support round-trip for Stack\](#support-round-trip-for-stackt). +* [Support enum string value deserialization](#support-enum-string-value-deserialization). + ::: zone-end ::: zone pivot="dotnet-core-3-1" @@ -236,6 +258,7 @@ The following sections provide converter samples that address some common scenar * [Support Dictionary with non-string key](#support-dictionary-with-non-string-key). * [Support polymorphic deserialization](#support-polymorphic-deserialization). * [Support round-trip for Stack\](#support-round-trip-for-stackt). + ::: zone-end For a sample converter, see [Supported collection types](system-text-json-supported-collection-types.md#systemdata-namespace). @@ -406,6 +429,16 @@ By default, the built-in property, as shown in the following example: + +:::code language="csharp" source="snippets/system-text-json-converters-how-to/csharp/GetDefaultConverter.cs" id="Converter" highlight="3-4,17"::: + +::: zone-end + ## Handle null values By default, the serializer handles null values as follows: diff --git a/docs/standard/serialization/system-text-json-how-to.md b/docs/standard/serialization/system-text-json-how-to.md index 6576e5290a0da..8efffde6e96c8 100644 --- a/docs/standard/serialization/system-text-json-how-to.md +++ b/docs/standard/serialization/system-text-json-how-to.md @@ -14,6 +14,7 @@ helpviewer_keywords: - "serialization" - "objects, serializing" ms.topic: how-to +adobe-target: true --- # How to serialize and deserialize (marshal and unmarshal) JSON in .NET diff --git a/docs/standard/serialization/xml-schema-definition-tool-xsd-exe.md b/docs/standard/serialization/xml-schema-definition-tool-xsd-exe.md index d8cd226108cf2..f7bbb3be9c06e 100644 --- a/docs/standard/serialization/xml-schema-definition-tool-xsd-exe.md +++ b/docs/standard/serialization/xml-schema-definition-tool-xsd-exe.md @@ -59,7 +59,7 @@ xsd {file.dll | file.exe} [-outputdir:directory] [/type:typename [...]][/paramet |**/e\[lement\]:**_element_|Specifies the element in the schema to generate code for. By default all elements are typed. You can specify this argument more than once.| |**/enableDataBinding**|Implements the interface on all generated types to enable data binding. The short form is `/edb`.| |**/enableLinqDataSet**|(Short form: `/eld`.) Specifies that the generated DataSet can be queried against using LINQ to DataSet. This option is used when the /dataset option is also specified. For more information, see [LINQ to DataSet Overview](../../framework/data/adonet/linq-to-dataset-overview.md) and [Querying Typed DataSets](../../framework/data/adonet/querying-typed-datasets.md). For general information about using LINQ, see [Language-Integrated Query (LINQ) - C#](../../csharp/programming-guide/concepts/linq/index.md) or [Language-Integrated Query (LINQ) - Visual Basic](../../visual-basic/programming-guide/concepts/linq/index.md).| -|**/f\[ields\]**|Generates fields instead of properties. By default, properties are generated.| +|**/f\[ields\]**|Generates fields only. By default, [properties with backing fields](../../csharp/programming-guide/classes-and-structs/properties.md#properties-with-backing-fields) are generated.| |**/l\[anguage\]:**_language_|Specifies the programming language to use. Choose from `CS` (C#, which is the default), `VB` (Visual Basic), `JS` (JScript), or `VJS` (Visual J#). You can also specify a fully qualified name for a class implementing | |**/n\[amespace\]:**_namespace_|Specifies the runtime namespace for the generated types. The default namespace is `Schemas`.| |**/nologo**|Suppresses the banner.| diff --git a/docs/standard/simd.md b/docs/standard/simd.md index 166ebc145395e..7cf88b01cea0b 100644 --- a/docs/standard/simd.md +++ b/docs/standard/simd.md @@ -72,25 +72,43 @@ var mResult = Matrix4x4.Multiply(m1, m2); The gives the ability to use longer vectors. The count of a instance is fixed, but its value depends on the CPU of the machine running the code. -The example below demonstrates how to calculate the element-wise product of two arrays using . +The following example demonstrates how to calculate the element-wise sum of two arrays using . ```csharp -double[] SimdVectorProd(double[] left, double[] right) +double[] Sum(double[] left, double[] right) { - var offset = Vector.Count; - double[] result = new double[left.Length]; - int i = 0; - for (i = 0; i < left.Length; i += offset) + if (left is null) + { + throw new ArgumentNullException(nameof(left)); + } + + if (right is null) + { + throw new ArgumentNullException(nameof(right)); + } + + if (left.Length != right.Length) + { + throw new ArgumentException($"{nameof(left)} and {nameof(right)} are not the same length"); + } + + int length = left.Length; + double[] result = new double[length]; + + // Get the number of elements that can't be processed in the vector + // NOTE: Vector.Count is a JIT time constant and will get optimized accordingly + int remaining = length % Vector.Count; + + for (int i = 0; i < length - remaining; i += Vector.Count) { var v1 = new Vector(left, i); var v2 = new Vector(right, i); - (v1 * v2).CopyTo(result, i); + (v1 + v2).CopyTo(result, i); } - //remaining items - for (; i < left.Length; ++i) + for (int i = length - remaining; i < length; i++) { - result[i] = left[i] * right[i]; + result[i] = left[i] + right[i]; } return result; diff --git a/docs/standard/threading/destroying-threads.md b/docs/standard/threading/destroying-threads.md index 311f09afa8f5f..bfde9c94c2022 100644 --- a/docs/standard/threading/destroying-threads.md +++ b/docs/standard/threading/destroying-threads.md @@ -1,7 +1,7 @@ --- title: "Destroying threads" description: Know your options when you need to destroy a thread in .NET, such as cooperative cancellation or the Thread.Abort method. Learn to handle ThreadAbortException. -ms.date: "03/30/2017" +ms.date: 05/26/2022 dev_langs: - "csharp" - "vb" @@ -10,12 +10,16 @@ helpviewer_keywords: - "threading [.NET], destroying threads" ms.topic: how-to --- -# Destroying threads +# Destroy threads -To terminate the execution of the thread, you usually use the [cooperative cancellation model](cancellation-in-managed-threads.md). Sometimes it is not possible to stop a thread cooperatively, because it runs third-party code not designed for cooperative cancellation. The method in .NET Framework can be used to terminate a managed thread forcibly. When you call , the Common Language Runtime throws a in the target thread, which the target thread can catch. For more information, see . The method is not supported in .NET 5 (including .NET Core) and later versions. If you need to terminate the execution of third-party code forcibly in .NET 5+, run it in the separate process and use . +To terminate the execution of the thread, you usually use the [cooperative cancellation model](cancellation-in-managed-threads.md). However, sometimes it's not possible to stop a thread cooperatively, because it runs third-party code not designed for cooperative cancellation. In .NET Framework apps, you can use the method to terminate a managed thread forcibly. When you call , the Common Language Runtime throws a in the target thread, which the target thread can catch. (However, the .NET Framework runtime always automatically rethrows the exception after the `catch` block.) For more information, see . + +The method [is not supported](../../core/compatibility/core-libraries/5.0/thread-abort-obsolete.md) in .NET 5 (including .NET Core) and later versions. If you need to terminate the execution of third-party code forcibly in .NET 5+, run it in the separate process and use . > [!NOTE] -> If a thread is executing unmanaged code when its method is called, the runtime marks it . The exception is thrown when the thread returns to managed code. +> +> - When you call to abort a thread other than the current thread, you don't know what code has executed or failed to execute when the is thrown. You also cannot be certain of the state of your application or any application and user state that it's responsible for preserving. For example, calling may prevent the execution of static constructors or the release of managed or unmanaged resources. +> - If a thread is executing unmanaged code when its method is called, the runtime marks it . The exception is thrown when the thread returns to managed code. Once a thread is aborted, it cannot be restarted. @@ -62,6 +66,7 @@ catch (ThreadAbortException ex) ## See also +- [Thread.Abort is obsolete](../../core/compatibility/core-libraries/5.0/thread-abort-obsolete.md) - - - [Using Threads and Threading](using-threads-and-threading.md) diff --git a/docs/standard/threading/exceptions-in-managed-threads.md b/docs/standard/threading/exceptions-in-managed-threads.md index 361ba7a28f934..c659812979970 100644 --- a/docs/standard/threading/exceptions-in-managed-threads.md +++ b/docs/standard/threading/exceptions-in-managed-threads.md @@ -1,7 +1,7 @@ --- title: "Exceptions in Managed Threads" description: See how unhandled exceptions are handled in .NET. Most unhandled thread exceptions proceed naturally and lead to application termination. -ms.date: "03/30/2017" +ms.date: 05/26/2022 helpviewer_keywords: - "unhandled exceptions,in managed threads" - "threading [.NET],unhandled exceptions" @@ -11,62 +11,28 @@ ms.assetid: 11294769-2e89-43cb-890e-ad4ad79cfbee --- # Exceptions in managed threads -The common language runtime allows most unhandled exceptions in threads to proceed naturally. In most cases this means that the unhandled exception causes the application to terminate. +The common language runtime allows most unhandled exceptions in threads to proceed naturally. In most cases, this means that the unhandled exception causes the application to terminate. However, the common language runtime provides a backstop for certain unhandled exceptions that are used for controlling program flow: -The common language runtime provides a backstop for certain unhandled exceptions that are used for controlling program flow: - -- A is thrown in a thread because was called. +- A is thrown in a thread because was called. This only applies to .NET Framework apps. - An is thrown in a thread because the application domain in which the thread is executing is being unloaded. - The common language runtime or a host process terminates the thread by throwing an internal exception. - If any of these exceptions are unhandled in threads created by the common language runtime, the exception terminates the thread, but the common language runtime does not allow the exception to proceed further. +If any of these exceptions are unhandled in threads created by the common language runtime, the exception terminates the thread, but the common language runtime does not allow the exception to proceed further. - If these exceptions are unhandled in the main thread, or in threads that entered the runtime from unmanaged code, they proceed normally, resulting in termination of the application. +If these exceptions are unhandled in the main thread, or in threads that entered the runtime from unmanaged code, they proceed normally, resulting in termination of the application. > [!NOTE] -> It is possible for the runtime to throw an unhandled exception before any managed code has had a chance to install an exception handler. Even though managed code had no chance to handle such an exception, the exception is allowed to proceed naturally. +> It's possible for the runtime to throw an unhandled exception before any managed code has had a chance to install an exception handler. Even though managed code had no chance to handle such an exception, the exception is allowed to proceed naturally. -## Exposing Threading Problems During Development +## Expose threading problems during development When threads are allowed to fail silently, without terminating the application, serious programming problems can go undetected. This is a particular problem for services and other applications that run for extended periods. As threads fail, program state gradually becomes corrupted. Application performance may degrade, or the application might become unresponsive. - Allowing unhandled exceptions in threads to proceed naturally, until the operating system terminates the program, exposes such problems during development and testing. Error reports on program terminations support debugging. - -## Change from previous versions - -In .NET Framework versions 1.0 and 1.1, the common language runtime provides a backstop for unhandled exceptions in the following situations: - -- There is no such thing as an unhandled exception on a thread pool thread. When a task throws an exception that it does not handle, the runtime prints the exception stack trace to the console and then returns the thread to the thread pool. - -- There is no such thing as an unhandled exception on a thread created with the method of the class. When code running on such a thread throws an exception that it does not handle, the runtime prints the exception stack trace to the console and then gracefully terminates the thread. - -- There is no such thing as an unhandled exception on the finalizer thread. When a finalizer throws an exception that it does not handle, the runtime prints the exception stack trace to the console and then allows the finalizer thread to resume running finalizers. - - The foreground or background status of a managed thread does not affect this behavior. - - For unhandled exceptions on threads originating in unmanaged code, the difference is more subtle. The runtime JIT-attach dialog preempts the operating system dialog for managed exceptions or native exceptions on threads that have passed through native code. The process terminates in all cases. - -### Migration - -If you are migrating from .NET Framework 1.0 or 1.1 and took advantage of the runtime backstop, for example to terminate threads, consider one of the following migration strategies: - -- Restructure the code so the thread exits gracefully when a signal is received. - -- Use the method to abort the thread. - -- If a thread must be stopped so that process termination can proceed, make the thread a background thread so that it is automatically terminated on process exit. - -In all cases, the strategy should follow the design guidelines for exceptions. See [Design Guidelines for Exceptions](../design-guidelines/exceptions.md). - -As a temporary compatibility measure, administrators can place a compatibility flag in the `` section of the application configuration file. This causes the common language runtime to revert to the behavior of versions 1.0 and 1.1. - -```xml - -``` + Allowing unhandled exceptions in threads to proceed naturally, until the operating system terminates the program, exposes such problems during development and testing. Error reports on program terminations support debugging. -## Host Override +## Host override An unmanaged host can use the [ICLRPolicyManager](../../framework/unmanaged-api/hosting/iclrpolicymanager-interface.md) interface in the Hosting API to override the default unhandled exception policy of the common language runtime. The [ICLRPolicyManager::SetUnhandledExceptionPolicy](../../framework/unmanaged-api/hosting/iclrpolicymanager-setunhandledexceptionpolicy-method.md) function is used to set the policy for unhandled exceptions. diff --git a/docs/standard/threading/managed-threading-best-practices.md b/docs/standard/threading/managed-threading-best-practices.md index c35e015dae51c..605e8f9927cbd 100644 --- a/docs/standard/threading/managed-threading-best-practices.md +++ b/docs/standard/threading/managed-threading-best-practices.md @@ -82,9 +82,9 @@ Use the pr ## General recommendations - Consider the following guidelines when using multiple threads: +Consider the following guidelines when using multiple threads: -- Don't use to terminate other threads. Calling **Abort** on another thread is akin to throwing an exception on that thread, without knowing what point that thread has reached in its processing. +- Don't use to terminate other threads. Calling `Abort` on another thread is akin to throwing an exception on that thread, without knowing what point that thread has reached in its processing. - Don't use and to synchronize the activities of multiple threads. Do use , , , and . @@ -163,7 +163,7 @@ Use the pr ## Recommendations for class libraries - Consider the following guidelines when designing class libraries for multithreading: +Consider the following guidelines when designing class libraries for multithreading: - Avoid the need for synchronization, if possible. This is especially true for heavily used code. For example, an algorithm might be adjusted to tolerate a race condition rather than eliminate it. Unnecessary synchronization decreases performance and creates the possibility of deadlocks and race conditions. diff --git a/docs/standard/threading/pausing-and-resuming-threads.md b/docs/standard/threading/pausing-and-resuming-threads.md index 057b187d209fd..cadad15431705 100644 --- a/docs/standard/threading/pausing-and-resuming-threads.md +++ b/docs/standard/threading/pausing-and-resuming-threads.md @@ -39,7 +39,7 @@ The most common ways to synchronize the activities of threads are to block and r - wakes a thread out of any wait it might be in and causes a to be thrown in the destination thread. -- wakes a thread out of any wait it might be in and causes a to be thrown on the thread. For details, see [Destroying Threads](destroying-threads.md). +- .NET Framework only: wakes a thread out of any wait it might be in and causes a to be thrown on the thread. For details, see [Destroy threads](destroying-threads.md). ## See also diff --git a/docs/standard/threading/toc.yml b/docs/standard/threading/toc.yml index 69b73b1c755fa..f77b3df9cf657 100644 --- a/docs/standard/threading/toc.yml +++ b/docs/standard/threading/toc.yml @@ -1,21 +1,21 @@ items: - name: Threading items: - - name: Managed Threading Basics + - name: Managed threading basics items: - name: Overview href: managed-threading-basics.md - - name: Threads and Threading + - name: Threads and threading href: threads-and-threading.md - - name: Exceptions in Managed Threads + - name: Exceptions in managed threads href: exceptions-in-managed-threads.md - - name: Synchronizing Data for Multithreading + - name: Synchronize data for multithreading href: synchronizing-data-for-multithreading.md - - name: Foreground and Background Threads + - name: Foreground and background threads href: foreground-and-background-threads.md - - name: Managed and Unmanaged Threading in Windows + - name: Managed and unmanaged threading in windows href: managed-and-unmanaged-threading-in-windows.md - - name: "Thread Local Storage: Thread-Relative Static Fields and Data Slots" + - name: "Thread local storage: Thread-relative static fields and data slots" href: thread-local-storage-thread-relative-static-fields-and-data-slots.md - name: Using threads and threading items: @@ -23,27 +23,29 @@ items: href: using-threads-and-threading.md - name: Creating threads and passing data at start time href: creating-threads-and-passing-data-at-start-time.md - - name: Pausing and interrupting threads + - name: Pause and interrupt threads href: pausing-and-resuming-threads.md - - name: Destroying threads - href: destroying-threads.md - - name: Scheduling threads + - name: Schedule threads href: scheduling-threads.md - - name: Cancellation in managed threads + - name: Cancel threads items: - name: Overview href: cancellation-in-managed-threads.md - - name: Canceling threads cooperatively + - name: Cancel threads cooperatively href: canceling-threads-cooperatively.md - - name: "How to: Listen for Cancellation Requests by Polling" - href: how-to-listen-for-cancellation-requests-by-polling.md - - name: "How to: Register Callbacks for Cancellation Requests" - href: how-to-register-callbacks-for-cancellation-requests.md - - name: "How to: Listen for Cancellation Requests That Have Wait Handles" - href: how-to-listen-for-cancellation-requests-that-have-wait-handles.md - - name: "How to: Listen for Multiple Cancellation Requests" - href: how-to-listen-for-multiple-cancellation-requests.md - - name: Managed Threading Best Practices + - name: How-tos + items: + - name: Listen for cancellation requests by polling + href: how-to-listen-for-cancellation-requests-by-polling.md + - name: Register callbacks for cancellation requests + href: how-to-register-callbacks-for-cancellation-requests.md + - name: Listen for cancellation requests that have wait handles + href: how-to-listen-for-cancellation-requests-that-have-wait-handles.md + - name: Listen for multiple cancellation requests + href: how-to-listen-for-multiple-cancellation-requests.md + - name: Destroy threads + href: destroying-threads.md + - name: Best practices href: managed-threading-best-practices.md - name: Threading objects and features items: diff --git a/docs/visual-basic/developing-apps/programming/computer-resources/how-to-create-a-registry-key-and-set-its-value.md b/docs/visual-basic/developing-apps/programming/computer-resources/how-to-create-a-registry-key-and-set-its-value.md index 274f0d89b0d44..1f73d45d8ee51 100644 --- a/docs/visual-basic/developing-apps/programming/computer-resources/how-to-create-a-registry-key-and-set-its-value.md +++ b/docs/visual-basic/developing-apps/programming/computer-resources/how-to-create-a-registry-key-and-set-its-value.md @@ -69,10 +69,11 @@ The following conditions may cause an exception: To run this process, your assembly requires a privilege level granted by the class. If you are running in a partial-trust context, the process might throw an exception due to insufficient privileges. Similarly, the user must have the correct ACLs for creating or writing to settings. For example, a local application that has the code access security permission might not have operating system permission. For more information, see [Code Access Security Basics](/previous-versions/dotnet/framework/code-access-security/code-access-security-basics). +[!INCLUDE [cas-deprecated](../../../../../includes/cas-deprecated.md)] + ## See also - - - - [Reading from and Writing to the Registry](reading-from-and-writing-to-the-registry.md) -- [Code Access Security Basics](/previous-versions/dotnet/framework/code-access-security/code-access-security-basics) diff --git a/docs/visual-basic/developing-apps/programming/computer-resources/how-to-read-a-value-from-a-registry-key.md b/docs/visual-basic/developing-apps/programming/computer-resources/how-to-read-a-value-from-a-registry-key.md index e2f5fb5c1a2ec..7298e1ac05204 100644 --- a/docs/visual-basic/developing-apps/programming/computer-resources/how-to-read-a-value-from-a-registry-key.md +++ b/docs/visual-basic/developing-apps/programming/computer-resources/how-to-read-a-value-from-a-registry-key.md @@ -48,7 +48,9 @@ The `GetValue` method of the `My.Computer.Registry` object can be used to read v ## .NET Framework Security - To run this process, your assembly requires a privilege level granted by the class. If you are running in a partial-trust context, the process might throw an exception due to insufficient privileges. Similarly, the user must have the correct ACLs for creating or writing to settings. For example, a local application that has the code access security permission might not have operating system permission. For more information, see [Code Access Security Basics](/previous-versions/dotnet/framework/code-access-security/code-access-security-basics). + To run this process, your assembly requires a privilege level granted by the class. If you are running in a partial-trust context, the process might throw an exception due to insufficient privileges. Similarly, the user must have the correct ACLs for creating or writing to settings. For example, a local application that has the code access security permission might not have operating system permission. For more information, see [Code Access Security Basics](/previous-versions/dotnet/framework/code-access-security/code-access-security-basics). + +[!INCLUDE [cas-deprecated](../../../../../includes/cas-deprecated.md)] ## See also diff --git a/docs/visual-basic/developing-apps/programming/drives-directories-files/how-to-create-a-file.md b/docs/visual-basic/developing-apps/programming/drives-directories-files/how-to-create-a-file.md index ead52f2e33845..a0f32aecf467e 100644 --- a/docs/visual-basic/developing-apps/programming/drives-directories-files/how-to-create-a-file.md +++ b/docs/visual-basic/developing-apps/programming/drives-directories-files/how-to-create-a-file.md @@ -49,5 +49,3 @@ This example creates an empty text file at the specified path using the - -- [Using Libraries from Partially Trusted Code](/previous-versions/dotnet/framework/code-access-security/using-libraries-from-partially-trusted-code) -- [Code Access Security Basics](/previous-versions/dotnet/framework/code-access-security/code-access-security-basics) diff --git a/docs/visual-basic/getting-started/additional-resources.md b/docs/visual-basic/getting-started/additional-resources.md index 771b6f111ce24..f2c1da73fc3b3 100644 --- a/docs/visual-basic/getting-started/additional-resources.md +++ b/docs/visual-basic/getting-started/additional-resources.md @@ -39,7 +39,7 @@ The following web sites provide guidance and can help you find answers to common |URL|Description| |----------|----------------| -|[Channel9](https://channel9.msdn.com/)|Provides continuous community through videos, Wikis, and forums.| +|[GitHub: Visual Basic .NET](https://github.com/dotnet/vblang)|The official repo for Visual Basic .NET language design.| ### Support diff --git a/docs/visual-basic/language-reference/special-characters/interpolated.md b/docs/visual-basic/language-reference/special-characters/interpolated.md index da66515275697..e1b89de5c21a5 100644 --- a/docs/visual-basic/language-reference/special-characters/interpolated.md +++ b/docs/visual-basic/language-reference/special-characters/interpolated.md @@ -5,7 +5,7 @@ ms.date: 10/31/2017 --- # $ (Visual Basic Reference) -Identifies a string literal as an [interpolated string](../../programming-guide/language-features/strings/interpolated-strings.md). An interpolated string is a template-like string that contains literal text along with *interpolated expressions*. When the interpolated string is resolved, for example in an assignment statement or a method call, its interpolated expressions are replaced by their string representations in the result string. Interpolated strings are replacements for the [composite format strings](../../../standard/base-types/composite-formatting.md) supported by the .NET Framework. +Identifies a string literal as an [interpolated string](../../programming-guide/language-features/strings/interpolated-strings.md). An interpolated string is a template-like string that contains literal text along with *interpolated expressions*. An interpolated expression is an expression that produces a result to be formatted in the resultant string. When the interpolated string is resolved, for example in an assignment statement or a method call, its interpolated expressions are replaced by their string representations in the result string. Interpolated strings are replacements for the [composite format strings](../../../standard/base-types/composite-formatting.md) supported by the .NET Framework. The following example uses the `$` character to define an interpolated string. diff --git a/docs/visual-basic/language-reference/statements/end-statement.md b/docs/visual-basic/language-reference/statements/end-statement.md index 9e28d7139c151..b284b90c3cbf5 100644 --- a/docs/visual-basic/language-reference/statements/end-statement.md +++ b/docs/visual-basic/language-reference/statements/end-statement.md @@ -56,6 +56,5 @@ End ## See also -- - [Stop Statement](stop-statement.md) - [End \ Statement](end-keyword-statement.md) diff --git a/docs/visual-basic/programming-guide/concepts/async/index.md b/docs/visual-basic/programming-guide/concepts/async/index.md index 130215888c504..2d4b63ac86651 100644 --- a/docs/visual-basic/programming-guide/concepts/async/index.md +++ b/docs/visual-basic/programming-guide/concepts/async/index.md @@ -241,7 +241,6 @@ You can ignore the convention where an event, base class, or interface contract |Async Cancellation: Bridging between the .NET Framework and the Windows Runtime|Shows how to bridge between Task types in the .NET Framework and IAsyncOperations in the Windows Runtime so that you can use with a Windows Runtime method.|[Async Sample: Bridging between .NET and Windows Runtime (AsTask & Cancellation)](https://code.msdn.microsoft.com/Async-Sample-Bridging-9479eca3)| |[Using Async for File Access (Visual Basic)](using-async-for-file-access.md)|Lists and demonstrates the benefits of using async and await to access files.|| |[Task-based Asynchronous Pattern (TAP)](../../../../standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap.md)|Describes a new pattern for asynchrony in the .NET Framework. The pattern is based on the and [Task(Of TResult)](xref:System.Threading.Tasks.Task%601) types.|| -|[Async Videos on Channel 9](https://channel9.msdn.com/search?term=async+&type=All)|Provides links to a variety of videos about async programming.|| ## Complete Example diff --git a/docs/visual-basic/programming-guide/language-features/data-types/tuples.md b/docs/visual-basic/programming-guide/language-features/data-types/tuples.md index e053d691fdb0f..e4e09b1c1fc2b 100644 --- a/docs/visual-basic/programming-guide/language-features/data-types/tuples.md +++ b/docs/visual-basic/programming-guide/language-features/data-types/tuples.md @@ -33,7 +33,7 @@ Rather than using default names for a tuple's fields, you can instantiate a *nam :::code language="vb" source="../../../../../samples/snippets/visualbasic/programming-guide/language-features/data-types/tuples/tuples.vb" id="Named"::: -You cam also specify the tuple names as part of the type declaration of a variable, field, or parameter: +You can also specify the tuple names as part of the type declaration of a variable, field, or parameter: :::code language="vb" source="../../../../../samples/snippets/visualbasic/programming-guide/language-features/data-types/tuples/tuples.vb" id="NamedDeclaration"::: @@ -77,7 +77,7 @@ When field name inference fails, Visual Basic does not generate a compiler error ## Tuples versus structures -A Visual Basic tuple is a value type that is an instance of one of the a **System.ValueTuple** generic types. For example, the `holiday` tuple defined in the previous example is an instance of the structure. It is designed to be a lightweight container for data. Since the tuple aims to make it easy to create an object with multiple data items, it lacks some of the features that a custom structure might have. These include: +A Visual Basic tuple is a value type that is an instance of one of the **System.ValueTuple** generic types. For example, the `holiday` tuple defined in the previous example is an instance of the structure. It is designed to be a lightweight container for data. Since the tuple aims to make it easy to create an object with multiple data items, it lacks some of the features that a custom structure might have. These include: - Custom members. You cannot define your own properties, methods, or events for a tuple. @@ -140,13 +140,13 @@ named = differentShape A method can return only a single value. Frequently, though, you'd like a method call to return multiple values. There are several ways to work around this limitation: -- You can create a custom class or structure whose properties or fields represent values returned by the method. Thus is a heavyweight solution; it requires that you define a custom type whose only purpose is to retrieve values from a method call. +- You can create a custom class or structure whose properties or fields represent values returned by the method. This is a heavyweight solution; it requires that you define a custom type whose only purpose is to retrieve values from a method call. - You can return a single value from the method, and return the remaining values by passing them by reference to the method. This involves the overhead of instantiating a variable and risks inadvertently overwriting the value of the variable that you pass by reference. - You can use a tuple, which provides a lightweight solution to retrieving multiple return values. -For example, the **TryParse** methods in .NET return a `Boolean` value that indicates whether the parsing operation succeeded. The result of the parsing operation is returned in a variable passed by reference to the method. Normally, a call to the a parsing method such as looks like the following: +For example, the **TryParse** methods in .NET return a `Boolean` value that indicates whether the parsing operation succeeded. The result of the parsing operation is returned in a variable passed by reference to the method. Normally, a call to a parsing method such as looks like the following: :::code language="vb" source="../../../../../samples/snippets/visualbasic/programming-guide/language-features/data-types/tuples/tuple-returns.vb" id="StandardMethodCall"::: diff --git a/docs/whats-new/dotnet-docs-2022-01-01.md b/docs/whats-new/dotnet-docs-2022-01-01.md deleted file mode 100644 index e6cd13c1c4b18..0000000000000 --- a/docs/whats-new/dotnet-docs-2022-01-01.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: ".NET docs: What's new for January 2022" -description: "What's new in the .NET docs for January 2022" -ms.date: 02/01/2022 ---- - -# .NET docs: What's new for January 2022 - -Welcome to what's new in the .NET docs for January 2022. This article lists some of the major changes to docs during this period. - -## .NET fundamentals - -### New articles - -- [CA1419: Provide a parameterless constructor that is as visible as the containing type for concrete types derived from 'System.Runtime.InteropServices.SafeHandle'](../fundamentals/code-analysis/quality-rules/ca1419.md) -- [CA1727: Use PascalCase for named placeholders](../fundamentals/code-analysis/quality-rules/ca1727.md) -- [CA1842: Do not use 'WhenAll' with a single task](../fundamentals/code-analysis/quality-rules/ca1842.md) -- [CA1843: Do not use 'WaitAll' with a single task](../fundamentals/code-analysis/quality-rules/ca1843.md) -- [CA1848: Use the LoggerMessage delegates](../fundamentals/code-analysis/quality-rules/ca1848.md) -- [CA2017: Parameter count mismatch](../fundamentals/code-analysis/quality-rules/ca2017.md) -- [CA2253: Named placeholders should not be numeric values](../fundamentals/code-analysis/quality-rules/ca2253.md) -- [CA2254: Template should be a static expression](../fundamentals/code-analysis/quality-rules/ca2254.md) -- [CA2256: All members declared in parent interfaces must have an implementation in a DynamicInterfaceCastableImplementation-attributed interface](../fundamentals/code-analysis/quality-rules/ca2256.md) -- [CA2257: Members defined on an interface with the 'DynamicInterfaceCastableImplementationAttribute' should be 'static'](../fundamentals/code-analysis/quality-rules/ca2257.md) -- [CA2258: Providing a 'DynamicInterfaceCastableImplementation' interface in Visual Basic is unsupported](../fundamentals/code-analysis/quality-rules/ca2258.md) -- [Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv and libuv.dll removed](../core/compatibility/aspnet-core/7.0/libuv-transport-dll-removed.md) -- [SYSLIB0037: AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete](../fundamentals/syslib-diagnostics/syslib0037.md) -- [Some APIs throw ArgumentNullException (.NET 7)](../core/compatibility/windows-forms/7.0/apis-throw-argumentnullexception.md) -- [API obsoletions with non-default diagnostic IDs (.NET 7)](../core/compatibility/core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md) -- [SYSLIB0036: Regex.CompileToAssembly is obsolete](../fundamentals/syslib-diagnostics/syslib0036.md) -- [Deserialize Version type with leading or trailing whitespace](../core/compatibility/serialization/7.0/deserialize-version-with-whitespace.md) -- [Set timestamp on read-only file on Windows](../core/compatibility/core-libraries/6.0/set-timestamp-readonly-file.md) -- [.NET implementations](../fundamentals/implementations.md) -- [Ecma standards](../fundamentals/standards.md) -- [Breaking changes in .NET 7](../core/compatibility/7.0.md) -- [Validate CompressionLevel for BrotliStream](../core/compatibility/core-libraries/7.0/compressionlevel-validation.md) -- [Default serialization format for TimeSpan](../core/compatibility/serialization/6.0/timespan-serialization-format.md) -- [IL3003: 'RequiresAssemblyFilesAttribute' annotations must match across all interface implementations or overrides.](../core/deploying/single-file/warnings/il3003.md) - -### Updated articles - -- [Upgrade a Windows Forms App to .NET 6 with the .NET Upgrade Assistant](../core/porting/upgrade-assistant-winforms-framework.md) - Upgrade assistant updates -- [Upgrade a WPF App to .NET 6 with the .NET Upgrade Assistant](../core/porting/upgrade-assistant-wpf-framework.md) - Upgrade assistant updates - -## C# language - -### Updated articles - -- [ECMA C# (draft) standard](~/_csharpstandard/standard/README.md) - Publish the C# draft standard instead of the Microsoft C# draft specification. - -## Community contributors - -The following people contributed to the .NET docs during this period. Thank you! Learn how to contribute by following the links under "Get involved" in the [what's new landing page](index.yml). - -- [lindexi](https://github.com/lindexi) - lindexi (9) -- [Youssef1313](https://github.com/Youssef1313) - Youssef Victor (7) -- [GitHubPang](https://github.com/GitHubPang) (6) -- [SteveDunn](https://github.com/SteveDunn) - Steve Dunn (3) -- [isaacabraham](https://github.com/isaacabraham) - Isaac Abraham (2) -- [MaceWindu](https://github.com/MaceWindu) (2) -- [pkulikov](https://github.com/pkulikov) - Petr Kulikov (2) -- [sputier](https://github.com/sputier) - Sébastien Putier (2) -- [ardalis](https://github.com/ardalis) - Steve Smith (1) -- [cmeeren](https://github.com/cmeeren) - Christer van der Meeren (1) -- [dickens-code](https://github.com/dickens-code) - DIcKeNs (1) -- [Dixin](https://github.com/Dixin) - Dixin (1) -- [Eagle3386](https://github.com/Eagle3386) - Martin Arndt (1) -- [epeshk](https://github.com/epeshk) - Evgeny Peshkov (1) -- [fowl2](https://github.com/fowl2) - James May (1) -- [heikow10](https://github.com/heikow10) - Heiko Wobst (1) -- [jjanuszkiewicz](https://github.com/jjanuszkiewicz) - Jakub Januszkiewicz (1) -- [jwood803](https://github.com/jwood803) - Jon Wood (1) -- [maxkoshevoi](https://github.com/maxkoshevoi) - Maksym Koshovyi (1) -- [ni-eke](https://github.com/ni-eke) (1) -- [nojaf](https://github.com/nojaf) - Florian Verdonck (1) -- [omajid](https://github.com/omajid) - Omair Majid (1) -- [Piotrku8192](https://github.com/Piotrku8192) - Piotr Szulakowski (1) -- [smholvoet](https://github.com/smholvoet) - Sander Holvoet (1) -- [vcrobe](https://github.com/vcrobe) (1) -- [wferebee](https://github.com/wferebee) - William Ferebee (1) -- [yugoccp](https://github.com/yugoccp) (1) diff --git a/docs/whats-new/dotnet-docs-2022-02-01.md b/docs/whats-new/dotnet-docs-2022-02-01.md deleted file mode 100644 index 02d8ac51d5e15..0000000000000 --- a/docs/whats-new/dotnet-docs-2022-02-01.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: ".NET docs: What's new for February 2022" -description: "What's new in the .NET docs for February 2022." -ms.date: 03/01/2022 ---- - -# .NET docs: What's new for February 2022 - -Welcome to what's new in the .NET docs for February 2022. This article lists some of the major changes to docs during this period. - -## Microsoft Orleans - -Orleans is a cross-platform framework for building robust, scalable distributed applications. We're pleased to announce that all of the official [Microsoft Orleans](/dotnet/orleans) content has been ported and is now available on the .NET docs. - -## .NET fundamentals - -### New articles - -- [Identity: Default Bootstrap version of UI changed](../core/compatibility/aspnet-core/6.0/identity-bootstrap4-to-5.md) -- [ScaleControl called only when needed](../core/compatibility/windows-forms/6.0/optimize-scalecontrol-calls.md) -- [FullPath and OldFullPath return fully qualified path](../core/compatibility/core-libraries/7.0/filesystemeventargs-fullpath.md) -- [Publishing a ReadyToRun project with --no-restore requires changes to the restore](../core/compatibility/sdk/6.0/publish-readytorun-requires-restore-change.md) -- [Write reference assemblies to intermediate output](../core/compatibility/sdk/6.0/write-reference-assemblies-to-obj.md) - -### Updated articles - -- [Microsoft.Diagnostics.NETCore.Client API](../core/diagnostics/microsoft-diagnostics-netcore-client.md) - Update Microsoft.Diagnostics.NETCore.Client docs - -## C# language - -### New articles - -- [Tutorial: Explore C# 10 preview feature - static abstract members in interfaces](../csharp/whats-new/tutorials/static-abstract-interface-methods.md) - -## ML.NET - -### Updated articles - -- [How to install the ML.NET Command-Line Interface (CLI) tool](../machine-learning/how-to-guides/install-ml-net-cli.md) - Update ML.NET install doc - -## Community contributors - -The following people contributed to the .NET docs during this period. Thank you! Learn how to contribute by following the links under "Get involved" in the [what's new landing page](index.yml). - -- [guardrex](https://github.com/guardrex) - Luke Latham (4) -- [smholvoet](https://github.com/smholvoet) - Sander Holvoet (3) -- [ardalis](https://github.com/ardalis) - Steve Smith (2) -- [GitHubPang](https://github.com/GitHubPang) (2) -- [Youssef1313](https://github.com/Youssef1313) - Youssef Victor (2) -- [zspitz](https://github.com/zspitz) - Zev Spitz (2) -- [bangjiehan](https://github.com/bangjiehan) (1) -- [cartermp](https://github.com/cartermp) - Phillip Carter (1) -- [ciphercoder](https://github.com/ciphercoder) - Irfan Akram (1) -- [cjessamy](https://github.com/cjessamy) - Christopher C. Jessamy (1) -- [colejohnson66](https://github.com/colejohnson66) - Cole Tobin (1) -- [dipakdotyadav](https://github.com/dipakdotyadav) - Dipak (1) -- [eatdrinksleepcode](https://github.com/eatdrinksleepcode) - David Nelson (1) -- [Jaiganeshkumaran](https://github.com/Jaiganeshkumaran) - Jaiganesh Kumaran (1) -- [jonadv](https://github.com/jonadv) - Jonathan (1) -- [knocte](https://github.com/knocte) - Andres G. Aragoneses (1) -- [leopcode](https://github.com/leopcode) (1) -- [madelson](https://github.com/madelson) (1) -- [MSDN-WhiteKnight](https://github.com/MSDN-WhiteKnight) - MSDN.WhiteKnight (1) -- [nojaf](https://github.com/nojaf) - Florian Verdonck (1) -- [stesee](https://github.com/stesee) - Stefan Seeland (1) -- [swharden](https://github.com/swharden) - Scott W Harden (1) -- [szantopeter](https://github.com/szantopeter) - Szanto Peter (1) -- [teo-tsirpanis](https://github.com/teo-tsirpanis) - Theodore Tsirpanis (1) -- [Tolyandre](https://github.com/Tolyandre) - Anatoley Buranov (1) -- [WhitWaldo](https://github.com/WhitWaldo) - Whit Waldo (1) diff --git a/docs/whats-new/dotnet-docs-2022-03-01.md b/docs/whats-new/dotnet-docs-2022-03-01.md index 52b420eafb674..b40409fcca530 100644 --- a/docs/whats-new/dotnet-docs-2022-03-01.md +++ b/docs/whats-new/dotnet-docs-2022-03-01.md @@ -79,7 +79,7 @@ The following people contributed to the .NET docs during this period. Thank you! - [BartoszKlonowski](https://github.com/BartoszKlonowski) - Bartosz Klonowski (2) - [paul-cheung](https://github.com/paul-cheung) - paul cheung (2) - [pbachmann](https://github.com/pbachmann) (2) -- [abhijithsundr](https://github.com/abhijithsundr) - Abhijith Sunder (1) +- Abhijith Sunder (1) - [alex-jitbit](https://github.com/alex-jitbit) - Alexander Yumashev (1) - [alexgordontlv](https://github.com/alexgordontlv) - Alexander Gordon (1) - [austindrenski](https://github.com/austindrenski) - Austin Drenski (1) diff --git a/docs/whats-new/dotnet-docs-2022-04-01.md b/docs/whats-new/dotnet-docs-2022-04-01.md new file mode 100644 index 0000000000000..fef273b52c01d --- /dev/null +++ b/docs/whats-new/dotnet-docs-2022-04-01.md @@ -0,0 +1,105 @@ +--- +title: ".NET docs: What's new for April 2022" +description: "What's new in the .NET docs for April 2022." +ms.date: 05/01/2022 +--- + +# .NET docs: What's new for April 1, 2022 - April 30, 2022 + +Welcome to what's new in the .NET docs for April 2022. This article lists some of the major changes to docs during this period. + +## .NET Framework + +### New articles + +- [\ Element](../framework/configure-apps/file-schema/runtime/disablestackoverflowprobing-element.md) +- [SqlBinary Constructor](../framework/additional-apis/system.data.sqltypes.sqlbinary.-ctor.md) +- [SqlGuid Constructor](../framework/additional-apis/system.data.sqltypes.sqlguid.-ctor.md) +- [SqlMoney Constructor](../framework/additional-apis/system.data.sqltypes.sqlmoney.-ctor.md) +- [CloseCLREnumeration Function for Silverlight](../framework/unmanaged-api/debugging/closeclrenumeration-function-for-silverlight.md) +- [CloseResumeHandle Function](../framework/unmanaged-api/debugging/closeresumehandle-function.md) +- [CLRCreateInstance for .NET Core Function](../framework/unmanaged-api/debugging/clrcreateinstance-function.md) +- [CreateDebuggingInterfaceFromVersion Function for .NET Core](../framework/unmanaged-api/debugging/createdebugginginterfacefromversion-function.md) +- [CreateDebuggingInterfaceFromVersion2 Function for .NET Core](../framework/unmanaged-api/debugging/createdebugginginterfacefromversion2-function.md) +- [CreateDebuggingInterfaceFromVersion3 Function for .NET Core](../framework/unmanaged-api/debugging/createdebugginginterfacefromversion3-function.md) +- [CreateDebuggingInterfaceFromVersionEx Function for .NET Core](../framework/unmanaged-api/debugging/createdebugginginterfacefromversionex-function.md) +- [CreateProcessForLaunch Function](../framework/unmanaged-api/debugging/createprocessforlaunch-function.md) +- [CreateVersionStringFromModule Function for Silverlight](../framework/unmanaged-api/debugging/createversionstringfrommodule-function-for-silverlight.md) +- [.NET Core Debugging](../framework/unmanaged-api/debugging/dotnet-debugging.md) +- [EnumerateCLRs Function for Silverlight](../framework/unmanaged-api/debugging/enumerateclrs-function-for-silverlight.md) +- [GetStartupNotificationEvent Function for Silverlight](../framework/unmanaged-api/debugging/getstartupnotificationevent-function-for-silverlight.md) +- [ICLRDebuggingLibraryProvider2 Interface](../framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-interface.md) +- [ICLRDebuggingLibraryProvider2::ProvideLibrary2 Method](../framework/unmanaged-api/debugging/iclrdebugginglibraryprovider2-providelibrary2-method.md) +- [ICLRDebuggingLibraryProvider3 Interface](../framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-interface.md) +- [ICLRDebuggingLibraryProvider3::ProvideUnixLibrary Method](../framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-provideunixlibrary-method.md) +- [ICLRDebuggingLibraryProvider3::ProvideWindowsLibrary Method](../framework/unmanaged-api/debugging/iclrdebugginglibraryprovider3-providewindowslibrary-method.md) +- [LIBRARY_PROVIDER_INDEX_TYPE Enumeration](../framework/unmanaged-api/debugging/libraryproviderindextype-enumeration.md) +- [PSTARTUP_CALLBACK Function Pointer](../framework/unmanaged-api/debugging/pstartup_callback-function-pointer.md) +- [RegisterForRuntimeStartup Function for .NET Core](../framework/unmanaged-api/debugging/registerforruntimestartup-function.md) +- [RegisterForRuntimeStartup3 Function for .NET Core](../framework/unmanaged-api/debugging/registerforruntimestartup3-function.md) +- [RegisterForRuntimeStartupEx Function for .NET Core](../framework/unmanaged-api/debugging/registerforruntimestartupex-function.md) +- [ResumeProcess Function](../framework/unmanaged-api/debugging/resumeprocess-function.md) +- [UnregisterForRuntimeStartup Function for .NET Core](../framework/unmanaged-api/debugging/unregisterforruntimestartup-function.md) + +## .NET fundamentals + +### New articles + +- [Debug ThreadPool Starvation](../core/diagnostics/debug-threadpool-starvation.md) +- [Diagnostic port](../core/diagnostics/diagnostic-port.md) +- [Multi-level lookup is disabled](../core/compatibility/deployment/7.0/multilevel-lookup.md) +- [SYSLIB0041: Some Rfc2898DeriveBytes constructors are obsolete](../fundamentals/syslib-diagnostics/syslib0041.md) +- [SYSLIB0042: FromXmlString and ToXmlString on ECC types are obsolete](../fundamentals/syslib-diagnostics/syslib0042.md) +- [SYSLIB0043: ECDiffieHellmanPublicKey.ToByteArray is obsolete](../fundamentals/syslib-diagnostics/syslib0043.md) +- [MVC's detection of an empty body in model binding changed](../core/compatibility/aspnet-core/7.0/mvc-empty-body-model-binding.md) +- [C++/CLI projects in Visual Studio](../core/compatibility/core-libraries/7.0/cpluspluscli-compiler-version.md) +- [CA1851: Possible multiple enumerations of `IEnumerable` collection](../fundamentals/code-analysis/quality-rules/ca1851.md) + +### Updated articles + +- [dotnet-coverage code coverage utility](../core/additional-tools/dotnet-coverage.md) - Adding new options and example scenarios + +## C# language + +### Updated articles + +- [Built-in reference types (C# reference)](../csharp/language-reference/builtin-types/reference-types.md) - Document raw string literals +- [Strings and string literals](../csharp/programming-guide/strings/index.md) - Document raw string literals + +## Community contributors + +The following people contributed to the .NET docs during this period. Thank you! Learn how to contribute by following the links under "Get involved" in the [what's new landing page](index.yml). + +- [GitHubPang](https://github.com/GitHubPang) (7) +- [nschonni](https://github.com/nschonni) - Nick Schonning (3) +- [Youssef1313](https://github.com/Youssef1313) - Youssef Victor (3) +- [bvda](https://github.com/bvda) - Brian Vestergaard Danielsen (1) +- [cartermp](https://github.com/cartermp) - Phillip Carter (1) +- [chessboards](https://github.com/chessboards) (1) +- [DreadLordMikey](https://github.com/DreadLordMikey) - Michael Hofer (1) +- [Flash0ver](https://github.com/Flash0ver) - Stefan Pölz (1) +- [ftsfranklin](https://github.com/ftsfranklin) (1) +- [gfoidl](https://github.com/gfoidl) - Günther Foidl (1) +- [hyoshioka0128](https://github.com/hyoshioka0128) - Hiroshi Yoshioka (1) +- [j0nimost](https://github.com/j0nimost) - John Nyingi (1) +- [JasonLoKiSmith](https://github.com/JasonLoKiSmith) (1) +- [jgscherber](https://github.com/jgscherber) - Jacob Scherber (1) +- [loris-s-sonarsource](https://github.com/loris-s-sonarsource) - Loris S. (1) +- [Marusyk](https://github.com/Marusyk) - Roman Marusyk (1) +- [mkowusu](https://github.com/mkowusu) - Michael Owusu (1) +- [N0D4N](https://github.com/N0D4N) (1) +- [NikRimington](https://github.com/NikRimington) - Nik (1) +- [omarjuul](https://github.com/omarjuul) - Camiel Egbers (1) +- [pbachmann](https://github.com/pbachmann) (1) +- [Prajwal-Koirala](https://github.com/Prajwal-Koirala) - Prajwal Koirala (1) +- QHopp (1) +- [renbaoshuo](https://github.com/renbaoshuo) - Baoshuo Ren (1) +- [sameercarpenter](https://github.com/sameercarpenter) - Sameer Carpenter (1) +- [serpent5](https://github.com/serpent5) - Kirk Larkin (1) +- [sixtymage](https://github.com/sixtymage) - Jon Hutchings (1) +- [stesee](https://github.com/stesee) - Stefan Seeland (1) +- [svick](https://github.com/svick) - Petr Onderka (1) +- [tommyb86](https://github.com/tommyb86) (1) +- [TrickyCat](https://github.com/TrickyCat) - Dmytro Doroshenko (1) +- [Zhu-Panda](https://github.com/Zhu-Panda) (1) +- [zspitz](https://github.com/zspitz) - Zev Spitz (1) diff --git a/docs/whats-new/dotnet-docs-2022-05-01.md b/docs/whats-new/dotnet-docs-2022-05-01.md new file mode 100644 index 0000000000000..df9c31f7d9721 --- /dev/null +++ b/docs/whats-new/dotnet-docs-2022-05-01.md @@ -0,0 +1,72 @@ +--- +title: ".NET docs: What's new for May 2022" +description: "What's new in the .NET docs for May 2022." +ms.date: 06/01/2022 +--- + +# .NET docs: What's new for May 2022 + +Welcome to what's new in the .NET docs for May 2022. This article lists some of the major changes to docs during this period. + +## .NET fundamentals + +### New articles + +- [Decrypting EnvelopedCms doesn't double unwrap](../core/compatibility/cryptography/7.0/decrypt-envelopedcms.md) +- [ActionResult\ sets StatusCode to 200](../core/compatibility/aspnet-core/6.0/actionresult-statuscode.md) +- [Guidelines for using HttpClient](../fundamentals/networking/httpclient-guidelines.md) +- [X500DistinguishedName parsing of friendly names](../core/compatibility/cryptography/7.0/x500-distinguished-names.md) +- [Equals method behavior change for NaN](../core/compatibility/core-libraries/7.0/equals-nan.md) +- [Migrate UWP apps to Windows App SDK with the .NET Upgrade Assistant](../core/porting/upgrade-assistant-uwp-framework.md) +- [Collectible Assembly in non-collectible AssemblyLoadContext](../core/compatibility/core-libraries/7.0/collectible-assemblies.md) +- [BinaryFormatter serialization of custom BuildEventArgs and ITaskItems removed for .NET 7](../core/compatibility/sdk/7.0/custom-serialization.md) +- [dotnet watch](../core/tools/dotnet-watch.md) +- [runtimeconfig.dev.json file not generated](../core/compatibility/sdk/6.0/runtimeconfigdev-file.md) +- [Default console logger formatting in container images](../core/compatibility/containers/6.0/console-formatter-default.md) + +### Updated articles + +- [Backtracking in Regular Expressions](../standard/base-types/backtracking-in-regular-expressions.md) - Update backtracking in regex to mention global timeout + +## C# language + +### New articles + +- [C# Warning waves](../csharp/language-reference/compiler-messages/warning-waves.md) + +## Microsoft Orleans + +### New articles + +- [Deploy Orleans to Azure App Service](../orleans/deployment/deploy-to-azure-app-service.md) + +## Community contributors + +The following people contributed to the .NET docs during this period. Thank you! Learn how to contribute by following the links under "Get involved" in the [what's new landing page](index.yml). + +- [GitHubPang](https://github.com/GitHubPang) (9) +- [OlegAlexander](https://github.com/OlegAlexander) (6) +- [dawedawe](https://github.com/dawedawe) - dawe (2) +- [increddibelly](https://github.com/increddibelly) - Joost Boomkamp (2) +- [Julian-C10](https://github.com/Julian-C10) - Julian (2) +- [alielbashir](https://github.com/alielbashir) - Ali Elbashir (1) +- [AnhBuiDeveloper](https://github.com/AnhBuiDeveloper) - Anh T. Bui (1) +- [bangseongbeom](https://github.com/bangseongbeom) - 방성범 (Bang Seongbeom) (1) +- [barbarbarbaris](https://github.com/barbarbarbaris) - Barış Kılıçlar (1) +- [BLooDBRothER](https://github.com/BLooDBRothER) - Arul Murugavel B (1) +- [c0g1t8](https://github.com/c0g1t8) - Gary Chan (1) +- [DAXaholic](https://github.com/DAXaholic) - Aaron Kunz (1) +- [Eideren](https://github.com/Eideren) - Eideren (1) +- [ElanHasson](https://github.com/ElanHasson) - Elan Hasson (1) +- [ericmutta](https://github.com/ericmutta) - Eric Mutta (1) +- [hmmwhatsthisdo](https://github.com/hmmwhatsthisdo) (1) +- [isobel-cullen](https://github.com/isobel-cullen) - Isobel Cullen (1) +- [jcmrva](https://github.com/jcmrva) - Josh M (1) +- [kriwar](https://github.com/kriwar) - Kristofer Wårell (1) +- [laurentkempe](https://github.com/laurentkempe) - Laurent Kempé (1) +- [Saibamen](https://github.com/Saibamen) - Adam Stachowicz (1) +- [softwarepronto](https://github.com/softwarepronto) (1) +- [tarurar](https://github.com/tarurar) - Andrei Tarutin (1) +- [willbush](https://github.com/willbush) - Will Bush (1) +- [wuyuansushen](https://github.com/wuyuansushen) (1) +- [ytaracgotora](https://github.com/ytaracgotora) (1) diff --git a/docs/whats-new/index.yml b/docs/whats-new/index.yml index 3704ea25ed020..11fa172c7eca9 100644 --- a/docs/whats-new/index.yml +++ b/docs/whats-new/index.yml @@ -5,19 +5,19 @@ summary: Welcome to what's new in .NET docs. Use this page to quickly find the l metadata: title: .NET documentation what's new? description: Learn about new and updated content in .NET docs. - ms.date: 04/01/2022 + ms.date: 06/01/2022 ms.topic: landing-page landingContent: - title: Find .NET updates linkLists: - linkListType: whats-new links: + - text: May 2022 + url: dotnet-docs-2022-05-01.md + - text: April 2022 + url: dotnet-docs-2022-04-01.md - text: March 2022 url: dotnet-docs-2022-03-01.md - - text: February 2022 - url: dotnet-docs-2022-02-01.md - - text: January 2022 - url: dotnet-docs-2022-01-01.md - title: Find language updates linkLists: - linkListType: whats-new diff --git a/docs/whats-new/toc.yml b/docs/whats-new/toc.yml index 08e343a0c9759..4745aa64d8c21 100644 --- a/docs/whats-new/toc.yml +++ b/docs/whats-new/toc.yml @@ -3,9 +3,9 @@ items: href: index.yml expanded: true items: + - name: May 2022 + href: dotnet-docs-2022-05-01.md + - name: April 2022 + href: dotnet-docs-2022-04-01.md - name: March 2022 href: dotnet-docs-2022-03-01.md - - name: February 2022 - href: dotnet-docs-2022-02-01.md - - name: January 2022 - href: dotnet-docs-2022-01-01.md diff --git a/includes/cas-deprecated.md b/includes/cas-deprecated.md new file mode 100644 index 0000000000000..df9272babb80d --- /dev/null +++ b/includes/cas-deprecated.md @@ -0,0 +1,2 @@ +> [!NOTE] +> Code Access Security (CAS) has been deprecated across all versions of .NET Framework and .NET. Recent versions of .NET do not honor CAS annotations and produce errors if CAS-related APIs are used. Developers should seek alternative means of accomplishing security tasks. diff --git a/includes/cli-verbosity-packages.md b/includes/cli-verbosity-packages.md index 4c04407b6efc4..8205cbc8b0990 100644 --- a/includes/cli-verbosity-packages.md +++ b/includes/cli-verbosity-packages.md @@ -6,4 +6,4 @@ ms.topic: include --- - **`-v|--verbosity `** - Sets the verbosity level of the command. Allowed values are `q[uiet]`, `m[inimal]`, `n[ormal]`, `d[etailed]`, and `diag[nostic]`. The default is `minimal`. If you specify specify `detailed` or `diagnostic` verbosity, the command displays information about the Nuget packages that it downloads. + Sets the verbosity level of the command. Allowed values are `q[uiet]`, `m[inimal]`, `n[ormal]`, `d[etailed]`, and `diag[nostic]`. The default is `minimal`. If you specify `detailed` or `diagnostic` verbosity, the command displays information about the Nuget packages that it downloads. diff --git a/includes/csharp10-templates.md b/includes/csharp10-templates.md index 0e3bbeb63b8d9..dfa4fbcde848a 100644 --- a/includes/csharp10-templates.md +++ b/includes/csharp10-templates.md @@ -5,7 +5,7 @@ ms.date: 09/02/2021 ms.topic: include --- > [!IMPORTANT] -> The C# templates for .NET 6 use *top level statements*. Your application may not match the code in this article, if you've already upgraded to the .NET 6 previews. For more information see the article on [New C# templates generate top level statements](~/docs/core/tutorials/top-level-templates.md) +> The C# templates for .NET 6 use *top level statements*. Your application may not match the code in this article, if you've already upgraded to the .NET 6. For more information see the article on [New C# templates generate top level statements](~/docs/core/tutorials/top-level-templates.md) > > The .NET 6 SDK also adds a set of *implicit* `global using` directives for projects that use the following SDKs: > diff --git a/includes/migration-guide/retargeting/wcf/wcf-transport-security-supports-certificates-stored-using-cng.md b/includes/migration-guide/retargeting/wcf/wcf-transport-security-supports-certificates-stored-using-cng.md index f62841115f7e3..d3f71a56e71f6 100644 --- a/includes/migration-guide/retargeting/wcf/wcf-transport-security-supports-certificates-stored-using-cng.md +++ b/includes/migration-guide/retargeting/wcf/wcf-transport-security-supports-certificates-stored-using-cng.md @@ -10,20 +10,20 @@ Apps that target the .NET Framework 4.6.1 and earlier but are running on the .NE ```xml - + ``` This can also be done programmatically with the following code: ```csharp -private const string DisableCngCertificates = @"Switch.System.ServiceModel.DisableCngCertificate"; +private const string DisableCngCertificates = @"Switch.System.IdentityModel.DisableCngCertificate"; AppContext.SetSwitch(disableCngCertificates, false); ``` ```vb -Const DisableCngCertificates As String = "Switch.System.ServiceModel.DisableCngCertificates" +Const DisableCngCertificates As String = "Switch.System.IdentityModel.DisableCngCertificates" AppContext.SetSwitch(disableCngCertificates, False) ``` diff --git a/includes/net-core-60-md.md b/includes/net-core-60-md.md new file mode 100644 index 0000000000000..ec7a99aeeab85 --- /dev/null +++ b/includes/net-core-60-md.md @@ -0,0 +1 @@ +Available since .NET 6.0 diff --git a/includes/scl-preview.md b/includes/scl-preview.md index 9d6af7eb9f1b1..fbd02ffc3f820 100644 --- a/includes/scl-preview.md +++ b/includes/scl-preview.md @@ -1,9 +1,9 @@ --- author: tdykstra ms.author: tdykstra -ms.date: 02/23/2022 +ms.date: 05/22/2022 ms.topic: include --- > [!IMPORTANT] -> `System.CommandLine` is currently in PREVIEW. +> `System.CommandLine` is currently in PREVIEW, and this documentation is for version 2.0 beta 4. > Some information relates to prerelease product that may be substantially modified before it's released. Microsoft makes no warranties, express or implied, with respect to the information provided here. diff --git a/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj b/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj index 76c42feedc616..fd722d9c4eae9 100644 --- a/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj +++ b/samples/snippets/core/testing/unit-testing-best-practices/csharp/after/unit-testing-best-practices-after.csproj @@ -7,9 +7,9 @@ - + - + diff --git a/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj b/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj index 76c42feedc616..fd722d9c4eae9 100644 --- a/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj +++ b/samples/snippets/core/testing/unit-testing-best-practices/csharp/before/unit-testing-best-practices-before.csproj @@ -7,9 +7,9 @@ - + - + diff --git a/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj b/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj index b2acd0cd8d863..48fa0c3e2aa24 100644 --- a/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj +++ b/samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService.Tests.csproj @@ -6,9 +6,9 @@ - + - + diff --git a/samples/snippets/core/testing/unit-testing-using-nunit/csharp/PrimeService.Tests/PrimeService.Tests.csproj b/samples/snippets/core/testing/unit-testing-using-nunit/csharp/PrimeService.Tests/PrimeService.Tests.csproj index feb4d1e950aa2..6be33aea898eb 100644 --- a/samples/snippets/core/testing/unit-testing-using-nunit/csharp/PrimeService.Tests/PrimeService.Tests.csproj +++ b/samples/snippets/core/testing/unit-testing-using-nunit/csharp/PrimeService.Tests/PrimeService.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/samples/snippets/core/testing/unit-testing-vb-dotnet-test/vb/PrimeService.Tests/PrimeService.Tests.vbproj b/samples/snippets/core/testing/unit-testing-vb-dotnet-test/vb/PrimeService.Tests/PrimeService.Tests.vbproj index e33ffd1a46806..119eab8fc6203 100644 --- a/samples/snippets/core/testing/unit-testing-vb-dotnet-test/vb/PrimeService.Tests/PrimeService.Tests.vbproj +++ b/samples/snippets/core/testing/unit-testing-vb-dotnet-test/vb/PrimeService.Tests/PrimeService.Tests.vbproj @@ -7,9 +7,9 @@ - + - + diff --git a/samples/snippets/core/testing/unit-testing-vb-mstest/vb/PrimeService.Tests/PrimeService.Tests.vbproj b/samples/snippets/core/testing/unit-testing-vb-mstest/vb/PrimeService.Tests/PrimeService.Tests.vbproj index 7921fd2cda753..5dcc478017953 100644 --- a/samples/snippets/core/testing/unit-testing-vb-mstest/vb/PrimeService.Tests/PrimeService.Tests.vbproj +++ b/samples/snippets/core/testing/unit-testing-vb-mstest/vb/PrimeService.Tests/PrimeService.Tests.vbproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/samples/snippets/core/testing/unit-testing-vb-nunit/vb/PrimeService.Tests/PrimeService.Tests.vbproj b/samples/snippets/core/testing/unit-testing-vb-nunit/vb/PrimeService.Tests/PrimeService.Tests.vbproj index 16f87e253edf8..e565251346481 100644 --- a/samples/snippets/core/testing/unit-testing-vb-nunit/vb/PrimeService.Tests/PrimeService.Tests.vbproj +++ b/samples/snippets/core/testing/unit-testing-vb-nunit/vb/PrimeService.Tests/PrimeService.Tests.vbproj @@ -10,7 +10,7 @@ - + diff --git a/samples/snippets/core/tutorials/testing-with-cli/csharp/test/NewTypesTests/NewTypesTests.csproj b/samples/snippets/core/tutorials/testing-with-cli/csharp/test/NewTypesTests/NewTypesTests.csproj index eebe498f8020b..813ab75702b76 100644 --- a/samples/snippets/core/tutorials/testing-with-cli/csharp/test/NewTypesTests/NewTypesTests.csproj +++ b/samples/snippets/core/tutorials/testing-with-cli/csharp/test/NewTypesTests/NewTypesTests.csproj @@ -5,9 +5,9 @@ - + - + diff --git a/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception.cpp b/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception.cpp deleted file mode 100644 index 11309149234bb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -using namespace System; -int main() -{ - int x = 0; - try - { - int y = 100 / x; - } - catch ( ArithmeticException^ e ) - { - Console::WriteLine( "ArithmeticException Handler: {0}", e ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Generic Exception Handler: {0}", e ); - } -} -/* -This code example produces the following results: - -ArithmeticException Handler: System.DivideByZeroException: Attempted to divide by zero. - at main() - -*/ -// diff --git a/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception3.cpp b/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception3.cpp deleted file mode 100644 index e392cc1958082..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception3.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -public ref class ProcessFile -{ -public: - static void Main() - { - try - { - StreamReader^ sr = File::OpenText("data.txt"); - Console::WriteLine("The first line of this file is {0}", sr->ReadLine()); - } - // - catch (FileNotFoundException^ e) - { - Console::WriteLine("[Data File Missing] {0}", e); - } - // - catch (Exception^ e) - { - Console::WriteLine("An error occurred: '{0}'", e); - } - } -}; - -int main() -{ - ProcessFile::Main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp b/samples/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp deleted file mode 100644 index e3a2a599d6d1d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -int main() -{ - - // creates the CspParameters object and sets the key container name used to store the RSA key pair - CspParameters^ cp = gcnew CspParameters; - cp->KeyContainerName = "MyKeyContainerName"; - - // instantiates the rsa instance accessing the key container MyKeyContainerName - RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( cp ); - - // add the below line to delete the key entry in MyKeyContainerName - // rsa.PersistKeyInCsp = false; - //writes out the current key pair used in the rsa instance - Console::WriteLine( "Key is : \n{0}", rsa->ToXmlString( true ) ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.cpp deleted file mode 100644 index a36d4628c16e2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "CustomPages.h" - -#include "MainFrm.h" -#include "CustomPagesDoc.h" -#include "CustomPagesView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesApp - -BEGIN_MESSAGE_MAP(CCustomPagesApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesApp construction - -CCustomPagesApp::CCustomPagesApp() : CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CCustomPagesApp object - -CCustomPagesApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesApp initialization - -BOOL CCustomPagesApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CCustomPagesDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CCustomPagesView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - LoadCustomState (); - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesApp message handlers - -int CCustomPagesApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void CCustomPagesApp::PreLoadState () -{ - // - // The GetContextMenuManager method is inherited from the CWinAppEx class. - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - GetContextMenuManager()->SetDontCloseActiveMenu(true); - // - - // - // The GetKeyboardManager method is inherited from the CWinAppEx class. - CKeyboardManager* cKeyboardManager = GetKeyboardManager(); - cKeyboardManager->ShowAllAccelerators(); - // - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CCustomPagesApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.h deleted file mode 100644 index bb61babc4192c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.h +++ /dev/null @@ -1,44 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesApp: -// See CustomPages.cpp for the implementation of this class -// - -class CCustomPagesApp : public CWinAppEx -{ -public: - CCustomPagesApp(); - - virtual void PreLoadState (); - - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CCustomPagesApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.rc deleted file mode 100644 index 9b83e617da0aa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPages.rc +++ /dev/null @@ -1,470 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\CustomPages.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About CustomPages" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "CustomPages Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_CUST_PAGE_DLG DIALOG DISCARDABLE 0, 0, 267, 119 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "My Customization Page" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Check1",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,7,63,10 - CONTROL "Check2",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,22,41,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_CUST_PAGE_DLG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 260 - TOPMARGIN, 7 - BOTTOMMARGIN, 112 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\CustomPages.ico" -IDR_CUSTOMTYPE ICON DISCARDABLE "res\\CustomPagesDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About CustomPages...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "CustomPages MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "CustomPages\0" - VALUE "LegalCopyright", "Copyright (C) 2001\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "CustomPages.EXE\0" - VALUE "ProductName", "CustomPages Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "CustomPages\n\nCustom\n\n\nCustomPages.Document\nCustom Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "CustomPages" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\CustomPages.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesDoc.cpp deleted file mode 100644 index 8c95f44a2cd40..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "CustomPages.h" - -#include "CustomPagesDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesDoc - -IMPLEMENT_DYNCREATE(CCustomPagesDoc, CDocument) - -BEGIN_MESSAGE_MAP(CCustomPagesDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesDoc construction/destruction - -CCustomPagesDoc::CCustomPagesDoc() -{ - // TODO: add one-time construction code here - -} - -CCustomPagesDoc::~CCustomPagesDoc() -{ -} - -BOOL CCustomPagesDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesDoc serialization - -void CCustomPagesDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesDoc diagnostics - -#ifdef _DEBUG -void CCustomPagesDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CCustomPagesDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesDoc.h deleted file mode 100644 index f7a866a7ce277..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CCustomPagesDoc : public CDocument -{ -protected: // create from serialization only - CCustomPagesDoc(); - DECLARE_DYNCREATE(CCustomPagesDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CCustomPagesDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesView.cpp deleted file mode 100644 index 16d1947535e49..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesView.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "CustomPages.h" - -#include "CustomPagesDoc.h" -#include "CustomPagesView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to add a custom property page to the customization dialog. \r\n\r\n") - _T("The following features are available:\r\n") - _T("* Insert custom property page 'My Customization Page' into the customization dialog.\r\n\r\n") - _T("This example was created using Application Wizard\r\n") - _T("Using resource editor create a new dialog form\r\n") - _T("Using class wizard create a new (CMyCustomizationPage) class for this form and derive it from CPropertyPage\r\n") - _T("CMyCustomizationPage must be enabled to be created dynamically (DECLARE_DYNCREATE)\r\n") - _T("See CMainFrame::OnViewCustomize() for details."); - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesView - -IMPLEMENT_DYNCREATE(CCustomPagesView, CView) - -BEGIN_MESSAGE_MAP(CCustomPagesView, CView) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesView construction/destruction - -CCustomPagesView::CCustomPagesView() -{ - // TODO: add construction code here - -} - -CCustomPagesView::~CCustomPagesView() -{ -} - -BOOL CCustomPagesView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesView drawing - -void CCustomPagesView::OnDraw(CDC* pDC) -{ -// CCustomPagesDoc* pDoc = GetDocument(); -// ASSERT_VALID(pDoc); - - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - pDC->FillSolidRect (rectFrame, ::GetSysColor (COLOR_INFOBK)); - - rectFrame.DeflateRect (1, 1); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - rectFrame.DeflateRect (2, 2); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - pDC->SetTextColor (::GetSysColor (COLOR_INFOTEXT)); - pDC->SetBkMode (TRANSPARENT); - - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - - pDC->SelectObject (pFontOld); - -} - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesView printing - -void CCustomPagesView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CCustomPagesView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CCustomPagesView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CCustomPagesView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesView diagnostics - -#ifdef _DEBUG -void CCustomPagesView::AssertValid() const -{ - CView::AssertValid(); -} - -void CCustomPagesView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CCustomPagesDoc* CCustomPagesView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCustomPagesDoc))); - return (CCustomPagesDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CCustomPagesView message handlers - -void CCustomPagesView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesView.h deleted file mode 100644 index f3bf62d6d6c6b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/CustomPagesView.h +++ /dev/null @@ -1,53 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CCustomPagesView : public CView -{ -protected: // create from serialization only - CCustomPagesView(); - DECLARE_DYNCREATE(CCustomPagesView) - -// Attributes -public: - CCustomPagesDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CCustomPagesView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in CustomPagesView.cpp -inline CCustomPagesDoc* CCustomPagesView::GetDocument() - { return (CCustomPagesDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MainFrm.cpp deleted file mode 100644 index c9f5e69199ed5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MainFrm.cpp +++ /dev/null @@ -1,250 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "CustomPages.h" - -#include "MainFrm.h" - -#include "MyCustomizationPage.h" -#include - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_WM_CLOSE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - CMFCToolBar::EnableQuickCustomization (); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - CList lstCustomPages; - lstCustomPages.AddTail (RUNTIME_CLASS (CMyCustomizationPage)); - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - // - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */, - AFX_CUSTOMIZE_MENU_SHADOWS | AFX_CUSTOMIZE_TEXT_LABELS | - AFX_CUSTOMIZE_MENU_ANIMATIONS, // default parameters - &lstCustomPages); // pointer to the list of runtime classes of the custom property pages - // - - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - // - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - // CPoint point - // CMenu* pPopup - // The this pointer points to CMainFrame class which extends the CFrameWnd class. - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - // - - // - // 30 is the size of the logo in pixels. - pPopupMenu->EnableMenuLogo(30); - pPopupMenu->EnableMenuSound(); - // 500 is the animation speed in milliseconds. - pPopupMenu->SetAnimationSpeed(500); - pPopupMenu->SetAnimationType(CMFCPopupMenu::SLIDE); - pPopupMenu->SetForceShadow(true); - // 200 is the maximum width of the pop-up menu in pixels. - pPopupMenu->SetMaxWidth(200); - pPopupMenu->SetRightAlign(); - pPopupMenu->InsertSeparator(); - // - - // - // CMFCPopupMenu* pPopupMenu - CMFCCustomizeButton* pCustom = (CMFCCustomizeButton*)pPopupMenu->GetParentButton(); - pCustom->SetDefaultDraw(true); - pCustom->SetExtraSize(10,10); - pCustom->SetMenuRightAlign(true); - pCustom->SetPipeStyle(false); - // - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MainFrm.h deleted file mode 100644 index 9f981104ad0e0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MainFrm.h +++ /dev/null @@ -1,53 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define CFrameWnd CFrameWndEx - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MyCustomizationPage.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MyCustomizationPage.cpp deleted file mode 100644 index 17ed051391766..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MyCustomizationPage.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "CustomPages.h" -#include "MyCustomizationPage.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -IMPLEMENT_DYNCREATE(CMyCustomizationPage, CPropertyPage) - -///////////////////////////////////////////////////////////////////////////// -// CMyCustomizationPage dialog - - -CMyCustomizationPage::CMyCustomizationPage(CWnd* /*pParent*/ /*=NULL*/) - : CPropertyPage(CMyCustomizationPage::IDD) -{ -} - - -void CMyCustomizationPage::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - - -BEGIN_MESSAGE_MAP(CMyCustomizationPage, CDialog) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMyCustomizationPage message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MyCustomizationPage.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MyCustomizationPage.h deleted file mode 100644 index 126b2d9e59de5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/MyCustomizationPage.h +++ /dev/null @@ -1,34 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CMyCustomizationPage dialog - -class CMyCustomizationPage : public CPropertyPage -{ - DECLARE_DYNCREATE (CMyCustomizationPage) -// Construction -public: - CMyCustomizationPage(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - enum { IDD = IDD_CUST_PAGE_DLG }; - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/ReadMe.htm deleted file mode 100644 index 9092648c6fe6f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/ReadMe.htm +++ /dev/null @@ -1,123 +0,0 @@ - - - - CustomPages Sample: MFC Toolbar Customization Dialog Application - - -

- CustomPages Sample: MFC Toolbar Customization Dialog Application

-
-
-
- -

-

-
-

- The CustomPages sample demonstrates how to add a custom page to the Toolbar Customization - dialog. The Toolbar Customization dialog is opened by clicking on the small dropdown - at the end of the menu, and selecting the Customize... menu item.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the CustomPages sample

-
-
    -
  1. -

    - Open the solution file CustomPages.sln.

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Rebuild Solution. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or - Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The CustomPages sample demonstrates the following keywords:

-

- CFrameWndEx; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; CMFCToolBar; CMFCToolBarsCustomizeDialog; - CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/Resource.h deleted file mode 100644 index 5e5b4b83de033..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/Resource.h +++ /dev/null @@ -1,28 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by CustomPages.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define IDR_MAINFRAME 128 -#define IDR_CUSTOMTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDD_CUST_PAGE_DLG 151 -#define IDD_ABOUTBOX 1000 -#define IDC_CHECK1 1041 -#define IDC_CHECK2 1042 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 152 -#define _APS_NEXT_COMMAND_VALUE 32822 -#define _APS_NEXT_CONTROL_VALUE 1043 -#define _APS_NEXT_SYMED_VALUE 107 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/Snippets.txt deleted file mode 100644 index 569bf1f3e49af..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/Snippets.txt +++ /dev/null @@ -1,8 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp: CMFCPopupMenu 1 -MainFrm.cpp: CMFCPopupMenu 2 -MainFrm.cpp: CMFCToolBarsCustomizeDialog 3 -CustomPages.cpp: CContextMenuManager 4 -CustomPages.cpp: CKeyboardManager 5 -MainFrm.cpp: CMFCCustomizeButton 6 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/StdAfx.cpp deleted file mode 100644 index 3a4f2140c06d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/StdAfx.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// stdafx.cpp : source file that includes just the standard includes -// CustomPages.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/StdAfx.h deleted file mode 100644 index 2f3c31a436cfe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/StdAfx.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/custompages.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/custompages.vcxproj deleted file mode 100644 index 3934fe0ed6822..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/custompages.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {099CE838-E266-4443-A3CB-91899C9FAC62} - CustomPages - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/CustomPages.tlb - - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/CustomPages.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/CustomPages.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/CustomPages.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - true - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/custompages.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/custompages.vcxproj.filters deleted file mode 100644 index 70af05c5dc617..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/custompages.vcxproj.filters +++ /dev/null @@ -1,83 +0,0 @@ - - - - - {e12f813e-7971-40f0-9965-4c28396f684f} - h;hpp;hxx;hm;inl - - - {7f551946-c755-4b80-ba10-3ee9a7e10fff} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {37a6e377-c0ed-4987-94f2-220ec9ced298} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPages.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPages.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPages.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPages.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPages.rc2 deleted file mode 100644 index bf9b837f10fa3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPages.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// CUSTOMPAGES.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPagesDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPagesDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/CustomPagesDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_CustomPages/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.cpp deleted file mode 100644 index 711b350dc8e06..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DesktopAlertDemo.h" -#include "DesktopAlertDemoDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDesktopAlertDemoApp - -BEGIN_MESSAGE_MAP(CDesktopAlertDemoApp, CWinAppEx) - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDesktopAlertDemoApp construction - -CDesktopAlertDemoApp::CDesktopAlertDemoApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CDesktopAlertDemoApp object - -CDesktopAlertDemoApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CDesktopAlertDemoApp initialization - -BOOL CDesktopAlertDemoApp::InitInstance() -{ - AfxEnableControlContainer(); - - // - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - // - InitContextMenuManager(); - - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - SetRegistryBase (_T("Settings")); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - CDesktopAlertDemoDlg dlg; - m_pMainWnd = &dlg; - int nResponse = (int) dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.h deleted file mode 100644 index 6c6a33b810e07..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.h +++ /dev/null @@ -1,38 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CDesktopAlertDemoApp: -// See DesktopAlertDemo.cpp for the implementation of this class -// - -class CDesktopAlertDemoApp : public CWinAppEx -{ -public: - CDesktopAlertDemoApp(); - -// Overrides - public: - virtual BOOL InitInstance(); - -// Implementation - - DECLARE_MESSAGE_MAP() -}; - -extern CDesktopAlertDemoApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.rc deleted file mode 100644 index 4fc0a2c2dba6b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemo.rc +++ /dev/null @@ -1,353 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\DesktopAlertDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\DesktopAlertDemo.ico" -IDI_MAIL ICON DISCARDABLE "res\\mail.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ALERT_DIALOG DIALOGEX 0, 0, 296, 244 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Desktop Alert Demo" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Desktop Alert Window &Look:",IDC_STATIC,7,7,100,8 - COMBOBOX IDC_VISUAL_MNGR,7,19,92,190,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "&Animation Type:",IDC_STATIC,7,42,52,8 - COMBOBOX IDC_ANIMATION,7,55,75,190,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP - LTEXT "A&nimation Speed (1-100):",IDC_STATIC,7,85,80,8 - CONTROL "Slider1",IDC_ANIM_SPEED,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP,7,96,80,15 - CTEXT "...",IDC_ANIM_SPEED_VAL,90,99,22,8 - LTEXT "&Transparency (10-255):",IDC_STATIC,7,121,74,8 - CONTROL "Slider1",IDC_TRANSP,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP,7,133,80,15 - CTEXT "...",IDC_TRANSP_VAL,90,135,22,8 - CONTROL "S&mall Caption",IDC_SMALL_CAPTION,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,159,59,10 - CONTROL "AutoClos&e Alert (1-5 sec):",IDC_AUTO_CLOSE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,178,102,10 - CONTROL "Slider1",IDC_AUTOCLOSE_TIME,"msctls_trackbar32", - TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,7,190,80,15 - CTEXT "...",IDC_AUTOCLOSE_VAL,90,192,22,8 - CONTROL "Create alert from dialog resource",IDC_POPUP_SOURCE, - "Button",BS_AUTORADIOBUTTON | WS_GROUP,112,15,124,10 - CONTROL "Create dynamic alert:",IDC_POPUP_SOURCE2,"Button", - BS_AUTORADIOBUTTON,112,31,89,10 - LTEXT "Icon:",IDC_ICON_LABEL,126,51,17,8 - COMBOBOX IDC_ICONS,162,50,84,215,CBS_DROPDOWNLIST | - CBS_OWNERDRAWVARIABLE | CBS_HASSTRINGS | WS_VSCROLL | - WS_TABSTOP - LTEXT "Text:",IDC_TEXT_LABEL,126,71,17,8 - EDITTEXT IDC_TEXT,162,71,127,36,ES_MULTILINE | ES_WANTRETURN | - WS_VSCROLL - LTEXT "Link text:",IDC_URL_LABEL,126,115,30,8 - EDITTEXT IDC_LINK,162,115,127,36,ES_MULTILINE | ES_WANTRETURN | - WS_VSCROLL - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,214,281,1 - PUSHBUTTON "&Show Alert",IDC_SHOW,231,223,58,14 -END - -IDD_DIALOG1 DIALOGEX 0, 0, 136, 49 -STYLE WS_CHILD -EXSTYLE WS_EX_TRANSPARENT -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "John Smith",IDC_FROM,28,3,62,8,0,WS_EX_TRANSPARENT - ICON IDI_MAIL,IDC_STATIC,2,3,20,20,0,WS_EX_TRANSPARENT - PUSHBUTTON "Hello,\r\nI'm sending you the requsted information", - IDC_BUTTON1,28,21,104,27,0,WS_EX_TRANSPARENT - PUSHBUTTON "",IDC_FLAG,2,29,12,12 - PUSHBUTTON "",IDC_DELETE,14,29,12,12 - LTEXT "Re: your request",IDC_STATIC,28,13,53,8 -END - -IDD_DIALOG2 DIALOGEX 0, 0, 118, 82 -STYLE WS_CHILD -EXSTYLE WS_EX_TRANSPARENT -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - PUSHBUTTON "Please visit our web site and learn more about MFC.", - IDC_BUTTON1,12,24,102,31,0,WS_EX_TRANSPARENT - PUSHBUTTON "Options...",IDC_OPTIONS,79,7,35,14 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "DesktopAlertDemo MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "DesktopAlertDemo\0" - VALUE "LegalCopyright", "Copyright (C) 2005\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "DesktopAlertDemo.EXE\0" - VALUE "ProductName", "DesktopAlertDemo Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_ALERT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 289 - VERTGUIDE, 112 - VERTGUIDE, 126 - VERTGUIDE, 162 - TOPMARGIN, 7 - BOTTOMMARGIN, 237 - END - - IDD_DIALOG1, DIALOG - BEGIN - LEFTMARGIN, 2 - RIGHTMARGIN, 132 - VERTGUIDE, 28 - TOPMARGIN, 3 - BOTTOMMARGIN, 45 - END - - IDD_DIALOG2, DIALOG - BEGIN - LEFTMARGIN, 2 - RIGHTMARGIN, 114 - TOPMARGIN, 3 - BOTTOMMARGIN, 78 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_ALERT_DIALOG DLGINIT -BEGIN - IDC_VISUAL_MNGR, 0x403, 15, 0 -0x534d, 0x4f20, 0x6666, 0x6369, 0x2065, 0x3032, 0x3030, "\000" - IDC_VISUAL_MNGR, 0x403, 13, 0 -0x534d, 0x4f20, 0x6666, 0x6369, 0x2065, 0x5058, "\000" - IDC_VISUAL_MNGR, 0x403, 15, 0 -0x534d, 0x4f20, 0x6666, 0x6369, 0x2065, 0x3032, 0x3330, "\000" - IDC_VISUAL_MNGR, 0x403, 15, 0 -0x534d, 0x5620, 0x2e53, 0x454e, 0x2054, 0x3032, 0x3530, "\000" - IDC_VISUAL_MNGR, 0x403, 11, 0 -0x6957, 0x646e, 0x776f, 0x2073, 0x5058, "\000" - IDC_VISUAL_MNGR, 0x403, 14, 0 -0x534d, 0x204e, 0x654d, 0x7373, 0x6e65, 0x6567, 0x0072, - IDC_VISUAL_MNGR, 0x403, 20, 0 -0x534d, 0x4f20, 0x6666, 0x6369, 0x2065, 0x3032, 0x3730, 0x4220, 0x756c, -0x0065, - IDC_VISUAL_MNGR, 0x403, 21, 0 -0x534d, 0x4f20, 0x6666, 0x6369, 0x2065, 0x3032, 0x3730, 0x4220, 0x616c, -0x6b63, "\000" - IDC_VISUAL_MNGR, 0x403, 22, 0 -0x534d, 0x4f20, 0x6666, 0x6369, 0x2065, 0x3032, 0x3730, 0x5320, 0x6c69, -0x6576, 0x0072, - IDC_VISUAL_MNGR, 0x403, 20, 0 -0x534d, 0x4f20, 0x6666, 0x6369, 0x2065, 0x3032, 0x3730, 0x4120, 0x7571, -0x0061, - IDC_ANIMATION, 0x403, 13, 0 -0x6f4e, 0x6120, 0x696e, 0x616d, 0x6974, 0x6e6f, "\000" - IDC_ANIMATION, 0x403, 7, 0 -0x6e55, 0x6f66, 0x646c, "\000" - IDC_ANIMATION, 0x403, 6, 0 -0x6c53, 0x6469, 0x0065, - IDC_ANIMATION, 0x403, 5, 0 -0x6146, 0x6564, "\000" - 0 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_FLAG BITMAP DISCARDABLE "res\\flag.bmp" -IDB_DELETE BITMAP DISCARDABLE "res\\delete.bmp" -IDB_LOGO BITMAP DISCARDABLE "res\\logo.bmp" -IDB_ICONS BITMAP DISCARDABLE "res\\icons.bmp" -IDB_ICONS_SMALL BITMAP DISCARDABLE "res\\iconss.bmp" -IDR_TOOLBAR1 BITMAP DISCARDABLE "res\\toolbar1.bmp" -IDB_MENUIMAGES BITMAP DISCARDABLE "res\\menuimages24.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_POPUP MENU DISCARDABLE -BEGIN - POPUP "Popup" - BEGIN - MENUITEM "&Open Item", ID_POPUP_OPENITEM - MENUITEM SEPARATOR - MENUITEM "&Flag Item", ID_POPUP_FLAGITEM - MENUITEM "&Delete Item", ID_POPUP_DELETEITEM - MENUITEM "&Mark as Read", ID_POPUP_MARKASREAD - MENUITEM SEPARATOR - MENUITEM "Disa&ble New Desktop Alert", ID_POPUP_DISABLENEWDESKTOPALERT - - MENUITEM SEPARATOR - MENUITEM "Desktop Alert &Settings...", ID_POPUP_DESKTOPALERTSETTINGS - - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_TOOLBAR1 TOOLBAR DISCARDABLE 16, 16 -BEGIN - BUTTON ID_POPUP_DELETEITEM - BUTTON ID_POPUP_FLAGITEM - BUTTON ID_POPUP_MARKASREAD -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\DesktopAlertDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemoDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemoDlg.cpp deleted file mode 100644 index 1e7d92e806d31..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemoDlg.cpp +++ /dev/null @@ -1,440 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DesktopAlertDemo.h" -#include "DesktopAlertDemoDlg.h" -#include "MyAlertDlg.h" -#include "MSNDlg.h" -#include "MSNVisualManager.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDesktopAlertDemoDlg dialog - -CDesktopAlertDemoDlg::CDesktopAlertDemoDlg(CWnd* pParent /*=NULL*/) - : CDialogEx(CDesktopAlertDemoDlg::IDD, pParent), - m_wndIcons (m_IconsSmall) -{ - m_nVisualMngr = 2; - m_nAnimation = 3; - m_nAnimationSpeed = 30; - m_strAnimSpeed = _T(""); - m_nTransparency = 200; - m_strTransparency = _T(""); - m_bSmallCaption = TRUE; - m_nPopupSource = 0; - m_nIcon = 2; - m_strLink = _T("Click here to open"); - m_strText = _T("Type your message text here"); - m_nAutoCloseTime = 0; - m_strAutoClose = _T(""); - m_bAutoClose = FALSE; - - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - m_ptPopup = CPoint (-1, -1); -} - -void CDesktopAlertDemoDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialogEx::DoDataExchange(pDX); - DDX_Control(pDX, IDC_AUTOCLOSE_TIME, m_wndAutoCloseTime); - DDX_Control(pDX, IDC_TEXT, m_wndText); - DDX_Control(pDX, IDC_LINK, m_wndLink); - DDX_Control(pDX, IDC_URL_LABEL, m_wndLabel3); - DDX_Control(pDX, IDC_TEXT_LABEL, m_wndLabel2); - DDX_Control(pDX, IDC_ICON_LABEL, m_wndLabel1); - DDX_Control(pDX, IDC_ICONS, m_wndIcons); - DDX_Control(pDX, IDC_TRANSP, m_wndTransparency); - DDX_Control(pDX, IDC_ANIM_SPEED, m_wndANimationSpeed); - DDX_CBIndex(pDX, IDC_VISUAL_MNGR, m_nVisualMngr); - DDX_CBIndex(pDX, IDC_ANIMATION, m_nAnimation); - DDX_Slider(pDX, IDC_ANIM_SPEED, m_nAnimationSpeed); - DDX_Text(pDX, IDC_ANIM_SPEED_VAL, m_strAnimSpeed); - DDX_Slider(pDX, IDC_TRANSP, m_nTransparency); - DDX_Text(pDX, IDC_TRANSP_VAL, m_strTransparency); - DDX_Check(pDX, IDC_SMALL_CAPTION, m_bSmallCaption); - DDX_Radio(pDX, IDC_POPUP_SOURCE, m_nPopupSource); - DDX_CBIndex(pDX, IDC_ICONS, m_nIcon); - DDX_Text(pDX, IDC_LINK, m_strLink); - DDX_Text(pDX, IDC_TEXT, m_strText); - DDX_Slider(pDX, IDC_AUTOCLOSE_TIME, m_nAutoCloseTime); - DDX_Text(pDX, IDC_AUTOCLOSE_VAL, m_strAutoClose); - DDX_Check(pDX, IDC_AUTO_CLOSE, m_bAutoClose); -} - -BEGIN_MESSAGE_MAP(CDesktopAlertDemoDlg, CDialogEx) - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - ON_BN_CLICKED(IDC_SHOW, OnShow) - ON_CBN_SELCHANGE(IDC_VISUAL_MNGR, OnSelchangeVisualMngr) - ON_CBN_SELCHANGE(IDC_ANIMATION, OnSelchangeAnimation) - ON_WM_HSCROLL() - ON_BN_CLICKED(IDC_SMALL_CAPTION, OnSmallCaption) - ON_BN_CLICKED(IDC_POPUP_SOURCE, OnPopupSource) - ON_BN_CLICKED(IDC_POPUP_SOURCE2, OnPopupSource) - ON_BN_CLICKED(IDC_AUTO_CLOSE, OnAutoClose) - ON_REGISTERED_MESSAGE(AFX_WM_ON_CLOSEPOPUPWINDOW, OnClosePopup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDesktopAlertDemoDlg message handlers - -BOOL CDesktopAlertDemoDlg::OnInitDialog() -{ - CDialogEx::OnInitDialog(); - - CMFCToolBar::AddToolBarForImageCollection (IDR_TOOLBAR1, IDB_MENUIMAGES); - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - m_wndANimationSpeed.SetRange (1, 100); - m_wndTransparency.SetRange (10, 255); - m_wndAutoCloseTime.SetRange (1, 5); - - m_nVisualMngr = theApp.GetInt (_T("VisualManager"), 2); - m_nAnimation = theApp.GetInt (_T("AnimationType"), 3); - m_nAnimationSpeed = theApp.GetInt (_T("AnimationSpeed"), 30); - m_nTransparency = theApp.GetInt (_T("Transparency"), 200); - m_bSmallCaption = theApp.GetInt (_T("SmallCaption"), TRUE); - m_nPopupSource = theApp.GetInt (_T("PopupSource"), 0); - - m_strAnimSpeed.Format (_T("%d"), m_nAnimationSpeed); - m_strTransparency.Format (_T("%d"), m_nTransparency); - - m_nAutoCloseTime = theApp.GetInt (_T("AutoClose"), 3); - m_bAutoClose = m_nAutoCloseTime > 0; - - if (m_nAutoCloseTime == 0) - { - m_nAutoCloseTime = 3; - } - - m_strAutoClose.Format (_T("%d"), m_nAutoCloseTime); - - m_wndAutoCloseTime.EnableWindow (m_bAutoClose); - - m_Icons.SetImageSize (CSize (32, 32)); - m_Icons.Load (IDB_ICONS); - - m_IconsSmall.SetImageSize (CSize (16, 16)); - m_IconsSmall.Load (IDB_ICONS_SMALL); - - for (int i = 0; i <= m_Icons.GetCount (); i++) - { - CString strText; - - if (i == 0) - { - strText = _T("No icon"); - } - else - { - strText.Format (_T("Icon %d"), i); - } - - m_wndIcons.AddString (strText); - } - - UpdateData (FALSE); - - OnSelchangeVisualMngr(); - EnableSourceControls (); - - m_menuPopup.LoadMenu (IDR_POPUP); - - return TRUE; // return TRUE unless you set the focus to a control -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CDesktopAlertDemoDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialogEx::OnPaint(); - } -} - -// The system calls this to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CDesktopAlertDemoDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - - -void CDesktopAlertDemoDlg::OnShow() -{ - UpdateData (); - - // - CMFCDesktopAlertWnd* pPopup = new CMFCDesktopAlertWnd; - - // int m_nAnimation - pPopup->SetAnimationType ((CMFCPopupMenu::ANIMATION_TYPE) m_nAnimation); - - // int m_nAnimationSpeed - pPopup->SetAnimationSpeed (m_nAnimationSpeed); - - // int m_nTransparency - pPopup->SetTransparency ((BYTE)m_nTransparency); - - // BOOL m_bSmallCaption - pPopup->SetSmallCaption (m_bSmallCaption); - - // BOOL m_bAutoClose, int m_nAutoCloseTime - pPopup->SetAutoCloseTime (m_bAutoClose ? m_nAutoCloseTime * 1000 : 0); - - // int m_nPopupSource - if (m_nPopupSource == 0) - { - // int m_nVisualMngr - // CPoint m_ptPopup - // The this pointer points to a CDesktopAlertDemoDlg class which extends the CDialogEx class. - if (m_nVisualMngr == 5) // MSN-style - { - pPopup->Create (this, IDD_DIALOG2, NULL, - m_ptPopup, RUNTIME_CLASS (CMSNDlg)); - } - else - { - pPopup->Create (this, IDD_DIALOG1, - m_menuPopup.GetSubMenu (0)->GetSafeHmenu (), - m_ptPopup, RUNTIME_CLASS (CMyPopupDlg)); - } - } - // - else - { - // Create indirect: - // - CMFCDesktopAlertWndInfo params; - // int m_nIcon - if (m_nIcon > 0) - { - // CMFCToolBarImages m_Icons - params.m_hIcon = m_Icons.ExtractIcon (m_nIcon - 1); - } - - // CString m_strText - params.m_strText = m_strText; - // CString m_strLink - params.m_strURL = m_strLink; - params.m_nURLCmdID = 101; - // - - pPopup->Create (this, params, NULL, m_ptPopup); - } - - HICON hIcon = (HICON) ::LoadImage (::AfxGetResourceHandle (), - MAKEINTRESOURCE (IDR_MAINFRAME), - IMAGE_ICON, ::GetSystemMetrics (SM_CXSMICON), ::GetSystemMetrics (SM_CYSMICON), 0); - - pPopup->SetIcon (hIcon, FALSE); - pPopup->SetWindowText (_T("Message")); - - EnableControls (FALSE); -} - - -LRESULT CDesktopAlertDemoDlg::OnClosePopup(WPARAM,LPARAM lp) -{ - CMFCDesktopAlertWnd* pPopup = (CMFCDesktopAlertWnd*) lp; - ASSERT_VALID (pPopup); - - m_ptPopup = pPopup->GetLastPos (); - - EnableControls (); - return 0; -} - -void CDesktopAlertDemoDlg::EnableControls (BOOL bEnable) -{ - CWnd* pWndChild = GetWindow (GW_CHILD); - - while (pWndChild != NULL) - { - ASSERT_VALID (pWndChild); - pWndChild->EnableWindow (bEnable); - pWndChild = pWndChild->GetNextWindow (); - } - - if (bEnable) - { - EnableSourceControls (); - } -} - -void CDesktopAlertDemoDlg::OnSelchangeVisualMngr() -{ - int nPrevVisualMngr = m_nVisualMngr; - - UpdateData (); - - switch (m_nVisualMngr) - { - case 0: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case 1: - // - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - // - break; - - case 2: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - break; - - case 3: - // - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - // - break; - - case 4: - // - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - // - break; - - case 5: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMSNVisualManager)); - break; - - case 6: - // - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - // - break; - - case 7: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - break; - - case 8: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - break; - - case 9: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - break; - } - - if (nPrevVisualMngr == 5 && !m_bSmallCaption) - { - m_bSmallCaption = TRUE; - - UpdateData (FALSE); - OnSmallCaption(); - } - - if (m_nVisualMngr == 5 && m_bSmallCaption) - { - m_bSmallCaption = FALSE; - - UpdateData (FALSE); - OnSmallCaption(); - } - - theApp.WriteInt (_T("VisualManager"), m_nVisualMngr); -} - -void CDesktopAlertDemoDlg::OnSelchangeAnimation() -{ - UpdateData (); - theApp.WriteInt (_T("AnimationType"), m_nAnimation); -} - -void CDesktopAlertDemoDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar); - - UpdateData (); - - theApp.WriteInt (_T("AnimationSpeed"), m_nAnimationSpeed); - m_strAnimSpeed.Format (_T("%d"), m_nAnimationSpeed); - - theApp.WriteInt (_T("Transparency"), m_nTransparency); - m_strTransparency.Format (_T("%d"), m_nTransparency); - - theApp.WriteInt (_T("AutoClose"), m_bAutoClose ? m_nAutoCloseTime : 0); - m_strAutoClose.Format (_T("%d"), m_nAutoCloseTime); - - UpdateData (FALSE); -} - -void CDesktopAlertDemoDlg::OnSmallCaption() -{ - UpdateData (); - theApp.WriteInt (_T("SmallCaption"), m_bSmallCaption); -} - -void CDesktopAlertDemoDlg::OnPopupSource() -{ - UpdateData (); - theApp.WriteInt (_T("PopupSource"), m_nPopupSource); - - EnableSourceControls (); -} - -void CDesktopAlertDemoDlg::EnableSourceControls () -{ - BOOL bEnable = m_nPopupSource != 0; - - m_wndText.EnableWindow (bEnable); - m_wndLink.EnableWindow (bEnable); - m_wndLabel3.EnableWindow (bEnable); - m_wndLabel2.EnableWindow (bEnable); - m_wndLabel1.EnableWindow (bEnable); - m_wndIcons.EnableWindow (bEnable); -} - -void CDesktopAlertDemoDlg::OnAutoClose() -{ - UpdateData (); - - m_wndAutoCloseTime.EnableWindow (m_bAutoClose); - theApp.WriteInt (_T("AutoClose"), m_bAutoClose ? m_nAutoCloseTime : 0); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemoDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemoDlg.h deleted file mode 100644 index 01a1c86974173..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/DesktopAlertDemoDlg.h +++ /dev/null @@ -1,81 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "IconComboBox.h" - -///////////////////////////////////////////////////////////////////////////// -// CDesktopAlertDemoDlg dialog - -class CDesktopAlertDemoDlg : public CDialogEx -{ -// Construction -public: - CDesktopAlertDemoDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - // - enum { IDD = IDD_ALERT_DIALOG }; - CSliderCtrl m_wndAutoCloseTime; - CEdit m_wndText; - CEdit m_wndLink; - CStatic m_wndLabel3; - CStatic m_wndLabel2; - CStatic m_wndLabel1; - CIconComboBox m_wndIcons; - CSliderCtrl m_wndTransparency; - CSliderCtrl m_wndANimationSpeed; - int m_nVisualMngr; - int m_nAnimation; - int m_nAnimationSpeed; - CString m_strAnimSpeed; - int m_nTransparency; - CString m_strTransparency; - BOOL m_bSmallCaption; - int m_nPopupSource; - int m_nIcon; - CString m_strLink; - CString m_strText; - int m_nAutoCloseTime; - CString m_strAutoClose; - BOOL m_bAutoClose; - // - - // ClassWizard generated virtual function overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - HICON m_hIcon; - CMenu m_menuPopup; - CPoint m_ptPopup; - CMFCToolBarImages m_Icons; - CMFCToolBarImages m_IconsSmall; - - virtual BOOL OnInitDialog(); - - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnShow(); - afx_msg void OnSelchangeVisualMngr(); - afx_msg void OnSelchangeAnimation(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg void OnSmallCaption(); - afx_msg void OnPopupSource(); - afx_msg void OnAutoClose(); - afx_msg LRESULT OnClosePopup(WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() - - void EnableControls (BOOL bEnable = TRUE); - void EnableSourceControls (); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/IconComboBox.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/IconComboBox.cpp deleted file mode 100644 index 4a31557f47013..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/IconComboBox.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DesktopAlertDemo.h" -#include "IconComboBox.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CIconComboBox - -CIconComboBox::CIconComboBox(CMFCToolBarImages& Icons) : - m_Icons (Icons) -{ -} - -CIconComboBox::~CIconComboBox() -{ -} - - -BEGIN_MESSAGE_MAP(CIconComboBox, CComboBox) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CIconComboBox message handlers - -int CIconComboBox::CompareItem(LPCOMPAREITEMSTRUCT /*lpCompareItemStruct*/) -{ - // TODO: Add your code to determine the sorting order of the specified items - // return -1 = item 1 sorts before item 2 - // return 0 = item 1 and item 2 sort the same - // return 1 = item 1 sorts after item 2 - - return 0; -} - -void CIconComboBox::DrawItem(LPDRAWITEMSTRUCT lpDIS) -{ - CDC* pDC= CDC::FromHandle (lpDIS->hDC); - ASSERT_VALID (pDC); - - HBRUSH brBackground; - COLORREF clText; - - if (lpDIS->itemState & ODS_SELECTED) - { - brBackground = GetSysColorBrush (COLOR_HIGHLIGHT); - clText = afxGlobalData.clrTextHilite; - } - else - { - brBackground = GetSysColorBrush (COLOR_WINDOW); - clText = afxGlobalData.clrWindowText; - } - - CRect rectItem = lpDIS->rcItem; - ::FillRect (lpDIS->hDC, &rectItem, brBackground); - - int nIndex = lpDIS->itemID; - - if (nIndex > 0) - { - CAfxDrawState ds; - m_Icons.SetTransparentColor (afxGlobalData.clrBarFace); - m_Icons.PrepareDrawImage (ds); - m_Icons.Draw (pDC, rectItem.left + 1, rectItem.top + 1, nIndex - 1); - m_Icons.EndDrawImage (ds); - } - - CString strText; - GetLBText (nIndex, strText); - - CRect rectText = rectItem; - rectText.left += 20; - - CFont* pOldFont = pDC->SelectObject (&afxGlobalData.fontRegular); - - pDC->SetBkMode (TRANSPARENT); - pDC->SetTextColor (clText); - - pDC->DrawText (strText, rectText, DT_SINGLELINE | DT_VCENTER); - - pDC->SelectObject (pOldFont); -} - -void CIconComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS) -{ - lpMIS->itemHeight = 18; - lpMIS->itemWidth = 18; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/IconComboBox.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/IconComboBox.h deleted file mode 100644 index 129d64888bf9a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/IconComboBox.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CIconComboBox window - -class CIconComboBox : public CComboBox -{ -// Construction -public: - CIconComboBox(CMFCToolBarImages& Icons); - -// Attributes -protected: - CMFCToolBarImages& m_Icons; - -// Operations -public: - -// Overrides - public: - virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct); - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); - -// Implementation -public: - virtual ~CIconComboBox(); - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNDlg.cpp deleted file mode 100644 index fb7793dec2531..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNDlg.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DesktopAlertDemo.h" -#include "MSNDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMSNDlg dialog - -IMPLEMENT_DYNCREATE(CMSNDlg, CMFCDesktopAlertDialog) - -CMSNDlg::CMSNDlg() -{ -} - - -void CMSNDlg::DoDataExchange(CDataExchange* pDX) -{ - CMFCDesktopAlertDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_OPTIONS, m_Options); - DDX_Control(pDX, IDC_BUTTON1, m_btnRL); -} - - -BEGIN_MESSAGE_MAP(CMSNDlg, CMFCDesktopAlertDialog) - ON_BN_CLICKED(IDC_BUTTON1, OnButton1) - ON_BN_CLICKED(IDC_OPTIONS, OnOptions) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMSNDlg message handlers - -void CMSNDlg::OnDraw (CDC* pDC) -{ - CMFCDesktopAlertDialog::OnDraw (pDC); - - CRect rectClient; - GetClientRect (rectClient); - - CSize sizeLogo = m_imgLogo.GetImageSize (); - - CAfxDrawState ds; - m_imgLogo.PrepareDrawImage (ds); - - m_imgLogo.Draw (pDC, - rectClient.right - sizeLogo.cx - 5, - rectClient.bottom - sizeLogo.cy - 5, - 0); - - m_imgLogo.EndDrawImage (ds); -} - - -BOOL CMSNDlg::OnInitDialog() -{ - CMFCDesktopAlertDialog::OnInitDialog(); - - m_Options.m_bAlwaysUnderlineText = FALSE; - m_Options.m_bDefaultClickProcess = FALSE; - - m_btnRL.m_bMultilineText = TRUE; - m_btnRL.m_bAlwaysUnderlineText = FALSE; - m_btnRL.m_bDefaultClickProcess = TRUE; - - m_imgLogo.Load (IDB_LOGO); - m_imgLogo.SetTransparentColor (RGB (236, 0, 140)); - m_imgLogo.SetSingleImage (); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CMSNDlg::OnButton1() -{ - ::ShellExecute (NULL, NULL, _T("http://www.microsoft.com"), NULL, NULL, NULL); -} - -void CMSNDlg::OnOptions() -{ - // TODO: Add your control notification handler code here - -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNDlg.h deleted file mode 100644 index f9d90a87ecb99..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNDlg.h +++ /dev/null @@ -1,45 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CMSNDlg dialog - -class CMSNDlg : public CMFCDesktopAlertDialog -{ - DECLARE_DYNCREATE(CMSNDlg) - -// Construction -public: - CMSNDlg(); - -// Dialog Data - enum { IDD = IDD_DIALOG2 }; - CMFCLinkCtrl m_Options; - CMFCLinkCtrl m_btnRL; - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - virtual void OnDraw (CDC* pDC); - -// Implementation -protected: - virtual BOOL OnInitDialog(); - - afx_msg void OnButton1(); - afx_msg void OnOptions(); - - DECLARE_MESSAGE_MAP() - - CMFCToolBarImages m_imgLogo; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNVisualManager.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNVisualManager.cpp deleted file mode 100644 index 7781db95fe5de..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNVisualManager.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DesktopAlertDemo.h" -#include "MSNVisualManager.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -IMPLEMENT_DYNCREATE(CMSNVisualManager, CMFCVisualManagerWindows) - -const COLORREF clrFillDark = RGB (220, 228, 247); -const COLORREF clrFillLight = RGB (255, 255, 255); - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CMSNVisualManager::CMSNVisualManager() -{ -} -//********************************************************************************** -CMSNVisualManager::~CMSNVisualManager() -{ -} -//********************************************************************************** -void CMSNVisualManager::OnFillPopupWindowBackground (CDC* pDC, CRect rect) -{ - if (afxGlobalData.IsHighContrastMode () || afxGlobalData.m_nBitsPerPixel <= 8) - { - CMFCVisualManagerWindows::OnFillPopupWindowBackground (pDC, rect); - return; - } - - ASSERT_VALID (pDC); - - CDrawingManager dm (*pDC); - - int nStep = 0; - int nPartHeight = 30; - - for (int y = rect.top; y < rect.bottom; y += nPartHeight) - { - CRect rectFill = rect; - - rectFill.top = y; - rectFill.bottom = y + nPartHeight; - - if ((nStep % 2) != 0) - { - dm.FillGradient (rectFill, clrFillDark, clrFillLight, TRUE); - } - else - { - dm.FillGradient (rectFill, clrFillLight, clrFillDark, TRUE); - } - - nStep++; - } - - rect.DeflateRect (1, 1); - pDC->Draw3dRect (rect, RGB (116, 141, 181), RGB (185, 200, 241)); -} -//********************************************************************************** -void CMSNVisualManager::OnDrawPopupWindowBorder (CDC* pDC, CRect rect) -{ - if (afxGlobalData.IsHighContrastMode () || afxGlobalData.m_nBitsPerPixel <= 8) - { - CMFCVisualManagerWindows::OnDrawPopupWindowBorder (pDC, rect); - return; - } - - ASSERT_VALID (pDC); - - pDC->Draw3dRect (rect, RGB (166, 180, 207), RGB (68, 87, 145)); - rect.DeflateRect (1, 1); - pDC->Draw3dRect (rect, RGB (255, 255, 255), RGB (209, 221, 245)); -} -//********************************************************************************** -COLORREF CMSNVisualManager::OnDrawPopupWindowCaption (CDC* pDC, CRect rectCaption, CMFCDesktopAlertWnd* pPopupWnd) -{ - if (afxGlobalData.IsHighContrastMode () || afxGlobalData.m_nBitsPerPixel <= 8) - { - return CMFCVisualManagerWindows::OnDrawPopupWindowCaption (pDC, rectCaption, pPopupWnd); - } - - ASSERT_VALID (pDC); - - CDrawingManager dm (*pDC); - - CRect rectFill = rectCaption; - rectFill.bottom = rectFill.CenterPoint ().y; - - dm.FillGradient (rectFill, clrFillLight, clrFillDark, TRUE); - - rectFill = rectCaption; - rectFill.top = rectFill.CenterPoint ().y; - - dm.FillGradient (rectFill, clrFillDark, clrFillLight, TRUE); - - return RGB (37, 50, 118); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNVisualManager.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNVisualManager.h deleted file mode 100644 index 41236955844b3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MSNVisualManager.h +++ /dev/null @@ -1,24 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CMSNVisualManager : public CMFCVisualManagerWindows -{ - DECLARE_DYNCREATE(CMSNVisualManager) - -public: - CMSNVisualManager(); - virtual ~CMSNVisualManager(); - - virtual void OnFillPopupWindowBackground (CDC* pDC, CRect rect); - virtual void OnDrawPopupWindowBorder (CDC* pDC, CRect rect); - virtual COLORREF OnDrawPopupWindowCaption (CDC* pDC, CRect rectCaption, CMFCDesktopAlertWnd* pPopupWnd); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MyAlertDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MyAlertDlg.cpp deleted file mode 100644 index 3ebd6fa3707a9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MyAlertDlg.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DesktopAlertDemo.h" -#include "MyAlertDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMyPopupDlg dialog - -IMPLEMENT_DYNCREATE(CMyPopupDlg, CMFCDesktopAlertDialog) - -CMyPopupDlg::CMyPopupDlg() -{ -} - - -void CMyPopupDlg::DoDataExchange(CDataExchange* pDX) -{ - CMFCDesktopAlertDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_FROM, m_wndFrom); - DDX_Control(pDX, IDC_FLAG, m_btnFlag); - DDX_Control(pDX, IDC_DELETE, m_btnDelete); - DDX_Control(pDX, IDC_BUTTON1, m_btnRL); -} - - -BEGIN_MESSAGE_MAP(CMyPopupDlg, CMFCDesktopAlertDialog) - ON_BN_CLICKED(IDC_DELETE, OnDelete) - ON_BN_CLICKED(IDC_FLAG, OnFlag) - ON_BN_CLICKED(IDC_BUTTON1, OnButton1) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMyPopupDlg message handlers - -BOOL CMyPopupDlg::OnInitDialog() -{ - CMFCDesktopAlertDialog::OnInitDialog(); - - LOGFONT lf; - m_wndFrom.GetFont ()->GetLogFont (&lf); - - lf.lfWeight = FW_BOLD; - m_fontBold.CreateFontIndirect (&lf); - - m_wndFrom.SetFont (&m_fontBold); - - // - m_btnFlag.SetImage (IDB_FLAG); - // - - m_btnDelete.SetImage (IDB_DELETE); - - m_btnRL.m_bMultilineText = TRUE; - m_btnRL.m_bAlwaysUnderlineText = FALSE; - m_btnRL.m_bDefaultClickProcess = TRUE; - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CMyPopupDlg::OnDelete() -{ - GetParent ()->PostMessage (WM_CLOSE); -} - -void CMyPopupDlg::OnFlag() -{ - GetParent ()->PostMessage (WM_CLOSE); -} - -void CMyPopupDlg::OnButton1() -{ - GetParent ()->PostMessage (WM_CLOSE); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MyAlertDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MyAlertDlg.h deleted file mode 100644 index 9d77505780a7b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/MyAlertDlg.h +++ /dev/null @@ -1,50 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CMyPopupDlg dialog - -class CMyPopupDlg : public CMFCDesktopAlertDialog -{ - DECLARE_DYNCREATE(CMyPopupDlg) - -// Construction -public: - CMyPopupDlg(); - -// Dialog Data - enum { IDD = IDD_DIALOG1 }; - CStatic m_wndFrom; - - // - CMFCDesktopAlertWndButton m_btnFlag; - // - CMFCDesktopAlertWndButton m_btnDelete; - CMFCLinkCtrl m_btnRL; - - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - virtual BOOL OnInitDialog(); - - afx_msg void OnDelete(); - afx_msg void OnFlag(); - afx_msg void OnButton1(); - - DECLARE_MESSAGE_MAP() - - CFont m_fontBold; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/ReadMe.htm deleted file mode 100644 index 50f341d130591..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,124 +0,0 @@ - - - - DesktopAlertDemo Sample: MFC Desktop Alert Application - - -

- DesktopAlertDemo Sample: MFC Desktop Alert Application

-
-
-
- -

-

-
-

- The DesktopAlertDemo sample demonstrates how to implement a desktop alert dialog - (similar to the dialog by an instant messaging application).

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the DesktopAlertDemo sample

-
-
    -
  1. -

    - Open the solution DesktopAlertDemo.sln.

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration. -

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or - Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The DesktopAlertDemo sample demonstrates the following keywords:

-

- CDialogEx; CDrawingManager; CMFCDesktopAlertDialog; CMFCDesktopAlertWnd; CMFCDesktopAlertWndButton; - CMFCDesktopAlertWndInfo; CMFCLinkCtrl; CMFCPopupMenu; CMFCToolBar; CMFCToolBarImages; - CMFCVisualManager; CMFCVisualManagerOffice; CMFCVisualManagerWindows; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/Resource.h deleted file mode 100644 index 1cfb8efbfa62c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/Resource.h +++ /dev/null @@ -1,58 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by DesktopAlertDemo.rc -// -#define IDD_ALERT_DIALOG 102 -#define IDR_MAINFRAME 128 -#define IDD_DIALOG1 129 -#define IDI_MAIL 130 -#define IDD_DIALOG2 130 -#define IDB_FLAG 132 -#define IDB_DELETE 133 -#define IDB_LOGO 134 -#define IDR_POPUP 136 -#define IDB_ICONS 145 -#define IDB_ICONS_SMALL 146 -#define IDR_TOOLBAR1 147 -#define IDB_MENUIMAGES 149 -#define IDC_SHOW 1000 -#define IDC_BUTTON1 1003 -#define IDC_VISUAL_MNGR 1004 -#define IDC_ANIMATION 1005 -#define IDC_ANIM_SPEED 1006 -#define IDC_ANIM_SPEED_VAL 1007 -#define IDC_TRANSP 1008 -#define IDC_FLAG 1008 -#define IDC_TRANSP_VAL 1009 -#define IDC_DELETE 1009 -#define IDC_FROM 1010 -#define IDC_AUTOCLOSE_TIME 1010 -#define IDC_SMALL_CAPTION 1011 -#define IDC_OPTIONS 1012 -#define IDC_AUTOCLOSE_VAL 1012 -#define IDC_POPUP_SOURCE 1013 -#define IDC_POPUP_SOURCE2 1014 -#define IDC_ICONS 1016 -#define IDC_ICON_LABEL 1017 -#define IDC_TEXT_LABEL 1018 -#define IDC_TEXT 1019 -#define IDC_URL_LABEL 1020 -#define IDC_LINK 1021 -#define IDC_AUTO_CLOSE 1022 -#define ID_POPUP_OPENITEM 32771 -#define ID_POPUP_FLAGITEM 32772 -#define ID_POPUP_DELETEITEM 32773 -#define ID_POPUP_MARKASREAD 32774 -#define ID_POPUP_DISABLENEWDESKTOPALERT 32775 -#define ID_POPUP_DESKTOPALERTSETTINGS 32776 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 150 -#define _APS_NEXT_COMMAND_VALUE 32779 -#define _APS_NEXT_CONTROL_VALUE 1023 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/Snippets.txt deleted file mode 100644 index 72ef78636f872..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/Snippets.txt +++ /dev/null @@ -1,12 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -DesktopAlertDemoDlg.cpp: CMFCDesktopAlertWnd 1 -DesktopAlertDemoDlg.h: CMFCDesktopAlertWndInfo 2 -DesktopAlertDemoDlg.cpp: CMFCDesktopAlertWndInfo 3 -MyAlertDlg.h: CMFCDesktopAlertWndButton 4 -MyAlertDlg.cpp: CMFCDeskTopAlertWndButton 5 -DesktopAlertDemo.cpp: CMFCVisualManagerOffice2003 6 -DesktopAlertDemoDlg.cpp: CMFCVisualManagerOffice2007 7 -DesktopAlertDemoDlg.cpp: CMFCVisualManagerOfficeXP 8 -DesktopAlertDemoDlg.cpp: CMFCVisualManagerVS2005 9 -DesktopAlertDemoDlg.cpp: CMFCVisualManagerWindows 10 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/StdAfx.cpp deleted file mode 100644 index 01ad7a7ea0200..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// DesktopAlertDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/StdAfx.h deleted file mode 100644 index 2f3c31a436cfe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/StdAfx.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/desktopalertdemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/desktopalertdemo.vcxproj deleted file mode 100644 index cc97cfa187a8b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/desktopalertdemo.vcxproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {8049899E-86B9-46C3-951B-B133163EB6AA} - DesktopAlertDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\Bin/DesktopAlertDemo.tlb - - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\Bin/DesktopAlertDemo.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Create - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - Create - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/desktopalertdemo.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/desktopalertdemo.vcxproj.filters deleted file mode 100644 index dd8770bebaca5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/desktopalertdemo.vcxproj.filters +++ /dev/null @@ -1,107 +0,0 @@ - - - - - {29c2dded-2972-4712-9741-4b68b46a4e58} - h;hpp;hxx;hm;inl - - - {d88e60d4-3891-49e7-ac86-42e3fbbee778} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {89c2bb4b-2a12-41b2-a591-a7a0aa16a73f} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/DesktopAlertDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/DesktopAlertDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/DesktopAlertDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/DesktopAlertDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/DesktopAlertDemo.rc2 deleted file mode 100644 index b267a35f250c4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/DesktopAlertDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// POPUPDEMO.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/delete.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/delete.bmp deleted file mode 100644 index b659c0ea1ca83..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/delete.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/flag.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/flag.bmp deleted file mode 100644 index a6aa86b69decb..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/flag.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/icons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/icons.bmp deleted file mode 100644 index c3742560b236f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/icons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/iconss.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/iconss.bmp deleted file mode 100644 index 86556083fb27c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/iconss.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/logo.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/logo.bmp deleted file mode 100644 index 3e4a1a91c9ade..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/logo.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/mail.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/mail.ico deleted file mode 100644 index 0593e1e5d0ffa..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/mail.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/menuimages24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/menuimages24.bmp deleted file mode 100644 index cb822dce165b8..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/menuimages24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/toolbar1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/toolbar1.bmp deleted file mode 100644 index a38f4b31d3c06..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/res/toolbar1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DesktopAlertDemo/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.cpp deleted file mode 100644 index 7daada164d68c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" - -#include "mainfrm.h" -#include "drawobj.h" -#include "drawdoc.h" -#include "drawvw.h" -#include "splitfrm.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDrawApp - -BEGIN_MESSAGE_MAP(CDrawApp, CWinAppEx) - //{{AFX_MSG_MAP(CDrawApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinAppEx::OnFilePrintSetup) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDrawApp construction - -CDrawApp::CDrawApp() -{ - // TODO: add construction code here, // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CDrawApp object - -CDrawApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CDrawApp initialization - -BOOL CDrawApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - LoadStdProfileSettings(4); // Load standard INI file options(including MRU) - - SetRegistryBase(_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - // TODO: Remove this if you don't want extended tooltips: - InitTooltipManager(); - - // - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), ¶ms); - // - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate(IDR_DRAWCLTYPE, RUNTIME_CLASS(CDrawDoc), RUNTIME_CLASS(CSplitFrame), RUNTIME_CLASS(CDrawView)); - pDocTemplate->SetContainerInfo(IDR_DRAWCLTYPE_CNTR_IP); - AddDocTemplate(pDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - - if (!pMainFrame) - return FALSE; - - if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) - { - delete pMainFrame; - return FALSE; - } - m_pMainWnd = pMainFrame; - - // Enable DDE Execute open - EnableShellOpen(); - RegisterShellFileTypes(TRUE); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // Enable drag/drop open - m_pMainWnd->DragAcceptFiles(); - - // The main window has been initialized, so show and update it. - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - - return TRUE; -} - -int CDrawApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CDrawApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.h deleted file mode 100644 index b7687287ef6ae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.h +++ /dev/null @@ -1,39 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifndef __AFXWIN_H__ -#error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols -#include // drawcli uses collection class templates - -///////////////////////////////////////////////////////////////////////////// -// CDrawApp: -// See drawcli.cpp for the implementation of this class -// - -class CDrawApp : public CWinAppEx -{ -public: - CDrawApp(); - - // Overrides - virtual BOOL InitInstance(); - virtual int ExitInstance(); - - // Implementation -protected: - //{{AFX_MSG(CDrawApp) - afx_msg void OnAppAbout(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -extern CDrawApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.rc deleted file mode 100644 index 6996bc9b790c9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/DrawClient.rc +++ /dev/null @@ -1,757 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_PROPERTIES BITMAP "res\\prop24.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_THEME_MENU MENU -BEGIN - MENUITEM "&Blue Theme", ID_VIEW_APPLOOK_2007 - MENUITEM "B&lack Theme", ID_VIEW_APPLOOK_2007_1 - MENUITEM "&Silver Theme", ID_VIEW_APPLOOK_2007_2 - MENUITEM "&Aqua Theme", ID_VIEW_APPLOOK_2007_3 -END - -IDR_WINDOWS_MENU MENU -BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW -END - -IDR_POPUP_MDITABS MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "&Save", ID_FILE_SAVE - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM SEPARATOR - MENUITEM "New &Horizontal Tab Group", 32824 - MENUITEM "New &Vertical Tab Group", 32825 - MENUITEM "Move to Ne&xt Tab Group", 32826 - MENUITEM "Move to P&revious Tab Group", 32827 - END -END - -IDR_POPUP_DROP_MDITABS MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "New &Horizontal Tab Group", ID_MDI_NEW_HORZ_TAB_GROUP - MENUITEM "New &Vertical Tab Group", ID_MDI_NEW_VERT_GROUP - MENUITEM "Move to Ne&xt Tab Group", ID_MDI_MOVE_TO_NEXT_GROUP - MENUITEM "Move to P&revious Tab Group", ID_MDI_MOVE_TO_PREV_GROUP - MENUITEM SEPARATOR - MENUITEM "&Cancel", 32828 - END -END - -IDR_DRAWCLTYPE MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Sen&d...", ID_FILE_SEND_MAIL - MENUITEM "Summary &Info...", ID_FILE_SUMMARYINFO - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1 - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - MENUITEM "&Delete\tDel", ID_EDIT_CLEAR - MENUITEM "Select &All\tCtrl+A", ID_EDIT_SELECT_ALL - MENUITEM SEPARATOR - MENUITEM "Insert &New Object...", ID_OLE_INSERT_NEW - MENUITEM "Lin&ks...", ID_OLE_EDIT_LINKS - MENUITEM "<>", ID_OLE_VERB_FIRST - END - POPUP "&View" - BEGIN - MENUITEM "&Grid Lines\tG", ID_VIEW_GRID - MENUITEM "&Paper Color...", ID_VIEW_PAPERCOLOR - MENUITEM "Show &Objects", ID_VIEW_SHOWOBJECTS - MENUITEM SEPARATOR - MENUITEM "&Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Draw" - BEGIN - MENUITEM "&Select", ID_DRAW_SELECT - MENUITEM "&Line", ID_DRAW_LINE - MENUITEM "&Rectangle", ID_DRAW_RECT - MENUITEM "R&ound Rectangle", ID_DRAW_ROUNDRECT - MENUITEM "&Ellipse", ID_DRAW_ELLIPSE - MENUITEM "&Polygon", ID_DRAW_POLYGON - END - POPUP "&Object" - BEGIN - MENUITEM "&Line Color...", ID_OBJECT_LINECOLOR - MENUITEM "No Line", ID_OBJECT_NOLINE - MENUITEM "&Fill Color...", ID_OBJECT_FILLCOLOR - MENUITEM "No Fill", ID_OBJECT_NOFILL - POPUP "Line Weight" - BEGIN - MENUITEM "Line Weight", ID_OBJECT_LINEWEIGHT - MENUITEM SEPARATOR - MENUITEM "More &Lines...", ID_OBJECT_LINEWEIGHT_MORE - - END - MENUITEM SEPARATOR - MENUITEM "&Styles", ID_OBJECT_STYLES - MENUITEM "&Properties...", ID_OBJECT_PROPERTIES - MENUITEM SEPARATOR - MENUITEM "Move To Front\tCtrl+Plus", ID_OBJECT_MOVETOFRONT - MENUITEM "Move To Back\tCtrl+Minus", ID_OBJECT_MOVETOBACK - MENUITEM "Move Forward\tPlus", ID_OBJECT_MOVEFORWARD - MENUITEM "Move Back\tMinus", ID_OBJECT_MOVEBACK - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - MENUITEM "&Cascade", ID_WINDOW_CASCADE - MENUITEM "&Tile", ID_WINDOW_TILE_HORZ - MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE - MENUITEM "Windows...", ID_WINDOW_MANAGER - END - POPUP "&Help" - BEGIN - MENUITEM "&About DrawClient...", ID_APP_ABOUT - END -END - -IDR_DRAWCLTYPE_CNTR_IP MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Sen&d...", ID_FILE_SEND_MAIL - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - MENUITEM SEPARATOR - MENUITEM SEPARATOR - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - MENUITEM "&Cascade", ID_WINDOW_CASCADE - MENUITEM "&Tile", ID_WINDOW_TILE_HORZ - MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE - END -END - -ID_POPUP_MENU MENU -BEGIN - POPUP "" - BEGIN - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Delete\tDel", ID_EDIT_CLEAR - MENUITEM SEPARATOR - MENUITEM "Object...", ID_OLE_VERB_FIRST - END -END - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM SEPARATOR - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - MENUITEM "&Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About DrawClient...", ID_APP_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_PROPERTIES TOOLBAR 16, 16 -BEGIN - BUTTON ID_EXPAND - BUTTON ID_SORTINGGROUP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// PNG -// - -IDB_RIBBON_HOMELARGE PNG "res\\homelarge.png" -IDB_RIBBON_HOMESMALL PNG "res\\homesmall.png" -IDB_RIBBON_VIEWSMALL PNG "res\\viewsmall.png" -IDB_RIBBON_VIEWLARGE PNG "res\\viewlarge.png" -IDB_RIBBON_FILELARGE PNG "res\\filelarge.png" -IDB_RIBBON_FILESMALL PNG "res\\filesmall.png" -IDB_RIBBON_FORMATLARGE PNG "res\\formatlarge.png" -IDB_RIBBON_FORMATSMALL PNG "res\\formatsmall.png" -IDB_RIBBON_MAIN PNG "res\\main.bmp" -IDB_RIBBON_ICONS PNG "res\\ribbonicons.png" -IDB_STATUSBAR_1 PNG "res\\sb_1.png" -IDB_STATUSBAR_2 PNG "res\\sb_2.png" -IDB_LINEWEIGHT PNG "res\\lineweight.png" -IDB_STYLES PNG "res\\styles.png" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#include ""res\\drawclient.rc2"" // non-App Studio edited resources\r\n" - "\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#include ""afxolecl.rc"" // OLE container resources\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "RES\\DRAWCLIENT.ICO" -IDR_DRAWCLTYPE ICON "RES\\DRAWDOC.ICO" - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "+", ID_OBJECT_MOVETOFRONT, ASCII, NOINVERT - "-", ID_OBJECT_MOVEBACK, ASCII, NOINVERT - "=", ID_OBJECT_MOVEFORWARD, ASCII, NOINVERT - "_", ID_OBJECT_MOVETOBACK, ASCII, NOINVERT - "A", ID_EDIT_SELECT_ALL, VIRTKEY, CONTROL, NOINVERT - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "E", ID_DRAW_ELLIPSE, ASCII, NOINVERT - "e", ID_DRAW_ELLIPSE, ASCII, NOINVERT - "G", ID_VIEW_GRID, ASCII, NOINVERT - "g", ID_VIEW_GRID, ASCII, NOINVERT - "L", ID_DRAW_LINE, ASCII, NOINVERT - "l", ID_DRAW_LINE, ASCII, NOINVERT - "N", ID_DRAW_ROUNDRECT, ASCII, NOINVERT - "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT - "n", ID_DRAW_ROUNDRECT, ASCII, NOINVERT - "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT - "R", ID_DRAW_RECT, ASCII, NOINVERT - "r", ID_DRAW_RECT, ASCII, NOINVERT - "S", ID_DRAW_SELECT, ASCII, NOINVERT - "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT - "s", ID_DRAW_SELECT, ASCII, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_ADD, ID_OBJECT_MOVEFORWARD, VIRTKEY, NOINVERT - VK_ADD, ID_OBJECT_MOVETOFRONT, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CLEAR, VIRTKEY, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_ESCAPE, ID_CANCEL_EDIT, VIRTKEY, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - VK_SUBTRACT, ID_OBJECT_MOVEBACK, VIRTKEY, NOINVERT - VK_SUBTRACT, ID_OBJECT_MOVETOBACK, VIRTKEY, CONTROL, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - -IDR_DRAWCLTYPE_CNTR_IP ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT - VK_ESCAPE, ID_CANCEL_EDIT, VIRTKEY, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About DrawClient" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "DrawClient Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT "� 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_PROP_RECT DIALOG 20, 20, 186, 93 -STYLE DS_CONTEXTHELP | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION -CAPTION "General" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Outline",IDC_STATIC,6,6,101,33 - LTEXT "Weight:",IDC_STATIC,11,20,27,8 - EDITTEXT IDC_WEIGHT,41,18,30,13,ES_AUTOHSCROLL - CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,71,18,10, - 14 - GROUPBOX "Fill",IDC_STATIC,6,44,100,40 - CONTROL "None",IDC_NOFILL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 11,56,35,10 -END - -IDD_SUMM_PAGE DIALOG 0, 0, 184, 163 -STYLE DS_CONTEXTHELP | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION | - WS_SYSMENU -CAPTION "Summary" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Author:",IDC_STATIC,7,23,24,8 - LTEXT "Keywords:",IDC_STATIC,7,39,34,8 - LTEXT "Comments:",IDC_STATIC,7,55,36,8 - LTEXT "Title:",IDC_STATIC,7,105,16,8 - LTEXT "Subject:",IDC_STATIC,7,121,27,8 - LTEXT "Template:",IDC_STATIC,7,137,32,8 - EDITTEXT IDC_AUTHOR,46,23,119,13,ES_AUTOHSCROLL - EDITTEXT IDC_KEYWORDS,46,39,119,13,ES_AUTOHSCROLL - EDITTEXT IDC_COMMENTS,46,55,119,47,ES_MULTILINE | ES_WANTRETURN | - WS_VSCROLL - EDITTEXT IDC_TITLE,46,105,119,13,ES_AUTOHSCROLL - EDITTEXT IDC_SUBJECT,46,121,119,13,ES_AUTOHSCROLL - EDITTEXT IDC_TEMPLATE,46,137,119,13,ES_AUTOHSCROLL - LTEXT "Application:",IDC_STATIC,7,7,38,8 - LTEXT "Static",IDC_APPNAME,46,7,119,8 -END - -IDD_STAT_PAGE DIALOG 0, 0, 184, 161 -STYLE DS_CONTEXTHELP | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION | - WS_SYSMENU -CAPTION "Statistics" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Last Saved By:",IDC_STATIC,7,13,49,8 - LTEXT "Static",IDC_SAVEDBY,72,13,84,8 - LTEXT "Revision number:",IDC_STATIC,7,27,56,8 - LTEXT "Total Editing Time:",IDC_STATIC,7,41,60,8 - LTEXT "Static",IDC_EDITTIME,72,41,84,8 - LTEXT "Last Printed:",IDC_STATIC,7,55,40,8 - LTEXT "Static",IDC_LASTPRINT,72,55,84,8 - LTEXT "Created:",IDC_STATIC,7,69,28,8 - LTEXT "Static",IDC_CREATEDATE,72,69,84,8 - LTEXT "Last Saved:",IDC_STATIC,7,83,39,8 - LTEXT "Static",IDC_LASTSAVE,72,83,84,8 - LTEXT "# Pages:",IDC_STATIC,7,97,30,8 - LTEXT "Static",IDC_NUMPAGES,72,97,32,8 - LTEXT "# words:",IDC_STATIC,7,111,28,8 - LTEXT "Static",IDC_NUMWORDS,72,111,32,8 - LTEXT "# chars:",IDC_STATIC,7,125,27,8 - LTEXT "Static",IDC_NUMCHARS,72,125,32,8 - LTEXT "Static",IDC_REVNUM,72,27,84,8 - LTEXT "Security Level:",IDC_STATIC,7,139,48,8 - LTEXT "Static",IDC_SECURITY,72,139,32,8 -END - -IDD_LINEWEIGHT DIALOG 0, 0, 160, 46 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Line Weight" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Weight:",IDC_STATIC,7,17,27,8 - EDITTEXT IDC_WEIGHT,37,15,30,13,ES_AUTOHSCROLL - CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,67,15,11, - 14 - DEFPUSHBUTTON "OK",IDOK,103,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,103,24,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Cursor -// - -IDC_PENCIL CURSOR "RES\\PENCIL.CUR" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "DRAWCLIENT MFC Application\0" - VALUE "FileVersion", "1.0.001\0" - VALUE "InternalName", "DRAWCLIENT\0" - VALUE "LegalCopyright", "� Microsoft Corporation. All rights reserved.\0" - VALUE "OriginalFilename", "DRAWCLIENT.EXE\0" - VALUE "ProductName", "DRAWCLIENT Application\0" - VALUE "ProductVersion", "1.0.001\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_SUMM_PAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 177 - TOPMARGIN, 7 - BOTTOMMARGIN, 156 - END - - IDD_STAT_PAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 177 - TOPMARGIN, 7 - BOTTOMMARGIN, 159 - END - - IDD_LINEWEIGHT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 153 - TOPMARGIN, 7 - BOTTOMMARGIN, 39 - END -END -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - ID_VIEW_APPLOOK_2007 "Activate Office 2007 (Blue) application look\nOffice 2007 Look (Blue)" - ID_VIEW_APPLOOK_2007_1 "Activate Office 2007 (Black) application look\nOffice 2007 Look (Black)" - ID_VIEW_APPLOOK_2007_2 "Activate Office 2007 (Silver) application look\nOffice 2007 Look (Silver)" - ID_VIEW_APPLOOK_2007_3 "Activate Office 2007 (Aqua) application look\nOffice 2007 Look (Aqua)" - ID_NEWWINDOW "Open another window for the active document\nNew Window" - ID_EXPAND "\nCategorized" - ID_SORTINGGROUP "\nAlphabetical" - ID_STATUSBAR_PANE_OBJECTCOUNT "Total Number Of Objects\nObject Count" -END - -STRINGTABLE -BEGIN - IDP_BUSY "Server is still busy." - IDP_OLE_INIT_FAILED "OLE 2.0 initialization failed. Make sure that the OLE libraries are the correct version." - IDP_FAILED_TO_CREATE "Failed to create object. Make sure the object is entered in the system registry." -END - -STRINGTABLE -BEGIN - IDR_MAINFRAME "DrawClient Application" - IDR_DRAWCLTYPE "\nDrawClient\nDrawClient Document\nDrawClient Files (*.drw)\n.drw\nDrawClient.Document\nDrawClient Document\nDCLI\nDrawClient Files" -END - -STRINGTABLE -BEGIN - ID_STATUSBAR_PANE_SELECTEDOBJECTCOUNT - "Total Number of Selected Objects\nSelected Object Count" - ID_TOOLS_OPTIONS "Changes application options\nOptions" - ID_OBJECT_NOFILL "\nNo Fill" - ID_OBJECT_LINEWEIGHT "Change the line weight\nLine Weight" - ID_OBJECT_LINEWEIGHT_MORE - "Launch dialog box to specify line weight\nMore Lines" - ID_OBJECT_PROPERTIES "Show the Colors and Lines dialog box\nAdvanced Tools" - ID_OBJECT_NOLINE "\nNo Line" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "DrawClient Application" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_DIRECT "Send the document directly to the default printer without making changes.\nQuick Print" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" - ID_FILE_SEND_MAIL "Send the active document through electronic mail\nSend Mail" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" - ID_CONTEXT_HELP "Display help for clicked-on buttons, menus and windows\nHelp mode" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_PASTE_LINK "Insert Clipboard contents and a link to its source\nPaste Link" - ID_EDIT_PASTE_SPECIAL "Insert Clipboard contents with options\nPaste Special" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - ID_OLE_INSERT_NEW "Insert new linked or embedded object\nNew Object" - ID_OLE_EDIT_LINKS "Edit linked objects\nEdit Links" - ID_OLE_EDIT_CONVERT "Convert object to different type\nConvert Object" -END - -STRINGTABLE -BEGIN - ID_OLE_VERB_FIRST "Activate embedded or linked object" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" -END - -STRINGTABLE -BEGIN - ID_VIEW_GRID "Show or hide gridlines\nToggle Gridlines" - ID_DRAW_SELECT "Choose object selection tool\nSelection Tool" - ID_DRAW_LINE "Choose line drawing tool\nLine Tool" - ID_DRAW_RECT "Choose rectangle drawing tool\nRectangle Tool" - ID_DRAW_ROUNDRECT "Choose rounded rectangle drawing tool\nRoundRect Tool" - ID_DRAW_ELLIPSE "Choose ellipse drawing tool\nEllipse Tool" - ID_OBJECT_LINECOLOR "Change the line or text color\nLine Color" - ID_OBJECT_FILLCOLOR "Change the fill or background color\nFill Color" - ID_OBJECT_MOVETOFRONT "Move object to front of drawing\nMove to Front" - ID_OBJECT_MOVETOBACK "Move object to back of drawing\nMove to Back" - ID_OBJECT_MOVEFORWARD "Move object to next position in z-order\nMove Forward" - ID_OBJECT_MOVEBACK "Move object to previous position in z-order\nMove Backward" - ID_VIEW_PAPERCOLOR "Change paper color displayed while editing\nPaper Color" - ID_DRAW_POLYGON "Choose the polygon drawing tool\nPolygon Tool" -END - -STRINGTABLE -BEGIN - ID_VIEW_SHOWOBJECTS "Toggle OLE object indication\nOLE object indication" - ID_FILE_SUMMARYINFO "Display summary information\nSummary Info" - ID_WINDOWS_MENU "Switch to a different currently open window\nSwitch Windows" -END - -STRINGTABLE -BEGIN - ID_WINDOW_MANAGER "Show Windows dialog to manage open windows\nManage opened windows" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#include "res\drawclient.rc2" // non-App Studio edited resources - -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#include "afxolecl.rc" // OLE container resources - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/LineWeightDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/LineWeightDlg.cpp deleted file mode 100644 index cc001155862df..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/LineWeightDlg.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" -#include "LineWeightDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -CLineWeightDlg::CLineWeightDlg(CWnd* pParent /*=NULL*/) : - CDialog(CLineWeightDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CLineWeightDlg) - m_penSize = 0; - //}}AFX_DATA_INIT -} - -void CLineWeightDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CLineWeightDlg) - DDX_Control(pDX, IDC_SPIN1, m_SpinCtrl); - DDX_Text(pDX, IDC_WEIGHT, m_penSize); - DDV_MinMaxUInt(pDX, m_penSize, 0, 100); - //}}AFX_DATA_MAP -} - -BOOL CLineWeightDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_SpinCtrl.SetRange(0, 100); - m_SpinCtrl.SetBase(10); - m_SpinCtrl.SetPos(max(m_penSize, 0)); - return TRUE; -} - -BEGIN_MESSAGE_MAP(CLineWeightDlg, CDialog) - //{{AFX_MSG_MAP(CLineWeightDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/LineWeightDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/LineWeightDlg.h deleted file mode 100644 index d8c7ddfa39618..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/LineWeightDlg.h +++ /dev/null @@ -1,36 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CLineWeightDlg : public CDialog -{ -// Construction -public: - CLineWeightDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CLineWeightDlg) - enum { IDD = IDD_LINEWEIGHT }; - CSpinButtonCtrl m_SpinCtrl; - UINT m_penSize; - //}}AFX_DATA - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnInitDialog(); - -// Implementation -protected: - //{{AFX_MSG(CLineWeightDlg) - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/PropertiesViewBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/PropertiesViewBar.cpp deleted file mode 100644 index 63ad6896a83b6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/PropertiesViewBar.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" -#include "PropertiesViewBar.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - - -CPropertiesViewBar::CPropertiesViewBar(void) -{ -} - -CPropertiesViewBar::~CPropertiesViewBar(void) -{ -} - -BEGIN_MESSAGE_MAP(CPropertiesViewBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_SETFOCUS() - ON_COMMAND (ID_EXPAND, OnPropListTreeMode) - ON_UPDATE_COMMAND_UI (ID_EXPAND, OnUpdatePropListTreeMode) - ON_COMMAND (ID_SORTINGGROUP, OnPropListAlphabetMode) - ON_UPDATE_COMMAND_UI (ID_SORTINGGROUP, OnUpdatePropListAlphabetMode) -END_MESSAGE_MAP() - -void CPropertiesViewBar::AdjustLayout () -{ - if (GetSafeHwnd () == NULL) - { - return; - } - - CRect rectClient; - GetClientRect (rectClient); - - int cyTlb = m_wndToolBar.CalcFixedLayout (FALSE, TRUE).cy; - - m_wndToolBar.SetWindowPos (NULL, - rectClient.left, - rectClient.top, - rectClient.Width (), - cyTlb, - SWP_NOACTIVATE | SWP_NOZORDER); - - - m_wndPropList.SetWindowPos (NULL, - rectClient.left, - rectClient.top + cyTlb, - rectClient.Width (), - rectClient.Height () - cyTlb, - SWP_NOACTIVATE | SWP_NOZORDER); -} -int CPropertiesViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty (); - - if (!m_wndPropList.Create (WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) - { - TRACE0("Failed to create Properies Grid \n"); - return -1; // fail to create - } - - m_wndToolBar.Create (this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); - m_wndToolBar.LoadToolBar (IDR_PROPERTIES, 0, 0, TRUE /* Is locked */); - - m_wndPropList.SetVSDotNetLook (TRUE); - m_wndPropList.SetGroupNameFullWidth (TRUE); - m_wndPropList.EnableDescriptionArea (TRUE); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - - m_wndToolBar.SetPaneStyle ( - m_wndToolBar.GetPaneStyle () & - ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - m_wndToolBar.SetOwner (this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame (FALSE); - - AdjustLayout (); - return 0; -} - -void CPropertiesViewBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout (); -} - -void CPropertiesViewBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - m_wndPropList.SetFocus (); -} -void CPropertiesViewBar::OnPropListTreeMode () -{ - m_wndPropList.SetAlphabeticMode (FALSE); -} -void CPropertiesViewBar::OnPropListAlphabetMode () -{ - m_wndPropList.SetAlphabeticMode (TRUE); -} -void CPropertiesViewBar::OnUpdatePropListTreeMode (CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (!m_wndPropList.IsAlphabeticMode ()); -} -void CPropertiesViewBar::OnUpdatePropListAlphabetMode (CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndPropList.IsAlphabeticMode ()); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/PropertiesViewBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/PropertiesViewBar.h deleted file mode 100644 index 40c0b2f7308a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/PropertiesViewBar.h +++ /dev/null @@ -1,62 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CPropertiesToolBar : public CMFCToolBar -{ -public: - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI ((CFrameWnd*) GetOwner (), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList () const { return FALSE; } -}; - -class CPropertiesViewBar : public CDockablePane -{ -public: - CPropertiesViewBar(void); - - void AdjustLayout (); - -// Attributes -public: - void SetVSDotNetLook (BOOL bSet) - { - m_wndPropList.SetVSDotNetLook (bSet); - m_wndPropList.SetGroupNameFullWidth (bSet); - } - - CMFCPropertyGridCtrl* GetPropList () {return &m_wndPropList;} - -protected: - CPropertiesToolBar m_wndToolBar; - CMFCPropertyGridCtrl m_wndPropList; - -// Attributes -protected: - -// Implementation -public: - virtual ~CPropertiesViewBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnPropListTreeMode (); - afx_msg void OnPropListAlphabetMode (); - afx_msg void OnUpdatePropListTreeMode (CCmdUI* pCmdUI); - afx_msg void OnUpdatePropListAlphabetMode (CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/ReadMe.htm deleted file mode 100644 index 8a9e766670513..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/ReadMe.htm +++ /dev/null @@ -1,134 +0,0 @@ - - - - DrawClient Sample: MFC Ribbon-Based OLE Object Drawing Application - - -

- DrawClient Sample: MFC Ribbon-Based OLE Object Drawing Application

-
-
-
- -

-

-
-

- The DrawClient sample demonstrates how to integrate support for a ribbon into an - object-oriented drawing application with visual editing container support. The DrawClient - sample is an update to the DrawCli MFC sample, using the same underlying document/view - architecture, but with a ribbon UI instead of a toolbar. The DrawClient sample also - demonstrates "command previewing", where the effect of a command can be seen before - it is actually selected, as in Office 2007.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the DrawClient sample

-
-
    -
  1. -

    - Open the solution file DrawClient.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The DrawClient sample demonstrates the following keywords:

-

- CDockablePane; CDockingManager; CMDIChildWndEx; CMDIFrameWndEx; CMDITabInfo; CMFCPopupMenu; - CMFCPopupMenuBar; CMFCPropertyGridCtrl; CMFCPropertySheet; CMFCRibbonApplicationButton; - CMFCRibbonBar; CMFCRibbonBaseElement; CMFCRibbonButton; CMFCRibbonButtonsGroup; - CMFCRibbonCategory; CMFCRibbonCheckBox; CMFCRibbonColorButton; CMFCRibbonCustomizePropertyPage; - CMFCRibbonGallery; CMFCRibbonGalleryIcon; CMFCRibbonLabel; CMFCRibbonMainPanel; - CMFCRibbonMainPanelButton; CMFCRibbonPanel; CMFCRibbonQuickAccessToolBarDefaultState; - CMFCRibbonStatusBar; CMFCRibbonStatusBarPane; CMFCTabCtrl; CMFCToolBar; CMFCToolBarImages; - CMFCToolBarMenuButton; CMFCToolTipCtrl; CMFCToolTipInfo; CMFCVisualManager; CMFCVisualManagerOffice; - CSplitterWndEx; CTabbedPane; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/RibbonListButton.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/RibbonListButton.cpp deleted file mode 100644 index d0bc00aa9d123..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/RibbonListButton.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "RibbonListButton.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int nImageMargin = 4; -const int nCheckMargin = 2; -const int nTextOffsetX = 11; -const int nTextOffsetY = 2; - -const int nBorderMarginX = 1; -const int nBorderMarginY = 3; - -///////////////////////////////////////////////////////////////////////////// -// CRibbonListButton - -IMPLEMENT_DYNCREATE(CRibbonListButton, CMFCRibbonGallery) - -CRibbonListButton::CRibbonListButton() -{ - m_sizeMargins = CSize(2, 2); -} - -CRibbonListButton::CRibbonListButton(UINT nID, LPCTSTR lpszText, int nSmallImageIndex, int nLargeImageIndex, BOOL bRightAlignedText) : CMFCRibbonGallery(nID, lpszText, nSmallImageIndex, nLargeImageIndex, CSize(0, 0), 0, TRUE) -{ - SetButtonMode(TRUE); - SetRightAlignedText(bRightAlignedText); - - m_sizeMargins = CSize(2, 2); - m_sizeMaxText = CSize(0, 0); -} - -CRibbonListButton::CRibbonListButton(UINT nID, LPCTSTR lpszText, int nSmallImageIndex, int nLargeImageIndex, UINT uiImagesPaletteResID, int cxPaletteImage, const CStringArray& arLabels, BOOL bRightAlignedText) : CMFCRibbonGallery(nID, lpszText, nSmallImageIndex, nLargeImageIndex, CSize(0, 0), 0, TRUE) -{ - SetButtonMode(TRUE); - SetRightAlignedText(bRightAlignedText); - - m_listImages.Load(uiImagesPaletteResID); - - BITMAP bmp; - GetObject(m_listImages.GetImageWell(), sizeof(BITMAP), &bmp); - - m_listImages.SetImageSize(CSize(cxPaletteImage, bmp.bmHeight), TRUE); - m_imagesPalette.SetImageSize(m_listImages.GetImageSize()); - - m_arLabels.Copy(arLabels); - m_nIcons = (int) m_arLabels.GetSize(); - - m_sizeMargins = CSize(2, 2); - m_sizeMaxText = CSize(0, 0); -} - -CRibbonListButton::~CRibbonListButton() -{ -} - -void CRibbonListButton::SetRightAlignedText(BOOL bSet) -{ - if (m_bRightAlignedText != bSet) - { - m_bRightAlignedText = bSet; - - if (m_bRightAlignedText) - { - SetIconsInRow(1); - } - } -} - -void CRibbonListButton::AddGroup(LPCTSTR lpszGroupName, UINT uiImagesPaletteResID, int cxPaletteImage, const CStringArray& arLabels) -{ - CMFCRibbonGallery::AddGroup(lpszGroupName, (int) arLabels.GetSize()); - - if (uiImagesPaletteResID != 0) - { - if (m_listImages.GetCount() == 0) - { - m_listImages.Load(uiImagesPaletteResID); - - BITMAP bmp; - GetObject(m_listImages.GetImageWell(), sizeof(BITMAP), &bmp); - - m_listImages.SetImageSize(CSize(cxPaletteImage, bmp.bmHeight), TRUE); - - m_imagesPalette.SetImageSize(m_listImages.GetImageSize()); - } - else - { - ASSERT(cxPaletteImage == m_listImages.GetImageSize().cx); - m_listImages.Load(uiImagesPaletteResID, NULL, TRUE); - } - } - - if (m_arLabels.GetSize() == 0) - { - m_arLabels.Copy(arLabels); - } - else - { - m_arLabels.Append(arLabels); - } - - m_nIcons = (int) m_arLabels.GetSize(); - - RemoveAll(); - m_sizeMaxText = CSize(0, 0); -} - -void CRibbonListButton::Clear() -{ - CMFCRibbonGallery::Clear(); - - m_arLabels.RemoveAll(); - m_sizeMaxText = CSize(0, 0); -} - -void CRibbonListButton::OnShowPopupMenu() -{ - ASSERT_VALID(this); - - CMFCRibbonBaseElement::OnShowPopupMenu(); - - if (m_sizeMaxText == CSize(0, 0)) - { - CMFCRibbonBar* pRibbonBar = GetTopLevelRibbonBar(); - ASSERT_VALID(pRibbonBar); - - CClientDC dc(pRibbonBar); - - CFont* pOldFont = dc.SelectObject(pRibbonBar->GetFont()); - ASSERT(pOldFont != NULL); - - int i = 0; - - for (i = 0; i < m_arLabels.GetSize(); i++) - { - CSize szText = dc.GetTextExtent(m_arLabels [i]); - - m_sizeMaxText.cx = max(m_sizeMaxText.cx, szText.cx); - m_sizeMaxText.cy = max(m_sizeMaxText.cy, szText.cy); - } - - const int cxImage = m_listImages.GetImageSize().cx; - - for (i = 0; i < m_arSubItems.GetSize(); i++) - { - CMFCRibbonBaseElement* pButton = m_arSubItems [i]; - ASSERT_VALID(pButton); - - CString strText = pButton->GetText(); - CSize szText = dc.GetTextExtent(strText); - - m_sizeMaxText.cx = max(m_sizeMaxText.cx, szText.cx - cxImage); - } - - dc.SelectObject(pOldFont); - } - - CMFCRibbonGallery::OnShowPopupMenu(); -} - -CSize CRibbonListButton::GetIconSize() const -{ - CSize size = CMFCRibbonGallery::GetIconSize(); - - if (m_bRightAlignedText) - { - if (size.cx > 0) - { - size.cx += 2 *(m_sizeMargins.cx + nCheckMargin) - nImageMargin + nTextOffsetX + m_sizeMaxText.cx; - } - else - { - size.cx = m_sizeMaxText.cx + 2 *(m_sizeMargins.cy + nCheckMargin + nTextOffsetX); - } - - if (size.cy > 0) - { - size.cy += 2 *(m_sizeMargins.cy - nImageMargin + nCheckMargin); - } - else - { - size.cy = m_sizeMaxText.cy + 2 * m_sizeMargins.cy; - } - } - else - { - size.cy += nTextOffsetY + m_sizeMaxText.cy; - } - - return size; -} - -void CRibbonListButton::OnDrawPaletteIcon( CDC* pDC, CRect rectIcon, int nIconIndex, CMFCRibbonGalleryIcon* pIcon, COLORREF clrText) -{ - ASSERT_VALID(this); - ASSERT_VALID(pDC); - ASSERT_VALID(pIcon); - ASSERT(nIconIndex >= 0); - ASSERT(nIconIndex < m_nIcons); - - BOOL bChecked = pIcon->IsChecked(); - BOOL bHighlighted = pIcon->IsHighlighted(); - - CRect rectText(0, 0, 0, 0); - - if (m_bRightAlignedText) - { - if (!m_bSmallIcons) - { - rectIcon.DeflateRect(nCheckMargin, nCheckMargin, nImageMargin, nCheckMargin); - } - - CRect rect(rectIcon); - rect.right = rect.left + m_listImages.GetImageSize().cx + m_sizeMargins.cx * 2; - - if (bChecked) - { - CMFCVisualManager::GetInstance()->OnDrawRibbonMenuCheckFrame(pDC, this, rect); - } - - if (0 <= nIconIndex && nIconIndex < m_listImages.GetCount()) - { - m_listImages.DrawEx(pDC, rect, nIconIndex, CMFCToolBarImages::ImageAlignHorzCenter, CMFCToolBarImages::ImageAlignVertCenter); - } - else if (bChecked) - { - CMFCToolBarMenuButton dummy; - CMFCVisualManager::GetInstance()->OnDrawMenuCheck(pDC, &dummy, rect, bHighlighted, FALSE); - } - - rectText = rect; - rectText.left = rectText.right + nTextOffsetX; - rectText.right = rectIcon.right; - } - else - { - if (!m_bSmallIcons) - { - rectIcon.DeflateRect(nImageMargin, nImageMargin); - } - - CRect rect(rectIcon); - rect.bottom = rect.top + m_listImages.GetImageSize().cy; - - if (0 <= nIconIndex && nIconIndex < m_listImages.GetCount()) - { - m_listImages.DrawEx(pDC, rect, nIconIndex, CMFCToolBarImages::ImageAlignHorzCenter, CMFCToolBarImages::ImageAlignVertTop); - } - - rectText = rect; - rectText.top = rectText.bottom + nTextOffsetY; - rectText.bottom = rectIcon.bottom; - } - - if (!rectText.IsRectEmpty()) - { - COLORREF clrOld = (COLORREF)-1; - if (clrText != (COLORREF)-1) - { - clrOld = pDC->SetTextColor(clrText); - } - - CString strText = m_arLabels[nIconIndex]; - - pDC->DrawText(strText, rectText, m_bRightAlignedText - ? DT_VCENTER | DT_SINGLELINE | DT_LEFT - : DT_TOP | DT_SINGLELINE | DT_CENTER | DT_END_ELLIPSIS); - - if (clrText != (COLORREF)-1) - { - pDC->SetTextColor(clrOld); - } - } -} - -void CRibbonListButton::CopyFrom(const CMFCRibbonBaseElement& s) -{ - ASSERT_VALID(this); - - CMFCRibbonGallery::CopyFrom(s); - - CRibbonListButton& src = (CRibbonListButton&) s; - - src.m_listImages.CopyTo(m_listImages); - m_imagesPalette.SetImageSize(m_listImages.GetImageSize()); - - m_arLabels.RemoveAll(); - m_arLabels.Copy(src.m_arLabels); - - m_sizeMargins = src.m_sizeMargins; - m_bRightAlignedText = src.m_bRightAlignedText; - m_sizeMaxText = src.m_sizeMaxText; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/RibbonListButton.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/RibbonListButton.h deleted file mode 100644 index d2b6dc979d867..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/RibbonListButton.h +++ /dev/null @@ -1,51 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CRibbonListButton : public CMFCRibbonGallery -{ - DECLARE_DYNCREATE(CRibbonListButton) - - // Construction: -public: - CRibbonListButton(); - CRibbonListButton(UINT nID, LPCTSTR lpszText, int nSmallImageIndex, int nLargeImageIndex, BOOL bRightAlignedText = TRUE); - CRibbonListButton(UINT nID, LPCTSTR lpszText, int nSmallImageIndex, int nLargeImageIndex, UINT uiImagesPaletteResID, int cxPaletteImage, const CStringArray& arLabels, BOOL bRightAlignedText = TRUE); - - virtual ~CRibbonListButton(); - -public: - void AddGroup(LPCTSTR lpszGroupName, UINT uiImagesPaletteResID, int cxPaletteImage, const CStringArray& arLabels); - - virtual void Clear(); - - void SetRightAlignedText(BOOL bSet = TRUE); - -protected: - virtual CSize GetIconSize() const; - virtual void OnDrawPaletteIcon(CDC* pDC, CRect rectIcon, int nIconIndex, CMFCRibbonGalleryIcon* pIcon, COLORREF clrText); - virtual void CopyFrom(const CMFCRibbonBaseElement& src); - virtual void OnShowPopupMenu(); - - virtual BOOL IsItemMenuLook() const - { - return m_bRightAlignedText; - } - - void RecalcTextSizes(CDC* pDC); - -protected: - CMFCToolBarImages m_listImages; - CStringArray m_arLabels; - CSize m_sizeMargins; - BOOL m_bRightAlignedText; - CSize m_sizeMaxText; -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/Snippets.txt deleted file mode 100644 index 8f5c83f7a83fc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/Snippets.txt +++ /dev/null @@ -1,13 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -CMDIFrameWndEx Class 1 -mainfrm.cpp 2 -mainfrm.cpp 3 -mainfrm.h: CMFCRibbonApplicationButton 4 -mainfrm.cpp: CMFCRibbonApplicationButton 5 -mainfrm.cpp: CMFCRibbonGallery 6 -mainfrm.cpp: CMFCPopupMenuBar 7 -mainfrm.cpp: CMFCRibbonBaseElement 8 -mainfrm.cpp: CMFCRibbonBaseElement 9 -mainfrm.cpp: CMFCCustomizeMenuButton 10 -DrawClient.cpp: CTooltipManager 11 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/cntritem.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/cntritem.cpp deleted file mode 100644 index 93ffdbdf7d6df..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/cntritem.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" - -#include "drawdoc.h" -#include "drawobj.h" -#include "drawvw.h" -#include "cntritem.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDrawItem implementation - -IMPLEMENT_SERIAL(CDrawItem, COleClientItem, 0) - -CDrawItem::CDrawItem(CDrawDoc* pContainer, CDrawOleObj* pDrawObj) -: COleClientItem(pContainer) -{ - m_pDrawObj = pDrawObj; -} - -CDrawItem::~CDrawItem() -{ - if (m_pDrawObj != NULL) - m_pDrawObj->m_pClientItem = NULL; -} - -void CDrawItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam) -{ - ASSERT_VALID(this); - - COleClientItem::OnChange(nCode, dwParam); - - switch (nCode) - { - case OLE_CHANGED_STATE: - case OLE_CHANGED_ASPECT: - m_pDrawObj->Invalidate(); - break; - case OLE_CHANGED: - UpdateExtent(); // extent may have changed - m_pDrawObj->Invalidate(); - break; - } -} - -BOOL CDrawItem::OnChangeItemPosition(const CRect& rectPos) -{ - ASSERT_VALID(this); - - CDrawView* pView = GetActiveView(); - ASSERT_VALID(pView); - CRect rect = rectPos; - pView->ClientToDoc(rect); - - if (rect != m_pDrawObj->m_position) - { - // invalidate old rectangle - m_pDrawObj->Invalidate(); - - // update to new rectangle - m_pDrawObj->m_position = rect; - GetExtent(&m_pDrawObj->m_extent); - - // and invalidate new rectangle - m_pDrawObj->Invalidate(); - - // mark document as dirty - GetDocument()->SetModifiedFlag(); - } - return COleClientItem::OnChangeItemPosition(rectPos); -} - -void CDrawItem::OnGetItemPosition(CRect& rPosition) -{ - ASSERT_VALID(this); - - // update to extent of item if m_position is not initialized - if (m_pDrawObj->m_position.IsRectEmpty()) - UpdateExtent(); - - // copy m_position, which is in document coordinates - CDrawView* pView = GetActiveView(); - ASSERT_VALID(pView); - rPosition = m_pDrawObj->m_position; - pView->DocToClient(rPosition); -} - -void CDrawItem::Serialize(CArchive& ar) -{ - ASSERT_VALID(this); - - // Call base class first to read in COleClientItem data. - // Note: this sets up the m_pDocument pointer returned from - // CDrawItem::GetDocument, therefore it is a good idea - // to call the base class Serialize first. - COleClientItem::Serialize(ar); - - // now store/retrieve data specific to CDrawItem - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -BOOL CDrawItem::UpdateExtent() -{ - CSize size; - if (!GetExtent(&size) || size == m_pDrawObj->m_extent) - return FALSE; // blank - - // if new object(i.e. m_extent is empty) setup position - if (m_pDrawObj->m_extent == CSize(0, 0)) - { - m_pDrawObj->m_position.right = m_pDrawObj->m_position.left + MulDiv(size.cx, 10, 254); - m_pDrawObj->m_position.bottom = m_pDrawObj->m_position.top - MulDiv(size.cy, 10, 254); - } - // else data changed so scale up rect as well - else if (!IsInPlaceActive() && size != m_pDrawObj->m_extent) - { - m_pDrawObj->m_position.right = m_pDrawObj->m_position.left + MulDiv(m_pDrawObj->m_position.Width(), size.cx, m_pDrawObj->m_extent.cx); - m_pDrawObj->m_position.bottom = m_pDrawObj->m_position.top + MulDiv(m_pDrawObj->m_position.Height(), size.cy, m_pDrawObj->m_extent.cy); - } - - m_pDrawObj->m_extent = size; - m_pDrawObj->Invalidate(); // redraw to the new size/position - return TRUE; -} - -void CDrawItem::OnActivate() -{ - // allow only one inplace active item per frame - CView* pView = GetActiveView(); - ASSERT_VALID(pView); - COleClientItem* pItem = GetDocument()->GetInPlaceActiveItem(pView); - if (pItem != NULL && pItem != this) - pItem->Close(); - - COleClientItem::OnActivate(); -} - -void CDrawItem::OnDeactivateUI(BOOL bUndoable) -{ - COleClientItem::OnDeactivateUI(bUndoable); - - // hide the object if it is not an outside-in object - DWORD dwMisc = 0; - m_lpObject->GetMiscStatus(GetDrawAspect(), &dwMisc); - if (dwMisc & OLEMISC_INSIDEOUT) - DoVerb(OLEIVERB_HIDE, NULL); -} - -BOOL CDrawItem::OnShowPanes(CFrameWnd* pFrameWnd, BOOL bShow) -{ - CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, pFrameWnd); - - if (pMainFrame != NULL) - { - ASSERT_VALID(pMainFrame); - return pMainFrame->OnShowPanes(bShow); - } - - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawItem diagnostics - -#ifdef _DEBUG -void CDrawItem::AssertValid() const -{ - COleClientItem::AssertValid(); -} - -void CDrawItem::Dump(CDumpContext& dc) const -{ - COleClientItem::Dump(dc); -} -#endif - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/cntritem.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/cntritem.h deleted file mode 100644 index b86d2c8dded49..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/cntritem.h +++ /dev/null @@ -1,52 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CDrawDoc; -class CDrawView; - -class CDrawItem : public COleClientItem -{ - DECLARE_SERIAL(CDrawItem) - -// Constructors -public: - CDrawItem(CDrawDoc* pContainer = NULL, CDrawOleObj* pDrawObj = NULL); - // Note: pContainer is allowed to be NULL to enable IMPLEMENT_SERIALIZE - // IMPLEMENT_SERIALIZE requires the class have a constructor with - // zero arguments. Normally, OLE items are constructed with a - // non-NULL document pointer. - -// Attributes -public: - CDrawDoc* GetDocument() { return(CDrawDoc*)COleClientItem::GetDocument(); } - CDrawView* GetActiveView() { return(CDrawView*)COleClientItem::GetActiveView(); } - - CDrawOleObj* m_pDrawObj; // back pointer to OLE draw object - -// Operations - BOOL UpdateExtent(); - -// Implementation -public: - ~CDrawItem(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - virtual void Serialize(CArchive& ar); - virtual void OnGetItemPosition(CRect& rPosition); - -protected: - virtual void OnChange(OLE_NOTIFICATION wNotification, DWORD dwParam); - virtual BOOL OnChangeItemPosition(const CRect& rectPos); - virtual void OnDeactivateUI(BOOL bUndoable); - virtual void OnActivate(); - virtual BOOL OnShowPanes(CFrameWnd* pFrameWnd, BOOL bShow); -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawclient.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawclient.vcxproj deleted file mode 100644 index 881cfc8d24beb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawclient.vcxproj +++ /dev/null @@ -1,257 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {96F97F2D-AD12-4EE3-B9D3-807AB38B34E5} - DrawClient - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - true - Win32 - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - Sync - MultiThreadedDebugDLL - true - Use - stdafx.h - Level4 - false - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /SAFESEH%(AdditionalOptions) - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - false - true - X64 - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - Sync - MultiThreadedDebugDLL - Use - stdafx.h - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX64 - - - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - Create - stdafx.h - $(IntDir)$(TargetName).pch - Create - stdafx.h - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - $(IntDir)$(TargetName).pch - $(IntDir)$(TargetName).pch - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawclient.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawclient.vcxproj.filters deleted file mode 100644 index 7533d93af793d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawclient.vcxproj.filters +++ /dev/null @@ -1,191 +0,0 @@ - - - - - {857ad0e0-f021-4848-b91c-71a6d46f29fe} - h;hpp;hxx;inl;fi;fd - - - {c8875ac3-8e82-4799-a32b-b942d320e1ca} - rc;ico;cur;bmp;dlg;rc2;rct;cnt;rtf;gif;jpg;jpeg;jpe - - - {c0e7f22b-e9a0-4829-afc7-d3cfdd7185e6} - cpp;c;cxx;def;r;odl;hpj;bat;for;f90 - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawdoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawdoc.cpp deleted file mode 100644 index 9f65ef408cf83..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawdoc.cpp +++ /dev/null @@ -1,299 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" - -#include "mainfrm.h" -#include "drawdoc.h" -#include "drawvw.h" -#include "drawobj.h" -#include "cntritem.h" -#include "summpage.h" -#include "statpage.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDrawDoc - -IMPLEMENT_DYNCREATE(CDrawDoc, COleDocument) - -BEGIN_MESSAGE_MAP(CDrawDoc, COleDocument) - //{{AFX_MSG_MAP(CDrawDoc) - ON_COMMAND(ID_VIEW_PAPERCOLOR, OnViewPaperColor) - ON_COMMAND(ID_FILE_SUMMARYINFO, OnFileSummaryInfo) - // Enable default OLE container implementation - ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, COleDocument::OnUpdatePasteMenu) - ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE_LINK, COleDocument::OnUpdatePasteLinkMenu) - ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_LINKS, COleDocument::OnUpdateEditLinksMenu) - ON_COMMAND(ID_OLE_EDIT_LINKS, COleDocument::OnEditLinks) - ON_UPDATE_COMMAND_UI(ID_OLE_VERB_FIRST, COleDocument::OnUpdateObjectVerbMenu) - // MAPI support - ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail) - ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL, OnUpdateFileSendMail) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDrawDoc construction/destruction - -CDrawDoc::CDrawDoc() -{ - EnableCompoundFile(); - - m_bCanDeactivateInplace = TRUE; - m_nMapMode = MM_ANISOTROPIC; - m_paperColorLast = m_paperColor = RGB(255, 255, 255); - m_pSummInfo = NULL; - ComputePageSize(); -} - -CDrawDoc::~CDrawDoc() -{ - POSITION pos = m_objects.GetHeadPosition(); - while (pos != NULL) - delete m_objects.GetNext(pos); - delete m_pSummInfo; -} - -BOOL CDrawDoc::OnNewDocument() -{ - if (!COleDocument::OnNewDocument()) - return FALSE; - - // reinitialization code - //(SDI documents will reuse this document) - if (m_pSummInfo != NULL) - delete m_pSummInfo; - m_pSummInfo = new CSummInfo; - // Title, Subject, Author, Keywords default to empty string - // Comments, Template, SavedBy default to empty string - // LastSave, LastPrint, EditTime, RevNum default to 0 - m_pSummInfo->StartEditTimeCount(); - m_pSummInfo->RecordCreateDate(); - m_pSummInfo->SetNumPages(1); - // NumWords, NumChars default to 0 - m_pSummInfo->SetAppname( _T("DrawCli") ); - // Security defaults to 0 - return TRUE; -} - -BOOL CDrawDoc::OnOpenDocument(LPCTSTR lpszPathName) -{ - if ( m_pSummInfo != NULL) - delete m_pSummInfo; - m_pSummInfo = new CSummInfo; - m_pSummInfo->StartEditTimeCount(); - return COleDocument::OnOpenDocument(lpszPathName); -} - -BOOL CDrawDoc::OnSaveDocument(LPCTSTR lpszPathName) -{ - m_pSummInfo->RecordSaveDate(); - m_pSummInfo->IncrRevNum(); - m_pSummInfo->SetLastAuthor(m_pSummInfo->GetAuthor()); - m_pSummInfo->AddCountToEditTime(); - m_pSummInfo->StartEditTimeCount(); - return COleDocument::OnSaveDocument(lpszPathName); -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawDoc serialization - -void CDrawDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - ar << m_paperColor; - m_objects.Serialize(ar); - m_pSummInfo->WriteToStorage(m_lpRootStg); - } - else - { - ar >> m_paperColor; - m_paperColorLast = m_paperColor; - m_objects.Serialize(ar); - m_pSummInfo->ReadFromStorage(m_lpRootStg); - } - - // By calling the base class COleDocument, we enable serialization - // of the container document's COleClientItem objects automatically. - COleDocument::Serialize(ar); -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawDoc implementation - -void CDrawDoc::Draw(CDC* pDC, CDrawView* pView) -{ - POSITION pos = m_objects.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_objects.GetNext(pos); - pObj->Draw(pDC); - if (pView->m_bActive && !pDC->IsPrinting() && pView->IsSelected(pObj)) - pObj->DrawTracker(pDC, CDrawObj::selected); - } -} - -void CDrawDoc::Add(CDrawObj* pObj) -{ - m_objects.AddTail(pObj); - pObj->m_pDocument = this; - SetModifiedFlag(); -} - -void CDrawDoc::Remove(CDrawObj* pObj) -{ - // Find and remove from document - POSITION pos = m_objects.Find(pObj); - if (pos != NULL) - m_objects.RemoveAt(pos); - // set document modified flag - SetModifiedFlag(); - - // call remove for each view so that the view can remove from m_selection - pos = GetFirstViewPosition(); - while (pos != NULL) - ((CDrawView*)GetNextView(pos))->Remove(pObj); -} - -// point is in logical coordinates -CDrawObj* CDrawDoc::ObjectAt(const CPoint& point) -{ - CRect rect(point, CSize(1, 1)); - POSITION pos = m_objects.GetTailPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_objects.GetPrev(pos); - if (pObj->Intersects(rect)) - return pObj; - } - - return NULL; -} - -void CDrawDoc::ComputePageSize() -{ - CSize new_size(850, 1100); // 8.5" x 11" default - - CPrintDialog dlg(FALSE); - if (AfxGetApp()->GetPrinterDeviceDefaults(&dlg.m_pd)) - { - // GetPrinterDC returns a HDC so attach it - CDC dc; - HDC hDC= dlg.CreatePrinterDC(); - ASSERT(hDC != NULL); - dc.Attach(hDC); - - // Get the size of the page in loenglish - new_size.cx = MulDiv(dc.GetDeviceCaps(HORZSIZE), 1000, 254); - new_size.cy = MulDiv(dc.GetDeviceCaps(VERTSIZE), 1000, 254); - } - - // if size changed then iterate over views and reset - if (new_size != m_size) - { - m_size = new_size; - POSITION pos = GetFirstViewPosition(); - while (pos != NULL) - ((CDrawView*)GetNextView(pos))->SetPageSize(m_size); - } -} - -void CDrawDoc::OnViewPaperColor() -{ - COLORREF color = ((CMainFrame*)AfxGetMainWnd())->GetColorFromColorButton(ID_VIEW_PAPERCOLOR); - m_paperColor = color == (COLORREF) -1 ? RGB(255, 255, 255) : color; - m_paperColorLast = m_paperColor; - - SetModifiedFlag(); - UpdateAllViews(NULL); -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawDoc diagnostics - -#ifdef _DEBUG -void CDrawDoc::AssertValid() const -{ - COleDocument::AssertValid(); -} - -void CDrawDoc::Dump(CDumpContext& dc) const -{ - COleDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CDrawDoc commands - -void CDrawDoc::OnFileSummaryInfo() -{ - ASSERT_VALID(this); - - CPropertySheet sheet( _T("Document Properties") ); - CSummPage summ; - CStatPage stat; - sheet.AddPage( &summ ); - sheet.AddPage( &stat ); - - summ.m_strAppname = m_pSummInfo->GetAppname(); - summ.m_strTitle = m_pSummInfo->GetTitle(); - summ.m_strSubj = m_pSummInfo->GetSubject(); - summ.m_strAuthor = m_pSummInfo->GetAuthor(); - summ.m_strKeywd = m_pSummInfo->GetKeywords(); - summ.m_strCmt = m_pSummInfo->GetComments(); - summ.m_strTempl = m_pSummInfo->GetTemplate(); - - stat.m_strSavedBy = m_pSummInfo->GetLastAuthor(); - stat.m_strRevNum = m_pSummInfo->GetRevNum(); - stat.m_strEditTime = m_pSummInfo->GetEditTime(); - stat.m_strLastPrint = m_pSummInfo->GetLastPrintDate(); - stat.m_strCreateDate = m_pSummInfo->GetCreateDate(); - stat.m_strLastSave = m_pSummInfo->GetLastSaveDate(); - stat.m_strNumPages = m_pSummInfo->GetNumPages(); - stat.m_strNumWords = m_pSummInfo->GetNumWords(); - stat.m_strNumChars = m_pSummInfo->GetNumChars(); - stat.m_strSecurity = m_pSummInfo->GetSecurity(); - - if (sheet.DoModal() != IDOK) - return; - - m_pSummInfo->SetAuthor(summ.m_strAuthor); - m_pSummInfo->SetKeywords(summ.m_strKeywd); - m_pSummInfo->SetSubject(summ.m_strSubj); - m_pSummInfo->SetComments(summ.m_strCmt); - m_pSummInfo->SetTemplate(summ.m_strTempl); - m_pSummInfo->SetTitle(summ.m_strTitle); - - SetModifiedFlag(); -} - -void CDrawDoc::SetPreviewColor(COLORREF clr) -{ - m_paperColor = clr == -1 ? m_paperColorLast : clr; - UpdateAllViews(NULL); -} - -BOOL CDrawDoc::CanCloseFrame(CFrameWnd* pFrame) -{ - m_bCanDeactivateInplace = FALSE; - - BOOL bRes = COleDocument::CanCloseFrame(pFrame); - - m_bCanDeactivateInplace = TRUE; - - return bRes; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawdoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawdoc.h deleted file mode 100644 index 727be4af068a0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawdoc.h +++ /dev/null @@ -1,73 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "drawobj.h" -#include "summinfo.h" - -class CDrawView; - -class CDrawDoc : public COleDocument -{ -protected: // create from serialization only - CDrawDoc(); - DECLARE_DYNCREATE(CDrawDoc) - -// Attributes -public: - CDrawObjList* GetObjects() { return &m_objects; } - const CSize& GetSize() const { return m_size; } - void ComputePageSize(); - int GetMapMode() const { return m_nMapMode; } - COLORREF GetPaperColor() const { return m_paperColor; } - CSummInfo *m_pSummInfo; - - BOOL CanDeactivateInplace() const - { - return m_bCanDeactivateInplace; - } - -// Operations -public: - CDrawObj* ObjectAt(const CPoint& point); - void Draw(CDC* pDC, CDrawView* pView); - void Add(CDrawObj* pObj); - void Remove(CDrawObj* pObj); - - void SetPreviewColor(COLORREF clr); - -// Implementation -public: - virtual ~CDrawDoc(); - virtual void Serialize(CArchive& ar); // overridden for document i/o -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - virtual BOOL OnNewDocument(); - virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); - virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); - virtual BOOL CanCloseFrame(CFrameWnd* pFrame); - - BOOL m_bCanDeactivateInplace; - - CDrawObjList m_objects; - CSize m_size; - int m_nMapMode; - COLORREF m_paperColor; - COLORREF m_paperColorLast; - -protected: - //{{AFX_MSG(CDrawDoc) - afx_msg void OnViewPaperColor(); - afx_msg void OnFileSummaryInfo(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawobj.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawobj.cpp deleted file mode 100644 index 6f46ebed89d22..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawobj.cpp +++ /dev/null @@ -1,1160 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" - -#include "drawdoc.h" -#include "drawvw.h" -#include "drawobj.h" - -#include "cntritem.h" -#include "rectdlg.h" - -IMPLEMENT_SERIAL(CDrawObj, CObject, 0) - -CDrawObj::CDrawObj() -{ -} - -CDrawObj::~CDrawObj() -{ -} - -CDrawObj::CDrawObj(const CRect& position) -{ - m_position = position; - m_pDocument = NULL; - - m_bPen = TRUE; - m_logpen.lopnStyle = PS_INSIDEFRAME; - m_logpen.lopnWidth.x = 1; - m_logpen.lopnWidth.y = 1; - m_logpen.lopnColor = RGB(0, 0, 0); - - m_bBrush = TRUE; - m_logbrush.lbStyle = BS_SOLID; - m_logbrush.lbColor = RGB(192, 192, 192); - m_logbrush.lbHatch = HS_HORIZONTAL; -} - -void CDrawObj::Serialize(CArchive& ar) -{ - CObject::Serialize(ar); - if (ar.IsStoring()) - { - ar << m_position; - ar <<(WORD)m_bPen; - ar.Write(&m_logpen, sizeof(LOGPEN)); - ar <<(WORD)m_bBrush; - ar.Write(&m_logbrush, sizeof(LOGBRUSH)); - } - else - { - // get the document back pointer from the archive - m_pDocument = (CDrawDoc*)ar.m_pDocument; - ASSERT_VALID(m_pDocument); - ASSERT_KINDOF(CDrawDoc, m_pDocument); - - WORD wTemp; - ar >> m_position; - ar >> wTemp; m_bPen = (BOOL)wTemp; - ar.Read(&m_logpen,sizeof(LOGPEN)); - ar >> wTemp; m_bBrush = (BOOL)wTemp; - ar.Read(&m_logbrush, sizeof(LOGBRUSH)); - } -} - -void CDrawObj::Remove() -{ - delete this; -} - -void CDrawObj::Draw(CDC*) -{ -} - -void CDrawObj::DrawTracker(CDC* pDC, TrackerState state) -{ - ASSERT_VALID(this); - - switch (state) - { - case normal: - break; - - case selected: - case active: - { - int nHandleCount = GetHandleCount(); - for (int nHandle = 1; nHandle <= nHandleCount; nHandle += 1) - { - CPoint handle = GetHandle(nHandle); - pDC->PatBlt(handle.x - 3, handle.y - 3, 7, 7, DSTINVERT); - } - } - break; - } -} - -// position is in logical -void CDrawObj::MoveTo(const CRect& position, CDrawView* pView) -{ - ASSERT_VALID(this); - - if (position == m_position) - return; - - if (pView == NULL) - { - Invalidate(); - m_position = position; - Invalidate(); - } - else - { - pView->InvalObj(this); - m_position = position; - pView->InvalObj(this); - } - m_pDocument->SetModifiedFlag(); -} - -// Note: if bSelected, hit-codes start at one for the top-left -// and increment clockwise, 0 means no hit. -// If !bSelected, 0 = no hit, 1 = hit(anywhere) - -// point is in logical coordinates -int CDrawObj::HitTest(CPoint point, CDrawView* pView, BOOL bSelected) -{ - ASSERT_VALID(this); - ASSERT(pView != NULL); - - if (bSelected) - { - int nHandleCount = GetHandleCount(); - for (int nHandle = 1; nHandle <= nHandleCount; nHandle += 1) - { - // GetHandleRect returns in logical coords - CRect rc = GetHandleRect(nHandle,pView); - if (point.x >= rc.left && point.x < rc.right && point.y <= rc.top && point.y > rc.bottom) - return nHandle; - } - } - else - { - if (point.x >= m_position.left && point.x < m_position.right && point.y <= m_position.top && point.y > m_position.bottom) - return 1; - } - return 0; -} - -// rect must be in logical coordinates -BOOL CDrawObj::Intersects(const CRect& rect) -{ - ASSERT_VALID(this); - - CRect fixed = m_position; - fixed.NormalizeRect(); - CRect rectT = rect; - rectT.NormalizeRect(); - return !(rectT & fixed).IsRectEmpty(); -} - -int CDrawObj::GetHandleCount() -{ - ASSERT_VALID(this); - return 8; -} - -// returns logical coords of center of handle -CPoint CDrawObj::GetHandle(int nHandle) -{ - ASSERT_VALID(this); - int x, y, xCenter, yCenter; - - // this gets the center regardless of left/right and top/bottom ordering - xCenter = m_position.left + m_position.Width() / 2; - yCenter = m_position.top + m_position.Height() / 2; - - switch (nHandle) - { - default: - ASSERT(FALSE); - - case 1: - x = m_position.left; - y = m_position.top; - break; - - case 2: - x = xCenter; - y = m_position.top; - break; - - case 3: - x = m_position.right; - y = m_position.top; - break; - - case 4: - x = m_position.right; - y = yCenter; - break; - - case 5: - x = m_position.right; - y = m_position.bottom; - break; - - case 6: - x = xCenter; - y = m_position.bottom; - break; - - case 7: - x = m_position.left; - y = m_position.bottom; - break; - - case 8: - x = m_position.left; - y = yCenter; - break; - } - - return CPoint(x, y); -} - -// return rectange of handle in logical coords -CRect CDrawObj::GetHandleRect(int nHandleID, CDrawView* pView) -{ - ASSERT_VALID(this); - ENSURE(pView != NULL); - - CRect rect; - // get the center of the handle in logical coords - CPoint point = GetHandle(nHandleID); - // convert to client/device coords - pView->DocToClient(point); - // return CRect of handle in device coords - rect.SetRect(point.x-3, point.y-3, point.x+3, point.y+3); - pView->ClientToDoc(rect); - - return rect; -} - -HCURSOR CDrawObj::GetHandleCursor(int nHandle) -{ - ASSERT_VALID(this); - - LPCTSTR id; - switch (nHandle) - { - default: - ASSERT(FALSE); - - case 1: - case 5: - id = IDC_SIZENWSE; - break; - - case 2: - case 6: - id = IDC_SIZENS; - break; - - case 3: - case 7: - id = IDC_SIZENESW; - break; - - case 4: - case 8: - id = IDC_SIZEWE; - break; - } - - return AfxGetApp()->LoadStandardCursor(id); -} - -// point must be in logical -void CDrawObj::MoveHandleTo(int nHandle, CPoint point, CDrawView* pView) -{ - ASSERT_VALID(this); - - CRect position = m_position; - switch (nHandle) - { - default: - ASSERT(FALSE); - - case 1: - position.left = point.x; - position.top = point.y; - break; - - case 2: - position.top = point.y; - break; - - case 3: - position.right = point.x; - position.top = point.y; - break; - - case 4: - position.right = point.x; - break; - - case 5: - position.right = point.x; - position.bottom = point.y; - break; - - case 6: - position.bottom = point.y; - break; - - case 7: - position.left = point.x; - position.bottom = point.y; - break; - - case 8: - position.left = point.x; - break; - } - - MoveTo(position, pView); -} - -void CDrawObj::Invalidate() -{ - ASSERT_VALID(this); - m_pDocument->UpdateAllViews(NULL, HINT_UPDATE_DRAWOBJ, this); -} - -CDrawObj* CDrawObj::Clone(CDrawDoc* pDoc) -{ - ASSERT_VALID(this); - - CDrawObj* pClone = new CDrawObj(m_position); - pClone->m_bPen = m_bPen; - pClone->m_logpen = m_logpen; - pClone->m_bBrush = m_bBrush; - pClone->m_logbrush = m_logbrush; - ASSERT_VALID(pClone); - - if (pDoc != NULL) - pDoc->Add(pClone); - - return pClone; -} - -void CDrawObj::OnEditProperties() -{ - ASSERT_VALID(this); - - CPropertySheet sheet( _T("Shape Properties") ); - CRectDlg dlg; - dlg.m_bNoFill = !m_bBrush; - dlg.m_penSize = m_bPen ? m_logpen.lopnWidth.x : 0; - sheet.AddPage( &dlg ); - - if (sheet.DoModal() != IDOK) - return; - - m_bBrush = !dlg.m_bNoFill; - m_bPen = dlg.m_penSize > 0; - if (m_bPen) - { - m_logpen.lopnWidth.x = dlg.m_penSize; - m_logpen.lopnWidth.y = dlg.m_penSize; - } - - Invalidate(); - m_pDocument->SetModifiedFlag(); -} - -void CDrawObj::OnOpen(CDrawView* /*pView*/ ) -{ - OnEditProperties(); -} - -void CDrawObj::SetLineColor(COLORREF color, BOOL bPreview) -{ - ASSERT_VALID(this); - - m_logpen.lopnColor = color; - - Invalidate(); - - if (!bPreview) - { - m_pDocument->SetModifiedFlag(); - } -} - -void CDrawObj::SetFillColor(COLORREF color, BOOL bPreview) -{ - ASSERT_VALID(this); - - m_logbrush.lbColor = color; - - Invalidate(); - - if (!bPreview) - { - m_pDocument->SetModifiedFlag(); - } -} - -void CDrawObj::SetLineWeight(int nWidth, BOOL bPreview) -{ - ASSERT_VALID(this); - - if (m_bPen) - { - m_bPen = nWidth > 0; - } - - if (m_bPen) - { - m_logpen.lopnWidth.x = nWidth; - m_logpen.lopnWidth.y = nWidth; - } - - Invalidate(); - - if (!bPreview) - { - m_pDocument->SetModifiedFlag(); - } -} - -void CDrawObj::EnableFill(BOOL bEnable, BOOL bPreview/* = FALSE*/) -{ - m_bBrush = bEnable; - if (!bPreview) - { - m_pDocument->SetModifiedFlag(); - } -} - -void CDrawObj::EnableLine(BOOL bEnable, BOOL bPreview/* = FALSE*/) -{ - m_bPen = bEnable; - if (!bPreview) - { - m_pDocument->SetModifiedFlag(); - } -} - -#ifdef _DEBUG -void CDrawObj::AssertValid() -{ - ASSERT(m_position.left <= m_position.right); - ASSERT(m_position.bottom <= m_position.top); -} -#endif - -//////////////////////////////////////////////////////////////////////////// -// CDrawRect - -IMPLEMENT_SERIAL(CDrawRect, CDrawObj, 0) - -CDrawRect::CDrawRect() -{ -} - -CDrawRect::CDrawRect(const CRect& position) -: CDrawObj(position) -{ - ASSERT_VALID(this); - - m_nShape = rectangle; - m_roundness.x = 16; - m_roundness.y = 16; -} - -void CDrawRect::Serialize(CArchive& ar) -{ - ASSERT_VALID(this); - - CDrawObj::Serialize(ar); - if (ar.IsStoring()) - { - ar <<(WORD) m_nShape; - ar << m_roundness; - } - else - { - WORD wTemp; - ar >> wTemp; m_nShape = (Shape)wTemp; - ar >> m_roundness; - } -} - -void CDrawRect::Draw(CDC* pDC) -{ - ASSERT_VALID(this); - - CBrush brush; - if (!brush.CreateBrushIndirect(&m_logbrush)) - return; - CPen pen; - if (!pen.CreatePenIndirect(&m_logpen)) - return; - - CBrush* pOldBrush; - CPen* pOldPen; - - if (m_bBrush) - pOldBrush = pDC->SelectObject(&brush); - else - pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH); - - if (m_bPen) - pOldPen = pDC->SelectObject(&pen); - else - pOldPen = (CPen*)pDC->SelectStockObject(NULL_PEN); - - CRect rect = m_position; - switch (m_nShape) - { - case rectangle: - pDC->Rectangle(rect); - break; - - case roundRectangle: - pDC->RoundRect(rect, m_roundness); - break; - - case ellipse: - pDC->Ellipse(rect); - break; - - case line: - if (rect.top > rect.bottom) - { - rect.top -= m_logpen.lopnWidth.y / 2; - rect.bottom += (m_logpen.lopnWidth.y + 1) / 2; - } - else - { - rect.top += (m_logpen.lopnWidth.y + 1) / 2; - rect.bottom -= m_logpen.lopnWidth.y / 2; - } - - if (rect.left > rect.right) - { - rect.left -= m_logpen.lopnWidth.x / 2; - rect.right += (m_logpen.lopnWidth.x + 1) / 2; - } - else - { - rect.left += (m_logpen.lopnWidth.x + 1) / 2; - rect.right -= m_logpen.lopnWidth.x / 2; - } - - pDC->MoveTo(rect.TopLeft()); - pDC->LineTo(rect.BottomRight()); - break; - } - - pDC->SelectObject(pOldBrush); - pDC->SelectObject(pOldPen); -} - -int CDrawRect::GetHandleCount() -{ - ASSERT_VALID(this); - - return m_nShape == line ? 2 : CDrawObj::GetHandleCount() +(m_nShape == roundRectangle); -} - -// returns center of handle in logical coordinates -CPoint CDrawRect::GetHandle(int nHandle) -{ - ASSERT_VALID(this); - - if (m_nShape == line && nHandle == 2) - nHandle = 5; - else if (m_nShape == roundRectangle && nHandle == 9) - { - CRect rect = m_position; - rect.NormalizeRect(); - CPoint point = rect.BottomRight(); - point.x -= m_roundness.x / 2; - point.y -= m_roundness.y / 2; - return point; - } - - return CDrawObj::GetHandle(nHandle); -} - -HCURSOR CDrawRect::GetHandleCursor(int nHandle) -{ - ASSERT_VALID(this); - - if (m_nShape == line && nHandle == 2) - nHandle = 5; - else if (m_nShape == roundRectangle && nHandle == 9) - return AfxGetApp()->LoadStandardCursor(IDC_SIZEALL); - return CDrawObj::GetHandleCursor(nHandle); -} - -// point is in logical coordinates -void CDrawRect::MoveHandleTo(int nHandle, CPoint point, CDrawView* pView) -{ - ASSERT_VALID(this); - - if (m_nShape == line && nHandle == 2) - nHandle = 5; - else if (m_nShape == roundRectangle && nHandle == 9) - { - CRect rect = m_position; - rect.NormalizeRect(); - if (point.x > rect.right - 1) - point.x = rect.right - 1; - else if (point.x < rect.left + rect.Width() / 2) - point.x = rect.left + rect.Width() / 2; - if (point.y > rect.bottom - 1) - point.y = rect.bottom - 1; - else if (point.y < rect.top + rect.Height() / 2) - point.y = rect.top + rect.Height() / 2; - m_roundness.x = 2 *(rect.right - point.x); - m_roundness.y = 2 *(rect.bottom - point.y); - m_pDocument->SetModifiedFlag(); - if (pView == NULL) - Invalidate(); - else - pView->InvalObj(this); - return; - } - - CDrawObj::MoveHandleTo(nHandle, point, pView); -} - -// rect must be in logical coordinates -BOOL CDrawRect::Intersects(const CRect& rect) -{ - ASSERT_VALID(this); - - CRect rectT = rect; - rectT.NormalizeRect(); - - CRect fixed = m_position; - fixed.NormalizeRect(); - if ((rectT & fixed).IsRectEmpty()) - return FALSE; - - CRgn rgn; - switch (m_nShape) - { - case rectangle: - return TRUE; - - case roundRectangle: - rgn.CreateRoundRectRgn(fixed.left, fixed.top, fixed.right, fixed.bottom, m_roundness.x, m_roundness.y); - break; - - case ellipse: - rgn.CreateEllipticRgnIndirect(fixed); - break; - - case line: - { - int x = (m_logpen.lopnWidth.x + 5) / 2; - int y = (m_logpen.lopnWidth.y + 5) / 2; - POINT points[4]; - points[0].x = fixed.left; - points[0].y = fixed.top; - points[1].x = fixed.left; - points[1].y = fixed.top; - points[2].x = fixed.right; - points[2].y = fixed.bottom; - points[3].x = fixed.right; - points[3].y = fixed.bottom; - - if (fixed.left < fixed.right) - { - points[0].x -= x; - points[1].x += x; - points[2].x += x; - points[3].x -= x; - } - else - { - points[0].x += x; - points[1].x -= x; - points[2].x -= x; - points[3].x += x; - } - - if (fixed.top < fixed.bottom) - { - points[0].y -= y; - points[1].y += y; - points[2].y += y; - points[3].y -= y; - } - else - { - points[0].y += y; - points[1].y -= y; - points[2].y -= y; - points[3].y += y; - } - rgn.CreatePolygonRgn(points, 4, ALTERNATE); - } - break; - } - return rgn.RectInRegion(fixed); -} - -CDrawObj* CDrawRect::Clone(CDrawDoc* pDoc) -{ - ASSERT_VALID(this); - - CDrawRect* pClone = new CDrawRect(m_position); - pClone->m_bPen = m_bPen; - pClone->m_logpen = m_logpen; - pClone->m_bBrush = m_bBrush; - pClone->m_logbrush = m_logbrush; - pClone->m_nShape = m_nShape; - pClone->m_roundness = m_roundness; - ASSERT_VALID(pClone); - - if (pDoc != NULL) - pDoc->Add(pClone); - - ASSERT_VALID(pClone); - return pClone; -} - -//////////////////////////////////////////////////////////////////////////// -// CDrawPoly - -IMPLEMENT_SERIAL(CDrawPoly, CDrawObj, 0) - -CDrawPoly::CDrawPoly() -{ - m_points = NULL; - m_nPoints = 0; - m_nAllocPoints = 0; -} - -CDrawPoly::CDrawPoly(const CRect& position) -: CDrawObj(position) -{ - m_points = NULL; - m_nPoints = 0; - m_nAllocPoints = 0; - - m_bPen = TRUE; - m_bBrush = FALSE; -} - -CDrawPoly::~CDrawPoly() -{ - if (m_points != NULL) - delete[] m_points; -} - -void CDrawPoly::Serialize( CArchive& ar ) -{ - int i; - CDrawObj::Serialize( ar ); - if ( ar.IsStoring() ) - { - ar <<(WORD) m_nPoints; - ar <<(WORD) m_nAllocPoints; - for (i = 0;i< m_nPoints; i++) - ar << m_points[i]; - } - else - { - WORD wTemp; - ar >> wTemp; m_nPoints = wTemp; - ar >> wTemp; m_nAllocPoints = wTemp; - m_points = new CPoint[m_nAllocPoints]; - for (i = 0;i < m_nPoints; i++) - ar >> m_points[i]; - } -} - -void CDrawPoly::Draw(CDC* pDC) -{ - ASSERT_VALID(this); - - CBrush brush; - if (!brush.CreateBrushIndirect(&m_logbrush)) - return; - CPen pen; - if (!pen.CreatePenIndirect(&m_logpen)) - return; - - CBrush* pOldBrush; - CPen* pOldPen; - - if (m_bBrush) - pOldBrush = pDC->SelectObject(&brush); - else - pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH); - - if (m_bPen) - pOldPen = pDC->SelectObject(&pen); - else - pOldPen = (CPen*)pDC->SelectStockObject(NULL_PEN); - - pDC->Polygon(m_points, m_nPoints); - - pDC->SelectObject(pOldBrush); - pDC->SelectObject(pOldPen); -} - -// position must be in logical coordinates -void CDrawPoly::MoveTo(const CRect& position, CDrawView* pView) -{ - ASSERT_VALID(this); - if (position == m_position) - return; - - if (pView == NULL) - Invalidate(); - else - pView->InvalObj(this); - - for (int i = 0; i < m_nPoints; i += 1) - { - m_points[i].x += position.left - m_position.left; - m_points[i].y += position.top - m_position.top; - } - - m_position = position; - - if (pView == NULL) - Invalidate(); - else - pView->InvalObj(this); - m_pDocument->SetModifiedFlag(); -} - -int CDrawPoly::GetHandleCount() -{ - return m_nPoints; -} - -CPoint CDrawPoly::GetHandle(int nHandle) -{ - ASSERT_VALID(this); - - ASSERT(nHandle >= 1 && nHandle <= m_nPoints); - return m_points[nHandle - 1]; -} - -HCURSOR CDrawPoly::GetHandleCursor(int ) -{ - return AfxGetApp()->LoadStandardCursor(IDC_ARROW); -} - -// point is in logical coordinates -void CDrawPoly::MoveHandleTo(int nHandle, CPoint point, CDrawView* pView) -{ - ASSERT_VALID(this); - ASSERT(nHandle >= 1 && nHandle <= m_nPoints); - if (m_points[nHandle - 1] == point) - return; - - m_points[nHandle - 1] = point; - RecalcBounds(pView); - - if (pView == NULL) - Invalidate(); - else - pView->InvalObj(this); - m_pDocument->SetModifiedFlag(); -} - -// rect must be in logical coordinates -BOOL CDrawPoly::Intersects(const CRect& rect) -{ - ASSERT_VALID(this); - CRgn rgn; - rgn.CreatePolygonRgn(m_points, m_nPoints, ALTERNATE); - return rgn.RectInRegion(rect); -} - -CDrawObj* CDrawPoly::Clone(CDrawDoc* pDoc) -{ - ASSERT_VALID(this); - -#pragma warning(suppress:6211) - CDrawPoly* pClone = new CDrawPoly(m_position); - pClone->m_bPen = m_bPen; - pClone->m_logpen = m_logpen; - pClone->m_bBrush = m_bBrush; - pClone->m_logbrush = m_logbrush; - pClone->m_points = new CPoint[m_nAllocPoints]; - - memcpy_s(pClone->m_points, sizeof(CPoint) * m_nAllocPoints, m_points, sizeof(CPoint) * m_nPoints); - - pClone->m_nAllocPoints = m_nAllocPoints; - pClone->m_nPoints = m_nPoints; - ASSERT_VALID(pClone); - - if (pDoc != NULL) - pDoc->Add(pClone); - - ASSERT_VALID(pClone); - return pClone; -} - -// point is in logical coordinates -void CDrawPoly::AddPoint(const CPoint& point, CDrawView* pView) -{ - ASSERT_VALID(this); - if (m_nPoints == m_nAllocPoints) - { - CPoint* newPoints = new CPoint[m_nAllocPoints + 10]; - if (m_points != NULL) - { - memcpy_s(newPoints, sizeof(CPoint) *(m_nAllocPoints + 10), m_points, sizeof(CPoint) * m_nAllocPoints); - delete[] m_points; - } - m_points = newPoints; - m_nAllocPoints += 10; - } - - if (m_nPoints == 0 || m_points[m_nPoints - 1] != point) - { - m_points[m_nPoints++] = point; - if (!RecalcBounds(pView)) - { - if (pView == NULL) - Invalidate(); - else - pView->InvalObj(this); - } - m_pDocument->SetModifiedFlag(); - } -} - -BOOL CDrawPoly::RecalcBounds(CDrawView* pView) -{ - ASSERT_VALID(this); - - if (m_nPoints == 0) - return FALSE; - - CRect bounds(m_points[0], CSize(0, 0)); - for (int i = 1; i < m_nPoints; ++i) - { - if (m_points[i].x < bounds.left) - bounds.left = m_points[i].x; - if (m_points[i].x > bounds.right) - bounds.right = m_points[i].x; - if (m_points[i].y < bounds.top) - bounds.top = m_points[i].y; - if (m_points[i].y > bounds.bottom) - bounds.bottom = m_points[i].y; - } - - if (bounds == m_position) - return FALSE; - - if (pView == NULL) - Invalidate(); - else - pView->InvalObj(this); - - m_position = bounds; - - if (pView == NULL) - Invalidate(); - else - pView->InvalObj(this); - - return TRUE; -} - -//////////////////////////////////////////////////////////////////////////// - -IMPLEMENT_SERIAL(CDrawOleObj, CDrawObj, 0) - -BOOL CDrawOleObj::c_bShowItems = TRUE; - -CDrawOleObj::CDrawOleObj() : m_extent(0,0) -{ - m_pClientItem = NULL; -} - -CDrawOleObj::CDrawOleObj(const CRect& position) -: CDrawObj(position), m_extent(0, 0) -{ - m_pClientItem = NULL; -} - -CDrawOleObj::~CDrawOleObj() -{ - if (m_pClientItem != NULL) - { - m_pClientItem->Release(); - m_pClientItem = NULL; - } -} - -void CDrawOleObj::Remove() -{ - if (m_pClientItem != NULL) - { - m_pClientItem->Delete(); - m_pClientItem = NULL; - } - CDrawObj::Remove(); -} - -void CDrawOleObj::Serialize( CArchive& ar ) -{ - ASSERT_VALID(this); - - CDrawObj::Serialize(ar); - - if (ar.IsStoring()) - { - ar << m_extent; - ar << m_pClientItem; - } - else - { - ar >> m_extent; - ar >> m_pClientItem; - m_pClientItem->m_pDrawObj = this; - } -} - -CDrawObj* CDrawOleObj::Clone(CDrawDoc* pDoc) -{ - ASSERT_VALID(this); - - AfxGetApp()->BeginWaitCursor(); - - CDrawOleObj* pClone = NULL; - CDrawItem* pItem = NULL; - TRY - { - // perform a "deep copy" -- need to copy CDrawOleObj and the CDrawItem - // that it points to. - pClone = new CDrawOleObj(m_position); -#pragma warning(suppress:6014) - pItem = new CDrawItem(m_pDocument, pClone); - if (!pItem->CreateCloneFrom(m_pClientItem)) - { - AfxThrowMemoryException(); - } - - pClone->m_pClientItem = pItem; - pClone->m_bPen = m_bPen; - pClone->m_logpen = m_logpen; - pClone->m_bBrush = m_bBrush; - pClone->m_logbrush = m_logbrush; - ASSERT_VALID(pClone); - - if (pDoc != NULL) - pDoc->Add(pClone); - } - CATCH_ALL(e) - { - if (pItem) - pItem->Delete(); - - if (pClone) - { - pClone->m_pClientItem = NULL; - pClone->Remove(); - } - AfxGetApp()->EndWaitCursor(); - - THROW_LAST(); - } - END_CATCH_ALL - - AfxGetApp()->EndWaitCursor(); - return pClone; -} - -void CDrawOleObj::Draw(CDC* pDC) -{ - ASSERT_VALID(this); - - CDrawItem* pItem = m_pClientItem; - if (pItem != NULL) - { - // draw the OLE item itself - pItem->Draw(pDC, m_position); - - // don't draw tracker in print preview or on printer - if (!pDC->IsPrinting()) - { - // use a CRectTracker to draw the standard effects - CRectTracker tracker; - tracker.m_rect = m_position; - pDC->LPtoDP(tracker.m_rect); - - if (c_bShowItems) - { - // put correct border depending on item type - if (pItem->GetType() == OT_LINK) - tracker.m_nStyle |= CRectTracker::dottedLine; - else - tracker.m_nStyle |= CRectTracker::solidLine; - } - - // put hatching over the item if it is currently open - if (pItem->GetItemState() == COleClientItem::openState || pItem->GetItemState() == COleClientItem::activeUIState) - { - tracker.m_nStyle |= CRectTracker::hatchInside; - } - tracker.Draw(pDC); - } - } -} - -void CDrawOleObj::OnOpen(CDrawView* pView) -{ - AfxGetApp()->BeginWaitCursor(); - m_pClientItem->DoVerb(GetKeyState(VK_CONTROL) < 0 ? OLEIVERB_OPEN : OLEIVERB_PRIMARY, pView); - AfxGetApp()->EndWaitCursor(); -} - -void CDrawOleObj::OnEditProperties() -{ - // using COlePropertiesDialog directly means no scaling - COlePropertiesDialog dlg(m_pClientItem, 100, 100, NULL); - - dlg.DoModal(); -} - -// position is in logical -void CDrawOleObj::MoveTo(const CRect& position, CDrawView* pView) -{ - ASSERT_VALID(this); - - if (position == m_position) - return; - - // call base class to update position - CDrawObj::MoveTo(position, pView); - - // update position of in-place editing session on position change - if (m_pClientItem->IsInPlaceActive()) - m_pClientItem->SetItemRects(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawobj.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawobj.h deleted file mode 100644 index a02c4f2b3e1cf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawobj.h +++ /dev/null @@ -1,232 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CDrawView; -class CDrawDoc; - -///////////////////////////////////////////////////////////////////////////// -// CDrawObj - base class for all 'drawable objects' - -class CDrawObj : public CObject -{ -protected: - DECLARE_SERIAL(CDrawObj); - CDrawObj(); - -// Constructors -public: - CDrawObj(const CRect& position); - -// Attributes - CRect m_position; - CDrawDoc* m_pDocument; - - virtual int GetHandleCount(); - virtual CPoint GetHandle(int nHandle); - CRect GetHandleRect(int nHandleID, CDrawView* pView); - virtual HCURSOR GetHandleCursor(int nHandle); - virtual void SetLineColor(COLORREF color, BOOL bPreview = FALSE); - virtual void SetFillColor(COLORREF color, BOOL bPreview = FALSE); - -// Operations - virtual void Draw(CDC* pDC); - enum TrackerState { normal, selected, active }; - virtual void DrawTracker(CDC* pDC, TrackerState state); - virtual void MoveTo(const CRect& positon, CDrawView* pView = NULL); - virtual int HitTest(CPoint point, CDrawView* pView, BOOL bSelected); - virtual BOOL Intersects(const CRect& rect); - virtual void MoveHandleTo(int nHandle, CPoint point, CDrawView* pView = NULL); - virtual void OnOpen(CDrawView* pView); - virtual void OnEditProperties(); - virtual CDrawObj* Clone(CDrawDoc* pDoc = NULL); - virtual void Remove(); - void Invalidate(); - - COLORREF GetLineColor() const - { - return m_logpen.lopnColor; - } - - int GetLineWeight() const - { - return m_logpen.lopnWidth.x; - } - - void SetLineWeight(int nWidth, BOOL bPreview = FALSE); - - COLORREF GetFillColor() const - { - return m_logbrush.lbColor; - } - - BOOL IsEnableFill() const - { - return m_bBrush; - } - - void EnableFill(BOOL bEnable, BOOL bPreview = FALSE); - - BOOL IsEnableLine() const - { - return m_bPen; - } - - void EnableLine(BOOL bEnable, BOOL bPreview = FALSE); - - virtual BOOL CanChangeFillColor() const - { - return TRUE; - } - - virtual BOOL CanChangeLineColor() const - { - return TRUE; - } - - virtual BOOL CanChangeLineWeight() const - { - return TRUE; - } - -// Implementation -public: - virtual ~CDrawObj(); - virtual void Serialize(CArchive& ar); -#ifdef _DEBUG - void AssertValid(); -#endif - -// implementation data -protected: - BOOL m_bPen; - LOGPEN m_logpen; - BOOL m_bBrush; - LOGBRUSH m_logbrush; -}; - -// special 'list' class for this application(requires afxtempl.h) -typedef CTypedPtrList CDrawObjList; - -//////////////////////////////////////////////////////////////////////// -// specialized draw objects - -class CDrawRect : public CDrawObj -{ -protected: - DECLARE_SERIAL(CDrawRect); - CDrawRect(); - -public: - CDrawRect(const CRect& position); - -// Implementation -public: - virtual void Serialize(CArchive& ar); - virtual void Draw(CDC* pDC); - virtual int GetHandleCount(); - virtual CPoint GetHandle(int nHandle); - virtual HCURSOR GetHandleCursor(int nHandle); - virtual void MoveHandleTo(int nHandle, CPoint point, CDrawView* pView = NULL); - virtual BOOL Intersects(const CRect& rect); - virtual CDrawObj* Clone(CDrawDoc* pDoc); - - virtual BOOL CanChangeFillColor() const - { - return m_nShape != line; - } - -protected: - enum Shape { rectangle, roundRectangle, ellipse, line }; - Shape m_nShape; - CPoint m_roundness; // for roundRect corners - - friend class CRectTool; -}; - -///////////////////////////////////////////////////////////////////////////// - -class CDrawPoly; - -class CDrawPoly : public CDrawObj -{ -protected: - DECLARE_SERIAL(CDrawPoly); - CDrawPoly(); - -public: - CDrawPoly(const CRect& position); - -// Operations - void AddPoint(const CPoint& point, CDrawView* pView = NULL); - BOOL RecalcBounds(CDrawView* pView = NULL); - -// Implementation -public: - virtual ~CDrawPoly(); - virtual void Serialize(CArchive& ar); - virtual void Draw(CDC* pDC); - virtual void MoveTo(const CRect& position, CDrawView* pView = NULL); - virtual int GetHandleCount(); - virtual CPoint GetHandle(int nHandle); - virtual HCURSOR GetHandleCursor(int nHandle); - virtual void MoveHandleTo(int nHandle, CPoint point, CDrawView* pView = NULL); - virtual BOOL Intersects(const CRect& rect); - virtual CDrawObj* Clone(CDrawDoc* pDoc); - -protected: - int m_nPoints; - int m_nAllocPoints; - CPoint* m_points; - CDrawPoly* m_pDrawObj; - - friend class CPolyTool; -}; - -class CDrawItem; // COleClientItem derived class - -class CDrawOleObj : public CDrawObj -{ -protected: - DECLARE_SERIAL(CDrawOleObj); - CDrawOleObj(); - -public: - CDrawOleObj(const CRect& position); - -// Implementation -public: - virtual void Serialize(CArchive& ar); - virtual void Draw(CDC* pDC); - virtual CDrawObj* Clone(CDrawDoc* pDoc); - virtual void OnOpen(CDrawView* pView); - virtual void MoveTo(const CRect& positon, CDrawView* pView = NULL); - virtual void OnEditProperties(); - virtual void Remove(); - virtual ~CDrawOleObj(); - - virtual BOOL CanChangeFillColor() const - { - return FALSE; - } - virtual BOOL CanChangeLineColor() const - { - return FALSE; - } - virtual BOOL CanChangeLineWeight() const - { - return FALSE; - } - - static BOOL c_bShowItems; - - CDrawItem* m_pClientItem; - CSize m_extent; // current extent is tracked separate from scaled position -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawtool.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawtool.cpp deleted file mode 100644 index be72d3fe2b139..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawtool.cpp +++ /dev/null @@ -1,460 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" -#include "drawdoc.h" -#include "drawvw.h" -#include "drawobj.h" -#include "drawtool.h" - -#include "mainfrm.h" - -///////////////////////////////////////////////////////////////////////////// -// CDrawTool implementation - -CPtrList CDrawTool::c_tools; - -static CSelectTool selectTool; -static CRectTool lineTool(line); -static CRectTool rectTool(rect); -static CRectTool roundRectTool(roundRect); -static CRectTool ellipseTool(ellipse); -static CPolyTool polyTool; - -CPoint CDrawTool::c_down; -UINT CDrawTool::c_nDownFlags; -CPoint CDrawTool::c_last; -DrawShape CDrawTool::c_drawShape = selection; - -CDrawTool::CDrawTool(DrawShape drawShape) -{ - m_drawShape = drawShape; - c_tools.AddTail(this); -} - -CDrawTool* CDrawTool::FindTool(DrawShape drawShape) -{ - POSITION pos = c_tools.GetHeadPosition(); - while (pos != NULL) - { - CDrawTool* pTool = (CDrawTool*)c_tools.GetNext(pos); - if (pTool->m_drawShape == drawShape) - return pTool; - } - - return NULL; -} - -void CDrawTool::OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - // deactivate any in-place active item on this view! - COleClientItem* pActiveItem = pView->GetDocument()->GetInPlaceActiveItem(pView); - if (pActiveItem != NULL) - { - pActiveItem->Close(); - ASSERT(pView->GetDocument()->GetInPlaceActiveItem(pView) == NULL); - } - - pView->SetCapture(); - c_nDownFlags = nFlags; - c_down = point; - c_last = point; -} - -void CDrawTool::OnLButtonDblClk(CDrawView* /*pView*/, UINT /*nFlags*/, const CPoint& /*point*/) -{ -} - -void CDrawTool::OnLButtonUp(CDrawView* /*pView*/, UINT /*nFlags*/, const CPoint& point) -{ - ReleaseCapture(); - - if (point == c_down) - c_drawShape = selection; -} - -void CDrawTool::OnMouseMove(CDrawView* /*pView*/, UINT /*nFlags*/, const CPoint& point) -{ - c_last = point; - SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); -} - -void CDrawTool::OnEditProperties(CDrawView* /*pView*/) -{ -} - -void CDrawTool::OnCancel() -{ - c_drawShape = selection; -} - -//////////////////////////////////////////////////////////////////////////// -// CResizeTool - -enum SelectMode -{ - none, netSelect, move, size -}; - -SelectMode selectMode = none; -int nDragHandle; - -CPoint lastPoint; - -CSelectTool::CSelectTool() -: CDrawTool(selection) -{ -} - -void CSelectTool::OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - CPoint local = point; - pView->ClientToDoc(local); - - CDrawObj* pObj; - selectMode = none; - - // Check for resizing(only allowed on single selections) - if (pView->m_selection.GetCount() == 1) - { - pObj = pView->m_selection.GetHead(); - nDragHandle = pObj->HitTest(local, pView, TRUE); - if (nDragHandle != 0) - selectMode = size; - } - - // See if the click was on an object, select and start move if so - if (selectMode == none) - { - pObj = pView->GetDocument()->ObjectAt(local); - - if (pObj != NULL) - { - selectMode = move; - - if (!pView->IsSelected(pObj)) - pView->Select(pObj, (nFlags & MK_SHIFT) != 0); - - // Ctrl+Click clones the selection... - if ((nFlags & MK_CONTROL) != 0) - pView->CloneSelection(); - } - } - - // Click on background, start a net-selection - if (selectMode == none) - { - if ((nFlags & MK_SHIFT) == 0) - pView->Select(NULL); - - selectMode = netSelect; - - CClientDC dc(pView); - CRect rect(point.x, point.y, point.x, point.y); - rect.NormalizeRect(); - dc.DrawFocusRect(rect); - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(pView); - - lastPoint = local; - CDrawTool::OnLButtonDown(pView, nFlags, point); -} - -void CSelectTool::OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - if ((nFlags & MK_SHIFT) != 0) - { - // Shift+DblClk deselects object... - CPoint local = point; - pView->ClientToDoc(local); - CDrawObj* pObj = pView->GetDocument()->ObjectAt(local); - if (pObj != NULL) - pView->Deselect(pObj); - } - else - { - // "Normal" DblClk opens properties, or OLE server... - if (pView->m_selection.GetCount() == 1) - pView->m_selection.GetHead()->OnOpen(pView); - } - - CDrawTool::OnLButtonDblClk(pView, nFlags, point); -} - -void CSelectTool::OnEditProperties(CDrawView* pView) -{ - if (pView->m_selection.GetCount() == 1) - pView->m_selection.GetHead()->OnEditProperties(); -} - -void CSelectTool::OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - if (pView->GetCapture() == pView) - { - if (selectMode == netSelect) - { - CClientDC dc(pView); - CRect rect(c_down.x, c_down.y, c_last.x, c_last.y); - rect.NormalizeRect(); - dc.DrawFocusRect(rect); - - pView->SelectWithinRect(rect, TRUE); - } - else if (selectMode != none) - { - pView->GetDocument()->UpdateAllViews(pView); - } - } - - CDrawTool::OnLButtonUp(pView, nFlags, point); -} - -void CSelectTool::OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - if (pView->GetCapture() != pView) - { - if (c_drawShape == selection && pView->m_selection.GetCount() == 1) - { - CDrawObj* pObj = pView->m_selection.GetHead(); - CPoint local = point; - pView->ClientToDoc(local); - int nHandle = pObj->HitTest(local, pView, TRUE); - if (nHandle != 0) - { - SetCursor(pObj->GetHandleCursor(nHandle)); - return; // bypass CDrawTool - } - } - if (c_drawShape == selection) - CDrawTool::OnMouseMove(pView, nFlags, point); - return; - } - - if (selectMode == netSelect) - { - CClientDC dc(pView); - CRect rect(c_down.x, c_down.y, c_last.x, c_last.y); - rect.NormalizeRect(); - dc.DrawFocusRect(rect); - rect.SetRect(c_down.x, c_down.y, point.x, point.y); - rect.NormalizeRect(); - dc.DrawFocusRect(rect); - - CDrawTool::OnMouseMove(pView, nFlags, point); - return; - } - - CPoint local = point; - pView->ClientToDoc(local); - CPoint delta = (CPoint)(local - lastPoint); - - POSITION pos = pView->m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = pView->m_selection.GetNext(pos); - CRect position = pObj->m_position; - - if (selectMode == move) - { - position += delta; - pObj->MoveTo(position, pView); - } - else if (nDragHandle != 0) - { - pObj->MoveHandleTo(nDragHandle, local, pView); - } - } - - lastPoint = local; - - if (selectMode == size && c_drawShape == selection) - { - c_last = point; - SetCursor(pView->m_selection.GetHead()->GetHandleCursor(nDragHandle)); - return; // bypass CDrawTool - } - - c_last = point; - - if (c_drawShape == selection) - CDrawTool::OnMouseMove(pView, nFlags, point); -} - -//////////////////////////////////////////////////////////////////////////// -// CRectTool(does rectangles, round-rectangles, and ellipses) - -CRectTool::CRectTool(DrawShape drawShape) -: CDrawTool(drawShape) -{ -} - -void CRectTool::OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - CDrawTool::OnLButtonDown(pView, nFlags, point); - - CPoint local = point; - pView->ClientToDoc(local); - - CDrawRect* pObj = new CDrawRect(CRect(local, CSize(0, 0))); - switch (m_drawShape) - { - default: - ASSERT(FALSE); // unsupported shape! - - case rect: - pObj->m_nShape = CDrawRect::rectangle; - break; - - case roundRect: - pObj->m_nShape = CDrawRect::roundRectangle; - break; - - case ellipse: - pObj->m_nShape = CDrawRect::ellipse; - break; - - case line: - pObj->m_nShape = CDrawRect::line; - break; - } - pView->GetDocument()->Add(pObj); - pView->Select(pObj); - - selectMode = size; - nDragHandle = 1; - lastPoint = local; - - ((CMainFrame*)AfxGetMainWnd())->ActivateRibbonContextCategory(ID_FORMAT_CONTEXT_TAB); -} - -void CRectTool::OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - CDrawTool::OnLButtonDblClk(pView, nFlags, point); -} - -void CRectTool::OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - if (point == c_down) - { - // Don't create empty objects... - CDrawObj *pObj = pView->m_selection.GetTail(); - pView->GetDocument()->Remove(pObj); - pObj->Remove(); - selectTool.OnLButtonDown(pView, nFlags, point); // try a select! - } - - selectTool.OnLButtonUp(pView, nFlags, point); -} - -void CRectTool::OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS)); - selectTool.OnMouseMove(pView, nFlags, point); -} - -//////////////////////////////////////////////////////////////////////////// -// CPolyTool - -CPolyTool::CPolyTool() -: CDrawTool(poly) -{ - m_pDrawObj = NULL; -} - -void CPolyTool::OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - CDrawTool::OnLButtonDown(pView, nFlags, point); - - CPoint local = point; - pView->ClientToDoc(local); - - if (m_pDrawObj == NULL) - { - pView->SetCapture(); - - m_pDrawObj = new CDrawPoly(CRect(local, CSize(0, 0))); - pView->GetDocument()->Add(m_pDrawObj); - pView->Select(m_pDrawObj); - m_pDrawObj->AddPoint(local, pView); - } - else if (local == m_pDrawObj->m_points[0]) - { - // Stop when the first point is repeated... - ReleaseCapture(); - m_pDrawObj->m_nPoints -= 1; - if (m_pDrawObj->m_nPoints < 2) - { - m_pDrawObj->Remove(); - } - else - { - pView->InvalObj(m_pDrawObj); - } - m_pDrawObj = NULL; - c_drawShape = selection; - return; - } - - local.x += 1; // adjacent points can't be the same! - m_pDrawObj->AddPoint(local, pView); - - selectMode = size; - nDragHandle = m_pDrawObj->GetHandleCount(); - lastPoint = local; -} - -void CPolyTool::OnLButtonUp(CDrawView* /*pView*/, UINT /*nFlags*/, const CPoint& /*point*/) -{ - // Don't release capture yet! -} - -void CPolyTool::OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point) -{ - if (m_pDrawObj != NULL &&(nFlags & MK_LBUTTON) != 0) - { - CPoint local = point; - pView->ClientToDoc(local); - m_pDrawObj->AddPoint(local); - nDragHandle = m_pDrawObj->GetHandleCount(); - lastPoint = local; - c_last = point; - SetCursor(AfxGetApp()->LoadCursor(IDC_PENCIL)); - } - else - { - SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS)); - selectTool.OnMouseMove(pView, nFlags, point); - } -} - -void CPolyTool::OnLButtonDblClk(CDrawView* pView, UINT , const CPoint& ) -{ - ReleaseCapture(); - - int nPoints = m_pDrawObj->m_nPoints; - if (nPoints > 2 && (m_pDrawObj->m_points[nPoints - 1] == m_pDrawObj->m_points[nPoints - 2] || - m_pDrawObj->m_points[nPoints - 1].x - 1 == m_pDrawObj->m_points[nPoints - 2].x && m_pDrawObj->m_points[nPoints - 1].y == m_pDrawObj->m_points[nPoints - 2].y)) - { - // Remove the last point if it's the same as the next to last... - m_pDrawObj->m_nPoints -= 1; - pView->InvalObj(m_pDrawObj); - } - - m_pDrawObj = NULL; - c_drawShape = selection; -} - -void CPolyTool::OnCancel() -{ - CDrawTool::OnCancel(); - - m_pDrawObj = NULL; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawtool.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawtool.h deleted file mode 100644 index 4b27905823fbc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawtool.h +++ /dev/null @@ -1,86 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once -#include "drawobj.h" - -class CDrawView; - -enum DrawShape -{ - selection, line, rect, roundRect, ellipse, poly -}; - -class CDrawTool -{ -// Constructors -public: - CDrawTool(DrawShape nDrawShape); - -// Overridables - virtual void OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnEditProperties(CDrawView* pView); - virtual void OnCancel(); - -// Attributes - DrawShape m_drawShape; - - static CDrawTool* FindTool(DrawShape drawShape); - static CPtrList c_tools; - static CPoint c_down; - static UINT c_nDownFlags; - static CPoint c_last; - static DrawShape c_drawShape; -}; - -class CSelectTool : public CDrawTool -{ -// Constructors -public: - CSelectTool(); - -// Implementation - virtual void OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnEditProperties(CDrawView* pView); -}; - -class CRectTool : public CDrawTool -{ -// Constructors -public: - CRectTool(DrawShape drawShape); - -// Implementation - virtual void OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point); -}; - -class CPolyTool : public CDrawTool -{ -// Constructors -public: - CPolyTool(); - -// Implementation - virtual void OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point); - virtual void OnCancel(); -private: - CDrawPoly* m_pDrawObj; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawvw.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawvw.cpp deleted file mode 100644 index 3f1792b0d33bf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawvw.cpp +++ /dev/null @@ -1,1746 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include - -#include "DrawClient.h" - -#include "drawdoc.h" -#include "drawobj.h" -#include "cntritem.h" -#include "drawvw.h" - -#include "drawobj.h" -#include "drawtool.h" -#include "mainfrm.h" - -#include "LineWeightDlg.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -// private clipboard format(list of Draw objects) -CLIPFORMAT CDrawView::m_cfDraw = (CLIPFORMAT) -::RegisterClipboardFormat(_T("MFC Draw Sample")); -CLIPFORMAT CDrawView::m_cfObjectDescriptor = NULL; - -///////////////////////////////////////////////////////////////////////////// -// CDrawView - -IMPLEMENT_DYNCREATE(CDrawView, CScrollView) - -BEGIN_MESSAGE_MAP(CDrawView, CScrollView) - //{{AFX_MSG_MAP(CDrawView) - ON_COMMAND(ID_OLE_INSERT_NEW, OnInsertObject) - ON_COMMAND(ID_CANCEL_EDIT, OnCancelEdit) - ON_WM_LBUTTONDOWN() - ON_WM_LBUTTONUP() - ON_WM_MOUSEMOVE() - ON_WM_LBUTTONDBLCLK() - ON_COMMAND(ID_DRAW_SELECT, OnDrawSelect) - ON_COMMAND(ID_DRAW_ROUNDRECT, OnDrawRoundRect) - ON_COMMAND(ID_DRAW_RECT, OnDrawRect) - ON_COMMAND(ID_DRAW_LINE, OnDrawLine) - ON_COMMAND(ID_DRAW_ELLIPSE, OnDrawEllipse) - ON_UPDATE_COMMAND_UI(ID_DRAW_ELLIPSE, OnUpdateDrawEllipse) - ON_UPDATE_COMMAND_UI(ID_DRAW_LINE, OnUpdateDrawLine) - ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, OnUpdateDrawRect) - ON_UPDATE_COMMAND_UI(ID_DRAW_ROUNDRECT, OnUpdateDrawRoundRect) - ON_UPDATE_COMMAND_UI(ID_DRAW_SELECT, OnUpdateDrawSelect) - ON_UPDATE_COMMAND_UI(ID_OBJECT_MOVEBACK, OnUpdateSingleSelect) - ON_COMMAND(ID_EDIT_SELECT_ALL, OnEditSelectAll) - ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) - ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR, OnUpdateAnySelect) - ON_COMMAND(ID_DRAW_POLYGON, OnDrawPolygon) - ON_UPDATE_COMMAND_UI(ID_DRAW_POLYGON, OnUpdateDrawPolygon) - ON_WM_SIZE() - ON_COMMAND(ID_VIEW_GRID, OnViewGrid) - ON_UPDATE_COMMAND_UI(ID_VIEW_GRID, OnUpdateViewGrid) - ON_WM_ERASEBKGND() - ON_COMMAND(ID_OBJECT_FILLCOLOR, OnObjectFillColor) - ON_UPDATE_COMMAND_UI(ID_OBJECT_FILLCOLOR, OnUpdateObjectFillColor) - ON_COMMAND(ID_OBJECT_NOFILL, OnObjectNoFill) - ON_UPDATE_COMMAND_UI(ID_OBJECT_NOFILL, OnUpdateObjectNoFill) - ON_COMMAND(ID_OBJECT_LINECOLOR, OnObjectLineColor) - ON_UPDATE_COMMAND_UI(ID_OBJECT_LINECOLOR, OnUpdateObjectLineColor) - ON_COMMAND(ID_OBJECT_NOLINE, OnObjectNoLine) - ON_UPDATE_COMMAND_UI(ID_OBJECT_NOLINE, OnUpdateObjectNoLine) - ON_COMMAND_RANGE(ID_OBJECT_LINEWEIGHT, ID_OBJECT_LINEWEIGHT_MORE, OnObjectLineWeight) - ON_UPDATE_COMMAND_UI_RANGE(ID_OBJECT_LINEWEIGHT, ID_OBJECT_LINEWEIGHT_MORE, OnUpdateObjectLineWeight) - ON_COMMAND(ID_OBJECT_PROPERTIES, OnObjectProperties) - ON_UPDATE_COMMAND_UI(ID_OBJECT_PROPERTIES, OnUpdateObjectProperties) - ON_COMMAND(ID_OBJECT_STYLES, OnObjectStyles) - ON_UPDATE_COMMAND_UI(ID_OBJECT_STYLES, OnUpdateObjectStyles) - ON_COMMAND(ID_OBJECT_MOVEBACK, OnObjectMoveBack) - ON_COMMAND(ID_OBJECT_MOVEFORWARD, OnObjectMoveForward) - ON_COMMAND(ID_OBJECT_MOVETOBACK, OnObjectMoveToBack) - ON_COMMAND(ID_OBJECT_MOVETOFRONT, OnObjectMoveToFront) - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy) - ON_COMMAND(ID_EDIT_CUT, OnEditCut) - ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut) - ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) - ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste) - ON_WM_SETFOCUS() - ON_COMMAND(ID_VIEW_SHOWOBJECTS, OnViewShowObjects) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWOBJECTS, OnUpdateViewShowObjects) - ON_WM_DESTROY() - ON_UPDATE_COMMAND_UI(ID_EDIT_SELECT_ALL, OnUpdateEditSelectAll) - ON_WM_CREATE() - ON_UPDATE_COMMAND_UI(ID_OBJECT_MOVEFORWARD, OnUpdateSingleSelect) - ON_UPDATE_COMMAND_UI(ID_OBJECT_MOVETOBACK, OnUpdateSingleSelect) - ON_UPDATE_COMMAND_UI(ID_OBJECT_MOVETOFRONT, OnUpdateSingleSelect) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) - ON_COMMAND(ID_FILE_PRINT_DIRECT, OnFilePrint) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDrawView construction/destruction - -CDrawView::CDrawView() -{ - m_bGrid = TRUE; - m_gridColor = RGB(0, 0, 128); - m_bActive = FALSE; - // new - if ( m_cfObjectDescriptor == NULL ) - m_cfObjectDescriptor = (CLIPFORMAT)::RegisterClipboardFormat(_T("Object Descriptor") ); - m_prevDropEffect = DROPEFFECT_NONE; - // end new -} - -CDrawView::~CDrawView() -{ - ResetPreviewState(); -} - -BOOL CDrawView::PreCreateWindow(CREATESTRUCT& cs) -{ - ASSERT(cs.style & WS_CHILD); - if (cs.lpszClass == NULL) - cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS); - return TRUE; -} - -void CDrawView::OnActivateView(BOOL bActivate, CView* pActiveView, CView* pDeactiveView) -{ - CView::OnActivateView(bActivate, pActiveView, pDeactiveView); - - if (!bActivate && GetDocument()->CanDeactivateInplace()) - { - COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); - if (pActiveItem != NULL && pActiveItem->GetItemState() == COleClientItem::activeUIState) - { - pActiveItem->Deactivate(); - } - } - - // invalidate selections when active status changes - if (m_bActive != bActivate) - { - if (bActivate) // if becoming active update as if active - m_bActive = bActivate; - if (!m_selection.IsEmpty()) - OnUpdate(NULL, HINT_UPDATE_SELECTION, NULL); - m_bActive = bActivate; - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawView drawing - -void CDrawView::InvalObj(CDrawObj* pObj) -{ - CRect rect = pObj->m_position; - DocToClient(rect); - if (m_bActive && IsSelected(pObj)) - { - rect.left -= 4; - rect.top -= 5; - rect.right += 5; - rect.bottom += 4; - } - rect.InflateRect(1, 1); // handles CDrawOleObj objects - - InvalidateRect(rect, FALSE); -} - -void CDrawView::OnUpdate(CView* , LPARAM lHint, CObject* pHint) -{ - switch (lHint) - { - case HINT_UPDATE_WINDOW: // redraw entire window - Invalidate(FALSE); - break; - - case HINT_UPDATE_DRAWOBJ: // a single object has changed - InvalObj((CDrawObj*)pHint); - break; - - case HINT_UPDATE_SELECTION: // an entire selection has changed - { - CDrawObjList* pList = pHint != NULL ? - (CDrawObjList*)pHint : &m_selection; - POSITION pos = pList->GetHeadPosition(); - while (pos != NULL) - { - InvalObj(pList->GetNext(pos)); - } - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - } - break; - - case HINT_DELETE_SELECTION: // an entire selection has been removed - if (pHint != &m_selection) - { - CDrawObjList* pList = (CDrawObjList*)pHint; - POSITION pos = pList->GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = pList->GetNext(pos); - InvalObj(pObj); - Remove(pObj); // remove it from this view's selection - } - } - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - break; - - case HINT_UPDATE_OLE_ITEMS: - { - CDrawDoc* pDoc = GetDocument(); - POSITION pos = pDoc->GetObjects()->GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = pDoc->GetObjects()->GetNext(pos); - if (pObj->IsKindOf(RUNTIME_CLASS(CDrawOleObj))) - InvalObj(pObj); - } - } - break; - - default: - ASSERT(FALSE); - break; - } -} - -void CDrawView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) -{ - CScrollView::OnPrepareDC(pDC, pInfo); - - // mapping mode is MM_ANISOTROPIC - // these extents setup a mode similar to MM_LOENGLISH - // MM_LOENGLISH is in .01 physical inches - // these extents provide .01 logical inches - - pDC->SetMapMode(MM_ANISOTROPIC); - pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY)); - pDC->SetWindowExt(100, -100); - - // set the origin of the coordinate system to the center of the page - CPoint ptOrg; - ptOrg.x = GetDocument()->GetSize().cx / 2; - ptOrg.y = GetDocument()->GetSize().cy / 2; - - // ptOrg is in logical coordinates - pDC->OffsetWindowOrg(-ptOrg.x,ptOrg.y); -} - -BOOL CDrawView::OnScrollBy(CSize sizeScroll, BOOL bDoScroll) -{ - // do the scroll - if (!CScrollView::OnScrollBy(sizeScroll, bDoScroll)) - return FALSE; - - // update the position of any in-place active item - if (bDoScroll) - { - UpdateActiveItem(); - UpdateWindow(); - } - return TRUE; -} - -void CDrawView::OnDraw(CDC* pDC) -{ - CDrawDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - CDC dc; - CDC* pDrawDC = pDC; - CBitmap bitmap; - CBitmap* pOldBitmap = 0; - - // only paint the rect that needs repainting - CRect client; - pDC->GetClipBox(client); - CRect rect = client; - DocToClient(rect); - - if (!pDC->IsPrinting()) - { - // draw to offscreen bitmap for fast looking repaints - if (dc.CreateCompatibleDC(pDC)) - { - if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height())) - { - OnPrepareDC(&dc, NULL); - pDrawDC = &dc; - - // offset origin more because bitmap is just piece of the whole drawing - dc.OffsetViewportOrg(-rect.left, -rect.top); - pOldBitmap = dc.SelectObject(&bitmap); - dc.SetBrushOrg(rect.left % 8, rect.top % 8); - - // might as well clip to the same rectangle - dc.IntersectClipRect(client); - } - } - } - - // paint background - CBrush brush; - if (!brush.CreateSolidBrush(pDoc->GetPaperColor())) - return; - - brush.UnrealizeObject(); - pDrawDC->FillRect(client, &brush); - - if (!pDC->IsPrinting() && m_bGrid) - DrawGrid(pDrawDC); - - pDoc->Draw(pDrawDC, this); - - if (pDrawDC != pDC) - { - pDC->SetViewportOrg(0, 0); - pDC->SetWindowOrg(0,0); - pDC->SetMapMode(MM_TEXT); - dc.SetViewportOrg(0, 0); - dc.SetWindowOrg(0,0); - dc.SetMapMode(MM_TEXT); - pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY); - dc.SelectObject(pOldBitmap); - } -} - -void CDrawView::Remove(CDrawObj* pObj) -{ - POSITION pos = m_selection.Find(pObj); - if (pos != NULL) - { - m_selection.RemoveAt(pos); - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); - } -} - -void CDrawView::PasteNative(COleDataObject& dataObject) -{ - // get file refering to clipboard data - CFile* pFile = dataObject.GetFileData(m_cfDraw); - if (pFile == NULL) - return; - - // connect the file to the archive - CArchive ar(pFile, CArchive::load); - TRY - { - ar.m_pDocument = GetDocument(); // set back-pointer in archive - - // read the selection - m_selection.Serialize(ar); - } - CATCH_ALL(e) - { - ar.Close(); - delete pFile; - THROW_LAST(); - } - END_CATCH_ALL - - ar.Close(); - delete pFile; -} - -void CDrawView::PasteEmbedded(COleDataObject& dataObject, CPoint point ) -{ - BeginWaitCursor(); - - // paste embedded - CDrawOleObj* pObj = new CDrawOleObj(GetInitialPosition()); - ASSERT_VALID(pObj); - -#pragma warning(suppress:6014) - CDrawItem* pItem = new CDrawItem(GetDocument(), pObj); - ASSERT_VALID(pItem); - pObj->m_pClientItem = pItem; - - TRY - { - if (!pItem->CreateFromData(&dataObject) && !pItem->CreateStaticFromData(&dataObject)) - { - AfxThrowMemoryException(); // any exception will do - } - - // add the object to the document - GetDocument()->Add(pObj); - m_selection.AddTail(pObj); - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); - - ClientToDoc( point ); - pObj->MoveTo( CRect( point, pObj->m_extent ), this ); - - // try to get initial presentation data - pItem->UpdateLink(); - pItem->UpdateExtent(); - } - CATCH_ALL(e) - { - // clean up item - pItem->Delete(); - pObj->m_pClientItem = NULL; - GetDocument()->Remove(pObj); - pObj->Remove(); - - AfxMessageBox(IDP_FAILED_TO_CREATE); - } - END_CATCH_ALL - - EndWaitCursor(); -} - -void CDrawView::DrawGrid(CDC* pDC) -{ - CDrawDoc* pDoc = GetDocument(); - - COLORREF oldBkColor = pDC->SetBkColor(pDoc->GetPaperColor()); - - CRect rect; - rect.left = -pDoc->GetSize().cx / 2; - rect.top = -pDoc->GetSize().cy / 2; - rect.right = rect.left + pDoc->GetSize().cx; - rect.bottom = rect.top + pDoc->GetSize().cy; - - // Center lines - CPen penDash; - penDash.CreatePen(PS_DASH, 0, m_gridColor); - CPen* pOldPen = pDC->SelectObject(&penDash); - - pDC->MoveTo(0, rect.top); - pDC->LineTo(0, rect.bottom); - pDC->MoveTo(rect.left, 0); - pDC->LineTo(rect.right, 0); - - // Major unit lines - CPen penDot; - penDot.CreatePen(PS_DOT, 0, m_gridColor); - pDC->SelectObject(&penDot); - - for (int x = rect.left / 100 * 100; x < rect.right; x += 100) - { - if (x != 0) - { - pDC->MoveTo(x, rect.top); - pDC->LineTo(x, rect.bottom); - } - } - - for (int y = rect.top / 100 * 100; y < rect.bottom; y += 100) - { - if (y != 0) - { - pDC->MoveTo(rect.left, y); - pDC->LineTo(rect.right, y); - } - } - - // Outlines - CPen penSolid; - penSolid.CreatePen(PS_SOLID, 0, m_gridColor); - pDC->SelectObject(&penSolid); - pDC->MoveTo(rect.left, rect.top); - pDC->LineTo(rect.right, rect.top); - pDC->LineTo(rect.right, rect.bottom); - pDC->LineTo(rect.left, rect.bottom); - pDC->LineTo(rect.left, rect.top); - - pDC->SelectObject(pOldPen); - pDC->SetBkColor(oldBkColor); -} - -void CDrawView::OnInitialUpdate() -{ - CSize size = GetDocument()->GetSize(); - CClientDC dc(NULL); - size.cx = MulDiv(size.cx, dc.GetDeviceCaps(LOGPIXELSX), 100); - size.cy = MulDiv(size.cy, dc.GetDeviceCaps(LOGPIXELSY), 100); - SetScrollSizes(MM_TEXT, size); -} - -void CDrawView::SetPageSize(CSize size) -{ - CClientDC dc(NULL); - size.cx = MulDiv(size.cx, dc.GetDeviceCaps(LOGPIXELSX), 100); - size.cy = MulDiv(size.cy, dc.GetDeviceCaps(LOGPIXELSY), 100); - SetScrollSizes(MM_TEXT, size); - GetDocument()->UpdateAllViews(NULL, HINT_UPDATE_WINDOW, NULL); -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawView printing - -BOOL CDrawView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CDrawView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) -{ - CScrollView::OnBeginPrinting(pDC,pInfo); - - // check page size -- user could have gone into print setup - // from print dialog and changed paper or orientation - GetDocument()->ComputePageSize(); -} - -void CDrawView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// OLE Client support and commands - -BOOL CDrawView::IsSelected(const CObject* pDocItem) const -{ - CDrawObj* pDrawObj = (CDrawObj*)pDocItem; - if (pDocItem->IsKindOf(RUNTIME_CLASS(CDrawItem))) - pDrawObj = ((CDrawItem*)pDocItem)->m_pDrawObj; - return m_selection.Find(pDrawObj) != NULL; -} - -void CDrawView::OnInsertObject() -{ - // Invoke the standard Insert Object dialog box to obtain information - // for new CDrawItem object. - COleInsertDialog dlg; - if (dlg.DoModal() != IDOK) - return; - - BeginWaitCursor(); - - // First create the C++ object - CDrawOleObj* pObj = new CDrawOleObj(GetInitialPosition()); - ASSERT_VALID(pObj); - CDrawItem* pItem = new CDrawItem(GetDocument(), pObj); - ASSERT_VALID(pItem); - pObj->m_pClientItem = pItem; - - // Now create the OLE object/item - TRY - { - if (!dlg.CreateItem(pObj->m_pClientItem)) - AfxThrowMemoryException(); - - // add the object to the document - GetDocument()->Add(pObj); - - // try to get initial presentation data - pItem->UpdateLink(); - pItem->UpdateExtent(); - - // if insert new object -- initially show the object - if (dlg.GetSelectionType() == COleInsertDialog::createNewItem) - pItem->DoVerb(OLEIVERB_SHOW, this); - } - CATCH_ALL(e) - { - // clean up item - pItem->Delete(); - pObj->m_pClientItem = NULL; - GetDocument()->Remove(pObj); - pObj->Remove(); - - AfxMessageBox(IDP_FAILED_TO_CREATE); - } - END_CATCH_ALL - - EndWaitCursor(); -} - -// The following command handler provides the standard keyboard -// user interface to cancel an in-place editing session. -void CDrawView::OnCancelEdit() -{ - // deactivate any in-place active item on this view! - COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); - if (pActiveItem != NULL) - { - // if we found one, deactivate it - pActiveItem->Close(); - } - ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL); - - // escape also brings us back into select mode - ReleaseCapture(); - - CDrawTool* pTool = CDrawTool::FindTool(CDrawTool::c_drawShape); - if (pTool != NULL) - { - pTool->OnCancel(); - } - - CDrawTool::c_drawShape = selection; -} - -void CDrawView::OnSetFocus(CWnd* pOldWnd) -{ - COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); - if (pActiveItem != NULL && pActiveItem->GetItemState() == COleClientItem::activeUIState) - { - // need to set focus to this item if it is in the same view - CWnd* pWnd = pActiveItem->GetInPlaceWindow(); - if (pWnd != NULL) - { - pWnd->SetFocus(); - return; - } - } - - CScrollView::OnSetFocus(pOldWnd); -} - -CRect CDrawView::GetInitialPosition() -{ - CRect rect(10, 10, 10, 10); - ClientToDoc(rect); - return rect; -} - -void CDrawView::ClientToDoc(CPoint& point) -{ - CClientDC dc(this); - OnPrepareDC(&dc, NULL); - dc.DPtoLP(&point); -} - -void CDrawView::ClientToDoc(CRect& rect) -{ - CClientDC dc(this); - OnPrepareDC(&dc, NULL); - dc.DPtoLP(rect); - ASSERT(rect.left <= rect.right); - ASSERT(rect.bottom <= rect.top); -} - -void CDrawView::DocToClient(CPoint& point) -{ - CClientDC dc(this); - OnPrepareDC(&dc, NULL); - dc.LPtoDP(&point); -} - -void CDrawView::DocToClient(CRect& rect) -{ - CClientDC dc(this); - OnPrepareDC(&dc, NULL); - dc.LPtoDP(rect); - rect.NormalizeRect(); -} - -void CDrawView::Select(CDrawObj* pObj, BOOL bAdd) -{ - if (!bAdd) - { - OnUpdate(NULL, HINT_UPDATE_SELECTION, NULL); - m_selection.RemoveAll(); - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - } - - if (pObj == NULL || IsSelected(pObj)) - { - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); - return; - } - - m_selection.AddTail(pObj); - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - InvalObj(pObj); - - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); -} - -// rect is in device coordinates -void CDrawView::SelectWithinRect(CRect rect, BOOL bAdd) -{ - if (!bAdd) - Select(NULL); - - ClientToDoc(rect); - - CDrawObjList* pObList = GetDocument()->GetObjects(); - POSITION posObj = pObList->GetHeadPosition(); - while (posObj != NULL) - { - CDrawObj* pObj = pObList->GetNext(posObj); - if (pObj->Intersects(rect)) - Select(pObj, TRUE); - } -} - -void CDrawView::Deselect(CDrawObj* pObj) -{ - POSITION pos = m_selection.Find(pObj); - if (pos != NULL) - { - InvalObj(pObj); - m_selection.RemoveAt(pos); - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); - } -} - -void CDrawView::CloneSelection() -{ - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - pObj->Clone(pObj->m_pDocument); - // copies object and adds it to the document - } -} - -void CDrawView::UpdateActiveItem() -{ - COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); - if (pActiveItem != NULL && pActiveItem->GetItemState() == COleClientItem::activeUIState) - { - // this will update the item rectangles by calling - // OnGetPosRect & OnGetClipRect. - pActiveItem->SetItemRects(); - } -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawView message handlers - -void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) -{ - if (!m_bActive) - return; - CDrawTool* pTool = CDrawTool::FindTool(CDrawTool::c_drawShape); - if (pTool != NULL) - { - pTool->OnLButtonDown(this, nFlags, point); - } -} - -void CDrawView::OnLButtonUp(UINT nFlags, CPoint point) -{ - if (!m_bActive) - return; - CDrawTool* pTool = CDrawTool::FindTool(CDrawTool::c_drawShape); - if (pTool != NULL) - pTool->OnLButtonUp(this, nFlags, point); -} - -void CDrawView::OnMouseMove(UINT nFlags, CPoint point) -{ - if (!m_bActive) - return; - CDrawTool* pTool = CDrawTool::FindTool(CDrawTool::c_drawShape); - if (pTool != NULL) - pTool->OnMouseMove(this, nFlags, point); -} - -void CDrawView::OnLButtonDblClk(UINT nFlags, CPoint point) -{ - if (!m_bActive) - return; - CDrawTool* pTool = CDrawTool::FindTool(CDrawTool::c_drawShape); - if (pTool != NULL) - pTool->OnLButtonDblClk(this, nFlags, point); -} - -void CDrawView::OnDestroy() -{ - CScrollView::OnDestroy(); - - // deactivate the inplace active item on this view - COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); - if (pActiveItem != NULL && pActiveItem->GetActiveView() == this) - { - pActiveItem->Deactivate(); - ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL); - } -} - -void CDrawView::OnDrawSelect() -{ - CDrawTool::c_drawShape = selection; -} - -void CDrawView::OnDrawRoundRect() -{ - CDrawTool::c_drawShape = roundRect; -} - -void CDrawView::OnDrawRect() -{ - CDrawTool::c_drawShape = rect; -} - -void CDrawView::OnDrawLine() -{ - CDrawTool::c_drawShape = line; -} - -void CDrawView::OnDrawEllipse() -{ - CDrawTool::c_drawShape = ellipse; -} - -void CDrawView::OnDrawPolygon() -{ - CDrawTool::c_drawShape = poly; -} - -void CDrawView::OnUpdateDrawEllipse(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(CDrawTool::c_drawShape == ellipse); -} - -void CDrawView::OnUpdateDrawLine(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(CDrawTool::c_drawShape == line); -} - -void CDrawView::OnUpdateDrawRect(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(CDrawTool::c_drawShape == rect); -} - -void CDrawView::OnUpdateDrawRoundRect(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(CDrawTool::c_drawShape == roundRect); -} - -void CDrawView::OnUpdateDrawSelect(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(CDrawTool::c_drawShape == selection); -} - -void CDrawView::OnUpdateSingleSelect(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(m_selection.GetCount() == 1); -} - -void CDrawView::OnEditSelectAll() -{ - CDrawObjList* pObList = GetDocument()->GetObjects(); - POSITION pos = pObList->GetHeadPosition(); - while (pos != NULL) - Select(pObList->GetNext(pos), TRUE); -} - -void CDrawView::OnUpdateEditSelectAll(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(GetDocument()->GetObjects()->GetCount() != 0); -} - -void CDrawView::OnEditClear() -{ - // update all the views before the selection goes away - GetDocument()->UpdateAllViews(NULL, HINT_DELETE_SELECTION, &m_selection); - OnUpdate(NULL, HINT_UPDATE_SELECTION, NULL); - - // now remove the selection from the document - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - GetDocument()->Remove(pObj); - pObj->Remove(); - } - //Cleanup Tool members such as CPolyTool::m_pDrawObj, that should be NULL at this point. - CDrawTool* pTool = CDrawTool::FindTool(CDrawTool::c_drawShape); - if (pTool != NULL) - { - pTool->OnCancel(); - } - m_selection.RemoveAll(); - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); -} - -void CDrawView::OnUpdateAnySelect(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_selection.IsEmpty()); -} - -void CDrawView::OnUpdateDrawPolygon(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(CDrawTool::c_drawShape == poly); -} - -void CDrawView::OnSize(UINT nType, int cx, int cy) -{ - CScrollView::OnSize(nType, cx, cy); - UpdateActiveItem(); -} - -void CDrawView::OnViewGrid() -{ - m_bGrid = !m_bGrid; - Invalidate(FALSE); -} - -void CDrawView::OnUpdateViewGrid(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_bGrid); - -} - -BOOL CDrawView::OnEraseBkgnd(CDC*) -{ - return TRUE; -} - -void CDrawView::OnUpdateSelection(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_selection.IsEmpty()); -} - -void CDrawView::OnObjectFillColor() -{ - COLORREF color = ((CMainFrame*)AfxGetMainWnd())->GetColorFromColorButton(ID_OBJECT_FILLCOLOR); - - if (color == (COLORREF) -1) - { - return; - } - - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj->CanChangeFillColor()) - { - pObj->EnableFill(TRUE); - pObj->SetFillColor(color); - } - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - Invalidate(); - - ResetPreviewState(); -} - -void CDrawView::PreviewFillColor(COLORREF color) -{ - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - - if (pObj->CanChangeFillColor()) - { - pObj->EnableFill(TRUE); - pObj->SetFillColor(color, TRUE /* Preview */); - } - } -} - -void CDrawView::OnUpdateObjectFillColor(CCmdUI* pCmdUI) -{ - if (m_selection.GetCount() == 1) - { - pCmdUI->Enable(m_selection.GetHead()->CanChangeFillColor()); - } - else - { - OnUpdateSelection(pCmdUI); - } -} - -void CDrawView::OnObjectNoFill() -{ - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj->CanChangeFillColor()) - { - pObj->EnableFill(FALSE); - } - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - Invalidate(); -} - -void CDrawView::OnUpdateObjectNoFill(CCmdUI* pCmdUI) -{ - if (m_selection.GetCount() == 1) - { - pCmdUI->Enable(m_selection.GetHead()->CanChangeFillColor()); - pCmdUI->SetCheck(!m_selection.GetHead()->IsEnableFill()); - } - else - { - OnUpdateSelection(pCmdUI); - } -} - -void CDrawView::OnObjectLineColor() -{ - COLORREF color = ((CMainFrame*)AfxGetMainWnd())->GetColorFromColorButton(ID_OBJECT_LINECOLOR); - - if (color == (COLORREF) -1) - { - return; - } - - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj->CanChangeLineColor()) - { - pObj->EnableLine(TRUE); - pObj->SetLineColor(color); - } - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - Invalidate(); - - ResetPreviewState(); -} - -void CDrawView::PreviewLineColor(COLORREF color) -{ - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj->CanChangeLineColor()) - { - pObj->EnableLine(TRUE); - pObj->SetLineColor(color, TRUE /* Preview */); - } - } -} - -void CDrawView::OnUpdateObjectLineColor(CCmdUI* pCmdUI) -{ - if (m_selection.GetCount() == 1) - { - pCmdUI->Enable(m_selection.GetHead()->CanChangeLineColor()); - } - else - { - OnUpdateSelection(pCmdUI); - } -} - -void CDrawView::OnObjectNoLine() -{ - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj->CanChangeLineColor()) - { - pObj->EnableLine(FALSE); - } - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - Invalidate(); - - ResetPreviewState(); -} - -void CDrawView::OnUpdateObjectNoLine(CCmdUI* pCmdUI) -{ - if (m_selection.GetCount() == 1) - { - pCmdUI->Enable(m_selection.GetHead()->CanChangeLineColor()); - pCmdUI->SetCheck(!m_selection.GetHead()->IsEnableLine()); - } - else - { - OnUpdateSelection(pCmdUI); - } -} - -void CDrawView::OnObjectLineWeight(UINT nID) -{ - int weight = -1; - if (nID == ID_OBJECT_LINEWEIGHT) - { - weight = ((CMainFrame*)AfxGetMainWnd())->GetWeightFromLineWeight(ID_OBJECT_LINEWEIGHT); - } - else if (nID == ID_OBJECT_LINEWEIGHT_MORE) - { - CLineWeightDlg dlg(AfxGetMainWnd()); - - if (m_selection.GetCount() == 1) - { - dlg.m_penSize = m_selection.GetHead()->IsEnableLine() ? m_selection.GetHead()->GetLineWeight() : 0; - } - - if (dlg.DoModal() == IDOK) - { - weight = dlg.m_penSize; - } - } - - if (weight == -1) - { - return; - } - - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj->CanChangeLineWeight()) - { - pObj->EnableLine(weight > 0); - pObj->SetLineWeight(weight); - } - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - Invalidate(); - - ResetPreviewState(); -} - -void CDrawView::PreviewLineWeight(int weight) -{ - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj->CanChangeLineWeight()) - { - pObj->EnableLine(weight > 0); - pObj->SetLineWeight(weight); - } - } -} - -void CDrawView::OnUpdateObjectLineWeight(CCmdUI* pCmdUI) -{ - if (m_selection.GetCount() == 1) - { - pCmdUI->Enable(m_selection.GetHead()->CanChangeLineWeight()); - } - else - { - OnUpdateSelection(pCmdUI); - } -} - -void CDrawView::OnObjectProperties() -{ - CDrawObj* pObj = m_selection.GetHead(); - if (pObj != NULL) - { - pObj->OnEditProperties(); - } -} - -void CDrawView::OnUpdateObjectProperties(CCmdUI* pCmdUI) -{ - BOOL bEnable = m_selection.GetCount() == 1; - if (bEnable) - { - bEnable = DYNAMIC_DOWNCAST(CDrawOleObj, m_selection.GetHead()) == NULL; - } - - pCmdUI->Enable(bEnable); -} - -void CDrawView::OnObjectStyles() -{ - CMainFrame::XStyle style; - - if (!((CMainFrame*)AfxGetMainWnd())->GetStyleFromStyles(style)) - { - return; - } - - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - - if (pObj->CanChangeFillColor()) - { - pObj->EnableFill(style.clrFill != (COLORREF)-1); - if (style.clrFill != (COLORREF)-1) - { - pObj->SetFillColor(style.clrFill, TRUE); - } - } - if (pObj->CanChangeLineColor()) - { - pObj->EnableLine(style.clrLine != (COLORREF)-1); - if (style.clrLine != (COLORREF)-1) - { - pObj->SetLineColor(style.clrLine, TRUE); - } - } - } - - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - Invalidate(); - - ResetPreviewState(); -} - -void CDrawView::PreviewStyle(COLORREF clrFill, COLORREF clrLine) -{ - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - - if (pObj->CanChangeFillColor()) - { - pObj->EnableFill(clrFill != (COLORREF)-1); - if (clrFill != (COLORREF)-1) - { - pObj->SetFillColor(clrFill); - } - } - if (pObj->CanChangeLineColor()) - { - pObj->EnableLine(clrLine != (COLORREF)-1); - if (clrLine != (COLORREF)-1) - { - pObj->SetLineColor(clrLine); - } - } - } -} - -void CDrawView::OnUpdateObjectStyles(CCmdUI* pCmdUI) -{ - if (m_selection.GetCount() == 1) - { - pCmdUI->Enable(m_selection.GetHead()->CanChangeFillColor()); - } - else - { - OnUpdateSelection(pCmdUI); - } -} - -void CDrawView::OnObjectMoveBack() -{ - CDrawDoc* pDoc = GetDocument(); - CDrawObj* pObj = m_selection.GetHead(); - CDrawObjList* pObjects = pDoc->GetObjects(); - POSITION pos = pObjects->Find(pObj); - ASSERT(pos != NULL); - if (pos != pObjects->GetHeadPosition()) - { - POSITION posPrev = pos; - pObjects->GetPrev(posPrev); - pObjects->RemoveAt(pos); - pObjects->InsertBefore(posPrev, pObj); - InvalObj(pObj); - } -} - -void CDrawView::OnObjectMoveForward() -{ - CDrawDoc* pDoc = GetDocument(); - CDrawObj* pObj = m_selection.GetHead(); - CDrawObjList* pObjects = pDoc->GetObjects(); - POSITION pos = pObjects->Find(pObj); - ASSERT(pos != NULL); - if (pos != pObjects->GetTailPosition()) - { - POSITION posNext = pos; - pObjects->GetNext(posNext); - pObjects->RemoveAt(pos); - pObjects->InsertAfter(posNext, pObj); - InvalObj(pObj); - } -} - -void CDrawView::OnObjectMoveToBack() -{ - CDrawDoc* pDoc = GetDocument(); - CDrawObj* pObj = m_selection.GetHead(); - CDrawObjList* pObjects = pDoc->GetObjects(); - POSITION pos = pObjects->Find(pObj); - ASSERT(pos != NULL); - pObjects->RemoveAt(pos); - pObjects->AddHead(pObj); - InvalObj(pObj); -} - -void CDrawView::OnObjectMoveToFront() -{ - CDrawDoc* pDoc = GetDocument(); - CDrawObj* pObj = m_selection.GetHead(); - CDrawObjList* pObjects = pDoc->GetObjects(); - POSITION pos = pObjects->Find(pObj); - ASSERT(pos != NULL); - pObjects->RemoveAt(pos); - pObjects->AddTail(pObj); - InvalObj(pObj); -} - -void CDrawView::OnEditCopy() -{ - ASSERT_VALID(this); - ASSERT(m_cfDraw != NULL); - - // Create a shared file and associate a CArchive with it - CSharedFile file; - CArchive ar(&file, CArchive::store); - - // Serialize selected objects to the archive - m_selection.Serialize(ar); - ar.Close(); - - COleDataSource* pDataSource = NULL; - TRY - { - pDataSource = new COleDataSource; - // put on local format instead of or in addition to - pDataSource->CacheGlobalData(m_cfDraw, file.Detach()); - - // if only one item and it is a COleClientItem then also - // paste in that format - CDrawObj* pDrawObj = m_selection.GetHead(); - if (m_selection.GetCount() == 1 && pDrawObj->IsKindOf(RUNTIME_CLASS(CDrawOleObj))) - { - CDrawOleObj* pDrawOle = (CDrawOleObj*)pDrawObj; - pDrawOle->m_pClientItem->GetClipboardData(pDataSource, FALSE); - } - - pDataSource->SetClipboard(); - } - CATCH_ALL(e) - { - delete pDataSource; - THROW_LAST(); - } - END_CATCH_ALL -} - -void CDrawView::OnUpdateEditCopy(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_selection.IsEmpty()); -} - -void CDrawView::OnEditCut() -{ - OnEditCopy(); - OnEditClear(); -} - -void CDrawView::OnUpdateEditCut(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_selection.IsEmpty()); -} - -void CDrawView::OnEditPaste() -{ - COleDataObject dataObject; - dataObject.AttachClipboard(); - - // invalidate current selection since it will be deselected - OnUpdate(NULL, HINT_UPDATE_SELECTION, NULL); - m_selection.RemoveAll(); - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - if (dataObject.IsDataAvailable(m_cfDraw)) - { - PasteNative(dataObject); - - // now add all items in m_selection to document - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - GetDocument()->Add(m_selection.GetNext(pos)); - } - else - PasteEmbedded(dataObject, GetInitialPosition().TopLeft() ); - - GetDocument()->SetModifiedFlag(); - - // invalidate new pasted stuff - GetDocument()->UpdateAllViews(NULL, HINT_UPDATE_SELECTION, &m_selection); - - ((CMainFrame*)AfxGetMainWnd())->UpdateContextTab(this); -} - -void CDrawView::OnUpdateEditPaste(CCmdUI* pCmdUI) -{ - // determine if private or standard OLE formats are on the clipboard - COleDataObject dataObject; - BOOL bEnable = dataObject.AttachClipboard() && - (dataObject.IsDataAvailable(m_cfDraw) || COleClientItem::CanCreateFromData(&dataObject)); - - // enable command based on availability - pCmdUI->Enable(bEnable); -} - -void CDrawView::OnFilePrint() -{ - CScrollView::OnFilePrint(); - GetDocument()->ComputePageSize(); -} - -void CDrawView::OnViewShowObjects() -{ - CDrawOleObj::c_bShowItems = !CDrawOleObj::c_bShowItems; - GetDocument()->UpdateAllViews(NULL, HINT_UPDATE_OLE_ITEMS, NULL); -} - -void CDrawView::OnUpdateViewShowObjects(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(CDrawOleObj::c_bShowItems); -} - -///////////////////////////////////////////////////////////////////////////// -// CDrawView diagnostics - -#ifdef _DEBUG -void CDrawView::AssertValid() const -{ - CScrollView::AssertValid(); -} - -void CDrawView::Dump(CDumpContext& dc) const -{ - CScrollView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// new -// support for drag/drop - -int CDrawView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CScrollView::OnCreate(lpCreateStruct) == -1) - return -1; - - // register drop target - if ( m_dropTarget.Register( this ) ) - return 0; - else - return -1; -} - -BOOL CDrawView::GetObjectInfo(COleDataObject* pDataObject, CSize* pSize, CSize* pOffset) -{ - ENSURE(pSize != NULL); - - // get object descriptor data - HGLOBAL hObjDesc = pDataObject->GetGlobalData(m_cfObjectDescriptor); - if (hObjDesc == NULL) - { - if (pOffset != NULL) - *pOffset = CSize(0, 0); // fill in defaults instead - *pSize = CSize(0, 0); - return FALSE; - } - ASSERT(hObjDesc != NULL); - - // otherwise, got CF_OBJECTDESCRIPTOR ok. Lock it down and extract size. - LPOBJECTDESCRIPTOR pObjDesc = (LPOBJECTDESCRIPTOR)GlobalLock(hObjDesc); - ENSURE(pObjDesc != NULL); - pSize->cx = (int)pObjDesc->sizel.cx; - pSize->cy = (int)pObjDesc->sizel.cy; - if (pOffset != NULL) - { - pOffset->cx = (int)pObjDesc->pointl.x; - pOffset->cy = (int)pObjDesc->pointl.y; - } - GlobalUnlock(hObjDesc); - GlobalFree(hObjDesc); - - // successfully retrieved pSize & pOffset info - return TRUE; -} - -DROPEFFECT CDrawView::OnDragEnter(COleDataObject* pDataObject, DWORD grfKeyState, CPoint point) -{ - ASSERT(m_prevDropEffect == DROPEFFECT_NONE); - m_bDragDataAcceptable = FALSE; - if (!COleClientItem::CanCreateFromData(pDataObject)) - return DROPEFFECT_NONE; - - m_bDragDataAcceptable = TRUE; - GetObjectInfo(pDataObject, &m_dragSize, &m_dragOffset); - CClientDC dc(NULL); - dc.HIMETRICtoDP(&m_dragSize); - dc.HIMETRICtoDP(&m_dragOffset); - - return OnDragOver(pDataObject, grfKeyState, point); -} - -DROPEFFECT CDrawView::OnDragOver(COleDataObject*, DWORD grfKeyState, CPoint point) -{ - if (m_bDragDataAcceptable == FALSE) - return DROPEFFECT_NONE; - - point -= m_dragOffset; // adjust target rect by original cursor offset - - // check for point outside logical area -- i.e. in hatched region - // GetTotalSize() returns the size passed to SetScrollSizes - CRect rectScroll(CPoint(0, 0), GetTotalSize()); - - CRect rectItem(point,m_dragSize); - rectItem.OffsetRect(GetDeviceScrollPosition()); - - DROPEFFECT de = DROPEFFECT_NONE; - CRect rectTemp; - if (rectTemp.IntersectRect(rectScroll, rectItem)) - { - // check for force link - if ((grfKeyState &(MK_CONTROL|MK_SHIFT)) == (MK_CONTROL|MK_SHIFT)) - de = DROPEFFECT_NONE; // DRAWCLI isn't a linking container - // check for force copy - else if ((grfKeyState & MK_CONTROL) == MK_CONTROL) - de = DROPEFFECT_COPY; - // check for force move - else if ((grfKeyState & MK_ALT) == MK_ALT) - de = DROPEFFECT_MOVE; - // default -- recommended action is move - else - de = DROPEFFECT_MOVE; - } - - if (point == m_dragPoint) - return de; - - // otherwise, cursor has moved -- need to update the drag feedback - CClientDC dc(this); - if (m_prevDropEffect != DROPEFFECT_NONE) - { - // erase previous focus rect - dc.DrawFocusRect(CRect(m_dragPoint, m_dragSize)); - } - m_prevDropEffect = de; - if (m_prevDropEffect != DROPEFFECT_NONE) - { - m_dragPoint = point; - dc.DrawFocusRect(CRect(point, m_dragSize)); - } - return de; -} - -BOOL CDrawView::OnDrop(COleDataObject* pDataObject, DROPEFFECT /*dropEffect*/, CPoint point) -{ - ASSERT_VALID(this); - - // clean up focus rect - OnDragLeave(); - - // offset point as appropriate for dragging - GetObjectInfo(pDataObject, &m_dragSize, &m_dragOffset); - CClientDC dc(NULL); - dc.HIMETRICtoDP(&m_dragSize); - dc.HIMETRICtoDP(&m_dragOffset); - point -= m_dragOffset; - - // invalidate current selection since it will be deselected - OnUpdate(NULL, HINT_UPDATE_SELECTION, NULL); - m_selection.RemoveAll(); - ((CMainFrame*)AfxGetMainWnd())->UpdateUI(this); - - if (m_bDragDataAcceptable) - PasteEmbedded(*pDataObject, point); - - // update the document and views - GetDocument()->SetModifiedFlag(); - GetDocument()->UpdateAllViews(NULL, 0, NULL); // including this view - - return TRUE; -} - -void CDrawView::OnDragLeave() -{ - CClientDC dc(this); - if (m_prevDropEffect != DROPEFFECT_NONE) - { - dc.DrawFocusRect(CRect(m_dragPoint,m_dragSize)); // erase previous focus rect - m_prevDropEffect = DROPEFFECT_NONE; - } -} - -void CDrawView::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - // make sure window is active - GetParentFrame()->ActivateFrame(); - - CPoint local = point; - ScreenToClient(&local); - ClientToDoc(local); - - CDrawObj* pObj; - pObj = GetDocument()->ObjectAt(local); - if (pObj != NULL) - { - if (!IsSelected(pObj)) - Select( pObj, FALSE ); // reselect item if appropriate - UpdateWindow(); - - CMenu menu; - if (menu.LoadMenu(ID_POPUP_MENU)) - { - CMenu* pPopup = menu.GetSubMenu(0); - ENSURE(pPopup != NULL); - - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->SetAutoDestroy(FALSE); - pPopupMenu->Create(this, point.x, point.y, pPopup->GetSafeHmenu()); - } - } -} - -void CDrawView::OnPrint(CDC* pDC, CPrintInfo* pInfo) -{ - if (pInfo->m_bPreview == FALSE) - ((CDrawDoc*)GetDocument())->m_pSummInfo->RecordPrintDate(); - OnDraw(pDC); -} - -void CDrawView::OnFilePrintPreview() -{ - COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); - if (pActiveItem != NULL && pActiveItem->GetItemState() == COleClientItem::activeUIState) - { - pActiveItem->Deactivate(); - } - - AFXPrintPreview(this); -} - -class CDrawObjFriend: public CDrawObj -{ - friend struct CDrawView::XPreviewStateItem; -}; - -void CDrawView::XPreviewStateItem::Store(const CDrawObj& rObj) -{ - const CDrawObjFriend* pMyObj = (CDrawObjFriend*)(&rObj); - - m_bPen = pMyObj->m_bPen; - memcpy(&m_logpen, &pMyObj->m_logpen, sizeof(LOGPEN)); - m_bBrush = pMyObj->m_bBrush; - memcpy(&m_logbrush, &pMyObj->m_logbrush, sizeof(LOGBRUSH)); -} - -void CDrawView::XPreviewStateItem::Restore(CDrawObj& rObj) const -{ - CDrawObjFriend* pMyObj = (CDrawObjFriend*)(&rObj); - - pMyObj->m_bPen = m_bPen; - memcpy(&pMyObj->m_logpen, &m_logpen, sizeof(LOGPEN)); - pMyObj->m_bBrush = m_bBrush; - memcpy(&pMyObj->m_logbrush, &m_logbrush, sizeof(LOGBRUSH)); -} - -void CDrawView::StorePreviewState() -{ - if (m_PreviewState.GetSize() > 0) - { - return; - } - - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj != NULL) - { - m_PreviewState.Add(new XPreviewStateItem(*pObj)); - } - } -} - -void CDrawView::RestorePreviewState(BOOL bReset) -{ - if (m_PreviewState.GetSize() == 0) - { - return; - } - - int index = 0; - - POSITION pos = m_selection.GetHeadPosition(); - while (pos != NULL) - { - CDrawObj* pObj = m_selection.GetNext(pos); - if (pObj != NULL) - { - m_PreviewState[index]->Restore(*pObj); - } - - index++; - } - - if (bReset) - { - ResetPreviewState(); - } - - Invalidate(); -} - -void CDrawView::ResetPreviewState() -{ - if (m_PreviewState.GetSize() == 0) - { - return; - } - - for (int i = 0; i < m_PreviewState.GetSize(); i++) - { - delete m_PreviewState[i]; - } - - m_PreviewState.RemoveAll(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawvw.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawvw.h deleted file mode 100644 index ba49996c43f7a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/drawvw.h +++ /dev/null @@ -1,203 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -// Hints for UpdateAllViews/OnUpdate -#define HINT_UPDATE_WINDOW 0 -#define HINT_UPDATE_DRAWOBJ 1 -#define HINT_UPDATE_SELECTION 2 -#define HINT_DELETE_SELECTION 3 -#define HINT_UPDATE_OLE_ITEMS 4 - -class CDrawObj; - -class CDrawView : public CScrollView -{ - friend class CDrawObjFriend; - -protected: // create from serialization only - CDrawView(); - DECLARE_DYNCREATE(CDrawView) - -// Attributes -public: - CDrawDoc* GetDocument() - { return(CDrawDoc*)m_pDocument; } - void SetPageSize(CSize size); - CRect GetInitialPosition(); - -// Operations -public: - void DocToClient(CRect& rect); - void DocToClient(CPoint& point); - void ClientToDoc(CPoint& point); - void ClientToDoc(CRect& rect); - void Select(CDrawObj* pObj, BOOL bAdd = FALSE); - void SelectWithinRect(CRect rect, BOOL bAdd = FALSE); - void Deselect(CDrawObj* pObj); - void CloneSelection(); - void UpdateActiveItem(); - void InvalObj(CDrawObj* pObj); - void Remove(CDrawObj* pObj); - void PasteNative(COleDataObject& dataObject); - void PasteEmbedded(COleDataObject& dataObject, CPoint point ); - - void PreviewFillColor(COLORREF color); - void PreviewLineColor(COLORREF color); - void PreviewLineWeight(int nWeight); - - void PreviewStyle(COLORREF clrFill, COLORREF clrLine); - - void StorePreviewState(); - void RestorePreviewState(BOOL bReset = TRUE); - void ResetPreviewState(); - -// Implementation -protected: - // added for drop-target functionality - COleDropTarget m_dropTarget; // for drop target functionality - CPoint m_dragPoint; // current position - CSize m_dragSize; // size of dragged object - CSize m_dragOffset; // offset between pt and drag object corner - DROPEFFECT m_prevDropEffect; - BOOL m_bDragDataAcceptable; - - BOOL GetObjectInfo(COleDataObject* pDataObject, CSize* pSize, CSize* pOffset); - // end of drop-target additions - - struct XPreviewStateItem - { - BOOL m_bPen; - LOGPEN m_logpen; - BOOL m_bBrush; - LOGBRUSH m_logbrush; - - XPreviewStateItem(const CDrawObj& rObj) - { - Store(rObj); - } - - void Store(const CDrawObj& rObj); - void Restore(CDrawObj& rObj) const; - }; - typedef CArray XPreviewState; - - XPreviewState m_PreviewState; - -public: - virtual ~CDrawView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - - virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); // overriden to record time/date - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual void OnActivateView(BOOL bActivate, CView* pActiveView, CView* pDeactiveView); - virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); - virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo); - virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll); - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - void DrawGrid(CDC* pDC); - - // added for drop-target functionality - virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point); - virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD grfKeyState, CPoint point); - virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD grfKeyState, CPoint point); - virtual void OnDragLeave(); - static CLIPFORMAT m_cfObjectDescriptor; - // end of drop-target additions - - static CLIPFORMAT m_cfDraw; // custom clipboard format - - CDrawObjList m_selection; - BOOL m_bGrid; - COLORREF m_gridColor; - BOOL m_bActive; // is the view active? - -protected: - virtual void OnInitialUpdate(); // called first time after construct - - // Printing support - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - - // OLE Container support -public: - virtual BOOL IsSelected(const CObject* pDocItem) const; - -protected: - //{{AFX_MSG(CDrawView) - afx_msg void OnInsertObject(); - afx_msg void OnCancelEdit(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); - afx_msg void OnDrawSelect(); - afx_msg void OnDrawRoundRect(); - afx_msg void OnDrawRect(); - afx_msg void OnDrawLine(); - afx_msg void OnDrawEllipse(); - afx_msg void OnUpdateDrawEllipse(CCmdUI* pCmdUI); - afx_msg void OnUpdateDrawLine(CCmdUI* pCmdUI); - afx_msg void OnUpdateDrawRect(CCmdUI* pCmdUI); - afx_msg void OnUpdateDrawRoundRect(CCmdUI* pCmdUI); - afx_msg void OnUpdateDrawSelect(CCmdUI* pCmdUI); - afx_msg void OnUpdateSingleSelect(CCmdUI* pCmdUI); - afx_msg void OnEditSelectAll(); - afx_msg void OnEditClear(); - afx_msg void OnUpdateAnySelect(CCmdUI* pCmdUI); - afx_msg void OnDrawPolygon(); - afx_msg void OnUpdateDrawPolygon(CCmdUI* pCmdUI); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnViewGrid(); - afx_msg void OnUpdateViewGrid(CCmdUI* pCmdUI); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnObjectFillColor(); - afx_msg void OnUpdateObjectFillColor(CCmdUI* pCmdUI); - afx_msg void OnObjectNoFill(); - afx_msg void OnUpdateObjectNoFill(CCmdUI* pCmdUI); - afx_msg void OnObjectLineColor(); - afx_msg void OnUpdateObjectLineColor(CCmdUI* pCmdUI); - afx_msg void OnObjectNoLine(); - afx_msg void OnUpdateObjectNoLine(CCmdUI* pCmdUI); - afx_msg void OnObjectLineWeight(UINT nID); - afx_msg void OnUpdateObjectLineWeight(CCmdUI* pCmdUI); - afx_msg void OnObjectProperties(); - afx_msg void OnUpdateObjectProperties(CCmdUI* pCmdUI); - afx_msg void OnObjectStyles(); - afx_msg void OnUpdateObjectStyles(CCmdUI* pCmdUI); - afx_msg void OnObjectMoveBack(); - afx_msg void OnObjectMoveForward(); - afx_msg void OnObjectMoveToBack(); - afx_msg void OnObjectMoveToFront(); - afx_msg void OnEditCopy(); - afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI); - afx_msg void OnEditCut(); - afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI); - afx_msg void OnEditPaste(); - afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI); - afx_msg void OnFilePrint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnViewShowObjects(); - afx_msg void OnUpdateViewShowObjects(CCmdUI* pCmdUI); - afx_msg void OnDestroy(); - afx_msg void OnUpdateEditSelectAll(CCmdUI* pCmdUI); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnFilePrintPreview(); - afx_msg void OnUpdateSelection(CCmdUI* pCmdUI); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() - -private: - COLORREF GetColorFromColorButton(int nButtonID); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/mainfrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/mainfrm.cpp deleted file mode 100644 index 3110174f9460d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/mainfrm.cpp +++ /dev/null @@ -1,1158 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" - -#include "mainfrm.h" -#include "drawdoc.h" -#include "drawvw.h" - -#include "RibbonListButton.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -static int g_nSelectedObjectGroupIndex = 0; -static int g_nMaxLineWeight = 20; - -static const CMainFrame::XStyle c_Styles[] = -{ - {RGB( 64, 64, 64), RGB( 0, 0, 0)}, - {RGB( 85, 140, 205), RGB( 61, 97, 140)}, - {RGB(207, 86, 82), RGB(143, 61, 59)}, - {RGB(168, 203, 96), RGB(116, 141, 66)}, - {RGB(145, 113, 184), RGB( 97, 77, 121)}, - {RGB( 77, 179, 206), RGB( 56, 129, 149)}, - {RGB(249, 151, 70), RGB(212, 107, 22)}, - {RGB( 0, 0, 0), (COLORREF)-1}, - {RGB( 78, 128, 188), (COLORREF)-1}, - {RGB(191, 79, 76), (COLORREF)-1}, - {RGB(154, 186, 88), (COLORREF)-1}, - {RGB(127, 99, 161), (COLORREF)-1}, - {RGB( 74, 171, 197), (COLORREF)-1}, - {RGB(246, 149, 69), (COLORREF)-1}, - {(COLORREF)-1, RGB( 0, 0, 0)}, - {(COLORREF)-1, RGB( 78, 128, 188)}, - {(COLORREF)-1, RGB(191, 79, 76)}, - {(COLORREF)-1, RGB(154, 186, 88)}, - {(COLORREF)-1, RGB(127, 99, 161)}, - {(COLORREF)-1, RGB( 74, 171, 197)}, - {(COLORREF)-1, RGB(246, 149, 69)}, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) - //{{AFX_MSG_MAP(CMainFrame) - ON_WM_CREATE() - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2007, ID_VIEW_APPLOOK_2007_3, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2007, ID_VIEW_APPLOOK_2007_3, OnUpdateAppLook) - ON_COMMAND(ID_WINDOW_MANAGER, OnWindowManager) - ON_COMMAND(ID_MDI_MOVE_TO_NEXT_GROUP, OnMdiMoveToNextGroup) - ON_COMMAND(ID_MDI_MOVE_TO_PREV_GROUP, OnMdiMoveToPrevGroup) - ON_COMMAND(ID_MDI_NEW_HORZ_TAB_GROUP, OnMdiNewHorzTabGroup) - ON_COMMAND(ID_MDI_NEW_VERT_GROUP, OnMdiNewVertGroup) - ON_COMMAND(ID_MDI_CANCEL, OnMdiCancel) - ON_REGISTERED_MESSAGE(AFX_WM_ON_RIBBON_CUSTOMIZE, OnRibbonCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_ON_HIGHLIGHT_RIBBON_LIST_ITEM, OnHighlightRibbonListItem) - ON_COMMAND(ID_WINDOWS_MENU,OnDummy) - ON_COMMAND(ID_TOOLS_OPTIONS, OnToolsOptions) - ON_WM_SYSCOLORCHANGE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_2007); -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - OnAppLook(m_nAppLook); - - if (!CreateRibbonBar()) - { - TRACE0("Failed to create ribbon bar\n"); - return -1; // fail to create - } - - if (!CreateStatusBar()) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - // Enable windows manager: - EnableWindowsDialog(ID_WINDOW_MANAGER, _T("&Windows..."), TRUE); - - return 0; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers and overrides - -void CMainFrame::OnAppLook(UINT id) -{ - CDockingManager::SetDockingMode(DT_SMART); - - m_nAppLook = id; - - CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2007: - case ID_VIEW_APPLOOK_2007_1: - case ID_VIEW_APPLOOK_2007_2: - case ID_VIEW_APPLOOK_2007_3: - // enable Office 2007 look: - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2007: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case ID_VIEW_APPLOOK_2007_1: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case ID_VIEW_APPLOOK_2007_2: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); - break; - - case ID_VIEW_APPLOOK_2007_3: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - } - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); - - CDockingManager::SetDockingMode(DT_SMART); - break; - } - - CMDITabInfo mdiTabParams; - - mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_VS2005; - mdiTabParams.m_bAutoColor = TRUE; - mdiTabParams.m_bDocumentMenu = TRUE; - mdiTabParams.m_bActiveTabCloseButton = TRUE; - - EnableMDITabbedGroups(TRUE, mdiTabParams); - - CDockingManager* pDockManager = GetDockingManager(); - if (pDockManager != NULL) - { - ASSERT_VALID(pDockManager); - pDockManager->AdjustPaneFrames(); - } - - CTabbedPane::ResetTabs(); - - RecalcLayout(); - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - theApp.WriteInt(_T("ApplicationLook"), m_nAppLook); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(m_nAppLook == pCmdUI->m_nID); -} - -void CMainFrame::OnWindowManager() -{ - ShowWindowsDialog(); -} - -LRESULT CMainFrame::OnRibbonCustomize(WPARAM /*wp*/, LPARAM /*lp*/) -{ - ShowOptions(0); - return 1; -} - -void CMainFrame::OnToolsOptions() -{ - ShowOptions(0); -} - -BOOL CMainFrame::OnShowMDITabContextMenu(CPoint point, DWORD dwAllowedItems, BOOL bDrop) -{ - CMenu menu; - VERIFY(menu.LoadMenu(bDrop ? IDR_POPUP_DROP_MDITABS : IDR_POPUP_MDITABS)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if ((dwAllowedItems & AFX_MDI_CREATE_HORZ_GROUP) == 0) - { - pPopup->DeleteMenu(ID_MDI_NEW_HORZ_TAB_GROUP, MF_BYCOMMAND); - } - - if ((dwAllowedItems & AFX_MDI_CREATE_VERT_GROUP) == 0) - { - pPopup->DeleteMenu(ID_MDI_NEW_VERT_GROUP, MF_BYCOMMAND); - } - - if ((dwAllowedItems & AFX_MDI_CAN_MOVE_NEXT) == 0) - { - pPopup->DeleteMenu(ID_MDI_MOVE_TO_NEXT_GROUP, MF_BYCOMMAND); - } - - if ((dwAllowedItems & AFX_MDI_CAN_MOVE_PREV) == 0) - { - pPopup->DeleteMenu(ID_MDI_MOVE_TO_PREV_GROUP, MF_BYCOMMAND); - } - - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->SetAutoDestroy(FALSE); - pPopupMenu->Create(this, point.x, point.y, pPopup->GetSafeHmenu()); - - return TRUE; -} - -void CMainFrame::OnMdiMoveToNextGroup() -{ - MDITabMoveToNextGroup(); -} - -void CMainFrame::OnMdiMoveToPrevGroup() -{ - MDITabMoveToNextGroup(FALSE); -} - -void CMainFrame::OnMdiNewHorzTabGroup() -{ - MDITabNewGroup(FALSE); -} - -void CMainFrame::OnMdiNewVertGroup() -{ - MDITabNewGroup(); -} - -void CMainFrame::OnMdiCancel() -{ - // TODO: Add your command handler code here - -} -BOOL CMainFrame::OnShowPopupMenu(CMFCPopupMenu* pMenuPopup) -{ - BOOL bRes = CMDIFrameWndEx::OnShowPopupMenu(pMenuPopup); - - if (pMenuPopup != NULL && !pMenuPopup->IsCustomizePane()) - { - AdjustObjectSubmenu(pMenuPopup); - } - - return bRes; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame helpers -BOOL CMainFrame::CreateRibbonBar() -{ - if (!m_wndRibbonBar.Create(this)) - { - return FALSE; - } - - // Load panel images: - m_PanelImages.SetImageSize(CSize(16, 16)); - m_PanelImages.Load(IDB_RIBBON_ICONS); - - // Init main button: - InitMainButton(); - - InitHomeCategory(); - InitViewCategory(); - InitTabButtons(); - - AddContextTab_Format(); - - // Init QAT state - // Add quick access toolbar commands: - CMFCRibbonQuickAccessToolBarDefaultState qatState; - - qatState.AddCommand(ID_FILE_NEW, FALSE); - qatState.AddCommand(ID_FILE_OPEN, FALSE); - qatState.AddCommand(ID_FILE_SAVE); - qatState.AddCommand(ID_FILE_PRINT_DIRECT); - qatState.AddCommand(ID_FILE_PRINT_PREVIEW, FALSE); - qatState.AddCommand(ID_EDIT_UNDO); - - // Set the state - m_wndRibbonBar.SetQuickAccessDefaultState(qatState); - - return TRUE; -} - -BOOL CMainFrame::CreateStatusBar() -{ - if (!m_wndStatusBar.Create(this)) - { - return FALSE; - } - - m_wndStatusBar.AddElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE_OBJECTCOUNT, _T("Object Count: None"), TRUE), _T("Object Count: None")); - - m_wndStatusBar.AddElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE_SELECTEDOBJECTCOUNT, _T("Selected Count: None"), TRUE), _T("Selected Count: None")); - - { - // - CMFCRibbonButtonsGroup* pSBGroup = new CMFCRibbonButtonsGroup; - - CMFCToolBarImages images; - images.SetImageSize(CSize(14, 14)); - - CMFCToolBarImages hotimages; - hotimages.SetImageSize(CSize(14, 14)); - - if (images.Load(IDB_STATUSBAR_1) && hotimages.Load(IDB_STATUSBAR_2)) - { - pSBGroup->SetImages(&images, &hotimages, NULL); - } - - pSBGroup->AddButton(new CMFCRibbonButton(ID_FILE_PRINT_PREVIEW, _T(""), 0)); - pSBGroup->AddButton(new CMFCRibbonButton(ID_FILE_SUMMARYINFO, _T(""), 1)); - - // CMFCRibbonStatusBar m_wndStatusBar - m_wndStatusBar.AddExtendedElement(pSBGroup, _T("View Shortcuts")); - // - } - - { - CMFCRibbonButtonsGroup* pSBGroup = new CMFCRibbonButtonsGroup; - - CMFCToolBarImages images; - images.SetImageSize(CSize(14, 14)); - if (images.Load(IDB_STATUSBAR_2)) - { - pSBGroup->SetImages(&images, NULL, NULL); - } - - pSBGroup->AddButton(new CMFCRibbonButton(ID_VIEW_GRID, _T(""), 0)); - pSBGroup->AddButton(new CMFCRibbonButton(ID_VIEW_SHOWOBJECTS, _T(""), 1)); - - m_wndStatusBar.AddExtendedElement(pSBGroup, _T("View Shortcuts")); - } - - return TRUE; -} - -void CMainFrame::InitMainButton() -{ - // - m_MainButton.SetImage(IDB_RIBBON_MAIN); - m_MainButton.SetToolTipText(_T("File")); - // Set the short cut keyboard text. - m_MainButton.SetText(_T("f")); - // - - m_wndRibbonBar.SetApplicationButton(&m_MainButton, CSize(45, 45)); - - CMFCRibbonMainPanel* pMainPanel = m_wndRibbonBar.AddMainCategory(_T("File"), IDB_RIBBON_FILESMALL, IDB_RIBBON_FILELARGE); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_NEW, _T("&New"), 0, 0)); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_OPEN, _T("&Open..."), 1, 1)); - - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SAVE, _T("&Save"), 2, 2)); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SAVE_AS, _T("Save &As..."), 3, 3)); - - CMFCRibbonButton* pBtnPrint = new CMFCRibbonButton(ID_FILE_PRINT, _T("&Print"), 4, 4); - - pBtnPrint->AddSubItem(new CMFCRibbonLabel(_T("Preview and print the document"))); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_DIRECT, _T("&Quick Print"), 7, 7, TRUE)); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_PREVIEW, _T("Print Pre&view"), 6, 6, TRUE)); - - pBtnPrint->SetKeys(_T("p"), _T("w")); - pMainPanel->Add(pBtnPrint); - - pMainPanel->AddSeparator(); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SEND_MAIL, _T("Sen&d..."), 8, 8)); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SUMMARYINFO, _T("Summary &Info..."), 9, 9)); - - pMainPanel->AddSeparator(); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_CLOSE, _T("&Close"), 5, 5)); - - pMainPanel->AddRecentFilesList(_T("Recent Documents")); - pMainPanel->AddToBottom(new CMFCRibbonMainPanelButton(ID_TOOLS_OPTIONS, _T("Opt&ions"), 10)); - pMainPanel->AddToBottom(new CMFCRibbonMainPanelButton(ID_APP_EXIT, _T("E&xit"), 11)); -} - -void CMainFrame::InitHomeCategory() -{ - CreateDocumentColors(); - - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Home"), IDB_RIBBON_HOMESMALL, IDB_RIBBON_HOMELARGE); - - // Create "Clipboard" panel: - CMFCRibbonPanel* pPanelClipboard = pCategory->AddPanel(_T("Clipboard\nzc"), m_PanelImages.ExtractIcon(0)); - - CMFCRibbonButton* pBtnPaste = new CMFCRibbonButton(ID_EDIT_PASTE, _T("Paste\nv"), 0, 0); - pPanelClipboard->Add(pBtnPaste); - - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_CUT, _T("Cut\nx"), 1)); - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_COPY, _T("Copy\nc"), 2)); - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_CLEAR, _T("Delete\nt"), 3)); - - // Create "Operations" panel - CMFCRibbonPanel* pPanelOperations = pCategory->AddPanel(_T("Operations\nzo"), m_PanelImages.ExtractIcon(1)); - - // - // Create the "Paper Color" button - CMFCRibbonColorButton* pBtnPaperColor = new CMFCRibbonColorButton(ID_VIEW_PAPERCOLOR, _T("Paper Color\ng"), TRUE, 13, 1); - pBtnPaperColor->SetAlwaysLargeImage(); - pBtnPaperColor->EnableAutomaticButton(_T("&Automatic"), RGB(255, 255, 255)); - pBtnPaperColor->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); - pBtnPaperColor->SetColumns(10); - pBtnPaperColor->SetColorBoxSize(CSize(17, 17)); - // CList m_lstMainColors - pBtnPaperColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors, TRUE); - // CList m_lstAdditionalColors - pBtnPaperColor->AddColorsGroup(_T(""), m_lstAdditionalColors, FALSE); - // CList m_lstStandardColors - pBtnPaperColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors, TRUE); - CList lstColors; - lstColors.AddTail(RGB(255,0,0)); - lstColors.AddTail(RGB(0,255,0)); - lstColors.AddTail(RGB(0,0,255)); - pBtnPaperColor->SetDocumentColors( _T("Document Colors"), lstColors ); - // - - pPanelOperations->Add(pBtnPaperColor); - - pPanelOperations->Add(new CMFCRibbonButton(ID_EDIT_SELECT_ALL, _T("Select All\na"), 4)); - pPanelOperations->Add(new CMFCRibbonButton(ID_OLE_INSERT_NEW, _T("New Object...\no"), 5)); - pPanelOperations->Add(new CMFCRibbonButton(ID_OLE_EDIT_LINKS, _T("Links...\ni"), 6)); - - // Create "Draw" panel - CMFCRibbonPanel* pPanelDraw = pCategory->AddPanel(_T("Draw\nzd"), m_PanelImages.ExtractIcon(2)); - - pPanelDraw->Add(new CMFCRibbonButton(ID_DRAW_SELECT, _T("Select\ns"), 7)); - pPanelDraw->Add(new CMFCRibbonButton(ID_DRAW_LINE, _T("Line\nl"), 8)); - pPanelDraw->Add(new CMFCRibbonButton(ID_DRAW_RECT, _T("Rectangle\nr"), 9)); - pPanelDraw->Add(new CMFCRibbonButton(ID_DRAW_ROUNDRECT, _T("Round Rectangle\nn"), 10)); - pPanelDraw->Add(new CMFCRibbonButton(ID_DRAW_ELLIPSE, _T("Ellipse\ne"), 11)); - pPanelDraw->Add(new CMFCRibbonButton(ID_DRAW_POLYGON, _T("Polygon\ny"), 12)); - - // Create "Arrange" panel - CMFCRibbonPanel* pPanelArrange = pCategory->AddPanel(_T("Arrange\nzj"), m_PanelImages.ExtractIcon(3)); - - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOFRONT, _T("Move to Front\nmf"), 15, 3)); - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEFORWARD, _T("Move Forward\nmw"), 17, 5)); - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEBACK, _T("Move Backward\nmd"), 18, 6)); - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOBACK, _T("Move to Back\nmb"), 16, 4)); - - // Add not-in-ribbon commands - CMFCRibbonButton* pUndo = new CMFCRibbonButton(ID_EDIT_UNDO, _T("Undo"), 20); - pCategory->AddHidden(pUndo); -} - -void CMainFrame::InitViewCategory() -{ - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&View"), IDB_RIBBON_VIEWSMALL, IDB_RIBBON_VIEWLARGE); - - // Create "Show/Hide" panel: - CMFCRibbonPanel* pPanelShow = pCategory->AddPanel(_T("Show/Hide\nzs"), m_PanelImages.ExtractIcon(4)); - - pPanelShow->Add(new CMFCRibbonCheckBox(ID_VIEW_GRID, _T("Grid Lines\ng"))); - pPanelShow->Add(new CMFCRibbonCheckBox(ID_VIEW_SHOWOBJECTS, _T("Show Objects\ns"))); - - // Create "Window" panel: - CMFCRibbonPanel* pPanelWindow = pCategory->AddPanel(_T("Window\nzw"), m_PanelImages.ExtractIcon(5)); - - pPanelWindow->Add(new CMFCRibbonButton(ID_WINDOW_NEW, _T("New Window\nn"), 0, 0)); - - CMFCRibbonButton* pBtnWindows = new CMFCRibbonButton(ID_WINDOWS_MENU, _T("Switch Windows\ns"), 1, 1); - pBtnWindows->SetMenu(IDR_WINDOWS_MENU, TRUE); - pBtnWindows->SetDefaultCommand(FALSE); - pPanelWindow->Add(pBtnWindows); -} - -void CMainFrame::InitTabButtons() -{ - // Add "Style" button to the right of tabs: - CMFCRibbonButton* pStyleButton = new CMFCRibbonButton((UINT) -1, _T("Style\ns")); - pStyleButton->SetMenu(IDR_THEME_MENU, TRUE /* Right align */); - - m_wndRibbonBar.AddToTabs(pStyleButton); - - // Add "About" button to the right of tabs: - m_wndRibbonBar.AddToTabs(new CMFCRibbonButton(ID_APP_ABOUT, _T("\na"), m_PanelImages.ExtractIcon(6))); - -} - -void CMainFrame::AddContextTab_Format() -{ - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddContextCategory(_T("Format"), _T("Drawing tools"), ID_FORMAT_CONTEXT_TAB, AFX_CategoryColor_Orange, IDB_RIBBON_FORMATSMALL, IDB_RIBBON_FORMATLARGE); - pCategory->SetKeys(_T("jd")); - - // Create "Styles" panel - CMFCRibbonPanel* pPanelStyles = pCategory->AddPanel(_T("Styles\nzs"), m_PanelImages.ExtractIcon(8)); - - // - CMFCRibbonGallery* pBtnStyles = new CMFCRibbonGallery(ID_OBJECT_STYLES, _T("Styles\nk"), 0, 0, IDB_STYLES, 40); - pBtnStyles->SetIconsInRow(7); - pBtnStyles->EnableMenuResize(TRUE, TRUE); - pBtnStyles->EnableMenuSideBar(); - pBtnStyles->SetButtonMode(false); - pBtnStyles->RedrawIcons(); - // - - pPanelStyles->Add(pBtnStyles); - - CMFCRibbonColorButton* pBtnFillColor = new CMFCRibbonColorButton(ID_OBJECT_FILLCOLOR, _T("Fill Color\nsf"), FALSE, 1, -1); - pBtnFillColor->SetDefaultCommand(FALSE); - pBtnFillColor->EnableAutomaticButton(_T("&Automatic"), RGB(128, 128, 128)); - pBtnFillColor->EnableOtherButton(_T("&More Fill Colors..."), _T("More Fill Colors")); - pBtnFillColor->SetColumns(10); - pBtnFillColor->SetColorBoxSize(CSize(17, 17)); - pBtnFillColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); - pBtnFillColor->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); - pBtnFillColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); - pBtnFillColor->AddSubItem(new CMFCRibbonButton(ID_OBJECT_NOFILL, _T("&No Fill\nn"), 2)); - pBtnFillColor->SetColor((COLORREF)-1); - pPanelStyles->Add(pBtnFillColor); - - CMFCRibbonColorButton* pBtnLineColor = new CMFCRibbonColorButton(ID_OBJECT_LINECOLOR, _T("Line Color\nso"), FALSE, 3, -1); - pBtnLineColor->SetDefaultCommand(FALSE); - pBtnLineColor->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); - pBtnLineColor->EnableOtherButton(_T("&More Line Colors..."), _T("More Line Colors")); - pBtnLineColor->SetColumns(10); - pBtnLineColor->SetColorBoxSize(CSize(17, 17)); - pBtnLineColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); - pBtnLineColor->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); - pBtnLineColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); - pBtnLineColor->AddSubItem(new CMFCRibbonButton(ID_OBJECT_NOLINE, _T("&No Line\nn"), 2)); - pBtnLineColor->SetColor((COLORREF)-1); - pPanelStyles->Add(pBtnLineColor); - - CStringArray sa; - sa.Add(_T("1 pt")); - sa.Add(_T("2 pt")); - sa.Add(_T("3 pt")); - sa.Add(_T("4 pt")); - sa.Add(_T("5 pt")); - sa.Add(_T("6 pt")); - sa.Add(_T("7 pt")); - CRibbonListButton* pBtnLineWeight = new CRibbonListButton(ID_OBJECT_LINEWEIGHT, _T("Line Weight\nsw"), 4, -1, IDB_LINEWEIGHT, 96, sa); - pBtnLineWeight->AddSubItem(new CMFCRibbonButton(ID_OBJECT_LINEWEIGHT_MORE, _T("More &Lines..."), 5, -1)); - pBtnLineWeight->EnableMenuResize(TRUE, TRUE); // Vertical only - pPanelStyles->Add(pBtnLineWeight); - - // Create "Arrange" panel - CMFCRibbonPanel* pPanelArrange = pCategory->AddPanel(_T("Arrange\nzj"), m_PanelImages.ExtractIcon(3)); - - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOFRONT, _T("Move to Front\nmf"), 7, 1)); - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEFORWARD, _T("Move Forward\nmw"), 9, 3)); - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEBACK, _T("Move Backward\nmd"), 10, 4)); - pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOBACK, _T("Move to Back\nmb"), 8, 2)); -} - -void CMainFrame::AdjustObjectSubmenu(CMFCPopupMenu* pMenuPopup) -{ - ASSERT(pMenuPopup != NULL); - - if (pMenuPopup->GetParentPopupMenu() != NULL) - { - return; - } - - // - // CMFCPopupMenu* pMenuPopup - CMFCPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar(); - // - ASSERT(pMenuBar != NULL); - - // - // CMFCPopupMenuBar* pMenuBar - CMFCCustomizeMenuButton* pBtn = (CMFCCustomizeMenuButton*)pMenuBar->GetButton(0); - pBtn->EnableCustomization(true); - pBtn->SetSeparator(); - // - - - int iIndex = pMenuBar->CommandToIndex(ID_OLE_VERB_FIRST); - if (iIndex < 0) - { - return; - } - - CFrameWnd* pFrame = GetActiveFrame(); - - if (pFrame == NULL) - { - return; - } - - CDrawDoc* pDoc = (CDrawDoc*)pFrame->GetActiveDocument(); - ASSERT_VALID(pDoc); - - // check for single selection - COleClientItem* pItem = pDoc->GetPrimarySelectedItem(pFrame->GetActiveView()); - if (pItem == NULL || pItem->GetType() == OT_STATIC) - { - // no selection, or is 'static' item - return; - } - - // only include Convert... if there is a handler for ID_OLE_EDIT_CONVERT - UINT nConvertID = ID_OLE_EDIT_CONVERT; - AFX_CMDHANDLERINFO info; - if (!pDoc->OnCmdMsg(ID_OLE_EDIT_CONVERT, CN_COMMAND, NULL, &info)) - nConvertID = 0; - - HMENU hMenu = pMenuBar->ExportToMenu(); - ASSERT(hMenu != NULL); - - // update the menu - AfxOleSetEditMenu(pItem, CMenu::FromHandle(hMenu), iIndex, ID_OLE_VERB_FIRST, ID_OLE_VERB_LAST, nConvertID); - - pMenuBar->ImportFromMenu(hMenu); - ::DestroyMenu(hMenu); -} - -void CMainFrame::ShowOptions(int nPage) -{ - // Create "Customize" page: - CMFCRibbonCustomizePropertyPage pageCustomize(&m_wndRibbonBar); - - // Add "popular" items: - CList lstPopular; - - lstPopular.AddTail(ID_FILE_NEW); - lstPopular.AddTail(ID_FILE_OPEN); - lstPopular.AddTail(ID_FILE_SAVE); - lstPopular.AddTail(ID_FILE_PRINT_PREVIEW); - lstPopular.AddTail(ID_FILE_PRINT_DIRECT); - lstPopular.AddTail(ID_EDIT_UNDO); - - pageCustomize.AddCustomCategory(_T("Popular Commands"), lstPopular); - - // Add hidden commands: - CList lstHidden; - m_wndRibbonBar.GetItemIDsList(lstHidden, TRUE); - - pageCustomize.AddCustomCategory(_T("Commands not in the Ribbon"), lstHidden); - - // Add all commands: - CList lstAll; - m_wndRibbonBar.GetItemIDsList(lstAll); - - pageCustomize.AddCustomCategory(_T("All Commands"), lstAll); - - // Create property sheet: - CMFCPropertySheet propSheet(_T("Options"), this, nPage); - propSheet.m_psh.dwFlags |= PSH_NOAPPLYNOW; - - propSheet.SetLook(CMFCPropertySheet::PropSheetLook_List, 124 /* List width */); - - propSheet.AddPage(&pageCustomize); - - if (propSheet.DoModal() != IDOK) - { - return; - } -} - -void CMainFrame::UpdateUI(CDrawView* pCurrView) -{ - // Update Status Bar - CDrawDoc* pCurrDoc = pCurrView->GetDocument(); - UpdateStatusBarCountPane(ID_STATUSBAR_PANE_OBJECTCOUNT, _T("Object Count"), (int) pCurrDoc->GetObjects()->GetCount()); - UpdateStatusBarCountPane(ID_STATUSBAR_PANE_SELECTEDOBJECTCOUNT, _T("Selected Count"), (int) pCurrView->m_selection.GetCount()); - - m_wndStatusBar.Invalidate(); - m_wndStatusBar.UpdateWindow(); -} - -void CMainFrame::UpdateContextTab(CDrawView* pCurrView) -{ - bool bEnable = pCurrView->m_selection.GetCount() > 0; - - SetRibbonContextCategory(bEnable ? ID_FORMAT_CONTEXT_TAB : 0); - - if (bEnable) - { - UpdateContextTabFromObject(pCurrView->m_selection); - } -} - -void CMainFrame::UpdateStatusBarCountPane(int nID, CString strText, int nCount) -{ - // - // CMFCRibbonStatusBar m_wndStatusBar - CMFCRibbonBaseElement* pPane = m_wndStatusBar.FindByID(nID); - // - - if (pPane != NULL) - { - if (nCount == 0) - { - strText += _T(": None"); - } - else - { - CString strFormatted; - strFormatted.Format(_T(": %d"), nCount); - - strText += strFormatted; - } - - // - pPane->SetDescription(_T("a pane")); - // CString strText - pPane->SetText(strText); - pPane->SetKeys(_T("p")); - pPane->SetToolTipText(_T("this is a pane")); - // - } - -} - -void CMainFrame::UpdateContextTabFromObject(CDrawObjList& list) -{ - int count = (int) list.GetCount(); - if (count == 0) - { - return; - } - - COLORREF clrFill = (COLORREF)-1; - COLORREF clrLine = (COLORREF)-1; - int nLineWeight = -1; - if (count == 1) - { - CDrawObj* pObj = list.GetHead(); - if (pObj->CanChangeFillColor() && pObj->IsEnableFill()) - { - clrFill = pObj->GetFillColor(); - } - if (pObj->CanChangeLineColor() && pObj->IsEnableLine()) - { - clrLine = pObj->GetLineColor(); - } - if (pObj->CanChangeLineWeight() && pObj->IsEnableLine()) - { - nLineWeight = pObj->GetLineWeight() - 1; - } - } - - { - CArray arButtons; - m_wndRibbonBar.GetElementsByID(ID_OBJECT_FILLCOLOR, arButtons); - - if (arButtons.GetSize() > 0) - { - for (int i = 0; i < arButtons.GetSize(); i++) - { - CMFCRibbonColorButton* pButton = DYNAMIC_DOWNCAST - (CMFCRibbonColorButton, arButtons[i] - ); - pButton->SetColor(clrFill); - } - } - } - - { - CArray arButtons; - m_wndRibbonBar.GetElementsByID(ID_OBJECT_LINECOLOR, arButtons); - - if (arButtons.GetSize() > 0) - { - for (int i = 0; i < arButtons.GetSize(); i++) - { - CMFCRibbonColorButton* pButton = DYNAMIC_DOWNCAST - (CMFCRibbonColorButton, arButtons[i] - ); - pButton->SetColor(clrLine); - } - } - } - - { - CArray arButtons; - m_wndRibbonBar.GetElementsByID(ID_OBJECT_LINEWEIGHT, arButtons); - - if (arButtons.GetSize() > 0) - { - for (int i = 0; i < arButtons.GetSize(); i++) - { - CRibbonListButton* pButton = DYNAMIC_DOWNCAST - (CRibbonListButton, arButtons[i] - ); - pButton->SelectItem(nLineWeight); - } - } - } - - m_wndRibbonBar.RedrawWindow(); -} - -void CMainFrame::CreateDocumentColors() -{ - typedef struct - { - COLORREF color; - TCHAR* szName; - } - ColorTableEntry; - - int i = 0; - int nNumColours = 0; - - static ColorTableEntry colorsMain [] = - { - { RGB(255, 255, 255), _T("White, Background 1") }, - { RGB(0, 0, 0), _T("Black, Text 1") }, - { RGB(238, 236, 225), _T("Tan, Background 2") }, - { RGB(31, 73, 125), _T("Dark Blue, Text 2") }, - { RGB(79, 129, 189), _T("Blue, Accent 1") }, - { RGB(192, 80, 77), _T("Red, Accent 2") }, - { RGB(155, 187, 89), _T("Olive Green, Accent 3") }, - { RGB(128, 100, 162), _T("Purple, Accent 4") }, - { RGB(75, 172, 198), _T("Aqua, Accent 5") }, - { RGB(245, 150, 70), _T("Orange, Accent 6") } - }; - - static ColorTableEntry colorsAdditional [] = - { - { RGB(242, 242, 242), _T("White, Background 1, Darker 5%") }, - { RGB(127, 127, 127), _T("Black, Text 1, Lighter 50%") }, - { RGB(214, 212, 202), _T("Tan, Background 2, Darker 10%") }, - { RGB(210, 218, 229), _T("Dark Blue, Text 2, Lighter 80%") }, - { RGB(217, 228, 240), _T("Blue, Accent 1, Lighter 80%") }, - { RGB(244, 219, 218), _T("Red, Accent 2, Lighter 80%") }, - { RGB(234, 241, 221), _T("Olive Green, Accent 3, Lighter 80%")}, - { RGB(229, 223, 235), _T("Purple, Accent 4, Lighter 80%") }, - { RGB(216, 237, 242), _T("Aqua, Accent 5, Lighter 80%") }, - { RGB(255, 234, 218), _T("Orange, Accent 6, Lighter 80%") }, - { RGB(215, 215, 215), _T("White, Background 1, Darker 15%") }, - { RGB(89, 89, 89), _T("Black, Text 1, Lighter 35%") }, - { RGB(177, 176, 167), _T("Tan, Background 2, Darker 25%") }, - { RGB(161, 180, 201), _T("Dark Blue, Text 2, Lighter 60%") }, - { RGB(179, 202, 226), _T("Blue, Accent 1, Lighter 60%") }, - { RGB(233, 184, 182), _T("Red, Accent 2, Lighter 60%") }, - { RGB(213, 226, 188), _T("Olive Green, Accent 3, Lighter 60%")}, - { RGB(203, 191, 215), _T("Purple, Accent 4, Lighter 60%") }, - { RGB(176, 220, 231), _T("Aqua, Accent 5, Lighter 60%") }, - { RGB(255, 212, 181), _T("Orange, Accent 6, Lighter 60%") }, - { RGB(190, 190, 190), _T("White, Background 1, Darker 25%") }, - { RGB(65, 65, 65), _T("Black, Text 1, Lighter 25%") }, - { RGB(118, 117, 112), _T("Tan, Background 2, Darker 35%") }, - { RGB(115, 143, 175), _T("Dark Blue, Text 2, Lighter 40%") }, - { RGB(143, 177, 213), _T("Blue, Accent 1, Lighter 40%") }, - { RGB(222, 149, 147), _T("Red, Accent 2, Lighter 40%") }, - { RGB(192, 213, 155), _T("Olive Green, Accent 3, Lighter 40%")}, - { RGB(177, 160, 197), _T("Purple, Accent 4, Lighter 40%") }, - { RGB(137, 203, 218), _T("Aqua, Accent 5, Lighter 40%") }, - { RGB(255, 191, 145), _T("Orange, Accent 6, Lighter 40%") }, - { RGB(163, 163, 163), _T("White, Background 1, Darker 35%") }, - { RGB(42, 42, 42), _T("Black, Text 1, Lighter 15%") }, - { RGB(61, 61, 59), _T("Tan, Background 2, Darker 50%") }, - { RGB(20, 57, 92), _T("Dark Blue, Text 2, Darker 25%") }, - { RGB(54, 96, 139), _T("Blue, Accent 1, Darker 25%") }, - { RGB(149, 63, 60), _T("Red, Accent 2, Darker 25%") }, - { RGB(114, 139, 71), _T("Olive Green, Accent 3, Darker 25%") }, - { RGB(97, 76, 119), _T("Purple, Accent 4, Darker 25%") }, - { RGB(41, 128, 146), _T("Aqua, Accent 5, Darker 25%") }, - { RGB(190, 112, 59), _T("Orange, Accent 6, Darker 25%") }, - { RGB(126, 126, 126), _T("White, Background 1, Darker 50%") }, - { RGB(20, 20, 20), _T("Black, Text 1, Lighter 5%") }, - { RGB(29, 29, 28), _T("Tan, Background 2, Darker 90%") }, - { RGB(17, 40, 64), _T("Dark Blue, Text 2, Darker 50%") }, - { RGB(38, 66, 94), _T("Blue, Accent 1, Darker 50%") }, - { RGB(100, 44, 43), _T("Red, Accent 2, Darker 50%") }, - { RGB(77, 93, 49), _T("Olive Green, Accent 3, Darker 50%") }, - { RGB(67, 53, 81), _T("Purple, Accent 4, Darker 50%") }, - { RGB(31, 86, 99), _T("Aqua, Accent 5, Darker 50%") }, - { RGB(126, 77, 42), _T("Orange, Accent 6, Darker 50%") }, - }; - - static ColorTableEntry colorsStandard [] = - { - { RGB(200, 15, 18), _T("Dark Red") }, - { RGB(255, 20, 24), _T("Red") }, - { RGB(255, 191, 40), _T("Orange") }, - { RGB(255, 255, 49), _T("Yellow") }, - { RGB(138, 207, 87), _T("Light Green") }, - { RGB(0, 175, 84), _T("Green") }, - { RGB(0, 174, 238), _T("Light Blue") }, - { RGB(0, 111, 189), _T("Blue") }, - { RGB(0, 36, 95), _T("Black") }, - { RGB(114, 50, 157), _T("Purple") }, - }; - - m_lstMainColors.RemoveAll(); - nNumColours = sizeof(colorsMain) / sizeof(ColorTableEntry); - - for (i = 0; i < nNumColours; i++) - { - m_lstMainColors.AddTail(colorsMain [i].color); - CMFCRibbonColorButton::SetColorName(colorsMain [i].color, colorsMain [i].szName); - }; - - m_lstAdditionalColors.RemoveAll(); - nNumColours = sizeof(colorsAdditional) / sizeof(ColorTableEntry); - - for (i = 0; i < nNumColours; i++) - { - m_lstAdditionalColors.AddTail(colorsAdditional [i].color); - CMFCRibbonColorButton::SetColorName(colorsAdditional [i].color, colorsAdditional [i].szName); - }; - - m_lstStandardColors.RemoveAll(); - nNumColours = sizeof(colorsStandard) / sizeof(ColorTableEntry); - - for (i = 0; i < nNumColours; i++) - { - m_lstStandardColors.AddTail(colorsStandard [i].color); - CMFCRibbonColorButton::SetColorName(colorsStandard [i].color, colorsStandard [i].szName); - }; -} - -COLORREF CMainFrame::GetColorFromColorButton(int nButtonID) -{ - CArray arButtons; - - m_wndRibbonBar.GetElementsByID(nButtonID, arButtons); - - if (arButtons.GetSize() == 0) - { - return(COLORREF) -1; - } - - CMFCRibbonColorButton* pColorButton = (CMFCRibbonColorButton*)arButtons.GetAt(0); - - COLORREF clr = pColorButton->GetColor(); - if (clr == (COLORREF)-1) - { - clr = pColorButton->GetAutomaticColor(); - } - - return clr; -} - -int CMainFrame::GetWeightFromLineWeight(int nButtonID) -{ - CArray arButtons; - - m_wndRibbonBar.GetElementsByID(nButtonID, arButtons); - - if (arButtons.GetSize() == 0) - { - return -1; - } - - int weight = -1; - CMFCRibbonGallery* pBtn = DYNAMIC_DOWNCAST(CMFCRibbonGallery, arButtons.GetAt(0)); - if (pBtn != NULL && pBtn->GetSelectedItem() != -1) - { - weight = pBtn->GetSelectedItem() + 1; - } - - return weight; -} - -BOOL CMainFrame::GetStyleFromStyles(XStyle& style) -{ - CArray arButtons; - - m_wndRibbonBar.GetElementsByID(ID_OBJECT_STYLES, arButtons); - - if (arButtons.GetSize() == 0) - { - return FALSE; - } - - BOOL bRes = FALSE; - - CMFCRibbonGallery* pBtn = DYNAMIC_DOWNCAST(CMFCRibbonGallery, arButtons.GetAt(0)); - if (pBtn != NULL && pBtn->GetSelectedItem() != -1) - { - style = c_Styles[pBtn->GetSelectedItem()]; - bRes = TRUE; - } - - return bRes; -} - -void CMainFrame::OnDummy() -{ -} - -LRESULT CMainFrame::OnHighlightRibbonListItem(WPARAM wp, LPARAM lp) -{ - int nIndex = (int) wp; - - CMFCRibbonBaseElement* pElem = (CMFCRibbonBaseElement*) lp; - ASSERT_VALID(pElem); - - const UINT uiCommand = pElem->GetID(); - - CFrameWnd* pFrame = GetActiveFrame(); - if (pFrame == NULL) - { - return 0; - } - - CDrawDoc* pDoc = (CDrawDoc*)pFrame->GetActiveDocument(); - if (pDoc == NULL) - { - return 0; - } - - ASSERT_VALID(pDoc); - - CDrawView* pView = DYNAMIC_DOWNCAST(CDrawView, pFrame->GetActiveView()); - if (pView == NULL) - { - return 0; - } - - if (uiCommand != ID_VIEW_PAPERCOLOR) - { - if (nIndex != -1) - { - pView->StorePreviewState(); - } - else - { - pView->RestorePreviewState(); - } - } - - switch (uiCommand) - { - case ID_VIEW_PAPERCOLOR: - case ID_OBJECT_FILLCOLOR: - case ID_OBJECT_LINECOLOR: - { - COLORREF color = ((CMFCRibbonColorButton*) pElem)->GetHighlightedColor(); - - if (uiCommand == ID_VIEW_PAPERCOLOR) - { - pDoc->SetPreviewColor(color); - } - else if (nIndex != -1) - { - if (uiCommand == ID_OBJECT_FILLCOLOR) - { - pView->PreviewFillColor(color); - } - else - { - pView->PreviewLineColor(color); - } - } - - CMFCPopupMenu::UpdateAllShadows(); - } - break; - - case ID_OBJECT_LINEWEIGHT: - if (nIndex != -1) - { - pView->PreviewLineWeight(nIndex + 1); - CMFCPopupMenu::UpdateAllShadows(); - } - break; - - case ID_OBJECT_STYLES: - if (nIndex != -1) - { - pView->PreviewStyle(c_Styles[nIndex].clrFill, c_Styles[nIndex].clrLine); - CMFCPopupMenu::UpdateAllShadows(); - } - break; - } - - return 0; -} - -void CMainFrame::SetRibbonContextCategory(UINT uiCategoryID) -{ - if (uiCategoryID != 0) - { - CMFCRibbonCategory* pActivaTab = m_wndRibbonBar.GetActiveCategory(); - if (pActivaTab != NULL && pActivaTab->GetContextID() == uiCategoryID) - { - return; - } - } - - BOOL bRecalc = m_wndRibbonBar.HideAllContextCategories(); - - if (uiCategoryID != 0) - { - m_wndRibbonBar.ShowContextCategories(uiCategoryID); - bRecalc = TRUE; - } - - if (bRecalc) - { - m_wndRibbonBar.RecalcLayout(); - m_wndRibbonBar.RedrawWindow(); - - SendMessage(WM_NCPAINT, 0, 0); - } -} - -void CMainFrame::ActivateRibbonContextCategory(UINT uiCategoryID) -{ - if (m_wndRibbonBar.GetHideFlags() == 0) - { - m_wndRibbonBar.ActivateContextCategory(uiCategoryID); - } -} -void CMainFrame::OnSysColorChange() -{ - BOOL bWasWindowRgn = m_Impl.HasRegion (); - - CMDIFrameWndEx::OnSysColorChange(); - - m_Impl.OnChangeVisualManager (); - - if (bWasWindowRgn && ! m_Impl.HasRegion ()) - { - SetWindowRgn (NULL, TRUE); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/mainfrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/mainfrm.h deleted file mode 100644 index 444faf6a4cd62..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/mainfrm.h +++ /dev/null @@ -1,116 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CDrawView; -#include "drawobj.h" - -#define ID_FORMAT_CONTEXT_TAB 1 - -// -class CMainFrame : public CMDIFrameWndEx -{ - DECLARE_DYNAMIC(CMainFrame) -public: - struct XStyle - { - COLORREF clrFill; - COLORREF clrLine; - }; - -public: - CMainFrame(); - - // Attributes -public: - CMFCRibbonBar* GetRibbonBar() {return &m_wndRibbonBar;} - - // Operations -public: - void UpdateUI(CDrawView* pCurrView); - void UpdateContextTab(CDrawView* pCurrView); - void UpdateContextTabFromObject(CDrawObjList& list); - - COLORREF GetColorFromColorButton(int nButtonID); - int GetWeightFromLineWeight(int nButtonID); - BOOL GetStyleFromStyles(XStyle& style); - - void SetRibbonContextCategory(UINT uiCategoryID); - void ActivateRibbonContextCategory(UINT uiCategoryID); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - // control bar embedded members - CMFCRibbonStatusBar m_wndStatusBar; - CMFCRibbonBar m_wndRibbonBar; - - // - CMFCRibbonApplicationButton m_MainButton; - // - - // panel images - CMFCToolBarImages m_PanelImages; - - // Document colors for demo: - CList m_lstMainColors; - CList m_lstAdditionalColors; - CList m_lstStandardColors; - - // Generated message map functions -protected: - //{{AFX_MSG(CMainFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - afx_msg void OnWindowManager(); - afx_msg void OnMdiMoveToNextGroup(); - afx_msg void OnMdiMoveToPrevGroup(); - afx_msg void OnMdiNewHorzTabGroup(); - afx_msg void OnMdiNewVertGroup(); - afx_msg void OnMdiCancel(); - afx_msg LRESULT OnRibbonCustomize(WPARAM wp, LPARAM lp); - afx_msg LRESULT OnHighlightRibbonListItem(WPARAM wp, LPARAM lp); - afx_msg void OnToolsOptions(); - afx_msg void OnDummy(); - afx_msg void OnSysColorChange(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowMDITabContextMenu(CPoint point, DWORD dwAllowedItems, BOOL bDrop); - virtual BOOL OnShowPopupMenu(CMFCPopupMenu* pMenuPopup); - - void ShowOptions(int nPage); - void CreateDocumentColors(); - -private: - BOOL CreateRibbonBar(); - BOOL CreateStatusBar(); - - void InitMainButton(); - void InitHomeCategory(); - void InitViewCategory(); - void InitTabButtons(); - - void AddContextTab_Format(); - - void AdjustObjectSubmenu(CMFCPopupMenu* pMenuPopup); - void UpdateStatusBarCountPane(int nID, CString strText, int nCount); - - UINT m_nAppLook; -}; -// - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/propset.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/propset.cpp deleted file mode 100644 index 3e7cc06026e8e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/propset.cpp +++ /dev/null @@ -1,1549 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" - -#include -#include -#include -#include "propset.h" - -#pragma warning( disable : 4311 4312 ) - -#ifdef AFXCTL_PROP_SEG -#pragma code_seg(AFXCTL_PROP_SEG) -#endif - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define new DEBUG_NEW - -static LPVOID CountPrefixedStringA(LPCSTR lpsz) -{ - DWORD cb = (lstrlenA( lpsz ) + 1); - LPDWORD lp = (LPDWORD)malloc((int)cb + sizeof(DWORD) ); - if (lp) - { - *lp = cb; - strcpy_s((LPSTR)(lp+1), (int)cb, lpsz ); - } - - return(LPVOID)lp; -} - -static LPVOID CountPrefixedStringW(LPCWSTR lpsz) -{ - DWORD cb = (DWORD)(wcslen( lpsz ) + 1); - LPDWORD lp = (LPDWORD)malloc((int)cb * sizeof(WCHAR) + sizeof(DWORD) ); - if (lp) - { - *lp = cb; - wcscpy_s((LPWSTR)(lp+1), (int)cb, lpsz ); - } - - return(LPVOID)lp; -} - -#ifdef _UNICODE -#define CountPrefixedStringT CountPrefixedStringW -#else -#define CountPrefixedStringT CountPrefixedStringA -#endif - -#ifdef _UNICODE - -#define MAX_STRLEN 1024 - -static LPBYTE ConvertStringProp(LPBYTE pbProp, DWORD dwType, ULONG nReps, size_t cbCharSize) -{ - LPBYTE pbResult = NULL; // Return value - ULONG cbResult = 0; // Number of bytes in pbResult - LPBYTE pbBuffer; // Temporary holding space - ULONG cchOrig; // Number of characters in original string - ULONG cchCopy; // Number of characters to copy - ULONG cbCopy; // Number of bytes to copy - LPBYTE pbResultNew; // Used for realloc of pbResult - - pbBuffer = (LPBYTE)malloc(MAX_STRLEN * cbCharSize); - if (pbBuffer == NULL) - return NULL; - - // If it's a vector, the count goes first. - if (dwType & VT_VECTOR) - { - pbResult = (LPBYTE)malloc(sizeof(DWORD)); - if (pbResult == NULL) - { - free(pbBuffer); - return NULL; - } - *(LPDWORD)pbResult = nReps; - cbResult = sizeof(DWORD); - } - - while (nReps--) - { - cchOrig = *(LPDWORD)pbProp; - pbProp += sizeof(DWORD); - - // Convert multibyte string to Unicode. - if (cbCharSize == sizeof(WCHAR)) - { - cchCopy = MultiByteToWideChar(CP_ACP, 0, (LPSTR)pbProp, -1, - (LPWSTR)pbBuffer, min(cchOrig, MAX_STRLEN)); - } - else - { - cchCopy = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)pbProp, -1, - (LPSTR)pbBuffer, min(cchOrig, MAX_STRLEN), NULL, NULL); - } - - // Allocate space to append string. - cbCopy = cchCopy *(ULONG)cbCharSize; - pbResultNew = (LPBYTE)realloc(pbResult, cbResult + sizeof(DWORD) + cbCopy); - - // If allocation failed, cleanup and return NULL; - if (pbResultNew == NULL) - { - free(pbResult); - free(pbBuffer); - return NULL; - } - - pbResult = pbResultNew; - - // Copy character count and converted string into place, // then update the total size. - memcpy(pbResult + cbResult, (LPBYTE)&cchCopy, sizeof(DWORD)); - memcpy(pbResult + cbResult + sizeof(DWORD), pbBuffer, cbCopy); - cbResult += sizeof(DWORD) + cbCopy; - - // Advance to the next vector element - pbProp += (cchOrig * cbCharSize); - } - - free(pbBuffer); - return pbResult; -} - -#endif // _UNICODE - -///////////////////////////////////////////////////////////////////////////// -//Implementation of the CProperty class - -CProperty::CProperty( void ) -{ - m_dwPropID = 0; - - m_dwType = VT_EMPTY; - m_pValue = NULL; // must init to NULL -} - -CProperty::CProperty( DWORD dwID, const LPVOID pValue, DWORD dwType ) -{ - m_dwPropID = dwID; - m_dwType = dwType; - m_pValue = NULL; // must init to NULL - Set( dwID, pValue, dwType ); -} - -CProperty::~CProperty() -{ - FreeValue(); -} - -BOOL CProperty::Set( DWORD dwID, const LPVOID pValue, DWORD dwType ) -{ - m_dwType = dwType; - m_dwPropID = dwID; - - return Set( pValue ); -} - -BOOL CProperty::Set( const LPVOID pValue, DWORD dwType ) -{ - m_dwType = dwType; - return Set( pValue ); -} - -BOOL CProperty::Set( const LPVOID pVal ) -{ - ULONG cb; - ULONG cbItem; - ULONG cbValue; - ULONG nReps; - LPBYTE pCur; - LPVOID pValue = pVal; - DWORD dwType = m_dwType; - LPVOID pValueOrig = NULL; - - if (m_pValue != NULL) - { - FreeValue(); - } - - if (pValue == NULL || m_dwType == 0) - return TRUE; - - // Given pValue, determine how big it is - // Then allocate a new buffer for m_pValue and copy... - nReps = 1; - cbValue = 0; - pCur = (LPBYTE)pValue; - if (m_dwType & VT_VECTOR) - { - // The next DWORD is a count of the elements - nReps = *(LPDWORD)pValue; - cb = sizeof( nReps ); - pCur += cb; - cbValue += cb; - dwType &= ~VT_VECTOR; - } - else - { - // If we get any of the string-like types, // and we are not a vector create a count-prefixed - // buffer. - switch (dwType ) - { - case VT_LPSTR: // null terminated string - pValueOrig = pValue; - pValue = CountPrefixedStringA((LPSTR)pValueOrig ); - pCur = (LPBYTE)pValue; - break; - - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - pValueOrig = pValue; - pValue = CountPrefixedStringT((LPTSTR)pValueOrig ); - pCur = (LPBYTE)pValue; - break; - - case VT_LPWSTR: // UNICODE string - pValueOrig = pValue; - pValue = CountPrefixedStringW((LPWSTR)pValueOrig ); - pCur = (LPBYTE)pValue; - break; - } - } - - // Since a value can be made up of a vector(VT_VECTOR) of - // items, we first seek through the value, picking out - // each item, getting it's size. - // - cbItem = 0; // Size of the current item - while (nReps--) - { - switch (dwType) - { - case VT_EMPTY: // nothing - cbItem = 0; - break; - - case VT_I2: // 2 byte signed int - case VT_BOOL: // True=-1, False=0 - cbItem = 2; - break; - - case VT_I4: // 4 byte signed int - case VT_R4: // 4 byte real - cbItem = 4; - break; - - case VT_R8: // 8 byte real - case VT_CY: // currency - case VT_DATE: // date - case VT_I8: // signed 64-bit int - case VT_FILETIME: // FILETIME - cbItem = 8; - break; - - case VT_CLSID: // A Class ID - cbItem = sizeof(CLSID); - break; - -#ifndef _UNICODE - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset -#endif // _UNICODE - case VT_LPSTR: // null terminated string - case VT_BLOB_OBJECT: // Blob contains an object - case VT_BLOB_PROPSET: // Blob contains a propset - case VT_BLOB: // Length prefixed bytes - case VT_CF: // Clipboard format - // Get the DWORD that gives us the size, making - // sure we increment cbValue. - cbItem = *(LPDWORD)pCur; - cb = sizeof(cbItem); - pCur += cb; - cbValue += cb; - break; - -#ifdef _UNICODE - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset -#endif // _UNICODE - case VT_LPWSTR: // UNICODE string - cbItem = *(LPDWORD)pCur * sizeof(WCHAR); - cb = sizeof( cbItem ); - pCur += cb; - cbValue += cb; - break; - case VT_VARIANT: // VARIANT* - break; - - default: - if (pValueOrig) - free( pValue ); - return FALSE; - } - - // Add 'cb' to cbItem before seeking... - // - // Seek to the next item - pCur += cbItem; - cbValue += cbItem; - } - - if (NULL == AllocValue(cbValue)) - { - TRACE0("CProperty::AllocValue failed"); - return FALSE; - } - memcpy_s( m_pValue, (int)cbValue, pValue, (int)cbValue ); - - if (pValueOrig) - free( pValue ); - - return TRUE; -} - -LPVOID CProperty::Get( void ) -{ return Get((DWORD*)NULL ); } - -LPVOID CProperty::Get( DWORD* pcb ) -{ - DWORD cb = 0; - LPBYTE p = NULL; - - p = (LPBYTE)m_pValue; - - // m_pValue points to a Property "Value" which may - // have size information included... - switch ( m_dwType ) - { - case VT_EMPTY: // nothing - cb = 0; - break; - - case VT_I2: // 2 byte signed int - case VT_BOOL: // True=-1, False=0 - cb = 2; - break; - - case VT_I4: // 4 byte signed int - case VT_R4: // 4 byte real - cb = 4; - break; - - case VT_R8: // 8 byte real - case VT_CY: // currency - case VT_DATE: // date - case VT_I8: // signed 64-bit int - case VT_FILETIME: // FILETIME - cb = 8; - break; - -#ifndef _UNICODE - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset -#endif // UNICODE - case VT_LPSTR: // null terminated string - case VT_CF: // Clipboard format - // Read the DWORD that gives us the size, making - // sure we increment cbValue. - cb = *(LPDWORD)p; - p += sizeof( DWORD ); - break; - - case VT_BLOB: // Length prefixed bytes - case VT_BLOB_OBJECT: // Blob contains an object - case VT_BLOB_PROPSET: // Blob contains a propset - // Read the DWORD that gives us the size. - cb = *(LPDWORD)p; - break; - -#ifdef _UNICODE - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset -#endif // _UNICODE - case VT_LPWSTR: // UNICODE string - cb = *(LPDWORD)p * sizeof(WCHAR); - p += sizeof( DWORD ); - break; - - case VT_CLSID: // A Class ID - cb = sizeof(CLSID); - break; - - case VT_VARIANT: // VARIANT* - break; - - default: - return NULL; - } - if (pcb != NULL) - *pcb = cb; - - return p; -} - -DWORD CProperty::GetType( void ) -{ return m_dwType; } - -void CProperty::SetType( DWORD dwType ) -{ m_dwType = dwType; } - -DWORD CProperty::GetID( void ) -{ return m_dwPropID; } - -void CProperty::SetID( DWORD dwPropID ) -{ m_dwPropID = dwPropID; } - -LPVOID CProperty::GetRawValue( void ) -{ return m_pValue; } - -BOOL CProperty::WriteToStream( IStream* pIStream ) -{ - ULONG cb = 0; - ULONG cbTotal; // Total size of the whole value - DWORD dwType = m_dwType; - DWORD nReps; - LPBYTE pValue; - LPBYTE pCur; - BOOL bSuccess = FALSE; - BYTE b = 0; - - nReps = 1; - pValue = (LPBYTE)m_pValue; - pCur = pValue; - cbTotal = 0; - if (m_dwType & VT_VECTOR) - { - // Value is a DWORD count of elements followed by - // that many repititions of the value. - // - nReps = *(LPDWORD)pCur; - cbTotal = sizeof(DWORD); - pCur += cbTotal; - dwType &= ~VT_VECTOR; - } - -#ifdef _UNICODE - switch (dwType) - { - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset - pValue = ConvertStringProp(pCur, m_dwType, nReps, sizeof(char)); - if (m_dwType & VT_VECTOR) - pCur = pValue + sizeof(DWORD); - break; - } -#endif // _UNICODE - - // Figure out how big the data is. - while (nReps--) - { - switch (dwType) - { - case VT_EMPTY: // nothing - cb = 0; - break; - - case VT_I2: // 2 byte signed int - case VT_BOOL: // True=-1, False=0 - cb = 2; - break; - - case VT_I4: // 4 byte signed int - case VT_R4: // 4 byte real - cb = 4; - break; - - case VT_R8: // 8 byte real - case VT_CY: // currency - case VT_DATE: // date - case VT_I8: // signed 64-bit int - case VT_FILETIME: // FILETIME - cb = 8; - break; - - case VT_LPSTR: // null terminated string - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset - case VT_BLOB: // Length prefixed bytes - case VT_BLOB_OBJECT: // Blob contains an object - case VT_BLOB_PROPSET: // Blob contains a propset - case VT_CF: // Clipboard format - cb = sizeof(DWORD) + *(LPDWORD)pCur; - break; - - case VT_LPWSTR: // UNICODE string - cb = sizeof(DWORD) +(*(LPDWORD)pCur * sizeof(WCHAR)); - break; - - case VT_CLSID: // A Class ID - cb = sizeof(CLSID); - break; - - case VT_VARIANT: // VARIANT* - break; - - default: - return FALSE; - } - - pCur += cb; - cbTotal+= cb; - } - - // Write the type - pIStream->Write((LPVOID)&m_dwType, sizeof(m_dwType), &cb); - if (cb != sizeof(m_dwType)) - goto Cleanup; - - // Write the value - pIStream->Write((LPVOID)pValue, cbTotal, &cb); - if (cb != cbTotal) - goto Cleanup; - - // Make sure we are 32 bit aligned - cbTotal = (((cbTotal + 3) >> 2) << 2) - cbTotal; - while (cbTotal--) - { - pIStream->Write((LPVOID)&b, 1, &cb); - if (cb != sizeof(BYTE)) - goto Cleanup; - } - - bSuccess = TRUE; - -Cleanup: - if (pValue != m_pValue) - free(pValue); - - return bSuccess; -} - -BOOL CProperty::ReadFromStream( IStream* pIStream ) -{ - ULONG cb; - ULONG cbItem; - ULONG cbValue; - DWORD dwType; - ULONG nReps; - ULONG iReps; - LPSTREAM pIStrItem; - LARGE_INTEGER li; - - // All properties are made up of a type/value pair. - // The obvious first thing to do is to get the type... - pIStream->Read((LPVOID)&m_dwType, sizeof(m_dwType), &cb ); - if (cb != sizeof(m_dwType)) - return FALSE; - - dwType = m_dwType; - nReps = 1; - cbValue = 0; - if (m_dwType & VT_VECTOR) - { - // The next DWORD in the stream is a count of the - // elements - pIStream->Read((LPVOID)&nReps, sizeof(nReps), &cb ); - if (cb != sizeof(nReps)) - return FALSE; - cbValue += cb; - dwType &= ~VT_VECTOR; - } - - // Since a value can be made up of a vector(VT_VECTOR) of - // items, we first seek through the value, picking out - // each item, getting it's size. We use a cloned - // stream for this(pIStrItem). - // We then use our pIStream to read the entire 'blob' into - // the allocated buffer. - // - cbItem = 0; // Size of the current item - pIStream->Clone( &pIStrItem ); - ENSURE(pIStrItem != NULL); - iReps = nReps; - while (iReps--) - { - switch (dwType) - { - case VT_EMPTY: // nothing - cbItem = 0; - break; - - case VT_I2: // 2 byte signed int - case VT_BOOL: // True=-1, False=0 - cbItem = 2; - break; - - case VT_I4: // 4 byte signed int - case VT_R4: // 4 byte real - cbItem = 4; - break; - - case VT_R8: // 8 byte real - case VT_CY: // currency - case VT_DATE: // date - case VT_I8: // signed 64-bit int - case VT_FILETIME: // FILETIME - cbItem = 8; - break; - - case VT_LPSTR: // null terminated string - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset - case VT_BLOB: // Length prefixed bytes - case VT_BLOB_OBJECT: // Blob contains an object - case VT_BLOB_PROPSET: // Blob contains a propset - case VT_CF: // Clipboard format - // Read the DWORD that gives us the size, making - // sure we increment cbValue. - pIStream->Read((LPVOID)&cbItem, sizeof(cbItem), &cb ); - if (cb != sizeof(cbItem)) - return FALSE; - LISet32( li, -(LONG)cb ); - pIStream->Seek( li, STREAM_SEEK_CUR, NULL ); - cbValue += cb; - break; - - case VT_LPWSTR: // UNICODE string - pIStream->Read((LPVOID)&cbItem, sizeof(cbItem), &cb ); - if (cb != sizeof(cbItem)) - return FALSE; - LISet32( li, -(LONG)cb ); - pIStream->Seek( li, STREAM_SEEK_CUR, NULL ); - cbValue += cb; - cbItem *= sizeof(WCHAR); - break; - - case VT_CLSID: // A Class ID - cbItem = sizeof(CLSID); - break; - - case VT_VARIANT: // VARIANT* - break; - - default: - pIStrItem->Release(); - return FALSE; - } - - // Add 'cb' to cbItem before seeking... - // - // Seek to the next item - LISet32( li, cbItem ); - pIStrItem->Seek( li, STREAM_SEEK_CUR, NULL); - cbValue += cbItem; - } - - pIStrItem->Release(); - -#ifdef _UNICODE - LPBYTE pTmp; - - switch (dwType) - { - case VT_BSTR: // binary string - case VT_STREAM: // Name of the stream follows - case VT_STORAGE: // Name of the storage follows - case VT_STREAMED_OBJECT:// Stream contains an object - case VT_STORED_OBJECT: // Storage contains an object - case VT_STREAMED_PROPSET:// Stream contains a propset - case VT_STORED_PROPSET: // Storage contains a propset - pTmp = (LPBYTE)malloc((int)cbValue); - pIStream->Read( pTmp, cbValue, &cb ); - m_pValue = ConvertStringProp(pTmp, m_dwType, nReps, sizeof(WCHAR)); - free(pTmp); - break; - - default: -#endif // _UNICODE - // Allocate cbValue bytes - if (NULL == AllocValue(cbValue)) - return FALSE; - - // Read the buffer from pIStream - pIStream->Read( m_pValue, cbValue, &cb ); - if (cb != cbValue) - return FALSE; -#ifdef _UNICODE - break; - } -#endif // _UNICODE - - // Done! - return TRUE; -} - -LPVOID CProperty::AllocValue(ULONG cb) -{ - return m_pValue = malloc((int)cb); -} - -void CProperty::FreeValue() -{ - if (m_pValue != NULL) - { - free(m_pValue); - m_pValue = NULL; - } -} - -///////////////////////////////////////////////////////////////////////////// -// Implementation of the CPropertySection Class - -CPropertySection::CPropertySection( void ) -{ - m_FormatID = GUID_NULL; - m_SH.cbSection = 0; - m_SH.cProperties = 0; -} - -CPropertySection::CPropertySection( CLSID FormatID ) -{ - m_FormatID = FormatID; - m_SH.cbSection = 0; - m_SH.cProperties = 0; -} - -CPropertySection::~CPropertySection( void ) -{ - RemoveAll(); - return; -} - -CLSID CPropertySection::GetFormatID( void ) -{ return m_FormatID; } - -void CPropertySection::SetFormatID( CLSID FormatID ) -{ m_FormatID = FormatID; } - -BOOL CPropertySection::Set( DWORD dwPropID, LPVOID pValue, DWORD dwType ) -{ - CProperty* pProp = GetProperty( dwPropID ); - if (pProp == NULL) - { - if ((pProp = new CProperty( dwPropID, pValue, dwType )) != NULL) - AddProperty( pProp ); - return(pProp != NULL); - } - - pProp->Set( dwPropID, pValue, dwType ); - return TRUE; -} - -BOOL CPropertySection::Set( DWORD dwPropID, LPVOID pValue ) -{ - // Since no dwType was specified, the property is assumed - // to exist. Fail if it does not. - CProperty* pProp = GetProperty( dwPropID ); - if (pProp != NULL && pProp->m_dwType) - { - pProp->Set( dwPropID, pValue, pProp->m_dwType ); - return TRUE; - } - else - return FALSE; -} - -LPVOID CPropertySection::Get( DWORD dwPropID ) -{ return Get( dwPropID, (DWORD*)NULL ); } - -LPVOID CPropertySection::Get( DWORD dwPropID, DWORD* pcb ) -{ - CProperty* pProp = GetProperty(dwPropID); - if (pProp) - { - ASSERT_VALID(pProp); - return pProp->Get(pcb); - } - else - return NULL; -} - -void CPropertySection::Remove( DWORD dwID ) -{ - POSITION pos = m_PropList.GetHeadPosition(); - CProperty* pProp; - while ( pos != NULL ) - { - POSITION posRemove = pos; - pProp = (CProperty*)m_PropList.GetNext( pos ); - if (pProp->m_dwPropID == dwID) - { - m_PropList.RemoveAt( posRemove ); - delete pProp; - m_SH.cProperties--; - return; - } - } -} - -void CPropertySection::RemoveAll( ) -{ - POSITION pos = m_PropList.GetHeadPosition(); - while ( pos != NULL ) - delete(CProperty*)m_PropList.GetNext( pos ); - m_PropList.RemoveAll(); - m_SH.cProperties = 0; -} - -CProperty* CPropertySection::GetProperty( DWORD dwPropID ) -{ - POSITION pos = m_PropList.GetHeadPosition(); - ASSERT_VALID(&m_PropList); - CProperty* pProp; - while (pos != NULL) - { - pProp= (CProperty*)m_PropList.GetNext( pos ); - ASSERT_VALID(pProp); - if (pProp->m_dwPropID == dwPropID) - return pProp; - } - return NULL; -} - -void CPropertySection::AddProperty( CProperty* pProp ) -{ - m_PropList.AddTail( pProp ); - m_SH.cProperties++; -} - -DWORD CPropertySection::GetSize( void ) -{ return m_SH.cbSection; } - -DWORD CPropertySection::GetCount( void ) -{ return(DWORD)m_PropList.GetCount(); } - -CObList* CPropertySection::GetList( void ) -{ return &m_PropList; } - -BOOL CPropertySection::WriteToStream( IStream* pIStream ) -{ - // Create a dummy property entry for the name dictionary(ID == 0). - Set(0, NULL, VT_EMPTY); - - ULONG cb; - ULARGE_INTEGER ulSeekOld; - ULARGE_INTEGER ulSeek; - LPSTREAM pIStrPIDO; - PROPERTYIDOFFSET pido; - LARGE_INTEGER li; - - // The Section header contains the number of bytes in the - // section. Thus we need to go back to where we should - // write the count of bytes - // after we write all the property sets.. - // We accomplish this by saving the seek pointer to where - // the size should be written in ulSeekOld - m_SH.cbSection = 0; - m_SH.cProperties = (DWORD)m_PropList.GetCount(); - LISet32( li, 0 ); - pIStream->Seek( li, STREAM_SEEK_CUR, &ulSeekOld); - - pIStream->Write((LPVOID)&m_SH, sizeof(m_SH), &cb); - if (sizeof(m_SH) != cb) - { - TRACE0("Write of section header failed(1).\n"); - return FALSE; - } - - if (m_PropList.IsEmpty()) - { - TRACE0("Warning: Wrote empty property section.\n"); - return TRUE; - } - - // After the section header is the list of property ID/Offset pairs - // Since there is an ID/Offset pair for each property and we - // need to write the ID/Offset pair as we write each property - // we clone the stream and use the clone to access the - // table of ID/offset pairs(PIDO)... - // - pIStream->Clone( &pIStrPIDO ); - - // Now seek pIStream past the PIDO list - // - LISet32( li, m_SH.cProperties * sizeof( PROPERTYIDOFFSET ) ); - pIStream->Seek( li, STREAM_SEEK_CUR, &ulSeek); - - // Now write each section to pIStream. - CProperty* pProp = NULL; - POSITION pos = m_PropList.GetHeadPosition(); - while ( pos != NULL ) - { - // Get next element(note cast) - pProp = (CProperty*)m_PropList.GetNext( pos ); - - if (pProp->m_dwPropID != 0) - { - // Write it - if (!pProp->WriteToStream( pIStream )) - { - pIStrPIDO->Release(); - return FALSE; - } - } - else - { - if (!WriteNameDictToStream( pIStream )) - { - pIStrPIDO->Release(); - return FALSE; - } - } - - // Using our cloned stream write the Format ID / Offset pair - // The offset to this property is the current seek pointer - // minus the pointer to the beginning of the section - pido.dwOffset = ulSeek.LowPart - ulSeekOld.LowPart; - pido.propertyID = pProp->m_dwPropID; - pIStrPIDO->Write((LPVOID)&pido, sizeof(pido), &cb); - if (sizeof(pido) != cb) - { - TRACE0("Write of 'pido' failed\n"); - pIStrPIDO->Release(); - return FALSE; - } - - // Get the seek offset after the write - LISet32( li, 0 ); - pIStream->Seek( li, STREAM_SEEK_CUR, &ulSeek ); - } - - pIStrPIDO->Release(); - - // Now go back to ulSeekOld and write the section header. - // Size of section is current seek point minus old seek point - // - m_SH.cbSection = ulSeek.LowPart - ulSeekOld.LowPart; - - // Seek to beginning of this section and write the section header. - LISet32( li, ulSeekOld.LowPart ); - pIStream->Seek( li, STREAM_SEEK_SET, NULL ); - pIStream->Write((LPVOID)&m_SH, sizeof(m_SH), &cb); - if (sizeof(m_SH) != cb) - { - TRACE0("Write of section header failed(2).\n"); - return FALSE; - } - - // Now seek to end of the now written section - LISet32(li, ulSeek.LowPart); - pIStream->Seek(li, STREAM_SEEK_SET, NULL); - - return TRUE; -} - -BOOL CPropertySection::ReadFromStream( IStream* pIStream, LARGE_INTEGER liPropSet ) -{ - ULONG cb; - PROPERTYIDOFFSET pido; - ULONG cProperties; - LPSTREAM pIStrPIDO; - ULARGE_INTEGER ulSectionStart; - LARGE_INTEGER li; - CProperty* pProp; - - if (m_SH.cProperties || !m_PropList.IsEmpty()) - RemoveAll(); - - // pIStream is pointing to the beginning of the section we - // are to read. First there is a DWORD that is the count - // of bytes in this section, then there is a count - // of properties, followed by a list of propertyID/offset pairs, // followed by type/value pairs. - // - LISet32( li, 0 ); - pIStream->Seek( li, STREAM_SEEK_CUR, &ulSectionStart ); - pIStream->Read((LPVOID)&m_SH, sizeof(m_SH), &cb ); - if (cb != sizeof(m_SH)) - return FALSE; - - // Now we're pointing at the first of the PropID/Offset pairs - //(PIDOs). To get to each property we use a cloned stream - // to stay back and point at the PIDOs(pIStrPIDO). We seek - // pIStream to each of the Type/Value pairs, creating CProperites - // and so forth as we go... - // - pIStream->Clone( &pIStrPIDO ); - - cProperties = m_SH.cProperties; - while (cProperties--) - { - pIStrPIDO->Read((LPVOID)&pido, sizeof( pido ), &cb ); - if (cb != sizeof(pido)) - { - pIStrPIDO->Release(); - return FALSE; - } - - // Do a seek from the beginning of the property set. - LISet32( li, ulSectionStart.LowPart + pido.dwOffset ); - pIStream->Seek( liPropSet, STREAM_SEEK_SET, NULL ); - pIStream->Seek( li, STREAM_SEEK_CUR, NULL ); - - // Now pIStream is at the type/value pair - if (pido.propertyID != 0) - { - pProp = new CProperty( pido.propertyID, NULL, 0 ); - pProp->ReadFromStream( pIStream ); - ASSERT_VALID(pProp); - m_PropList.AddTail( pProp ); - ASSERT_VALID(&m_PropList); - } - else - { - ReadNameDictFromStream( pIStream ); - } - } - - pIStrPIDO->Release(); - - return TRUE; -} - -BOOL CPropertySection::GetID( LPCTSTR pszName, DWORD* pdwPropID ) -{ - CString strName(pszName); - strName.MakeLower(); // Dictionary stores all names in lowercase - - void* pvID; - if (m_NameDict.Lookup(strName, pvID)) - { - *pdwPropID = (DWORD)pvID; - return TRUE; - } - - // Failed to find entry in dictionary - return FALSE; -} - -BOOL CPropertySection::SetName( DWORD dwPropID, LPCTSTR pszName ) -{ - BOOL bSuccess = TRUE; - CString strName(pszName); - strName.MakeLower(); // Dictionary stores all names in lowercase - - TRY - { - void* pDummy; - BOOL bNameExists = m_NameDict.Lookup(strName, pDummy); - - ASSERT(! bNameExists); // Property names must be unique. - - if (bNameExists) - bSuccess = FALSE; - else - m_NameDict.SetAt(strName, (void*)dwPropID); - } - CATCH(CException, e) - { - TRACE0("Failed to add entry to dictionary.\n"); - bSuccess = FALSE; - } - END_CATCH - - return bSuccess; -} - -struct DICTENTRYHEADER -{ - DWORD dwPropID; - DWORD cb; -}; - -struct DICTENTRY -{ - DICTENTRYHEADER hdr; - char sz[256]; -}; - -BOOL CPropertySection::ReadNameDictFromStream( IStream* pIStream ) -{ - ULONG cb; - ULONG cbRead = 0; - - // Read dictionary header(count). - ULONG cProperties = 0; - pIStream->Read((LPVOID)&cProperties, sizeof(cProperties), &cb); - if (sizeof(cProperties) != cb) - { - TRACE0("Read of dictionary header failed.\n"); - return FALSE; - } - - ULONG iProp; - DICTENTRY entry; - - for (iProp = 0; iProp < cProperties; iProp++) - { - // Read entry header(dwPropID, cch). - if (FAILED(pIStream->Read((LPVOID)&entry, sizeof(DICTENTRYHEADER), &cbRead)) || - (sizeof(DICTENTRYHEADER) != cbRead)) - { - TRACE0("Read of dictionary entry failed.\n"); - return FALSE; - } - - // Read entry data(name). - - cb = entry.hdr.cb; - - if (FAILED(pIStream->Read((LPVOID)entry.sz, cb, &cbRead)) || - (cbRead != cb)) - { - TRACE0("Read of dictionary entry failed.\n"); - return FALSE; - } - - LPTSTR pszName; - -#ifdef _UNICODE - // Persistent form is always ANSI/DBCS. Convert to Unicode. - WCHAR wszName[256]; - MultiByteToWideChar(CP_ACP, 0, entry.sz, -1, wszName, 256); - pszName = wszName; -#else // _UNICODE - pszName = entry.sz; -#endif // _UNICODE - - // Section's "name" appears first in list and has dwPropID == 0. - if ((iProp == 0) &&(entry.hdr.dwPropID == 0)) - m_strSectionName = pszName; // Section name - else - SetName(entry.hdr.dwPropID, pszName); // Some other property - } - - return TRUE; -} - -static BOOL WriteNameDictEntry(IStream* pIStream, DWORD dwPropID, CString& strName) -{ - ULONG cb; - ULONG cbWritten = 0; - DICTENTRY entry; - - entry.hdr.dwPropID = dwPropID; - entry.hdr.cb = min(strName.GetLength() + 1, 255); -#ifdef _UNICODE - // Persistent form is always ANSI/DBCS. Convert from Unicode. - WideCharToMultiByte(CP_ACP, 0, strName, -1, entry.sz, 256, NULL, NULL); -#else // _UNICODE - memcpy_s(entry.sz, 256, (LPCSTR)strName, (size_t)entry.hdr.cb); -#endif // _UNICODE - - cb = sizeof(DICTENTRYHEADER) + entry.hdr.cb; - - if (FAILED(pIStream->Write((LPVOID)&entry, cb, &cbWritten)) || - (cbWritten != cb)) - { - TRACE0("Write of dictionary entry failed.\n"); - return FALSE; - } - - return TRUE; -} - -BOOL CPropertySection::WriteNameDictToStream( IStream* pIStream ) -{ - ULONG cb; - - // Write dictionary header(count). - ULONG cProperties = (ULONG)(m_NameDict.GetCount() + 1); - pIStream->Write((LPVOID)&cProperties, sizeof(cProperties), &cb); - if (sizeof(cProperties) != cb) - { - TRACE0("Write of dictionary header failed.\n"); - return FALSE; - } - - POSITION pos; - CString strName; - void* pvID; - - // Write out section's "name" with dwPropID == 0 first - if (! WriteNameDictEntry(pIStream, 0, m_strSectionName)) - return FALSE; - - // Enumerate contents of dictionary and write out(dwPropID, cb, name). - pos = m_NameDict.GetStartPosition(); - while (pos != NULL) - { - m_NameDict.GetNextAssoc( pos, strName, pvID ); - if (! WriteNameDictEntry(pIStream, (DWORD)pvID, strName)) - return FALSE; - } - - return TRUE; -} - -BOOL CPropertySection::SetSectionName( LPCTSTR pszName ) -{ - m_strSectionName = pszName; - return TRUE; -} - -LPCTSTR CPropertySection::GetSectionName( void ) -{ - return(LPCTSTR)m_strSectionName; -} - -///////////////////////////////////////////////////////////////////////////// -// Implementation of the CPropertySet class - -CPropertySet::CPropertySet( void ) -{ - m_PH.wByteOrder = 0xFFFE; - m_PH.wFormat = 0; - m_PH.dwOSVer = (DWORD)MAKELONG( LOWORD(GetVersion()), 2 ); - m_PH.clsID = GUID_NULL; - m_PH.cSections = 0; - -} - -CPropertySet::CPropertySet( CLSID clsID ) -{ - m_PH.wByteOrder = 0xFFFE; - m_PH.wFormat = 0; - m_PH.dwOSVer = (DWORD)MAKELONG( LOWORD(GetVersion()), 2 ); - m_PH.clsID = clsID; - m_PH.cSections = 0; -} - -CPropertySet::~CPropertySet() -{ RemoveAll(); } - -BOOL CPropertySet::Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue, DWORD dwType ) -{ - CPropertySection* pSect = GetSection( FormatID ); - if (pSect == NULL) - { - if ((pSect = new CPropertySection( FormatID )) != NULL) - AddSection( pSect ); - } - pSect->Set( dwPropID, pValue, dwType ); - return TRUE; -} - -BOOL CPropertySet::Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue ) -{ - // Since there is no dwType, we have to assume that the property - // already exists. If it doesn't, fail. - CPropertySection* pSect = GetSection( FormatID ); - if (pSect != NULL) - return pSect->Set( dwPropID, pValue ); - else - return FALSE; -} - -LPVOID CPropertySet::Get( CLSID FormatID, DWORD dwPropID, DWORD* pcb ) -{ - CPropertySection* pSect = GetSection( FormatID ); - if (pSect) - return pSect->Get( dwPropID, pcb ); - else - return NULL; -} - -LPVOID CPropertySet::Get( CLSID FormatID, DWORD dwPropID ) -{ return Get( FormatID, dwPropID, (DWORD*)NULL ); } - -void CPropertySet::Remove( CLSID FormatID, DWORD dwPropID ) -{ - CPropertySection* pSect = GetSection( FormatID ); - if (pSect) - pSect->Remove( dwPropID ); -} - -void CPropertySet::Remove( CLSID FormatID ) -{ - CPropertySection* pSect; - POSITION posRemove = m_SectionList.GetHeadPosition(); - POSITION pos = posRemove; - while ( posRemove != NULL ) - { - pSect = (CPropertySection*)m_SectionList.GetNext( pos ); - if (IsEqualCLSID( pSect->m_FormatID, FormatID )) - { - m_SectionList.RemoveAt( posRemove ); - delete pSect; - m_PH.cSections--; - return; - } - posRemove = pos; - } -} - -void CPropertySet::RemoveAll( ) -{ - POSITION pos = m_SectionList.GetHeadPosition(); - while ( pos != NULL ) - { - delete(CPropertySection*)m_SectionList.GetNext( pos ); - } - m_SectionList.RemoveAll(); - m_PH.cSections = 0; -} - -CPropertySection* CPropertySet::GetSection( CLSID FormatID ) -{ - POSITION pos = m_SectionList.GetHeadPosition(); - CPropertySection* pSect; - while (pos != NULL) - { - pSect = (CPropertySection*)m_SectionList.GetNext( pos ); - if (IsEqualCLSID( pSect->m_FormatID, FormatID )) - return pSect; - } - return NULL; -} - -CPropertySection* CPropertySet::AddSection( CLSID FormatID ) -{ - CPropertySection* pSect = GetSection( FormatID ); - if (pSect) - return pSect; - - pSect = new CPropertySection( FormatID ) ; - if (pSect) - AddSection( pSect ); - return pSect; -} - -void CPropertySet::AddSection( CPropertySection* pSect ) -{ - m_SectionList.AddTail( pSect ); - m_PH.cSections++; -} - -CProperty* CPropertySet::GetProperty( CLSID FormatID, DWORD dwPropID ) -{ - CPropertySection* pSect = GetSection( FormatID ); - if (pSect) - return pSect->GetProperty( dwPropID ); - else - return NULL; -} - -void CPropertySet::AddProperty( CLSID FormatID, CProperty* pProp ) -{ - CPropertySection* pSect = GetSection( FormatID ); - if (pSect) - pSect->AddProperty( pProp ); -} - -WORD CPropertySet::GetByteOrder( void ) -{ return m_PH.wByteOrder; } - -WORD CPropertySet::GetFormatVersion( void ) -{ return m_PH.wFormat; } - -void CPropertySet::SetFormatVersion( WORD wFmtVersion ) -{ m_PH.wFormat = wFmtVersion; } - -DWORD CPropertySet::GetOSVersion( void ) -{ return m_PH.dwOSVer; } - -void CPropertySet::SetOSVersion( DWORD dwOSVer ) -{ m_PH.dwOSVer = dwOSVer; } - -CLSID CPropertySet::GetClassID( void ) -{ return m_PH.clsID; } - -void CPropertySet::SetClassID( CLSID clsID ) -{ m_PH.clsID = clsID; } - -DWORD CPropertySet::GetCount( void ) -{ return(DWORD)m_SectionList.GetCount(); } - -CObList* CPropertySet::GetList( void ) -{ return &m_SectionList; } - -BOOL CPropertySet::WriteToStream( IStream* pIStream ) -{ - LPSTREAM pIStrFIDO; - FORMATIDOFFSET fido; - ULONG cb; - ULARGE_INTEGER ulSeek; - LARGE_INTEGER li; - - // Write the Property List Header - m_PH.cSections = (DWORD)m_SectionList.GetCount(); - pIStream->Write((LPVOID)&m_PH, sizeof(m_PH), &cb); - if (sizeof(m_PH) != cb) - { - TRACE0("Write of Property Set Header failed.\n"); - return FALSE; - } - - if (m_SectionList.IsEmpty()) - { - TRACE0("Warning: Wrote empty property set.\n"); - return TRUE; - } - - // After the header is the list of Format ID/Offset pairs - // Since there is an ID/Offset pair for each section and we - // need to write the ID/Offset pair as we write each section - // we clone the stream and use the clone to access the - // table of ID/offset pairs(FIDO)... - // - pIStream->Clone( &pIStrFIDO ); - - // Now seek pIStream past the FIDO list - // - LISet32( li, m_PH.cSections * sizeof( FORMATIDOFFSET ) ); - pIStream->Seek( li, STREAM_SEEK_CUR, &ulSeek); - - // Write each section. - CPropertySection* pSect = NULL; - POSITION pos = m_SectionList.GetHeadPosition(); - while ( pos != NULL ) - { - // Get next element(note cast) - pSect = (CPropertySection*)m_SectionList.GetNext( pos ); - - // Write it - if (!pSect->WriteToStream( pIStream )) - { - pIStrFIDO->Release(); - return FALSE; - } - - // Using our cloned stream write the Format ID / Offset pair - fido.formatID = pSect->m_FormatID; - fido.dwOffset = ulSeek.LowPart; - pIStrFIDO->Write((LPVOID)&fido, sizeof(fido), &cb); - if (sizeof(fido) != cb) - { - TRACE0("Write of 'fido' failed.\n"); - pIStrFIDO->Release(); - return FALSE; - } - - // Get the seek offset(for pIStream) after the write - LISet32( li, 0 ); - pIStream->Seek( li, STREAM_SEEK_CUR, &ulSeek ); - } - - pIStrFIDO->Release(); - - return TRUE; -} - -BOOL CPropertySet::ReadFromStream( IStream* pIStream ) -{ - ULONG cb; - FORMATIDOFFSET fido; - ULONG cSections; - LPSTREAM pIStrFIDO; - CPropertySection* pSect; - LARGE_INTEGER li; - LARGE_INTEGER liPropSet; - - // Save the stream position at which the property set starts. - LARGE_INTEGER liZero = {0,0}; - pIStream->Seek( liZero, STREAM_SEEK_CUR, (ULARGE_INTEGER*)&liPropSet ); - - if (m_PH.cSections || !m_SectionList.IsEmpty()) - RemoveAll(); - - // The stream starts like this: - // wByteOrder wFmtVer dwOSVer clsID cSections - // Which is nice, because our PROPHEADER is the same! - pIStream->Read((LPVOID)&m_PH, sizeof( m_PH ), &cb ); - if (cb != sizeof(m_PH)) - return FALSE; - - // Now we're pointing at the first of the FormatID/Offset pairs - //(FIDOs). To get to each section we use a cloned stream - // to stay back and point at the FIDOs(pIStrFIDO). We seek - // pIStream to each of the sections, creating CProperitySection - // and so forth as we go... - // - pIStream->Clone( &pIStrFIDO ); - - cSections = m_PH.cSections; - while (cSections--) - { - pIStrFIDO->Read((LPVOID)&fido, sizeof( fido ), &cb ); - if (cb != sizeof(fido)) - { - pIStrFIDO->Release(); - return FALSE; - } - - // Do a seek from the beginning of the property set. - LISet32( li, fido.dwOffset ); - pIStream->Seek( liPropSet, STREAM_SEEK_SET, NULL ); - pIStream->Seek( li, STREAM_SEEK_CUR, NULL ); - - // Now pIStream is at the type/value pair - pSect = new CPropertySection; - pSect->SetFormatID( fido.formatID ); - pSect->ReadFromStream( pIStream, liPropSet ); - m_SectionList.AddTail( pSect ); - } - - pIStrFIDO->Release(); - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/propset.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/propset.h deleted file mode 100644 index 46736c7198d37..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/propset.h +++ /dev/null @@ -1,186 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -typedef struct tagSECTIONHEADER -{ - DWORD cbSection ; - DWORD cProperties ; // Number of props. -} SECTIONHEADER, *LPSECTIONHEADER ; - -typedef struct tagPROPERTYIDOFFSET -{ - DWORD propertyID; - DWORD dwOffset; -} PROPERTYIDOFFSET, *LPPROPERTYIDOFFSET; - -typedef struct tagPROPHEADER -{ - WORD wByteOrder ; // Always 0xFFFE - WORD wFormat ; // Always 0 - DWORD dwOSVer ; // System version - CLSID clsID ; // Application CLSID - DWORD cSections ; // Number of sections(must be at least 1) -} PROPHEADER, *LPPROPHEADER ; - -typedef struct tagFORMATIDOFFSET -{ - GUID formatID; - DWORD dwOffset; -} FORMATIDOFFSET, *LPFORMATIDOFFSET; - -///////////////////////////////////////////////////////////////////////////// -// CProperty - -class CProperty : public CObject -{ - friend class CPropertySet ; - friend class CPropertySection ; - -public: -// Construction - CProperty( void ) ; - CProperty( DWORD dwID, const LPVOID pValue, DWORD dwType ) ; - -// Attributes - BOOL Set( DWORD dwID, const LPVOID pValue, DWORD dwType ) ; - BOOL Set( const LPVOID pValue, DWORD dwType ) ; - BOOL Set( const LPVOID pValue ) ; - LPVOID Get( DWORD* pcb ) ; // Returns pointer to actual value - LPVOID Get( void ) ; // Returns pointer to actual value - DWORD GetType( void ) ; // Returns property type - void SetType( DWORD dwType ) ; - DWORD GetID( void ) ; - void SetID( DWORD dwPropID ) ; - - LPVOID GetRawValue( void ) ; // Returns pointer internal value(may - // include size information) - -// Operations - BOOL WriteToStream( IStream* pIStream ) ; - BOOL ReadFromStream( IStream* pIStream ) ; - -private: - DWORD m_dwPropID ; - DWORD m_dwType ; - LPVOID m_pValue ; - - LPVOID AllocValue(ULONG cb); - void FreeValue(); - -public: - ~CProperty() ; -} ; - -///////////////////////////////////////////////////////////////////////////// -// CPropertySection - -class CPropertySection : public CObject -{ - friend class CPropertySet ; - friend class CProperty ; - -public: -// Construction - CPropertySection( void ) ; - CPropertySection( CLSID FormatID ) ; - -// Attributes - CLSID GetFormatID( void ) ; - void SetFormatID( CLSID FormatID ) ; - - BOOL Set( DWORD dwPropID, LPVOID pValue, DWORD dwType ) ; - BOOL Set( DWORD dwPropID, LPVOID pValue ) ; - LPVOID Get( DWORD dwPropID, DWORD* pcb ) ; - LPVOID Get( DWORD dwPropID ) ; - void Remove( DWORD dwPropID ) ; - void RemoveAll() ; - - CProperty* GetProperty( DWORD dwPropID ) ; - void AddProperty( CProperty* pProp ) ; - - DWORD GetSize( void ) ; - DWORD GetCount( void ) ; - CObList* GetList( void ) ; - - BOOL GetID( LPCTSTR pszName, DWORD* pdwPropID ) ; - BOOL SetName( DWORD dwPropID, LPCTSTR pszName ) ; - - BOOL SetSectionName( LPCTSTR pszName ); - LPCTSTR GetSectionName( void ); - -// Operations - BOOL WriteToStream( IStream* pIStream ) ; - BOOL ReadFromStream( IStream* pIStream, LARGE_INTEGER liPropSet ) ; - BOOL WriteNameDictToStream( IStream* pIStream ) ; - BOOL ReadNameDictFromStream( IStream* pIStream ) ; - -private: -// Implementation - CLSID m_FormatID ; - SECTIONHEADER m_SH ; - // List of properties(CProperty) - CObList m_PropList ; - // Dictionary of property names - CMapStringToPtr m_NameDict ; - CString m_strSectionName; - -public: - ~CPropertySection(); -} ; - -///////////////////////////////////////////////////////////////////////////// -// CPropertySet - -class CPropertySet : public CObject -{ - friend class CPropertySection ; - friend class CProperty ; - -public: -// Construction - CPropertySet( void ) ; - CPropertySet( CLSID clsID ) ; - -// Attributes - BOOL Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue, DWORD dwType ) ; - BOOL Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue ) ; - LPVOID Get( CLSID FormatID, DWORD dwPropID, DWORD* pcb ) ; - LPVOID Get( CLSID FormatID, DWORD dwPropID ) ; - void Remove( CLSID FormatID, DWORD dwPropID ) ; - void Remove( CLSID FormatID ) ; - void RemoveAll( ) ; - - CProperty* GetProperty( CLSID FormatID, DWORD dwPropID ) ; - void AddProperty( CLSID FormatID, CProperty* pProp ) ; - CPropertySection* GetSection( CLSID FormatID ) ; - CPropertySection* AddSection( CLSID FormatID ) ; - void AddSection( CPropertySection* psect ) ; - - WORD GetByteOrder( void ) ; - WORD GetFormatVersion( void ) ; - void SetFormatVersion( WORD wFmtVersion ) ; - DWORD GetOSVersion( void ) ; - void SetOSVersion( DWORD dwOSVer ) ; - CLSID GetClassID( void ) ; - void SetClassID( CLSID clsid ) ; - DWORD GetCount( void ) ; - CObList* GetList( void ) ; - -// Operations - BOOL WriteToStream( IStream* pIStream ) ; - BOOL ReadFromStream( IStream* pIStream ) ; - -// Implementation -private: - PROPHEADER m_PH ; - CObList m_SectionList ; - -public: - ~CPropertySet(); -} ; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/rectdlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/rectdlg.cpp deleted file mode 100644 index 1ee15a9077b58..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/rectdlg.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" -#include "rectdlg.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CRectDlg dialog - -CRectDlg::CRectDlg(CWnd* /*pParent = NULL*/) : CPropertyPage(CRectDlg::IDD) -{ - //{{AFX_DATA_INIT(CRectDlg) - m_bNoFill = FALSE; - m_penSize = 0; - //}}AFX_DATA_INIT -} - -void CRectDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CRectDlg) - DDX_Control(pDX, IDC_SPIN1, m_SpinCtrl); - DDX_Check(pDX, IDC_NOFILL, m_bNoFill); - DDX_Text(pDX, IDC_WEIGHT, m_penSize); - DDV_MinMaxUInt(pDX, m_penSize, 0, 100); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CRectDlg, CDialog) - //{{AFX_MSG_MAP(CRectDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CRectDlg message handlers - -BOOL CRectDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_SpinCtrl.SetRange(0, 100); - m_SpinCtrl.SetBase(10); - m_SpinCtrl.SetPos(max(m_penSize, 0)); - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/rectdlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/rectdlg.h deleted file mode 100644 index 163f1faffde67..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/rectdlg.h +++ /dev/null @@ -1,36 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CRectDlg dialog - -class CRectDlg : public CPropertyPage -{ -// Construction -public: - CRectDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CRectDlg) - enum { IDD = IDD_PROP_RECT }; - CSpinButtonCtrl m_SpinCtrl; - BOOL m_bNoFill; - UINT m_penSize; - //}}AFX_DATA - -// Implementation -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - //{{AFX_MSG(CRectDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/DrawClient.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/DrawClient.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/DrawClient.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/DrawClient.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/DrawClient.rc2 deleted file mode 100644 index 5a75e6cd0025f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/DrawClient.rc2 +++ /dev/null @@ -1,12 +0,0 @@ -// -// DRAWCLI.RC2 - resources App Studio does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by App Studio -#endif //APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// Add additional manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/drawdoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/drawdoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/drawdoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/filelarge.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/filelarge.png deleted file mode 100644 index db2117e64fe2a..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/filelarge.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/filesmall.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/filesmall.png deleted file mode 100644 index 3ad22c36a1ac7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/filesmall.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/formatlarge.PNG b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/formatlarge.PNG deleted file mode 100644 index 7250ebd8e7141..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/formatlarge.PNG and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/formatsmall.PNG b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/formatsmall.PNG deleted file mode 100644 index 6cac145c56e65..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/formatsmall.PNG and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/homelarge.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/homelarge.png deleted file mode 100644 index 5207f47b8aed4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/homelarge.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/homesmall.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/homesmall.png deleted file mode 100644 index 5f732f188fead..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/homesmall.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/lineweight.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/lineweight.png deleted file mode 100644 index b776837295bf2..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/lineweight.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/main.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/main.bmp deleted file mode 100644 index 9393d8e6ee316..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/main.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/pencil.cur b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/pencil.cur deleted file mode 100644 index ed9ee9a99ff9d..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/pencil.cur and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/prop24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/prop24.bmp deleted file mode 100644 index 69beb909ea46d..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/prop24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/ribbonicons.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/ribbonicons.png deleted file mode 100644 index 52d2ff4dae4a8..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/ribbonicons.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/sb_1.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/sb_1.png deleted file mode 100644 index 81afdd1421ebb..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/sb_1.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/sb_2.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/sb_2.png deleted file mode 100644 index 8b5ef3e190d8e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/sb_2.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/styles.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/styles.png deleted file mode 100644 index db2649f935ce3..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/styles.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/viewlarge.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/viewlarge.png deleted file mode 100644 index 2207897ad9699..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/viewlarge.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/viewsmall.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/viewsmall.png deleted file mode 100644 index 8eaf092a4f86f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/res/viewsmall.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/resource.h deleted file mode 100644 index 67c2838317bf6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/resource.h +++ /dev/null @@ -1,110 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by DrawClient.rc -// -#define IDR_MAINFRAME 2 -#define IDR_DRAWCLTYPE 3 -#define IDR_DRAWCLTYPE_CNTR_IP 6 -#define IDP_BUSY 100 -#define IDP_OLE_INIT_FAILED 101 -#define IDD_PROP_RECT 101 -#define IDP_FAILED_TO_CREATE 102 -#define IDC_WEIGHT 102 -#define IDC_PENCIL 102 -#define IDC_NOFILL 103 -#define ID_POPUP_MENU 103 -#define IDC_SPIN1 104 -#define IDD_SUMM_PAGE 104 -#define IDC_AUTHOR 105 -#define IDD_STAT_PAGE 105 -#define IDC_KEYWORDS 106 -#define IDC_COMMENTS 107 -#define IDC_TITLE 108 -#define IDC_SUBJECT 109 -#define IDC_TEMPLATE 110 -#define IDB_RIBBON_MAIN 110 -#define IDC_SAVEDBY 111 -#define IDC_REVNUM 112 -#define IDB_RIBBON_FILELARGE 112 -#define IDC_EDITTIME 113 -#define IDB_RIBBON_FILESMALL 113 -#define IDC_LASTPRINT 114 -#define IDC_CREATEDATE 115 -#define IDC_LASTSAVE 116 -#define IDR_THEME_MENU 116 -#define IDC_NUMPAGES 117 -#define IDB_RIBBON_ICONS 117 -#define IDC_NUMWORDS 118 -#define IDR_WINDOWS_MENU 118 -#define IDC_NUMCHARS 119 -#define IDR_POPUP_MDITABS 119 -#define IDC_APPNAME 120 -#define IDR_POPUP_DROP_MDITABS 120 -#define IDC_SECURITY 122 -#define IDC_THUMBNAIL 123 -#define IDR_PROPERTY 123 -#define IDR_PROPERTIES 123 -#define IDB_RIBBON_HOMELARGE 126 -#define IDB_RIBBON_HOMESMALL 127 -#define IDB_RIBBON_VIEWSMALL 128 -#define IDB_RIBBON_VIEWLARGE 129 -#define IDB_STATUSBAR_1 130 -#define IDB_STATUSBAR_2 131 -#define IDB_RIBBON_FORMATLARGE 132 -#define IDB_RIBBON_FORMATSMALL 133 -#define IDB_LINEWEIGHT 134 -#define IDD_LINEWEIGHT 135 -#define IDB_STYLES 136 -#define IDD_ABOUTBOX 999 -#define ID_CANCEL_EDIT 32768 -#define ID_VIEW_GRID 32769 -#define ID_DRAW_SELECT 32770 -#define ID_DRAW_LINE 32771 -#define ID_DRAW_RECT 32772 -#define ID_DRAW_ROUNDRECT 32773 -#define ID_DRAW_ELLIPSE 32774 -#define ID_OBJECT_LINECOLOR 32775 -#define ID_OBJECT_FILLCOLOR 32776 -#define ID_OBJECT_MOVETOFRONT 32777 -#define ID_OBJECT_MOVETOBACK 32778 -#define ID_OBJECT_MOVEFORWARD 32779 -#define ID_OBJECT_MOVEBACK 32780 -#define ID_VIEW_PAPERCOLOR 32781 -#define ID_DRAW_POLYGON 32782 -#define ID_VIEW_SHOWOBJECTS 32784 -#define ID_FILE_SUMMARYINFO 32792 -#define ID_WINDOWS_MENU 32793 -#define ID_WINDOW_WINDOWS 32812 -#define ID_WINDOW_MANAGER 32813 -#define ID_VIEW_APPLOOK_2007 32818 -#define ID_VIEW_APPLOOK_2007_1 32819 -#define ID_VIEW_APPLOOK_2007_2 32820 -#define ID_VIEW_APPLOOK_2007_3 32821 -#define ID_NEWWINDOW 32823 -#define ID_MDI_NEW_HORZ_TAB_GROUP 32824 -#define ID_MDI_NEW_VERT_GROUP 32825 -#define ID_MDI_MOVE_TO_NEXT_GROUP 32826 -#define ID_MDI_MOVE_TO_PREV_GROUP 32827 -#define ID_MDI_CANCEL 32828 -#define ID_EXPAND 32829 -#define ID_SORTINGGROUP 32830 -#define ID_STATUSBAR_PANE_OBJECTCOUNT 32831 -#define ID_STATUSBAR_PANE_SELECTEDOBJECTCOUNT 32832 -#define ID_TOOLS_OPTIONS 32833 -#define ID_OBJECT_NOFILL 32834 -#define ID_OBJECT_LINEWEIGHT 32835 -#define ID_OBJECT_LINEWEIGHT_MORE 32836 -#define ID_OBJECT_PROPERTIES 32838 -#define ID_OBJECT_NOLINE 32839 -#define ID_OBJECT_STYLES 32840 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 137 -#define _APS_NEXT_COMMAND_VALUE 32841 -#define _APS_NEXT_CONTROL_VALUE 124 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/setup.lst b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/setup.lst deleted file mode 100644 index a8e512c6e9fe0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/setup.lst +++ /dev/null @@ -1,2 +0,0 @@ -1; -..\disk1\data.z diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/setup.rul b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/setup.rul deleted file mode 100644 index b04f7d8f2b7e5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/setup.rul +++ /dev/null @@ -1,515 +0,0 @@ -/*----------------------------------------------------------------------------*\ - * - * IIIIIII SSSSSS - * II SS InstallSHIELD (R) - * II SSSSSS (c) 1990-1995, Stirling Technologies, Inc. - * II SS All Rights Reserved. - * IIIIIII SSSSSS - * - * - * This source code is intended as a supplement to Stirling Technologies, - * Inc., product documentation. Refer to your Stirling Technologies, Inc., - * product documentation for more detailed information. - * - * - * File Name: SETUP.RUL - * - * Description: InstallSHIELD SDK Edition MFC Sample script. - * - * - * - * - * Author: Stirling Technologies, Inc. Date: 2-4-95 - * - * Comments: This sample script installs a simple MFC application - * to a Windows 95 or Windows NT platform. The installation - * includes application program files, sample files, - * and help files. For information on using this script, - * see the file README.TXT. - * With minor modifications, this script can be - * adapted to create new, customized installations. - * - * - * -\*----------------------------------------------------------------------------*/ - - - -// Size of components. -#define SIZE_REQ_SAMPLES 12000 -#define SIZE_REQ_HELP 32000 -#define SIZE_REQ_PROGRAM 1300000 - -#define APP_NAME "Drawing Client" -#define PROGRAM_GROUP_NAME "YourCompany Applications" -#define APPBASE_PATH "YourCompany\\DrawCli\\" -#define COMPANY_NAME "YourCompany" -#define PRODUCT_NAME "Drawing Client" -#define PRODUCT_VERSION "2.0" -#define PRODUCT_KEY "drawcli.exe" -#define UNINSTALL_KEY "DrawCliV3" -#define APPBASE_DIR95 "Program Files" -#define BASE_REGISTRYNT "Software\\Microsoft\\Windows NT\\CurrentVersion\\App Paths\\" -#define BASE_REGISTRY95 "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" - -#define STR_COMPLETE95 "by selecting the program icon in the Programs menu.\n\n" -#define STR_COMPLETENT "by selecting the program icon in the program group.\n\n" - -declare - - // Global variable declarations. - STRING svGrp, szMsg, szFileSet, szTitle, szAppPath, szAppSharedDir; - STRING szProgram, szTemp, svUninstLogFile, szRegKey; - STRING svMainDirectory[ _MAX_STRING ]; - BOOL bSpaceOk, bReshowSetupType; - NUMBER nResult, nStatusId, nType; - - BOOL bIncludeProgram, bIncludeSamples, bIncludeHelp; - BOOL bWinNT; - - // Function declarations. - prototype SetupScreen(); - prototype CheckRequirements(); - prototype CheckSpaceRequirements( number, number, number, string ); - prototype CreateRegDBEntries(); - -program - -StartHere: - Disable( BACKGROUND ); - - // Set up the installation screen. - SetupScreen(); - - // Set installation info., which is required for registry entries. - InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY ); - -// Create a Welcome dialog. -WelcomeDlg: - Disable( BACKBUTTON ); - Welcome( "Welcome", 0 ); - Enable( BACKBUTTON ); - - // Test target system proper configuration. - CheckRequirements(); - - // Ask user for a destination location for the installation. -GetTargetDirectory: - - svMainDirectory = TARGETDISK ^ APPBASE_DIR95 ^ APPBASE_PATH; - - szMsg = "Please enter the destination path\n"+ - "To accept the default, select > (Next)"; - if ( AskDestPath( "Choose Destination Location", szMsg, - svMainDirectory, 0 ) = BACK ) then - goto WelcomeDlg; - endif; - - szAppSharedDir = svMainDirectory ^ "System"; - - nType = TYPICAL; -DetermineUserSelection: - - nType = SetupType( "Selection of Installation Type", "", svMainDirectory, nType, 0 ); - if ( nType = BACK ) then goto GetTargetDirectory; endif; - - bReshowSetupType = FALSE; - - switch (nType) - case TYPICAL: - bIncludeSamples = TRUE; - bIncludeProgram = TRUE; - bIncludeHelp = TRUE; - case COMPACT: - bIncludeProgram = TRUE; - case CUSTOM: - SetDialogTitle( DLG_ASK_OPTIONS, "Select Components" ); - bIncludeSamples = TRUE; - bIncludeProgram = TRUE; - bIncludeHelp = TRUE; - szMsg = "Select the components that you wish to install.\n"+ - "If the check box is unchecked, that component will not be "+ - "installed. Click Next to continue with the installation."; - - nResult = AskOptions( NONEXCLUSIVE, szMsg, - "Application Program Files", bIncludeProgram, - "Sample Files", bIncludeSamples, - "On-Line Help Files", bIncludeHelp ); - - if ( nResult = BACK ) then goto DetermineUserSelection; endif; - - // Handle user clicking Cancel button. - if (nResult = CANCEL) then - if (AskYesNo( "Are you sure you would like to exit setup?", NO ) = YES) then - abort; - else - bReshowSetupType = TRUE; - endif; - endif; - endswitch; - - if (bReshowSetupType = TRUE) then goto DetermineUserSelection; endif; - - // Check to see if target system meets space requirements. - bSpaceOk = CheckSpaceRequirements( bIncludeSamples, - bIncludeProgram, - bIncludeHelp, - svMainDirectory ); - - // Ask user to try again if not enough space available. - if (bSpaceOk = FALSE) then goto DetermineUserSelection; endif; - -FolderSelection: - if ( bWinNT ) then - svGrp = PROGRAM_GROUP_NAME; - - // Allow user to modify folder name. - if ( SelectFolder( "Folder Selection", svGrp, svGrp ) = BACK ) then - goto DetermineUserSelection; - endif; - endif; - -FileTransferSetup: - - // Prepare InstallSHIELD to record deinstallation information. - DeinstallStart( svMainDirectory, svUninstLogFile, UNINSTALL_KEY, 0 ); - RegDBSetItem( REGDB_UNINSTALL_NAME, APP_NAME ); - - // Set registry App Paths key information for the main application. - szAppPath = svMainDirectory ^ "PROGRAM" + ";" + szAppSharedDir; - RegDBSetItem( REGDB_APPPATH, szAppPath ); - szProgram = svMainDirectory ^ "PROGRAM\\drawcli.exe"; - RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram ); - - // Define the "General" file set. - szFileSet = "General"; - TARGETDIR = svMainDirectory; - - FileSetBeginDefine( szFileSet ); - - SetStatusWindow( -1, "Copying program files..." ); - - // Always copy README & related files, located at - // the root level in the DATA.Z library file. - CompressGet( "data.z", "*.*", COMP_NORMAL ); - - if (bIncludeProgram) then - TARGETDIR = svMainDirectory ^ "PROGRAM"; - CompressGet( "data.z", "program\\*.*", INCLUDE_SUBDIR ); - if ( bWinNT ) then - TARGETDIR = TARGETDISK ^ "\\WINNT35\\SYSTEM32"; - else - TARGETDIR = TARGETDISK ^ "\\WINDOWS\\SYSTEM"; - endif; - CompressGet( "data.z", "shared\\*.*", - SHAREDFILE | COMP_UPDATE_VERSION ); -// CompressGet( "data.z", "shared\\*.*", COMP_NORMAL ); -// TARGETDIR = szAppSharedDir; -// CompressGet( "data.z", "shared\\*.*", SHAREDFILE | COMP_NORMAL ); - endif; - - if (bIncludeSamples) then - TARGETDIR = svMainDirectory ^ "SAMPLES"; - CompressGet( "data.z", "samples\\*.*", INCLUDE_SUBDIR ); - endif; - - if (bIncludeHelp) then - TARGETDIR = svMainDirectory ^ "HELP"; - CompressGet( "data.z", "help\\*.*", INCLUDE_SUBDIR ); - endif; - - FileSetEndDefine( szFileSet ); - -DoFileTransfer: - // Set up progress indicator and information gauge. - Enable( STATUSDLG ); - StatusUpdate( ON, 50 ); - - // Perform the file set. - nResult = FileSetPerformEz( szFileSet, 0 ); - - switch (nResult) - - case FS_DONE: // Successful completion. - - case FS_CREATEDIR: // Create directory error. - MessageBox( "Unable to create a directory under " + TARGETDIR + "."+ - "Please check write access to this directory.", SEVERE ); - abort; - - default: // Group all other errors under default label. - NumToStr( szTemp, nResult ); - MessageBox( "General file transfer error."+ - "Please check your target location and try again."+ - "\n\n Error Number:"+szTemp, SEVERE ); - - abort; - endswitch; - -SetRegistryEntries: - - CreateRegDBEntries( ); - - Delay(2); - Disable( FEEDBACK_FULL ); - Disable( STATUSDLG ); - - // Create program groups (folders) and icons. - -CreateFolderIcons: - SetStatusWindow( 99, "Installing program icon to the Start Menu...." ); - - if ( bWinNT ) then - CreateProgramFolder( svGrp ); - ShowProgramFolder( svGrp, SW_SHOW ); - LongPathToShortPath( svMainDirectory ); - Delay(1); - endif; - - TARGETDIR = svMainDirectory; - - if (bIncludeProgram) then - szProgram = TARGETDIR ^ "PROGRAM\\DRAWCLI.EXE"; - if ( bWinNT ) then - AddFolderIcon( svGrp, APP_NAME, szProgram, - TARGETDIR ^ "PROGRAM", - "", 0, "", REPLACE ); - else - LongPathToQuote( szProgram, TRUE ); - AddFolderIcon( "", APP_NAME, szProgram, - TARGETDIR ^ "PROGRAM", - "", 0, "", REPLACE ); - endif; - Delay( 1 ); - endif; - - if ( bWinNT ) then - if (bIncludeSamples) then - szProgram = TARGETDIR ^ "PROGRAM\\DRAWCLI.EXE "; - AddFolderIcon( svGrp, "Example1", - szProgram + TARGETDIR ^ "SAMPLES\\DRAWCLI1.DRW", - TARGETDIR ^ "SAMPLES", - szProgram, 1, "", REPLACE ); - Delay( 1 ); - endif; - - if (bIncludeSamples) then - AddFolderIcon( svGrp, "Example2", - szProgram + TARGETDIR ^ "SAMPLES\\HMM.DRW", - TARGETDIR ^ "SAMPLES", - szProgram, 1, "", REPLACE ); - Delay( 1 ); - endif; - - AddFolderIcon( svGrp, "ReadmeFile", - "NOTEPAD.EXE " + TARGETDIR ^ "README.TXT", - TARGETDIR, - "", 0, "", REPLACE ); - Delay( 1 ); - - szProgram = WINDIR ^ "UNINST.EXE"; - LongPathToShortPath( szProgram ); - LongPathToShortPath( svUninstLogFile ); - AddFolderIcon( svGrp, "Uninstaller", - szProgram + " -f" + svUninstLogFile, - WINDIR, - "", 0, "", REPLACE ); - Delay( 1 ); - endif; - - // Announce setup complete. - - SetStatusWindow( 100, "Installation complete." ); - - // If shared files could not be installed, then users must restart system. - if (BATCH_INSTALL = TRUE) then - szMsg = "Some files could not be installed because they are "+ - "currently in use by other programs in the system. "+ - "To allow for proper operation of the new program you should restart"+ - "your system at this time."; - if (RebootDialog( "Restart Windows", szMsg, SYS_BOOTMACHINE ) = 0) then - // Set up shared files to be installed after system is next rebooted. - CommitSharedFiles(0); - endif; - else - - szMsg = "Setup is complete. You may run the installed program "; - if ( bWinNT ) then - szMsg = szMsg + STR_COMPLETENT; - else - szMsg = szMsg + STR_COMPLETE95; - endif; - - MessageBeep( 0 ); - MessageBox( szMsg, INFORMATION ); - endif; - - exit; - - -/*---------------------------------------------------------------------------*\ - * - * Function: SetupScreen - * - * Purpose: This function will set up the screen look. This includes - * colors, fonts, text to be displayed, etc. - * - * - * Input: - * - * Returns: - * - * Comments: -\*---------------------------------------------------------------------------*/ - -function SetupScreen() - begin - - Enable( DEFWINDOWMODE ); - Enable( INDVFILESTATUS ); - - SetTitle( APP_NAME + " Setup", 36, WHITE ); - - SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text. - - Enable( BACKGROUND ); - - end; - - -/*---------------------------------------------------------------------------*\ - * - * Function: CheckRequirements - * - * Purpose: This function will check all minimum requirements for the - * application being installed. If any fail, then the user - * is informed and the installation is terminated. - * - * - * Input: - * - * Returns: - * - * Comments: -\*---------------------------------------------------------------------------*/ - -function CheckRequirements() - number nvDx, nvDy; - number nvResult; - STRING szResult; - begin - - // Determine if target system uses NT or Windows 95. - GetSystemInfo( WINMAJOR, nvResult, szResult ); - bWinNT = TRUE; - if (nvResult = 4) then - bWinNT = FALSE; // Running Windows 95. - endif; - - // Check screen resolution. - GetExtents( nvDx, nvDy ); - if (nvDy < 480) then - MessageBox( "This program requires VGA or better resolution.", WARNING ); - exit; - endif; - - end; - -/*---------------------------------------------------------------------------*\ - * - * Function: CheckSpaceRequirements - * - * Purpose: This function will check space requirements based on the - * elements being installed. - * - * Input: - * - * Returns: - * - * Comments: -\*---------------------------------------------------------------------------*/ - -function CheckSpaceRequirements( bIncludeSamples, - bIncludeProgram, - bIncludeHelp, - szDir ) - number nSizeRequired; - begin - - nSizeRequired = 0; - - // Determine total size. - if (bIncludeSamples) then - nSizeRequired = nSizeRequired + SIZE_REQ_SAMPLES; - endif; - - if (bIncludeHelp) then - nSizeRequired = nSizeRequired + SIZE_REQ_HELP; - endif; - - if (bIncludeProgram) then - nSizeRequired = nSizeRequired + SIZE_REQ_PROGRAM; - endif; - - // Check space on target drive. - bSpaceOk = TRUE; - if (GetDiskSpace( szDir ) < nSizeRequired) then - szMsg = "There is not enough space available on the disk\n" + - "'" + svMainDirectory + "' \n" + - "Please free up some space or change the target location\n" + - "to a different disk"; - MessageBeep(0); - MessageBox( szMsg, WARNING ); - bSpaceOk = FALSE; - endif; - - return bSpaceOk; - end; - - -/*---------------------------------------------------------------------------*\ - * - * Function: CreateRegDBEntries - * - * Purpose: This function will create necessary keys and values for - * the sample program. - * - * Input: - * - * Returns: - * - * Comments: -\*---------------------------------------------------------------------------*/ - -function CreateRegDBEntries() - string szKey[255], szValue, szDemo, szProgram; -begin - - RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE ); - - // Create PRODUCT_KEY key. - szKey = "SOFTWARE\\" + COMPANY_NAME + "\\" + PRODUCT_NAME + "\\" + - PRODUCT_VERSION + "\\" + "DRAWCLI"; - RegDBCreateKeyEx( szKey, "" ); - - // The following keys are duplicates of ones that the MFC library - // will create. They're included so that they'll be registered - // in the log used by InstallSHIELD's uninstall program, causing - // them to be removed upon uninstall. - - // create key used by CWinApp::SetRegisterKey - RegDBSetDefaultRoot( HKEY_CURRENT_USER ); - RegDBCreateKeyEx( "Software\\" + COMPANY_NAME, "" ); - - // create keys used by CWinApp::EnableShellFileTypes - RegDBSetDefaultRoot( HKEY_CLASSES_ROOT ); - RegDBCreateKeyEx( ".DRW", "" ); - RegDBCreateKeyEx( "DrawCl.Document", "" ); - - // register filetype icon - RegDBCreateKeyEx( "DrawCl.Document\\DefaultIcon", "" ); - RegDBSetKeyValueEx( "DrawCl.Document\\DefaultIcon", - "", REGDB_STRING, APPBASE_DIR95 + "\\" + - APPBASE_PATH + "\\PROGRAM\\" + PRODUCT_KEY + ",1", -1 ); -end; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/splitfrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/splitfrm.cpp deleted file mode 100644 index f0098a41e7357..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/splitfrm.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" -#include "splitfrm.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSplitFrame - -IMPLEMENT_DYNCREATE(CSplitFrame, CMDIChildWndEx) - -CSplitFrame::CSplitFrame() -{ -} - -CSplitFrame::~CSplitFrame() -{ -} - -BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) -{ - return m_wndSplitter.Create(this, 2, 2, CSize(10, 10), pContext); -} - -BEGIN_MESSAGE_MAP(CSplitFrame, CMDIChildWndEx) - //{{AFX_MSG_MAP(CSplitFrame) - ON_COMMAND(ID_FILE_PRINT, OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_PREVIEW, OnUpdateFilePrintPreview) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void CSplitFrame::OnFilePrint () -{ - if (m_dockManager.IsPrintPreviewValid ()) - { - PostMessage (WM_COMMAND, AFX_ID_PREVIEW_PRINT); - } -} - -void CSplitFrame::OnFilePrintPreview() -{ - if (m_dockManager.IsPrintPreviewValid ()) - { - PostMessage (WM_COMMAND, AFX_ID_PREVIEW_CLOSE); // Force Print Preview Close - } -} - -void CSplitFrame::OnUpdateFilePrintPreview(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_dockManager.IsPrintPreviewValid ()); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/splitfrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/splitfrm.h deleted file mode 100644 index 04ed9eee86e39..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/splitfrm.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CSplitFrame frame with splitter - -#ifndef __AFXEXT_H__ -#include -#endif - -class CSplitFrame : public CMDIChildWndEx -{ - DECLARE_DYNCREATE(CSplitFrame) - -protected: - CSplitFrame(); // protected constructor used by dynamic creation - -// Attributes -protected: - CSplitterWndEx m_wndSplitter; -public: - -// Implementation -public: - virtual ~CSplitFrame(); - virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); - - //{{AFX_MSG(CSplitFrame) - afx_msg void OnFilePrint(); - afx_msg void OnFilePrintPreview(); - afx_msg void OnUpdateFilePrintPreview(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/statpage.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/statpage.cpp deleted file mode 100644 index 82a3133316484..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/statpage.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" -#include "statpage.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CStatPage property page - -IMPLEMENT_DYNCREATE(CStatPage, CPropertyPage) - -CStatPage::CStatPage() : CPropertyPage(CStatPage::IDD) -{ - //{{AFX_DATA_INIT(CStatPage) - m_strCreateDate = _T(""); - m_strEditTime = _T(""); - m_strLastPrint = _T(""); - m_strLastSave = _T(""); - m_strNumChars = _T(""); - m_strNumPages = _T(""); - m_strNumWords = _T(""); - m_strRevNum = _T(""); - m_strSavedBy = _T(""); - m_strSecurity = _T(""); - //}}AFX_DATA_INIT -} - -CStatPage::~CStatPage() -{ -} - -void CStatPage::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CStatPage) - DDX_Text(pDX, IDC_CREATEDATE, m_strCreateDate); - DDX_Text(pDX, IDC_EDITTIME, m_strEditTime); - DDX_Text(pDX, IDC_LASTPRINT, m_strLastPrint); - DDX_Text(pDX, IDC_LASTSAVE, m_strLastSave); - DDX_Text(pDX, IDC_NUMCHARS, m_strNumChars); - DDX_Text(pDX, IDC_NUMPAGES, m_strNumPages); - DDX_Text(pDX, IDC_NUMWORDS, m_strNumWords); - DDX_Text(pDX, IDC_REVNUM, m_strRevNum); - DDX_Text(pDX, IDC_SAVEDBY, m_strSavedBy); - DDX_Text(pDX, IDC_SECURITY, m_strSecurity); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CStatPage, CPropertyPage) - //{{AFX_MSG_MAP(CStatPage) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/statpage.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/statpage.h deleted file mode 100644 index e29300f15d8b2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/statpage.h +++ /dev/null @@ -1,47 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CStatPage dialog - -class CStatPage : public CPropertyPage -{ - DECLARE_DYNCREATE(CStatPage) - -// Construction -public: - CStatPage(); - ~CStatPage(); - -// Dialog Data - //{{AFX_DATA(CStatPage) - enum { IDD = IDD_STAT_PAGE }; - CString m_strSavedBy; - CString m_strRevNum; - CString m_strEditTime; - CString m_strLastPrint; - CString m_strCreateDate; - CString m_strLastSave; - CString m_strNumPages; - CString m_strNumWords; - CString m_strNumChars; - CString m_strSecurity; - //}}AFX_DATA - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - // Implementation -protected: - //{{AFX_MSG(CStatPage) - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/stdafx.cpp deleted file mode 100644 index 07f7b469ee436..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/stdafx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// stdafx.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/stdafx.h deleted file mode 100644 index 9cd10d8ad27c5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/stdafx.h +++ /dev/null @@ -1,51 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include // MFC OLE classes -#include // MFC OLE dialog classes - -#include // MFC Automation classes - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#pragma warning(disable : 4189) -#include // MFC rich edit classes -#pragma warning(default : 4189) - -#include // MFC ribbon and control bar classes - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summinfo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summinfo.cpp deleted file mode 100644 index 1f6f439f1375d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summinfo.cpp +++ /dev/null @@ -1,383 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include - -#include "DrawClient.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -#include - -// the following header redefines -// the DEFINE_GUID macro to actually allocate data - -#include -#ifndef INITGUID -#define INITGUID -#endif - -// the DEFINE_GUID macro in the following header now allocates data -#include "summinfo.h" - -const OLECHAR szSummInfo[] = OLESTR("\005SummaryInformation"); - -#if defined(_UNICODE) -LPCSTR tcstocs(LPCTSTR lpctStr) { // typed char(WCHAR) to CHAR - size_t numConv = 0; - static CHAR strTemp[1024]; - wcstombs_s(&numConv, strTemp, 1024, lpctStr, 1024); - return strTemp; -} -#else // !defined(_UNICODE) -#define tcstocs(lpctStr)(LPCSTR)(lpctStr) -#endif - -CSummInfo::CSummInfo() -{ - m_propSet.SetFormatVersion(0); - DWORD dwOSVer; - dwOSVer = (DWORD)MAKELONG(LOWORD(GetVersion()), 2); - m_propSet.SetOSVersion(dwOSVer); - m_propSet.SetClassID(FMTID_SummaryInformation); - m_pSection = m_propSet.AddSection(FMTID_SummaryInformation); - UINT cp = GetACP(); - m_pSection->Set(PID_CODEPAGE, (void*)&cp, VT_I2); - SetTitle(_T("")); - SetSubject(_T("")); - SetAuthor(_T("")); - SetKeywords(_T("")); - SetComments(_T("")); - SetTemplate(_T("")); - SetLastAuthor(_T("")); - m_pSection->Set(PIDSI_REVNUMBER, (void*)_T("0"), VT_LPSTR); - FILETIME zeroTime = {0L, 0L}; - m_pSection->Set(PIDSI_EDITTIME, (void*)&zeroTime, VT_FILETIME); - m_pSection->Set(PIDSI_LASTPRINTED, (void*)&zeroTime, VT_FILETIME); - m_pSection->Set(PIDSI_LASTSAVE_DTM, (void*)&zeroTime, VT_FILETIME); - m_pSection->Set(PIDSI_CREATE_DTM, (void*)&zeroTime, VT_FILETIME); - SetNumPages(0); - SetNumWords(0); - SetNumChars(0); - SetAppname(_T("")); - SetSecurity(0); -} - -BOOL CSummInfo::SetTitle(LPCTSTR szTitle) -{ - return m_pSection->Set(PIDSI_TITLE, (void*)tcstocs(szTitle), VT_LPSTR); -} - -CString CSummInfo::GetTitle() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_TITLE)); -} - -BOOL CSummInfo::SetSubject(LPCTSTR szSubject) -{ - return m_pSection->Set(PIDSI_SUBJECT, (void*)tcstocs(szSubject), VT_LPSTR); -} - -CString CSummInfo::GetSubject() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_SUBJECT)); -} - -BOOL CSummInfo::SetAuthor(LPCTSTR szAuthor) -{ - return m_pSection->Set(PIDSI_AUTHOR, (void*)tcstocs(szAuthor), VT_LPSTR); -} - -CString CSummInfo::GetAuthor() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_AUTHOR)); -} - -BOOL CSummInfo::SetKeywords(LPCTSTR szKeywords) -{ - return m_pSection->Set(PIDSI_KEYWORDS, (void*)tcstocs(szKeywords), VT_LPSTR); -} - -CString CSummInfo::GetKeywords() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_KEYWORDS)); -} - -BOOL CSummInfo::SetComments(LPCTSTR szComments) -{ - return m_pSection->Set(PIDSI_COMMENTS, (void*)tcstocs(szComments), VT_LPSTR); -} - -CString CSummInfo::GetComments() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_COMMENTS)); -} - -BOOL CSummInfo::SetTemplate(LPCTSTR szTemplate) -{ - return m_pSection->Set(PIDSI_TEMPLATE, (void*)tcstocs(szTemplate), VT_LPSTR); -} - -CString CSummInfo::GetTemplate() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_TEMPLATE)); -} - -BOOL CSummInfo::SetLastAuthor(LPCTSTR szLastAuthor) -{ - return m_pSection->Set(PIDSI_LASTAUTHOR, (void*)tcstocs(szLastAuthor), VT_LPSTR); -} - -CString CSummInfo::GetLastAuthor() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_LASTAUTHOR)); -} - -BOOL CSummInfo::IncrRevNum() -{ - ULONG count; - _stscanf_s((LPCTSTR)GetRevNum(), _T("%lu"), &count); - count++; - TCHAR buff[20]; - _stprintf_s(buff, 20, _T("%lu"), count); - return m_pSection->Set(PIDSI_REVNUMBER, (void*)buff, VT_LPSTR); -} - -CString CSummInfo::GetRevNum() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_REVNUMBER)); -} - -void CSummInfo::StartEditTimeCount() -{ - FILETIME now; - CoFileTimeNow(&now); - startEdit = *(__int64*)&now; -} - -BOOL CSummInfo::AddCountToEditTime() -{ - FILETIME now; - CoFileTimeNow(&now); - __int64 currTime = *(__int64*)&now; - __int64 thisSession = currTime - startEdit; - __int64 lastTotal = *(__int64*)m_pSection->Get(PIDSI_EDITTIME); - __int64 newTotal = lastTotal + thisSession; - return m_pSection->Set(PIDSI_EDITTIME, (void*)&newTotal, VT_FILETIME); -} - -CString CSummInfo::GetEditTime() -{ - FILETIME now; - CoFileTimeNow(&now); - __int64 currTime = *(__int64*)&now; - __int64 thisSession = currTime - startEdit; - __int64 lastTotal = *(__int64*)m_pSection->Get(PIDSI_EDITTIME); - __int64 newTotal = lastTotal + thisSession; - ULONG editMinutes = (ULONG)(newTotal/600000000); - - TCHAR buff[20]; - _stprintf_s(buff, 20, _T("%lu min"), editMinutes); - return CString(buff); -} - -BOOL CSummInfo::RecordPrintDate() -{ - FILETIME printDate; - CoFileTimeNow(&printDate); - return m_pSection->Set(PIDSI_LASTPRINTED, - (void*)&printDate, VT_FILETIME); -} - -CString CSummInfo::GetLastPrintDate() -{ - FILETIME* pPrintDate = (FILETIME*)m_pSection->Get(PIDSI_LASTPRINTED); - if ((pPrintDate == NULL) || ((pPrintDate->dwLowDateTime == 0L) && (pPrintDate->dwHighDateTime == 0L))) - return CString(_T("")); - else - { - COleDateTime tempDate = *pPrintDate; - return tempDate.Format(); - } -} - -BOOL CSummInfo::RecordCreateDate() -{ - FILETIME createDate; - CoFileTimeNow(&createDate); - return m_pSection->Set(PIDSI_CREATE_DTM, (void*)&createDate, VT_FILETIME); -} - -CString CSummInfo::GetCreateDate() -{ - FILETIME* pCreateDate = (FILETIME*)m_pSection->Get(PIDSI_CREATE_DTM); - if ((pCreateDate == NULL) || ((pCreateDate->dwLowDateTime == 0L) && (pCreateDate->dwHighDateTime == 0L) )) - return CString(_T("")); - else - { - COleDateTime tempDate = *pCreateDate; - return tempDate.Format(); - } -} - -BOOL CSummInfo::RecordSaveDate() -{ - FILETIME saveDate; - CoFileTimeNow(&saveDate); - return m_pSection->Set(PIDSI_LASTSAVE_DTM, (void*)&saveDate, VT_FILETIME); -} - -CString CSummInfo::GetLastSaveDate() -{ - FILETIME *pSaveDate = (FILETIME*)m_pSection->Get(PIDSI_LASTSAVE_DTM); - if ((pSaveDate == NULL) || ((pSaveDate->dwLowDateTime == 0L) && (pSaveDate->dwHighDateTime == 0L) )) - return CString(_T("")); - else - { - COleDateTime tempDate = *pSaveDate; - return tempDate.Format(); - } -} - -BOOL CSummInfo::SetNumPages(ULONG nPages) -{ - return m_pSection->Set(PIDSI_PAGECOUNT, (void*)&nPages, VT_I4); -} - -CString CSummInfo::GetNumPages() -{ - TCHAR buff[20]; - ULONG* pNumPages = (ULONG*)m_pSection->Get(PIDSI_PAGECOUNT); - if (pNumPages != NULL) - { - _stprintf_s(buff,20, _T("%lu"), *pNumPages); - return CString(buff); - } - else - return CString(_T("")); -} - -BOOL CSummInfo::SetNumWords(ULONG nWords) -{ - return m_pSection->Set(PIDSI_WORDCOUNT, (void*)&nWords, VT_I4); -} - -CString CSummInfo::GetNumWords() -{ - TCHAR buff[20]; - ULONG* pNumWords = (ULONG*)m_pSection->Get(PIDSI_WORDCOUNT); - if (pNumWords != NULL) - { - _stprintf_s(buff, 20,_T("%lu"), *pNumWords); - return CString(buff); - } - else - return CString(_T("")); -} - -BOOL CSummInfo::SetNumChars(ULONG nChars) -{ - return m_pSection->Set(PIDSI_CHARCOUNT, (void*)&nChars, VT_I4); -} - -CString CSummInfo::GetNumChars() -{ - TCHAR buff[20]; - ULONG* pNumChars = (ULONG*)m_pSection->Get(PIDSI_CHARCOUNT); - if (pNumChars != NULL) - { - _stprintf_s(buff, 20,_T("%lu"), *pNumChars); - return CString(buff); - } - else - return CString(_T("")); -} - -BOOL CSummInfo::SetAppname(LPCTSTR szAppname) -{ - return m_pSection->Set(PIDSI_APPNAME, (void*)tcstocs(szAppname), VT_LPSTR); -} - -CString CSummInfo::GetAppname() -{ - return CString((LPCSTR)m_pSection->Get(PIDSI_APPNAME)); -} - -BOOL CSummInfo::SetSecurity(ULONG nLevel) -{ - return m_pSection->Set(PID_SECURITY, (void*)&nLevel, VT_I4); -} - -CString CSummInfo::GetSecurity() -{ - TCHAR buff[20]; - ULONG* pSecurity = (ULONG*)m_pSection->Get(PID_SECURITY); - if (pSecurity != NULL) - { - _stprintf_s(buff, 20,_T("%lu"), *pSecurity); - return CString(buff); - } - else - return CString(_T("")); -} - -BOOL CSummInfo::WriteToStorage(LPSTORAGE lpRootStg) -{ - if (lpRootStg != NULL) - { - LPSTREAM lpStream = NULL; - if (FAILED(lpRootStg->CreateStream(szSummInfo, STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, 0, &lpStream))) - { - TRACE(_T("CreateStream failed\n")); - return FALSE; - } - else - { - if (!m_propSet.WriteToStream(lpStream)) - { - TRACE(_T("WriteToStream failed\n")); - return FALSE; - } - lpRootStg->Commit(STGC_DEFAULT); - lpStream->Release(); - return TRUE; - } - } - return FALSE; -} - -BOOL CSummInfo::ReadFromStorage(LPSTORAGE lpRootStg) -{ - if (lpRootStg != NULL) - { - LPSTREAM lpStream = NULL; - - if (FAILED(lpRootStg->OpenStream(szSummInfo, NULL, STGM_SHARE_EXCLUSIVE|STGM_READ, 0, &lpStream))) - { - TRACE(_T("OpenStream failed\n")); - return FALSE; - } - else - { - if (!m_propSet.ReadFromStream(lpStream)) - { - TRACE(_T("ReadFromStream failed\n")); - return FALSE; - } - m_pSection = m_propSet.GetSection(FMTID_SummaryInformation); - lpStream->Release(); - return TRUE; - } - } - return FALSE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summinfo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summinfo.h deleted file mode 100644 index 1a1260ef23bdd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summinfo.h +++ /dev/null @@ -1,63 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "propset.h" -#include - -extern const OLECHAR szSummInfo[]; - -DEFINE_GUID( FMTID_SummaryInformation, 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 ); - -class CSummInfo -{ -public: - CSummInfo(); - BOOL SetTitle(LPCTSTR szTitle); - CString GetTitle(); - BOOL SetSubject(LPCTSTR szSubject); - CString GetSubject(); - BOOL SetAuthor(LPCTSTR szAuthor); - CString GetAuthor(); - BOOL SetKeywords(LPCTSTR szKeywords); - CString GetKeywords(); - BOOL SetComments(LPCTSTR szComments); - CString GetComments(); - BOOL SetTemplate(LPCTSTR szTemplate); - CString GetTemplate(); - BOOL SetLastAuthor(LPCTSTR szLastAuthor); - CString GetLastAuthor(); - BOOL IncrRevNum(); - CString GetRevNum(); - void StartEditTimeCount(); - BOOL AddCountToEditTime(); - CString GetEditTime(); - BOOL RecordPrintDate(); - CString GetLastPrintDate(); - BOOL RecordCreateDate(); - CString GetCreateDate(); - BOOL RecordSaveDate(); - CString GetLastSaveDate(); - BOOL SetNumPages(ULONG nPages); - CString GetNumPages(); - BOOL SetNumWords(ULONG nWords); - CString GetNumWords(); - BOOL SetNumChars(ULONG nChars); - CString GetNumChars(); - BOOL SetAppname(LPCTSTR szAppname); - CString GetAppname(); - BOOL SetSecurity(ULONG nLevel); - CString GetSecurity(); - BOOL WriteToStorage(LPSTORAGE lpRootStg); - BOOL ReadFromStorage(LPSTORAGE lpRootStg); - -protected: - CPropertySet m_propSet; - CPropertySection* m_pSection; - __int64 startEdit; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summpage.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summpage.cpp deleted file mode 100644 index 00c49d7f842cb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summpage.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "DrawClient.h" -#include "summpage.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSummPage property page - -IMPLEMENT_DYNCREATE(CSummPage, CPropertyPage) - -CSummPage::CSummPage() : CPropertyPage(CSummPage::IDD) -{ - //{{AFX_DATA_INIT(CSummPage) - m_strAuthor = _T(""); - m_strKeywd = _T(""); - m_strSubj = _T(""); - m_strCmt = _T(""); - m_strTempl = _T(""); - m_strTitle = _T(""); - m_strAppname = _T(""); - //}}AFX_DATA_INIT -} - -CSummPage::~CSummPage() -{ -} - -void CSummPage::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSummPage) - DDX_Text(pDX, IDC_AUTHOR, m_strAuthor); - DDX_Text(pDX, IDC_KEYWORDS, m_strKeywd); - DDX_Text(pDX, IDC_SUBJECT, m_strSubj); - DDX_Text(pDX, IDC_COMMENTS, m_strCmt); - DDX_Text(pDX, IDC_TEMPLATE, m_strTempl); - DDX_Text(pDX, IDC_TITLE, m_strTitle); - DDX_Text(pDX, IDC_APPNAME, m_strAppname); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CSummPage, CPropertyPage) - //{{AFX_MSG_MAP(CSummPage) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summpage.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summpage.h deleted file mode 100644 index 1bf5153d43946..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/summpage.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CSummPage : public CPropertyPage -{ - DECLARE_DYNCREATE(CSummPage) - -// Construction -public: - CSummPage(); - ~CSummPage(); - -// Dialog Data - //{{AFX_DATA(CSummPage) - enum { IDD = IDD_SUMM_PAGE }; - CString m_strAuthor; - CString m_strKeywd; - CString m_strSubj; - CString m_strCmt; - CString m_strTempl; - CString m_strTitle; - CString m_strAppname; - //}}AFX_DATA - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - //{{AFX_MSG(CSummPage) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_DrawClient/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.cpp deleted file mode 100644 index e5609e8676372..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Explorer.h" - -#include "MainFrm.h" -#include "ExplorerDoc.h" -#include "ExplorerView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CExplorerApp - -BEGIN_MESSAGE_MAP(CExplorerApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CExplorerApp construction - -CExplorerApp::CExplorerApp() : CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CExplorerApp object - -CExplorerApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CExplorerApp initialization - -BOOL CExplorerApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - CoInitialize (NULL); - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - InitShellManager(); - - // Enable user-defined tools. If you want allow more than 10 tools, - // add tools entry to resources (ID_USER_TOOL11, ID_USER_TOOL12,...) - EnableUserTools (ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CExplorerDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CExplorerView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CExplorerApp message handlers - -int CExplorerApp::ExitInstance() -{ - CoUninitialize (); - return CWinAppEx::ExitInstance(); -} - -void CExplorerApp::PreLoadState () -{ - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CExplorerApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CExplorerApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.h deleted file mode 100644 index 860ccb67a7ad4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.h +++ /dev/null @@ -1,45 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CExplorerApp: -// See Explorer.cpp for the implementation of this class -// - -class CExplorerApp : public CWinAppEx -{ -public: - CExplorerApp(); - - // Override from CWorkspace - virtual void PreLoadState (); - - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CExplorerApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.rc deleted file mode 100644 index d1e541b1236cf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Explorer.rc +++ /dev/null @@ -1,472 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\Explorer.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\Explorer.ico" -IDR_EXPTYPE ICON DISCARDABLE "res\\ExplorerDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_MENU16 BITMAP DISCARDABLE "res\\menu16.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// PNG -// - -IDB_MENU256 PNG DISCARDABLE "res\\menu_hc.png" -IDB_TOOLBAR256 PNG DISCARDABLE "res\\Toolbar_hc.png" -IDB_TOOLBARCOLD256 PNG DISCARDABLE "res\\ToolbarCold_hc.png" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 24, 24 -BEGIN - BUTTON ID_GO_BACK - BUTTON ID_GO_FORWARD - BUTTON ID_FOLDER_UP - SEPARATOR - BUTTON ID_VIEW_FOLDERS - SEPARATOR - BUTTON ID_MOVE_TO - BUTTON ID_COPY_TO - SEPARATOR - BUTTON ID_VIEW_VIEWS -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "&Folders", ID_VIEW_FOLDERS - MENUITEM SEPARATOR - MENUITEM "&Large Icons", ID_VIEW_LARGEICON - MENUITEM "S&mall Icons", ID_VIEW_SMALLICON - MENUITEM "L&ist", ID_VIEW_LIST - MENUITEM "&Details", ID_VIEW_DETAILS - MENUITEM SEPARATOR - MENUITEM "&Refresh", ID_VIEW_REFRESH - END - POPUP "&Tools" - BEGIN - MENUITEM "&", ID_TOOLS_ENTRY - END - POPUP "&Help" - BEGIN - MENUITEM "&About Explorer...", ID_APP_ABOUT - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -IDR_HISTORY_POPUP MENU DISCARDABLE -BEGIN - MENUITEM "", ID_COMMAND_HISTORY -END - -IDR_VIEWS_POPUP MENU DISCARDABLE -BEGIN - MENUITEM "&Large Icons", ID_VIEW_LARGEICON - MENUITEM "&Small Icons", ID_VIEW_SMALLICON - MENUITEM "L&ist", ID_VIEW_LIST - MENUITEM "&Details", ID_VIEW_DETAILS -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About Explorer" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "Explorer Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "Explorer MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "Explorer\0" - VALUE "LegalCopyright", "Copyright (C) 2001\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "Explorer.EXE\0" - VALUE "ProductName", "Explorer Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "Explorer\n\nExp\n\n\nExplorer.Document\nExp Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "Explorer" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_TOOLS_ENTRY "User-defined tools\nUser Tools" - ID_USER_TOOL1 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL2 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL3 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL4 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL5 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL6 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL7 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL8 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL9 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL10 "Activates user-defined tool\nUser Tool" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" - ID_VIEW_AUTOARRANGE "Arrange icons on a grid." -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_SMALLICON "Display items by using small icons.\nSmall Icons" - ID_VIEW_LARGEICON "Display items by using large icons.\nLarge Icons" - ID_VIEW_LIST "Displays items in a list.\nList" - ID_VIEW_DETAILS "Displays detailed information about each item in the window.\nDetails" - ID_VIEW_LINEUP "Arranges icons in a grid." - ID_VIEW_BYNAME "Sorts the icons alphabetically." -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_FOLDERS "Show or hide the folders bar\nToggle Folders" - ID_FOLDER_UP "Display the parent folder Up\nUp" - ID_GO_BACK "Goes back one step.\nBack" - ID_GO_FORWARD "Goes forward one step.\nForward" - ID_MOVE_TO "Move the selected file to specified folder\nMove To" - ID_COPY_TO "Copy the selected file to specified folder\nCopy To" - ID_VIEW_REFRESH "Refresh\nRefresh" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\Explorer.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerDoc.cpp deleted file mode 100644 index a734dfd57fbe3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerDoc.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Explorer.h" - -#include "ExplorerDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CExplorerDoc - -IMPLEMENT_DYNCREATE(CExplorerDoc, CDocument) - -BEGIN_MESSAGE_MAP(CExplorerDoc, CDocument) - ON_COMMAND(ID_COMMAND_HISTORY, OnCommandHistory) - ON_COMMAND(ID_GO_BACK, OnGoBack) - ON_COMMAND(ID_GO_FORWARD, OnGoForward) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CExplorerDoc construction/destruction - -CExplorerDoc::CExplorerDoc() -{ - // TODO: add one-time construction code here - -} - -CExplorerDoc::~CExplorerDoc() -{ -} - -BOOL CExplorerDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CExplorerDoc serialization - -void CExplorerDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CExplorerDoc diagnostics - -#ifdef _DEBUG -void CExplorerDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CExplorerDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CExplorerDoc commands - -void CExplorerDoc::OnCommandHistory() -{ - // TODO: Add your command handler code here - -} - -void CExplorerDoc::OnGoBack() -{ - // TODO: Add your command handler code here - -} - -void CExplorerDoc::OnGoForward() -{ - // TODO: Add your command handler code here - -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerDoc.h deleted file mode 100644 index 6ba58a9784489..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerDoc.h +++ /dev/null @@ -1,46 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CExplorerDoc : public CDocument -{ -protected: // create from serialization only - CExplorerDoc(); - DECLARE_DYNCREATE(CExplorerDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CExplorerDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -protected: - afx_msg void OnCommandHistory(); - afx_msg void OnGoBack(); - afx_msg void OnGoForward(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerView.cpp deleted file mode 100644 index b5bacc6be34bc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerView.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Explorer.h" - -#include "ExplorerDoc.h" -#include "ExplorerView.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CExplorerView - -IMPLEMENT_DYNCREATE(CExplorerView, CView) - -BEGIN_MESSAGE_MAP(CExplorerView, CView) - ON_WM_CREATE() - ON_WM_SIZE() - ON_COMMAND(ID_VIEW_LARGEICON, OnViewLargeicon) - ON_UPDATE_COMMAND_UI(ID_VIEW_LARGEICON, OnUpdateViewLargeicon) - ON_COMMAND(ID_VIEW_DETAILS, OnViewDetails) - ON_UPDATE_COMMAND_UI(ID_VIEW_DETAILS, OnUpdateViewDetails) - ON_COMMAND(ID_VIEW_LIST, OnViewList) - ON_UPDATE_COMMAND_UI(ID_VIEW_LIST, OnUpdateViewList) - ON_COMMAND(ID_VIEW_SMALLICON, OnViewSmallicon) - ON_UPDATE_COMMAND_UI(ID_VIEW_SMALLICON, OnUpdateViewSmallicon) - ON_WM_ERASEBKGND() - ON_WM_SETFOCUS() - ON_COMMAND(ID_FOLDER_UP, OnFolderUp) - ON_UPDATE_COMMAND_UI(ID_FOLDER_UP, OnUpdateFolderUp) - ON_COMMAND(ID_COPY_TO, OnCopyTo) - ON_COMMAND(ID_MOVE_TO, OnMoveTo) - ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh) - ON_REGISTERED_MESSAGE(AFX_WM_CHANGE_CURRENT_FOLDER, OnChangeFolder) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CExplorerView construction/destruction - -CExplorerView::CExplorerView() -{ -} - -CExplorerView::~CExplorerView() -{ -} - -BOOL CExplorerView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CExplorerView drawing - -void CExplorerView::OnDraw(CDC* /*pDC*/) -{ -} - -void CExplorerView::OnInitialUpdate() -{ - CView::OnInitialUpdate(); - OnChangeFolder (0, 0); // To update mainframe's address bar -} - -///////////////////////////////////////////////////////////////////////////// -// CExplorerView diagnostics - -#ifdef _DEBUG -void CExplorerView::AssertValid() const -{ - CView::AssertValid(); -} - -void CExplorerView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CExplorerDoc* CExplorerView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExplorerDoc))); - return (CExplorerDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CExplorerView message handlers - -int CExplorerView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CView::OnCreate(lpCreateStruct) == -1) - return -1; - - // - CRect rectDummy (0, 0, 0, 0); - // The this pointer points to CExplorerView class which extends the CView class. - m_wndList.Create (WS_CHILD | WS_VISIBLE | LVS_REPORT, rectDummy, this, 1); - // - - return 0; -} - -void CExplorerView::OnSize(UINT nType, int cx, int cy) -{ - CView::OnSize(nType, cx, cy); - m_wndList.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); -} - -void CExplorerView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) -{ - if (bActivate && AfxGetMainWnd () != NULL) - { - ((CMainFrame*) AfxGetMainWnd ())->GetFolders ().SetRelatedList (&m_wndList); - } - - CView::OnActivateView(bActivate, pActivateView, pDeactiveView); -} - -void CExplorerView::OnViewLargeicon() -{ - m_wndList.ModifyStyle(LVS_TYPEMASK, LVS_ICON); -} - -void CExplorerView::OnUpdateViewLargeicon(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio ((m_wndList.GetStyle () & LVS_TYPEMASK) == LVS_ICON); -} - -void CExplorerView::OnViewDetails() -{ - m_wndList.ModifyStyle(LVS_TYPEMASK, LVS_REPORT); -} - -void CExplorerView::OnUpdateViewDetails(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio ((m_wndList.GetStyle () & LVS_TYPEMASK) == LVS_REPORT); -} - -void CExplorerView::OnViewList() -{ - m_wndList.ModifyStyle(LVS_TYPEMASK, LVS_LIST); -} - -void CExplorerView::OnUpdateViewList(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio ((m_wndList.GetStyle () & LVS_TYPEMASK) == LVS_LIST); -} - -void CExplorerView::OnViewSmallicon() -{ - m_wndList.ModifyStyle(LVS_TYPEMASK, LVS_SMALLICON); -} - -void CExplorerView::OnUpdateViewSmallicon(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio ((m_wndList.GetStyle () & LVS_TYPEMASK) == LVS_SMALLICON); -} - -BOOL CExplorerView::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} - -void CExplorerView::OnSetFocus(CWnd* pOldWnd) -{ - CView::OnSetFocus(pOldWnd); - m_wndList.SetFocus (); -} - -LRESULT CExplorerView::OnChangeFolder(WPARAM,LPARAM) -{ - CString strPath; - if (!m_wndList.GetCurrentFolder (strPath) && - !m_wndList.GetCurrentFolderName (strPath)) - { - strPath = _T("????"); - } - - if (AfxGetMainWnd () != NULL) - { - ((CMainFrame*) AfxGetMainWnd ())->SetCurrFolder (strPath); - } - - return 0; -} - -void CExplorerView::OnFolderUp() -{ - // - m_wndList.DisplayParentFolder (); - // -} - -void CExplorerView::OnUpdateFolderUp(CCmdUI* pCmdUI) -{ - pCmdUI->Enable (!m_wndList.IsDesktop ()); -} - -void CExplorerView::OnCopyTo() -{ - // - CString strPath; - // The this pointer points to the CExplorerView class which extends the CView class. - // CMFCShellListCtrl m_wndList - if (m_wndList.GetCurrentFolder (strPath) && - theApp.GetShellManager ()->BrowseForFolder (strPath, - this, strPath, _T("Copy the selected item(s) to the folder:"))) - { - MessageBox (CString (_T("The selected path is: ")) + strPath); - } - // -} - -void CExplorerView::OnMoveTo() -{ - CString strPath; - if (m_wndList.GetCurrentFolder (strPath) && - theApp.GetShellManager ()->BrowseForFolder (strPath, - this, strPath, _T("Move the selected item(s) to the folder:"))) - { - MessageBox (CString (_T("The selected path is: ")) + strPath); - } -} - -void CExplorerView::OnViewRefresh() -{ - m_wndList.Refresh (); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerView.h deleted file mode 100644 index 3d4f81bcaff5a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ExplorerView.h +++ /dev/null @@ -1,71 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CExplorerView : public CView -{ -protected: // create from serialization only - CExplorerView(); - DECLARE_DYNCREATE(CExplorerView) - -// Attributes -public: - CExplorerDoc* GetDocument(); - // - CMFCShellListCtrl m_wndList; - // - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual void OnInitialUpdate(); // called first time after construct - virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView); - -// Implementation -public: - virtual ~CExplorerView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnViewLargeicon(); - afx_msg void OnUpdateViewLargeicon(CCmdUI* pCmdUI); - afx_msg void OnViewDetails(); - afx_msg void OnUpdateViewDetails(CCmdUI* pCmdUI); - afx_msg void OnViewList(); - afx_msg void OnUpdateViewList(CCmdUI* pCmdUI); - afx_msg void OnViewSmallicon(); - afx_msg void OnUpdateViewSmallicon(CCmdUI* pCmdUI); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnFolderUp(); - afx_msg void OnUpdateFolderUp(CCmdUI* pCmdUI); - afx_msg void OnCopyTo(); - afx_msg void OnMoveTo(); - afx_msg void OnViewRefresh(); - afx_msg LRESULT OnChangeFolder(WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in ExplorerView.cpp -inline CExplorerDoc* CExplorerView::GetDocument() - { return (CExplorerDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/FolderBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/FolderBar.cpp deleted file mode 100644 index f6c3f2dc85798..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/FolderBar.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "explorer.h" -#include "FolderBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int idTree = 1; - -///////////////////////////////////////////////////////////////////////////// -// CFolderBar - -CFolderBar::CFolderBar() -{ -// m_nSize = 300; // Initial width -} - -CFolderBar::~CFolderBar() -{ -} - - -BEGIN_MESSAGE_MAP(CFolderBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_SETFOCUS() - ON_WM_ERASEBKGND() -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CFolderBar message handlers - -int CFolderBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - // - // const int idTree = 1 - CRect rectDummy (0, 0, 0, 0); - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | - TVS_LINESATROOT | TVS_HASBUTTONS; - - // The this pointer points to CFolderBar class which extends the CDockablePane class - m_wndShellTree.Create (dwViewStyle, rectDummy, this, idTree); - // - return 0; -} - -void CFolderBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - m_wndShellTree.SetWindowPos (NULL, 0, 0, - cx, cy, - SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CFolderBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - m_wndShellTree.SetFocus (); -} - -BOOL CFolderBar::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/FolderBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/FolderBar.h deleted file mode 100644 index b53b2d055aad0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/FolderBar.h +++ /dev/null @@ -1,44 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CFolderBar window - -class CFolderBar : public CDockablePane -{ -// Construction -public: - CFolderBar(); - -// Attributes -public: - // - CMFCShellTreeCtrl m_wndShellTree; - // - -// Operations -public: - -// Overrides - -// Implementation -public: - virtual ~CFolderBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/MainFrm.cpp deleted file mode 100644 index d9aaf47640ba7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/MainFrm.cpp +++ /dev/null @@ -1,382 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Explorer.h" - -#include "MainFrm.h" -#include "ExplorerDoc.h" -#include "ExplorerView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_COMMAND(ID_VIEW_FOLDERS, OnViewFolders) - ON_UPDATE_COMMAND_UI(ID_VIEW_FOLDERS, OnUpdateViewFolders) - ON_CBN_SELENDOK(AFX_IDW_TOOLBAR + 1, OnNewAddress) - ON_COMMAND(IDOK, OnNewAddressEnter) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // enable Windows XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - - CMFCToolBar::EnableQuickCustomization (); - - //--------------------------------- - // Set toolbar and menu image size: - //--------------------------------- - CMFCToolBar::SetSizes (CSize (28, 28), CSize (22, 22)); - CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16)); - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_COMMAND_HISTORY); - lstBasicCommands.AddTail (ID_VIEW_LARGEICON); - lstBasicCommands.AddTail (ID_VIEW_SMALLICON); - lstBasicCommands.AddTail (ID_VIEW_LIST); - lstBasicCommands.AddTail (ID_VIEW_DETAILS); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_COPY); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Remove menubar gripper and borders: - m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() & - ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - UINT uiToolbarColdID = bIsHighColor ? IDB_TOOLBARCOLD256 : 0; - UINT uiMenuID = bIsHighColor ? IDB_MENU256 : IDB_MENU16; - - if (!m_wndToolBar.CreateEx(this) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, uiToolbarColdID, uiMenuID, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - // Remove toolbar gripper and borders: - m_wndToolBar.SetPaneStyle (m_wndToolBar.GetPaneStyle() & - ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - //---------------------------------------- - // Create a combo box for the address bar: - //---------------------------------------- - if (!m_wndAddress.Create (CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 1)) - { - TRACE0("Failed to create combobox\n"); - return -1; // fail to create - } - - // Each rebar pane will occupy its own row: - DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK; - - if (!m_wndReBar.Create(this) || - !m_wndReBar.AddBar (&m_wndMenuBar) || - !m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle) || - !m_wndReBar.AddBar(&m_wndAddress, _T("Address"), NULL, dwStyle)) - { - TRACE0("Failed to create rebar\n"); - return -1; // fail to create - } - - m_wndMenuBar.AdjustLayout (); - m_wndToolBar.AdjustLayout (); - - // TODO: Remove this if you don't want chevrons: - m_wndMenuBar.EnableCustomizeButton (TRUE, -1, _T("")); - m_wndToolBar.EnableCustomizeButton (TRUE, -1, _T("")); - - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - if (!m_wndFoldersBar.Create (_T("Folders"), - this, CRect (0, 0, 200, 200), TRUE, ID_VIEW_FOLDERS, - WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_HIDE_INPLACE | WS_CAPTION)) - { - TRACE0("Failed to create folders bar\n"); - return -1; // fail to create - } - - EnableDocking (CBRS_ALIGN_ANY); - - m_wndReBar.EnableDocking (CBRS_TOP); - DockPane (&m_wndReBar); - - m_wndFoldersBar.EnableDocking (CBRS_LEFT | CBRS_RIGHT); - DockPane (&m_wndFoldersBar); - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - - // TODO: Remove this if you don't want tool tips - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - if (uiToolBarId != IDR_MAINFRAME) - { - return 0; - } - - // Replace "Back" and "Forward" buttons by the menu buttons - // with the history lists: - - CMenu menuHistory; - menuHistory.LoadMenu (IDR_HISTORY_POPUP); - - // - // CMenu menuHistory - CMFCToolBarMenuButton btnBack (ID_GO_BACK, menuHistory, - GetCmdMgr ()->GetCmdImage (ID_GO_BACK), _T("Back")); - // - - btnBack.m_bText = TRUE; - m_wndToolBar.ReplaceButton (ID_GO_BACK, btnBack); - - m_wndToolBar.ReplaceButton (ID_GO_FORWARD, - CMFCToolBarMenuButton (ID_GO_FORWARD, menuHistory, - GetCmdMgr ()->GetCmdImage (ID_GO_FORWARD), _T("Forward"))); - - // "Folders" button has a text label: - m_wndToolBar.SetToolBarBtnText (m_wndToolBar.CommandToIndex (ID_VIEW_FOLDERS), - _T("Folders")); - - // Replace "Views" button by the menu button: - CMenu menuViews; - menuViews.LoadMenu (IDR_VIEWS_POPUP); - - m_wndToolBar.ReplaceButton (ID_VIEW_VIEWS, - CMFCToolBarMenuButton ((UINT)-1, menuViews, - GetCmdMgr ()->GetCmdImage (ID_VIEW_VIEWS), _T("Views"))); - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnViewFolders() -{ - ShowPane (&m_wndFoldersBar, - !(m_wndFoldersBar.GetStyle () & WS_VISIBLE), - FALSE,TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewFolders(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndFoldersBar.GetStyle () & WS_VISIBLE); -} - -CMFCShellTreeCtrl& CMainFrame::GetFolders () -{ - return m_wndFoldersBar.m_wndShellTree; -} - -void CMainFrame::SetCurrFolder (LPCTSTR lpszPath) -{ - ASSERT (lpszPath != NULL); - m_wndAddress.GetEditCtrl()->SetWindowText (lpszPath); -} - -void CMainFrame::OnNewAddress() -{ - // gets called when an item in the Address combo box is selected - // just navigate to the newly selected location. - CString str; - - m_wndAddress.GetLBText(m_wndAddress.GetCurSel(), str); - ((CExplorerView*)GetActiveView())->m_wndList.DisplayFolder (str); -} - -void CMainFrame::OnNewAddressEnter() -{ - CString str; - - m_wndAddress.GetEditCtrl()->GetWindowText(str); - ((CExplorerView*)GetActiveView())->m_wndList.DisplayFolder (str); - - COMBOBOXEXITEM item; - - item.mask = CBEIF_TEXT; - item.iItem = -1; - item.pszText = (LPTSTR)(LPCTSTR)str; - m_wndAddress.InsertItem(&item); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/MainFrm.h deleted file mode 100644 index 838dab01cb814..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/MainFrm.h +++ /dev/null @@ -1,66 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "FolderBar.h" - -#define CFrameWnd CFrameWndEx - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - CMFCShellTreeCtrl& GetFolders (); - -// Operations -public: - void SetCurrFolder (LPCTSTR lpszPath); - -// Overrides - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); - -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - CMFCReBar m_wndReBar; - CFolderBar m_wndFoldersBar; - CComboBoxEx m_wndAddress; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnViewFolders(); - afx_msg void OnUpdateViewFolders(CCmdUI* pCmdUI); - afx_msg void OnNewAddressEnter(); - afx_msg void OnNewAddress(); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ReadMe.htm deleted file mode 100644 index 8483e05689d81..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/ReadMe.htm +++ /dev/null @@ -1,124 +0,0 @@ - - - - Explorer Sample: MFC Windows Explorer Application - - -

- Explorer Sample: MFC Windows Explorer Application

-
-
-
- -

-

-
-

- The Explorer sample demonstrates how to implement a file system explorer similar - to the Windows Explorer, with similar user interface elements and capabilities.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the Explorer sample

-
-
    -
  1. -

    - Open the solution file Explorer.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The Explorer sample demonstrates the following keywords:

-

- CDockablePane; CFrameWndEx; CMFCMenuBar; CMFCPopupMenu; CMFCReBar; CMFCShellListCtrl; - CMFCShellTreeCtrl; CMFCStatusBar; CMFCToolBar; CMFCToolBarMenuButton; CMFCToolBarsCustomizeDialog; - CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Resource.h deleted file mode 100644 index 2a5528ae62fd6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Resource.h +++ /dev/null @@ -1,53 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Explorer.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define ID_VIEW_ARRANGE 127 -#define IDR_MAINFRAME 128 -#define IDR_EXPTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDB_TOOLBAR256 151 -#define IDB_TOOLBARCOLD256 152 -#define IDR_HISTORY_POPUP 154 -#define IDR_VIEWS_POPUP 155 -#define IDB_MENU256 155 -#define IDB_MENU16 156 -#define IDD_ABOUTBOX 999 -#define IDC_COMPANY_URL 1041 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_TOOLS_ENTRY 32805 -#define ID_USER_TOOL1 32806 -#define ID_USER_TOOL2 32807 -#define ID_USER_TOOL3 32808 -#define ID_USER_TOOL4 32809 -#define ID_USER_TOOL5 32810 -#define ID_USER_TOOL6 32811 -#define ID_USER_TOOL7 32812 -#define ID_USER_TOOL8 32813 -#define ID_USER_TOOL9 32814 -#define ID_USER_TOOL10 32815 -#define ID_VIEW_FOLDERS 32822 -#define ID_FOLDER_UP 32823 -#define ID_GO_BACK 32824 -#define ID_GO_FORWARD 32825 -#define ID_MOVE_TO 32826 -#define ID_COPY_TO 32827 -#define ID_VIEW_VIEWS 32828 -#define ID_COMMAND_HISTORY 32829 -#define ID_VIEW_REFRESH 32830 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 156 -#define _APS_NEXT_COMMAND_VALUE 32831 -#define _APS_NEXT_CONTROL_VALUE 1042 -#define _APS_NEXT_SYMED_VALUE 107 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Snippets.txt deleted file mode 100644 index 8be6eb27b9fef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/Snippets.txt +++ /dev/null @@ -1,9 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -ExplorerView.h: CMFCShellListCtrl 1 -ExplorerView.cpp: CMFCShellListCtrl 2 -ExplorerView.cpp: CMFCShellListCtrl 3 -FolderBar.h: CMFCShellTreeCtrl 4 -FolderBar.cpp: CMFCShellTreeCtrl 5 -ExplorerView.cpp: CShellManager 6 -MainFrm.cpp: CCommandManager 7 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/StdAfx.cpp deleted file mode 100644 index bd24b03f41dd1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/StdAfx.cpp +++ /dev/null @@ -1,10 +0,0 @@ -//******************************************************************************* -// -// stdafx.cpp : source file that includes just the standard includes -// Explorer.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/StdAfx.h deleted file mode 100644 index b9ac5b6aa9842..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/StdAfx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/explorer.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/explorer.vcxproj deleted file mode 100644 index 816310f87a761..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/explorer.vcxproj +++ /dev/null @@ -1,234 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {13E57A12-A533-4F1D-86C9-9870C789BE39} - Explorer - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Explorer.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Explorer.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Explorer.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Explorer.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Explorer.rc2 deleted file mode 100644 index 8f7f4af69bdae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Explorer.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// BCGVEXPLORER.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ExplorerDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ExplorerDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ExplorerDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar.bmp deleted file mode 100644 index fdcdd28baf953..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar256.bmp deleted file mode 100644 index 496ca35ceefc5..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ToolbarCold256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ToolbarCold256.bmp deleted file mode 100644 index 7c1347bc1d0d8..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ToolbarCold256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ToolbarCold_hc.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ToolbarCold_hc.png deleted file mode 100644 index 6132ed601d536..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/ToolbarCold_hc.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar_hc.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar_hc.png deleted file mode 100644 index 7c0c8c398ed88..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/Toolbar_hc.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu16.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu16.bmp deleted file mode 100644 index e481a4d701979..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu16.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu256.bmp deleted file mode 100644 index 184f7649581a6..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu_hc.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu_hc.png deleted file mode 100644 index 68c486cd3a3ba..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/res/menu_hc.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Explorer/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ExplorerBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ExplorerBar.cpp deleted file mode 100644 index c79200d99d0b6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ExplorerBar.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" -#include "ExplorerBar.h" -#include "IEDemoDoc.h" -#include "IEDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int idTree = 1; - -///////////////////////////////////////////////////////////////////////////// -// CExplorerBar - -CExplorerBar::CExplorerBar() -{ -} - -CExplorerBar::~CExplorerBar() -{ -} - -BEGIN_MESSAGE_MAP(CExplorerBar, CMFCTasksPane) - //{{AFX_MSG_MAP(CExplorerBar) - ON_WM_CREATE() - //}}AFX_MSG_MAP - ON_NOTIFY(TVN_SELCHANGED, idTree, OnSelectTree) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CExplorerBar message handlers - -int CExplorerBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMFCTasksPane::OnCreate(lpCreateStruct) == -1) - return -1; - - SetWindowText (_T("Explorer Bar")); - EnableOffsetCustomControls (FALSE); - - // ---------------------- - // Create favorites list: - // ---------------------- - CRect rectDummy (0, 0, 0, 0); - const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_SINGLEEXPAND | TVS_TRACKSELECT; - - if(!m_wndFavorites.Create (dwTreeStyle, rectDummy, - this, idTree)) - { - TRACE0("Failed to create the Favorites window\n"); - return FALSE; // fail to create - } - - theApp.m_Favorites.FillTree (m_wndFavorites); - - // ----------- - // Add groups: - // ----------- - int nGroup1 = AddGroup (_T("Favorites"), FALSE, TRUE); - AddWindow (nGroup1, m_wndFavorites.GetSafeHwnd (), 200); - - int nGroup2 = AddGroup (_T("Links")); - - AddTask (nGroup2, _T("MSDN Home"), -1, ID_LINK_MSDN); - AddTask (nGroup2, _T("Microsoft Home"), -1, ID_LINK_MICROSOFT); - AddTask (nGroup2, _T("Visual C++ Developer Center"), -1, ID_LINK_VISUALCPP); - - return 0; -} -//************************************************************************************ -void CExplorerBar::OnSelectTree(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - HTREEITEM hTreeItem = m_wndFavorites.GetSelectedItem (); - if (hTreeItem != NULL) - { - CFavorit* pFavorit = (CFavorit*) m_wndFavorites.GetItemData (hTreeItem); - ASSERT_VALID (pFavorit); - - if (!pFavorit->GetURL ().IsEmpty ()) - { - CIEDemoView* pView = - (CIEDemoView*)((CFrameWnd*) AfxGetMainWnd ())->GetActiveView (); - ASSERT_VALID (pView); - - pView->Navigate2 (pFavorit->GetURL ()); - } - } - - *pResult = 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ExplorerBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ExplorerBar.h deleted file mode 100644 index 89cc119080064..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ExplorerBar.h +++ /dev/null @@ -1,50 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -// ExplorerBar.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CExplorerBar window - -class CExplorerBar : public CMFCTasksPane -{ -// Construction -public: - CExplorerBar(); - -// Attributes -protected: - CTreeCtrl m_wndFavorites; - -// Operations -protected: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CExplorerBar) - //}}AFX_VIRTUAL - -protected: - -// Implementation -public: - virtual ~CExplorerBar(); - - // Generated message map functions -protected: - //{{AFX_MSG(CExplorerBar) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - //}}AFX_MSG - afx_msg void OnSelectTree(NMHDR* pNMHDR, LRESULT* pResult); - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/FavoritesManager.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/FavoritesManager.cpp deleted file mode 100644 index 48b961c246e83..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/FavoritesManager.cpp +++ /dev/null @@ -1,337 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include -#include "IEDemo.h" -#include "FavoritesManager.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -CMap CFavorit::m_URLIcons; -CMap CFavorit::m_IDIcons; -UINT CFavorit::m_uiNextCommand = FIRST_FAVORITE_COMMAND; -int CFavorit::m_iFolderIcon = -1; -int CFavorit::m_iInternetShortcutIcon = -1; - -CFavorit::CFavorit (LPCTSTR lpszName, int iIcon, LPCTSTR lpszURL, UINT uiCommand) -{ - m_strName = lpszName; - m_iIcon = iIcon; - - if (lpszURL != NULL) - { - m_strURL = lpszURL; - } - - m_uiCommand = uiCommand; - - if (uiCommand != 0) - { - m_IDIcons.SetAt (uiCommand, iIcon); - } -} -//************************************************************************************* -CFavorit::CFavorit () -{ - m_uiCommand = 0; - m_iIcon = -1; -} -//************************************************************************************* -CFavorit::~CFavorit() -{ - CleanUp (); -} -//************************************************************************************* -void CFavorit::CleanUp () -{ - m_uiCommand = 0; - m_iIcon = -1; - - while (!m_lstSubItems.IsEmpty ()) - { - delete m_lstSubItems.RemoveHead (); - } -} -//************************************************************************************* -const CFavorit* CFavorit::FindByID (UINT uiCommandID) const -{ - if (m_uiCommand == uiCommandID) - { - return this; - } - - for (POSITION pos = m_lstSubItems.GetHeadPosition (); pos != NULL;) - { - CFavorit* pFavorit = (CFavorit*) m_lstSubItems.GetNext (pos); - ASSERT_VALID (pFavorit); - - const CFavorit* pFavoritFound = pFavorit->FindByID (uiCommandID); - if (pFavoritFound != NULL) - { - return pFavoritFound; - } - } - - return NULL; -} -//************************************************************************************* -BOOL CFavorit::Build (CString strPath) -{ - // make sure there's a trailing backslash - if (strPath.GetLength () == 0 || - strPath [strPath.GetLength () - 1] != _T('\\')) - { - strPath += _T('\\'); - } - - // Prepare file mask: - CString strFileMask = strPath; - strFileMask += _T("*.*"); - - // Start find all files in specific directory: - WIN32_FIND_DATA fd; - HANDLE hFile = FindFirstFile (strFileMask, &fd); - if (hFile == INVALID_HANDLE_VALUE) - { - return FALSE; - } - - do - { - CString strName = fd.cFileName; - if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - if (strName != _T(".") && strName != _T("..")) - { - CFavorit* pSubFavorit = new CFavorit (strName, m_iFolderIcon, NULL); - ASSERT_VALID (pSubFavorit); - - pSubFavorit->Build (strPath + strName); - - // Add to end of folders: - BOOL bAdded = FALSE; - for (POSITION pos = m_lstSubItems.GetTailPosition (); pos != NULL;) - { - POSITION posSave = pos; - - CFavorit* pListFavorit = (CFavorit*) m_lstSubItems.GetPrev (pos); - ASSERT_VALID (pListFavorit); - - if (pListFavorit->m_uiCommand == 0) - { - m_lstSubItems.InsertAfter (posSave, pSubFavorit); - bAdded = TRUE; - break; - } - } - - if (!bAdded) - { - m_lstSubItems.AddTail (pSubFavorit); - } - } - } - else if (strName.Right (4).CompareNoCase (_T(".url")) == 0) - { - CString strFilePath = strPath + strName; - - // an .URL file is formatted just like an .INI file, so we can - // use GetPrivateProfileString() to get the information we want - TCHAR szURL [INTERNET_MAX_PATH_LENGTH + 1]; - ::GetPrivateProfileString (_T("InternetShortcut"), _T("URL"), - _T(""), szURL, INTERNET_MAX_PATH_LENGTH, - strFilePath); - - // Obtain URL icon: - TCHAR ext[_MAX_EXT]; - _tsplitpath_s (szURL, NULL, 0, NULL, 0, NULL, 0, ext, _MAX_EXT); - - int iIcon = 0; - if (!m_URLIcons.Lookup (ext, iIcon)) - { - // Retrieve icon file - SHFILEINFO sfi; - if (::SHGetFileInfo (strFilePath, 0, &sfi, sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX) && - sfi.iIcon >= 0) - { - m_URLIcons.SetAt (ext, sfi.iIcon); - iIcon = sfi.iIcon; - - if (m_iInternetShortcutIcon == -1) - { - m_iInternetShortcutIcon = sfi.iIcon; - } - } - } - - strName = strName.Left (strName.GetLength () - 4); - - m_lstSubItems.AddTail (new CFavorit ( - strName, iIcon, szURL, m_uiNextCommand ++)); - } - } - while (FindNextFile (hFile, &fd)); - FindClose (hFile); - - return TRUE; -} -//************************************************************************************* -BOOL CFavorit::CreateMenu (CMenu& menu) -{ - ASSERT (menu.GetSafeHmenu () == NULL); - ASSERT (m_uiCommand == 0); - - if (!menu.CreatePopupMenu ()) - { - ASSERT (FALSE); - return FALSE; - } - - for (POSITION pos = m_lstSubItems.GetHeadPosition (); pos != NULL;) - { - CFavorit* pFavorit = (CFavorit*) m_lstSubItems.GetNext (pos); - ASSERT_VALID (pFavorit); - - if (pFavorit->m_uiCommand != 0) - { - menu.InsertMenu ((UINT)-1, MF_BYPOSITION | MF_STRING, pFavorit->m_uiCommand, - pFavorit->m_strName); - } - else - { - CMenu subMenu; - if (pFavorit->CreateMenu (subMenu)) - { - menu.InsertMenu ((UINT) -1, MF_BYPOSITION | MF_POPUP | MF_STRING, - (UINT_PTR) subMenu.Detach (), pFavorit->m_strName); - } - } - } - - return TRUE; -} -//************************************************************************************ -void CFavorit::FillTree (CTreeCtrl& wndTree, HTREEITEM htreeItemParent) -{ - for (POSITION pos = m_lstSubItems.GetHeadPosition (); pos != NULL;) - { - CFavorit* pFavorit = (CFavorit*) m_lstSubItems.GetNext (pos); - ASSERT_VALID (pFavorit); - - HTREEITEM hTreeItem = wndTree.InsertItem (pFavorit->m_strName, - pFavorit->m_iIcon, pFavorit->m_iIcon, htreeItemParent); - wndTree.SetItemData (hTreeItem, (DWORD_PTR) pFavorit); - - pFavorit->FillTree (wndTree, hTreeItem); - } -} - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFavoritesManager::CFavoritesManager() -{ - m_himSystem = NULL; - m_SysImageSize = CSize (0, 0); -} -//************************************************************************************* -CFavoritesManager::~CFavoritesManager() -{ -} -//************************************************************************************ -BOOL CFavoritesManager::Load () -{ - HKEY hKey; - - // find out from the registry where the favorites are located. - if(RegOpenKey (HKEY_CURRENT_USER, - _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"), - &hKey) != ERROR_SUCCESS) - { - TRACE0("Favorites folder not found\n"); - return FALSE; - } - - TCHAR sz [MAX_PATH]; - DWORD dwSize = sizeof(sz); - - RegQueryValueEx(hKey, _T("Favorites"), NULL, NULL, (LPBYTE)sz, &dwSize); - - TCHAR szPath [MAX_PATH]; - ExpandEnvironmentStrings(sz, szPath, MAX_PATH); - - RegCloseKey(hKey); - - SHFILEINFO sfi; - m_himSystem = (HIMAGELIST)SHGetFileInfo( szPath, - 0, - &sfi, - sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - if (m_himSystem != NULL) - { - int cx, cy; - - ::ImageList_GetIconSize (m_himSystem, &cx, &cy); - m_SysImageSize = CSize (cx, cy); - - CFavorit::m_iFolderIcon = sfi.iIcon; - } - - m_Root.Build (szPath); - return TRUE; -} -//************************************************************************************* -BOOL CFavoritesManager::CreateMenu (CMenu& menu) -{ - return m_Root.CreateMenu (menu); -} -//************************************************************************************* -void CFavoritesManager::FillTree (CTreeCtrl& wndTree) -{ - ASSERT (wndTree.GetSafeHwnd () != NULL); - - wndTree.DeleteAllItems (); - wndTree.SetImageList (CImageList::FromHandle (m_himSystem), TVSIL_NORMAL); - m_Root.FillTree (wndTree, NULL); -} -//************************************************************************************* -int CFavoritesManager::GetIDIcon (UINT uiCommandID) const -{ - int iIcon = -1; - CFavorit::m_IDIcons.Lookup (uiCommandID, iIcon); - - return iIcon; -} -//************************************************************************************ -CString CFavoritesManager::GetURLofID (UINT uiCommandID) const -{ - if (uiCommandID == 0) - { - ASSERT (FALSE); - return _T(""); - } - - const CFavorit* pFavorit = m_Root.FindByID (uiCommandID); - if (pFavorit == NULL) - { - ASSERT (FALSE); - return _T(""); - } - - return pFavorit->m_strURL; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/FavoritesManager.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/FavoritesManager.h deleted file mode 100644 index 2d4129ee58564..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/FavoritesManager.h +++ /dev/null @@ -1,125 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define FIRST_FAVORITE_COMMAND 0xe00 -#define LAST_FAVORITE_COMMAND 0xfff - -class CFavorit : public CObject -{ - friend class CFavoritesManager; - -// Construction/Destruction -public: - CFavorit (LPCTSTR lpszName, int iIcon, LPCTSTR lpszURL, UINT uiCommand = 0); - virtual ~CFavorit(); - -protected: - CFavorit(); - -// Operations: -public: - const CFavorit* FindByID (UINT uiCommandID) const; - -protected: - void CleanUp (); - BOOL Build (CString strPath); - BOOL CreateMenu (CMenu& menu); - void FillTree (CTreeCtrl& wndTree, HTREEITEM htreeItemParent); - -// Attributes: -public: - const CString& GetName () const - { - return m_strName; - } - - const CString& GetURL () const - { - return m_strURL; - } - - int GetIcon () const - { - return m_iIcon; - } - - UINT GetCommand () const - { - return m_uiCommand; - } - - const CObList& GetSubItems () const - { - return m_lstSubItems; - } - -protected: - CString m_strName; - CString m_strURL; - UINT m_uiCommand; - int m_iIcon; - - CObList m_lstSubItems; // List of CFavorit objects - - static CMap m_URLIcons; - static CMap m_IDIcons; - static UINT m_uiNextCommand; - static int m_iFolderIcon; - static int m_iInternetShortcutIcon; -}; - - -class CFavoritesManager : public CObject -{ -// Construction/Destruction -public: - CFavoritesManager(); - virtual ~CFavoritesManager(); - -// Operations: -public: - BOOL Load (); - BOOL CreateMenu (CMenu& menu); - void FillTree (CTreeCtrl& wndTree); - -// Attributes: -public: - HIMAGELIST GetSysImages () const - { - return m_himSystem; - } - - CSize GetSysImageSize () const - { - return m_SysImageSize; - } - - int GetFolderIcon () const - { - return CFavorit::m_iFolderIcon; - } - - int GetInternetShortcutIcon () const - { - return CFavorit::m_iInternetShortcutIcon; - } - - int GetIDIcon (UINT uiCommandID) const; - - CString GetURLofID (UINT uiCommandID) const; - -protected: - CFavorit m_Root; - - HIMAGELIST m_himSystem; - CSize m_SysImageSize; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/HistoryObj.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/HistoryObj.cpp deleted file mode 100644 index 4965954845b59..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/HistoryObj.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" -#include "HistoryObj.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CHistoryObj::CHistoryObj(const CString& strTitle, const CString& strURL, - const UINT uiCommand) : - m_strTitle (strTitle), - m_strURL (strURL), - m_uiCommand (uiCommand) -{ -} - -CHistoryObj::~CHistoryObj() -{ -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/HistoryObj.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/HistoryObj.h deleted file mode 100644 index 9479a2bc80dfc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/HistoryObj.h +++ /dev/null @@ -1,39 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CHistoryObj -{ -public: - CHistoryObj(const CString& strTitle, const CString& strURL, const UINT uiCommand); - virtual ~CHistoryObj(); - - LPCTSTR GetTitle () const - { - return m_strTitle; - } - - LPCTSTR GetURL () const - { - return m_strURL; - } - - UINT GetCommand () const - { - return m_uiCommand; - } - -protected: - const CString m_strTitle; - const CString m_strURL; - const UINT m_uiCommand; -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.cpp deleted file mode 100644 index 58ead1341eabf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" -#include "MainFrm.h" - -#include "IEDemoDoc.h" -#include "IEDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CIEDemoApp - -BEGIN_MESSAGE_MAP(CIEDemoApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - - -// CIEDemoApp construction - -CIEDemoApp::CIEDemoApp() : - CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - - -// The one and only CIEDemoApp object - -CIEDemoApp theApp; - - -// CIEDemoApp initialization - -BOOL CIEDemoApp::InitInstance() -{ - // InitCommonControlsEx() is required on Windows XP if an application - // manifest specifies use of ComCtl32.dll version 6 or later to enable - // visual styles. Otherwise, any window creation will fail. - INITCOMMONCONTROLSEX InitCtrls; - InitCtrls.dwSize = sizeof(InitCtrls); - // Set this to include all the common control classes you want to use - // in your application. - InitCtrls.dwICC = ICC_WIN95_CLASSES; - InitCommonControlsEx(&InitCtrls); - - CWinApp::InitInstance(); - - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - AfxEnableControlContainer(); - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - LoadStdProfileSettings(4); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitKeyboardManager(); - - // Initialize favorites: - m_Favorites.Load (); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CIEDemoDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CIEDemoView)); - if (!pDocTemplate) - return FALSE; - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - // call DragAcceptFiles only if there's a suffix - // In an SDI app, this should occur after ProcessShellCommand - return TRUE; -} - -// CIEDemoApp message handlers - -int CIEDemoApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CIEDemoApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -// CIEDemoApp message handlers - - -void CIEDemoApp::PreLoadState () -{ -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.h deleted file mode 100644 index cb529c6da75a0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.h +++ /dev/null @@ -1,44 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols -#include "FavoritesManager.h" - -// CIEDemoApp: -// See IEDemo.cpp for the implementation of this class -// - -class CIEDemoApp : public CWinAppEx -{ -public: - CIEDemoApp(); - - // Override from CWorkspace - virtual void PreLoadState (); - - CFavoritesManager m_Favorites; - -// Overrides -public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - DECLARE_MESSAGE_MAP() -}; - -extern CIEDemoApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.rc deleted file mode 100644 index f9af31b5fb1e8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemo.rc +++ /dev/null @@ -1,518 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\IEDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\IEDemo.ico" -IDR_IEDTYPE ICON "res\\IEDemoDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_POPUP_TOOLBAR MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "Standard &Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Address Bar", ID_VIEW_ADDRESS_BAR - MENUITEM "&Links", ID_VIEW_LINKS_BAR - MENUITEM "&Explorer Bar", ID_VIEW_EXPLORERBAR - MENUITEM SEPARATOR - MENUITEM "Te&xt Labels", ID_VIEW_TEXTLABELS - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -IDR_FAVORITES_POPUP MENU -BEGIN - MENUITEM "", ID_FAVORITES_DUMMY -END - -IDR_FONT_POPUP MENU -BEGIN - POPUP "Font" - BEGIN - MENUITEM "Lar&gest", ID_VIEW_FONTS_LARGEST - MENUITEM "&Larger", ID_VIEW_FONTS_LARGE - MENUITEM "&Medium", ID_VIEW_FONTS_MEDIUM - MENUITEM "&Smaller", ID_VIEW_FONTS_SMALL - MENUITEM "Sm&allest", ID_VIEW_FONTS_SMALLEST - END -END - -IDR_HISTORY_POPUP MENU -BEGIN - MENUITEM "", ID_HISTORY_DUMMY -END - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM SEPARATOR - MENUITEM "&Close", ID_APP_EXIT - END - POPUP "&View" - BEGIN - MENUITEM "&Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "&Address Bar", ID_VIEW_ADDRESS_BAR - MENUITEM "&Links", ID_VIEW_LINKS_BAR - MENUITEM "&Explorer Bar", ID_VIEW_EXPLORERBAR - MENUITEM SEPARATOR - POPUP "Fo&nts" - BEGIN - MENUITEM "Largest", ID_VIEW_FONTS_LARGEST - MENUITEM "Large", ID_VIEW_FONTS_LARGE - MENUITEM "Medium", ID_VIEW_FONTS_MEDIUM - MENUITEM "Small", ID_VIEW_FONTS_SMALL - MENUITEM "Smallest", ID_VIEW_FONTS_SMALLEST - END - MENUITEM SEPARATOR - MENUITEM "Sto&p\tEsc", ID_VIEW_STOP - MENUITEM "&Refresh\tF5", ID_VIEW_REFRESH - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END - POPUP "&Go" - BEGIN - MENUITEM "&Back\tAlt+Left Arrow", ID_GO_BACK - MENUITEM "&Forward\tAlt+Right Arrow", ID_GO_FORWARD - MENUITEM SEPARATOR - MENUITEM "&Start Page", ID_GO_START_PAGE - MENUITEM "Search the &Web", ID_GO_SEARCH_THE_WEB - END - POPUP "F&avorites" - BEGIN - MENUITEM "", ID_FAVORITES_DUMMY - END - POPUP "&Help" - BEGIN - MENUITEM "&About IEDemo...", ID_APP_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About IEDemo" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "IEDemo Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT "� 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDR_MAINFRAME DIALOG 0, 0, 330, 16 -STYLE DS_SETFONT | WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "TODO: layout dialog bar ",IDC_STATIC,12,4,300,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "IEDemo MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "IEDemo" - VALUE "LegalCopyright", "Copyright (C) 2007 Microsoft Corporation" - VALUE "OriginalFilename", "IEDemo.EXE" - VALUE "ProductName", "IEDemo Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_COLDTOOLBAR BITMAP "res\\coldtool.bmp" -IDB_HOTTOOLBAR BITMAP "res\\hottoolb.bmp" -IDB_MENU_IMAGES BITMAP "res\\menu_img.bmp" -IDR_MAINFRAME BITMAP "res\\toolbar.bmp" -IDR_TOOLBAR_IMAGE_COLLECTION BITMAP "res\\toolbar1.bmp" -IDB_IMAGE_COLLECTION BITMAP "res\\image_col.bmp" -IDB_IMAGE_COLLECTION_SMALL BITMAP "res\\image_small.bmp" -IDB_MENU_IMAGES_16 BITMAP "res\\menu_images_16.bmp" -IDB_STATUS_READY BITMAP "res\\status_r.bmp" -IDB_STATUS_ANIMATION BITMAP "res\\status_a.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 23, 23 -BEGIN - BUTTON ID_GO_BACK - BUTTON ID_GO_FORWARD - BUTTON ID_VIEW_STOP - BUTTON ID_VIEW_REFRESH - BUTTON ID_GO_START_PAGE - BUTTON ID_GO_SEARCH_THE_WEB - BUTTON ID_FAVORITES_DUMMY - BUTTON ID_FILE_PRINT - BUTTON ID_FONT_DROPDOWN -END - -IDR_TOOLBAR_IMAGE_COLLECTION TOOLBAR 23, 23 -BEGIN - BUTTON ID_LINK_1 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "IEDemo\n\nIED\n\n\nIEDemo.Document\nIED Document" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "IEDemo" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" - ID_VIEW_STOP "Stops opening a file\nStop" - ID_VIEW_REFRESH "Refreshes the contents of the current page\nRefresh" - ID_LINK_1 "Open this page" - ID_VIEW_FONTS_LARGEST "Selects largest font size" - ID_VIEW_FONTS_LARGE "Selects large font size" -END - -STRINGTABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" - ID_INDICATOR_ICON " " - ID_INDICATOR_PROGRESS " " - IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed." -END - -STRINGTABLE -BEGIN - IDS_WEB_TUTORIAL "http://www.microsoft.com/magazine/guides/internet/" - IDS_ONLINE_SUPPORT "http://www.microsoft.com/iesupport/" - IDS_FREE_STUFF "http://www.microsoft.com/ie/download/" - IDS_INTERNET_START_PAGE "http://home.microsoft.com/" - IDS_BEST_OF_THE_WEB "http://home.microsoft.com/exploring/exploring.asp" - IDS_MICROSOFT_HOME_PAGE "http://www.microsoft.com/" - IDS_BACK "Back" - IDS_FORWARD "Forward" - IDS_STOP "Stop" - IDS_REFRESH "Refresh" -END - -STRINGTABLE -BEGIN - IDS_HOME "Home" - IDS_SEARCH "Search" - IDS_FAVORITES "Favorites" - IDS_PRINT "Print" - IDS_FONT "Font" - IDS_ADDRESS "Address: " - IDS_LINKS "Links: " -END - -STRINGTABLE -BEGIN - IDS_FILETYPES "HTML Files|*.htm;*.html|Text Files|*.txt|GIF Files|*.gif|JPEG Files|*.jpg;*.jpeg|AU Files|*.au|AIFF Files|*.aif;*.aiff|XBM Files|*.xbm|All Files|*.*||" -END - -STRINGTABLE -BEGIN - ID_VIEW_FONTS_MEDIUM "Selects medium font size." - ID_VIEW_FONTS_SMALL "Selects small font size." - ID_VIEW_FONTS_SMALLEST "Selects smallest font size." - ID_GO_BACK "Goes back one step.\nBack" - ID_GO_FORWARD "Goes forward one step.\nForward" - ID_GO_START_PAGE "Opens your start page.\nStart Page" - ID_GO_SEARCH_THE_WEB "Opens your search page.\nSearch" - ID_GO_BEST_OF_THE_WEB "Opens the Best of the Web page." - ID_FAVORITES_DROPDOWN "View list of your personal favorites.\nFavorites" - ID_FONT_DROPDOWN "Change font size.\nFonts" - ID_HELP_WEB_TUTORIAL "Opens the Web tutorial page (on the Internet)." -END - -STRINGTABLE -BEGIN - ID_VIEW_ADDRESS_BAR "Show or hide the address bar\nToggle AddressBar" -END - -STRINGTABLE -BEGIN - ID_VIEW_LINKS_BAR "Show or hide the links bar\nToggle LinksBar" - ID_VIEW_TEXTLABELS "Toggle text labels on the main tollbars\nText Labels" - ID_VIEW_EXPLORERBAR "Show or hide the explorer bar\nToggle Explorer Bar" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\IEDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoDoc.cpp deleted file mode 100644 index 578699a6085c0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoDoc.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" - -#include "IEDemoDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoDoc - -IMPLEMENT_DYNCREATE(CIEDemoDoc, CDocument) - -BEGIN_MESSAGE_MAP(CIEDemoDoc, CDocument) - //{{AFX_MSG_MAP(CIEDemoDoc) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoDoc construction/destruction - -CIEDemoDoc::CIEDemoDoc() -{ - m_iHistoryOffset = 0; - m_arHistory.SetSize (0, 1); -} - -CIEDemoDoc::~CIEDemoDoc() -{ - for (int i = 0; i < m_arHistory.GetSize (); i ++) - { - ASSERT (m_arHistory [i] != NULL); - delete m_arHistory [i]; - } -} - -BOOL CIEDemoDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoDoc serialization - -void CIEDemoDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoDoc diagnostics - -#ifdef _DEBUG -void CIEDemoDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CIEDemoDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoDoc commands - -CHistoryObj* CIEDemoDoc::AddURLToHistory (const CString& strTitle, const CString& strURL) -{ - ASSERT (m_arHistory.GetSize () <= HISTORY_LEN); - - for (int i = 0; i < m_arHistory.GetSize (); i ++) - { - CHistoryObj* pObj = m_arHistory [i]; - ASSERT (pObj != NULL); - - if (pObj && pObj->GetTitle () == strTitle && pObj->GetURL () == strURL) - { - return pObj; - } - } - - if (m_arHistory.GetSize () == HISTORY_LEN) - { - delete m_arHistory [0]; - m_arHistory.RemoveAt (0); - } - - CHistoryObj* pObj = new CHistoryObj (strTitle, strURL, - FIRST_HISTORY_COMMAND + (UINT)m_arHistory.GetSize ()); - m_arHistory.InsertAt (0, pObj); - - m_iHistoryOffset = 0; - return pObj; -} -//**************************************************************************************** -void CIEDemoDoc::GetBackList (_T_HistotyList& lst) const -{ - lst.RemoveAll (); - for (int i = m_iHistoryOffset + 1; i < m_arHistory.GetSize () ; i ++) - { - lst.AddTail (m_arHistory [i]); - } -} -//**************************************************************************************** -void CIEDemoDoc::GetFrwdList (_T_HistotyList& lst) const -{ - lst.RemoveAll (); - for (int i = m_iHistoryOffset - 1; i >= 0; i --) - { - ASSERT (i < m_arHistory.GetSize ()); - lst.AddTail (m_arHistory [i]); - } -} -//**************************************************************************************** -CHistoryObj* CIEDemoDoc::Go (UINT uiCmd) -{ - for (int i = 0; i < m_arHistory.GetSize (); i ++) - { - CHistoryObj* pObj = m_arHistory [i]; - ASSERT (pObj != NULL); - - if (pObj && pObj->GetCommand () == uiCmd) - { - m_arHistory.RemoveAt (i); - m_arHistory.Add (pObj); - - m_iHistoryOffset = 0; - return pObj; - } - } - - return NULL; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoDoc.h deleted file mode 100644 index b66d731a76983..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoDoc.h +++ /dev/null @@ -1,96 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define FIRST_HISTORY_COMMAND 0x1000 -#define HISTORY_LEN 10 - -#include "HistoryObj.h" - -typedef CList _T_HistotyList; - -class CIEDemoDoc : public CDocument -{ -protected: // create from serialization only - CIEDemoDoc(); - DECLARE_DYNCREATE(CIEDemoDoc) - -// Attributes -public: - CArray m_arHistory; - int m_iHistoryOffset; - -// Operations -public: - void GetBackList (_T_HistotyList& lst) const; - void GetFrwdList (_T_HistotyList& lst) const; - - BOOL IsBackAvailable () const - { - return m_iHistoryOffset < m_arHistory.GetSize () - 1; - } - - BOOL IsFrwdAvailable () - { - return m_iHistoryOffset > 0; - } - - CHistoryObj* GoBack () - { - if (m_iHistoryOffset >= m_arHistory.GetSize ()) - { - ASSERT (FALSE); - return NULL; - } - - return m_arHistory [++ m_iHistoryOffset]; - } - - CHistoryObj* GoForward () - { - if (m_iHistoryOffset < 1) - { - ASSERT (FALSE); - return NULL; - } - - return m_arHistory [--m_iHistoryOffset]; - } - - CHistoryObj* Go (UINT uiCmd); - CHistoryObj* AddURLToHistory (const CString& strTitle, const CString& strURL); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CIEDemoDoc) - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CIEDemoDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CIEDemoDoc) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoView.cpp deleted file mode 100644 index 7611598a7c146..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoView.cpp +++ /dev/null @@ -1,288 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" - -#include "IEDemoDoc.h" -#include "IEDemoView.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoView - -IMPLEMENT_DYNCREATE(CIEDemoView, CHtmlView) - -BEGIN_MESSAGE_MAP(CIEDemoView, CHtmlView) - //{{AFX_MSG_MAP(CIEDemoView) - ON_COMMAND(ID_GO_BACK, OnGoBack) - ON_COMMAND(ID_GO_FORWARD, OnGoForward) - ON_COMMAND(ID_GO_SEARCH_THE_WEB, OnGoSearchTheWeb) - ON_COMMAND(ID_GO_START_PAGE, OnGoStartPage) - ON_COMMAND(ID_VIEW_STOP, OnViewStop) - ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh) - ON_COMMAND(ID_VIEW_FONTS_LARGEST, OnViewFontsLargest) - ON_COMMAND(ID_VIEW_FONTS_LARGE, OnViewFontsLarge) - ON_COMMAND(ID_VIEW_FONTS_MEDIUM, OnViewFontsMedium) - ON_COMMAND(ID_VIEW_FONTS_SMALL, OnViewFontsSmall) - ON_COMMAND(ID_VIEW_FONTS_SMALLEST, OnViewFontsSmallest) - ON_COMMAND(ID_FILE_OPEN, OnFileOpen) - ON_UPDATE_COMMAND_UI(ID_GO_FORWARD, OnUpdateGoForward) - ON_UPDATE_COMMAND_UI(ID_GO_BACK, OnUpdateGoBack) - ON_WM_DESTROY() - //}}AFX_MSG_MAP - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CHtmlView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CHtmlView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, CHtmlView::OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoView construction/destruction - -CIEDemoView::CIEDemoView() -{ - // TODO: add construction code here - -} - -CIEDemoView::~CIEDemoView() -{ -} - -BOOL CIEDemoView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CHtmlView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoView drawing - -void CIEDemoView::OnDraw(CDC* /*pDC*/) -{ -// CIEDemoDoc* pDoc = GetDocument(); -// ASSERT_VALID(pDoc); - // TODO: add draw code for native data here -} - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoView printing - -BOOL CIEDemoView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CIEDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CIEDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoView diagnostics - -#ifdef _DEBUG -void CIEDemoView::AssertValid() const -{ - CHtmlView::AssertValid(); -} - -void CIEDemoView::Dump(CDumpContext& dc) const -{ - CHtmlView::Dump(dc); -} - -CIEDemoDoc* CIEDemoView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CIEDemoDoc))); - return (CIEDemoDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CIEDemoView message handlers -// these are all simple one-liners to do simple controlling of the browser -void CIEDemoView::OnGoBack() -{ - CIEDemoDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - CHistoryObj* pHistoryObj = pDoc->GoBack (); - if (pHistoryObj != NULL) - { - Navigate2 (pHistoryObj->GetURL (), 0, NULL); - } -} - -void CIEDemoView::OnGoForward() -{ -// GoForward(); - CIEDemoDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - CHistoryObj* pHistoryObj = pDoc->GoForward (); - if (pHistoryObj != NULL) - { - Navigate2 (pHistoryObj->GetURL (), 0, NULL); - } -} - -void CIEDemoView::OnGoSearchTheWeb() -{ - GoSearch(); -} - -void CIEDemoView::OnGoStartPage() -{ - GoHome(); -} - -void CIEDemoView::OnViewStop() -{ - Stop(); -} - -void CIEDemoView::OnViewRefresh() -{ - Refresh(); -} - -// these functions control the font size. There is no explicit command in the -// CHtmlView class to do this, but we can do it by using the ExecWB() function. -void CIEDemoView::OnViewFontsLargest() -{ - COleVariant vaZoomFactor(4l); - - ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, - &vaZoomFactor, NULL); -} - -void CIEDemoView::OnViewFontsLarge() -{ - COleVariant vaZoomFactor(3l); - - ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, - &vaZoomFactor, NULL); -} - -void CIEDemoView::OnViewFontsMedium() -{ - COleVariant vaZoomFactor(2l); - - ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, - &vaZoomFactor, NULL); -} - -void CIEDemoView::OnViewFontsSmall() -{ - COleVariant vaZoomFactor(1l); - - ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, - &vaZoomFactor, NULL); -} - -void CIEDemoView::OnViewFontsSmallest() -{ - COleVariant vaZoomFactor(0l); - - ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, - &vaZoomFactor, NULL); -} - -// This demonstrates how we can use the Navigate2() function to load local files -// including local HTML pages, GIFs, AIFF files, etc. -void CIEDemoView::OnFileOpen() -{ - BOOL bValidString; - CString str; - bValidString = str.LoadString(IDS_FILETYPES); - - CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, str); - - if(fileDlg.DoModal() == IDOK) - Navigate2(fileDlg.GetPathName(), 0, NULL); -} - -void CIEDemoView::OnUpdateGoForward(CCmdUI* pCmdUI) -{ - CIEDemoDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - pCmdUI->Enable (pDoc->IsFrwdAvailable ()); -} - -void CIEDemoView::OnUpdateGoBack(CCmdUI* pCmdUI) -{ - CIEDemoDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - pCmdUI->Enable (pDoc->IsBackAvailable ()); -} - -void CIEDemoView::OnDocumentComplete(LPCTSTR lpszURL) -{ - // make sure the main frame has the new URL. This call also stops the animation - ((CMainFrame*)GetParentFrame())->SetAddress(lpszURL); - - CIEDemoDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - pDoc->AddURLToHistory (GetLocationName (), lpszURL); - ((CMainFrame*)GetParentFrame())->SetProgress (0, -1); - - CHtmlView::OnDocumentComplete(lpszURL); -} - -void CIEDemoView::OnTitleChange(LPCTSTR lpszText) -{ - // this will change the main frame's title bar - if (m_pDocument != NULL) - m_pDocument->SetTitle(lpszText); -} - -void CIEDemoView::OnBeforeNavigate2(LPCTSTR /*lpszURL*/, DWORD /*nFlags*/, LPCTSTR /*lpszTargetFrameName*/, CByteArray& /*baPostedData*/, LPCTSTR /*lpszHeaders*/, BOOL* /*pbCancel*/) -{ - // start the animation so that is plays while the new page is being loaded - ((CMainFrame*)GetParentFrame())->StartAnimation(); -} - -void CIEDemoView::OnInitialUpdate() -{ - GoHome(); -} - -void CIEDemoView::OnProgressChange(long nProgress, long nProgressMax) -{ - ((CMainFrame*)GetParentFrame())->SetProgress(nProgress, nProgressMax); - - CHtmlView::OnProgressChange(nProgress, nProgressMax); -} - -void CIEDemoView::OnDestroy() -{ - CHtmlView::OnDestroy(); - CView::OnDestroy(); // Fixes CHtmlView bug -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoView.h deleted file mode 100644 index d1172a5a541df..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/IEDemoView.h +++ /dev/null @@ -1,78 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CIEDemoView : public CHtmlView -{ -protected: // create from serialization only - CIEDemoView(); - DECLARE_DYNCREATE(CIEDemoView) - -// Attributes -public: - CIEDemoDoc* GetDocument(); - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CIEDemoView) - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual void OnDocumentComplete(LPCTSTR lpszURL); - virtual void OnTitleChange(LPCTSTR lpszText); - virtual void OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel); - virtual void OnInitialUpdate(); - virtual void OnProgressChange(long nProgress, long nProgressMax); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CIEDemoView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CIEDemoView) - afx_msg void OnGoBack(); - afx_msg void OnGoForward(); - afx_msg void OnGoSearchTheWeb(); - afx_msg void OnGoStartPage(); - afx_msg void OnViewStop(); - afx_msg void OnViewRefresh(); - afx_msg void OnViewFontsLargest(); - afx_msg void OnViewFontsLarge(); - afx_msg void OnViewFontsMedium(); - afx_msg void OnViewFontsSmall(); - afx_msg void OnViewFontsSmallest(); - afx_msg void OnFileOpen(); - afx_msg void OnUpdateGoForward(CCmdUI* pCmdUI); - afx_msg void OnUpdateGoBack(CCmdUI* pCmdUI); - afx_msg void OnDestroy(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in IEDemoView.cpp -inline CIEDemoDoc* CIEDemoView::GetDocument() - { return (CIEDemoDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinkButton.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinkButton.cpp deleted file mode 100644 index 3628cca2f16b8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinkButton.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" -#include "LinkButton.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -IMPLEMENT_SERIAL(CLinkButton, CMFCToolBarButton, 1) - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CLinkButton::CLinkButton() -{ - Initialize (); -} -//*************************************************************************************** -CLinkButton::CLinkButton(LPCTSTR lpszLabel, LPCTSTR lpszURL) -{ - m_strURL = lpszURL; - m_strText = lpszLabel; - - Initialize (); -} -//*************************************************************************************** -CLinkButton::~CLinkButton() -{ - -} -//*************************************************************************************** -void CLinkButton::Initialize () -{ - m_nID = ID_LINK_1; - SetImage (GetCmdMgr ()->GetCmdImage (ID_LINK_1)); - m_bImage = m_bText = TRUE; - - // - CMFCToolBarComboBoxButton* pButton = new CMFCToolBarComboBoxButton(); - CMFCToolBarComboBoxEdit* pWndEdit = new CMFCToolBarComboBoxEdit(*pButton); - // -} -//********************************************************************************* -void CLinkButton::CopyFrom (const CMFCToolBarButton& src) -{ - CMFCToolBarButton::CopyFrom (src); - - const CLinkButton& srcLinkButton = (const CLinkButton&) src; - m_strURL = srcLinkButton.m_strURL; -} -//*************************************************************************************** -void CLinkButton::Serialize (CArchive& ar) -{ - CMFCToolBarButton::Serialize (ar); - - if (ar.IsLoading ()) - { - ar >> m_strURL; - } - else - { - ar << m_strURL; - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinkButton.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinkButton.h deleted file mode 100644 index 8fc09477fe278..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinkButton.h +++ /dev/null @@ -1,39 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CLinkButton : public CMFCToolBarButton -{ - DECLARE_SERIAL(CLinkButton) - -public: - CLinkButton(); - CLinkButton(LPCTSTR lpszLabel, LPCTSTR lpszURL); - - virtual ~CLinkButton(); - - LPCTSTR GetURL () const - { - return m_strURL; - } - -protected: - void Initialize (); - virtual void CopyFrom (const CMFCToolBarButton& src); - virtual void Serialize (CArchive& ar); - - CString m_strURL; - - virtual BOOL IsEditable () const - { - return FALSE; - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinksBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinksBar.cpp deleted file mode 100644 index 2989e997a9f44..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinksBar.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" -#include "LinksBar.h" -#include "LinkButton.h" -#include "IEDemoDoc.h" -#include "IEDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -IMPLEMENT_SERIAL(CLinksBar, CMFCToolBar, 1) - -///////////////////////////////////////////////////////////////////////////// -// CLinksBar - -CLinksBar::CLinksBar() -{ -} - -CLinksBar::~CLinksBar() -{ -} - - -BEGIN_MESSAGE_MAP(CLinksBar, CMFCToolBar) - //{{AFX_MSG_MAP(CLinksBar) - ON_WM_CREATE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CLinksBar message handlers - -int CLinksBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMFCToolBar::OnCreate(lpCreateStruct) == -1) - return -1; - - RestoreOriginalstate (); - return 0; -} - -BOOL CLinksBar::OnSendCommand (const CMFCToolBarButton* pButton) -{ - CLinkButton* pLinkButton = DYNAMIC_DOWNCAST (CLinkButton, pButton); - if (pLinkButton == NULL) - { - // Defauult processing - return FALSE; - } - - CString strURL = pLinkButton->GetURL (); - - ((CIEDemoView*)GetParentFrame ()->GetActiveView())->Navigate2 (strURL, 0, NULL); - return TRUE; -} - -BOOL CLinksBar::RestoreOriginalstate () -{ - RemoveAllButtons (); - - InsertButton (CLinkButton (_T("MSDN Home"), _T("http://www.msdn.com"))); - InsertButton (CLinkButton (_T("Microsoft Home"), _T("http://www.microsoft.com"))); - InsertButton (CLinkButton (_T("Visual C++ Developer Center"), _T("http://msdn2.microsoft.com/visualc/"))); - - EnableCustomizeButton (TRUE, -1, _T("")); - - AdjustLayout (); - Invalidate (); - - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinksBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinksBar.h deleted file mode 100644 index 8395425addf5c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/LinksBar.h +++ /dev/null @@ -1,57 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CLinksBar window - -class CLinksBar : public CMFCToolBar -{ - DECLARE_SERIAL(CLinksBar) - -// Construction -public: - CLinksBar(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CLinksBar) - //}}AFX_VIRTUAL - - virtual BOOL OnSendCommand (const CMFCToolBarButton* pButton); - virtual BOOL CanBeRestored () const - { - return TRUE; - } - virtual BOOL RestoreOriginalstate (); - - virtual BOOL AllowChangeTextLabels () const - { - return FALSE; - } - -// Implementation -public: - virtual ~CLinksBar(); - - // Generated message map functions -protected: - //{{AFX_MSG(CLinksBar) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/MainFrm.cpp deleted file mode 100644 index 603eea6bb9ba8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/MainFrm.cpp +++ /dev/null @@ -1,799 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "IEDemo.h" -#include "IEDemoDoc.h" -#include "IEDemoView.h" -#include "MainFrm.h" -#include "LinkButton.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - //{{AFX_MSG_MAP(CMainFrame) - ON_WM_CREATE() - ON_COMMAND(ID_LINK_1, OnLink1) - ON_COMMAND(ID_VIEW_ADDRESS_BAR, OnViewAddressBar) - ON_UPDATE_COMMAND_UI(ID_VIEW_ADDRESS_BAR, OnUpdateViewAddressBar) - ON_COMMAND(ID_VIEW_LINKS_BAR, OnViewLinksBar) - ON_UPDATE_COMMAND_UI(ID_VIEW_LINKS_BAR, OnUpdateViewLinksBar) - ON_COMMAND(ID_VIEW_TEXTLABELS, OnViewTextlabels) - ON_UPDATE_COMMAND_UI(ID_VIEW_TEXTLABELS, OnUpdateViewTextlabels) - ON_COMMAND(ID_VIEW_EXPLORERBAR, OnViewExplorerbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_EXPLORERBAR, OnUpdateViewExplorerbar) - //}}AFX_MSG_MAP - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_REGISTERED_MESSAGE(AFX_WM_CUSTOMIZEHELP, OnHelpCustomizeToolbars) - ON_CBN_SELENDOK(AFX_IDW_TOOLBAR + 1,OnNewAddress) - ON_COMMAND_RANGE(FIRST_FAVORITE_COMMAND, LAST_FAVORITE_COMMAND, OnFavorite) - ON_COMMAND_RANGE(FIRST_HISTORY_COMMAND, FIRST_HISTORY_COMMAND + HISTORY_LEN - 1, OnHistory) - ON_COMMAND(IDOK, OnNewAddressEnter) - ON_COMMAND(ID_LINK_MSDN, OnLinkMSDN) - ON_COMMAND(ID_LINK_MICROSOFT, OnLinkMicrosoft) - ON_COMMAND(ID_LINK_VISUALCPP, OnLinkVisualCPP) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_INDICATOR_ICON, // status icon - ID_SEPARATOR, // status line indicator - ID_INDICATOR_PROGRESS, // progress bar - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -const int nStatusIcon = 0; -const int nStatusInfo = 1; -const int nStatusProgress = 2; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_bMainToolbarMenu = FALSE; -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - CMFCToolBar::EnableQuickCustomization (); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - - ((CMFCVisualManagerWindows*)CMFCVisualManager::GetInstance ())->SetOfficeStyleMenus (); - - //--------------------------------- - // Set toolbar and menu image size: - //--------------------------------- - CMFCToolBar::SetSizes (CSize (36, 30), CSize (23, 23)); - CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16)); - - //-------------------- - // Create the menubar: - //-------------------- - // - // The this pointer points to CMainFrame class which extends the CFrameWnd class. - if (!m_wndMenuBar.CreateEx (this, TBSTYLE_TRANSPARENT)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - // - - // - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - m_wndMenuBar.EnableCustomizeButton (TRUE, -1, _T("")); - // first parameter is the command ID for the button of the Help combo box - // third parameter is the width of the button for the combo box in pixels. - m_wndMenuBar.EnableHelpCombobox(1,_T("enter text here"),30); - m_wndMenuBar.EnableMenuShadows(); - m_wndMenuBar.SetMaximizeMode(true); - // - - //------------------------------------ - // Remove menubar gripper and borders: - //------------------------------------ - m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() & - ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - m_bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 16; - - UINT uiToolbarHotID = m_bIsHighColor ? IDB_HOTTOOLBAR : 0; - UINT uiToolbarColdID = m_bIsHighColor ? IDB_COLDTOOLBAR : 0; - UINT uiMenuID = m_bIsHighColor ? IDB_MENU_IMAGES : IDB_MENU_IMAGES_16; - - // - // The this pointer points to CMainFrame class which extends the CFrameWnd class. - if (!m_wndToolBar.CreateEx (this, TBSTYLE_TRANSPARENT) || - !m_wndToolBar.LoadToolBar (IDR_MAINFRAME, uiToolbarColdID, uiMenuID, - FALSE /* Not locked */, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - // - - // - m_wndToolBar.SetWindowText (_T("Standard")); - m_wndToolBar.SetBorders (); - - //------------------------------------ - // Remove toolbar gripper and borders: - //------------------------------------ - m_wndToolBar.SetPaneStyle (m_wndToolBar.GetPaneStyle() & - ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - // - - BOOL bValidString; - - //---------------------------------------- - // Create a combo box for the address bar: - //---------------------------------------- - CString strAddressLabel; - bValidString = strAddressLabel.LoadString(IDS_ADDRESS); - - if (!m_wndAddress.Create (CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 1)) - { - TRACE0("Failed to create combobox\n"); - return -1; // fail to create - } - - //------------------ - // Create links bar: - //------------------ - CString strLinksLabel; - bValidString = strLinksLabel.LoadString (IDS_LINKS); - - if (!m_wndLinksBar.CreateEx (this, TBSTYLE_TRANSPARENT, - AFX_DEFAULT_TOOLBAR_STYLE, CRect(0, 0, 0, 0), AFX_IDW_TOOLBAR + 3)) - { - TRACE0("Failed to create links bar\n"); - } - - m_wndLinksBar.EnableCustomizeButton (TRUE, -1, _T("")); - - m_wndLinksBar.SetWindowText (strLinksLabel); - m_wndLinksBar.SetPaneStyle (m_wndLinksBar.GetPaneStyle() & - ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - //-------------- - // Create rebar: - //-------------- - if (!m_wndReBar.Create(this) || - !m_wndReBar.AddBar(&m_wndMenuBar) || - !m_wndReBar.AddBar(&m_wndToolBar, NULL, NULL, - RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK) || - !m_wndReBar.AddBar(&m_wndAddress, strAddressLabel, NULL, - RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK) || - !m_wndReBar.AddBar(&m_wndLinksBar, strLinksLabel, NULL, - RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK)) - { - TRACE0("Failed to create rebar\n"); - return -1; // fail to create - } - - m_wndMenuBar.AdjustLayout (); - m_wndToolBar.AdjustLayout (); - m_wndLinksBar.AdjustLayout (); - - //-------------------------------------------------------------- - // Set up min/max sizes and ideal sizes for pieces of the rebar: - //-------------------------------------------------------------- - REBARBANDINFO rbbi; - - // - CRect rectToolBar; - m_wndToolBar.GetItemRect(0, &rectToolBar); - // - - rbbi.cbSize = sizeof(rbbi); - rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE; - rbbi.cxMinChild = rectToolBar.Width(); - rbbi.cyMinChild = rectToolBar.Height(); - rbbi.cx = rbbi.cxIdeal = rectToolBar.Width() * m_wndToolBar.GetCount (); - m_wndReBar.GetReBarCtrl().SetBandInfo (1, &rbbi); - rbbi.cxMinChild = 0; - - CRect rectAddress; - m_wndAddress.GetEditCtrl()->GetWindowRect(&rectAddress); - - rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; - rbbi.cyMinChild = rectAddress.Height() + 10; - rbbi.cxIdeal = 200; - m_wndReBar.GetReBarCtrl().SetBandInfo (3, &rbbi); - - EnableDocking(CBRS_ALIGN_ANY); - m_wndReBar.EnableDocking (CBRS_TOP); - DockPane (&m_wndReBar); - - //------------------- - // Create status bar: - //------------------- - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - //------------------------------ - // First pane - image/animation: - //------------------------------ - m_wndStatusBar.SetPaneStyle (nStatusIcon, SBPS_NOBORDERS); - - m_bmpStatus.LoadBitmap (IDB_STATUS_READY); - m_imlStatusAnimation.Create (IDB_STATUS_ANIMATION, 11, 0, RGB (255, 0, 255)); - - m_wndStatusBar.SetPaneIcon (nStatusIcon, m_bmpStatus); - m_wndStatusBar.SetPaneText (nStatusIcon, NULL); - m_wndStatusBar.SetPaneWidth (nStatusIcon, 0); - - m_wndStatusBar.SetPaneStyle (nStatusInfo, SBPS_STRETCH | SBPS_NOBORDERS); - m_wndStatusBar.SetPaneWidth (nStatusProgress, 80); - - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndLinksBar.SetPaneStyle(m_wndLinksBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - - //----------------------- - // Set up Favorites menu: - //----------------------- - VERIFY (theApp.m_Favorites.CreateMenu (m_menuFavorites)); - - //--------------------- - // Create explorer bar: - //--------------------- - if (!m_wndExplorerBar.Create (_T("Favorites"),this, CRect (0, 0, 200, 200), - TRUE, - ID_VIEW_EXPLORERBAR, - WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_HIDE_INPLACE | WS_CAPTION, - AFX_CBRS_OUTLOOK_TABS, - AFX_CBRS_CLOSE | AFX_CBRS_RESIZE)) - { - TRACE0("Failed to create explorerbar\n"); - return FALSE; // fail to create - } - - m_wndExplorerBar.EnableDocking (CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT); - DockPane(&m_wndExplorerBar); - - //------------------------------------------------------ - // Add additional images to the global image collection: - //------------------------------------------------------ - CMFCToolBar::AddToolBarForImageCollection ( - IDR_TOOLBAR_IMAGE_COLLECTION, // Toolbar (need for map "Command - Image") - m_bIsHighColor ? IDB_IMAGE_COLLECTION : 0, // "Hot" images - m_bIsHighColor ? IDB_IMAGE_COLLECTION : 0, // "Cold" images - m_bIsHighColor ? IDB_IMAGE_COLLECTION_SMALL : 0); // Menu images - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */, - AFX_CUSTOMIZE_TEXT_LABELS | AFX_CUSTOMIZE_NOTOOLS | AFX_CUSTOMIZE_NO_LARGE_ICONS); - - CMenu menuFavorites; - menuFavorites.LoadMenu (IDR_FAVORITES_POPUP); - - BOOL bValidString; - CString strFavorites; - bValidString = strFavorites.LoadString (IDS_FAVORITES); - - // CMFCToolBarsCustomizeDialog* pDlgCust - // - pDlgCust->ReplaceButton (ID_FAVORITES_DUMMY, - CMFCToolBarMenuButton ((UINT)-1, menuFavorites, -1, strFavorites)); - pDlgCust->EnableUserDefinedToolbars(); - pDlgCust->Create (); - // -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM wp,LPARAM lp) -{ - CMFCToolBar* pToolBar = DYNAMIC_DOWNCAST (CMFCToolBar, - CWnd::FromHandlePermanent ((HWND) wp)); - m_bMainToolbarMenu = ( - pToolBar != NULL && pToolBar->GetDlgCtrlID () == AFX_IDW_TOOLBAR); - - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - if (pPopupMenu) - { - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - if (uiToolBarId == IDR_MAINFRAME) - { - CString str; - - // Replace "Back" and "Forward" buttons by the menu buttons - // with the history lists: - - CMenu menuHistory; - menuHistory.LoadMenu (IDR_HISTORY_POPUP); - - BOOL bValidString; - bValidString = str.LoadString (IDS_BACK); - - // - // CMenu menuHistory - // CString str - m_wndToolBar.ReplaceButton (ID_GO_BACK, - CMFCToolBarMenuButton (ID_GO_BACK, menuHistory, - GetCmdMgr ()->GetCmdImage (ID_GO_BACK), str)); - // - - bValidString = str.LoadString (IDS_FORWARD); - m_wndToolBar.ReplaceButton (ID_GO_FORWARD, - CMFCToolBarMenuButton (ID_GO_FORWARD, menuHistory, - GetCmdMgr ()->GetCmdImage (ID_GO_FORWARD), str)); - - // Setup "Favorites" menu button: - CMenu menuFavorites; - menuFavorites.LoadMenu (IDR_FAVORITES_POPUP); - - bValidString = str.LoadString (IDS_FAVORITES); - m_wndToolBar.ReplaceButton (ID_FAVORITES_DUMMY, - CMFCToolBarMenuButton ((UINT)-1, menuFavorites, - GetCmdMgr ()->GetCmdImage (ID_FAVORITES_DUMMY), str)); - - // Setup "Fonts" menu button: - CMenu menuFonts; - menuFonts.LoadMenu (IDR_FONT_POPUP); - - bValidString = str.LoadString(IDS_FONT); - m_wndToolBar.ReplaceButton (ID_FONT_DROPDOWN, - CMFCToolBarMenuButton ((UINT)-1, *menuFonts.GetSubMenu (0), - GetCmdMgr ()->GetCmdImage (ID_FONT_DROPDOWN), str)); - // Some buttons will appear with text by default: - - m_wndToolBar.SetToolBarBtnText (m_wndToolBar.CommandToIndex (ID_GO_BACK)); - m_wndToolBar.SetToolBarBtnText (m_wndToolBar.CommandToIndex (ID_GO_SEARCH_THE_WEB)); - } - - return 0; -} - -LRESULT CMainFrame::OnHelpCustomizeToolbars(WPARAM /*wp*/, LPARAM /*lp*/) -{ -// int iPageNum = (int) wp; - -// CToolbarCustomize* pDlg = (CToolbarCustomize*) lp; -// ASSERT_VALID (pDlg); - - // TODO: show help about page number iPageNum - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup == NULL) - { - return TRUE; - } - - CMFCPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar (); - ASSERT_VALID (pMenuBar); - - for (int i = 0; i < pMenuBar->GetCount (); i ++) - { - CMFCToolBarButton* pButton = pMenuBar->GetButton (i); - ASSERT_VALID (pButton); - - if (pButton->m_nID == ID_FAVORITES_DUMMY) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - return FALSE; - } - - pMenuBar->ImportFromMenu (m_menuFavorites); - pMenuPopup->SetMaxWidth (300); - - return TRUE; - } - } - - CMFCToolBarMenuButton* pParentButton = pMenuPopup->GetParentButton (); - if (pParentButton == NULL) - { - return TRUE; - } - - switch (pParentButton->m_nID) - { - case ID_GO_BACK: - case ID_GO_FORWARD: - { - if (CMFCToolBar::IsCustomizeMode ()) - { - return FALSE; - } - - CIEDemoView* pView = ((CIEDemoView*)GetActiveView()); - ASSERT_VALID (pView); - - CIEDemoDoc* pDoc = pView->GetDocument(); - ASSERT_VALID(pDoc); - - _T_HistotyList lst; - - if (pParentButton->m_nID == ID_GO_BACK) - { - pDoc->GetBackList (lst); - } - else - { - pDoc->GetFrwdList (lst); - } - - if (!lst.IsEmpty ()) - { - pMenuPopup->RemoveAllItems (); - - for (POSITION pos = lst.GetHeadPosition (); pos != NULL;) - { - CHistoryObj* pObj = lst.GetNext (pos); - ASSERT (pObj != NULL); - - if (pObj) - { - pMenuPopup->InsertItem (CMFCToolBarMenuButton (pObj->GetCommand (), NULL, -1, pObj->GetTitle ())); - } - } - } - } - } - - return TRUE; -} - -BOOL CMainFrame::OnDrawMenuImage (CDC* pDC, - const CMFCToolBarMenuButton* pMenuButton, - const CRect& rectImage) -{ - if (theApp.m_Favorites.GetSysImages () == NULL) - { - return FALSE; - } - - ASSERT_VALID (pDC); - ASSERT_VALID (pMenuButton); - - int iIcon = -1; - - if (pMenuButton->m_nID >= FIRST_FAVORITE_COMMAND && - pMenuButton->m_nID <= LAST_FAVORITE_COMMAND) - { - iIcon = theApp.m_Favorites.GetIDIcon (pMenuButton->m_nID); - } - else if (IsFavoritesMenu (pMenuButton)) // Maybe, favorits folder? - { - iIcon = theApp.m_Favorites.GetFolderIcon (); - } - - if (iIcon == -1) - { - return FALSE; // Don't draw it! - } - - ::ImageList_Draw (theApp.m_Favorites.GetSysImages (), iIcon, - pDC->GetSafeHdc (), - rectImage.left + (rectImage.Width () - theApp.m_Favorites.GetSysImageSize ().cx) / 2, - rectImage.top + (rectImage.Height () - theApp.m_Favorites.GetSysImageSize ().cy) / 2, ILD_TRANSPARENT); - - return TRUE; -} - -BOOL CMainFrame::IsFavoritesMenu (const CMFCToolBarMenuButton* pMenuButton) -{ - if (pMenuButton == NULL || pMenuButton->m_nID != (UINT) -1) - { - return FALSE; - } - - ASSERT_VALID (pMenuButton); - const CObList& lstCommands = pMenuButton->GetCommands (); - - for (POSITION pos = lstCommands.GetHeadPosition (); pos != NULL;) - { - CMFCToolBarButton* pCmd = (CMFCToolBarButton*) lstCommands.GetNext (pos); - ASSERT_VALID (pCmd); - - if ((pCmd->m_nID >= FIRST_FAVORITE_COMMAND && - pCmd->m_nID <= LAST_FAVORITE_COMMAND) || - IsFavoritesMenu (DYNAMIC_DOWNCAST (CMFCToolBarMenuButton, pCmd))) - { - return TRUE; - } - } - - return FALSE; -} - -void CMainFrame::OnFavorite(UINT nID) -{ - SetFocus (); - ((CIEDemoView*)GetActiveView())->Navigate2(theApp.m_Favorites.GetURLofID (nID), 0, NULL); -} - -void CMainFrame::OnHistory(UINT nID) -{ - CIEDemoView* pView = ((CIEDemoView*)GetActiveView()); - ASSERT_VALID (pView); - - CIEDemoDoc* pDoc = pView->GetDocument(); - ASSERT_VALID(pDoc); - - CHistoryObj* pObj = pDoc->Go (nID); - ASSERT (pObj != NULL); - - if (pObj) - { - pView->Navigate2 (pObj->GetURL (), 0, NULL); - } -} - -void CMainFrame::SetAddress(LPCTSTR lpszUrl) -{ - // This is called when the browser has completely loaded the new location, - // so make sure the text in the address bar is up to date and stop the - // animation. - m_wndAddress.SetWindowText(lpszUrl); - m_wndStatusBar.SetPaneIcon (nStatusIcon, m_bmpStatus); -} - -void CMainFrame::StartAnimation() -{ - // Start the animation. This is called when the browser begins to - // navigate to a new location - m_wndStatusBar.SetPaneAnimation (nStatusIcon, m_imlStatusAnimation); -} - -void CMainFrame::OnNewAddress() -{ - // gets called when an item in the Address combo box is selected - // just navigate to the newly selected location. - CString str; - - m_wndAddress.GetLBText(m_wndAddress.GetCurSel(), str); - ((CIEDemoView*)GetActiveView())->Navigate2(str, 0, NULL); -} - -void CMainFrame::OnNewAddressEnter() -{ - // gets called when an item is entered manually into the edit box portion - // of the Address combo box. - // navigate to the newly selected location and also add this address to the - // list of addresses in the combo box. - CString str; - - m_wndAddress.GetEditCtrl()->GetWindowText(str); - ((CIEDemoView*)GetActiveView())->Navigate2(str, 0, NULL); - - COMBOBOXEXITEM item; - - item.mask = CBEIF_TEXT; - item.iItem = -1; - item.pszText = (LPTSTR)(LPCTSTR)str; - m_wndAddress.InsertItem(&item); -} - -void CMainFrame::OnLink1() -{ - // TODO: Add your command handler code here - -} - -void CMainFrame::OnViewAddressBar() -{ - m_wndReBar.GetReBarCtrl().ShowBand (3, !m_wndAddress.IsWindowVisible ()); -} - -void CMainFrame::OnUpdateViewAddressBar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndAddress.IsWindowVisible ()); -} - -void CMainFrame::OnViewLinksBar() -{ - ShowPane (&m_wndLinksBar, (m_wndLinksBar.GetStyle () & WS_VISIBLE) == 0, FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewLinksBar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndLinksBar.IsWindowVisible ()); -} - -BOOL CMainFrame::OnMenuButtonToolHitTest (CMFCToolBarButton* pButton, TOOLINFO* pTI) -{ - ASSERT_VALID (pButton); - - if (pButton->m_nID < FIRST_FAVORITE_COMMAND || - pButton->m_nID > LAST_FAVORITE_COMMAND) - { - return FALSE; - } - - ASSERT (pTI != NULL); - - if (pTI) - { - CString strText = theApp.m_Favorites.GetURLofID (pButton->m_nID); - pTI->lpszText = (LPTSTR) ::calloc ((strText.GetLength () + 1), sizeof (TCHAR)); - if (pTI->lpszText) - { - lstrcpy (pTI->lpszText, strText); - } - } - - return TRUE; -} -//*************************************************************************************** -void CMainFrame::OnViewTextlabels() -{ - m_wndToolBar.EnableTextLabels (!m_wndToolBar.AreTextLabels ()); -} -//*************************************************************************************** -void CMainFrame::OnUpdateViewTextlabels(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_bMainToolbarMenu && m_wndToolBar.AreTextLabels ()); - pCmdUI->Enable (m_bMainToolbarMenu); -} -//*************************************************************************************** -BOOL CMainFrame::GetToolbarButtonToolTipText (CMFCToolBarButton* pButton, CString& strTTText) -{ - CLinkButton* pLinkBtn = NULL; - - ASSERT_VALID (pButton); - - if (pButton->m_nID == ID_LINK_1 && - (pLinkBtn = DYNAMIC_DOWNCAST (CLinkButton, pButton)) != NULL) - { - strTTText = pLinkBtn->GetURL (); - return TRUE; - } - - return FALSE; // Default tooltip text -} -//******************************************************************************************** -BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) -{ - if (!CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) - { - return FALSE; - } - - return TRUE; -} -//******************************************************************************************** -void CMainFrame::OnViewExplorerbar() -{ - ShowPane (&m_wndExplorerBar, (m_wndExplorerBar.GetStyle () & WS_VISIBLE) == 0, FALSE, TRUE); -} -//******************************************************************************************** -void CMainFrame::OnUpdateViewExplorerbar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndExplorerBar.IsWindowVisible ()); -} -//******************************************************************************************** -void CMainFrame::SetProgress (long nCurr, long nTotal) -{ - m_wndStatusBar.EnablePaneProgressBar (nStatusProgress, nTotal); - - if (nTotal >= 0) - { - m_wndStatusBar.SetPaneProgress (nStatusProgress, min (nTotal, max (0, nCurr))); - } - else - { - m_wndStatusBar.RedrawWindow (); - } -} -//******************************************************************************************** -void CMainFrame::OnLinkMSDN() -{ - ((CIEDemoView*)GetActiveView())->Navigate2 (_T("http://www.msdn.com"), 0, NULL); -} -//******************************************************************************************** -void CMainFrame::OnLinkMicrosoft() -{ - ((CIEDemoView*)GetActiveView())->Navigate2 (_T("http://www.microsoft.com"), 0, NULL); -} -//******************************************************************************************** -void CMainFrame::OnLinkVisualCPP() -{ - ((CIEDemoView*)GetActiveView())->Navigate2 (_T("http://msdn2.microsoft.com/visualc/"), 0, NULL); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/MainFrm.h deleted file mode 100644 index 93b22c7449388..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/MainFrm.h +++ /dev/null @@ -1,109 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define CFrameWnd CFrameWndEx - -#include "LinksBar.h" -#include "ExplorerBar.h" - -class CMainFrame : public CFrameWnd -{ -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - CMenu m_menuFavorites; - -protected: - CBitmap m_bmpStatus; - CImageList m_imlStatusAnimation; - -// Operations -public: - void SetAddress(LPCTSTR lpszUrl); - void StartAnimation(); - BOOL IsFavoritesMenu (const CMFCToolBarMenuButton* pMenuButton); - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); - virtual BOOL OnDrawMenuImage (CDC* pDC, - const CMFCToolBarMenuButton* pMenuButton, - const CRect& rectImage); - - virtual BOOL OnMenuButtonToolHitTest (CMFCToolBarButton* pButton, TOOLINFO* pTI); - virtual BOOL GetToolbarButtonToolTipText (CMFCToolBarButton* pButton, CString& strTTText); - - void SetProgress (long nCurr, long nTotal); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMainFrame) - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - // - CMFCMenuBar m_wndMenuBar; - // - CMFCStatusBar m_wndStatusBar; - - // - CMFCToolBar m_wndToolBar; - // - - CLinksBar m_wndLinksBar; - CMFCReBar m_wndReBar; - - CComboBoxEx m_wndAddress; - CExplorerBar m_wndExplorerBar; - - BOOL m_bMainToolbarMenu; - BOOL m_bIsHighColor; - -// Generated message map functions -protected: - //{{AFX_MSG(CMainFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnLink1(); - afx_msg void OnViewAddressBar(); - afx_msg void OnUpdateViewAddressBar(CCmdUI* pCmdUI); - afx_msg void OnViewLinksBar(); - afx_msg void OnUpdateViewLinksBar(CCmdUI* pCmdUI); - afx_msg void OnViewTextlabels(); - afx_msg void OnUpdateViewTextlabels(CCmdUI* pCmdUI); - afx_msg void OnViewExplorerbar(); - afx_msg void OnUpdateViewExplorerbar(CCmdUI* pCmdUI); - //}}AFX_MSG - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg LRESULT OnHelpCustomizeToolbars(WPARAM wp, LPARAM lp); - afx_msg void OnNewAddress(); - afx_msg void OnNewAddressEnter(); - afx_msg void OnFavorite(UINT nID); - afx_msg void OnHistory(UINT nID); - afx_msg void OnLinkMSDN(); - afx_msg void OnLinkMicrosoft(); - afx_msg void OnLinkVisualCPP(); - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ReadMe.htm deleted file mode 100644 index e032452c67bcd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,124 +0,0 @@ - - - - IEDemo Sample: MFC Internet Explorer Application - - -

- IEDemo Sample: MFC Internet Explorer Application

-
-
-
- -

-

-
-

- The IEDemo sample demonstrates how to implement an application similar to Internet - Explorer, with similar user interface elements and capabilities.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the IEDemo sample

-
-
    -
  1. -

    - Open the solution file IEDemo.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The IEDemo sample demonstrates the following keywords:

-

- CFrameWndEx; CMDID; CMFCMenuBar; CMFCPopupMenu; CMFCPopupMenuBar; CMFCReBar; CMFCStatusBar; - CMFCTasksPane; CMFCToolBar; CMFCToolBarButton; CMFCToolBarMenuButton; CMFCToolBarsCustomizeDialog; - CMFCVisualManager; CMFCVisualManagerWindows; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/Resource.h deleted file mode 100644 index 352a5a8e3a752..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/Resource.h +++ /dev/null @@ -1,88 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by IEDemo.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define ID_INDICATOR_ICON 102 -#define ID_INDICATOR_PROGRESS 103 -#define IDP_SOCKETS_INIT_FAILED 104 -#define IDR_MAINFRAME 128 -#define IDR_IEDTYPE 129 -#define IDR_MAINFRAME2 129 -#define IDR_POPUP_TOOLBAR 131 -#define IDR_FONT_POPUP 132 -#define IDR_MFCAVI 132 -#define IDR_FAVORITES_POPUP 133 -#define IDR_HISTORY_POPUP 134 -#define IDB_MENU_IMAGES 134 -#define IDR_TOOLBAR_IMAGE_COLLECTION 138 -#define IDB_IMAGE_COLLECTION 140 -#define IDB_STATUS_READY 141 -#define IDB_STATUS_ANIMATION 142 -#define IDB_COLDTOOLBAR 261 -#define IDB_HOTTOOLBAR 262 -#define IDB_IMAGE_COLLECTION_SMALL 263 -#define IDB_MENU_IMAGES_16 264 -#define IDS_WEB_TUTORIAL 736 -#define IDS_ONLINE_SUPPORT 737 -#define IDS_FREE_STUFF 738 -#define IDS_INTERNET_START_PAGE 743 -#define IDS_BEST_OF_THE_WEB 745 -#define IDS_MICROSOFT_HOME_PAGE 747 -#define IDS_BACK 748 -#define IDS_FORWARD 749 -#define IDS_STOP 750 -#define IDS_REFRESH 751 -#define IDS_HOME 752 -#define IDS_SEARCH 753 -#define IDS_FAVORITES 754 -#define IDS_PRINT 755 -#define IDS_FONT 756 -#define IDS_ADDRESS 757 -#define IDS_LINKS 758 -#define IDD_ABOUTBOX 999 -#define IDC_MAIL 1000 -#define IDC_URL 1001 -#define IDC_VERSION 1002 -#define IDC_TREE1 1003 -#define IDS_FILETYPES 1201 -#define ID_VIEW_ADDRESS_BAR 32722 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_STOP 32778 -#define ID_VIEW_REFRESH 32779 -#define ID_LINK_1 32781 -#define ID_VIEW_FONTS_LARGEST 32782 -#define ID_VIEW_FONTS_LARGE 32783 -#define ID_VIEW_FONTS_MEDIUM 32784 -#define ID_VIEW_FONTS_SMALL 32785 -#define ID_VIEW_FONTS_SMALLEST 32786 -#define ID_GO_BACK 32787 -#define ID_GO_FORWARD 32788 -#define ID_GO_START_PAGE 32789 -#define ID_GO_SEARCH_THE_WEB 32790 -#define ID_GO_BEST_OF_THE_WEB 32791 -#define ID_FAVORITES_DROPDOWN 32792 -#define ID_FONT_DROPDOWN 32793 -#define ID_HELP_WEB_TUTORIAL 32798 -#define ID_HELP_ONLINE_SUPPORT 32800 -#define ID_FAVORITES_DUMMY 32819 -#define ID_HISTORY_DUMMY 32820 -#define ID_VIEW_LINKS_BAR 32821 -#define ID_VIEW_TEXTLABELS 32823 -#define ID_VIEW_EXPLORERBAR 32825 -#define ID_LINK_MSDN 32826 -#define ID_LINK_MICROSOFT 32827 -#define ID_LINK_VISUALCPP 32828 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 144 -#define _APS_NEXT_COMMAND_VALUE 32830 -#define _APS_NEXT_CONTROL_VALUE 1004 -#define _APS_NEXT_SYMED_VALUE 102 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/Snippets.txt deleted file mode 100644 index 9990d66e7a12d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/Snippets.txt +++ /dev/null @@ -1,12 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.h: CMFCMenuBar 1 -MainFrm.cpp: CMFCMenuBar::CreateEx 2 -MainFrm.cpp: CMFCMenuBar 3 -MainFrm.cpp: CMFCToolBarsCustomizeDialog 4 -LinkButton.cpp: CMFCToolBarComboBoxEdit 5 -MainFrm.h: CMFCToolBar 6 -MainFrm.cpp: CMFCToolBar 7 -MainFrm.cpp: CMFCToolBar 8 -MainFrm.cpp: CMFCToolBar 9 -MainFrm.cpp: CMFCToolBar 10 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/iedemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/iedemo.vcxproj deleted file mode 100644 index c34eda40b8686..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/iedemo.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {09AC8F6B-84CD-4145-BA28-BFAE195961D6} - IEDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - false - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - false - X64 - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - MachineX64 - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/iedemo.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/iedemo.vcxproj.filters deleted file mode 100644 index 5f427df8b15f3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/iedemo.vcxproj.filters +++ /dev/null @@ -1,134 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemo.rc2 deleted file mode 100644 index 0bf6820e538d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// BCGVIEDemo.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemoDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemoDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/IEDemoDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/coldtool.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/coldtool.bmp deleted file mode 100644 index 4ac9ed12809eb..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/coldtool.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/hottoolb.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/hottoolb.bmp deleted file mode 100644 index ba92eba13a02f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/hottoolb.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/image_col.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/image_col.bmp deleted file mode 100644 index ac6cccf210ee4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/image_col.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/image_small.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/image_small.bmp deleted file mode 100644 index f3e0f64ac1805..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/image_small.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/menu_images_16.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/menu_images_16.bmp deleted file mode 100644 index 056d53a3d2555..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/menu_images_16.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/menu_img.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/menu_img.bmp deleted file mode 100644 index 8a6e1f2bcf36c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/menu_img.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/status_a.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/status_a.bmp deleted file mode 100644 index f20b603d5194a..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/status_a.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/status_r.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/status_r.bmp deleted file mode 100644 index 68f953045dd12..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/status_r.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/toolbar.bmp deleted file mode 100644 index b2575b5c30e0f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/toolbar1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/toolbar1.bmp deleted file mode 100644 index a3b5714a17626..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/res/toolbar1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/stdafx.cpp deleted file mode 100644 index 6acf577411247..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/stdafx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// IEDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/stdafx.h deleted file mode 100644 index 1d1958fb1a1c8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/stdafx.h +++ /dev/null @@ -1,49 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - - -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - -#include // MFC HTML view support - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_IEDemo/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ChildFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ChildFrm.cpp deleted file mode 100644 index 33c12365fb705..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ChildFrm.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// ChildFrm.cpp : implementation of the CChildFrame class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "ChildFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CChildFrame - -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) -END_MESSAGE_MAP() - -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here -} - -CChildFrame::~CChildFrame() -{ -} - - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs - if( !CMDIChildWndEx::PreCreateWindow(cs) ) - return FALSE; - - return TRUE; -} - -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWndEx::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWndEx::Dump(dc); -} -#endif //_DEBUG - -// CChildFrame message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ChildFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ChildFrm.h deleted file mode 100644 index 00e42c9ed4f80..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ChildFrm.h +++ /dev/null @@ -1,32 +0,0 @@ -// ChildFrm.h : interface of the CChildFrame class -// - -#pragma once - -class CChildFrame : public CMDIChildWndEx -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.cpp deleted file mode 100644 index fdaee5b22f1c2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// MFCRibbonApp.cpp : Defines the class behaviors for the application. - - -#include "stdafx.h" -#include "afxwinappex.h" -#include "MFCRibbonApp.h" -#include "MainFrm.h" - -#include "ChildFrm.h" -#include "MFCRibbonAppDoc.h" -#include "MFCRibbonAppView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMFCRibbonAppApp - -BEGIN_MESSAGE_MAP(CMFCRibbonAppApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, &CMFCRibbonAppApp::OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) -END_MESSAGE_MAP() - - -// CMFCRibbonAppApp construction - -CMFCRibbonAppApp::CMFCRibbonAppApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -// The one and only CMFCRibbonAppApp object - -CMFCRibbonAppApp theApp; - - -// CMFCRibbonAppApp initialization - -BOOL CMFCRibbonAppApp::InitInstance() -{ - CWinAppEx::InitInstance(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Local AppWizard-Generated Applications")); - LoadStdProfileSettings(0); // Load standard INI file options - - InitContextMenuManager(); - - InitKeyboardManager(); - - InitTooltipManager(); - CMFCToolTipInfo ttParams; - ttParams.m_bVislManagerTheme = TRUE; - theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate(IDR_MFCRibbonAppTYPE, - RUNTIME_CLASS(CMFCRibbonAppDoc), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CMFCRibbonAppView)); - if (!pDocTemplate) - return FALSE; - AddDocTemplate(pDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) - { - delete pMainFrame; - return FALSE; - } - m_pMainWnd = pMainFrame; - // call DragAcceptFiles only if there's a suffix - // In an MDI app, this should occur immediately after setting m_pMainWnd - // Enable drag/drop open - m_pMainWnd->DragAcceptFiles(); - - // Enable DDE Execute open - EnableShellOpen(); - RegisterShellFileTypes(TRUE); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - - // Dispatch commands specified on the command line. Will return FALSE if - // app was launched with /RegServer, /Register, /Unregserver or /Unregister. - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - // The main window has been initialized, so show and update it - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - - return TRUE; -} - - - -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - enum { IDD = IDD_ABOUTBOX }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - -// App command to run the dialog -void CMFCRibbonAppApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -// CMFCRibbonAppApp customization load/save methods - -void CMFCRibbonAppApp::PreLoadState() -{ - CString strName; - strName.LoadString(IDS_EDIT_MENU); - GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); -} - -void CMFCRibbonAppApp::LoadCustomState() -{ -} - -void CMFCRibbonAppApp::SaveCustomState() -{ -} - -// CMFCRibbonAppApp message handlers - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.h deleted file mode 100644 index c98c8d0ae8b9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.h +++ /dev/null @@ -1,36 +0,0 @@ -// MFCRibbonApp.h : main header file for the MFCRibbonApp application -// -#pragma once - -#ifndef __AFXWIN_H__ - #error "include 'stdafx.h' before including this file for PCH" -#endif - -#include "resource.h" // main symbols - - -// CMFCRibbonAppApp: -// See MFCRibbonApp.cpp for the implementation of this class -// - -class CMFCRibbonAppApp : public CWinAppEx -{ -public: - CMFCRibbonAppApp(); - - -// Overrides -public: - virtual BOOL InitInstance(); - -// Implementation - UINT m_nAppLook; - virtual void PreLoadState(); - virtual void LoadCustomState(); - virtual void SaveCustomState(); - - afx_msg void OnAppAbout(); - DECLARE_MESSAGE_MAP() -}; - -extern CMFCRibbonAppApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.rc deleted file mode 100644 index 19f7cbf78ccf5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.rc +++ /dev/null @@ -1,541 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#ifndef APSTUDIO_INVOKED -#include "targetver.h" -#endif -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#ifndef APSTUDIO_INVOKED\r\n" - "#include ""targetver.h""\r\n" - "#endif\r\n" - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#include ""res\\MFCRibbonApp.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // MFC ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\MFCRibbonApp.ico" -IDR_MFCRibbonAppTYPE ICON "res\\MFCRibbonAppDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDR_MAINFRAME_256 BITMAP "res\\Toolbar256.bmp" -IDB_MAIN BITMAP "res\\main.bmp" -IDB_FILELARGE BITMAP "res\\filelarge.bmp" -IDB_FILESMALL BITMAP "res\\filesmall.bmp" -IDB_WRITELARGE BITMAP "res\\writelarge.bmp" -IDB_WRITESMALL BITMAP "res\\writesmall.bmp" -IDB_BUTTONS BITMAP "res\\buttons.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_APP_ABOUT -END - -IDR_MAINFRAME_256 TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Windows &2000", ID_VIEW_APPLOOK_WIN_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_OFF_XP - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_OFF_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS_2005 - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_OFF_2007_AQUA - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About MFCRibbonApp...", ID_APP_ABOUT - END -END - -IDR_MFCRibbonAppTYPE MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Windows &2000", ID_VIEW_APPLOOK_WIN_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_OFF_XP - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_OFF_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS_2005 - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_OFF_2007_AQUA - END - END - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - END - POPUP "&Help" - BEGIN - MENUITEM "&About MFCRibbonApp...", ID_APP_ABOUT - END -END - -IDR_POPUP_EDIT MENU -BEGIN - POPUP "Edit" - BEGIN - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END -END - -IDR_WINDOWS_MENU MENU -BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW -END - -IDR_THEME_MENU MENU -BEGIN - MENUITEM "Office 2007 (&Blue Style)", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "Office 2007 (B&lack Style)", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "Office 2007 (&Silver Style)", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "Office 2007 (&Aqua Style)", ID_VIEW_APPLOOK_OFF_2007_AQUA -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About MFCRibbonApp" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20 - LTEXT "MFCRibbonApp, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX - LTEXT "Copyright (C) 2008",IDC_STATIC,42,26,114,8 - DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "TODO: " - VALUE "FileDescription", "TODO: " - VALUE "FileVersion", "1.0.0.1" - VALUE "InternalName", "MFCRibbonApp.exe" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved." - VALUE "OriginalFilename", "MFCRibbonApp.exe" - VALUE "ProductName", "TODO: " - VALUE "ProductVersion", "1.0.0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 163 - TOPMARGIN, 7 - BOTTOMMARGIN, 55 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "MFCRibbonApp" - IDR_MFCRibbonAppTYPE "\nMFCRibbonApp\nMFCRibbonApp\nMFCRibbonApp Files (*.mfcrbnapp)\n.mfcrbnapp\nMFCRibbonApp.Document\nMFCRibbonApp.Document" - IDS_WINDOWS_MANAGER "Windows..." -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "MFCRibbonApp" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle Status Bar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" -END - -STRINGTABLE -BEGIN - IDS_STATUS_PANE1 "Pane 1" - IDS_STATUS_PANE2 "Pane 2" - ID_SLIDER_CONTROL "Slider control" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_FILE "File" - IDS_RIBBON_NEW "&New" - IDS_RIBBON_OPEN "&Open..." - IDS_RIBBON_SAVE "&Save" - IDS_RIBBON_SAVEAS "Save &As..." - IDS_RIBBON_PRINT "Print" - IDS_RIBBON_PRINT_LABEL "Preview and print the document" - IDS_RIBBON_PRINT_QUICK "&Quick Print" - IDS_RIBBON_PRINT_PREVIEW "Print Pre&view" - IDS_RIBBON_PRINT_SETUP "Print Set&up" - IDS_RIBBON_CLOSE "&Close" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_RECENT_DOCS "Recent Documents" - IDS_RIBBON_EXIT "E&xit" - IDS_RIBBON_HOME "&Home" - IDS_RIBBON_CLIPBOARD "Clipboard\nd" - IDS_RIBBON_PASTE "Paste\nv" - IDS_RIBBON_CUT "Cut\nx" - IDS_RIBBON_COPY "Copy\nc" - IDS_RIBBON_SELECTALL "Select All\na" - IDS_RIBBON_WINDOW "Window\nw" - IDS_RIBBON_WINDOWS "Windows\ni" - IDS_RIBBON_STYLE "Style" - IDS_RIBBON_STYLE_TIP "Modify Visual Style" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_STYLE_DESC "Choose one of the Office 2007 themes" - IDS_RIBBON_STATUSBAR "Status Bar" - IDS_RIBBON_VIEW "View" -END - -STRINGTABLE -BEGIN - IDS_EDIT_MENU "Edit" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_CUSTOM "Custom" - IDS_RIBBON_FAVORITES "FAVORITES" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) -#include "res\MFCRibbonApp.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#if !defined(_AFXDLL) -#include "afxribbon.rc" // MFC ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.reg b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.reg deleted file mode 100644 index 44314b013f25b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonApp.reg +++ /dev/null @@ -1,15 +0,0 @@ -REGEDIT -; This .REG file may be used by your SETUP program. -; If a SETUP program is not available, the entries below will be -; registered in your InitInstance automatically with a call to -; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll. - -HKEY_CLASSES_ROOT\.mfcrbnapp = MFCRibbonApp.Document -HKEY_CLASSES_ROOT\MFCRibbonApp.Document\shell\open\command = MFCRibbonApp.EXE %1 -HKEY_CLASSES_ROOT\MFCRibbonApp.Document\shell\open\ddeexec = [open("%1")] -HKEY_CLASSES_ROOT\MFCRibbonApp.Document\shell\open\ddeexec\application = MFCRibbonApp - ; note: the application is optional - ; (it defaults to the app name in "command") - -HKEY_CLASSES_ROOT\MFCRibbonApp.Document = MFCRibbonApp.Document - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppDoc.cpp deleted file mode 100644 index a5d318561262d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppDoc.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// MFCRibbonAppDoc.cpp : implementation of the CMFCRibbonAppDoc class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "MFCRibbonAppDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMFCRibbonAppDoc - -IMPLEMENT_DYNCREATE(CMFCRibbonAppDoc, CDocument) - -BEGIN_MESSAGE_MAP(CMFCRibbonAppDoc, CDocument) -END_MESSAGE_MAP() - - -// CMFCRibbonAppDoc construction/destruction - -CMFCRibbonAppDoc::CMFCRibbonAppDoc() -{ - // TODO: add one-time construction code here - -} - -CMFCRibbonAppDoc::~CMFCRibbonAppDoc() -{ -} - -BOOL CMFCRibbonAppDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - - -// CMFCRibbonAppDoc serialization - -void CMFCRibbonAppDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - - -// CMFCRibbonAppDoc diagnostics - -#ifdef _DEBUG -void CMFCRibbonAppDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CMFCRibbonAppDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - - -// CMFCRibbonAppDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppDoc.h deleted file mode 100644 index ebdf5767a9fc0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// MFCRibbonAppDoc.h : interface of the CMFCRibbonAppDoc class -// - - -#pragma once - - -class CMFCRibbonAppDoc : public CDocument -{ -protected: // create from serialization only - CMFCRibbonAppDoc(); - DECLARE_DYNCREATE(CMFCRibbonAppDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides -public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CMFCRibbonAppDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppView.cpp deleted file mode 100644 index f3e6566ce3fcc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppView.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// MFCRibbonAppView.cpp : implementation of the CMFCRibbonAppView class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "MFCRibbonAppDoc.h" -#include "MFCRibbonAppView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMFCRibbonAppView - -IMPLEMENT_DYNCREATE(CMFCRibbonAppView, CView) - -BEGIN_MESSAGE_MAP(CMFCRibbonAppView, CView) -END_MESSAGE_MAP() - -// CMFCRibbonAppView construction/destruction - -CMFCRibbonAppView::CMFCRibbonAppView() -{ - // TODO: add construction code here - -} - -CMFCRibbonAppView::~CMFCRibbonAppView() -{ -} - -BOOL CMFCRibbonAppView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -// CMFCRibbonAppView drawing - -void CMFCRibbonAppView::OnDraw(CDC* /*pDC*/) -{ - CMFCRibbonAppDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - if (!pDoc) - return; - - // TODO: add draw code for native data here -} - -void CMFCRibbonAppView::OnRButtonUp(UINT nFlags, CPoint point) -{ - ClientToScreen(&point); - OnContextMenu(this, point); -} - -void CMFCRibbonAppView::OnContextMenu(CWnd* pWnd, CPoint point) -{ - theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); -} - - -// CMFCRibbonAppView diagnostics - -#ifdef _DEBUG -void CMFCRibbonAppView::AssertValid() const -{ - CView::AssertValid(); -} - -void CMFCRibbonAppView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CMFCRibbonAppDoc* CMFCRibbonAppView::GetDocument() const // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCRibbonAppDoc))); - return (CMFCRibbonAppDoc*)m_pDocument; -} -#endif //_DEBUG - - -// CMFCRibbonAppView message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppView.h deleted file mode 100644 index a74336c23176c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MFCRibbonAppView.h +++ /dev/null @@ -1,49 +0,0 @@ -// MFCRibbonAppView.h : interface of the CMFCRibbonAppView class -// - - -#pragma once - - -class CMFCRibbonAppView : public CView -{ -protected: // create from serialization only - CMFCRibbonAppView(); - DECLARE_DYNCREATE(CMFCRibbonAppView) - -// Attributes -public: - CMFCRibbonAppDoc* GetDocument() const; - -// Operations -public: - -// Overrides -public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); -protected: - -// Implementation -public: - virtual ~CMFCRibbonAppView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - afx_msg void OnFilePrintPreview(); - afx_msg void OnRButtonUp(UINT nFlags, CPoint point); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in MFCRibbonAppView.cpp -inline CMFCRibbonAppDoc* CMFCRibbonAppView::GetDocument() const - { return reinterpret_cast(m_pDocument); } -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MainFrm.cpp deleted file mode 100644 index 994156a7d0b8c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MainFrm.cpp +++ /dev/null @@ -1,420 +0,0 @@ -// MainFrm.cpp : implementation of the CMainFrame class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) - ON_WM_CREATE() - ON_COMMAND(ID_WINDOW_MANAGER, &CMainFrame::OnWindowManager) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_OFF_2007_AQUA, OnApplicationLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_OFF_2007_AQUA, OnUpdateApplicationLook) - ON_COMMAND( ID_SLIDER_CONTROL, OnSliding ) - ON_REGISTERED_MESSAGE( AFX_WM_ON_GET_TAB_TOOLTIP, OnTooltips ) - ON_WM_ACTIVATE() -END_MESSAGE_MAP() - -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_OFF_2007_BLUE); - m_ribbonSlider = new CMFCRibbonSlider(ID_SLIDER_CONTROL, 500 ); -} - -CMainFrame::~CMainFrame() -{ -} - -LRESULT CMainFrame::OnTooltips(WPARAM /*wp*/, LPARAM lp) -{ - CMFCTabToolTipInfo* pInfo = (CMFCTabToolTipInfo*) lp; - ASSERT (pInfo != NULL); - ASSERT_VALID (pInfo->m_pTabWnd); - - if (!pInfo->m_pTabWnd->IsMDITab ()) - { - return 0; - } - - pInfo->m_strText.Format (_T("Tab #%d Custom Tooltip"), pInfo->m_nTabIndex + 1); - return 0; -} - -void CMainFrame::OnSliding( ) -{ - CString cstr; - - if (GetAsyncKeyState (VK_LBUTTON) == 0) - { - cstr.Format( _T( "position %d" ), m_ribbonSlider -> GetPos() ), - AfxMessageBox( cstr ); - } -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - // set the visual manager and style based on persisted value - OnApplicationLook(theApp.m_nAppLook); - - // - CMDITabInfo mdiTabParams; - mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; - // set to FALSE to place close button at right of tab area - mdiTabParams.m_bActiveTabCloseButton = FALSE; - // set to TRUE to enable document icons on MDI tabs - mdiTabParams.m_bTabIcons = TRUE; - // set to FALSE to disable auto-coloring of MDI tabs - mdiTabParams.m_bAutoColor = FALSE; - // set to TRUE to enable the document menu at the right edge of the tab area - mdiTabParams.m_bDocumentMenu = TRUE; - //set to TRUE to enable the user to change the tabs positions by dragging the tabs - mdiTabParams.m_bEnableTabSwap = TRUE; - // set to TRUE to give each tab window has a flat frame - mdiTabParams.m_bFlatFrame = TRUE; - // set to TRUE to enable each tab window to display the Close button on the right edge of the tab. - mdiTabParams.m_bTabCloseButton = FALSE; - // set to TRUE to enable the tabs to display tooltips. - mdiTabParams.m_bTabCustomTooltips = TRUE; - // Specifies that the tabs labels are located at the top of the page - mdiTabParams.m_tabLocation = CMFCTabCtrl::LOCATION_TOP; - EnableMDITabbedGroups(TRUE, mdiTabParams); - // - - m_wndRibbonBar.Create(this,WS_CHILD|CBRS_TOP); - InitializeRibbon(); - - if (!m_wndStatusBar.Create(this)) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - CString strTitlePane1; - CString strTitlePane2; - strTitlePane1.LoadString(IDS_STATUS_PANE1); - strTitlePane2.LoadString(IDS_STATUS_PANE2); - - CMFCRibbonStatusBarPane* rsbp = new CMFCRibbonStatusBarPane( ID_STATUSBAR_PANE1, strTitlePane1, TRUE ); - rsbp->SetTextAlign( TA_CENTER ); - - m_wndStatusBar.AddElement(rsbp, strTitlePane1); - m_wndStatusBar.AddExtendedElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE), strTitlePane2); - - // enable Visual Studio 2005 style docking window behavior - CDockingManager::SetDockingMode(DT_SMART); - // enable Visual Studio 2005 style docking window auto-hide behavior - EnableAutoHidePanes(CBRS_ALIGN_ANY); - - // Enable enhanced windows management dialog - EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWndEx::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -void CMainFrame::InitializeRibbon() -{ - CString strTemp; - strTemp.LoadString(IDS_RIBBON_FILE); - - // Load panel images: - m_PanelImages.SetImageSize(CSize(16, 16)); - m_PanelImages.Load(IDB_BUTTONS); - - // Init main button: - m_MainButton.SetImage(IDB_MAIN); - m_MainButton.SetText(_T("\nf")); - m_MainButton.SetToolTipText(strTemp); - - m_wndRibbonBar.SetApplicationButton(&m_MainButton, CSize (45, 45)); - - m_wndRibbonBar.EnableToolTips( true, false ); - - CMFCRibbonMainPanel* pMainPanel = m_wndRibbonBar.AddMainCategory(strTemp, IDB_FILESMALL, IDB_FILELARGE); - - strTemp.LoadString(IDS_RIBBON_NEW); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_NEW, strTemp, 0, 0)); - strTemp.LoadString(IDS_RIBBON_OPEN); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_OPEN, strTemp, 1, 1)); - strTemp.LoadString(IDS_RIBBON_SAVE); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SAVE, strTemp, 2, 2)); - strTemp.LoadString(IDS_RIBBON_SAVEAS); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SAVE_AS, strTemp, 3, 3)); - - strTemp.LoadString(IDS_RIBBON_PRINT); - CMFCRibbonButton* pBtnPrint = new CMFCRibbonButton(ID_FILE_PRINT, strTemp, 6, 6); - pBtnPrint->SetKeys(_T("p"), _T("w")); - strTemp.LoadString(IDS_RIBBON_PRINT_LABEL); - pBtnPrint->AddSubItem(new CMFCRibbonLabel(strTemp)); - strTemp.LoadString(IDS_RIBBON_PRINT_QUICK); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_DIRECT, strTemp, 7, 7, TRUE)); - strTemp.LoadString(IDS_RIBBON_PRINT_PREVIEW); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_PREVIEW, strTemp, 8, 8, TRUE)); - strTemp.LoadString(IDS_RIBBON_PRINT_SETUP); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_SETUP, strTemp, 11, 11, TRUE)); - pMainPanel->Add(pBtnPrint); - pMainPanel->Add(new CMFCRibbonSeparator(TRUE)); - - strTemp.LoadString(IDS_RIBBON_CLOSE); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_CLOSE, strTemp, 9, 9)); - - strTemp.LoadString(IDS_RIBBON_RECENT_DOCS); - pMainPanel->AddRecentFilesList(strTemp); - - strTemp.LoadString(IDS_RIBBON_EXIT); - pMainPanel->AddToBottom(new CMFCRibbonMainPanelButton(ID_APP_EXIT, strTemp, 15)); - - // Add "Home" category with "Clipboard" panel: - strTemp.LoadString(IDS_RIBBON_HOME); - CMFCRibbonCategory* pCategoryHome = m_wndRibbonBar.AddCategory(strTemp, IDB_WRITESMALL, IDB_WRITELARGE); - - - - CMFCRibbonCategory* activeCategory = m_wndRibbonBar.GetActiveCategory(); - //MessageBox( activeCategory ->GetName() ); - - m_wndRibbonBar.AddContextCategory( _T( "HI" ), _T( "there" ), IDS_RIBBON_HOME, AFX_CategoryColor_Red, IDB_WRITESMALL, IDB_WRITELARGE ); - - CString cstr; - cstr.Format( _T( "category count %d" ), m_wndRibbonBar.GetCategoryCount() ); - //MessageBox( cstr ); - - - if ( m_wndRibbonBar.GetContextName( IDS_RIBBON_HOME, cstr ) ) - { - //MessageBox( cstr ); - } - - - CMFCRibbonCategory* mainCategory = m_wndRibbonBar.GetMainCategory(); - - //MessageBox( mainCategory ->GetName() ); - - // Create "Clipboard" panel: - strTemp.LoadString(IDS_RIBBON_CLIPBOARD); - CMFCRibbonPanel* pPanelClipboard = pCategoryHome->AddPanel(strTemp, m_PanelImages.ExtractIcon(27)); - - strTemp.LoadString(IDS_RIBBON_PASTE); - CMFCRibbonButton* pBtnPaste = new CMFCRibbonButton(ID_EDIT_PASTE, strTemp, 0, 0); - pPanelClipboard->Add(pBtnPaste); - - strTemp.LoadString(IDS_RIBBON_CUT); - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_CUT, strTemp, 1)); - strTemp.LoadString(IDS_RIBBON_COPY); - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_COPY, strTemp, 2)); - strTemp.LoadString(IDS_RIBBON_SELECTALL); - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_SELECT_ALL, strTemp, -1)); - - // Create and add a "View" panel: - strTemp.LoadString(IDS_RIBBON_VIEW); - CMFCRibbonPanel* pPanelView = pCategoryHome->AddPanel(strTemp, m_PanelImages.ExtractIcon (7)); - - strTemp.LoadString(IDS_RIBBON_STATUSBAR); - CMFCRibbonButton* pBtnStatusBar = new CMFCRibbonCheckBox(ID_VIEW_STATUS_BAR, strTemp); - pPanelView->Add(pBtnStatusBar); - - // Create and add a "Windows" panel: - strTemp.LoadString(IDS_RIBBON_WINDOW); - CMFCRibbonPanel* pPanelWindow = pCategoryHome->AddPanel(strTemp, m_PanelImages.ExtractIcon (7)); - - strTemp.LoadString(IDS_RIBBON_WINDOWS); - - //MessageBox( strTemp ); - strTemp = "Sam"; - CMFCRibbonButton* pBtnWindows = new CMFCRibbonButton(ID_WINDOW_MANAGER, strTemp, -1, 1); - pBtnWindows->SetMenu(IDR_WINDOWS_MENU, TRUE); - pPanelWindow->Add(pBtnWindows); - - // Add elements to the right side of tabs: - strTemp.LoadString(IDS_RIBBON_STYLE); - CMFCRibbonButton* pVisualStyleButton = new CMFCRibbonButton(1, strTemp, -1, -1); - - pVisualStyleButton->SetMenu(IDR_THEME_MENU, TRUE /* No default command */, TRUE /* Right align */); - - CString strp; - - strp.Format( _T( "%d" ), pVisualStyleButton ->GetQuickAccessToolBarID() ); - - //MessageBox( strp ); - - strTemp.LoadString(IDS_RIBBON_STYLE_TIP); - pVisualStyleButton->SetToolTipText(strTemp); - strTemp.LoadString(IDS_RIBBON_STYLE_DESC); - pVisualStyleButton->SetDescription(strTemp); - m_wndRibbonBar.AddToTabs(pVisualStyleButton); - - pVisualStyleButton -> SetDefaultCommand( TRUE ); - pVisualStyleButton ->RemoveSubItem( 0 ); - pVisualStyleButton ->SetRightAlignMenu( TRUE ); - - MessageBox( pVisualStyleButton ->GetText() ); - - // Add quick access toolbar commands: - CList lstQATCmds; - - lstQATCmds.AddTail(ID_FILE_NEW); - lstQATCmds.AddTail(ID_FILE_OPEN); - lstQATCmds.AddTail(ID_FILE_SAVE); - lstQATCmds.AddTail(ID_FILE_PRINT_DIRECT); - - m_wndRibbonBar.SetQuickAccessCommands(lstQATCmds); - m_wndRibbonBar.AddToTabs(new CMFCRibbonButton(ID_APP_ABOUT, _T("\na"), m_PanelImages.ExtractIcon (0))); - - strTemp.LoadString(IDS_RIBBON_CUSTOM); - CMFCRibbonCategory* pCategoryCustom = m_wndRibbonBar.AddCategory(strTemp, IDB_FILESMALL, IDB_FILELARGE); - - // Create "Favorites" panel: - strTemp.LoadString(IDS_RIBBON_FAVORITES); - CMFCRibbonPanel* pPanelFavorites = pCategoryCustom->AddPanel(strTemp, m_PanelImages.ExtractIcon(15)); - - // Create "Quick Print" button: - strTemp.LoadString(IDS_RIBBON_PRINT_QUICK); - CMFCRibbonButton* pBtnFavPrintQuick = new CMFCRibbonButton(ID_FILE_PRINT_DIRECT, strTemp, 7); - - // Create "Print" button with "Quick Print" as subitem: - strTemp.LoadString(IDS_RIBBON_PRINT); - CMFCRibbonButton* pBtnFavPrint = new CMFCRibbonButton(ID_FILE_PRINT, strTemp, 6); - pBtnFavPrint->AddSubItem(pBtnFavPrintQuick); - - // Add "Print" button to "Favorites" panel: - pPanelFavorites->Add(pBtnFavPrint); - - // Create a simple combo box with two entries: - CMFCRibbonComboBox *pComboSimple = new CMFCRibbonComboBox(-1, FALSE, -1, 0, -1); - - // Add two items to the combo box and select the first item in the list: - pComboSimple->AddItem(_T("Hi!")); - pComboSimple->AddItem(_T("Hello!")); - pComboSimple->SelectItem(0); - - // Add combo button to "Favorites" panel: - pPanelFavorites->Add(pComboSimple); - - //CMFCRibbonSlider* ribbonSlider = new CMFCRibbonSlider(); - m_ribbonSlider->SetZoomButtons( true ); - pPanelFavorites->Add( m_ribbonSlider ); - pCategoryHome ->AddHidden( m_ribbonSlider ); - /* - int pageSize = ribbonSlider -> GetPageSize(); - CString cstr; - cstr.Format( _T( "page size = %d" ), pageSize ); - MessageBox( cstr, _T( "hello" ), 0 ); - */ -} - -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWndEx::Dump(dc); -} -#endif //_DEBUG - - -// CMainFrame message handlers - -void CMainFrame::OnWindowManager() -{ - ShowWindowsDialog(); -} - -void CMainFrame::OnApplicationLook(UINT id) -{ - CWaitCursor wait; - - theApp.m_nAppLook = id; - - switch (theApp.m_nAppLook) - { - case ID_VIEW_APPLOOK_WIN_2000: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_OFF_XP: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_OFF_2003: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - CDockingManager::SetDockingMode(DT_SMART); - break; - - case ID_VIEW_APPLOOK_VS_2005: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); - CDockingManager::SetDockingMode(DT_SMART); - break; - - default: - switch (theApp.m_nAppLook) - { - case ID_VIEW_APPLOOK_OFF_2007_BLUE: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case ID_VIEW_APPLOOK_OFF_2007_BLACK: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case ID_VIEW_APPLOOK_OFF_2007_SILVER: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); - break; - - case ID_VIEW_APPLOOK_OFF_2007_AQUA: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - } - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode(DT_SMART); - } - - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); - - theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); -} - -void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); -} - -void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) -{ - CMDIFrameWndEx::OnActivate(nState, pWndOther, bMinimized); - - // TODO: Add your message handler code here -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MainFrm.h deleted file mode 100644 index 2680fe8b0baa0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/MainFrm.h +++ /dev/null @@ -1,52 +0,0 @@ -// MainFrm.h : interface of the CMainFrame class -// - -#pragma once - -class CMainFrame : public CMDIFrameWndEx -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides -public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCRibbonBar m_wndRibbonBar; - CMFCRibbonApplicationButton m_MainButton; - CMFCToolBarImages m_PanelImages; - CMFCRibbonStatusBar m_wndStatusBar; - CMFCRibbonSlider* m_ribbonSlider; - -// Generated message map functions -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnWindowManager(); - afx_msg void OnApplicationLook(UINT id); - afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); - afx_msg void OnSliding(); - afx_msg LRESULT OnTooltips(WPARAM /*wp*/, LPARAM lp); - DECLARE_MESSAGE_MAP() - - void InitializeRibbon(); -public: - afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ReadMe.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ReadMe.txt deleted file mode 100644 index 11580887f8811..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/ReadMe.txt +++ /dev/null @@ -1,127 +0,0 @@ -================================================================================ - MICROSOFT FOUNDATION CLASS LIBRARY : MFCRibbonApp Project Overview -=============================================================================== - -The application wizard has created this MFCRibbonApp application for -you. This application not only demonstrates the basics of using the Microsoft -Foundation Classes but is also a starting point for writing your application. - -This file contains a summary of what you will find in each of the files that -make up your MFCRibbonApp application. - -MFCRibbonApp.vcproj - This is the main project file for VC++ projects generated using an application wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - application wizard. - -MFCRibbonApp.h - This is the main header file for the application. It includes other - project specific headers (including Resource.h) and declares the - CMFCRibbonAppApp application class. - -MFCRibbonApp.cpp - This is the main application source file that contains the application - class CMFCRibbonAppApp. - -MFCRibbonApp.rc - This is a listing of all of the Microsoft Windows resources that the - program uses. It includes the icons, bitmaps, and cursors that are stored - in the RES subdirectory. This file can be directly edited in Microsoft - Visual C++. Your project resources are in 1033. - -res\MFCRibbonApp.ico - This is an icon file, which is used as the application's icon. This - icon is included by the main resource file MFCRibbonApp.rc. - -res\MFCRibbonApp.rc2 - This file contains resources that are not edited by Microsoft - Visual C++. You should place all resources not editable by - the resource editor in this file. - -MFCRibbonApp.reg - This is an example .reg file that shows you the kind of registration - settings the framework will set for you. You can use this as a .reg - file to go along with your application or just delete it and rely - on the default RegisterShellFileTypes registration. - - -///////////////////////////////////////////////////////////////////////////// - -For the main frame window: - The project includes a standard MFC interface. - -MainFrm.h, MainFrm.cpp - These files contain the frame class CMainFrame, which is derived from - CMDIFrameWnd and controls all MDI frame features. - -res\Toolbar.bmp - This bitmap file is used to create tiled images for the toolbar. - The initial toolbar and status bar are constructed in the CMainFrame - class. Edit this toolbar bitmap using the resource editor, and - update the IDR_MAINFRAME TOOLBAR array in MFCRibbonApp.rc to add - toolbar buttons. -///////////////////////////////////////////////////////////////////////////// - -For the child frame window: - -ChildFrm.h, ChildFrm.cpp - These files define and implement the CChildFrame class, which - supports the child windows in an MDI application. - -///////////////////////////////////////////////////////////////////////////// - -The application wizard creates one document type and one view: - -MFCRibbonAppDoc.h, MFCRibbonAppDoc.cpp - the document - These files contain your CMFCRibbonAppDoc class. Edit these files to - add your special document data and to implement file saving and loading - (via CMFCRibbonAppDoc::Serialize). - The Document will have the following strings: - File extension: mfcrbnapp - File type ID: MFCRibbonApp.Document - Main frame caption: MFCRibbonApp - Doc type name: MFCRibbonApp - Filter name: MFCRibbonApp Files (*.mfcrbnapp) - File new short name: MFCRibbonApp - File type long name: MFCRibbonApp.Document - -MFCRibbonAppView.h, MFCRibbonAppView.cpp - the view of the document - These files contain your CMFCRibbonAppView class. - CMFCRibbonAppView objects are used to view CMFCRibbonAppDoc objects. - -res\MFCRibbonAppDoc.ico - This is an icon file, which is used as the icon for MDI child windows - for the CMFCRibbonAppDoc class. This icon is included by the main - resource file MFCRibbonApp.rc. - - - - -///////////////////////////////////////////////////////////////////////////// - -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named MFCRibbonApp.pch and a precompiled types file named StdAfx.obj. - -Resource.h - This is the standard header file, which defines new resource IDs. - Microsoft Visual C++ reads and updates this file. - -///////////////////////////////////////////////////////////////////////////// - -Other notes: - -The application wizard uses "TODO:" to indicate parts of the source code you -should add to or customize. - -If your application uses MFC in a shared DLL, you will need -to redistribute the MFC DLLs. If your application is in a language -other than the operating system's locale, you will also have to -redistribute the corresponding localized resources MFC90XXX.DLL. -For more information on both of these topics, please see the section on -redistributing Visual C++ applications in MSDN documentation. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/Snippets.txt deleted file mode 100644 index 6337c50de358b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/Snippets.txt +++ /dev/null @@ -1,3 +0,0 @@ -Topic Snippet Id - -CMDITabInfo: MainFrm.cpp 1 diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/mfcribbonapp.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/mfcribbonapp.vcxproj deleted file mode 100644 index 7318ea8cca5e7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/mfcribbonapp.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Release - Win32 - - - - {68E86035-ED93-4DDD-99B7-15A3337B8A2D} - MFCRibbonApp - MFCProj - - - - Application - Dynamic - Unicode - v110 - - - Application - v110 - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - true - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level3 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - true - Windows - MachineX86 - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonApp.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonApp.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonApp.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonApp.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonApp.rc2 deleted file mode 100644 index 2c189044817a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonApp.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// MFCRibbonApp.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonAppDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonAppDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/MFCRibbonAppDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/buttons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/buttons.bmp deleted file mode 100644 index 565fdcd6cda0a..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/buttons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/filelarge.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/filelarge.bmp deleted file mode 100644 index bf5c47c416ff3..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/filelarge.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/filesmall.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/filesmall.bmp deleted file mode 100644 index e530a92b3f2f0..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/filesmall.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/main.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/main.bmp deleted file mode 100644 index 9393d8e6ee316..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/main.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/writelarge.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/writelarge.bmp deleted file mode 100644 index 7f11d1dc99f78..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/writelarge.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/writesmall.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/writesmall.bmp deleted file mode 100644 index eda0f16597e8d..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/res/writesmall.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/resource.h deleted file mode 100644 index 5993822cfb3c0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/resource.h +++ /dev/null @@ -1,76 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by MFCRibbonApp.rc -// -#define IDS_RIBBON_CUSTOM 1 -#define IDS_RIBBON_FAVORITES 2 -#define IDD_ABOUTBOX 100 -#define IDB_WRITESMALL 110 -#define IDB_WRITELARGE 111 -#define IDB_MAIN 112 -#define IDB_BUTTONS 113 -#define IDB_FILELARGE 114 -#define IDB_FILESMALL 115 -#define IDR_POPUP_EDIT 119 -#define ID_STATUSBAR_PANE1 120 -#define ID_STATUSBAR_PANE2 121 -#define IDS_STATUS_PANE1 122 -#define IDS_STATUS_PANE2 123 -#define ID_SLIDER_CONTROL 124 -#define IDR_MAINFRAME 128 -#define IDR_MAINFRAME_256 129 -#define IDR_MFCRibbonAppTYPE 130 -#define ID_WINDOW_MANAGER 131 -#define IDS_WINDOWS_MANAGER 132 -#define IDR_PASTE_MENU 151 -#define IDR_WINDOWS_MENU 152 -#define IDR_THEME_MENU 200 -#define ID_SET_STYLE 201 -#define ID_VIEW_APPLOOK_WIN_2000 210 -#define ID_VIEW_APPLOOK_OFF_XP 211 -#define ID_VIEW_APPLOOK_WIN_XP 212 -#define ID_VIEW_APPLOOK_OFF_2003 213 -#define ID_VIEW_APPLOOK_VS_2005 214 -#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 -#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 -#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 -#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 -#define IDS_RIBBON_FILE 260 -#define IDS_RIBBON_NEW 262 -#define IDS_RIBBON_OPEN 263 -#define IDS_RIBBON_SAVE 264 -#define IDS_RIBBON_SAVEAS 265 -#define IDS_RIBBON_PRINT 266 -#define IDS_RIBBON_PRINT_LABEL 267 -#define IDS_RIBBON_PRINT_QUICK 268 -#define IDS_RIBBON_PRINT_PREVIEW 269 -#define IDS_RIBBON_PRINT_SETUP 270 -#define IDS_RIBBON_CLOSE 271 -#define IDS_RIBBON_RECENT_DOCS 272 -#define IDS_RIBBON_EXIT 273 -#define IDS_RIBBON_HOME 274 -#define IDS_RIBBON_CLIPBOARD 275 -#define IDS_RIBBON_PASTE 276 -#define IDS_RIBBON_CUT 277 -#define IDS_RIBBON_COPY 278 -#define IDS_RIBBON_SELECTALL 279 -#define IDS_RIBBON_WINDOW 284 -#define IDS_RIBBON_WINDOWS 285 -#define IDS_RIBBON_STYLE 286 -#define IDS_RIBBON_STYLE_TIP 287 -#define IDS_RIBBON_STYLE_DESC 288 -#define IDS_RIBBON_STATUSBAR 289 -#define IDS_RIBBON_VIEW 290 -#define IDS_EDIT_MENU 306 -#define ID_WRITE_PASTEASHYPERLINK 32770 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 310 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 310 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/stdafx.cpp deleted file mode 100644 index 07ccf36321adb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/stdafx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// MFCRibbonApp.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/stdafx.h deleted file mode 100644 index 72f901ec9aeca..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/stdafx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - - - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITab/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ChildFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ChildFrm.cpp deleted file mode 100644 index a89a3c94e3fd0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ChildFrm.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "MDITabsDemo.h" - -#include "ChildFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame - -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here - -} - -CChildFrame::~CChildFrame() -{ -} - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - if( !CMDIChildWndEx::PreCreateWindow(cs) ) - return FALSE; - - if (!theApp.m_Options.IsMDITabsDisabled ()) - { - cs.style &= ~WS_SYSMENU; - } - - return TRUE; -} - -void CChildFrame::ActivateFrame(int nCmdShow) -{ - CMDIChildWndEx::ActivateFrame(nCmdShow); -} - - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWndEx::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ChildFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ChildFrm.h deleted file mode 100644 index 227ec56013961..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ChildFrm.h +++ /dev/null @@ -1,39 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CChildFrame : public CMDIChildWndEx -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual void ActivateFrame(int nCmdShow); - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.cpp deleted file mode 100644 index e32b0eff23373..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.cpp +++ /dev/null @@ -1,256 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "MDITabsDemo.h" - -#include "MainFrm.h" -#include "ChildFrm.h" -#include "MDITabsDemoDoc.h" -#include "MDITabsDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -CMDITabOptions::CMDITabOptions() -{ - m_nMDITabsType = CMDITabOptions::MDITabsStandard; - m_bTabsOnTop = TRUE; - m_bActiveTabCloseButton = FALSE; - m_nTabsStyle = CMFCTabCtrl::STYLE_3D_ONENOTE; - m_bTabsAutoColor = FALSE; - m_bMDITabsIcons = TRUE; - m_bMDITabsDocMenu = FALSE; - m_bDragMDITabs = TRUE; - m_bMDITabsContextMenu = TRUE; - m_nMDITabsBorderSize = 2; - m_bDisableMDIChildRedraw = TRUE; - m_bFlatFrame = TRUE; - m_bCustomTooltips = FALSE; -} - -void CMDITabOptions::Load () -{ - m_nMDITabsType = (MDITabsType) theApp.GetInt (_T("ShowMDITabs"), TRUE); - m_bTabsOnTop = theApp.GetInt (_T("TabsOnTop"), TRUE); - m_bActiveTabCloseButton = theApp.GetInt (_T("ActiveTabCloseButton"), FALSE); - m_nTabsStyle = (CMFCTabCtrl::Style) theApp.GetInt (_T("TabsStyle"), CMFCTabCtrl::STYLE_3D_ONENOTE); - m_bTabsAutoColor = theApp.GetInt (_T("TabsAutoColor"), FALSE); - m_bMDITabsIcons = theApp.GetInt (_T("MDITabsIcons"), TRUE); - m_bMDITabsDocMenu = theApp.GetInt (_T("MDITabsDocMenu"), FALSE); - m_bDragMDITabs = theApp.GetInt (_T("DragMDITabs"), TRUE); - m_bMDITabsContextMenu = theApp.GetInt (_T("MDITabsContextMenu"), TRUE); - m_nMDITabsBorderSize = theApp.GetInt (_T("MDITabsBorderSize"), TRUE); - m_bDisableMDIChildRedraw = theApp.GetInt (_T("DisableMDIChildRedraw"), TRUE); - m_bFlatFrame = theApp.GetInt (_T("FlatFrame"), TRUE); - m_bCustomTooltips = theApp.GetInt (_T("CustomTooltips"), FALSE); -} - -void CMDITabOptions::Save () -{ - theApp.WriteInt (_T("ShowMDITabs"), m_nMDITabsType); - theApp.WriteInt (_T("TabsOnTop"), m_bTabsOnTop); - theApp.WriteInt (_T("ActiveTabCloseButton"), m_bActiveTabCloseButton); - theApp.WriteInt (_T("TabsStyle"), m_nTabsStyle); - theApp.WriteInt (_T("TabsAutoColor"), m_bTabsAutoColor); - theApp.WriteInt (_T("MDITabsIcons"), m_bMDITabsIcons); - theApp.WriteInt (_T("MDITabsDocMenu"), m_bMDITabsDocMenu); - theApp.WriteInt (_T("DragMDITabs"), m_bDragMDITabs); - theApp.WriteInt (_T("MDITabsContextMenu"), m_bMDITabsContextMenu); - theApp.WriteInt (_T("MDITabsBorderSize"), m_nMDITabsBorderSize); - theApp.WriteInt (_T("DisableMDIChildRedraw"), m_bDisableMDIChildRedraw); - theApp.WriteInt (_T("FlatFrame"), m_bFlatFrame); - theApp.WriteInt (_T("CustomTooltips"), m_bCustomTooltips); -} - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoApp - -BEGIN_MESSAGE_MAP(CMDITabsDemoApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoApp construction - -CMDITabsDemoApp::CMDITabsDemoApp() : - CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CMDITabsDemoApp object - -CMDITabsDemoApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoApp initialization - -BOOL CMDITabsDemoApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - SetRegistryBase (_T("Settings")); - - m_Options.Load (); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - InitTooltipManager (); - - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS (CMFCToolTipCtrl), - ¶ms); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate( - IDR_MDITABTYPE, - RUNTIME_CLASS(CMDITabsDemoDoc), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CMDITabsDemoView)); - AddDocTemplate(pDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) - return FALSE; - m_pMainWnd = pMainFrame; - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - OnFileNew (); - OnFileNew (); - OnFileNew (); - - // The main window has been initialized, so show and update it. - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoApp message handlers - -int CMDITabsDemoApp::ExitInstance() -{ - m_Options.Save (); - return CWinAppEx::ExitInstance(); -} - -void CMDITabsDemoApp::PreLoadState () -{ - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - -void CMDITabsDemoApp::UpdateMDITabs (BOOL bResetMDIChild) -{ - ((CMainFrame*) AfxGetMainWnd ())->UpdateMDITabs (bResetMDIChild); -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CMDITabsDemoApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.h deleted file mode 100644 index ae11f88980aec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.h +++ /dev/null @@ -1,80 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -class CMDITabOptions -{ -public: - CMDITabOptions(); - - enum MDITabsType - { - None, - MDITabsStandard, - MDITabbedGroups - }; - - - MDITabsType m_nMDITabsType; - BOOL m_bTabsOnTop; - BOOL m_bActiveTabCloseButton; - CMFCTabCtrl::Style m_nTabsStyle; - BOOL m_bTabsAutoColor; - BOOL m_bMDITabsIcons; - BOOL m_bMDITabsDocMenu; - BOOL m_bDragMDITabs; - BOOL m_bMDITabsContextMenu; - int m_nMDITabsBorderSize; - BOOL m_bDisableMDIChildRedraw; - BOOL m_bFlatFrame; - BOOL m_bCustomTooltips; - - void Load (); - void Save (); - - BOOL IsMDITabsDisabled () const {return m_nMDITabsType == CMDITabOptions::None;} -}; - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoApp: -// See MDITabsDemo.cpp for the implementation of this class -// - -class CMDITabsDemoApp : public CWinAppEx -{ -public: - CMDITabsDemoApp(); - - virtual void PreLoadState (); - - void UpdateMDITabs (BOOL bResetMDIChild); - - CMDITabOptions m_Options; - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CMDITabsDemoApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.rc deleted file mode 100644 index aa1ef9d4d0562..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemo.rc +++ /dev/null @@ -1,569 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\MDITabsDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\MDITabsDemo.ico" -IDR_MDITABTYPE ICON DISCARDABLE "res\\MDITabsDemoDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_WORKSPACE BITMAP DISCARDABLE "res\\workspace.bmp" -IDB_TOOLBAR256 BITMAP MOVEABLE PURE "res\\Toolbar256.bmp" -IDR_THEME BITMAP DISCARDABLE "res\\theme.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - -IDR_THEME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_LABEL - BUTTON ID_VIEW_APPLOOK_2000 - BUTTON ID_VIEW_APPLOOK_XP - BUTTON ID_VIEW_APPLOOK_2003 - BUTTON ID_VIEW_APPLOOK_VS2005 - BUTTON ID_VIEW_APPLOOK_WIN_XP - BUTTON ID_VIEW_APPLOOK_2007_1 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM SEPARATOR - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_2007_1 - - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_2007_2 - - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_2007_3 - - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_2007_4 - - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About MDITabsDemo...", ID_APP_ABOUT - END -END - -IDR_MDITABTYPE MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_2007_1 - - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_2007_2 - - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_2007_3 - - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_2007_4 - - END - END - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - MENUITEM "&Cascade", ID_WINDOW_CASCADE - MENUITEM "&Tile", ID_WINDOW_TILE_HORZ - MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE - END - POPUP "&Help" - BEGIN - MENUITEM "&About MDITabsDemo...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_MDITABS MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Tabbed Document", ID_MDI_TABBED - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Visual Style Toolbar", ID_VIEW_THEME_TOOLBAR - MENUITEM "&Workspace", ID_VIEW_WORKSPACE - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -IDR_POPUP_STYLE_20007 MENU DISCARDABLE -BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_2007_1 - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_2007_2 - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_2007_3 - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_2007_4 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About MDITabsDemo" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "MDITabsDemo Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "MDITabsDemo MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "MDITabsDemo\0" - VALUE "LegalCopyright", "Copyright (C) 2004\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "MDITabsDemo.EXE\0" - VALUE "ProductName", "MDITabsDemo Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "MDITabsDemo" - IDR_MDITABTYPE "\nMDITab\nMDITab\n\n\nMDITabsDemo.Document\nMDITab Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "MDITabsDemo" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_WORKSPACE "Show or hide the workspace bar\nToggle Workspace" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_MANAGER "Manages the currently opened window\nWindow List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_WINDOWS_MANAGER "&Windows..." -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_APPLOOK_2000 "Activate Office 2000 application look\nOffice 2000 Look" - ID_VIEW_APPLOOK_XP "Activate Office XP application look\nOffice XP Look" - ID_VIEW_APPLOOK_2003 "Activate Office 2003 application look\nOffice 2003 Look" - ID_VIEW_APPLOOK_WIN_XP "Activate Windows XP application look\nWindows XP Look" - ID_VIEW_APPLOOK_VS2005 "Activate Visual Studio.NET 2005 application look\nVS 2005 Look" - ID_VIEW_APPLOOK_2007_1 "Activate Office 2007 application look\nOffice 2007 Look - Blue" - ID_VIEW_APPLOOK_2007_2 "Activate Office 2007 application look\nOffice 2007 Look - Black" - ID_VIEW_APPLOOK_2007_3 "Activate Office 2007 application look\nOffice 2007 Look - Aqua" - ID_VIEW_APPLOOK_2007_4 "Activate Office 2007 application look\nOffice 2007 Look - Silver" - ID_VIEW_THEME_TOOLBAR "Show or hide the style toolbar\nToggle Style ToolBar" - ID_MDI_TABBED "Tabbed Document\nTabbed Document" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\MDITabsDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoDoc.cpp deleted file mode 100644 index 70e7a349b8586..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "MDITabsDemo.h" - -#include "MDITabsDemoDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoDoc - -IMPLEMENT_DYNCREATE(CMDITabsDemoDoc, CDocument) - -BEGIN_MESSAGE_MAP(CMDITabsDemoDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoDoc construction/destruction - -CMDITabsDemoDoc::CMDITabsDemoDoc() -{ - // TODO: add one-time construction code here - -} - -CMDITabsDemoDoc::~CMDITabsDemoDoc() -{ -} - -BOOL CMDITabsDemoDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoDoc serialization - -void CMDITabsDemoDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoDoc diagnostics - -#ifdef _DEBUG -void CMDITabsDemoDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CMDITabsDemoDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoDoc.h deleted file mode 100644 index 601205faeec59..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CMDITabsDemoDoc : public CDocument -{ -protected: // create from serialization only - CMDITabsDemoDoc(); - DECLARE_DYNCREATE(CMDITabsDemoDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CMDITabsDemoDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoView.cpp deleted file mode 100644 index ba65481f59396..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoView.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "MDITabsDemo.h" - -#include "MDITabsDemoDoc.h" -#include "MDITabsDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoView - -IMPLEMENT_DYNCREATE(CMDITabsDemoView, CView) - -BEGIN_MESSAGE_MAP(CMDITabsDemoView, CView) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoView construction/destruction - -CMDITabsDemoView::CMDITabsDemoView() -{ - // TODO: add construction code here - -} - -CMDITabsDemoView::~CMDITabsDemoView() -{ -} - -BOOL CMDITabsDemoView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoView drawing - -void CMDITabsDemoView::OnDraw(CDC* pDC) -{ - CMDITabsDemoDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - CString strTitle = pDoc->GetTitle (); - - CFont* pOldFont = pDC->SelectObject (&afxGlobalData.fontRegular); - pDC->SetBkMode (TRANSPARENT); - - pDC->TextOut (10, 10, strTitle); - - pDC->SelectObject (pOldFont); -} - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoView printing - -void CMDITabsDemoView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CMDITabsDemoView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CMDITabsDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CMDITabsDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoView diagnostics - -#ifdef _DEBUG -void CMDITabsDemoView::AssertValid() const -{ - CView::AssertValid(); -} - -void CMDITabsDemoView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CMDITabsDemoDoc* CMDITabsDemoView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMDITabsDemoDoc))); - return (CMDITabsDemoDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMDITabsDemoView message handlers - -void CMDITabsDemoView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoView.h deleted file mode 100644 index 771f8776f8371..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MDITabsDemoView.h +++ /dev/null @@ -1,53 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CMDITabsDemoView : public CView -{ -protected: // create from serialization only - CMDITabsDemoView(); - DECLARE_DYNCREATE(CMDITabsDemoView) - -// Attributes -public: - CMDITabsDemoDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CMDITabsDemoView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in MDITabsDemoView.cpp -inline CMDITabsDemoDoc* CMDITabsDemoView::GetDocument() - { return (CMDITabsDemoDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MainFrm.cpp deleted file mode 100644 index 8bb193f919104..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MainFrm.cpp +++ /dev/null @@ -1,740 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "MDITabsDemo.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -class CToolbarLabel : public CMFCToolBarButton -{ - DECLARE_SERIAL(CToolbarLabel) - -public: - CToolbarLabel (UINT nID = 0, LPCTSTR lpszText = NULL); - - virtual void OnDraw (CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, - BOOL bHorz = TRUE, BOOL bCustomizeMode = FALSE, - BOOL bHighlight = FALSE, - BOOL bDrawBorder = TRUE, - BOOL bGrayDisabledButtons = TRUE); -}; - -IMPLEMENT_SERIAL(CToolbarLabel, CMFCToolBarButton, 1) - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CToolbarLabel::CToolbarLabel (UINT nID, LPCTSTR lpszText) -{ - if (lpszText != NULL) - { - m_strText = lpszText; - } - - m_bText = TRUE; - m_nID = nID; - m_iImage = -1; -} - -void CToolbarLabel::OnDraw (CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, - BOOL bHorz, BOOL /*bCustomizeMode*/, BOOL /*bHighlight*/, - BOOL /*bDrawBorder*/, BOOL /*bGrayDisabledButtons*/) -{ - UINT nStyle = m_nStyle; - m_nStyle &= ~TBBS_DISABLED; - - CMFCToolBarButton::OnDraw (pDC, rect, pImages, bHorz, FALSE, - FALSE, FALSE, FALSE); - - m_nStyle = nStyle; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_THEME_TOOLBAR, OnViewThemeToolbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_THEME_TOOLBAR, OnUpdateViewThemeToolbar) - ON_COMMAND(ID_MDI_TABBED, OnMdiTabbed) - ON_UPDATE_COMMAND_UI(ID_MDI_TABBED, OnUpdateMdiTabbed) - ON_COMMAND(ID_WINDOW_MANAGER, OnWindowManager) - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_COMMAND(ID_VIEW_WORKSPACE, OnViewWorkspace) - ON_UPDATE_COMMAND_UI(ID_VIEW_WORKSPACE, OnUpdateViewWorkspace) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnUpdateAppLook) - ON_REGISTERED_MESSAGE(AFX_WM_ON_GET_TAB_TOOLTIP, OnGetTabToolTip) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_nAppLook = theApp.GetInt (_T("ApplicationLook"), ID_VIEW_APPLOOK_2003); -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - OnAppLook (m_nAppLook); - - CMFCToolBar::EnableQuickCustomization (); - - UpdateMDITabs (FALSE); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Prevent the menu bar from taking the focus on activation - CMFCPopupMenu::SetForceMenuFocus(FALSE); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndToolBarTheme.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_THEME_TOOLBAR) || - !m_wndToolBarTheme.LoadToolBar (IDR_THEME, 0, 0, TRUE /* Locked */)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - CImageList imagesWorkspace; - imagesWorkspace.Create (IDB_WORKSPACE, 16, 0, RGB (255, 0, 255)); - - if (!m_wndWorkSpace.Create (_T("MDI Tabs Options"), this, CRect (0, 0, 300, 300), - TRUE, ID_VIEW_WORKSPACE, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Workspace bar\n"); - return FALSE; // fail to create - } - - m_wndWorkSpace.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); - - m_wndToolBar.SetWindowText (_T("Standard")); - m_wndToolBarTheme.SetWindowText (_T("Visual Style")); - - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBarTheme.EnableDocking(CBRS_ALIGN_ANY); - - m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - EnableAutoHidePanes(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane(&m_wndToolBarTheme); - DockPane (&m_wndWorkSpace); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - m_wndToolBarTheme.EnableCustomizeButton (TRUE, -1, _T("")); - - // Enable windows manager: - EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - - if (uiToolBarId == IDR_THEME) - { - CMenu menu2007; - menu2007.LoadMenu (IDR_POPUP_STYLE_20007); - - UINT uiCmd2007 = ID_VIEW_APPLOOK_2007_1; - - if (m_nAppLook >= ID_VIEW_APPLOOK_2007_1 && - m_nAppLook <= ID_VIEW_APPLOOK_2007_4) - { - uiCmd2007 = m_nAppLook; - } - - CMFCToolBarMenuButton menuButton (uiCmd2007, menu2007.Detach (), -1); - - for (UINT uiCmd = ID_VIEW_APPLOOK_2007_1; uiCmd <= ID_VIEW_APPLOOK_2007_4; uiCmd++) - { - if (m_wndToolBarTheme.ReplaceButton (ID_VIEW_APPLOOK_2007_1, menuButton) > 0) - { - break; - } - } - - for (int i = 0; i < m_wndToolBarTheme.GetCount (); i++) - { - m_wndToolBarTheme.SetToolBarBtnText (i, NULL, TRUE, FALSE); - } - - m_wndToolBarTheme.ReplaceButton (ID_LABEL, - CToolbarLabel (ID_LABEL, _T("Visual style: "))); - } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CMDIFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnViewWorkspace() -{ - ShowPane (&m_wndWorkSpace, - !(m_wndWorkSpace.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewWorkspace(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndWorkSpace.IsVisible ()); -} - -void CMainFrame::OnWindowManager() -{ - ShowWindowsDialog (); -} - -void CMainFrame::OnAppLook(UINT id) -{ - m_nAppLook = id; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2000: - // enable Office 2000 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_XP: - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - // enable Windows XP look (in other OS Office XP look will be used): - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - break; - - case ID_VIEW_APPLOOK_2003: - // enable Office 2003 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - break; - - case ID_VIEW_APPLOOK_VS2005: - // enable VS 2005 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - break; - - case ID_VIEW_APPLOOK_2007_1: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - case ID_VIEW_APPLOOK_2007_2: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - case ID_VIEW_APPLOOK_2007_3: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - case ID_VIEW_APPLOOK_2007_4: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - default: - ASSERT (FALSE); - } - - CDockingManager* pDockManager = GetDockingManager (); - if (pDockManager != NULL) - { - ASSERT_VALID (pDockManager); - pDockManager->AdjustPaneFrames (); - } - - CDockingManager::SetDockingMode (DT_SMART); - - if (!IsMDITabbedGroup()) - { - HWND hwndT = ::GetWindow(m_hWndMDIClient, GW_CHILD); - while (hwndT != NULL) - { - CMDIChildWndEx* pFrame = DYNAMIC_DOWNCAST(CMDIChildWndEx, CWnd::FromHandle(hwndT)); - if (pFrame != NULL) - { - ASSERT_VALID(pFrame); - if (!pFrame->IsZoomed() && !pFrame->IsIconic()) - { - CRect rectFrame; - // Force a resize to happen on all the "restored" MDI child windows - pFrame->GetWindowRect(rectFrame); - pFrame->SetWindowPos(NULL, -1, -1, rectFrame.Width() + 1, rectFrame.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); - pFrame->SetWindowPos(NULL, -1, -1, rectFrame.Width(), rectFrame.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); - } - } - hwndT = ::GetWindow(hwndT, GW_HWNDNEXT); - } - } - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - theApp.WriteInt (_T("ApplicationLook"), m_nAppLook); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); -} - -// -void CMainFrame::UpdateMDITabs (BOOL bResetMDIChild) -{ - CMDITabInfo params; - HWND hwndActive = NULL; - - switch (theApp.m_Options.m_nMDITabsType) - { - case CMDITabOptions::None: - { - BOOL bCascadeMDIChild = FALSE; - - if (IsMDITabbedGroup ()) - { - EnableMDITabbedGroups (FALSE, params); - bCascadeMDIChild = TRUE; - } - else if (AreMDITabs ()) - { - EnableMDITabs (FALSE); - bCascadeMDIChild = TRUE; - } - - if (bCascadeMDIChild) - { - // - // CMDIClientAreaWnd m_wndClientArea - hwndActive = (HWND) m_wndClientArea.SendMessage (WM_MDIGETACTIVE); - m_wndClientArea.PostMessage (WM_MDICASCADE); - m_wndClientArea.UpdateTabs( false ); - m_wndClientArea.SetActiveTab(hwndActive); - // - ::BringWindowToTop (hwndActive); - } - } - break; - - case CMDITabOptions::MDITabsStandard: - hwndActive = (HWND) m_wndClientArea.SendMessage (WM_MDIGETACTIVE); - m_wndClientArea.PostMessage (WM_MDIMAXIMIZE, LPARAM(hwndActive), 0L); - ::BringWindowToTop (hwndActive); - - EnableMDITabs (TRUE,theApp.m_Options.m_bMDITabsIcons, theApp.m_Options.m_bTabsOnTop ? CMFCTabCtrl::LOCATION_TOP : CMFCTabCtrl::LOCATION_BOTTOM, theApp.m_Options.m_nTabsStyle); - - GetMDITabs().EnableAutoColor (theApp.m_Options.m_bTabsAutoColor); - GetMDITabs().EnableTabDocumentsMenu (theApp.m_Options.m_bMDITabsDocMenu); - GetMDITabs().EnableTabSwap (theApp.m_Options.m_bDragMDITabs); - GetMDITabs().SetTabBorderSize (theApp.m_Options.m_nMDITabsBorderSize); - GetMDITabs().SetFlatFrame (theApp.m_Options.m_bFlatFrame); - GetMDITabs().EnableCustomToolTips (theApp.m_Options.m_bCustomTooltips); - GetMDITabs().EnableCustomToolTips (theApp.m_Options.m_bCustomTooltips); - GetMDITabs().EnableActiveTabCloseButton (theApp.m_Options.m_bActiveTabCloseButton); - break; -// - - // - case CMDITabOptions::MDITabbedGroups: - hwndActive = (HWND) m_wndClientArea.SendMessage (WM_MDIGETACTIVE); - m_wndClientArea.PostMessage (WM_MDIMAXIMIZE, LPARAM(hwndActive), 0L); - ::BringWindowToTop (hwndActive); - - params.m_tabLocation = theApp.m_Options.m_bTabsOnTop ? CMFCTabCtrl::LOCATION_TOP : CMFCTabCtrl::LOCATION_BOTTOM; - params.m_style = theApp.m_Options.m_nTabsStyle; - params.m_bTabCloseButton = !theApp.m_Options.m_bActiveTabCloseButton; - params.m_bActiveTabCloseButton = theApp.m_Options.m_bActiveTabCloseButton; - params.m_bAutoColor = theApp.m_Options.m_bTabsAutoColor; - params.m_bDocumentMenu = theApp.m_Options.m_bMDITabsDocMenu; - params.m_bEnableTabSwap = theApp.m_Options.m_bDragMDITabs; - params.m_nTabBorderSize = theApp.m_Options.m_nMDITabsBorderSize; - params.m_bTabIcons = theApp.m_Options.m_bMDITabsIcons; - params.m_bFlatFrame = theApp.m_Options.m_bFlatFrame; - params.m_bTabCustomTooltips = theApp.m_Options.m_bCustomTooltips; - - EnableMDITabbedGroups (TRUE, params); - break; - // - } - - // Some "Windows..." commands are non-relevant when all MDI child windows are always maximized: - CList lstCommands; - - if (theApp.m_Options.IsMDITabsDisabled()) - { - lstCommands.AddTail (ID_WINDOW_CASCADE); - lstCommands.AddTail (ID_WINDOW_TILE_HORZ); - lstCommands.AddTail (ID_WINDOW_ARRANGE); - } - - CMFCToolBar::SetNonPermittedCommands (lstCommands); - - if (bResetMDIChild) - { - // Adjust MDI child windows: - BOOL bMaximize = !theApp.m_Options.IsMDITabsDisabled(); - - HWND hwndT = ::GetWindow(m_hWndMDIClient, GW_CHILD); - while (hwndT != NULL) - { - CMDIChildWndEx* pFrame = DYNAMIC_DOWNCAST(CMDIChildWndEx, CWnd::FromHandle(hwndT)); - if (pFrame != NULL) - { - ASSERT_VALID (pFrame); - if (bMaximize) - { - pFrame->ModifyStyle(WS_SYSMENU, 0); - } - else - { - pFrame->ModifyStyle(0, WS_SYSMENU); - pFrame->ShowWindow(SW_RESTORE); - - // Force a resize to happen on all the "restored" MDI child windows - CRect rectFrame; - pFrame->GetWindowRect(rectFrame); - pFrame->SetWindowPos(NULL, -1, -1, rectFrame.Width() + 1, rectFrame.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); - pFrame->SetWindowPos(NULL, -1, -1, rectFrame.Width(), rectFrame.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); - } - } - - hwndT = ::GetWindow(hwndT, GW_HWNDNEXT); - } - if (bMaximize) - { - m_wndMenuBar.SetMaximizeMode (FALSE); - } - } - - if (m_wndWorkSpace.IsAutoHideMode ()) - { - m_wndWorkSpace.BringWindowToTop (); - - // - // CWorkspaceBar m_wndWorkSpace - CPaneDivider* pSlider = m_wndWorkSpace.GetDefaultPaneDivider (); - // - - if (pSlider != NULL) - { - pSlider->BringWindowToTop (); - } - } - - CMDIFrameWndEx::m_bDisableSetRedraw = theApp.m_Options.m_bDisableMDIChildRedraw; - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); -} - -void CMainFrame::OnViewThemeToolbar() -{ - ShowPane (&m_wndToolBarTheme, - !(m_wndToolBarTheme.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewThemeToolbar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndToolBarTheme.IsVisible ()); -} - -CMDIChildWndEx* CMainFrame::CreateDocumentWindow (LPCTSTR lpcszDocName) -{ - if (lpcszDocName != NULL && lpcszDocName [0] != '\0') - { - CDocument* pDoc = AfxGetApp()->OpenDocumentFile (lpcszDocName); - - if (pDoc != NULL) - { - POSITION pos = pDoc->GetFirstViewPosition(); - - if (pos != NULL) - { - CView* pView = pDoc->GetNextView (pos); - return DYNAMIC_DOWNCAST (CMDIChildWndEx, pView->GetParent ()); - } - } - } - return NULL; -} - -BOOL CMainFrame::OnShowMDITabContextMenu (CPoint point, DWORD dwAllowedItems, BOOL bDrop) -{ - if (bDrop || !theApp.m_Options.m_bMDITabsContextMenu) - { - return FALSE; - } - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_MDITABS)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - if ((dwAllowedItems & AFX_MDI_CAN_BE_DOCKED) == 0) - { - pPopup->DeleteMenu (ID_MDI_TABBED, MF_BYCOMMAND); - } - - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - if (pPopupMenu) - { - pPopupMenu->SetAutoDestroy (FALSE); - pPopupMenu->Create (this, point.x, point.y, pPopup->GetSafeHmenu ()); - } - } - - return TRUE; -} - -// -LRESULT CMainFrame::OnGetTabToolTip(WPARAM /*wp*/, LPARAM lp) -{ - CMFCTabToolTipInfo* pInfo = (CMFCTabToolTipInfo*) lp; - ASSERT (pInfo != NULL); - - if (pInfo) - { - ASSERT_VALID (pInfo->m_pTabWnd); - if (!pInfo->m_pTabWnd->IsMDITab ()) - { - return 0; - } - pInfo->m_strText.Format (_T("Tab #%d Custom Tooltip"), pInfo->m_nTabIndex + 1); - } - - return 0; -} -// - -void CMainFrame::SetupOffice2007Button () -{ - CMFCToolBarButton* pOffice2007 = NULL; - int nIndex = -1; - - for (UINT uiCmd = ID_VIEW_APPLOOK_2007_1; uiCmd <= ID_VIEW_APPLOOK_2007_4; uiCmd++) - { - nIndex = m_wndToolBarTheme.CommandToIndex (uiCmd); - - CMFCToolBarButton* pButton = m_wndToolBarTheme.GetButton (nIndex); - if (pButton != NULL) - { - pOffice2007 = pButton; - break; - } - } - - if (pOffice2007 == NULL) - { - return; - } - - ASSERT_VALID (pOffice2007); - - pOffice2007->m_nID = m_nAppLook; - m_wndToolBarTheme.SetToolBarBtnText (nIndex, NULL, TRUE, FALSE); - m_wndToolBarTheme.AdjustSizeImmediate (); -} - -void CMainFrame::OnMdiTabbed() -{ - CMDIChildWndEx* pMDIChild = DYNAMIC_DOWNCAST(CMDIChildWndEx, MDIGetActive ()); - if (pMDIChild == NULL) - { - ASSERT (FALSE); - return; - } - - TabbedDocumentToControlBar (pMDIChild); -} - -void CMainFrame::OnUpdateMdiTabbed(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MainFrm.h deleted file mode 100644 index 7d794e444991d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/MainFrm.h +++ /dev/null @@ -1,73 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "WorkspaceBar.h" - -#define CMDIFrameWnd CMDIFrameWndEx - -class CMainFrame : public CMDIFrameWnd -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - void UpdateMDITabs (BOOL bResetMDIChild); - CMDIChildWndEx* CreateDocumentWindow (LPCTSTR lpcszDocName); - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - CMFCToolBar m_wndToolBarTheme; - CWorkspaceBar m_wndWorkSpace; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewThemeToolbar(); - afx_msg void OnUpdateViewThemeToolbar(CCmdUI* pCmdUI); - afx_msg void OnMdiTabbed(); - afx_msg void OnUpdateMdiTabbed(CCmdUI* pCmdUI); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnViewWorkspace(); - afx_msg void OnUpdateViewWorkspace(CCmdUI* pCmdUI); - afx_msg void OnWindowManager(); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - afx_msg LRESULT OnGetTabToolTip(WPARAM wp, LPARAM lp); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); - virtual BOOL OnShowMDITabContextMenu (CPoint point, DWORD dwAllowedItems, BOOL bDrop); - - UINT m_nAppLook; - - void SetupOffice2007Button (); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ReadMe.htm deleted file mode 100644 index d1dedba531359..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,127 +0,0 @@ - - - - MDITabsDemo Sample: MFC Tabbed MDI Application - - -

- MDITabsDemo Sample: MFC Tabbed MDI Application

-
-
-
- -

-

-
-

- The MDITabsDemo sample demonstrates how to create an application that uses the new - tabbed MDI documents interface rather than the traditional MDI child windows.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the MDITabsDemo sample

-
-
    -
  1. -

    - Open the solution file MDITabsDemo.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The MDITabsDemo sample demonstrates the following keywords:

-

- CDockablePane; CDockingManager; CMDIChildWndEx; CMDIFrameWnd; CMDIFrameWndEx; CMDITabInfo; - CMDITabOptions; CMFCMenuBar; CMFCPopupMenu; CMFCPropertyGridCtrl; CMFCPropertyGridProperty; - CMFCStatusBar; CMFCTabCtrl; CMFCTabToolTipInfo; CMFCToolBar; CMFCToolBarButton; - CMFCToolBarImages; CMFCToolBarMenuButton; CMFCToolBarsCustomizeDialog; CMFCToolTipCtrl; - CMFCToolTipInfo; CMFCVisualManager; CMFCVisualManagerOffice; CMFCVisualManagerWindows; - CPaneDivider; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/Resource.h deleted file mode 100644 index f25e96637df01..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/Resource.h +++ /dev/null @@ -1,45 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by MDITabsDemo.rc -// -#define IDD_ABOUTBOX 100 -#define IDP_OLE_INIT_FAILED 100 -#define IDS_WINDOWS_MANAGER 107 -#define IDR_MAINFRAME 128 -#define IDR_MDITABTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDR_POPUP_MDITABS 132 -#define IDR_POPUP_STYLE_20007 133 -#define IDB_WORKSPACE 147 -#define IDB_TOOLBAR256 151 -#define IDR_THEME 154 -#define IDC_COMPANY_URL 1041 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_WORKSPACE 32803 -#define ID_WINDOW_MANAGER 32823 -#define ID_VIEW_APPLOOK_2000 32832 -#define ID_VIEW_APPLOOK_XP 32833 -#define ID_VIEW_APPLOOK_2003 32834 -#define ID_VIEW_APPLOOK_WIN_XP 32835 -#define ID_VIEW_APPLOOK_VS2005 32836 -#define ID_VIEW_APPLOOK_2007_1 32837 -#define ID_VIEW_APPLOOK_2007_2 32838 -#define ID_VIEW_APPLOOK_2007_3 32839 -#define ID_VIEW_APPLOOK_2007_4 32840 -#define ID_VIEW_THEME_TOOLBAR 32841 -#define ID_LABEL 32842 -#define ID_MDI_TABBED 32843 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 156 -#define _APS_NEXT_COMMAND_VALUE 32844 -#define _APS_NEXT_CONTROL_VALUE 1042 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/Snippets.txt deleted file mode 100644 index f82877917dca5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/Snippets.txt +++ /dev/null @@ -1,7 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -CMDITabInfo::m_bEnableTabSwap etc. 1 -CMFCTabToolTipInfo various 2 -CMDIFrameWndEx::EnableMDITabs 3 -MainFrm.cpp 4 -MainFrm.cpp: CPaneDivider 5 diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/StdAfx.cpp deleted file mode 100644 index eb87fc204e0ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/StdAfx.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// stdafx.cpp : source file that includes just the standard includes -// MDITabsDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/StdAfx.h deleted file mode 100644 index 2f3c31a436cfe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/StdAfx.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/WorkspaceBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/WorkspaceBar.cpp deleted file mode 100644 index 3e227c1b18eda..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/WorkspaceBar.cpp +++ /dev/null @@ -1,357 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "MDITabsDemo.h" -#include "WorkspaceBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#pragma warning(disable: 4800) // 'LPCVARIANT' : forcing value to bool 'true' or 'false' (performance warning) - -const int nBorderSize = 1; - -static TCHAR* lpszMDITabsStyles [] = -{ - _T("None"), - _T("MDI Tabs (Standard)"), - _T("MDI Tabbed Groups"), - NULL -}; - - -static TCHAR* lpszStyles [] = -{ - _T("3D Tabs"), - _T("OneNote"), - _T("Visual Studio 2005"), - NULL -}; - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar - -BEGIN_MESSAGE_MAP(CWorkspaceBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_PAINT() - ON_REGISTERED_MESSAGE(AFX_WM_PROPERTY_CHANGED, OnPropertyChanged) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar construction/destruction - -CWorkspaceBar::CWorkspaceBar() -{ - // TODO: add one-time construction code here - -} - -CWorkspaceBar::~CWorkspaceBar() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar message handlers - -int CWorkspaceBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty (); - - if (!m_wndPropList.Create (WS_VISIBLE | WS_CHILD, rectDummy, this, 1)) - { - TRACE0("Failed to create Properies Grid \n"); - return -1; // fail to create - } - - m_wndPropList.EnableHeaderCtrl (FALSE); - m_wndPropList.EnableDescriptionArea (); - m_wndPropList.SetVSDotNetLook (); - - CMFCPropertyGridProperty* pMDITabsProp = new CMFCPropertyGridProperty (_T("Enable MDI Tabs"), - lpszMDITabsStyles [1], - _T("Enable or disable either the standard MDI Tabs feature, or MDI Tabbed Groups feature"), - idShowMDITabs); - - pMDITabsProp->AddOption (_T ("None")); - pMDITabsProp->AddOption (_T ("MDI Tabs (Standard)")); - pMDITabsProp->AddOption (_T ("MDI Tabbed Groups")); - - int i = 0; - for (i = 0; lpszMDITabsStyles [i] != NULL; i++) - { - pMDITabsProp->AddOption (lpszMDITabsStyles [i]); - } - - switch (theApp.m_Options.m_nMDITabsType) - { - case CMDITabOptions::None: - pMDITabsProp->SetValue (lpszMDITabsStyles [0]); - break; - - case CMDITabOptions::MDITabsStandard: - pMDITabsProp->SetValue (lpszMDITabsStyles [1]); - break; - - case CMDITabOptions::MDITabbedGroups: - pMDITabsProp->SetValue (lpszMDITabsStyles [2]); - break; - } - - pMDITabsProp->AllowEdit (FALSE); - - m_wndPropList.AddProperty (pMDITabsProp); - - COleVariant varTabsOnTop((short)(theApp.m_Options.m_bTabsOnTop == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Tabs on top"), varTabsOnTop, - _T("Show MDI tabs on top"), idTabsOnTop)); - - COleVariant varActiveTabCloseButton((short)(theApp.m_Options.m_bActiveTabCloseButton == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Active tab \"Close\" button"), varActiveTabCloseButton, - _T("Show \"Close\" button on the active tab right side"), idActiveTabCloseButton)); - - CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty (_T("MDI Tabs style"), _T(""), - _T("One of: VS.NET, OneNote or Visual Studio 2005"), idTabsStyle); - - for (i = 0; lpszStyles [i] != NULL; i++) - { - pProp->AddOption (lpszStyles [i]); - } - - switch (theApp.m_Options.m_nTabsStyle) - { - case CMFCTabCtrl::STYLE_3D_SCROLLED: - pProp->SetValue (lpszStyles [0]); - break; - - case CMFCTabCtrl::STYLE_3D_ONENOTE: - pProp->SetValue (lpszStyles [1]); - break; - - case CMFCTabCtrl::STYLE_3D_VS2005: - pProp->SetValue (lpszStyles [2]); - break; - } - - pProp->AllowEdit (FALSE); - m_wndPropList.AddProperty (pProp); - - COleVariant varTabsAutoColor((short)(theApp.m_Options.m_bTabsAutoColor == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Tabs auto-color"), varTabsAutoColor, - _T("Set MDI tabs automatic color"), idTabsAutoColor)); - - COleVariant varMDITabsIcons((short)(theApp.m_Options.m_bMDITabsIcons == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Tab icons"), varMDITabsIcons, - _T("Show document icons on MDI tabs"), idMDITabsIcons)); - - COleVariant varMDITabsDocMenu((short)(theApp.m_Options.m_bMDITabsDocMenu == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Tabs document menu"), varMDITabsDocMenu, - _T("Show menu with a list of opened documents"), idMDITabsDocMenu)); - - COleVariant varDragMDITabs((short)(theApp.m_Options.m_bDragMDITabs == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Drag tabs"), varDragMDITabs, - _T("Enable MDI tabs order changing"), idDragMDITabs)); - - COleVariant varMDITabsContextMenu((short)(theApp.m_Options.m_bMDITabsContextMenu == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Context Menu"), varMDITabsContextMenu, - _T("Enable MDI tabs context menu"), idMDITabsContextMenu)); - - CMFCPropertyGridProperty* pBorderProp = new CMFCPropertyGridProperty (_T("Border Size"), - (COleVariant) ((short) theApp.m_Options.m_nMDITabsBorderSize), - _T("Set MDI border"), idMDITabsBorderSize); - pBorderProp->EnableSpinControl (TRUE, 0, 10); - pBorderProp->AllowEdit(FALSE); - - m_wndPropList.AddProperty (pBorderProp); - - COleVariant varDisableMDIChildRedraw((short)(theApp.m_Options.m_bDisableMDIChildRedraw == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("No optimize MDI child redraw"), varDisableMDIChildRedraw, - _T("Disable MDI Child redraw optimization"), idDisableMDIChildRedraw)); - - COleVariant varFlatFrame((short)(theApp.m_Options.m_bFlatFrame == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Flat Frame"), varFlatFrame, - _T("Enable or disable 3D frame around MDI client area"), idFlatFrame)); - - COleVariant varCustomTooltips((short)(theApp.m_Options.m_bCustomTooltips == TRUE), VT_BOOL); - m_wndPropList.AddProperty (new CMFCPropertyGridProperty (_T("Custom Tooltips"), varCustomTooltips, - _T("Enable MDI tabs custom tooltips"), idCustomTooltips)); - - SetPropState (); - return 0; -} - -void CWorkspaceBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - // Tab control should cover a whole client area: - m_wndPropList.SetWindowPos (NULL, nBorderSize, nBorderSize, - cx - 2 * nBorderSize, cy - 2 * nBorderSize, - SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CWorkspaceBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndPropList.GetWindowRect (rectTree); - ScreenToClient (rectTree); - - rectTree.InflateRect (nBorderSize, nBorderSize); - dc.Draw3dRect (rectTree, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DSHADOW)); -} - -LRESULT CWorkspaceBar::OnPropertyChanged (WPARAM,LPARAM lParam) -{ - CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*) lParam; - - BOOL bResetMDIChild = FALSE; - - switch ((int) pProp->GetData ()) - { - case idShowMDITabs: - { - CString strShowMdiTabOption = (LPCTSTR) (_bstr_t)pProp->GetValue (); - bResetMDIChild = TRUE; - - for (int i = 0; lpszMDITabsStyles [i] != NULL; i++) - { - if (strShowMdiTabOption == lpszMDITabsStyles [i]) - { - switch (i) - { - case 0: - theApp.m_Options.m_nMDITabsType = CMDITabOptions::None; - break; - - case 1: - theApp.m_Options.m_nMDITabsType = CMDITabOptions::MDITabsStandard; - break; - - case 2: - theApp.m_Options.m_nMDITabsType = CMDITabOptions::MDITabbedGroups; - break; - } - break; - } - } - - SetPropState (); - } - break; - - case idTabsOnTop: - theApp.m_Options.m_bTabsOnTop = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idActiveTabCloseButton: - theApp.m_Options.m_bActiveTabCloseButton = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idTabsStyle: - { - CString strStyle = (LPCTSTR) (_bstr_t)pProp->GetValue (); - - for (int i = 0; lpszStyles [i] != NULL; i++) - { - if (strStyle == lpszStyles [i]) - { - switch (i) - { - case 0: - theApp.m_Options.m_nTabsStyle = CMFCTabCtrl::STYLE_3D_SCROLLED; - break; - - case 1: - theApp.m_Options.m_nTabsStyle = CMFCTabCtrl::STYLE_3D_ONENOTE; - break; - - case 2: - theApp.m_Options.m_nTabsStyle = CMFCTabCtrl::STYLE_3D_VS2005; - break; - } - break; - } - } - } - break; - - case idTabsAutoColor: - theApp.m_Options.m_bTabsAutoColor = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idMDITabsIcons: - theApp.m_Options.m_bMDITabsIcons = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idMDITabsDocMenu: - theApp.m_Options.m_bMDITabsDocMenu = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idDragMDITabs: - theApp.m_Options.m_bDragMDITabs = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idMDITabsContextMenu: - theApp.m_Options.m_bMDITabsContextMenu = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idMDITabsBorderSize: - { - int nBorder = pProp->GetValue ().iVal; - theApp.m_Options.m_nMDITabsBorderSize = min (10, max (0, nBorder)); - } - break; - - case idDisableMDIChildRedraw: - theApp.m_Options.m_bDisableMDIChildRedraw = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idFlatFrame: - theApp.m_Options.m_bFlatFrame = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - - case idCustomTooltips: - theApp.m_Options.m_bCustomTooltips = pProp->GetValue().boolVal == VARIANT_TRUE; - break; - } - - theApp.UpdateMDITabs (bResetMDIChild); - return 0; -} - -void CWorkspaceBar::SetPropState () -{ - for (int i = 0; i < m_wndPropList.GetPropertyCount (); i++) - { - CMFCPropertyGridProperty* pProp = m_wndPropList.GetProperty (i); - ASSERT_VALID (pProp); - - if ((int) pProp->GetData () != idShowMDITabs) - { - pProp->Enable (theApp.m_Options.m_nMDITabsType != CMDITabOptions::None); - } - } - - if (m_wndPropList.GetSafeHwnd () != NULL) - { - m_wndPropList.RedrawWindow (); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/WorkspaceBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/WorkspaceBar.h deleted file mode 100644 index 0317c295cdd3c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/WorkspaceBar.h +++ /dev/null @@ -1,56 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CWorkspaceBar : public CDockablePane -{ -public: - CWorkspaceBar(); - -// Attributes -protected: - CMFCPropertyGridCtrl m_wndPropList; - - enum - { - idShowMDITabs, - idTabsOnTop, - idActiveTabCloseButton, - idTabsStyle, - idTabsAutoColor, - idMDITabsIcons, - idMDITabsDocMenu, - idDragMDITabs, - idMDITabsContextMenu, - idMDITabsBorderSize, - idDisableMDIChildRedraw, - idFlatFrame, - idCustomTooltips - }; - -// Operations -public: - void SetPropState (); - -// Overrides - -// Implementation -public: - virtual ~CWorkspaceBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnPaint(); - afx_msg LRESULT OnPropertyChanged (WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/mditabsdemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/mditabsdemo.vcxproj deleted file mode 100644 index f169982d5f3e7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/mditabsdemo.vcxproj +++ /dev/null @@ -1,231 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {22318805-4E74-4658-90F0-3B03B1D9D855} - MDITabsDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/MDITabsDemo.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/MDITabsDemo.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/MDITabsDemo.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/MDITabsDemo.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - - true - - - - - - - - - true - true - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/mditabsdemo.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/mditabsdemo.vcxproj.filters deleted file mode 100644 index 38420c5683da0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/mditabsdemo.vcxproj.filters +++ /dev/null @@ -1,100 +0,0 @@ - - - - - {3236d792-55a2-4162-886f-b3586e7fe08d} - h;hpp;hxx;hm;inl - - - {77aa0b06-6565-4589-80d7-1f5010326328} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {ad7abeb8-2903-4c22-81ae-62ac723567c9} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemo.rc2 deleted file mode 100644 index 30726d2a39a26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// MDITABSDEMO.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemoDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemoDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/MDITabsDemoDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/theme.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/theme.bmp deleted file mode 100644 index 0192312baa327..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/theme.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/workspace.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/workspace.bmp deleted file mode 100644 index cd2ea75dcd988..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/res/workspace.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_MDITabsDemo/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/CalendarBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/CalendarBar.cpp deleted file mode 100644 index e0d0921527dec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/CalendarBar.cpp +++ /dev/null @@ -1,143 +0,0 @@ - -#include "stdafx.h" -#include "CalendarBar.h" -#include "Misc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int nBorderSize = 10; - -///////////////////////////////////////////////////////////////////////////// -// CCalendarBar - -CCalendarBar::CCalendarBar() -{ - m_nMyCalendarsY = 0; -} - -CCalendarBar::~CCalendarBar() -{ -} - -BEGIN_MESSAGE_MAP(CCalendarBar, CWnd) - ON_WM_CREATE() - ON_WM_ERASEBKGND() - ON_WM_SIZE() - ON_WM_PAINT() - ON_WM_SETTINGCHANGE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCalendarBar message handlers - -int CCalendarBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy(0, 0, 0, 0); - m_wndCalendar.Create(WS_CHILD | WS_VISIBLE, rectDummy, this, 1); - - CBitmap bmp; - bmp.LoadBitmap(IDB_PAGES_SMALL_HC); - - m_Images.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 0); - m_Images.Add(&bmp, RGB(255, 0, 255)); - - return 0; -} - -BOOL CCalendarBar::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} - -void CCalendarBar::OnSize(UINT nType, int cx, int cy) -{ - CWnd::OnSize(nType, cx, cy); - - int nMyCalendarsHeight = 70; - - if (m_wndCalendar.GetSafeHwnd() != NULL) - { - m_wndCalendar.SetWindowPos(NULL, nBorderSize, nBorderSize, cx - 2 * nBorderSize, cy - 2 * nBorderSize - nMyCalendarsHeight - 10, SWP_NOZORDER | SWP_NOACTIVATE); - } - - m_nMyCalendarsY = cy - nMyCalendarsHeight; -} - -BOOL CCalendarBar::Create(const RECT& rect, CWnd* pParentWnd, UINT nID) -{ - return CWnd::Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, rect, pParentWnd, nID); -} - -void CCalendarBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectClient; - GetClientRect(rectClient); - - dc.FillRect(rectClient, &afxGlobalData.brWindow); - - if (rectClient.bottom - m_nMyCalendarsY > 0) - { - CRect rectMyCalendarsCaption = rectClient; - rectMyCalendarsCaption.top = m_nMyCalendarsY; - rectMyCalendarsCaption.bottom = rectMyCalendarsCaption.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2; - - COLORREF clrText = CMFCVisualManager::GetInstance()->OnDrawPaneCaption(&dc, NULL, FALSE, rectMyCalendarsCaption, CRect(0, 0, 0, 0)); - - CPen* pOldPen = dc.SelectObject(&afxGlobalData.penBarShadow); - - dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.top); - dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.top); - - dc.SelectStockObject(BLACK_PEN); - - dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.bottom); - dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.bottom); - - dc.SelectObject(pOldPen); - - CRect rectText = rectMyCalendarsCaption; - rectText.DeflateRect(10, 0); - - dc.SetBkMode(TRANSPARENT); - dc.SetTextColor(clrText); - - CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); - - BOOL bNameValid; - CString str; - - bNameValid = str.LoadString(IDS_MYCALENDARS); - ASSERT(bNameValid); - dc.DrawText(str, rectText, DT_VCENTER | DT_LEFT | DT_SINGLELINE); - - CRect rectCalendar = rectClient; - rectCalendar.top = rectMyCalendarsCaption.bottom + 5; - rectCalendar.bottom = rectCalendar.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2 - 5; - - dc.FillSolidRect(rectCalendar, RGB(255, 255, 213)); - - rectCalendar.DeflateRect(20, 0); - m_Images.Draw(&dc, 3, rectCalendar.TopLeft(), 0); - - rectCalendar.left += 20; - - bNameValid = str.LoadString(IDS_CALENDAR); - ASSERT(bNameValid); - - dc.SetTextColor(afxGlobalData.clrHotLinkNormalText); - dc.DrawText(str, rectCalendar, DT_VCENTER | DT_LEFT | DT_SINGLELINE); - - dc.SelectObject(pOldFont); - } -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/CalendarBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/CalendarBar.h deleted file mode 100644 index ab2719c2fe730..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/CalendarBar.h +++ /dev/null @@ -1,34 +0,0 @@ - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CCalendarBar window - -class CCalendarBar : public CWnd -{ -// Construction -public: - CCalendarBar(); - -// Attributes -protected: - CMonthCalCtrl m_wndCalendar; - int m_nMyCalendarsY; - CImageList m_Images; - -// Overrides -public: - virtual BOOL Create(const RECT& rect, CWnd* pParentWnd, UINT nID = (UINT)-1); - -// Implementation -public: - virtual ~CCalendarBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnPaint(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ChildFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ChildFrm.cpp deleted file mode 100644 index 26d39f14e4487..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ChildFrm.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// ChildFrm.cpp : implementation of the CChildFrame class -// - -#include "stdafx.h" -#include "Misc.h" - -#include "ChildFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CChildFrame - -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) -END_MESSAGE_MAP() - -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here -} - -CChildFrame::~CChildFrame() -{ -} - - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs - if( !CMDIChildWndEx::PreCreateWindow(cs) ) - return FALSE; - - return TRUE; -} - -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWndEx::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWndEx::Dump(dc); -} -#endif //_DEBUG - -// CChildFrame message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ChildFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ChildFrm.h deleted file mode 100644 index 4093e72f0c848..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ChildFrm.h +++ /dev/null @@ -1,33 +0,0 @@ - -// ChildFrm.h : interface of the CChildFrame class -// - -#pragma once - -class CChildFrame : public CMDIChildWndEx -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ClassView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ClassView.cpp deleted file mode 100644 index c383ad79bf251..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ClassView.cpp +++ /dev/null @@ -1,322 +0,0 @@ - -#include "stdafx.h" -#include "MainFrm.h" -#include "ClassView.h" -#include "Resource.h" -#include "Misc.h" - -class CClassViewMenuButton : public CMFCToolBarMenuButton -{ - friend class CClassView; - - DECLARE_SERIAL(CClassViewMenuButton) - -public: - CClassViewMenuButton(HMENU hMenu = NULL) : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) - { - } - - virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, - BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) - { - pImages = CMFCToolBar::GetImages(); - - CAfxDrawState ds; - pImages->PrepareDrawImage(ds); - - CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); - - pImages->EndDrawImage(ds); - } -}; - -IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CClassView::CClassView() -{ - m_nCurrSort = ID_SORTING_GROUPBYTYPE; -} - -CClassView::~CClassView() -{ -} - -BEGIN_MESSAGE_MAP(CClassView, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_CLASS_ADD_MEMBER_FUNCTION, OnClassAddMemberFunction) - ON_COMMAND(ID_CLASS_ADD_MEMBER_VARIABLE, OnClassAddMemberVariable) - ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) - ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) - ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) - ON_WM_PAINT() - ON_WM_SETFOCUS() - ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) - ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CClassView message handlers - -int CClassView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create views: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - - if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) - { - TRACE0("Failed to create Class View\n"); - return -1; // fail to create - } - - // Load images: - m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); - m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* Is locked */); - - OnChangeVisualStyle(); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - m_wndToolBar.SetOwner(this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame(FALSE); - - CMenu menuSort; - menuSort.LoadMenu(IDR_POPUP_SORT); - - m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); - - CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); - - if (pButton != NULL) - { - pButton->m_bText = FALSE; - pButton->m_bImage = TRUE; - pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); - pButton->SetMessageWnd(this); - } - - // Fill in some static tree view data (dummy code, nothing magic here) - FillClassView(); - - return 0; -} - -void CClassView::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout(); -} - -void CClassView::FillClassView() -{ - HTREEITEM hRoot = m_wndClassView.InsertItem(_T("FakeApp classes"), 0, 0); - m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); - - HTREEITEM hClass = m_wndClassView.InsertItem(_T("CFakeAboutDlg"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass); - - m_wndClassView.Expand(hRoot, TVE_EXPAND); - - hClass = m_wndClassView.InsertItem(_T("CFakeApp"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("CFakeApp()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); - - hClass = m_wndClassView.InsertItem(_T("CFakeAppDoc"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass); - m_wndClassView.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); - - hClass = m_wndClassView.InsertItem(_T("CFakeAppView"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("CFakeAppView()"), 4, 4, hClass); - m_wndClassView.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); - m_wndClassView.Expand(hClass, TVE_EXPAND); - - hClass = m_wndClassView.InsertItem(_T("CFakeAppFrame"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); - m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); - m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); - - hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); - m_wndClassView.InsertItem(_T("theFakeApp"), 5, 5, hClass); - m_wndClassView.Expand(hClass, TVE_EXPAND); -} - -void CClassView::OnContextMenu(CWnd* pWnd, CPoint point) -{ - CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; - ASSERT_VALID(pWndTree); - - if (pWnd != pWndTree) - { - CDockablePane::OnContextMenu(pWnd, point); - return; - } - - if (point != CPoint(-1, -1)) - { - // Select clicked item: - CPoint ptTree = point; - pWndTree->ScreenToClient(&ptTree); - - UINT flags = 0; - HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); - if (hTreeItem != NULL) - { - pWndTree->SelectItem(hTreeItem); - } - } - - pWndTree->SetFocus(); - CMenu menu; - menu.LoadMenu(IDR_POPUP_SORT); - - CMenu* pSumMenu = menu.GetSubMenu(0); - - if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - - if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) - return; - - ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); - UpdateDialogControls(this, FALSE); - } -} - -void CClassView::AdjustLayout() -{ - if (GetSafeHwnd() == NULL) - { - return; - } - - CRect rectClient; - GetClientRect(rectClient); - - int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; - - m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndClassView.SetWindowPos(NULL, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); -} - -BOOL CClassView::PreTranslateMessage(MSG* pMsg) -{ - return CDockablePane::PreTranslateMessage(pMsg); -} - -void CClassView::OnSort(UINT id) -{ - if (m_nCurrSort == id) - { - return; - } - - m_nCurrSort = id; - - CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); - - if (pButton != NULL) - { - pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); - m_wndToolBar.Invalidate(); - m_wndToolBar.UpdateWindow(); - } -} - -void CClassView::OnUpdateSort(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); -} - -void CClassView::OnClassAddMemberFunction() -{ - AfxMessageBox(_T("Add member function...")); -} - -void CClassView::OnClassAddMemberVariable() -{ - // TODO: Add your command handler code here -} - -void CClassView::OnClassDefinition() -{ - // TODO: Add your command handler code here -} - -void CClassView::OnClassProperties() -{ - // TODO: Add your command handler code here -} - -void CClassView::OnNewFolder() -{ - AfxMessageBox(_T("New Folder...")); -} - -void CClassView::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndClassView.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void CClassView::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - - m_wndClassView.SetFocus(); -} - -void CClassView::OnChangeVisualStyle() -{ - m_ClassViewImages.DeleteImageList(); - - UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; - - CBitmap bmp; - if (!bmp.LoadBitmap(uiBmpId)) - { - TRACE(_T("Can't load bitmap: %x\n"), uiBmpId); - ASSERT(FALSE); - return; - } - - BITMAP bmpObj; - bmp.GetBitmap(&bmpObj); - - UINT nFlags = ILC_MASK; - - nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; - - m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); - m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); - - m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); - - m_wndToolBar.CleanUpLockedImages(); - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT_24 : IDR_SORT, 0, 0, TRUE /* Locked */); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ClassView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ClassView.h deleted file mode 100644 index 76cab59dcca9c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ClassView.h +++ /dev/null @@ -1,54 +0,0 @@ - -#pragma once - -#include "ViewTree.h" - -class CClassToolBar : public CMFCToolBar -{ - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList() const { return FALSE; } -}; - -class CClassView : public CDockablePane -{ -public: - CClassView(); - virtual ~CClassView(); - - void AdjustLayout(); - void OnChangeVisualStyle(); - -protected: - CClassToolBar m_wndToolBar; - CViewTree m_wndClassView; - CImageList m_ClassViewImages; - UINT m_nCurrSort; - - void FillClassView(); - -// Overrides -public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnClassAddMemberFunction(); - afx_msg void OnClassAddMemberVariable(); - afx_msg void OnClassDefinition(); - afx_msg void OnClassProperties(); - afx_msg void OnNewFolder(); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); - afx_msg void OnSort(UINT id); - afx_msg void OnUpdateSort(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/FileView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/FileView.cpp deleted file mode 100644 index cae85f8c00476..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/FileView.cpp +++ /dev/null @@ -1,256 +0,0 @@ - -#include "stdafx.h" -#include "mainfrm.h" -#include "FileView.h" -#include "Resource.h" -#include "Misc.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CFileView - -CFileView::CFileView() -{ -} - -CFileView::~CFileView() -{ -} - -BEGIN_MESSAGE_MAP(CFileView, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_PROPERTIES, OnProperties) - ON_COMMAND(ID_OPEN, OnFileOpen) - ON_COMMAND(ID_OPEN_WITH, OnFileOpenWith) - ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) - ON_COMMAND(ID_EDIT_CUT, OnEditCut) - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) - ON_WM_PAINT() - ON_WM_SETFOCUS() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar message handlers - -int CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create view: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; - - if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) - { - TRACE0("Failed to create file view\n"); - return -1; // fail to create - } - - // Load view images: - m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); - m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); - - m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_EXPLORER); - m_wndToolBar.LoadToolBar(IDR_EXPLORER, 0, 0, TRUE /* Is locked */); - - OnChangeVisualStyle(); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - m_wndToolBar.SetOwner(this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame(FALSE); - - // Fill in some static tree view data (dummy code, nothing magic here) - FillFileView(); - AdjustLayout(); - - return 0; -} - -void CFileView::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout(); -} - -void CFileView::FillFileView() -{ - HTREEITEM hRoot = m_wndFileView.InsertItem(_T("FakeApp files"), 0, 0); - m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); - - HTREEITEM hSrc = m_wndFileView.InsertItem(_T("FakeApp Source Files"), 0, 0, hRoot); - - m_wndFileView.InsertItem(_T("FakeApp.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("FakeApp.rc"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("FakeAppDoc.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("FakeAppView.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("StdAfx.cpp"), 1, 1, hSrc); - - HTREEITEM hInc = m_wndFileView.InsertItem(_T("FakeApp Header Files"), 0, 0, hRoot); - - m_wndFileView.InsertItem(_T("FakeApp.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("FakeAppDoc.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("FakeAppView.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("Resource.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("StdAfx.h"), 2, 2, hInc); - - HTREEITEM hRes = m_wndFileView.InsertItem(_T("FakeApp Resource Files"), 0, 0, hRoot); - - m_wndFileView.InsertItem(_T("FakeApp.ico"), 2, 2, hRes); - m_wndFileView.InsertItem(_T("FakeApp.rc2"), 2, 2, hRes); - m_wndFileView.InsertItem(_T("FakeAppDoc.ico"), 2, 2, hRes); - m_wndFileView.InsertItem(_T("FakeToolbar.bmp"), 2, 2, hRes); - - m_wndFileView.Expand(hRoot, TVE_EXPAND); - m_wndFileView.Expand(hSrc, TVE_EXPAND); - m_wndFileView.Expand(hInc, TVE_EXPAND); -} - -void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) -{ - CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; - ASSERT_VALID(pWndTree); - - if (pWnd != pWndTree) - { - CDockablePane::OnContextMenu(pWnd, point); - return; - } - - if (point != CPoint(-1, -1)) - { - // Select clicked item: - CPoint ptTree = point; - pWndTree->ScreenToClient(&ptTree); - - UINT flags = 0; - HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); - if (hTreeItem != NULL) - { - pWndTree->SelectItem(hTreeItem); - } - } - - pWndTree->SetFocus(); - theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); -} - -void CFileView::AdjustLayout() -{ - if (GetSafeHwnd() == NULL) - { - return; - } - - CRect rectClient; - GetClientRect(rectClient); - - int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; - - m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndFileView.SetWindowPos(NULL, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CFileView::OnProperties() -{ - AfxMessageBox(_T("Properties....")); - -} - -void CFileView::OnFileOpen() -{ - // TODO: Add your command handler code here -} - -void CFileView::OnFileOpenWith() -{ - // TODO: Add your command handler code here -} - -void CFileView::OnDummyCompile() -{ - // TODO: Add your command handler code here -} - -void CFileView::OnEditCut() -{ - // TODO: Add your command handler code here -} - -void CFileView::OnEditCopy() -{ - // TODO: Add your command handler code here -} - -void CFileView::OnEditClear() -{ - // TODO: Add your command handler code here -} - -void CFileView::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndFileView.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void CFileView::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - - m_wndFileView.SetFocus(); -} - -void CFileView::OnChangeVisualStyle() -{ - m_wndToolBar.CleanUpLockedImages(); - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EXPLORER_24 : IDR_EXPLORER, 0, 0, TRUE /* Locked */); - - m_FileViewImages.DeleteImageList(); - - UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW_24 : IDB_FILE_VIEW; - - CBitmap bmp; - if (!bmp.LoadBitmap(uiBmpId)) - { - TRACE(_T("Can't load bitmap: %x\n"), uiBmpId); - ASSERT(FALSE); - return; - } - - BITMAP bmpObj; - bmp.GetBitmap(&bmpObj); - - UINT nFlags = ILC_MASK; - - nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; - - m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); - m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); - - m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/FileView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/FileView.h deleted file mode 100644 index c728d6d488af9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/FileView.h +++ /dev/null @@ -1,55 +0,0 @@ - -#pragma once - -#include "ViewTree.h" - -class CFileViewToolBar : public CMFCToolBar -{ - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList() const { return FALSE; } -}; - -class CFileView : public CDockablePane -{ -// Construction -public: - CFileView(); - - void AdjustLayout(); - void OnChangeVisualStyle(); - -// Attributes -protected: - - CViewTree m_wndFileView; - CImageList m_FileViewImages; - CFileViewToolBar m_wndToolBar; - -protected: - void FillFileView(); - -// Implementation -public: - virtual ~CFileView(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnProperties(); - afx_msg void OnFileOpen(); - afx_msg void OnFileOpenWith(); - afx_msg void OnDummyCompile(); - afx_msg void OnEditCut(); - afx_msg void OnEditCopy(); - afx_msg void OnEditClear(); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MainFrm.cpp deleted file mode 100644 index 06717fda24549..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MainFrm.cpp +++ /dev/null @@ -1,531 +0,0 @@ - -// MainFrm.cpp : implementation of the CMainFrame class -// - -#include "stdafx.h" -#include "Misc.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) - -const int iMaxUserToolbars = 10; -const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; -const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) - ON_WM_CREATE() - ON_COMMAND(ID_WINDOW_MANAGER, &CMainFrame::OnWindowManager) - ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_OFF_2007_AQUA, &CMainFrame::OnApplicationLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_OFF_2007_AQUA, &CMainFrame::OnUpdateApplicationLook) - ON_COMMAND(ID_VIEW_CAPTION_BAR, &CMainFrame::OnViewCaptionBar) - ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTION_BAR, &CMainFrame::OnUpdateViewCaptionBar) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2005); -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - BOOL bNameValid; - // set the visual manager and style based on persisted value - OnApplicationLook(theApp.m_nAppLook); - - CMDITabInfo mdiTabParams; - mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; // other styles available... - mdiTabParams.m_bActiveTabCloseButton = TRUE; // set to FALSE to place close button at right of tab area - mdiTabParams.m_bTabIcons = FALSE; // set to TRUE to enable document icons on MDI tabs - mdiTabParams.m_bAutoColor = TRUE; // set to FALSE to disable auto-coloring of MDI tabs - mdiTabParams.m_bDocumentMenu = TRUE; // enable the document menu at the right edge of the tab area - EnableMDITabbedGroups(TRUE, mdiTabParams); - - if (!m_wndMenuBar.Create(this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); - - // prevent the menu bar from taking the focus on activation - CMFCPopupMenu::SetForceMenuFocus(FALSE); - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - CString strToolBarName; - bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); - ASSERT(bNameValid); - m_wndToolBar.SetWindowText(strToolBarName); - - CString strCustomize; - bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); - ASSERT(bNameValid); - m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); - - // Allow user-defined toolbars operations: - InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); - - if (!m_wndStatusBar.Create(this)) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); - - // TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - - // enable Visual Studio 2005 style docking window behavior - CDockingManager::SetDockingMode(DT_SMART); - // enable Visual Studio 2005 style docking window auto-hide behavior - EnableAutoHidePanes(CBRS_ALIGN_ANY); - - // Navigation pane will be created at left, so temporary disable docking at the left side: - EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT); - - // Create and setup "Outlook" navigation bar: - if (!CreateOutlookBar(m_wndNavigationBar, ID_VIEW_NAVIGATION, m_wndTree, m_wndCalendar, 250)) - { - TRACE0("Failed to create navigation pane\n"); - return -1; // fail to create - } - - // Create a caption bar: - if (!CreateCaptionBar()) - { - TRACE0("Failed to create caption bar\n"); - return -1; // fail to create - } - - // Outlook bar is created and docking on the left side should be allowed. - EnableDocking(CBRS_ALIGN_LEFT); - EnableAutoHidePanes(CBRS_ALIGN_RIGHT); - - // Load menu item image (not placed on any standard toolbars): - CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); - - // create docking windows - if (!CreateDockingWindows()) - { - TRACE0("Failed to create docking windows\n"); - return -1; - } - - m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); - m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndFileView); - CDockablePane* pTabbedBar = NULL; - m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); - m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndOutput); - m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndProperties); - - - // Enable enhanced windows management dialog - EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); - - // Enable toolbar and docking window menu replacement - EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); - - // enable quick (Alt+drag) toolbar customization - CMFCToolBar::EnableQuickCustomization(); - - if (CMFCToolBar::GetUserImages() == NULL) - { - // load user-defined toolbar images - if (m_UserImages.Load(_T(".\\UserImages.bmp"))) - { - m_UserImages.SetImageSize(CSize(16, 16), FALSE); - CMFCToolBar::SetUserImages(&m_UserImages); - } - } - - // enable menu personalization (most-recently used commands) - // TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command. - CList lstBasicCommands; - - lstBasicCommands.AddTail(ID_FILE_NEW); - lstBasicCommands.AddTail(ID_FILE_OPEN); - lstBasicCommands.AddTail(ID_FILE_SAVE); - lstBasicCommands.AddTail(ID_FILE_PRINT); - lstBasicCommands.AddTail(ID_APP_EXIT); - lstBasicCommands.AddTail(ID_EDIT_CUT); - lstBasicCommands.AddTail(ID_EDIT_PASTE); - lstBasicCommands.AddTail(ID_EDIT_UNDO); - lstBasicCommands.AddTail(ID_APP_ABOUT); - lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); - lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); - lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); - lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); - lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); - lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); - lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); - lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); - lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); - lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); - lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); - - CMFCToolBar::SetBasicCommands(lstBasicCommands); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWndEx::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -BOOL CMainFrame::CreateDockingWindows() -{ - BOOL bNameValid; - - // Create class view - CString strClassView; - bNameValid = strClassView.LoadString(IDS_CLASS_VIEW); - ASSERT(bNameValid); - if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Class View window\n"); - return FALSE; // failed to create - } - - // Create file view - CString strFileView; - bNameValid = strFileView.LoadString(IDS_FILE_VIEW); - ASSERT(bNameValid); - if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create File View window\n"); - return FALSE; // failed to create - } - - // Create output window - CString strOutputWnd; - bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND); - ASSERT(bNameValid); - if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Output window\n"); - return FALSE; // failed to create - } - - // Create properties window - CString strPropertiesWnd; - bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); - ASSERT(bNameValid); - if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Properties window\n"); - return FALSE; // failed to create - } - - SetDockingWindowIcons(theApp.m_bHiColorIcons); - return TRUE; -} - -void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons) -{ - HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndFileView.SetIcon(hFileViewIcon, FALSE); - - HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndClassView.SetIcon(hClassViewIcon, FALSE); - - HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndOutput.SetIcon(hOutputBarIcon, FALSE); - - HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE); - - UpdateMDITabbedBarsIcons(); -} - -BOOL CMainFrame::CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth) -{ - CWindowDC dc(NULL); - - bar.SetMode2003(); - - BOOL bNameValid; - CString strTemp; - bNameValid = strTemp.LoadString(IDS_SHORTCUTS); - ASSERT(bNameValid); - if (!bar.Create(strTemp, this, CRect(0, 0, nInitialWidth, 32000), uiID, WS_CHILD | WS_VISIBLE | CBRS_LEFT)) - { - return FALSE; // fail to create - } - - CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)bar.GetUnderlyingWindow(); - - if (pOutlookBar == NULL) - { - ASSERT(FALSE); - return FALSE; - } - - pOutlookBar->EnableInPlaceEdit(TRUE); - - static UINT uiPageID = 1; - - DWORD dwPaneStyle = AFX_DEFAULT_TOOLBAR_STYLE | CBRS_FLOAT_MULTI; - - // can float, can autohide, can resize, CAN NOT CLOSE - DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE; - - CRect rectDummy(0, 0, 0, 0); - const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; - - tree.Create(dwTreeStyle, rectDummy, &bar, 1200); - bNameValid = strTemp.LoadString(IDS_FOLDERS); - ASSERT(bNameValid); - pOutlookBar->AddControl(&tree, strTemp, 2, TRUE, dwStyle); - - calendar.Create(rectDummy, &bar, 1201); - bNameValid = strTemp.LoadString(IDS_CALENDAR); - ASSERT(bNameValid); - pOutlookBar->AddControl(&calendar, strTemp, 3, TRUE, dwStyle); - - bar.SetPaneStyle(bar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); - - pOutlookBar->SetImageList(theApp.m_bHiColorIcons ? IDB_PAGES_HC : IDB_PAGES, 24); - pOutlookBar->SetToolbarImageList(theApp.m_bHiColorIcons ? IDB_PAGES_SMALL_HC : IDB_PAGES_SMALL, 16); - pOutlookBar->RecalcLayout(); - - BOOL bAnimation = theApp.GetInt(_T("OutlookAnimation"), TRUE); - CMFCOutlookBarTabCtrl::EnableAnimation(bAnimation); - - bar.SetButtonsFont(&afxGlobalData.fontBold); - - return TRUE; -} - -BOOL CMainFrame::CreateCaptionBar() -{ - if (!m_wndCaptionBar.Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this, ID_VIEW_CAPTION_BAR, -1, TRUE)) - { - TRACE0("Failed to create caption bar\n"); - return FALSE; - } - - BOOL bNameValid; - - CString strTemp, strTemp2; - bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON); - ASSERT(bNameValid); - m_wndCaptionBar.SetButton(strTemp, ID_TOOLS_OPTIONS, CMFCCaptionBar::ALIGN_LEFT, FALSE); - bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON_TIP); - ASSERT(bNameValid); - m_wndCaptionBar.SetButtonToolTip(strTemp); - - bNameValid = strTemp.LoadString(IDS_CAPTION_TEXT); - ASSERT(bNameValid); - m_wndCaptionBar.SetText(strTemp, CMFCCaptionBar::ALIGN_LEFT); - - m_wndCaptionBar.SetBitmap(IDB_INFO, RGB(255, 255, 255), FALSE, CMFCCaptionBar::ALIGN_LEFT); - bNameValid = strTemp.LoadString(IDS_CAPTION_IMAGE_TIP); - ASSERT(bNameValid); - bNameValid = strTemp2.LoadString(IDS_CAPTION_IMAGE_TEXT); - ASSERT(bNameValid); - m_wndCaptionBar.SetImageToolTip(strTemp, strTemp2); - - return TRUE; -} - -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWndEx::Dump(dc); -} -#endif //_DEBUG - - -// CMainFrame message handlers - -void CMainFrame::OnWindowManager() -{ - ShowWindowsDialog(); -} - -void CMainFrame::OnViewCustomize() -{ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* scan menus */); - pDlgCust->EnableUserDefinedToolbars(); - pDlgCust->Create(); -} - -LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) -{ - LRESULT lres = CMDIFrameWndEx::OnToolbarCreateNew(wp,lp); - if (lres == 0) - { - return 0; - } - - CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres; - ASSERT_VALID(pUserToolbar); - - BOOL bNameValid; - CString strCustomize; - bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); - ASSERT(bNameValid); - - pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); - return lres; -} - -void CMainFrame::OnApplicationLook(UINT id) -{ - CWaitCursor wait; - - theApp.m_nAppLook = id; - - switch (theApp.m_nAppLook) - { - case ID_VIEW_APPLOOK_WIN_2000: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_OFF_XP: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_OFF_2003: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - CDockingManager::SetDockingMode(DT_SMART); - break; - - case ID_VIEW_APPLOOK_VS_2005: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); - CDockingManager::SetDockingMode(DT_SMART); - break; - - default: - switch (theApp.m_nAppLook) - { - case ID_VIEW_APPLOOK_OFF_2007_BLUE: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case ID_VIEW_APPLOOK_OFF_2007_BLACK: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case ID_VIEW_APPLOOK_OFF_2007_SILVER: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); - break; - - case ID_VIEW_APPLOOK_OFF_2007_AQUA: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - } - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode(DT_SMART); - } - - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); - - theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); -} - -void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); -} - -void CMainFrame::OnViewCaptionBar() -{ - m_wndCaptionBar.ShowWindow(m_wndCaptionBar.IsVisible() ? SW_HIDE : SW_SHOW); - RecalcLayout(FALSE); -} - -void CMainFrame::OnUpdateViewCaptionBar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndCaptionBar.IsVisible()); -} - -BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) -{ - // base class does the real work - - if (!CMDIFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) - { - return FALSE; - } - - - // enable customization button for all user toolbars - BOOL bNameValid; - CString strCustomize; - bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); - ASSERT(bNameValid); - - for (int i = 0; i < iMaxUserToolbars; i ++) - { - CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); - if (pUserToolbar != NULL) - { - pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); - } - } - - return TRUE; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MainFrm.h deleted file mode 100644 index 76def5089d9f5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MainFrm.h +++ /dev/null @@ -1,82 +0,0 @@ - -// MainFrm.h : interface of the CMainFrame class -// - -#pragma once -#include "FileView.h" -#include "ClassView.h" -#include "OutputWnd.h" -#include "PropertiesWnd.h" -#include "CalendarBar.h" -#include "Resource.h" - -class COutlookBar : public CMFCOutlookBar -{ - virtual BOOL AllowShowOnPaneMenu() const { return TRUE; } - virtual void GetPaneName(CString& strName) const { BOOL bNameValid = strName.LoadString(IDS_OUTLOOKBAR); ASSERT(bNameValid); } -}; - -class CMainFrame : public CMDIFrameWndEx -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides -public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCToolBar m_wndToolBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBarImages m_UserImages; - CFileView m_wndFileView; - CClassView m_wndClassView; - COutputWnd m_wndOutput; - CPropertiesWnd m_wndProperties; - COutlookBar m_wndNavigationBar; - CMFCShellTreeCtrl m_wndTree; - CCalendarBar m_wndCalendar; - CMFCCaptionBar m_wndCaptionBar; - -// Generated message map functions -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnWindowManager(); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp); - afx_msg void OnApplicationLook(UINT id); - afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); - afx_msg void OnViewCaptionBar(); - afx_msg void OnUpdateViewCaptionBar(CCmdUI* pCmdUI); - DECLARE_MESSAGE_MAP() - - BOOL CreateDockingWindows(); - void SetDockingWindowIcons(BOOL bHiColorIcons); - BOOL CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth); - BOOL CreateCaptionBar(); - - int FindFocusedOutlookWnd(CMFCOutlookBarTabCtrl** ppOutlookWnd); - - CMFCOutlookBarTabCtrl* FindOutlookParent(CWnd* pWnd); - CMFCOutlookBarTabCtrl* m_pCurrOutlookWnd; - CMFCOutlookBarPane* m_pCurrOutlookPage; -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.cpp deleted file mode 100644 index 0646e0f395b29..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.cpp +++ /dev/null @@ -1,200 +0,0 @@ - -// Misc.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "afxwinappex.h" -#include "Misc.h" -#include "MainFrm.h" - -#include "ChildFrm.h" -#include "MiscDoc.h" -#include "MiscView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMiscApp - -BEGIN_MESSAGE_MAP(CMiscApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, &CMiscApp::OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) -END_MESSAGE_MAP() - - -// CMiscApp construction - -CMiscApp::CMiscApp() -{ - - m_bHiColorIcons = TRUE; - - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -// The one and only CMiscApp object - -CMiscApp theApp; - - -// CMiscApp initialization - -BOOL CMiscApp::InitInstance() -{ - // InitCommonControlsEx() is required on Windows XP if an application - // manifest specifies use of ComCtl32.dll version 6 or later to enable - // visual styles. Otherwise, any window creation will fail. - INITCOMMONCONTROLSEX InitCtrls; - InitCtrls.dwSize = sizeof(InitCtrls); - // Set this to include all the common control classes you want to use - // in your application. - InitCtrls.dwICC = ICC_WIN95_CLASSES; - InitCommonControlsEx(&InitCtrls); - - CWinAppEx::InitInstance(); - - if (!AfxSocketInit()) - { - AfxMessageBox(IDP_SOCKETS_INIT_FAILED); - return FALSE; - } - - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - AfxEnableControlContainer(); - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Local AppWizard-Generated Applications")); - LoadStdProfileSettings(4); // Load standard INI file options (including MRU) - - InitContextMenuManager(); - InitShellManager(); - - InitKeyboardManager(); - - InitTooltipManager(); - CMFCToolTipInfo ttParams; - ttParams.m_bVislManagerTheme = TRUE; - theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate(IDR_MiscTYPE, - RUNTIME_CLASS(CMiscDoc), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CMiscView)); - if (!pDocTemplate) - return FALSE; - AddDocTemplate(pDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) - { - delete pMainFrame; - return FALSE; - } - m_pMainWnd = pMainFrame; - // call DragAcceptFiles only if there's a suffix - // In an MDI app, this should occur immediately after setting m_pMainWnd - - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - - // Dispatch commands specified on the command line. Will return FALSE if - // app was launched with /RegServer, /Register, /Unregserver or /Unregister. - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - // The main window has been initialized, so show and update it - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - - return TRUE; -} - - - -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - enum { IDD = IDD_ABOUTBOX }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - -// App command to run the dialog -void CMiscApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -// CMiscApp customization load/save methods - -void CMiscApp::PreLoadState() -{ - BOOL bNameValid; - CString strName; - bNameValid = strName.LoadString(IDS_EDIT_MENU); - ASSERT(bNameValid); - GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); - bNameValid = strName.LoadString(IDS_EXPLORER); - ASSERT(bNameValid); - GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER); -} - -void CMiscApp::LoadCustomState() -{ -} - -void CMiscApp::SaveCustomState() -{ -} - -// CMiscApp message handlers - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.h deleted file mode 100644 index 5e40e0462b499..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.h +++ /dev/null @@ -1,56 +0,0 @@ - -// Misc.h : main header file for the Misc application -// -#pragma once - -#ifndef __AFXWIN_H__ - #error "include 'stdafx.h' before including this file for PCH" -#endif - -#include "resource.h" // main symbols - - -// CMiscApp: -// See Misc.cpp for the implementation of this class -// - -class CMiscApp : public CWinAppEx -{ -public: - CMiscApp(); - - -// Overrides -public: - virtual BOOL InitInstance(); - -// Implementation - UINT m_nAppLook; - BOOL m_bHiColorIcons; - - virtual void PreLoadState(); - virtual void LoadCustomState(); - virtual void SaveCustomState(); - - afx_msg void OnAppAbout(); - DECLARE_MESSAGE_MAP() -}; - -extern CMiscApp theApp; - - -class CMyApp -{ - // - void CMyApp::ProcessCommand() - { - // Temporarily disable menu animation. - CMFCDisableMenuAnimation disableMenuAnimation; - - // TODO: Process the command here. - - // When the CMFCDisableMenuAnimation object leaves scope, - // the destructor will restore the previous animation type. - } - // -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.rc deleted file mode 100644 index 22df335534601..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Misc.rc +++ /dev/null @@ -1,598 +0,0 @@ -//Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#ifndef APSTUDIO_INVOKED -#include "targetver.h" -#endif -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -#ifdef APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#ifndef APSTUDIO_INVOKED\r\n" - "#include ""targetver.h""\r\n" - "#endif\r\n" - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#include ""res\\Misc.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // MFC ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) -IDR_MAINFRAME ICON "res\\Misc.ico" -IDR_MiscTYPE ICON "res\\MiscDoc.ico" -#endif -IDI_FILE_VIEW ICON "res\\file_view.ico" -IDI_FILE_VIEW_HC ICON "res\\file_view_hc.ico" -IDI_CLASS_VIEW ICON "res\\class_view.ico" -IDI_CLASS_VIEW_HC ICON "res\\class_view_hc.ico" -IDI_OUTPUT_WND ICON "res\\output_wnd.ico" -IDI_OUTPUT_WND_HC ICON "res\\output_wnd_hc.ico" -IDI_PROPERTIES_WND ICON "res\\properties_wnd.ico" -IDI_PROPERTIES_WND_HC ICON "res\\properties_wnd_hc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDR_MAINFRAME_256 BITMAP "res\\Toolbar256.bmp" -IDR_SORT BITMAP "res\\sort.bmp" -IDB_SORT_24 BITMAP "res\\sort_hc.bmp" -IDB_FILE_VIEW BITMAP "res\\fileview.bmp" -IDB_FILE_VIEW_24 BITMAP "res\\fileview_hc.bmp" -IDB_CLASS_VIEW BITMAP "res\\classview.bmp" -IDB_CLASS_VIEW_24 BITMAP "res\\classview_hc.bmp" -IDR_EXPLORER BITMAP "res\\explorer.bmp" -IDB_EXPLORER_24 BITMAP "res\\explorer_hc.bmp" -IDR_MENU_IMAGES BITMAP "res\\menuimages.bmp" -IDB_MENU_IMAGES_24 BITMAP "res\\menuimages_hc.bmp" -IDR_PROPERTIES BITMAP "res\\properties.bmp" -IDB_PROPERTIES_HC BITMAP "res\\properties_hc.bmp" -IDB_NAVIGATION_LARGE BITMAP "res\\nav_large.bmp" -IDB_NAVIGATION_LARGE_HC BITMAP "res\\nav_large_hc.bmp" -IDB_PAGES BITMAP "res\\pages.bmp" -IDB_PAGES_HC BITMAP "res\\pages_hc.bmp" -IDB_PAGES_SMALL BITMAP "res\\pages_small.bmp" -IDB_PAGES_SMALL_HC BITMAP "res\\pages_small_hc.bmp" -IDB_INFO BITMAP "res\\info.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_APP_ABOUT -END - -IDR_MAINFRAME_256 TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_APP_ABOUT -END - - -IDR_SORT TOOLBAR 16, 16 -BEGIN - BUTTON ID_SORT_MENU - BUTTON ID_NEW_FOLDER -END - -IDR_EXPLORER TOOLBAR 16, 16 -BEGIN - BUTTON ID_PROPERTIES -END - -IDR_MENU_IMAGES TOOLBAR 16, 16 -BEGIN - BUTTON ID_WINDOW_MANAGER - SEPARATOR - BUTTON ID_WINDOW_CASCADE - BUTTON ID_WINDOW_TILE_HORZ - BUTTON ID_TOOLS_MACRO - BUTTON ID_SORTING_SORTALPHABETIC - BUTTON ID_SORTING_SORTBYTYPE - BUTTON ID_SORTING_SORTBYACCESS - BUTTON ID_SORTING_GROUPBYTYPE -END - -IDR_PROPERTIES TOOLBAR 16, 16 -BEGIN - BUTTON ID_EXPAND_ALL - BUTTON ID_SORTPROPERTIES - BUTTON ID_PROPERTIES1 - BUTTON ID_PROPERTIES2 -END -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM SEPARATOR - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - POPUP "&Toolbars and Docking Windows" - BEGIN - MENUITEM "", ID_VIEW_TOOLBAR - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "&Caption Bar", ID_VIEW_CAPTION_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Windows &2000", ID_VIEW_APPLOOK_WIN_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_OFF_XP - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_OFF_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS_2005 - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_OFF_2007_AQUA - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About Misc...", ID_APP_ABOUT - END -END - -IDR_MiscTYPE MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars and Docking Windows" - BEGIN - MENUITEM "", ID_VIEW_TOOLBAR - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "&Caption Bar", ID_VIEW_CAPTION_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Windows &2000", ID_VIEW_APPLOOK_WIN_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_OFF_XP - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_OFF_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS_2005 - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_OFF_2007_AQUA - END - END - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - END - POPUP "&Help" - BEGIN - MENUITEM "&About Misc...", ID_APP_ABOUT - END -END - - - - -IDR_POPUP_EDIT MENU -BEGIN - POPUP "Edit" - BEGIN - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END -END - -IDR_POPUP_SORT MENU -BEGIN - POPUP "Sorting" - BEGIN - MENUITEM "&Sort Alphabetically", ID_SORTING_SORTALPHABETIC - MENUITEM "Sort by &Type", ID_SORTING_SORTBYTYPE - MENUITEM "Sort by Acc&ess", ID_SORTING_SORTBYACCESS - MENUITEM "Group by t&ype", ID_SORTING_GROUPBYTYPE - END -END - -IDR_POPUP_EXPLORER MENU -BEGIN - POPUP "Explorer" - BEGIN - MENUITEM "&Open", ID_OPEN - MENUITEM "Open &With....", ID_OPEN_WITH - MENUITEM SEPARATOR - MENUITEM "&Compile", ID_DUMMY_COMPILE - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Remove", ID_EDIT_CLEAR - MENUITEM SEPARATOR - MENUITEM "&Properties...", ID_PROPERTIES - END -END - -IDR_OUTPUT_POPUP MENU -BEGIN - POPUP "Popup" - BEGIN - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Clear", ID_EDIT_CLEAR - MENUITEM SEPARATOR - MENUITEM "&Hide", ID_VIEW_OUTPUTWND - END -END - -IDR_THEME_MENU MENU DISCARDABLE -BEGIN - MENUITEM "Office 2007 (&Blue Style)", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "Office 2007 (B&lack Style)", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "Office 2007 (&Silver Style)", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "Office 2007 (&Aqua Style)", ID_VIEW_APPLOOK_OFF_2007_AQUA -END - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY,CONTROL - "O", ID_FILE_OPEN, VIRTKEY,CONTROL - "S", ID_FILE_SAVE, VIRTKEY,CONTROL - "P", ID_FILE_PRINT, VIRTKEY,CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY,CONTROL - "X", ID_EDIT_CUT, VIRTKEY,CONTROL - "C", ID_EDIT_COPY, VIRTKEY,CONTROL - "V", ID_EDIT_PASTE, VIRTKEY,CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT -END - - - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About Misc" -FONT 8, "MS Shell Dlg" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20 - LTEXT "Misc, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX - LTEXT "Copyright (C) 2008",IDC_STATIC,42,26,114,8 - DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP -END - - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "TODO: " - VALUE "FileDescription", "TODO: " - VALUE "FileVersion", "1.0.0.1" - VALUE "InternalName", "Misc.exe" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved." - VALUE "OriginalFilename","Misc.exe" - VALUE "ProductName", "TODO: " - VALUE "ProductVersion", "1.0.0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 163 - TOPMARGIN, 7 - BOTTOMMARGIN, 55 - END -END -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDP_OLE_INIT_FAILED "OLE initialization failed. Make sure that the OLE libraries are the correct version." - IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed." -END -STRINGTABLE -BEGIN -// Non-mac-targeting apps remove the two extra substrings - IDR_MAINFRAME "Misc" - IDR_MiscTYPE "\nMisc\nMisc\n\n\nMisc.Document\nMisc.Document" -END -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "Misc" - AFX_IDS_IDLEMESSAGE "Ready" -END -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT_DIRECT "Print the active document using current options\nQuick Print" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle Status Bar" - ID_VIEW_CAPTION_BAR "Show or hide the caption bar\nToggle Caption Bar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - - -STRINGTABLE -BEGIN - IDS_STATUS_PANE1 "Pane 1" - IDS_STATUS_PANE2 "Pane 2" - IDS_TOOLBAR_STANDARD "Standard" - IDS_TOOLBAR_CUSTOMIZE "Customize..." - IDS_WINDOWS_MANAGER "&Windows..." - IDS_FILE_VIEW "File View" - IDS_CLASS_VIEW "Class View" - IDS_EXPLORER "Explorer" - IDS_OUTPUT_WND "Output" - IDS_BUILD_TAB "Build" - IDS_DEBUG_TAB "Debug" - IDS_FIND_TAB "Find" - IDS_PROPERTIES_WND "Properties" - IDS_MYCALENDARS "My Calendars" - IDS_CALENDAR "Calendar" - IDS_SHORTCUTS "Shortcuts" - IDS_FOLDERS "Folders" - IDS_OUTLOOKBAR "Outlook Bar" - IDS_RIBBON_CAPTIONBAR "Caption Bar" - IDS_CAPTION_BUTTON "Options..." - IDS_CAPTION_BUTTON_TIP "Click here to see more options" - IDS_CAPTION_TEXT "This is a caption bar where a message can be presented to the user." - IDS_CAPTION_IMAGE_TIP "Important" - IDS_CAPTION_IMAGE_TEXT "Here is an informational message for the user." - IDS_EDIT_MENU "Edit" -END -#endif - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) -#include "res\\Misc.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#if !defined(_AFXDLL) -#include "afxribbon.rc" // MFC ribbon and control bar resources -#endif -#endif -#endif // not APSTUDIO_INVOKED diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscDoc.cpp deleted file mode 100644 index df6f2121c62c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscDoc.cpp +++ /dev/null @@ -1,79 +0,0 @@ - -// MiscDoc.cpp : implementation of the CMiscDoc class -// - -#include "stdafx.h" -#include "Misc.h" - -#include "MiscDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMiscDoc - -IMPLEMENT_DYNCREATE(CMiscDoc, CDocument) - -BEGIN_MESSAGE_MAP(CMiscDoc, CDocument) -END_MESSAGE_MAP() - - -// CMiscDoc construction/destruction - -CMiscDoc::CMiscDoc() -{ - // TODO: add one-time construction code here - -} - -CMiscDoc::~CMiscDoc() -{ -} - -BOOL CMiscDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - - -// CMiscDoc serialization - -void CMiscDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - - -// CMiscDoc diagnostics - -#ifdef _DEBUG -void CMiscDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CMiscDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - - -// CMiscDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscDoc.h deleted file mode 100644 index 98ae486bc724f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscDoc.h +++ /dev/null @@ -1,41 +0,0 @@ - -// MiscDoc.h : interface of the CMiscDoc class -// - - -#pragma once - - -class CMiscDoc : public CDocument -{ -protected: // create from serialization only - CMiscDoc(); - DECLARE_DYNCREATE(CMiscDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides -public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CMiscDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscView.cpp deleted file mode 100644 index b1dc313b6f175..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscView.cpp +++ /dev/null @@ -1,117 +0,0 @@ - -// MiscView.cpp : implementation of the CMiscView class -// - -#include "stdafx.h" -#include "Misc.h" - -#include "MiscDoc.h" -#include "MiscView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMiscView - -IMPLEMENT_DYNCREATE(CMiscView, CView) - -BEGIN_MESSAGE_MAP(CMiscView, CView) - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMiscView::OnFilePrintPreview) -END_MESSAGE_MAP() - -// CMiscView construction/destruction - -CMiscView::CMiscView() -{ - // TODO: add construction code here - -} - -CMiscView::~CMiscView() -{ -} - -BOOL CMiscView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -// CMiscView drawing - -void CMiscView::OnDraw(CDC* /*pDC*/) -{ - CMiscDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - if (!pDoc) - return; - - // TODO: add draw code for native data here -} - - -// CMiscView printing - - -void CMiscView::OnFilePrintPreview() -{ - AFXPrintPreview(this); -} - -BOOL CMiscView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CMiscView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CMiscView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CMiscView::OnRButtonUp(UINT nFlags, CPoint point) -{ - ClientToScreen(&point); - OnContextMenu(this, point); -} - -void CMiscView::OnContextMenu(CWnd* pWnd, CPoint point) -{ - theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); -} - - -// CMiscView diagnostics - -#ifdef _DEBUG -void CMiscView::AssertValid() const -{ - CView::AssertValid(); -} - -void CMiscView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CMiscDoc* CMiscView::GetDocument() const // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMiscDoc))); - return (CMiscDoc*)m_pDocument; -} -#endif //_DEBUG - - -// CMiscView message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscView.h deleted file mode 100644 index cec31b703bbab..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/MiscView.h +++ /dev/null @@ -1,53 +0,0 @@ - -// MiscView.h : interface of the CMiscView class -// - - -#pragma once - - -class CMiscView : public CView -{ -protected: // create from serialization only - CMiscView(); - DECLARE_DYNCREATE(CMiscView) - -// Attributes -public: - CMiscDoc* GetDocument() const; - -// Operations -public: - -// Overrides -public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); -protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CMiscView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - afx_msg void OnFilePrintPreview(); - afx_msg void OnRButtonUp(UINT nFlags, CPoint point); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in MiscView.cpp -inline CMiscDoc* CMiscView::GetDocument() const - { return reinterpret_cast(m_pDocument); } -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/OutputWnd.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/OutputWnd.cpp deleted file mode 100644 index 6d1333da6cedf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/OutputWnd.cpp +++ /dev/null @@ -1,198 +0,0 @@ - -#include "stdafx.h" - -#include "OutputWnd.h" -#include "Resource.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutputBar - -COutputWnd::COutputWnd() -{ -} - -COutputWnd::~COutputWnd() -{ -} - -BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() -END_MESSAGE_MAP() - -int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - m_Font.CreateStockObject(DEFAULT_GUI_FONT); - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create tabs window: - if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) - { - TRACE0("Failed to create output tab window\n"); - return -1; // fail to create - } - - // Create output panes: - const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; - - if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) || - !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) || - !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4)) - { - TRACE0("Failed to create output windows\n"); - return -1; // fail to create - } - - m_wndOutputBuild.SetFont(&m_Font); - m_wndOutputDebug.SetFont(&m_Font); - m_wndOutputFind.SetFont(&m_Font); - - CString strTabName; - BOOL bNameValid; - - // Attach list windows to tab: - bNameValid = strTabName.LoadString(IDS_BUILD_TAB); - ASSERT(bNameValid); - m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0); - bNameValid = strTabName.LoadString(IDS_DEBUG_TAB); - ASSERT(bNameValid); - m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1); - bNameValid = strTabName.LoadString(IDS_FIND_TAB); - ASSERT(bNameValid); - m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2); - - // Fill output tabs with some dummy text (nothing magic here) - FillBuildWindow(); - FillDebugWindow(); - FillFindWindow(); - - return 0; -} - -void COutputWnd::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - // Tab control should cover the whole client area: - m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); -} - -void COutputWnd::AdjustHorzScroll(CListBox& wndListBox) -{ - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(&m_Font); - - int cxExtentMax = 0; - - for (int i = 0; i < wndListBox.GetCount(); i ++) - { - CString strItem; - wndListBox.GetText(i, strItem); - - cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx); - } - - wndListBox.SetHorizontalExtent(cxExtentMax); - dc.SelectObject(pOldFont); -} - -void COutputWnd::FillBuildWindow() -{ - m_wndOutputBuild.AddString(_T("Build output is being displayed here.")); - m_wndOutputBuild.AddString(_T("The output is being displayed in rows of a list view")); - m_wndOutputBuild.AddString(_T("but you can change the way it is displayed as you wish...")); -} - -void COutputWnd::FillDebugWindow() -{ - m_wndOutputDebug.AddString(_T("Debug output is being displayed here.")); - m_wndOutputDebug.AddString(_T("The output is being displayed in rows of a list view")); - m_wndOutputDebug.AddString(_T("but you can change the way it is displayed as you wish...")); -} - -void COutputWnd::FillFindWindow() -{ - m_wndOutputFind.AddString(_T("Find output is being displayed here.")); - m_wndOutputFind.AddString(_T("The output is being displayed in rows of a list view")); - m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish...")); -} - -///////////////////////////////////////////////////////////////////////////// -// COutputList1 - -COutputList::COutputList() -{ -} - -COutputList::~COutputList() -{ -} - -BEGIN_MESSAGE_MAP(COutputList, CListBox) - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) - ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput) - ON_WM_WINDOWPOSCHANGING() -END_MESSAGE_MAP() -///////////////////////////////////////////////////////////////////////////// -// COutputList message handlers - -void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - CMenu menu; - menu.LoadMenu(IDR_OUTPUT_POPUP); - - CMenu* pSumMenu = menu.GetSubMenu(0); - - if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - - if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) - return; - - ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); - UpdateDialogControls(this, FALSE); - } - - SetFocus(); -} - -void COutputList::OnEditCopy() -{ - MessageBox(_T("Copy output")); -} - -void COutputList::OnEditClear() -{ - MessageBox(_T("Clear output")); -} - -void COutputList::OnViewOutput() -{ - CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); - CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); - - if (pMainFrame != NULL && pParentBar != NULL) - { - pMainFrame->SetFocus(); - pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); - pMainFrame->RecalcLayout(); - - } -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/OutputWnd.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/OutputWnd.h deleted file mode 100644 index db1f6b9cb5fb2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/OutputWnd.h +++ /dev/null @@ -1,59 +0,0 @@ - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// COutputList window - -class COutputList : public CListBox -{ -// Construction -public: - COutputList(); - -// Implementation -public: - virtual ~COutputList(); - -protected: - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnEditCopy(); - afx_msg void OnEditClear(); - afx_msg void OnViewOutput(); - - DECLARE_MESSAGE_MAP() -}; - -class COutputWnd : public CDockablePane -{ -// Construction -public: - COutputWnd(); - -// Attributes -protected: - CFont m_Font; - - CMFCTabCtrl m_wndTabs; - - COutputList m_wndOutputBuild; - COutputList m_wndOutputDebug; - COutputList m_wndOutputFind; - -protected: - void FillBuildWindow(); - void FillDebugWindow(); - void FillFindWindow(); - - void AdjustHorzScroll(CListBox& wndListBox); - -// Implementation -public: - virtual ~COutputWnd(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/PropertiesWnd.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/PropertiesWnd.cpp deleted file mode 100644 index a7f556cf55d20..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/PropertiesWnd.cpp +++ /dev/null @@ -1,269 +0,0 @@ - -#include "stdafx.h" - -#include "PropertiesWnd.h" -#include "Resource.h" -#include "MainFrm.h" -#include "Misc.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CResourceViewBar - -CPropertiesWnd::CPropertiesWnd() -{ -} - -CPropertiesWnd::~CPropertiesWnd() -{ -} - -BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) - ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) - ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) - ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) - ON_COMMAND(ID_PROPERTIES1, OnProperties1) - ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) - ON_COMMAND(ID_PROPERTIES2, OnProperties2) - ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) - ON_WM_SETFOCUS() - ON_WM_SETTINGCHANGE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CResourceViewBar message handlers - -void CPropertiesWnd::AdjustLayout() -{ - if (GetSafeHwnd() == NULL) - { - return; - } - - CRect rectClient,rectCombo; - GetClientRect(rectClient); - - m_wndObjectCombo.GetWindowRect(&rectCombo); - - int cyCmb = rectCombo.Size().cy; - int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; - - m_wndObjectCombo.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), 200, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb + cyTlb, rectClient.Width(), rectClient.Height() -(cyCmb+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); -} - -int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create combo: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - - if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) - { - TRACE0("Failed to create Properties Combo \n"); - return -1; // fail to create - } - - m_wndObjectCombo.AddString(_T("Application")); - m_wndObjectCombo.AddString(_T("Properties Window")); - m_wndObjectCombo.SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); - m_wndObjectCombo.SetCurSel(0); - - if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) - { - TRACE0("Failed to create Properties Grid \n"); - return -1; // fail to create - } - - InitPropList(); - - m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); - m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* Is locked */); - m_wndToolBar.CleanUpLockedImages(); - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* Locked */); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - m_wndToolBar.SetOwner(this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame(FALSE); - - AdjustLayout(); - return 0; -} - -void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout(); -} - -void CPropertiesWnd::OnExpandAllProperties() -{ - m_wndPropList.ExpandAll(); -} - -void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* pCmdUI) -{ -} - -void CPropertiesWnd::OnSortProperties() -{ - m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); -} - -void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); -} - -void CPropertiesWnd::OnProperties1() -{ - // TODO: Add your command handler code here -} - -void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here -} - -void CPropertiesWnd::OnProperties2() -{ - // TODO: Add your command handler code here -} - -void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here -} - -void CPropertiesWnd::InitPropList() -{ - SetPropListFont(); - - m_wndPropList.EnableHeaderCtrl(FALSE); - m_wndPropList.EnableDescriptionArea(); - m_wndPropList.SetVSDotNetLook(); - m_wndPropList.MarkModifiedProperties(); - - CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Appearance")); - - pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("3D Look"), (_variant_t) false, _T("Specifies the window's font will be non-bold and controls will have a 3D border"))); - - CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Border"), _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame")); - pProp->AddOption(_T("None")); - pProp->AddOption(_T("Thin")); - pProp->AddOption(_T("Resizable")); - pProp->AddOption(_T("Dialog Frame")); - pProp->AllowEdit(FALSE); - - pGroup1->AddSubItem(pProp); - pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (_variant_t) _T("About"), _T("Specifies the text that will be displayed in the window's title bar"))); - - m_wndPropList.AddProperty(pGroup1); - - CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("Window Size"), 0, TRUE); - - pProp = new CMFCPropertyGridProperty(_T("Height"), (_variant_t) 250l, _T("Specifies the window's height")); - pProp->EnableSpinControl(TRUE, 0, 1000); - pSize->AddSubItem(pProp); - - pProp = new CMFCPropertyGridProperty( _T("Width"), (_variant_t) 150l, _T("Specifies the window's width")); - pProp->EnableSpinControl(); - pSize->AddSubItem(pProp); - - m_wndPropList.AddProperty(pSize); - - CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("Font")); - - LOGFONT lf; - CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); - font->GetLogFont(&lf); - - lstrcpy(lf.lfFaceName, _T("Arial")); - - pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the window"))); - pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (_variant_t) true, _T("Specifies that the window uses MS Shell Dlg font"))); - - m_wndPropList.AddProperty(pGroup2); - - CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("Misc")); - pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("Application")); - pProp->Enable(FALSE); - pGroup3->AddSubItem(pProp); - - CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default window color")); - pColorProp->EnableOtherButton(_T("Other...")); - pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE)); - pGroup3->AddSubItem(pColorProp); - - static TCHAR BASED_CODE szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||"); - pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the window icon"))); - - pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\"))); - - m_wndPropList.AddProperty(pGroup3); - - CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("Hierarchy")); - - CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level")); - pGroup4->AddSubItem(pGroup41); - - CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level")); - pGroup41->AddSubItem(pGroup411); - - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description"))); - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description"))); - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description"))); - - pGroup4->Expand(FALSE); - m_wndPropList.AddProperty(pGroup4); -} - -void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - m_wndPropList.SetFocus(); -} - -void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) -{ - CDockablePane::OnSettingChange(uFlags, lpszSection); - SetPropListFont(); -} - -void CPropertiesWnd::SetPropListFont() -{ - ::DeleteObject(m_fntPropList.Detach()); - - LOGFONT lf; - afxGlobalData.fontRegular.GetLogFont(&lf); - - NONCLIENTMETRICS info; - info.cbSize = sizeof(info); - - afxGlobalData.GetNonClientMetrics(info); - - lf.lfHeight = info.lfMenuFont.lfHeight; - lf.lfWeight = info.lfMenuFont.lfWeight; - lf.lfItalic = info.lfMenuFont.lfItalic; - - m_fntPropList.CreateFontIndirect(&lf); - - m_wndPropList.SetFont(&m_fntPropList); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/PropertiesWnd.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/PropertiesWnd.h deleted file mode 100644 index 266e37adc57cb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/PropertiesWnd.h +++ /dev/null @@ -1,60 +0,0 @@ - -#pragma once - -class CPropertiesToolBar : public CMFCToolBar -{ -public: - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList() const { return FALSE; } -}; - -class CPropertiesWnd : public CDockablePane -{ -// Construction -public: - CPropertiesWnd(); - - void AdjustLayout(); - -// Attributes -public: - void SetVSDotNetLook(BOOL bSet) - { - m_wndPropList.SetVSDotNetLook(bSet); - m_wndPropList.SetGroupNameFullWidth(bSet); - } - -protected: - CFont m_fntPropList; - CComboBox m_wndObjectCombo; - CPropertiesToolBar m_wndToolBar; - CMFCPropertyGridCtrl m_wndPropList; - -// Implementation -public: - virtual ~CPropertiesWnd(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnExpandAllProperties(); - afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI); - afx_msg void OnSortProperties(); - afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI); - afx_msg void OnProperties1(); - afx_msg void OnUpdateProperties1(CCmdUI* pCmdUI); - afx_msg void OnProperties2(); - afx_msg void OnUpdateProperties2(CCmdUI* pCmdUI); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); - - DECLARE_MESSAGE_MAP() - - void InitPropList(); - void SetPropListFont(); -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ReadMe.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ReadMe.txt deleted file mode 100644 index 922b1d8f68ec0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ReadMe.txt +++ /dev/null @@ -1,133 +0,0 @@ -================================================================================ - MICROSOFT FOUNDATION CLASS LIBRARY : Misc Project Overview -=============================================================================== - -The application wizard has created this Misc application for -you. This application not only demonstrates the basics of using the Microsoft -Foundation Classes but is also a starting point for writing your application. - -This file contains a summary of what you will find in each of the files that -make up your Misc application. - -Misc.vcproj - This is the main project file for VC++ projects generated using an application wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - application wizard. - -Misc.h - This is the main header file for the application. It includes other - project specific headers (including Resource.h) and declares the - CMiscApp application class. - -Misc.cpp - This is the main application source file that contains the application - class CMiscApp. - -Misc.rc - This is a listing of all of the Microsoft Windows resources that the - program uses. It includes the icons, bitmaps, and cursors that are stored - in the RES subdirectory. This file can be directly edited in Microsoft - Visual C++. Your project resources are in 1033. - -res\Misc.ico - This is an icon file, which is used as the application's icon. This - icon is included by the main resource file Misc.rc. - -res\Misc.rc2 - This file contains resources that are not edited by Microsoft - Visual C++. You should place all resources not editable by - the resource editor in this file. - -///////////////////////////////////////////////////////////////////////////// - -For the main frame window: - The project includes a standard MFC interface. - -MainFrm.h, MainFrm.cpp - These files contain the frame class CMainFrame, which is derived from - CMDIFrameWnd and controls all MDI frame features. - -res\Toolbar.bmp - This bitmap file is used to create tiled images for the toolbar. - The initial toolbar and status bar are constructed in the CMainFrame - class. Edit this toolbar bitmap using the resource editor, and - update the IDR_MAINFRAME TOOLBAR array in Misc.rc to add - toolbar buttons. -///////////////////////////////////////////////////////////////////////////// - -For the child frame window: - -ChildFrm.h, ChildFrm.cpp - These files define and implement the CChildFrame class, which - supports the child windows in an MDI application. - -///////////////////////////////////////////////////////////////////////////// - -The application wizard creates one document type and one view: - -MiscDoc.h, MiscDoc.cpp - the document - These files contain your CMiscDoc class. Edit these files to - add your special document data and to implement file saving and loading - (via CMiscDoc::Serialize). - -MiscView.h, MiscView.cpp - the view of the document - These files contain your CMiscView class. - CMiscView objects are used to view CMiscDoc objects. - -res\MiscDoc.ico - This is an icon file, which is used as the icon for MDI child windows - for the CMiscDoc class. This icon is included by the main - resource file Misc.rc. - - - - -///////////////////////////////////////////////////////////////////////////// - -Other Features: - -ActiveX Controls - The application includes support to use ActiveX controls. - -Printing and Print Preview support - The application wizard has generated code to handle the print, print setup, and print preview - commands by calling member functions in the CView class from the MFC library. - -Windows Sockets - The application has support for establishing communications over TCP/IP networks. - -///////////////////////////////////////////////////////////////////////////// - -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named Misc.pch and a precompiled types file named StdAfx.obj. - -Resource.h - This is the standard header file, which defines new resource IDs. - Microsoft Visual C++ reads and updates this file. - -Misc.manifest - Application manifest files are used by Windows XP to describe an applications - dependency on specific versions of Side-by-Side assemblies. The loader uses this - information to load the appropriate assembly from the assembly cache or private - from the application. The Application manifest maybe included for redistribution - as an external .manifest file that is installed in the same folder as the application - executable or it may be included in the executable in the form of a resource. -///////////////////////////////////////////////////////////////////////////// - -Other notes: - -The application wizard uses "TODO:" to indicate parts of the source code you -should add to or customize. - -If your application uses MFC in a shared DLL, you will need -to redistribute the MFC DLLs. If your application is in a language -other than the operating system's locale, you will also have to -redistribute the corresponding localized resources MFC90XXX.DLL. -For more information on both of these topics, please see the section on -redistributing Visual C++ applications in MSDN documentation. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Resource.h deleted file mode 100644 index 580e7c31dbf94..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Resource.h +++ /dev/null @@ -1,118 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Misc.rc -// -#define IDD_ABOUTBOX 100 -#define IDP_OLE_INIT_FAILED 100 -#define IDP_SOCKETS_INIT_FAILED 104 -#define IDR_POPUP_EDIT 119 -#define ID_STATUSBAR_PANE1 120 -#define ID_STATUSBAR_PANE2 121 -#define IDS_STATUS_PANE1 122 -#define IDS_STATUS_PANE2 123 -#define IDS_TOOLBAR_STANDARD 124 -#define IDS_TOOLBAR_CUSTOMIZE 125 -#define ID_VIEW_CUSTOMIZE 126 -#define IDR_MAINFRAME 128 -#define IDR_MAINFRAME_256 129 -#define IDR_MiscTYPE 130 -#define ID_WINDOW_MANAGER 131 -#define IDS_WINDOWS_MANAGER 132 -#define ID_VIEW_FILEVIEW 133 -#define ID_VIEW_CLASSVIEW 134 -#define ID_PROPERTIES 135 -#define ID_OPEN 136 -#define ID_OPEN_WITH 137 -#define ID_DUMMY_COMPILE 138 -#define ID_CLASS_ADD_MEMBER_FUNCTION 139 -#define ID_CLASS_ADD_MEMBER_VARIABLE 140 -#define ID_CLASS_DEFINITION 141 -#define ID_CLASS_PROPERTIES 142 -#define ID_NEW_FOLDER 143 -#define ID_SORT_MENU 144 -#define ID_SORTING_GROUPBYTYPE 145 -#define ID_SORTING_SORTALPHABETIC 146 -#define ID_SORTING_SORTBYTYPE 147 -#define ID_SORTING_SORTBYACCESS 148 -#define ID_VIEW_OUTPUTWND 149 -#define ID_VIEW_PROPERTIESWND 150 -#define ID_SORTPROPERTIES 151 -#define ID_PROPERTIES1 152 -#define ID_PROPERTIES2 153 -#define ID_EXPAND_ALL 154 -#define IDS_FILE_VIEW 155 -#define IDS_CLASS_VIEW 156 -#define IDS_OUTPUT_WND 157 -#define IDS_PROPERTIES_WND 158 -#define IDI_FILE_VIEW 161 -#define IDI_FILE_VIEW_HC 162 -#define IDI_CLASS_VIEW 163 -#define IDI_CLASS_VIEW_HC 164 -#define IDI_OUTPUT_WND 165 -#define IDI_OUTPUT_WND_HC 166 -#define IDI_PROPERTIES_WND 167 -#define IDI_PROPERTIES_WND_HC 168 -#define IDR_EXPLORER 169 -#define IDB_EXPLORER_24 170 -#define IDR_SORT 171 -#define IDB_SORT_24 172 -#define IDR_POPUP_SORT 173 -#define IDR_POPUP_EXPLORER 174 -#define IDB_FILE_VIEW 175 -#define IDB_FILE_VIEW_24 176 -#define IDB_CLASS_VIEW 177 -#define IDB_CLASS_VIEW_24 178 -#define IDR_MENU_IMAGES 179 -#define IDB_MENU_IMAGES_24 180 -#define ID_TOOLS_MACRO 181 -#define IDR_OUTPUT_POPUP 182 -#define IDR_PROPERTIES 183 -#define IDB_PROPERTIES_HC 184 -#define ID_VIEW_NAVIGATION 185 -#define IDB_NAVIGATION_LARGE 186 -#define IDB_NAVIGATION_LARGE_HC 187 -#define IDB_PAGES 188 -#define IDB_PAGES_HC 189 -#define IDB_PAGES_SMALL 190 -#define IDB_PAGES_SMALL_HC 191 -#define IDR_THEME_MENU 200 -#define ID_SET_STYLE 201 -#define ID_VIEW_APPLOOK_WIN_2000 210 -#define ID_VIEW_APPLOOK_OFF_XP 211 -#define ID_VIEW_APPLOOK_WIN_XP 212 -#define ID_VIEW_APPLOOK_OFF_2003 213 -#define ID_VIEW_APPLOOK_VS_2005 214 -#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 -#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 -#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 -#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 -#define ID_TOOLS_OPTIONS 220 -#define ID_VIEW_CAPTION_BAR 221 -#define IDB_INFO 230 -#define IDS_CAPTION_BUTTON 231 -#define IDS_CAPTION_BUTTON_TIP 232 -#define IDS_CAPTION_TEXT 233 -#define IDS_CAPTION_IMAGE_TIP 234 -#define IDS_CAPTION_IMAGE_TEXT 235 -#define IDS_MYCALENDARS 250 -#define IDS_CALENDAR 251 -#define IDS_SHORTCUTS 252 -#define IDS_FOLDERS 253 -#define IDS_OUTLOOKBAR 258 -#define IDS_RIBBON_CAPTIONBAR 295 -#define IDS_BUILD_TAB 300 -#define IDS_DEBUG_TAB 301 -#define IDS_FIND_TAB 302 -#define IDS_EXPLORER 305 -#define IDS_EDIT_MENU 306 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 310 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 310 -#define _APS_NEXT_COMMAND_VALUE 32771 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Snippets.txt deleted file mode 100644 index 4f62e120b2030..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/Snippets.txt +++ /dev/null @@ -1,3 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -Misc.h 1 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/UserImages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/UserImages.bmp deleted file mode 100644 index affe657025e47..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/UserImages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ViewTree.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ViewTree.cpp deleted file mode 100644 index 5d77a551833ba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ViewTree.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -#include "stdafx.h" -#include "ViewTree.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CViewTree - -CViewTree::CViewTree() -{ -} - -CViewTree::~CViewTree() -{ -} - -BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CViewTree message handlers - -BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); - - NMHDR* pNMHDR = (NMHDR*)lParam; - ASSERT(pNMHDR != NULL); - - if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != NULL) - { - GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); - } - - return bRes; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ViewTree.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ViewTree.h deleted file mode 100644 index e8ecbcfdda784..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/ViewTree.h +++ /dev/null @@ -1,23 +0,0 @@ - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CViewTree window - -class CViewTree : public CTreeCtrl -{ -// Construction -public: - CViewTree(); - -// Overrides -protected: - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - -// Implementation -public: - virtual ~CViewTree(); - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/misc.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/misc.vcxproj deleted file mode 100644 index d319f9defd88f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/misc.vcxproj +++ /dev/null @@ -1,141 +0,0 @@ - - - - - Debug - Win32 - - - - {E9176179-C7DE-42CF-AF57-854E7665C5F4} - Misc - MFCProj - - - - Application - Dynamic - Unicode - v110 - - - Application - - - - - - - - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - true - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level3 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - true - Windows - MachineX86 - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/misc.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/misc.vcxproj.filters deleted file mode 100644 index bde349c1a5336..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/misc.vcxproj.filters +++ /dev/null @@ -1,206 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Misc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Misc.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Misc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Misc.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Misc.rc2 deleted file mode 100644 index b6e05eff65d39..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Misc.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// Misc.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/MiscDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/MiscDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/MiscDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/class_view.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/class_view.ico deleted file mode 100644 index bf6b0ddcfc446..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/class_view.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/class_view_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/class_view_hc.ico deleted file mode 100644 index 3112bf258700b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/class_view_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/classview.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/classview.bmp deleted file mode 100644 index 1e02aa1aed9c4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/classview.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/classview_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/classview_hc.bmp deleted file mode 100644 index 6b22e786bcd9f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/classview_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/explorer.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/explorer.bmp deleted file mode 100644 index a4ef154527a80..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/explorer.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/explorer_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/explorer_hc.bmp deleted file mode 100644 index 559214a9bd70b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/explorer_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/file_view.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/file_view.ico deleted file mode 100644 index 0f93f52ab0185..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/file_view.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/file_view_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/file_view_hc.ico deleted file mode 100644 index 42ec43574f325..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/file_view_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/fileview.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/fileview.bmp deleted file mode 100644 index a2d62d0cb7f23..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/fileview.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/fileview_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/fileview_hc.bmp deleted file mode 100644 index b60f48381c687..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/fileview_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/info.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/info.bmp deleted file mode 100644 index 08b705b29c685..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/info.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/menuimages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/menuimages.bmp deleted file mode 100644 index 9d816ccecd94f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/menuimages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/menuimages_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/menuimages_hc.bmp deleted file mode 100644 index 04c3430d343f4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/menuimages_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/nav_large.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/nav_large.bmp deleted file mode 100644 index a081e17c9a1f2..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/nav_large.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/nav_large_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/nav_large_hc.bmp deleted file mode 100644 index 6607b554799ba..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/nav_large_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/output_wnd.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/output_wnd.ico deleted file mode 100644 index d14f99150a44b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/output_wnd.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/output_wnd_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/output_wnd_hc.ico deleted file mode 100644 index fdd27e85abee6..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/output_wnd_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages.bmp deleted file mode 100644 index 28c7202e9681f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_hc.bmp deleted file mode 100644 index d5850bce033ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_small.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_small.bmp deleted file mode 100644 index f48e621cb53e1..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_small.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_small_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_small_hc.bmp deleted file mode 100644 index b6fd7c2ebfdec..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/pages_small_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties.bmp deleted file mode 100644 index 8bf6601aaac49..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_hc.bmp deleted file mode 100644 index 6e90ff49bfdf9..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_wnd.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_wnd.ico deleted file mode 100644 index b8cb52eed2c87..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_wnd.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_wnd_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_wnd_hc.ico deleted file mode 100644 index 05a6d0e43de08..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/properties_wnd_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/sort.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/sort.bmp deleted file mode 100644 index 4e2155debf2dd..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/sort.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/sort_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/sort_hc.bmp deleted file mode 100644 index 5e1c3772dd759..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/res/sort_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/stdafx.cpp deleted file mode 100644 index 63acc0f336e82..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ - -// stdafx.cpp : source file that includes just the standard includes -// Misc.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/stdafx.h deleted file mode 100644 index bb087cbf76431..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/stdafx.h +++ /dev/null @@ -1,61 +0,0 @@ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - - -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - - -#include // MFC socket extensions - - - - - - - -#ifdef _UNICODE -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif -#endif - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Misc/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/CustomProperties.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/CustomProperties.cpp deleted file mode 100644 index 14e6677911d80..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/CustomProperties.cpp +++ /dev/null @@ -1,701 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "CustomProperties.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -//////////////////////////////////////////////////////////////////////////////// -// CCheckBoxProp class - -CCheckBoxProp::CCheckBoxProp(const CString& strName, BOOL bCheck, LPCTSTR lpszDescr, DWORD dwData) : - CMFCPropertyGridProperty(strName, COleVariant((long)bCheck), lpszDescr, dwData) -{ - m_rectCheck.SetRectEmpty(); -} - -void CCheckBoxProp::OnDrawName(CDC* pDC, CRect rect) -{ - m_rectCheck = rect; - m_rectCheck.DeflateRect(1, 1); - - m_rectCheck.right = m_rectCheck.left + m_rectCheck.Height(); - - rect.left = m_rectCheck.right + 1; - - CMFCPropertyGridProperty::OnDrawName(pDC, rect); - - OnDrawCheckBox(pDC, m_rectCheck, (m_varValue.boolVal)); -} - -void CCheckBoxProp::OnClickName(CPoint point) -{ - if (m_bEnabled && m_rectCheck.PtInRect(point)) - { - m_varValue.boolVal = !(m_varValue.boolVal); - m_pWndList->InvalidateRect(m_rectCheck); - } -} - -BOOL CCheckBoxProp::OnDblClk(CPoint point) -{ - if (m_bEnabled && m_rectCheck.PtInRect(point)) - { - return TRUE; - } - - m_varValue.boolVal = !(m_varValue.boolVal); - m_pWndList->InvalidateRect(m_rectCheck); - return TRUE; -} - -void CCheckBoxProp::OnDrawCheckBox(CDC * pDC, CRect rect, BOOL bChecked) -{ - COLORREF clrTextOld = pDC->GetTextColor(); - - CMFCVisualManager::GetInstance()->OnDrawCheckBox(pDC, rect, FALSE, bChecked, m_bEnabled); - - pDC->SetTextColor(clrTextOld); -} - -BOOL CCheckBoxProp::PushChar(UINT nChar) -{ - if (nChar == VK_SPACE) - { - OnDblClk(CPoint(-1, -1)); - } - - return TRUE; -} - -//////////////////////////////////////////////////////////////////////////////// -// CPasswordProp class - -const TCHAR cPassword = _T('*'); - -CPasswordProp::CPasswordProp(const CString& strName, const CString& strPassword, LPCTSTR lpszDescr, DWORD dwData) -: CMFCPropertyGridProperty(strName, (LPCTSTR) strPassword, lpszDescr, dwData) -{ -} - -CWnd* CPasswordProp::CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat) -{ - CEdit* pWndEdit = new CEdit; - - DWORD dwStyle = WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ES_PASSWORD; - - if (!m_bEnabled || !m_bAllowEdit) - { - dwStyle |= ES_READONLY; - } - - pWndEdit->Create(dwStyle, rectEdit, m_pWndList, AFX_PROPLIST_ID_INPLACE); - pWndEdit->SetPasswordChar(cPassword); - - bDefaultFormat = TRUE; - return pWndEdit; -} - -CString CPasswordProp::FormatProperty() -{ - CString strVal = (LPCTSTR)(_bstr_t)m_varValue; - - for (int i = 0; i < strVal.GetLength(); i++) - { - strVal.SetAt(i, cPassword); - } - - return strVal; -} - -///////////////////////////////////////////////////////////////////////////// -// CPropSliderCtrl - -CPropSliderCtrl::CPropSliderCtrl(CSliderProp* pProp, COLORREF clrBack) -{ - m_clrBack = clrBack; - m_brBackground.CreateSolidBrush(m_clrBack); - m_pProp = pProp; -} - -CPropSliderCtrl::~CPropSliderCtrl() -{ -} - -BEGIN_MESSAGE_MAP(CPropSliderCtrl, CSliderCtrl) - //{{AFX_MSG_MAP(CPropSliderCtrl) - ON_WM_CTLCOLOR_REFLECT() - ON_WM_HSCROLL_REFLECT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPropSliderCtrl message handlers - -HBRUSH CPropSliderCtrl::CtlColor(CDC* pDC, UINT /*nCtlColor*/) -{ - pDC->SetBkColor(m_clrBack); - return m_brBackground; -} - -void CPropSliderCtrl::HScroll(UINT /*nSBCode*/, UINT /*nPos*/) -{ - ASSERT_VALID(m_pProp); - - m_pProp->OnUpdateValue(); - m_pProp->Redraw(); -} - -//////////////////////////////////////////////////////////////////////////////// -// CSliderProp class - -CSliderProp::CSliderProp(const CString& strName, long nValue, LPCTSTR lpszDescr, DWORD dwData) : - CMFCPropertyGridProperty(strName, nValue, lpszDescr, dwData) -{ -} - -CWnd* CSliderProp::CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat) -{ - CPropSliderCtrl* pWndSlider = new CPropSliderCtrl(this, m_pWndList->GetBkColor()); - - rectEdit.left += rectEdit.Height() + 5; - - pWndSlider->Create(WS_VISIBLE | WS_CHILD, rectEdit, m_pWndList, AFX_PROPLIST_ID_INPLACE); - pWndSlider->SetPos(m_varValue.lVal); - - bDefaultFormat = TRUE; - return pWndSlider; -} - -BOOL CSliderProp::OnUpdateValue() -{ - ASSERT_VALID(this); - ASSERT_VALID(m_pWndInPlace); - ASSERT_VALID(m_pWndList); - ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd())); - - long lCurrValue = m_varValue.lVal; - - CSliderCtrl* pSlider = (CSliderCtrl*) m_pWndInPlace; - - m_varValue = (long) pSlider->GetPos(); - - if (lCurrValue != m_varValue.lVal) - { - m_pWndList->OnPropertyChanged(this); - } - - return TRUE; -} - -//////////////////////////////////////////////////////////////////////////////// -// CBoundedNumberPairProp class - -CBoundedNumberPairProp::CBoundedNumberPairProp(const CString& strGroupName, int nMinValue1, int nMaxValue1, int nMinValue2, int nMaxValue2, DWORD_PTR dwData, BOOL bIsValueList) : - CMFCPropertyGridProperty(strGroupName, dwData, bIsValueList) -{ - m_nMinValue1 = nMinValue1; - m_nMaxValue1 = nMaxValue1; - m_nMinValue2 = nMinValue2; - m_nMaxValue2 = nMaxValue2; -} - -BOOL CBoundedNumberPairProp::OnUpdateValue() -{ - ASSERT_VALID(this); - ASSERT_VALID(m_pWndInPlace); - ASSERT_VALID(m_pWndList); - ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd())); - - CString strText; - m_pWndInPlace->GetWindowText(strText); - - BOOL bIsChanged = FormatProperty() != strText; - - if (bIsChanged) - { - CString strDelimeter(_T(",")); - - for (int i = 0; !strText.IsEmpty() && i < GetSubItemsCount(); i++) - { - CString strItem = strText.SpanExcluding(strDelimeter); - if (strItem.GetLength() + 1 > strText.GetLength()) - { - strText.Empty(); - } - else - { - strText = strText.Mid(strItem.GetLength() + 1); - } - strItem.TrimLeft(); - strItem.TrimRight(); - - int nItem = _ttoi(strItem); - if ((i == 0) && ((nItem < m_nMinValue1) || (nItem > m_nMaxValue1))) - { - static BOOL bRecursedHere = FALSE; - if (bRecursedHere) - return TRUE; - bRecursedHere = TRUE; - - CString strMessage; - strMessage.Format(_T("Height value must be between %d and %d."), m_nMinValue1, m_nMaxValue1); - AfxMessageBox(strMessage); - - bRecursedHere = FALSE; - return FALSE; - } - else if ((i == 1) && ((nItem < m_nMinValue2) || (nItem > m_nMaxValue2))) - { - static BOOL bRecursedHere = FALSE; - if (bRecursedHere) - return TRUE; - bRecursedHere = TRUE; - - CString strMessage; - strMessage.Format(_T("Width value must be between %d and %d."), m_nMinValue2, m_nMaxValue2); - AfxMessageBox(strMessage); - - bRecursedHere = FALSE; - return FALSE; - } - } - - return CMFCPropertyGridProperty::OnUpdateValue(); - } - - return TRUE; -} - -//////////////////////////////////////////////////////////////////////////////// -// CBoundedNumberSubProp class - -CBoundedNumberSubProp::CBoundedNumberSubProp(const CString& strName, const COleVariant& varValue, int nMinValue, int nMaxValue, LPCTSTR lpszDescr) : - CMFCPropertyGridProperty(strName, varValue, lpszDescr) -{ - m_nMinValue = nMinValue; - m_nMaxValue = nMaxValue; -} - -BOOL CBoundedNumberSubProp::OnUpdateValue() -{ - ASSERT_VALID(this); - ASSERT_VALID(m_pWndInPlace); - ASSERT_VALID(m_pWndList); - ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd())); - - BOOL bRet = TRUE; - CString strText; - m_pWndInPlace->GetWindowText(strText); - - BOOL bIsChanged = FormatProperty() != strText; - if (bIsChanged) - { - int nItem = _ttoi(strText); - if ((nItem < m_nMinValue) || (nItem > m_nMaxValue)) - { - static BOOL bRecursedHere = FALSE; - if (bRecursedHere) - return TRUE; - bRecursedHere = TRUE; - - CString strMessage; - strMessage.Format(_T("Value must be between %d and %d."), m_nMinValue, m_nMaxValue); - AfxMessageBox(strMessage); - - bRecursedHere = FALSE; - return FALSE; - } - - bRet = CMFCPropertyGridProperty::OnUpdateValue(); - - if (m_pParent != NULL) - { - m_pWndList->OnPropertyChanged(m_pParent); - } - } - - return bRet; -} - -//////////////////////////////////////////////////////////////////////////////// -// CIconListProp class - -const int nIconMargin = 3; - -CIconListProp::CIconListProp(const CString& strName, const CImageList& imageListIcons, int nSelectedIcon, CStringList* plstIconNames, LPCTSTR lpszDescr, DWORD dwData) : - CMFCPropertyGridProperty(strName, (long) nSelectedIcon, lpszDescr, dwData) -{ - m_imageListIcons.CreateFromImageList(imageListIcons); - m_imageListIcons.SetTransparentColor(::GetSysColor(COLOR_3DFACE)); - - if (plstIconNames != NULL) - { - m_lstIconNames.AddTail(plstIconNames); - ASSERT(m_lstIconNames.GetCount() == m_imageListIcons.GetCount()); - } - - for (int i = 0; i < m_imageListIcons.GetCount(); i++) - { - CString strItem; - strItem.Format(_T("%d"), i); - - AddOption(strItem); - } - - AllowEdit(FALSE); -} - -CComboBox* CIconListProp::CreateCombo(CWnd* pWndParent, CRect rect) -{ - rect.bottom = rect.top + 400; - - CIconCombo* pWndCombo = new CIconCombo(m_imageListIcons, m_lstIconNames); - if (!pWndCombo->Create(WS_CHILD | CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS, rect, pWndParent, AFX_PROPLIST_ID_INPLACE)) - { - delete pWndCombo; - return NULL; - } - - return pWndCombo; -} - -void CIconListProp::OnDrawValue(CDC* pDC, CRect rect) -{ - ASSERT_VALID(m_pWndList); - ASSERT_VALID(pDC); - - CString strVal = (LPCTSTR)(_bstr_t) m_varValue; - if (strVal.IsEmpty() || m_imageListIcons.GetCount() == 0) - { - return; - } - - int nIndex = _ttoi(strVal); - - if (nIndex < 0) - { - return; - } - - COLORREF clrTextOld = pDC->GetTextColor(); - - CFont* pOldFont = pDC->SelectObject(IsModified() && m_pWndList->IsMarkModifiedProperties() ? &m_pWndList->GetBoldFont() : m_pWndList->GetFont()); - - CRect rectImage = rect; - rectImage.right = rectImage.left + rectImage.Height(); - rectImage.DeflateRect(1, 1); - - CAfxDrawState ds; - m_imageListIcons.PrepareDrawImage(ds, rectImage.Size()); - m_imageListIcons.Draw(pDC, rectImage.left, rectImage.top, nIndex); - m_imageListIcons.EndDrawImage(ds); - - if (!m_lstIconNames.IsEmpty()) - { - CString str = m_lstIconNames.GetAt(m_lstIconNames.FindIndex(nIndex)); - - rect.left = rectImage.right + 2 * nIconMargin; - - pDC->DrawText(str, rect, DT_SINGLELINE | DT_VCENTER); - } - - pDC->SetTextColor(clrTextOld); - pDC->SelectObject(pOldFont); - - m_bValueIsTruncated = FALSE; -} - -CWnd* CIconListProp::CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat) -{ - CWnd* pWnd = CMFCPropertyGridProperty::CreateInPlaceEdit(rectEdit, bDefaultFormat); - if (pWnd != NULL) - { - pWnd->ShowWindow(SW_HIDE); - } - - return pWnd; -} - -///////////////////////////////////////////////////////////////////////////// -// CIconCombo - -CIconCombo::CIconCombo(CMFCToolBarImages& imageListIcons, CStringList& lstIconNames) : - m_imageListIcons(imageListIcons), m_lstIconNames(lstIconNames) -{ -} - -CIconCombo::~CIconCombo() -{ -} - -BEGIN_MESSAGE_MAP(CIconCombo, CComboBox) - //{{AFX_MSG_MAP(CIconCombo) - ON_WM_DRAWITEM() - ON_WM_MEASUREITEM() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CIconCombo message handlers - -void CIconCombo::OnDrawItem(int /*nIDCtl*/, LPDRAWITEMSTRUCT lpDIS) -{ - CDC* pDC = CDC::FromHandle(lpDIS->hDC); - ASSERT_VALID(pDC); - - CRect rect = lpDIS->rcItem; - int nIcon = lpDIS->itemID; - - HBRUSH brBackground; - COLORREF clText; - - if (lpDIS->itemState & ODS_SELECTED) - { - brBackground = GetSysColorBrush(COLOR_HIGHLIGHT); - clText = afxGlobalData.clrTextHilite; - } - else - { - brBackground = GetSysColorBrush(COLOR_WINDOW); - clText = afxGlobalData.clrWindowText; - } - - if (lpDIS->itemAction &(ODA_DRAWENTIRE | ODA_SELECT)) - { - ::FillRect(lpDIS->hDC, &rect, brBackground); - } - - if (nIcon < 0) - { - return; - } - - CAfxDrawState ds; - m_imageListIcons.PrepareDrawImage(ds); - m_imageListIcons.Draw(pDC, rect.left + nIconMargin, rect.top + nIconMargin, nIcon); - m_imageListIcons.EndDrawImage(ds); - - if (!m_lstIconNames.IsEmpty()) - { - CString str = m_lstIconNames.GetAt(m_lstIconNames.FindIndex(nIcon)); - CFont* pOldFont = pDC->SelectObject(&afxGlobalData.fontRegular); - - pDC->SetBkMode(TRANSPARENT); - pDC->SetTextColor(clText); - - CRect rectText = rect; - rectText.left += m_imageListIcons.GetImageSize().cx + 2 * nIconMargin; - - pDC->DrawText(str, rectText, DT_SINGLELINE | DT_VCENTER); - - pDC->SelectObject(pOldFont); - } -} - -void CIconCombo::OnMeasureItem(int /*nIDCtl*/, LPMEASUREITEMSTRUCT lpMeasureItemStruct) -{ - int nTextWidth = 0; - int nTextHeight = 0; - - if (!m_lstIconNames.IsEmpty()) - { - nTextHeight = afxGlobalData.GetTextHeight(); - - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); - - for (POSITION pos = m_lstIconNames.GetHeadPosition(); pos != NULL;) - { - CString str = m_lstIconNames.GetNext(pos); - - nTextWidth = max(nTextWidth, dc.GetTextExtent(str).cx + nIconMargin); - } - - dc.SelectObject(pOldFont); - } - - lpMeasureItemStruct->itemWidth = m_imageListIcons.GetImageSize().cx + nTextWidth + 2 * nIconMargin; - lpMeasureItemStruct->itemHeight = max(nTextHeight, m_imageListIcons.GetImageSize().cy + 2 * nIconMargin); -} - -//////////////////////////////////////////////////////////////////////////////// -// CComboBoxExProp class - -CComboBoxExProp::CComboBoxExProp(const CString& strName, const CString& strValue, LPCTSTR lpszDescr, DWORD dwData, CImageList* pImageList) : - CMFCPropertyGridProperty(strName, (LPCTSTR) strValue, lpszDescr, dwData), m_pImageList(pImageList) -{ -} - -CComboBox* CComboBoxExProp::CreateCombo(CWnd* pWndParent, CRect rect) -{ - rect.bottom = rect.top + 400; - - CComboBoxEx* pWndCombo = new CComboBoxEx; - - if (!pWndCombo->Create(WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, rect, pWndParent, AFX_PROPLIST_ID_INPLACE)) - { - delete pWndCombo; - return NULL; - } - - if (m_pImageList != NULL) - { - pWndCombo->SetImageList(m_pImageList); - } - - return pWndCombo; -} - -BOOL CComboBoxExProp::OnEdit(LPPOINT lptClick) -{ - if (!CMFCPropertyGridProperty::OnEdit(lptClick)) - { - return FALSE; - } - - CComboBoxEx* pWndComboEx = DYNAMIC_DOWNCAST(CComboBoxEx, m_pWndCombo); - if (pWndComboEx == NULL) - { - ASSERT(FALSE); - return FALSE; - } - - pWndComboEx->ResetContent(); - - int i = 0; - - COMBOBOXEXITEM item; - memset(&item, 0, sizeof(item)); - - item.mask = CBEIF_IMAGE | CBEIF_INDENT | CBEIF_SELECTEDIMAGE | CBEIF_TEXT; - - for (POSITION pos = m_lstOptions.GetHeadPosition(); pos != NULL; i++) - { - CString strItem = m_lstOptions.GetNext(pos); - - item.iItem = i; - item.iSelectedImage = item.iImage = m_lstIcons [i]; - item.iIndent = m_lstIndents [i]; - item.pszText = (LPTSTR)(LPCTSTR) strItem; - item.cchTextMax = strItem.GetLength(); - - pWndComboEx->InsertItem(&item); - } - - return TRUE; -} - -BOOL CComboBoxExProp::AddOption(LPCTSTR lpszOption, int nIcon, int nIndent) -{ - if (!CMFCPropertyGridProperty::AddOption(lpszOption)) - { - return FALSE; - } - - m_lstIcons.Add(nIcon); - m_lstIndents.Add(nIndent); - - return TRUE; -} - -COwnerDrawDescrProp::COwnerDrawDescrProp(const CString& strName, const COleVariant& varValue) : CMFCPropertyGridProperty(strName, varValue) -{ -} - -void COwnerDrawDescrProp::OnDrawDescription(CDC* pDC, CRect rect) -{ - // - // CRect rect - // CDC* pDC - CDrawingManager dm(*pDC); - // The last parameter is the angle that specifies the direction of the color gradient. - dm.FillGradient2(rect, RGB(102, 200, 238), RGB(0, 129, 185), 45); - // - - CFont* pOldFont = pDC->SelectObject(&afxGlobalData.fontBold); - - CString strText = _T("Custom Text"); - - pDC->SetTextColor(RGB(0, 65, 117)); - pDC->DrawText(strText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); - - rect.OffsetRect(-2, -2); - - pDC->SetTextColor(RGB(155, 251, 255)); - pDC->DrawText(strText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); - - pDC->SelectObject(pOldFont); -} - -CTwoButtonsProp::CTwoButtonsProp(const CString& strName, const COleVariant& varValue) : CMFCPropertyGridProperty(strName, varValue) -{ - CBitmap bmp; - bmp.LoadBitmap(IDB_BUTTONS); - - m_images.Create(14, 14, ILC_MASK | ILC_COLOR8, 0, 0); - m_images.Add(&bmp, RGB(255, 0, 255)); -} - -void CTwoButtonsProp::AdjustButtonRect() -{ - CMFCPropertyGridProperty::AdjustButtonRect(); - m_rectButton.left -= m_rectButton.Width(); -} - -void CTwoButtonsProp::OnClickButton(CPoint point) -{ - BOOL bIsLeft = point.x < m_rectButton.CenterPoint().x; - AfxMessageBox(bIsLeft ? _T("Left button clicked") : _T("Right button clicked")); -} - -void CTwoButtonsProp::OnDrawButton(CDC* pDC, CRect rectButton) -{ - for (int i = 0; i < 2; i++) - { - CMFCToolBarButton button; - - CRect rect = rectButton; - - if (i == 0) - { - rect.right = rect.left + rect.Width() / 2; - } - else - { - rect.left = rect.right - rect.Width() / 2; - } - - CMFCVisualManager::AFX_BUTTON_STATE state = CMFCVisualManager::ButtonsIsHighlighted; - - CMFCVisualManager::GetInstance()->OnFillButtonInterior(pDC, &button, rect, state); - - m_images.Draw(pDC, i, CPoint(rect.left, rect.top), ILD_NORMAL); - - CMFCVisualManager::GetInstance()->OnDrawButtonBorder(pDC, &button, rect, state); - } -} - -CCustomDlgProp::CCustomDlgProp(const CString& strName, const COleVariant& varValue) : CMFCPropertyGridProperty(strName, varValue) -{ -} - -void CCustomDlgProp::OnClickButton(CPoint /*point*/) -{ - AfxMessageBox(_T("Show your dialog here...")); - SetValue(_T("New value")); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/CustomProperties.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/CustomProperties.h deleted file mode 100644 index d6074e26b9c04..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/CustomProperties.h +++ /dev/null @@ -1,198 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CCheckBoxProp : public CMFCPropertyGridProperty -{ -public: - CCheckBoxProp(const CString& strName, BOOL bCheck, LPCTSTR lpszDescr = NULL, DWORD dwData = 0); - -protected: - virtual BOOL OnEdit(LPPOINT /*lptClick*/) { return FALSE; } - virtual void OnDrawButton(CDC* /*pDC*/, CRect /*rectButton*/) {} - virtual void OnDrawValue(CDC* /*pDC*/, CRect /*rect*/) {} - virtual BOOL HasButton() const { return FALSE; } - - virtual BOOL PushChar(UINT nChar); - virtual void OnDrawCheckBox(CDC * pDC, CRect rectCheck, BOOL bChecked); - virtual void OnDrawName(CDC* pDC, CRect rect); - virtual void OnClickName(CPoint point); - virtual BOOL OnDblClk(CPoint point); - -protected: - CRect m_rectCheck; -}; - -class CPasswordProp : public CMFCPropertyGridProperty -{ -public: - CPasswordProp(const CString& strName, const CString& strPassword, LPCTSTR lpszDescr = NULL, DWORD dwData = 0); - -protected: - virtual CWnd* CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat); - virtual CString FormatProperty(); -}; - -class CSliderProp : public CMFCPropertyGridProperty -{ -public: - CSliderProp(const CString& strName, long nValue, LPCTSTR lpszDescr = NULL, DWORD dwData = 0); - - virtual BOOL OnUpdateValue(); - -protected: - virtual CWnd* CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat); - virtual BOOL OnSetCursor() const { return FALSE; /* Use default */ } -}; - -class CBoundedNumberPairProp : public CMFCPropertyGridProperty -{ -public: - CBoundedNumberPairProp(const CString& strGroupName, int nMinValue1, int nMaxValue1, int nMinValue2, int nMaxValue2, DWORD_PTR dwData = 0, BOOL bIsValueList = FALSE); - - virtual BOOL OnUpdateValue(); - -private: - int m_nMinValue1; - int m_nMaxValue1; - int m_nMinValue2; - int m_nMaxValue2; -}; - -class CBoundedNumberSubProp : public CMFCPropertyGridProperty -{ -public: - CBoundedNumberSubProp(const CString& strName, const COleVariant& varValue, int nMinValue, int nMaxValue, LPCTSTR lpszDescr = NULL); - - virtual BOOL OnUpdateValue(); -private: - int m_nMinValue; - int m_nMaxValue; -}; - -///////////////////////////////////////////////////////////////////////////// -// CPropSliderCtrl window - -class CPropSliderCtrl : public CSliderCtrl -{ -// Construction -public: - CPropSliderCtrl(CSliderProp* pProp, COLORREF clrBack); - -// Attributes -protected: - CBrush m_brBackground; - COLORREF m_clrBack; - CSliderProp* m_pProp; - -// Implementation -public: - virtual ~CPropSliderCtrl(); - -protected: - //{{AFX_MSG(CPropSliderCtrl) - afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); - //}}AFX_MSG - afx_msg void HScroll(UINT nSBCode, UINT nPos); - - DECLARE_MESSAGE_MAP() -}; - -class CIconListProp : public CMFCPropertyGridProperty -{ -public: - CIconListProp(const CString& strName, const CImageList& imageListIcons, int nSelectedIcon, CStringList* plstIconNames = NULL, LPCTSTR lpszDescr = NULL, DWORD dwData = 0); - -protected: - virtual CWnd* CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat); - virtual CComboBox* CreateCombo(CWnd* pWndParent, CRect rect); - virtual void OnDrawValue(CDC* pDC, CRect rect); - - CMFCToolBarImages m_imageListIcons; - CStringList m_lstIconNames; -}; - -///////////////////////////////////////////////////////////////////////////// -// CIconCombo window - -class CIconCombo : public CComboBox -{ -// Construction -public: - CIconCombo(CMFCToolBarImages& imageListIcons, CStringList& lstIconNames); - -// Attributes -protected: - CMFCToolBarImages& m_imageListIcons; - CStringList& m_lstIconNames; - -// Implementation -public: - virtual ~CIconCombo(); - -protected: - //{{AFX_MSG(CIconCombo) - afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct); - afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -class CComboBoxExProp : public CMFCPropertyGridProperty -{ -public: - CComboBoxExProp(const CString& strName, const CString& strValue, LPCTSTR lpszDescr = NULL, DWORD dwData = 0, CImageList* pImageList = NULL); - - BOOL AddOption(LPCTSTR lpszOption, int nIcon = -1, int nIndent = 0); - -protected: - virtual CComboBox* CreateCombo(CWnd* pWndParent, CRect rect); - virtual BOOL OnEdit(LPPOINT lptClick); - - CImageList* m_pImageList; - CArray m_lstIcons; - CArray m_lstIndents; -}; - -class COwnerDrawDescrProp : public CMFCPropertyGridProperty -{ -public: - COwnerDrawDescrProp(const CString& strName, const COleVariant& varValue); - -protected: - virtual void OnDrawDescription(CDC* pDC, CRect rect); -}; - -class CTwoButtonsProp : public CMFCPropertyGridProperty -{ -public: - CTwoButtonsProp(const CString& strName, const COleVariant& varValue); - -protected: - virtual BOOL HasButton() const { return TRUE; } - virtual void AdjustButtonRect(); - virtual void OnClickButton(CPoint point); - virtual void OnDrawButton(CDC* pDC, CRect rectButton); - - CImageList m_images; -}; - -class CCustomDlgProp : public CMFCPropertyGridProperty -{ -public: - CCustomDlgProp(const CString& strName, const COleVariant& varValue); - -protected: - virtual BOOL HasButton() const { return TRUE; } - virtual void OnClickButton(CPoint point); -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.cpp deleted file mode 100644 index 3c279258327fb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include -#include "NewControls.h" -#include "NewControlsPropSheet.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -///////////////////////////////////////////////////////////////////////////// -// CNewControlsApp - -BEGIN_MESSAGE_MAP(CNewControlsApp, CWinAppEx) - ON_COMMAND(ID_HELP, CWinAppEx::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CNewControlsApp construction - -CNewControlsApp::CNewControlsApp() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CNewControlsApp object - -CNewControlsApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CNewControlsApp initialization - -BOOL CNewControlsApp::InitInstance() -{ - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - SetRegistryBase(_T("Settings")); - - InitCommonControls(); - InitContextMenuManager(); - InitShellManager(); - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); - CMFCButton::EnableWindowsTheming(); - - NewControlsPropSheet propSheet; - m_pMainWnd = &propSheet; - propSheet.DoModal(); - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.h deleted file mode 100644 index ed9300196bc7f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.h +++ /dev/null @@ -1,64 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ -#error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CNewControlsApp: -// See NewControls.cpp for the implementation of this class -// - -class CNewControlsApp : public CWinAppEx -{ -public: - CNewControlsApp(); - -// Overrides -public: - virtual BOOL InitInstance(); - -// Implementation - DECLARE_MESSAGE_MAP() -}; - -extern CNewControlsApp theApp; - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.rc deleted file mode 100644 index 2d48fc6c9c89f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControls.rc +++ /dev/null @@ -1,520 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\NewControls.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#ifndef _AFXDLL\r\n" - "#include ""afxribbon.rc"" // Ribbon and control bars\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\NewControls.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About NewControls" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "NewControls Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_PAGE1 DIALOG 0, 0, 309, 228 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Buttons" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Push button: ",IDC_STATIC,7,7,163,140 - PUSHBUTTON "CThemedB&utton",IDC_BUTTON,17,19,71,14 - LTEXT "Image &Location:",IDC_STATIC,17,54,52,8 - COMBOBOX IDC_IMAGE_LOCATION,79,53,83,83,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Appearanc&e:",IDC_STATIC,17,72,42,8 - COMBOBOX IDC_IMAGE,79,71,83,83,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "&Border:",IDC_BORDER_LABEL,17,90,24,8 - COMBOBOX IDC_BORDER,79,89,83,74,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "&Cursor:",IDC_STATIC,17,108,23,8 - COMBOBOX IDC_CURSOR,79,107,83,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "&Tooltip:",IDC_STATIC,17,126,24,8 - EDITTEXT IDC_TOOLTIP,79,125,49,14,ES_AUTOHSCROLL - PUSHBUTTON "&Set",IDC_SET_TOOLTIP,137,125,25,14 - GROUPBOX "Radio button: ",IDC_STATIC,180,7,122,101 - CONTROL "Option 1",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,210,27,43,10 - CONTROL "Option 2",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,210,46,43,10 - CONTROL "Option 3",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,210,65,43,10 - CONTROL "Option 4",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,210,84,43,10 - GROUPBOX "Menu button:",IDC_STATIC,7,151,163,70 - PUSHBUTTON "C&MFCMenuButton",IDC_BUTTON_MENU,17,166,90,14 - CONTROL "Ri&ght Arrow",IDC_RIGHT_ARROW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,188,53,10 - CONTROL "Stay &Pressed",IDC_PRESSED_ON_MENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,79,188,57,10 - CONTROL "&Default Click",IDC_MENU_DEFAULT_CLICK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,203,56,10 - GROUPBOX "Check button:",IDC_STATIC,180,110,122,37 - CONTROL "&On/Off",IDC_CHECK_BUTTON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,127,38,10 - CONTROL "Windows &XP-style Buttons",IDC_XP_BUTTONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,203,211,99,10 - GROUPBOX "Multi-line text button:",IDC_STATIC,180,151,122,54 - PUSHBUTTON "This is a multi-line button\nYou can add some text\nlines here...",IDC_BUTTON_MULTLINE,191,166,96,32 -END - -IDD_PAGE2 DIALOG 0, 0, 309, 190 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Color Controls" -FONT 8, "MS Sans Serif" -BEGIN - PUSHBUTTON "&Dialog...",IDC_COLOR_DLG,37,24,39,14 - GROUPBOX "Advanced color dialog: ",IDC_STATIC,7,7,137,41 - PUSHBUTTON "Picker",IDC_COLOR_PICKER,37,64,67,14 - CTEXT "Static",IDC_RGB,39,82,67,8 - GROUPBOX "Color picker: ",IDC_STATIC,7,52,137,42 - GROUPBOX "Color bar: ",IDC_STATIC,7,98,137,85 - CONTROL "",IDC_COLORBAR,"Static",SS_BLACKFRAME,17,112,65,64 - GROUPBOX "Color bar with custom palette: ",IDC_STATIC,151,7,151,98 - CONTROL "",IDC_COLORBAR2,"Static",SS_BLACKFRAME,159,20,136,64 - CTEXT "Static",IDC_RGB_COLOR_BAR2,159,91,135,8 - CTEXT "Static",IDC_RGB_COLOR_BAR,85,136,53,8 - CTEXT "Static",IDC_RGB_DLG,77,27,59,8 - GROUPBOX "Color palette: ",IDC_STATIC,151,109,151,74 - PUSHBUTTON "Palette",IDC_COLOR_PALETTE,159,123,107,42 - CTEXT "Static",IDC_RGB_COLOR_PALETTE,159,170,135,8 - PUSHBUTTON "Lum",IDC_LUM,273,123,21,42 -END - -IDD_PAGE3 DIALOGEX 0, 0, 309, 217 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Misc. Controls" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - GROUPBOX "Font combobox: ",IDC_STATIC,7,7,148,67 - COMBOBOX IDC_FONT,17,21,130,209,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - CONTROL "&TrueType",IDC_TRUETYPE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,40,47,10 - CONTROL "&Raster",IDC_RASTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,65,40,37,10 - CONTROL "&Device",IDC_DEVICE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,105,40,39,10 - CONTROL "Draw &using font",IDC_DRAW_USING_FONT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,55,65,10 - GROUPBOX "Link button: ",IDC_STATIC,164,7,138,49 - PUSHBUTTON "CMFCLinkCtrl",IDC_BUTTON_URL,176,26,108,14 - GROUPBOX "Image editor:",IDC_STATIC,7,114,148,56 - CONTROL "",IDC_IMAGE_AREA,"Static",SS_GRAYRECT | NOT WS_VISIBLE,22,128,20,20 - PUSHBUTTON "&Edit...",IDC_EDIT_IMAGE,63,128,38,14 - LTEXT "CVSListBo&x",IDC_EDIT_LIST,164,71,138,59,WS_TABSTOP - GROUPBOX "Edit Browse Controls: ",IDC_STATIC,164,134,138,76 - EDITTEXT IDC_FILE_EDIT,202,148,90,14,ES_AUTOHSCROLL - LTEXT "File:",IDC_STATIC,173,148,14,8 - EDITTEXT IDC_FOLDER_EDIT,202,169,90,14,ES_AUTOHSCROLL - LTEXT "Folder: ",IDC_STATIC,173,169,24,8 - EDITTEXT IDC_CUSTOM_EDIT,202,189,90,14,ES_AUTOHSCROLL - LTEXT "Custom: ",IDC_STATIC,173,189,28,8 -END - -IDD_PAGE4 DIALOG 0, 0, 309, 190 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Masked Edit" -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_MASKEDIT1,18,22,114,14,ES_AUTOHSCROLL - LTEXT "Mask 1: phone number",IDC_STATIC,18,13,74,8 - EDITTEXT IDC_MASKEDIT2,18,50,114,14,ES_AUTOHSCROLL - LTEXT "Mask 2: State, Zip Code",IDC_STATIC,18,41,78,8 - EDITTEXT IDC_MASKEDIT3,18,78,114,14,ES_AUTOHSCROLL - LTEXT "Mask 3: serial code",IDC_STATIC,18,69,62,8 - EDITTEXT IDC_MASKEDIT4,18,106,114,14,ES_AUTOHSCROLL - LTEXT "Mask 4: 0xFFFF",IDC_STATIC,18,97,52,8 - EDITTEXT IDC_MASKEDIT5,18,134,114,14,ES_AUTOHSCROLL - LTEXT "Mask 5: digits only",IDC_STATIC,18,125,59,8 - PUSHBUTTON "Get values",IDC_BUTTON1,249,23,40,14 - EDITTEXT IDC_VALUE1,142,23,94,14,ES_AUTOHSCROLL | ES_READONLY - EDITTEXT IDC_VALUE2,142,50,94,14,ES_AUTOHSCROLL | ES_READONLY - EDITTEXT IDC_VALUE3,142,78,94,14,ES_AUTOHSCROLL | ES_READONLY - EDITTEXT IDC_VALUE4,142,105,94,14,ES_AUTOHSCROLL | ES_READONLY - EDITTEXT IDC_VALUE5,142,134,94,14,ES_AUTOHSCROLL | ES_READONLY -END - -IDD_PAGE5 DIALOG 0, 0, 309, 243 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "List Controls" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "CMFCListCtrl:",IDC_STATIC,7,7,43,8 - CONTROL "List1",IDC_LIST1,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,7,20,132,140 - CONTROL "&Mark sorted column",IDC_MARK_SORTED_COLUMN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,167,78,10 - CONTROL "&Colored rows",IDC_COLOR_ROWS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,181,57,10 - CONTROL "Modify &Font",IDC_MODIFY_FONT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,194,53,10 - LTEXT "CMFCPropertyGridCtrl:",IDC_STATIC,157,7,100,8 - CONTROL "",IDC_PROPLIST_LOCATION,"Static",SS_BLACKFRAME | NOT WS_VISIBLE,157,20,145,140 - PUSHBUTTON "Expand &All",IDC_PROPLIST_EXPAND_ALL,252,6,50,12 - CONTROL "&Header",IDC_HEADER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,167,39,10 - CONTROL "VS.NET look",IDC_DOT_NET_LOOK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,181,57,10 - CONTROL "&Description",IDC_DESCRIPTION_AREA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,194,51,10 - CONTROL "C&ustom Colors",IDC_CUSTOM_COLORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,222,167,61,10 - CONTROL "Categori&zed",IDC_PROPLIST_CATEGORIZED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,222,181,53,10 - CONTROL "Show D&rag Context",IDC_PROPLIST_CATEGORIZED2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,222,194,77,10 - CONTROL "Mar&k Changed",IDC_MARK_CHANGED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,210,63,10 - PUSHBUTTON "R&eset Values",IDC_RESET_VALUES,222,208,51,14 - CONTROL "Hide Fon&t Properties",IDC_HIDE_FONT_PROPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,226,80,10 -END - -IDD_PAGE6 DIALOG 0, 0, 309, 217 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Shell Controls" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "CMFCShellTreeCtrl:",IDC_STATIC,6,7,67,8 - CONTROL "Tree1",IDC_TREE1,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,6,19,153,77 - GROUPBOX "Folder selector: ",IDC_STATIC,173,7,129,89 - PUSHBUTTON "Select &Folder...",IDC_SELECT_FOLDER,184,20,60,14 - LTEXT "CMFCShellListCtrl:",IDC_STATIC,6,102,63,8 - CONTROL "List1",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,6,113,296,95 - EDITTEXT IDC_SELECTED_FOLDER,184,40,111,48, ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "NewControls MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "NewControls" - VALUE "LegalCopyright", "Copyright (C) 2000" - VALUE "OriginalFilename", "NewControls.EXE" - VALUE "ProductName", "NewControls Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_PAGE1, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 302 - VERTGUIDE, 17 - VERTGUIDE, 79 - VERTGUIDE, 162 - VERTGUIDE, 170 - VERTGUIDE, 180 - VERTGUIDE, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 221 - HORZGUIDE, 166 - HORZGUIDE, 188 - END - - IDD_PAGE2, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 302 - VERTGUIDE, 144 - TOPMARGIN, 7 - BOTTOMMARGIN, 183 - HORZGUIDE, 123 - END - - IDD_PAGE3, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 302 - VERTGUIDE, 17 - VERTGUIDE, 63 - VERTGUIDE, 155 - VERTGUIDE, 164 - VERTGUIDE, 173 - VERTGUIDE, 202 - VERTGUIDE, 292 - TOPMARGIN, 7 - BOTTOMMARGIN, 210 - HORZGUIDE, 148 - END - - IDD_PAGE4, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 302 - VERTGUIDE, 18 - VERTGUIDE, 132 - VERTGUIDE, 142 - VERTGUIDE, 236 - TOPMARGIN, 7 - BOTTOMMARGIN, 183 - END - - IDD_PAGE5, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 302 - VERTGUIDE, 157 - VERTGUIDE, 222 - TOPMARGIN, 7 - BOTTOMMARGIN, 236 - HORZGUIDE, 20 - HORZGUIDE, 160 - END - - IDD_PAGE6, DIALOG - BEGIN - LEFTMARGIN, 6 - RIGHTMARGIN, 302 - VERTGUIDE, 184 - TOPMARGIN, 7 - BOTTOMMARGIN, 208 - HORZGUIDE, 20 - HORZGUIDE, 96 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_BTN1 BITMAP "res\\btn1.bmp" -IDB_BTN1_HOT BITMAP "res\\btn1_hot.bmp" -IDB_GLOBE BITMAP "res\\globe.bmp" -IDB_PLAY BITMAP "res\\play.bmp" -IDB_STOP BITMAP "res\\stop.bmp" -IDB_STOP_HOT BITMAP "res\\stop_hot.bmp" -IDB_PLAY_HOT BITMAP "res\\play_hot.bmp" -IDB_IMAGE BITMAP "res\\image.bmp" -IDB_TEST_BITMAP BITMAP "res\\test_bit.bmp" -IDR_TOOLBAR_MENU_IMAGES BITMAP "res\\toolbar1.bmp" -IDB_ICONS BITMAP "res\\icons.bmp" -IDB_CHECK BITMAP "res\\bitmap1.bmp" -IDB_CHECKNO BITMAP "res\\checkno.bmp" -IDB_RADIO_ON BITMAP "res\\radio_on.bmp" -IDB_RADIO_OFF BITMAP "res\\radio_of.bmp" -IDB_PROPICONS BITMAP "Res\\propicons.bmp" -IDB_BUTTONS BITMAP "res\\buttons.bmp" -IDB_CHECK32 BITMAP "Res\\check32.bmp" -IDB_CHECKNO32 BITMAP "Res\\checkno32.bmp" -IDB_RADIO_OFF32 BITMAP "Res\\radio_of32.bmp" -IDB_RADIO_ON32 BITMAP "Res\\radio_on32.bmp" -IDB_BTN1_HOT_32 BITMAP "Res\\button32hot.bmp" -IDB_BTN1_32 BITMAP "Res\\button32.bmp" -IDB_ICONS32 BITMAP "Res\\icons32.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Cursor -// - -IDC_CURSOR CURSOR "res\\Btn.cur" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MENU1 MENU -BEGIN - POPUP "Dummy" - BEGIN - MENUITEM "Item &1", ID_ITEM_1 - MENUITEM "Item &2", ID_ITEM_2 - MENUITEM "Item &3", ID_ITEM_3 - MENUITEM "Item &4", ID_ITEM_4 - END -END - -IDR_DIALOG_MENU MENU -BEGIN - POPUP "Dummy" - BEGIN - MENUITEM "Item &1", ID_ITEM_1 - MENUITEM "Item &2", ID_ITEM_2 - MENUITEM SEPARATOR - MENUITEM "&About...", ID_DIALOG_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_PAGE1 DLGINIT -BEGIN - IDC_IMAGE_LOCATION, 0x403, 24, 0 -0x6d49, 0x6761, 0x2065, 0x6e6f, 0x6c20, 0x6665, 0x2074, 0x6428, 0x6665, -0x7561, 0x746c, 0x0029, - IDC_IMAGE_LOCATION, 0x403, 15, 0 -0x6d49, 0x6761, 0x2065, 0x6e6f, 0x7220, 0x6769, 0x7468, "\000" - IDC_IMAGE_LOCATION, 0x403, 13, 0 -0x6d49, 0x6761, 0x2065, 0x6e6f, 0x7420, 0x706f, "\000" - IDC_IMAGE, 0x403, 6, 0 -0x6d49, 0x6761, 0x0065, - IDC_IMAGE, 0x403, 5, 0 -0x6554, 0x7478, "\000" - IDC_IMAGE, 0x403, 15, 0 -0x6d49, 0x6761, 0x2065, 0x6e61, 0x2064, 0x6554, 0x7478, "\000" - IDC_BORDER, 0x403, 5, 0 -0x6c46, 0x7461, "\000" - IDC_BORDER, 0x403, 10, 0 -0x6553, 0x696d, 0x462d, 0x616c, 0x0074, - IDC_BORDER, 0x403, 4, 0 -0x2d33, 0x0044, - IDC_CURSOR, 0x403, 9, 0 -0x7453, 0x6e61, 0x6164, 0x6472, "\000" - IDC_CURSOR, 0x403, 5, 0 -0x6148, 0x646e, "\000" - IDC_CURSOR, 0x403, 13, 0 -0x7355, 0x7265, 0x642d, 0x6665, 0x6e69, 0x6465, "\000" - 0 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_TOOLBAR_MENU_IMAGES TOOLBAR 16, 15 -BEGIN - BUTTON ID_DIALOG_ABOUT - BUTTON ID_ITEM_1 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About NewControls..." - IDS_CAPTION "NewControls" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "NewControls Example" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\NewControls.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#ifndef _AFXDLL -#include "afxribbon.rc" // Ribbon and control bars -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControlsPropSheet.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControlsPropSheet.cpp deleted file mode 100644 index f04d604deafee..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControlsPropSheet.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "NewControlsPropSheet.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// NewControlsPropSheet - -IMPLEMENT_DYNAMIC(NewControlsPropSheet, CMFCPropertySheet) - -NewControlsPropSheet::NewControlsPropSheet(CWnd* pParentWnd) -:CMFCPropertySheet(IDS_CAPTION, pParentWnd) -{ - BOOL b32BitIcons = true; - - if (afxGlobalData.m_nBitsPerPixel == 16) - { - // 32-bit icons in 16 bpp display mode - // are correctly displayed in WinXP only - - OSVERSIONINFO osvi; - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - ::GetVersionEx(&osvi); - - b32BitIcons = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && (osvi.dwMajorVersion > 5 || (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion >= 1))); - } - - SetLook(CMFCPropertySheet::PropSheetLook_OutlookBar); - SetIconsList(b32BitIcons ? IDB_ICONS32 : IDB_ICONS, 32); - - AddPage(&m_Page1); - AddPage(&m_Page2); - AddPage(&m_Page3); - AddPage(&m_Page4); - AddPage(&m_Page5); - AddPage(&m_Page6); - - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -NewControlsPropSheet::~NewControlsPropSheet() -{ -} - -BEGIN_MESSAGE_MAP(NewControlsPropSheet, CMFCPropertySheet) - ON_WM_QUERYDRAGICON() - ON_WM_SYSCOMMAND() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// NewControlsPropSheet message handlers - -BOOL NewControlsPropSheet::OnInitDialog() -{ - BOOL bResult = CMFCPropertySheet::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - BOOL bValidString; - CString strAboutMenu; - bValidString = strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - return bResult; -} - -HCURSOR NewControlsPropSheet::OnQueryDragIcon() -{ - return(HCURSOR) m_hIcon; -} - -void NewControlsPropSheet::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg aboutDlg; - aboutDlg.DoModal(); - } - else - { - CMFCPropertySheet::OnSysCommand(nID, lParam); - } -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControlsPropSheet.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControlsPropSheet.h deleted file mode 100644 index 802f10e9b186c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/NewControlsPropSheet.h +++ /dev/null @@ -1,55 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "Page1.h" -#include "Page2.h" -#include "Page3.h" -#include "Page4.h" -#include "Page5.h" -#include "Page6.h" - -///////////////////////////////////////////////////////////////////////////// -// NewControlsPropSheet - -class NewControlsPropSheet : public CMFCPropertySheet -{ - DECLARE_DYNAMIC(NewControlsPropSheet) - -// Construction -public: - NewControlsPropSheet(CWnd* pParentWnd = NULL); - -// Attributes -public: - CPage1 m_Page1; - CPage2 m_Page2; - CPage3 m_Page3; - CPage4 m_Page4; - CPage5 m_Page5; - CPage6 m_Page6; - - HICON m_hIcon; - -// Overrides -public: - virtual BOOL OnInitDialog(); - -// Implementation -public: - virtual ~NewControlsPropSheet(); - -protected: - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page1.cpp deleted file mode 100644 index ea9be2d784726..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page1.cpp +++ /dev/null @@ -1,359 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "Page1.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const size_t MAX_TIP_TEXT_LENGTH = 1024; - -///////////////////////////////////////////////////////////////////////////// -// CPage1 property page - -IMPLEMENT_DYNCREATE(CPage1, CMFCPropertyPage) - -CPage1::CPage1() : CMFCPropertyPage(CPage1::IDD) -{ - m_bXPButtons = TRUE; - m_bCheck = TRUE; - m_strToolTip = _T("ToolTip"); - m_iImage = 2; - m_iBorderStyle = 0; - m_iCursor = 0; - m_bMenuStayPressed = FALSE; - m_bRightArrow = FALSE; - m_nImageLocation = 0; - m_bMenuDefaultClick = FALSE; -} - -CPage1::~CPage1() -{ -} - -void CPage1::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); - DDX_Control(pDX, IDC_BUTTON_MULTLINE, m_btnMultiLine); - DDX_Control(pDX, IDC_BORDER, m_wndBorder); - DDX_Control(pDX, IDC_BORDER_LABEL, m_wndBorderLabel); - DDX_Control(pDX, IDC_CHECK_BUTTON, m_btnCheck); - DDX_Control(pDX, IDC_XP_BUTTONS, m_wndXPButtons); - DDX_Check(pDX, IDC_XP_BUTTONS, m_bXPButtons); - DDX_Check(pDX, IDC_CHECK_BUTTON, m_bCheck); - DDX_Control(pDX, IDC_BUTTON, m_Button); - DDX_Text(pDX, IDC_TOOLTIP, m_strToolTip); - DDX_Control(pDX, IDC_TOOLTIP, m_wndToolTip); - DDX_CBIndex(pDX, IDC_IMAGE, m_iImage); - DDX_CBIndex(pDX, IDC_BORDER, m_iBorderStyle); - DDX_CBIndex(pDX, IDC_CURSOR, m_iCursor); - DDX_Control(pDX, IDC_BUTTON_MENU, m_btnMenu); - DDX_Check(pDX, IDC_PRESSED_ON_MENU, m_bMenuStayPressed); - DDX_Check(pDX, IDC_RIGHT_ARROW, m_bRightArrow); - DDX_CBIndex(pDX, IDC_IMAGE_LOCATION, m_nImageLocation); - DDX_Check(pDX, IDC_MENU_DEFAULT_CLICK, m_bMenuDefaultClick); - - DDX_Control(pDX, IDC_RADIO1, m_btnRadio1); - DDX_Control(pDX, IDC_RADIO2, m_btnRadio2); - DDX_Control(pDX, IDC_RADIO3, m_btnRadio3); - DDX_Control(pDX, IDC_RADIO4, m_btnRadio4); -} - -BEGIN_MESSAGE_MAP(CPage1, CMFCPropertyPage) - ON_BN_CLICKED(IDC_XP_BUTTONS, OnXpButtons) - ON_BN_CLICKED(IDC_SET_TOOLTIP, OnSetTooltip) - ON_CBN_SELCHANGE(IDC_CURSOR, OnSetCursor) - ON_BN_CLICKED(IDC_BUTTON, OnButton) - ON_BN_CLICKED(IDC_RIGHT_ARROW, OnRightArrow) - ON_BN_CLICKED(IDC_BUTTON_MENU, OnButtonMenu) - ON_BN_CLICKED(IDC_PRESSED_ON_MENU, OnPressedOnMenu) - ON_COMMAND(ID_DIALOG_ABOUT, OnDialogAbout) - ON_UPDATE_COMMAND_UI(ID_ITEM_2, OnUpdateItem2) - ON_CBN_SELCHANGE(IDC_IMAGE, OnResetButton) - ON_CBN_SELCHANGE(IDC_BORDER, OnResetButton) - ON_CBN_SELCHANGE(IDC_IMAGE, OnResetButton) - ON_CBN_SELCHANGE(IDC_BORDER, OnResetButton) - ON_CBN_SELCHANGE(IDC_IMAGE_LOCATION, OnResetButton) - ON_BN_CLICKED(IDC_MENU_DEFAULT_CLICK, OnMenuDefaultClick) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPage1 message handlers - -void CPage1::OnXpButtons() -{ - UpdateData(); - - CMFCButton::EnableWindowsTheming(m_bXPButtons); - - m_wndBorder.EnableWindow(!m_bXPButtons); - m_wndBorderLabel.EnableWindow(!m_bXPButtons); - - RedrawWindow(); -} - -BOOL CPage1::OnInitDialog() -{ - CMFCPropertyPage::OnInitDialog(); - - if (!CMFCVisualManagerWindows::IsWinXPThemeAvailable()) - { - m_bXPButtons = FALSE; - m_wndXPButtons.EnableWindow(FALSE); - } - else - { - m_wndBorder.EnableWindow(FALSE); - m_wndBorderLabel.EnableWindow(FALSE); - } - - m_Button.m_bTransparent = TRUE; - - OnResetButton(); - OnSetCursor(); - OnSetTooltip(); - - m_menu.LoadMenu(IDR_MENU1); - // - // CMenu m_menu - m_btnMenu.m_hMenu = m_menu.GetSubMenu(0)->GetSafeHmenu(); - m_btnMenu.SizeToContent(); - // set to FALSE so that the framework calls CContextMenuManager::TrackPopupMenu - // to display its menu - m_btnMenu.m_bOSMenu = FALSE; - // - - m_wndToolTip.SetLimitText(MAX_TIP_TEXT_LENGTH); - - m_btnCheck.SetImage(IDB_CHECKNO32); - m_btnCheck.SetCheckedImage(IDB_CHECK32); - m_btnCheck.SizeToContent(); - m_btnCheck.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; - - m_btnRadio1.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; - m_btnRadio2.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; - m_btnRadio3.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; - m_btnRadio4.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; - - m_btnRadio1.SetImage(IDB_RADIO_OFF32); - m_btnRadio2.SetImage(IDB_RADIO_OFF32); - m_btnRadio3.SetImage(IDB_RADIO_OFF32); - m_btnRadio4.SetImage(IDB_RADIO_OFF32); - - m_btnRadio1.SetCheckedImage(IDB_RADIO_ON32); - m_btnRadio2.SetCheckedImage(IDB_RADIO_ON32); - m_btnRadio3.SetCheckedImage(IDB_RADIO_ON32); - m_btnRadio4.SetCheckedImage(IDB_RADIO_ON32); - - m_btnRadio1.SizeToContent(); - m_btnRadio2.SizeToContent(); - m_btnRadio3.SizeToContent(); - m_btnRadio4.SizeToContent(); - - m_btnRadio1.SetCheck(TRUE); - - m_btnMultiLine.SizeToContent(); - - CMFCToolBar::AddToolBarForImageCollection(IDR_TOOLBAR_MENU_IMAGES); - - UpdateData(FALSE); - - return TRUE; // return TRUE unless you set the focus to a control -} - - -void CPage1::OnResetButton() -{ - UpdateData(); - - // - //int m_iBorderStyle - switch (m_iBorderStyle) - { - case 0: - m_Button.m_nFlatStyle = CMFCButton::BUTTONSTYLE_FLAT; - break; - - case 1: - m_Button.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; - break; - - case 2: - m_Button.m_nFlatStyle = CMFCButton::BUTTONSTYLE_3D; - } - // - - // - // int m_iImage - // IDB_BTN1_32, IDB_BTN1_HOT_32, IDB_BTN1, IDB_BTN1_HOT are int macros that are #define. - if (m_iImage == 1) - { - m_Button.SetImage((HBITMAP) NULL); - } - else - { - m_Button.SetImage(IDB_BTN1_32, IDB_BTN1_HOT_32); - } - // - - // - // int m_iImage - if (m_iImage == 0) - { - m_Button.SetWindowText(_T("")); - } - else - { - m_Button.SetWindowText(_T("Button")); - } - // - - switch (m_nImageLocation) - { - case 0: - m_Button.m_bRightImage = FALSE; - m_Button.m_bTopImage = FALSE; - break; - - case 1: - m_Button.m_bRightImage = TRUE; - m_Button.m_bTopImage = FALSE; - break; - - case 2: - m_Button.m_bRightImage = FALSE; - m_Button.m_bTopImage = TRUE; - break; - } - - // - // Resize the button. - m_Button.SizeToContent(); - m_Button.EnableFullTextTooltip(true); - // Use the application menu font at the button text font. - m_Button.EnableMenuFont(); - // Use the current Windows theme to draw the button borders. - m_Button.EnableWindowsTheming(true); - // Set the button to auto-repeat mode. - m_Button.SetAutorepeatMode(); - // Set the background color for the button text. - m_Button.SetFaceColor(RGB(255,0,0),true); - m_Button.SetTextColor(RGB(0,0,255)); - // Set the tooltip of the button. - m_Button.SetTooltip(_T("this is a button!")); - // -} - -// -// int m_iCursor -void CPage1::OnSetCursor() -{ - UpdateData(); - - switch (m_iCursor) - { - case 0: - m_Button.SetMouseCursor(NULL); - break; - - case 1: - m_Button.SetMouseCursorHand(); - break; - - case 2: - m_Button.SetMouseCursor(AfxGetApp()->LoadCursor(IDC_CURSOR)); - break; - } -} -// - -void CPage1::OnButton() -{ - MessageBox(_T("Button Clicked!")); -} - -void CPage1::OnSetTooltip() -{ - UpdateData(); - m_Button.SetTooltip(m_strToolTip); -} - -void CPage1::OnPressedOnMenu() -{ - UpdateData(); - m_btnMenu.m_bStayPressed = m_bMenuStayPressed; -} - -void CPage1::OnRightArrow() -{ - UpdateData(); - m_btnMenu.m_bRightArrow = m_bRightArrow; - m_btnMenu.Invalidate(); -} - -void CPage1::OnButtonMenu() -{ - CString strItem; - - switch (m_btnMenu.m_nMenuResult) - { - case ID_ITEM_1: - strItem = _T("Item 1"); - break; - - case ID_ITEM_2: - strItem = _T("Item 2"); - break; - - case ID_ITEM_3: - strItem = _T("Item 3"); - break; - - case ID_ITEM_4: - strItem = _T("Item 4"); - break; - - default: - if (!m_bMenuDefaultClick) - { - return; - } - - strItem = _T("Default Menu Button Action"); - break; - } - - MessageBox(strItem); -} - -void CPage1::OnDialogAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -void CPage1::OnUpdateItem2(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(); -} - -void CPage1::OnMenuDefaultClick() -{ - UpdateData(); - - m_btnMenu.m_bDefaultClick = m_bMenuDefaultClick; - m_btnMenu.RedrawWindow(); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page1.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page1.h deleted file mode 100644 index 9ee6994690bea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page1.h +++ /dev/null @@ -1,81 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CPage1 dialog - -class CPage1 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CPage1) - -// Construction -public: - CPage1(); - ~CPage1(); - -// Dialog Data - enum { IDD = IDD_PAGE1 }; - CMFCButton m_btnMultiLine; - CComboBox m_wndBorder; - CStatic m_wndBorderLabel; - CMFCButton m_btnCheck; - CButton m_wndXPButtons; - BOOL m_bXPButtons; - BOOL m_bCheck; - - // - CMFCButton m_Button; - // - CString m_strToolTip; - CEdit m_wndToolTip; - int m_iFrameRate; - int m_iImage; - int m_iBorderStyle; - int m_iCursor; - // - CMFCMenuButton m_btnMenu; - // - BOOL m_bMenuStayPressed; - BOOL m_bRightArrow; - int m_nImageLocation; - BOOL m_bMenuDefaultClick; - - - CMFCButton m_btnRadio1; - CMFCButton m_btnRadio2; - CMFCButton m_btnRadio3; - CMFCButton m_btnRadio4; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - virtual BOOL OnInitDialog(); - - afx_msg void OnXpButtons(); - afx_msg void OnSetTooltip(); - afx_msg void OnSetCursor(); - afx_msg void OnButton(); - afx_msg void OnRightArrow(); - afx_msg void OnButtonMenu(); - afx_msg void OnPressedOnMenu(); - afx_msg void OnDialogAbout(); - afx_msg void OnUpdateItem2(CCmdUI* pCmdUI); - afx_msg void OnResetButton(); - afx_msg void OnMenuDefaultClick(); - - DECLARE_MESSAGE_MAP() - - CMenu m_menu; -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page2.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page2.cpp deleted file mode 100644 index 0664656bb93f8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page2.cpp +++ /dev/null @@ -1,244 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "Page2.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPage2 property page - -IMPLEMENT_DYNCREATE(CPage2, CMFCPropertyPage) - -CPage2::CPage2() : CMFCPropertyPage(CPage2::IDD) -{ - m_strRGB = _T("255, 0, 255"); - m_strRGBColorBar = _T("0, 0, 0"); - m_strRGBColorBar2 = _T("0, 0, 255"); - m_strRGBColorDialog = _T("255, 0, 255"); - m_strRGBColorPalette = _T("0, 255, 0"); - m_Color = RGB(255, 0, 255); -} - -CPage2::~CPage2() -{ -} - -void CPage2::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); - DDX_Control(pDX, IDC_LUM, m_wndLum); - DDX_Control(pDX, IDC_COLOR_PALETTE, m_wndColorPalette); - DDX_Control(pDX, IDC_COLORBAR2, m_wndColorBarFrame2); - DDX_Control(pDX, IDC_COLORBAR, m_wndColorBarFrame); - DDX_Control(pDX, IDC_COLOR_PICKER, m_ColorPicker); - DDX_Text(pDX, IDC_RGB, m_strRGB); - DDX_Text(pDX, IDC_RGB_COLOR_BAR, m_strRGBColorBar); - DDX_Text(pDX, IDC_RGB_COLOR_BAR2, m_strRGBColorBar2); - DDX_Text(pDX, IDC_RGB_DLG, m_strRGBColorDialog); - DDX_Text(pDX, IDC_RGB_COLOR_PALETTE, m_strRGBColorPalette); -} - -BEGIN_MESSAGE_MAP(CPage2, CMFCPropertyPage) - ON_BN_CLICKED(IDC_COLOR_DLG, OnColorDlg) - ON_BN_CLICKED(IDC_COLOR_PICKER, OnColorPicker) - ON_BN_CLICKED(IDC_COLOR_PALETTE, OnColorPalette) - ON_BN_CLICKED(IDC_LUM, OnLum) - ON_COMMAND(IDC_COLORBAR, OnColorBar) - ON_COMMAND(IDC_COLORBAR2, OnColorBar2) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPage2 message handlers - -BOOL CPage2::OnInitDialog() -{ - CMFCPropertyPage::OnInitDialog(); - - // Create color picker: - m_ColorPicker.EnableAutomaticButton(_T("Automatic"), RGB(255, 0, 255)); - m_ColorPicker.EnableOtherButton(_T("Other")); - m_ColorPicker.SetColor((COLORREF)-1); - m_ColorPicker.SetColumnsNumber(10); - - // Create regular color bar: - CRect rectColorBar; - m_wndColorBarFrame.GetClientRect(&rectColorBar); - m_wndColorBarFrame.MapWindowPoints(this, &rectColorBar); - - // - // set the margins - m_wndColorBar.SetHorzMargin(0); - m_wndColorBar.SetVertMargin(0); - // enable the display of a dialog box that - // lets the user select more colors - m_wndColorBar.EnableOtherButton(_T("Other...")); - // create a color bar control window - m_wndColorBar.CreateControl(this, rectColorBar, IDC_COLORBAR, 5 /* columns */); - // set the currently selected color - m_wndColorBar.SetColor(RGB(255, 0, 0)); - // - - // Create regular color bar with the custom palette: - m_wndColorBarFrame2.GetClientRect(&rectColorBar); - m_wndColorBarFrame2.MapWindowPoints(this, &rectColorBar); - - // Create the palette -#define NUM_COLOURS 64 - struct - { - LOGPALETTE LogPalette; - PALETTEENTRY PalEntry[NUM_COLOURS]; - }pal; - - LOGPALETTE* pLogPalette = (LOGPALETTE*) &pal; - pLogPalette->palVersion = 0x300; - pLogPalette->palNumEntries = (WORD) NUM_COLOURS; - - COLORREF colorStart = RGB(0, 0, 255); - COLORREF colorFinish = RGB(255, 255, 255); - - int nShift = 6; - for (int i = 0; i < NUM_COLOURS; i++) - { - BYTE bR = (BYTE)((GetRValue(colorStart) *(NUM_COLOURS - i) + GetRValue(colorFinish) * i) >> nShift); - BYTE bG = (BYTE)((GetGValue(colorStart) *(NUM_COLOURS - i) + GetGValue(colorFinish) * i) >> nShift); - BYTE bB = (BYTE)((GetBValue(colorStart) *(NUM_COLOURS - i) + GetBValue(colorFinish) * i) >> nShift); - - pLogPalette->palPalEntry[i].peRed = bR; - pLogPalette->palPalEntry[i].peGreen = bG; - pLogPalette->palPalEntry[i].peBlue = bB; - pLogPalette->palPalEntry[i].peFlags = 0; - } - - m_palColorPicker.CreatePalette(pLogPalette); - m_wndColorBar2.SetHorzMargin(0); - m_wndColorBar2.SetVertMargin(0); - - m_wndColorBar2.CreateControl(this, rectColorBar, IDC_COLORBAR2, -1 /* columns */, &m_palColorPicker); - m_wndColorBar2.SetColor(colorStart); - - // Create system palette: - CClientDC dc(this); - - int nColors = 256; // Use 256 first entries - UINT nSize = sizeof(LOGPALETTE) +(sizeof(PALETTEENTRY) * nColors); - LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize]; - - pLP->palVersion = 0x300; - pLP->palNumEntries = (USHORT) nColors; - - ::GetSystemPaletteEntries(dc.GetSafeHdc(), 0, nColors, pLP->palPalEntry); - - m_palSys.CreatePalette(pLP); - - delete[] pLP; - - m_wndColorPalette.SetType(CMFCColorPickerCtrl::PICKER); - m_wndColorPalette.SetPalette(&m_palSys); - m_wndColorPalette.SetColor(RGB(0, 255, 0)); - - // - // CPalette m_palSys - // set the type of the color picker control - m_wndLum.SetType(CMFCColorPickerCtrl::LUMINANCE); - m_wndLum.SetPalette(&m_palSys); - // set the color, hue, luminance and saturation of the color picker control - m_wndLum.SetColor(RGB(0, 255, 0)); - m_wndLum.SetHue(0.5); - m_wndLum.SetLuminance(2.5); - m_wndLum.SetLuminanceBarWidth(10); - m_wndLum.SetSaturation(0.5); - // - - UpdateData(FALSE); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} -void CPage2::OnColorDlg() -{ - // - // COLORREF m_Color - CMFCColorDialog dlg(m_Color, 0, this); - dlg.SetCurrentColor(RGB(0,255,0)); - dlg.SetNewColor(RGB(0,0,255)); - // set the red, green, and blue components of a selected - // color on the two property pages of the color dialog - dlg.SetPageOne(255,0,0); - dlg.SetPageTwo(0,255,0); - // - - if (dlg.DoModal() == IDOK) - { - m_Color = dlg.GetColor(); - - m_strRGBColorDialog.Format(_T("%d,%d,%d"), GetRValue(m_Color), GetGValue(m_Color), GetBValue(m_Color)); - - UpdateData(FALSE); - } - -} - -void CPage2::OnColorPicker() -{ - COLORREF color = m_ColorPicker.GetColor(); - if (color == -1) - { - color = m_ColorPicker.GetAutomaticColor(); - } - - m_strRGB.Format(_T("%d,%d,%d"), GetRValue(color), GetGValue(color), GetBValue(color)); - - UpdateData(FALSE); -} - -void CPage2::OnColorBar() -{ - COLORREF color = m_wndColorBar.GetColor(); - - m_strRGBColorBar.Format(_T("%d,%d,%d"), GetRValue(color), GetGValue(color), GetBValue(color)); - - UpdateData(FALSE); -} - -void CPage2::OnColorBar2() -{ - COLORREF color = m_wndColorBar2.GetColor(); - - m_strRGBColorBar2.Format(_T("%d,%d,%d"), GetRValue(color), GetGValue(color), GetBValue(color)); - - UpdateData(FALSE); -} - -void CPage2::OnColorPalette() -{ - COLORREF color = m_wndColorPalette.GetColor(); - - m_strRGBColorPalette.Format(_T("%d,%d,%d"), GetRValue(color), GetGValue(color), GetBValue(color)); - - m_wndLum.SetColor(color); - UpdateData(FALSE); -} - -void CPage2::OnLum() -{ - COLORREF color = m_wndLum.GetColor(); - - m_strRGBColorPalette.Format(_T("%d,%d,%d"), GetRValue(color), GetGValue(color), GetBValue(color)); - - m_wndColorPalette.SetLuminance(m_wndLum.GetLuminance()); - UpdateData(FALSE); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page2.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page2.h deleted file mode 100644 index 0923bb2ad9610..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page2.h +++ /dev/null @@ -1,69 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CPage2 dialog - -class CPage2 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CPage2) - -// Construction -public: - CPage2(); - ~CPage2(); - -// Dialog Data - enum { IDD = IDD_PAGE2 }; - - // - CMFCColorPickerCtrl m_wndLum; - // - - CMFCColorPickerCtrl m_wndColorPalette; - CStatic m_wndColorBarFrame2; - CStatic m_wndColorBarFrame; - CMFCColorButton m_ColorPicker; - CString m_strRGB; - CString m_strRGBColorBar; - CString m_strRGBColorBar2; - CString m_strRGBColorDialog; - CString m_strRGBColorPalette; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - virtual BOOL OnInitDialog(); - - afx_msg void OnColorDlg(); - afx_msg void OnColorPicker(); - afx_msg void OnColorPalette(); - afx_msg void OnLum(); - afx_msg void OnColorBar(); - afx_msg void OnColorBar2(); - - DECLARE_MESSAGE_MAP() - - COLORREF m_Color; - - // - CMFCColorBar m_wndColorBar; - // - - CMFCColorBar m_wndColorBar2; - - CPalette m_palColorPicker; - CPalette m_palSys; -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page3.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page3.cpp deleted file mode 100644 index 00f4a9cbd72c6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page3.cpp +++ /dev/null @@ -1,199 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "Page3.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPage3 property page - -IMPLEMENT_DYNCREATE(CPage3, CMFCPropertyPage) - -CPage3::CPage3() : CMFCPropertyPage(CPage3::IDD) -{ - m_bTrueType = TRUE; - m_bRaster = TRUE; - m_bDeviceFont = TRUE; - m_bDrawUsingFont = FALSE; -} - -CPage3::~CPage3() -{ -} - -void CPage3::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); - DDX_Control(pDX, IDC_CUSTOM_EDIT, m_wndCustomEdit); - DDX_Control(pDX, IDC_FOLDER_EDIT, m_wndFolderEdit); - DDX_Control(pDX, IDC_FILE_EDIT, m_wndFileEdit); - DDX_Control(pDX, IDC_FONT, m_wndFont); - DDX_Control(pDX, IDC_IMAGE_AREA, m_wndImageArea); - DDX_Control(pDX, IDC_EDIT_IMAGE, m_btnImageEdit); - DDX_Control(pDX, IDC_BUTTON_URL, m_btnLink); - DDX_Control(pDX, IDC_EDIT_LIST, m_wndEditListBox); - DDX_Check(pDX, IDC_TRUETYPE, m_bTrueType); - DDX_Check(pDX, IDC_RASTER, m_bRaster); - DDX_Check(pDX, IDC_DEVICE, m_bDeviceFont); - DDX_Check(pDX, IDC_DRAW_USING_FONT, m_bDrawUsingFont); -} - -BEGIN_MESSAGE_MAP(CPage3, CMFCPropertyPage) - ON_BN_CLICKED(IDC_EDIT_IMAGE, OnEditImage) - ON_WM_PAINT() - ON_BN_CLICKED(IDC_RASTER, OnFontType) - ON_BN_CLICKED(IDC_TRUETYPE, OnFontType) - ON_BN_CLICKED(IDC_DEVICE, OnFontType) - ON_BN_CLICKED(IDC_DRAW_USING_FONT, OnDrawUsingFont) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPage3 message handlers - -BOOL CPage3::OnInitDialog() -{ - CMFCPropertyPage::OnInitDialog(); - - m_wndEditListBox.SetStandardButtons(); - m_wndEditListBox.EnableBrowseButton(); - - m_wndEditListBox.AddItem(_T("Item 1")); - m_wndEditListBox.AddItem(_T("Item 2")); - m_wndEditListBox.AddItem(_T("Item 3")); - - // - m_btnLink.SetURL(_T("http://www.microsoft.com")); - m_btnLink.SetTooltip(_T("Visit Microsoft site")); - // resize the button to contain the button text or bitmap - m_btnLink.SizeToContent(); - // - - m_btnImageEdit.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT; - m_btnImageEdit.SetImage(IDB_IMAGE); - m_btnImageEdit.SizeToContent(); - m_btnImageEdit.SetTextHotColor(RGB(0, 0, 255)); - - m_bmpImage.LoadBitmap(IDB_TEST_BITMAP); - - BITMAP bmp; - m_bmpImage.GetBitmap(&bmp); - - m_wndImageArea.GetClientRect(m_rectImage); - m_wndImageArea.MapWindowPoints(this, m_rectImage); - - m_rectImage.right = m_rectImage.left + bmp.bmWidth; - m_rectImage.bottom = m_rectImage.top + bmp.bmHeight; - - // - m_wndFont.SelectFont(_T("Arial")); - // - - // - // enable the browse button and put the control in file browse mode - m_wndFolderEdit.EnableFolderBrowseButton(); - // enable the browse button and put the control in the folder browse mode - m_wndFileEdit.EnableFileBrowseButton(); - // - - m_wndCustomEdit.EnableBrowseButton(); - - UpdateData(FALSE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CPage3::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectFrame = m_rectImage; - - rectFrame.InflateRect(1, 1); - dc.Draw3dRect(rectFrame, GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_3DSHADOW)); - rectFrame.InflateRect(1, 1); - dc.Draw3dRect(rectFrame, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW)); - - dc.DrawState(m_rectImage.TopLeft(), m_rectImage.Size(), &m_bmpImage, 0); -} - -void CPage3::OnEditImage() -{ - // - // CBitmap m_bmpImage - HBITMAP hBmpCopy = (HBITMAP) ::CopyImage(m_bmpImage.GetSafeHandle(), IMAGE_BITMAP, 0, 0, 0); - // - ASSERT(hBmpCopy != NULL); - - if (hBmpCopy) - { - // - // this points to Page3 class which extends the CMFCPropertyPage class - CMFCImageEditorDialog dlg(CBitmap::FromHandle(hBmpCopy), this); - // - - if (dlg.DoModal() == IDOK) - { - m_bmpImage.DeleteObject(); - m_bmpImage.Attach(hBmpCopy); - - InvalidateRect(m_rectImage); - UpdateWindow(); - } - else - { - ::DeleteObject(hBmpCopy); - } - } -} - -void CPage3::OnFontType() -{ - UpdateData(); - - // - // specify the font type - // BOOL m_bTrueType: true font type - // BOOL m_bRaster: raster font type - // BOOL m_bDeviceFont: device font type - int nFontType = 0; - - if (m_bTrueType) - { - nFontType |= TRUETYPE_FONTTYPE; - } - - if (m_bRaster) - { - nFontType |= RASTER_FONTTYPE; - } - - if (m_bDeviceFont) - { - nFontType |= DEVICE_FONTTYPE; - } - - CWaitCursor wait; - m_wndFont.Setup(nFontType); - // -} - -void CPage3::OnDrawUsingFont() -{ - UpdateData(); - CMFCFontComboBox::m_bDrawUsingFont = m_bDrawUsingFont; - m_wndFont.RedrawWindow(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page3.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page3.h deleted file mode 100644 index 750d7bd2979a5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page3.h +++ /dev/null @@ -1,93 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CCustomEditListBox : public CVSListBox -{ - virtual void OnBrowse() - { - int nSel = GetSelItem(); - - MessageBox(_T("Browse item...")); - - if (nSel == GetCount()) // New item - { - nSel = AddItem(_T("New text")); - SelectItem(nSel); - } - else - { - SetItemText(nSel, _T("Updated text")); - } - } -}; - -class CMyBrowseEdit : public CMFCEditBrowseCtrl -{ - virtual void OnBrowse() - { - MessageBox(_T("Browse item...")); - SetWindowText(_T("New value!")); - } -}; - -///////////////////////////////////////////////////////////////////////////// -// CPage3 dialog - -class CPage3 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CPage3) - -// Construction -public: - CPage3(); - ~CPage3(); - -// Dialog Data - enum { IDD = IDD_PAGE3 }; - CMyBrowseEdit m_wndCustomEdit; - - // - CMFCEditBrowseCtrl m_wndFolderEdit; - CMFCEditBrowseCtrl m_wndFileEdit; - // - - // - CMFCFontComboBox m_wndFont; - // - - CStatic m_wndImageArea; - CMFCButton m_btnImageEdit; - // - CMFCLinkCtrl m_btnLink; - // - CCustomEditListBox m_wndEditListBox; - BOOL m_bTrueType; - BOOL m_bRaster; - BOOL m_bDeviceFont; - BOOL m_bDrawUsingFont; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - afx_msg void OnEditImage(); - virtual BOOL OnInitDialog(); - afx_msg void OnPaint(); - afx_msg void OnFontType(); - afx_msg void OnDrawUsingFont(); - - DECLARE_MESSAGE_MAP() - - CRect m_rectImage; - CBitmap m_bmpImage; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page4.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page4.cpp deleted file mode 100644 index a8c05dc6498ae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page4.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "Page4.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPage4 property page - -IMPLEMENT_DYNCREATE(CPage4, CMFCPropertyPage) - -CPage4::CPage4() : CMFCPropertyPage(CPage4::IDD) -{ - m_strValue1 = _T(""); - m_strValue2 = _T(""); - m_strValue3 = _T(""); - m_strValue4 = _T(""); - m_strValue5 = _T(""); -} - -CPage4::~CPage4() -{ -} - -void CPage4::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); - DDX_Control(pDX, IDC_MASKEDIT5, m_wndMaskEdit5); - DDX_Control(pDX, IDC_MASKEDIT4, m_wndMaskEdit4); - DDX_Control(pDX, IDC_MASKEDIT3, m_wndMaskEdit3); - DDX_Control(pDX, IDC_MASKEDIT2, m_wndMaskEdit2); - DDX_Control(pDX, IDC_MASKEDIT1, m_wndMaskEdit1); - DDX_Text(pDX, IDC_VALUE1, m_strValue1); - DDX_Text(pDX, IDC_VALUE2, m_strValue2); - DDX_Text(pDX, IDC_VALUE3, m_strValue3); - DDX_Text(pDX, IDC_VALUE4, m_strValue4); - DDX_Text(pDX, IDC_VALUE5, m_strValue5); -} - -BEGIN_MESSAGE_MAP(CPage4, CMFCPropertyPage) - ON_BN_CLICKED(IDC_BUTTON1, OnButtonGet) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPage4 message handlers - -// -BOOL CPage4::OnInitDialog() -{ - CMFCPropertyPage::OnInitDialog(); - - // Mask 1: phone number - m_wndMaskEdit1.EnableMask(_T(" ddd ddd dddd"), // The mask string - _T("(___) ___-____"), // Literal, "_" char = character entry - _T(' ')); // Default char - m_wndMaskEdit1.SetValidChars(NULL); // Valid string characters - m_wndMaskEdit1.SetWindowText(_T("(123) 123-1212")); - - // Mask 2: State, Zip Code - m_wndMaskEdit2.EnableMask(_T(" cc ddddd-dddd"), // The mask string - _T("State: __, Zip: _____-____"), // Literal, "_" char = character entry - _T(' ')); // Backspace replace char - m_wndMaskEdit2.SetValidChars(NULL); // Valid string characters - m_wndMaskEdit2.SetWindowText(_T("State: NY, Zip: 12345-6789")); - // Mask 3: serial code - m_wndMaskEdit3.EnableMask(_T(" AAAA AAAA AAAA AAAA"), // The mask string - _T("S/N: ____-____-____-____"), // Literal, "_" char = character entry - _T('_')); // Backspace replace char - m_wndMaskEdit3.SetValidChars(NULL); // Valid string characters - m_wndMaskEdit3.SetWindowText(_T("S/N: FPR5-5678-1234-8765")); - - // Mask 4: 0xFFFF - m_wndMaskEdit4.EnableMask(_T(" AAAA"), // The mask string - _T("0x____"), // Literal, "_" char = character entry - _T('_')); // Backspace replace char - m_wndMaskEdit4.SetValidChars(_T("1234567890ABCDEFabcdef")); // Valid string characters - m_wndMaskEdit4.SetWindowText(_T("0x01AF")); - - // Mask 5: digits only - m_wndMaskEdit5.DisableMask(); // Don't use the mask - m_wndMaskEdit5.SetValidChars(_T("1234567890")); // Valid string characters - m_wndMaskEdit5.SetWindowText(_T("1234567890")); - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CPage4::OnButtonGet() -{ - m_wndMaskEdit1.GetWindowText(m_strValue1); - m_wndMaskEdit2.GetWindowText(m_strValue2); - m_wndMaskEdit3.GetWindowText(m_strValue3); - m_wndMaskEdit4.GetWindowText(m_strValue4); - m_wndMaskEdit5.GetWindowText(m_strValue5); - UpdateData(FALSE); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page4.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page4.h deleted file mode 100644 index dc9c706b38578..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page4.h +++ /dev/null @@ -1,52 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CPage4 dialog - -class CPage4 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CPage4) - -// Construction -public: - CPage4(); - ~CPage4(); - -// Dialog Data - enum { IDD = IDD_PAGE4 }; - - // - CMFCMaskedEdit m_wndMaskEdit1; - CMFCMaskedEdit m_wndMaskEdit2; - CMFCMaskedEdit m_wndMaskEdit3; - CMFCMaskedEdit m_wndMaskEdit4; - CMFCMaskedEdit m_wndMaskEdit5; - - CString m_strValue1; - CString m_strValue2; - CString m_strValue3; - CString m_strValue4; - CString m_strValue5; - // - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - virtual BOOL OnInitDialog(); - afx_msg void OnButtonGet(); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page5.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page5.cpp deleted file mode 100644 index d125c85e9375a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page5.cpp +++ /dev/null @@ -1,464 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "CustomProperties.h" -#include "Page5.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPage5 property page - -IMPLEMENT_DYNCREATE(CPage5, CMFCPropertyPage) - -CPage5::CPage5() : CMFCPropertyPage(CPage5::IDD) -{ - m_bDescrArea = TRUE; - m_bDotNetLook = TRUE; - m_bHeader = TRUE; - m_bMarkSortedColumn = TRUE; - m_bColor = TRUE; - m_bModifyFont = TRUE; - m_bPropListCustomColors = FALSE; - m_bPropListCategorized = TRUE; - m_bShowDragContext = TRUE; - m_bMarkChanged = TRUE; - m_bHideFontProps = FALSE; - - m_wndList.m_bColor = TRUE; - m_wndList.m_bModifyFont = TRUE; - - pGroupFont = NULL; -} - -CPage5::~CPage5() -{ -} - -void CPage5::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); - DDX_Control(pDX, IDC_PROPLIST_EXPAND_ALL, m_btnExpandAll); - DDX_Control(pDX, IDC_PROPLIST_LOCATION, m_wndPropListLocation); - DDX_Control(pDX, IDC_LIST1, m_wndList); - DDX_Check(pDX, IDC_DESCRIPTION_AREA, m_bDescrArea); - DDX_Check(pDX, IDC_DOT_NET_LOOK, m_bDotNetLook); - DDX_Check(pDX, IDC_HEADER, m_bHeader); - DDX_Check(pDX, IDC_MARK_SORTED_COLUMN, m_bMarkSortedColumn); - DDX_Check(pDX, IDC_COLOR_ROWS, m_bColor); - DDX_Check(pDX, IDC_MODIFY_FONT, m_bModifyFont); - DDX_Check(pDX, IDC_CUSTOM_COLORS, m_bPropListCustomColors); - DDX_Check(pDX, IDC_PROPLIST_CATEGORIZED, m_bPropListCategorized); - DDX_Check(pDX, IDC_PROPLIST_CATEGORIZED2, m_bShowDragContext); - DDX_Check(pDX, IDC_MARK_CHANGED, m_bMarkChanged); - DDX_Check(pDX, IDC_HIDE_FONT_PROPS, m_bHideFontProps); -} - -BEGIN_MESSAGE_MAP(CPage5, CMFCPropertyPage) - ON_BN_CLICKED(IDC_HEADER, OnHeader) - ON_BN_CLICKED(IDC_DOT_NET_LOOK, OnDotNetLook) - ON_BN_CLICKED(IDC_DESCRIPTION_AREA, OnDescriptionArea) - ON_BN_CLICKED(IDC_MARK_SORTED_COLUMN, OnMarkSortedColumn) - ON_BN_CLICKED(IDC_COLOR_ROWS, OnColorRows) - ON_BN_CLICKED(IDC_MODIFY_FONT, OnModifyFont) - ON_BN_CLICKED(IDC_CUSTOM_COLORS, OnPropListCustomColors) - ON_BN_CLICKED(IDC_PROPLIST_EXPAND_ALL, OnProplistExpandAll) - ON_BN_CLICKED(IDC_PROPLIST_CATEGORIZED, OnProplistCategorized) - ON_BN_CLICKED(IDC_PROPLIST_CATEGORIZED2, OnProplistCategorized2) - ON_BN_CLICKED(IDC_RESET_VALUES, OnResetValues) - ON_BN_CLICKED(IDC_MARK_CHANGED, OnMarkChanged) - ON_BN_CLICKED(IDC_HIDE_FONT_PROPS, OnHideFontProps) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPage5 message handlers - -const int nColumns = 3; -const int nRows = 50; - -BOOL CPage5::OnInitDialog() -{ - CMFCPropertyPage::OnInitDialog(); - - m_wndList.InsertColumn(0, _T("#"), LVCFMT_LEFT, 20); - - int nColumn; - for (nColumn = 1; nColumn < nColumns; nColumn++) - { - m_wndList.InsertColumn(nColumn, CString((TCHAR)(_T('A') + nColumn - 1)), LVCFMT_LEFT, 60 + nColumn * 10); - } - - for (int i = 0; i < nRows; i++) - { - CString str; - str.Format(_T("%d"), i); - m_wndList.InsertItem(i, str); - m_wndList.SetItemData(i, i); - - for (nColumn = 1; nColumn < nColumns; nColumn++) - { - str.Format(_T("Item(%d, %d)"), nColumn - 1, nColumn == 1 ? 99 - i : i + 50); - m_wndList.SetItemText(i, nColumn, str); - } - } - - m_wndList.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); - m_wndList.EnableMarkSortedColumn(); - - CRect rectPropList; - m_wndPropListLocation.GetClientRect(&rectPropList); - m_wndPropListLocation.MapWindowPoints(this, &rectPropList); - - // - // CRect rectPropList - // CMFCPropertyGridCtrl m_wndPropList - // The this pointer points to a CPage5 class which extends the CMFCPropertyPage class. - m_wndPropList.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, rectPropList, this, (UINT)-1); - // - - // - m_wndPropList.EnableHeaderCtrl(); - m_wndPropList.EnableDescriptionArea(); - m_wndPropList.SetVSDotNetLook(m_bDotNetLook); - // BOOL m_bMarkChanged - m_wndPropList.MarkModifiedProperties(m_bMarkChanged); - // BOOL m_bPropListCategorized - m_wndPropList.SetAlphabeticMode(!m_bPropListCategorized); - // BOOL m_bShowDragContext - m_wndPropList.SetShowDragContext(m_bShowDragContext); - // - - // - CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Appearance")); - - // construct a COleVariant object. - COleVariant var3DLook((short)VARIANT_FALSE, VT_BOOL); - - pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("3D Look"), var3DLook, - _T("Specifies the dialog's font will be nonbold and controls will have a 3D border"))); - - CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Border"), - _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame")); - pProp->AddOption(_T("None")); - pProp->AddOption(_T("Thin")); - pProp->AddOption(_T("Resizable")); - pProp->AddOption(_T("Dialog Frame")); - pProp->AllowEdit(FALSE); - - pGroup1->AddSubItem(pProp); - pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (COleVariant) _T("About NewControlsDemo"), _T("Specifies the text that will be displayed in the dialog's title bar"))); - pGroup1->AdjustButtonRect(); - pGroup1->AllowEdit(); - pGroup1->Enable(); - pGroup1->Show(); - pGroup1->Redraw(); - // - m_wndPropList.AddProperty(pGroup1); - - CMFCPropertyGridProperty* pSize = new CBoundedNumberPairProp(_T("Window Size"), 0, 300, 0, 200, 0, TRUE); - - pProp = new CBoundedNumberSubProp(_T("Height"), (COleVariant) 250l, 0, 300, _T("Specifies the dialog's height")); - pProp->EnableSpinControl(TRUE, 0, 300); - pSize->AddSubItem(pProp); - - pProp = new CBoundedNumberSubProp( _T("Width"), (COleVariant) 150l, 0, 200, _T("Specifies the dialog's width")); - pProp->EnableSpinControl(TRUE, 0, 200); - pSize->AddSubItem(pProp); - - m_wndPropList.AddProperty(pSize); - - pGroupFont = new CMFCPropertyGridProperty(_T("Font")); - - LOGFONT lf; - CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); - font->GetLogFont(&lf); - lstrcpy(lf.lfFaceName, _T("Arial")); - - // - // LOGFONT lf - // CMFCPropertyGridProperty* pGroupFont - pGroupFont->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the dialog"))); - // - - pGroupFont->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (COleVariant)VARIANT_TRUE, _T("Specifies that the dialog uses MS Shell Dlg font"))); - - m_wndPropList.AddProperty(pGroupFont); - - CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("Misc")); - pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("IDD_ABOUT_BOX(dialog)")); - pProp->Enable(FALSE); - pGroup3->AddSubItem(pProp); - - // - CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default dialog color")); - pColorProp->EnableOtherButton(_T("Other...")); - pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE)); - pColorProp->SetColor(RGB(255,0,0)); - pColorProp->SetColumnsNumber(3); - // - pGroup3->AddSubItem(pColorProp); - - static TCHAR BASED_CODE szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||"); - pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the dialog icon"))); - - pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\"))); - - pGroup3->AddSubItem(new CMFCPropertyGridProperty(_T("Phone"), _T("(123) 123-12-12"), _T("Enter a phone number"), 0, _T(" ddd ddd dd dd"), _T("(___) ___-__-__"))); - - m_wndPropList.AddProperty(pGroup3); - - CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("Hierarchy")); - - CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level")); - pGroup4->AddSubItem(pGroup41); - - CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level")); - pGroup41->AddSubItem(pGroup411); - - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (COleVariant) _T("Value 1"), _T("This is a description"))); - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (COleVariant) _T("Value 2"), _T("This is a description"))); - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (COleVariant) _T("Value 3"), _T("This is a description"))); - - pGroup4->Expand(FALSE); - m_wndPropList.AddProperty(pGroup4); - - // Add custom properties: - CMFCPropertyGridProperty* pGroup5 = new CMFCPropertyGridProperty(_T("Custom Properties")); - - pGroup5->AddSubItem(new CCheckBoxProp(_T("Check Box"), TRUE, _T("Check Box Property"))); - - pGroup5->AddSubItem(new CPasswordProp(_T("Password"), _T("123456"), _T("Password Property"))); - - pGroup5->AddSubItem(new CSliderProp(_T("Slider"), 0, _T("Slider Property"))); - - CBitmap bmp; - bmp.LoadBitmap(IDB_PROPICONS); - - m_imageList.Create(16, 16, ILC_MASK | ILC_COLOR24, 0, 0); - m_imageList.Add(&bmp, RGB(192, 192, 192)); - - CStringList lstIconNames; - lstIconNames.AddTail(_T("Icon 1")); - lstIconNames.AddTail(_T("Icon 2")); - lstIconNames.AddTail(_T("Icon 3")); - lstIconNames.AddTail(_T("Icon 4")); - lstIconNames.AddTail(_T("Icon 5")); - lstIconNames.AddTail(_T("Icon 6")); - lstIconNames.AddTail(_T("Icon 7")); - lstIconNames.AddTail(_T("Icon 8")); - lstIconNames.AddTail(_T("Icon 9")); - lstIconNames.AddTail(_T("Icon 10")); - - pGroup5->AddSubItem(new CIconListProp(_T("Icon List"), m_imageList, 0, &lstIconNames, _T("Icon List Property"))); - - CComboBoxExProp* pComboEx = new CComboBoxExProp(_T("ComboBoxEx"), _T("Test"), _T("ComboBoxEx Property"), 0, &m_imageList); - pComboEx->AddOption(_T("New"), 0, 0); - pComboEx->AddOption(_T("Open"), 1, 1); - pComboEx->AddOption(_T("Save"), 2, 0); - - pGroup5->AddSubItem(pComboEx); - - pGroup5->AddSubItem(new COwnerDrawDescrProp(_T("Owner-draw descr."), 0l)); - pGroup5->AddSubItem(new CTwoButtonsProp(_T("2 Buttons"), _T("text"))); - pGroup5->AddSubItem(new CCustomDlgProp(_T("Custom Dialog"), _T("value"))); - - m_wndPropList.AddProperty(pGroup5); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CPage5::OnHeader() -{ - UpdateData(); - // - // BOOL m_bHeader - m_wndPropList.EnableHeaderCtrl(m_bHeader); - // -} - -void CPage5::OnDotNetLook() -{ - UpdateData(); - // - // BOOL m_bDOtNetLook - m_wndPropList.SetVSDotNetLook(m_bDotNetLook); - // -} - -void CPage5::OnDescriptionArea() -{ - UpdateData(); - // - m_wndPropList.EnableDescriptionArea(m_bDescrArea); - // -} - -void CPage5::OnMarkSortedColumn() -{ - UpdateData(); - // - // BOOL m_bMarkSortedColumn - m_wndList.EnableMarkSortedColumn(m_bMarkSortedColumn); - // -} - -COLORREF CMyListCtrl::OnGetCellTextColor(int nRow, int nColum) -{ - if (!m_bColor) - { - return CMFCListCtrl::OnGetCellTextColor(nRow, nColum); - } - - return(nRow % 2) == 0 ? RGB(128, 37, 0) : RGB(0, 0, 0); -} - -COLORREF CMyListCtrl::OnGetCellBkColor(int nRow, int nColum) -{ - if (!m_bColor) - { - return CMFCListCtrl::OnGetCellBkColor(nRow, nColum); - } - - if (m_bMarkSortedColumn && nColum == m_iSortedColumn) - { - return(nRow % 2) == 0 ? RGB(233, 221, 229) : RGB(176, 218, 234); - } - - return(nRow % 2) == 0 ? RGB(253, 241, 249) : RGB(196, 238, 254); -} - -HFONT CMyListCtrl::OnGetCellFont(int nRow, int nColum, DWORD /*dwData* = 0*/) -{ - if (!m_bModifyFont) - { - return NULL; - } - - if (nColum == 2 &&(nRow >= 4 && nRow <= 8)) - { - return afxGlobalData.fontDefaultGUIBold; - } - - return NULL; -} - -int CMyListCtrl::OnCompareItems(LPARAM lParam1, LPARAM lParam2, int iColumn) -{ - CString strItem1 = GetItemText((int)(lParam1 < lParam2 ? lParam1 : lParam2), iColumn); - CString strItem2 = GetItemText((int)(lParam1 < lParam2 ? lParam2 : lParam1), iColumn); - - if (iColumn == 0) - { - int nItem1 = _ttoi(strItem1); - int nItem2 = _ttoi(strItem2); - return(nItem1 < nItem2 ? -1 : 1); - } - else - { - int iSort = _tcsicmp(strItem1, strItem2); - return(iSort); - } -} - -void CPage5::OnColorRows() -{ - UpdateData(); - m_wndList.m_bColor = m_bColor; - m_wndList.RedrawWindow(); -} - -void CPage5::OnModifyFont() -{ - UpdateData(); - m_wndList.m_bModifyFont = m_bModifyFont; - m_wndList.RedrawWindow(); -} - -void CPage5::OnPropListCustomColors() -{ - UpdateData(); - - // - // BOOL m_bPropListCustomColors - // set custom colors for various elements of the property grid control - if (m_bPropListCustomColors) - { - m_wndPropList.SetCustomColors(RGB(228, 243, 254), RGB(46, 70, 165), RGB(200, 236, 209), RGB(33, 102, 49), RGB(255, 229, 216), RGB(128, 0, 0), RGB(159, 159, 255)); - } - else - { - COLORREF c = (COLORREF)-1; - m_wndPropList.SetCustomColors(c, c, c, c, c, c, c); - } - - m_wndPropList.RedrawWindow(); - // -} - -void CPage5::OnProplistExpandAll() -{ - static BOOL bExpanded = FALSE; - - m_wndPropList.ExpandAll(!bExpanded); - - m_btnExpandAll.SetWindowText(bExpanded ? _T("Expand &All") : _T("Collapse &All")); - - bExpanded = !bExpanded; -} - -void CPage5::OnProplistCategorized() -{ - UpdateData(); - - // - m_wndPropList.SetAlphabeticMode(!m_bPropListCategorized); - // - m_btnExpandAll.EnableWindow(m_bPropListCategorized); -} - -void CPage5::OnProplistCategorized2() -{ - UpdateData(); - // - // BOOL m_bShowDragContext - m_wndPropList.SetShowDragContext(m_bShowDragContext); - // -} - -void CPage5::OnResetValues() -{ - // - // restore original values of the properties - m_wndPropList.ResetOriginalValues(); - // -} - -void CPage5::OnMarkChanged() -{ - UpdateData(); - // - m_wndPropList.MarkModifiedProperties(m_bMarkChanged); - // -} - -void CPage5::OnHideFontProps() -{ - UpdateData(); - - ASSERT_VALID(pGroupFont); - pGroupFont->Show(!m_bHideFontProps); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page5.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page5.h deleted file mode 100644 index 9ce3ef5519921..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page5.h +++ /dev/null @@ -1,86 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CMyListCtrl : public CMFCListCtrl -{ - virtual COLORREF OnGetCellTextColor(int nRow, int nColum); - virtual COLORREF OnGetCellBkColor(int nRow, int nColum); - virtual HFONT OnGetCellFont(int nRow, int nColum, DWORD dwData = 0); - - virtual int OnCompareItems(LPARAM lParam1, LPARAM lParam2, int iColumn); - -public: - BOOL m_bColor; - BOOL m_bModifyFont; -}; - -///////////////////////////////////////////////////////////////////////////// -// CPage5 dialog - -class CPage5 : public CMFCPropertyPage -{ - friend class CMyListCtrl; - - DECLARE_DYNCREATE(CPage5) - -// Construction -public: - CPage5(); - ~CPage5(); - -// Dialog Data - enum { IDD = IDD_PAGE5 }; - CButton m_btnExpandAll; - CStatic m_wndPropListLocation; - CMyListCtrl m_wndList; - BOOL m_bDescrArea; - BOOL m_bDotNetLook; - BOOL m_bHeader; - BOOL m_bMarkSortedColumn; - BOOL m_bColor; - BOOL m_bModifyFont; - BOOL m_bPropListCustomColors; - BOOL m_bPropListCategorized; - BOOL m_bShowDragContext; - BOOL m_bMarkChanged; - BOOL m_bHideFontProps; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - virtual BOOL OnInitDialog(); - - afx_msg void OnHeader(); - afx_msg void OnDotNetLook(); - afx_msg void OnDescriptionArea(); - afx_msg void OnMarkSortedColumn(); - afx_msg void OnColorRows(); - afx_msg void OnModifyFont(); - afx_msg void OnPropListCustomColors(); - afx_msg void OnProplistExpandAll(); - afx_msg void OnProplistCategorized(); - afx_msg void OnProplistCategorized2(); - afx_msg void OnResetValues(); - afx_msg void OnMarkChanged(); - afx_msg void OnHideFontProps(); - - DECLARE_MESSAGE_MAP() - // - CMFCPropertyGridCtrl m_wndPropList; - // - CImageList m_imageList; - - CMFCPropertyGridProperty* pGroupFont; -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page6.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page6.cpp deleted file mode 100644 index f22ce88683780..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page6.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "NewControls.h" -#include "Page6.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPage6 property page - -IMPLEMENT_DYNCREATE(CPage6, CMFCPropertyPage) - -CPage6::CPage6() : CMFCPropertyPage(CPage6::IDD) -{ - m_strSelectedFolder = _T("c:\\"); -} - -CPage6::~CPage6() -{ -} - -void CPage6::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); - DDX_Control(pDX, IDC_LIST1, m_wndShellList); - DDX_Control(pDX, IDC_TREE1, m_wbdShellTree); - DDX_Text(pDX, IDC_SELECTED_FOLDER, m_strSelectedFolder); -} - -BEGIN_MESSAGE_MAP(CPage6, CMFCPropertyPage) - ON_BN_CLICKED(IDC_SELECT_FOLDER, OnSelectFolder) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPage6 message handlers - -void CPage6::OnSelectFolder() -{ - if (theApp.GetShellManager()->BrowseForFolder(m_strSelectedFolder, this, m_strSelectedFolder)) - { - UpdateData(FALSE); - } -} - -BOOL CPage6::OnInitDialog() -{ - CMFCPropertyPage::OnInitDialog(); - - m_wbdShellTree.Expand(m_wbdShellTree.GetRootItem(), TVE_EXPAND); - m_wbdShellTree.SetRelatedList(&m_wndShellList); - - return TRUE; // return TRUE unless you set the focus to a control -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page6.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page6.h deleted file mode 100644 index b13c6d705fc46..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Page6.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CPage6 dialog - -class CPage6 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CPage6) - -// Construction -public: - CPage6(); - ~CPage6(); - -// Dialog Data - enum { IDD = IDD_PAGE6 }; - CMFCShellListCtrl m_wndShellList; - CMFCShellTreeCtrl m_wbdShellTree; - CString m_strSelectedFolder; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - afx_msg void OnSelectFolder(); - virtual BOOL OnInitDialog(); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/ReadMe.htm deleted file mode 100644 index 45af12a98f329..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/ReadMe.htm +++ /dev/null @@ -1,130 +0,0 @@ - - - - NewControls Sample: MFC Controls Demonstration Application - - -

- NewControls Sample: MFC Controls Demonstration Application

-
-
-
- -

-

-
-

- The NewControls sample demonstrates the capabilities of many of the controls implemented - in MFC, including customizable buttons, color picker controls and palettes, a font - chooser, an image editor, a property grid, a masked edit control, and shell list - and tree controls.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the NewControls sample

-
-
    -
  1. -

    - Open the solution file NewControls.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The NewControls sample demonstrates the following keywords:

-

- CDrawingManager; CMFCButton; CMFCColorBar; CMFCColorButton; CMFCColorDialog; CMFCColorPickerCtrl; - CMFCEditBrowseCtrl; CMFCFontComboBox; CMFCImageEditorDialog; CMFCLinkCtrl; CMFCListCtrl; - CMFCMaskedEdit; CMFCMenuButton; CMFCPropertyGridColorProperty; CMFCPropertyGridCtrl; - CMFCPropertyGridFileProperty; CMFCPropertyGridFontProperty; CMFCPropertyGridProperty; - CMFCPropertyPage; CMFCPropertySheet; CMFCShellListCtrl; CMFCShellTreeCtrl; CMFCToolBar; - CMFCToolBarButton; CMFCToolBarImages; CMFCVisualManager; CMFCVisualManagerWindows; - CVSListBox; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Resource.h deleted file mode 100644 index 6633a79671c16..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Resource.h +++ /dev/null @@ -1,140 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by NewControls.rc -// -#define IDM_ABOUTBOX 0x0010 -#define IDS_ABOUTBOX 101 -#define IDD_NewControls_DIALOG 102 -#define IDS_CAPTION 102 -#define IDD_PAGE1 107 -#define IDD_PAGE2 108 -#define IDD_PAGE3 109 -#define IDD_PAGE4 110 -#define IDD_PAGE5 111 -#define IDD_PAGE6 113 -#define IDR_MAINFRAME 128 -#define IDB_BTN1 129 -#define IDB_BTN1_HOT 130 -#define IDC_CURSOR 130 -#define IDR_MENU1 131 -#define IDC_BORDER 131 -#define IDB_GLOBE 132 -#define IDR_DIALOG_MENU 132 -#define IDB_PLAY 133 -#define IDB_STOP 134 -#define IDB_STOP_HOT 135 -#define IDB_PLAY_HOT 136 -#define IDB_IMAGE 137 -#define IDB_TEST_BITMAP 138 -#define IDB_BACK 140 -#define IDR_TOOLBAR_MENU_IMAGES 141 -#define IDB_ICONS 143 -#define IDB_CHECK 144 -#define IDB_RADIO_ON 146 -#define IDB_PROPICONS 147 -#define IDB_BUTTONS 149 -#define IDB_CHECKNO 151 -#define IDB_RADIO_OFF 152 -#define IDB_CHECK32 153 -#define IDB_CHECKNO32 154 -#define IDB_RADIO_OFF32 155 -#define IDB_RADIO_ON32 156 -#define IDB_BTN1_HOT_32 157 -#define IDB_BTN1_32 158 -#define IDB_ICONS32 159 -#define IDD_ABOUTBOX 999 -#define IDC_BUTTON 1000 -#define IDC_MAIL 1000 -#define IDC_IMAGE 1001 -#define IDC_URL 1001 -#define IDC_VERSION 1002 -#define IDC_IMAGE_LOCATION 1002 -#define IDC_BUTTON_MULTLINE 1003 -#define IDC_TOOLTIP 1008 -#define IDC_SET_TOOLTIP 1009 -#define IDC_BUTTON_MENU 1013 -#define IDC_RIGHT_ARROW 1014 -#define IDC_EDIT_LIST 1015 -#define IDC_BUTTON_URL 1016 -#define IDC_IMAGE_AREA 1021 -#define IDC_EDIT_IMAGE 1022 -#define IDC_COLOR_AREA 1023 -#define IDC_PRESSED_ON_MENU 1023 -#define IDC_COLOR_DLG 1024 -#define IDC_TRUETYPE 1024 -#define IDC_MENU_DEFAULT_CLICK 1024 -#define IDC_COLOR_PICKER 1025 -#define IDC_RASTER 1025 -#define IDC_DEVICE 1026 -#define IDC_RGB 1027 -#define IDC_DRAW_USING_FONT 1027 -#define IDC_RGB_COLOR_BAR 1028 -#define IDC_BACKGROUND 1029 -#define IDC_RGB_DLG 1029 -#define IDC_XP_BUTTONS 1030 -#define IDC_CHECK_BUTTON 1038 -#define IDC_FONT 1039 -#define IDC_BORDER_LABEL 1040 -#define IDC_RADIO1 1041 -#define IDC_RADIO2 1042 -#define IDC_RGB_COLOR_BAR2 1042 -#define IDC_RADIO3 1043 -#define IDC_COLOR_PALETTE 1043 -#define IDC_RADIO4 1044 -#define IDC_RGB_COLOR_PALETTE 1044 -#define IDC_LIST1 1044 -#define IDC_MASKEDIT1 1045 -#define IDC_MASKEDIT2 1046 -#define IDC_MASKEDIT3 1047 -#define IDC_MASKEDIT4 1048 -#define IDC_MASKEDIT5 1049 -#define IDC_BUTTON1 1060 -#define IDC_VALUE1 1061 -#define IDC_VALUE2 1062 -#define IDC_VALUE3 1063 -#define IDC_VALUE4 1064 -#define IDC_VALUE5 1065 -#define IDC_PROPLIST_LOCATION 1067 -#define IDC_HEADER 1068 -#define IDC_DOT_NET_LOOK 1069 -#define IDC_DESCRIPTION_AREA 1070 -#define IDC_MARK_SORTED_COLUMN 1071 -#define IDC_COLOR_ROWS 1072 -#define IDC_LUM 1072 -#define IDC_MODIFY_FONT 1073 -#define IDC_DATETIMELOCATION 1074 -#define IDC_DATETIME 1074 -#define IDC_CUSTOM_COLORS 1074 -#define IDC_PROPLIST_CATEGORIZED 1075 -#define IDC_PROPLIST_CATEGORIZED2 1076 -#define IDC_MARK_CHANGED 1077 -#define IDC_CHECKMINUTES 1085 -#define IDC_DATETIMEPICKER2 1088 -#define IDC_DATETIMEFORMAT 1095 -#define IDC_TREE1 1103 -#define IDC_SELECT_FOLDER 1104 -#define IDC_PROPLIST_EXPAND_ALL 1105 -#define IDC_SELECTED_FOLDER 1107 -#define IDC_FILE_EDIT 1109 -#define IDC_FOLDER_EDIT 1110 -#define IDC_CUSTOM_EDIT 1111 -#define IDC_RESET_VALUES 1113 -#define IDC_HIDE_FONT_PROPS 1114 -#define IDC_COLORBAR 16516 -#define IDC_COLORBAR2 16518 -#define ID_ITEM_1 32771 -#define ID_ITEM_2 32772 -#define ID_ITEM_3 32773 -#define ID_ITEM_4 32774 -#define ID_DIALOG_ABOUT 32775 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 160 -#define _APS_NEXT_COMMAND_VALUE 32778 -#define _APS_NEXT_CONTROL_VALUE 1115 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Snippets.txt deleted file mode 100644 index a480ac98d1331..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/Snippets.txt +++ /dev/null @@ -1,42 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -Page2.h: CMFCColorBar 1 -Page2.cpp: CMFCColorBar 2 -Page2.cpp: CMFCColorDialog 3 -Page2.h: CMFCColorPickerCtrl 4 -Page2.cpp: CMFCColorPickerCtrl 5 -Page3.h: CMFCEditBrowseCtrl 6 -Page3.cpp: CMFCEditBrowseCtrl 7 -Page3.cpp: CMFCImageEditorDialog 8 -Page3.h: CMFCLinkCtrl 9 -Page3.cpp: CMFCLinkCtrl 10 -Page4.h: CMFCMaskedEdit 11 -Page4.cpp: CMFCMaskedEdit 12 -Page5.cpp: CMFCPropertyGridColorProperty 13 -Page5.h: CMFCPropertyGridCtrl 14 -Page5.cpp: CMFCPropertyGridCtrl 15 -Page5.cpp: CMFCPropertyGridCtrl 16 -Page5.cpp: CMFCPropertyGridCtrl 17 -Page5.cpp: CMFCPropertyGridCtrl 18 -Page5.cpp: CMFCPropertyGridCtrl 19 -Page5.cpp: CMFCPropertyGridCtrl 20 -Page5.cpp: CMFCPropertyGridCtrl 21 -Page5.cpp: CMFCPropertyGridCtrl 22 -Page5.cpp: CMFCPropertyGridCtrl 23 -Page5.cpp: CMFCPropertyGridCtrl 24 -Page5.cpp: CMFCPropertyGridCtrl 25 -Page5.cpp: CMFCPropertyGridFontProperty 26 -Page5.cpp: CMFCPropertyGridProperty 27 -Page1.h: CMFCButton 28 -Page1.cpp: CMFCButton 29 -Page1.cpp: CMFCButton 30 -Page1.cpp: CMFCButton 31 -Page1.cpp: CMFCButton 32 -Page1.cpp: CMFCButton 33 -Page3.h: CMFCFontComboBox 34 -Page3.cpp: CMFCFontComboBox 35 -Page3.cpp: CMFCFontComboBox 36 -CustomProperties.cpp: CDrawingManager::FillGradient2 37 -Page1.h: CMFCMenuButton 38 -Page1.cpp: CMFCMenuButton 39 -Page3.cpp: CMFCImageEditorDialog 40 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.log b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.log deleted file mode 100644 index ab87afe2d1dd8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.log +++ /dev/null @@ -1,23 +0,0 @@ -Build started 5/7/2009 2:23:13 PM. - 1>Project "C:\MFC\mfc-ta\NVC_MFC_NewControls\cpp\NewControls.vcxproj" on node 2 (build target(s)). - Skipping target "IsProjectFileNewer" because all output files are up-to-date with respect to the input files. - 1>_PrepareForBuild: - Touching "Debug\lastbuild.timestamp". - ClCompile: - Skipping task because its outputs are up-to-date. - Page1.cpp - ResourceCompile: - Microsoft (R) Windows (R) Resource Compiler Version 6.1.7000.0 - - Copyright (C) Microsoft Corporation. All rights reserved. - - - Link: - NewControls.vcxproj -> C:\MFC\mfc-ta\NVC_MFC_NewControls\cpp\Debug\NewControls.exe - _AfterBuild: - Creating "Debug\LastSuccessfulBuild.timestamp" because "AlwaysCreate" was specified. - 1>Done Building Project "C:\MFC\mfc-ta\NVC_MFC_NewControls\cpp\NewControls.vcxproj" (build target(s)). - -Build succeeded. - -Time Elapsed 00:00:17.37 diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.vcxproj deleted file mode 100644 index 8e0ed3b5cd218..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.vcxproj +++ /dev/null @@ -1,198 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {491D63E1-0D49-4470-A1E1-AF28BBDA09F8} - NewControls - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - <_ProjectFileVersion>10.0.20428.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - true - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - false - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - false - X64 - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX64 - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.vcxproj.filters deleted file mode 100644 index 08fb151ce5099..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/newcontrols.vcxproj.filters +++ /dev/null @@ -1,179 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/Btn.cur b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/Btn.cur deleted file mode 100644 index c0ef04df5a945..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/Btn.cur and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/NewControls.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/NewControls.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/NewControls.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/NewControls.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/NewControls.rc2 deleted file mode 100644 index aec0b8f1d68ce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/NewControls.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// BCGVCONTROLS.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/back.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/back.bmp deleted file mode 100644 index 6ea376b88f4ab..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/back.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/bitmap1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/bitmap1.bmp deleted file mode 100644 index 623610df8564f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/bitmap1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/btn1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/btn1.bmp deleted file mode 100644 index d8ad96ca97527..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/btn1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/btn1_hot.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/btn1_hot.bmp deleted file mode 100644 index 0c190ac0a4f78..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/btn1_hot.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/button32.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/button32.bmp deleted file mode 100644 index 7f62939a30107..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/button32.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/button32hot.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/button32hot.bmp deleted file mode 100644 index 50d73726302bd..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/button32hot.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/buttons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/buttons.bmp deleted file mode 100644 index 8235cc77a5f84..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/buttons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/check32.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/check32.bmp deleted file mode 100644 index 8087414183a0e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/check32.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/checkno.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/checkno.bmp deleted file mode 100644 index c090e83a45d51..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/checkno.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/checkno32.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/checkno32.bmp deleted file mode 100644 index 4ed56b4f09484..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/checkno32.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/globe.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/globe.bmp deleted file mode 100644 index 621cd87ea9571..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/globe.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/icons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/icons.bmp deleted file mode 100644 index c6e0ba356b6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/icons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/icons32.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/icons32.bmp deleted file mode 100644 index 3ee8bc258e72c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/icons32.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/image.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/image.bmp deleted file mode 100644 index b8c763b7188fc..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/image.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/play.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/play.bmp deleted file mode 100644 index b019b452ef832..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/play.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/play_hot.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/play_hot.bmp deleted file mode 100644 index 37dc47edcb46f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/play_hot.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/propicons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/propicons.bmp deleted file mode 100644 index e904664344245..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/propicons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_of.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_of.bmp deleted file mode 100644 index 5b5912528880d..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_of.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_of32.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_of32.bmp deleted file mode 100644 index 8e11940892305..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_of32.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_on.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_on.bmp deleted file mode 100644 index 92cc528ea3069..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_on.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_on32.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_on32.bmp deleted file mode 100644 index 49332bce6ebac..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/radio_on32.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/stop.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/stop.bmp deleted file mode 100644 index 7553a84658def..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/stop.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/stop_hot.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/stop_hot.bmp deleted file mode 100644 index 66a7b0c8927f5..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/stop_hot.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/test_bit.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/test_bit.bmp deleted file mode 100644 index 32e0dd2cbc813..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/test_bit.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/toolbar1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/toolbar1.bmp deleted file mode 100644 index dfd3c7136f1ad..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/res/toolbar1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/stdafx.cpp deleted file mode 100644 index 5d203c39bf501..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/stdafx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// NewControls.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/stdafx.h deleted file mode 100644 index 2d94bc34ac357..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/stdafx.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_NewControls/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/AppLookDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/AppLookDlg.cpp deleted file mode 100644 index 80bc8fcbad0c0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/AppLookDlg.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "AppLookDlg.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg dialog - -CAppLookDlg::CAppLookDlg(BOOL bStartup, CWnd* pParent /*=NULL*/) : - CDialog(CAppLookDlg::IDD, pParent), m_bStartup(bStartup) -{ - m_nAppLook = 1; - m_bShowAtStartup = FALSE; - m_bOutlookBar2003 = FALSE; - m_nStyle2007 = 0; - - m_nAppLook = theApp.GetInt(_T("AppLook"), 2); - m_bShowAtStartup = theApp.GetInt(_T("ShowAppLookAtStartup"), TRUE); - m_nStyle2007 = theApp.GetInt(_T("Style2007"), 0); - m_bOutlookBar2003 = theApp.GetInt(_T("OutlookBar2003"), m_nAppLook == 2); -} - -void CAppLookDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_STYLE2007, m_wndStyle2007); - DDX_Control(pDX, IDC_OUTLOOKBAR2003, m_wndOutlookBar2003); - DDX_Control(pDX, IDOK, m_wndOK); - DDX_Control(pDX, IDCANCEL, m_wndCancel); - DDX_Radio(pDX, IDC_APP_LOOK1, m_nAppLook); - DDX_Check(pDX, IDC_SHOW_AT_STARTUP, m_bShowAtStartup); - DDX_Check(pDX, IDC_OUTLOOKBAR2003, m_bOutlookBar2003); - DDX_CBIndex(pDX, IDC_STYLE2007, m_nStyle2007); -} - -BEGIN_MESSAGE_MAP(CAppLookDlg, CDialog) - ON_BN_CLICKED(IDC_APPLY, OnApply) - ON_BN_CLICKED(IDC_APP_LOOK1, OnAppLook) - ON_BN_CLICKED(IDC_APP_LOOK2, OnAppLook) - ON_BN_CLICKED(IDC_APP_LOOK3, OnAppLook) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg message handlers - -BOOL CAppLookDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - SetLook(); - - m_wndStyle2007.EnableWindow(m_nAppLook == 2); - - if (m_bStartup) - { - if (!m_bShowAtStartup) - { - EndDialog(IDCANCEL); - return TRUE; - } - - CRect rectBtn; - - // Hide "Cancel" button: - m_wndCancel.GetWindowRect(rectBtn); - ScreenToClient(rectBtn); - - m_wndOK.MoveWindow(rectBtn); - - m_wndCancel.ShowWindow(SW_HIDE); - } - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CAppLookDlg::OnOK() -{ - CDialog::OnOK(); - SetLook(); -} - -void CAppLookDlg::OnApply() -{ - SetLook(); - - if (!m_bStartup) - { - m_wndCancel.SetWindowText(_T("Close")); - } -} - -void CAppLookDlg::SetLook() -{ - UpdateData(); - OnAppLook(); - - switch (m_nAppLook) - { - case 0: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); - break; - - case 1: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - break; - - case 2: - switch (m_nStyle2007) - { - case 0: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case 1: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case 2: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - - case 3: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); - break; - } - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); - break; - } - - theApp.WriteInt(_T("AppLook"), m_nAppLook); - theApp.WriteInt(_T("Style2007"), m_nStyle2007); - theApp.WriteInt(_T("ShowAppLookAtStartup"), m_bShowAtStartup); - theApp.WriteInt(_T("OutlookBar2003"), m_bOutlookBar2003); - - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); - if (pMainFrame != NULL) - { - pMainFrame->OnChangeLook((m_nAppLook == 2 || m_nAppLook == 3) && m_bOutlookBar2003); - } -} - -void CAppLookDlg::OnAppLook() -{ - UpdateData(); - - m_wndStyle2007.EnableWindow(m_nAppLook == 2); - m_wndOutlookBar2003.EnableWindow(m_nAppLook == 1 || m_nAppLook == 2); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/AppLookDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/AppLookDlg.h deleted file mode 100644 index 2657234c4963f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/AppLookDlg.h +++ /dev/null @@ -1,48 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg dialog - -class CAppLookDlg : public CDialog -{ -// Construction -public: - CAppLookDlg(BOOL bStartup, CWnd* pParent = NULL); // standard constructor - -// Dialog Data - enum { IDD = IDD_APP_LOOK }; - CComboBox m_wndStyle2007; - CButton m_wndOutlookBar2003; - CButton m_wndOK; - CButton m_wndCancel; - int m_nAppLook; - BOOL m_bShowAtStartup; - BOOL m_bOutlookBar2003; - int m_nStyle2007; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void OnApply(); - afx_msg void OnAppLook(); - - DECLARE_MESSAGE_MAP() - - const BOOL m_bStartup; - - void SetLook(); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/CalendarBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/CalendarBar.cpp deleted file mode 100644 index 02457549775f8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/CalendarBar.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "CalendarBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int nBorderSize = 10; - -///////////////////////////////////////////////////////////////////////////// -// CCalendarBar - -CCalendarBar::CCalendarBar() -{ - m_nMyCalendarsY = 0; -} - -CCalendarBar::~CCalendarBar() -{ -} - -BEGIN_MESSAGE_MAP(CCalendarBar, CWnd) - ON_WM_CREATE() - ON_WM_ERASEBKGND() - ON_WM_SIZE() - ON_WM_PAINT() - ON_WM_SETTINGCHANGE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCalendarBar message handlers - -int CCalendarBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy(0, 0, 0, 0); - m_wndCalendar.Create(WS_CHILD | WS_VISIBLE, rectDummy, this, 1); - - CBitmap bmp; - bmp.LoadBitmap(IDB_PAGES_SMALL_HC); - - m_Images.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 0); - m_Images.Add(&bmp, RGB(255, 0, 255)); - - return 0; -} - -BOOL CCalendarBar::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} - -void CCalendarBar::OnSize(UINT nType, int cx, int cy) -{ - CWnd::OnSize(nType, cx, cy); - - int nMyCalendarsHeight = 70; - - if (m_wndCalendar.GetSafeHwnd() != NULL) - { - m_wndCalendar.SetWindowPos(NULL, nBorderSize, nBorderSize, cx - 2 * nBorderSize, cy - 2 * nBorderSize - nMyCalendarsHeight - 10, SWP_NOZORDER | SWP_NOACTIVATE); - } - - m_nMyCalendarsY = cy - nMyCalendarsHeight; -} - -BOOL CCalendarBar::Create(const RECT& rect, CWnd* pParentWnd, UINT nID) -{ - return CWnd::Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, rect, pParentWnd, nID); -} - -void CCalendarBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectClient; - GetClientRect(rectClient); - - dc.FillRect(rectClient, &afxGlobalData.brWindow); - - if (rectClient.bottom - m_nMyCalendarsY > 0) - { - CRect rectMyCalendarsCaption = rectClient; - rectMyCalendarsCaption.top = m_nMyCalendarsY; - rectMyCalendarsCaption.bottom = rectMyCalendarsCaption.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2; - - COLORREF clrText = CMFCVisualManager::GetInstance()->OnDrawPaneCaption(&dc, NULL, FALSE, rectMyCalendarsCaption, CRect(0, 0, 0, 0)); - - CPen* pOldPen = dc.SelectObject(&afxGlobalData.penBarShadow); - - dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.top); - dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.top); - - dc.SelectStockObject(BLACK_PEN); - - dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.bottom); - dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.bottom); - - dc.SelectObject(pOldPen); - - CRect rectText = rectMyCalendarsCaption; - rectText.DeflateRect(10, 0); - - dc.SetBkMode(TRANSPARENT); - dc.SetTextColor(clrText); - - CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular); - - CString str = _T("My Calendars"); - dc.DrawText(str, rectText, DT_VCENTER | DT_LEFT | DT_SINGLELINE); - - CRect rectCalendar = rectClient; - rectCalendar.top = rectMyCalendarsCaption.bottom + 5; - rectCalendar.bottom = rectCalendar.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2 - 5; - - dc.FillSolidRect(rectCalendar, RGB(255, 255, 213)); - - rectCalendar.DeflateRect(20, 0); - m_Images.Draw(&dc, 3, rectCalendar.TopLeft(), 0); - - rectCalendar.left += 20; - - str = _T("Calendar"); - - dc.SetTextColor(afxGlobalData.clrHotLinkNormalText); - dc.DrawText(str, rectCalendar, DT_VCENTER | DT_LEFT | DT_SINGLELINE); - - dc.SelectObject(pOldFont); - } -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/CalendarBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/CalendarBar.h deleted file mode 100644 index 569a28f4b5f58..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/CalendarBar.h +++ /dev/null @@ -1,42 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CCalendarBar window - -class CCalendarBar : public CWnd -{ -// Construction -public: - CCalendarBar(); - -// Attributes -protected: - CMonthCalCtrl m_wndCalendar; - int m_nMyCalendarsY; - CImageList m_Images; - -// Overrides -public: - virtual BOOL Create(const RECT& rect, CWnd* pParentWnd, UINT nID = (UINT)-1); - -// Implementation -public: - virtual ~CCalendarBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnPaint(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListBar.cpp deleted file mode 100644 index 9b57e9a4094d9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListBar.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "FolderListBar.h" -#include "WorkspaceObj.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int idTree = 5; - -///////////////////////////////////////////////////////////////////////////// -// CFolderListBar - -CFolderListBar::CFolderListBar(const CObList& lstWorkspaces, CImageList& images) : m_wndFolders(lstWorkspaces, images) -{ - // m_nSize = 200; // Initial width - m_bNotifyFrame = TRUE; -} - -CFolderListBar::~CFolderListBar() -{ -} - -BEGIN_MESSAGE_MAP(CFolderListBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_NOTIFY(TVN_SELCHANGED, idTree, OnSelectTree) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFolderListBar message handlers - -int CFolderListBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy(0, 0, 0, 0); - m_wndFolders.Create(0, rectDummy, this, idTree); - - return 0; -} - -void CFolderListBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - if (CanAdjustLayout()) - { - m_wndFolders.SetWindowPos(NULL, 0, 0, cx , cy , SWP_NOACTIVATE | SWP_NOZORDER); - } -} - -void CFolderListBar::OnEraseWorkArea(CDC* pDC, CRect rectWorkArea) -{ - ASSERT_VALID(pDC); - pDC->FillSolidRect(rectWorkArea, GetSysColor(COLOR_WINDOW)); -} - -void CFolderListBar::OnSelectTree(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - HTREEITEM hTreeItem = m_wndFolders.GetSelectedItem(); - if (hTreeItem != NULL) - { - CWorkspaceObj* pWS = (CWorkspaceObj*) m_wndFolders.GetItemData(hTreeItem); - ASSERT_VALID(pWS); - - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, GetParentFrame()); - if (pMainFrame != NULL && m_bNotifyFrame) - { - pMainFrame->SetWorkSpace(pWS); - } - } - - *pResult = 0; -} - -BOOL CFolderListBar::SelectWorkspace(CWorkspaceObj* pWS) -{ - ASSERT_VALID(pWS); - - m_bNotifyFrame = FALSE; - m_wndFolders.SelectWorkspace(pWS); - m_bNotifyFrame = TRUE; - - return TRUE; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListBar.h deleted file mode 100644 index 98311cb035262..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListBar.h +++ /dev/null @@ -1,58 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "FoldersTree.h" - -class CWorkspaceObj; - -///////////////////////////////////////////////////////////////////////////// -// CFolderListBar window - -class CFolderListBar : public CDockablePane -{ -// Construction -public: - CFolderListBar(const CObList& lstWorkspaces, CImageList& images); - -// Attributes -protected: - CFoldersTree m_wndFolders; - BOOL m_bNotifyFrame; - -// Operations -public: - BOOL SelectWorkspace(CWorkspaceObj* pWS); - virtual BOOL CanAcceptPane(const CBasePane* /*pBar*/) const - { - return FALSE; - } - virtual BOOL DoesAllowDynInsertBefore() const - { - return FALSE; - } - -// Overrides -protected: - virtual void OnEraseWorkArea(CDC* pDC, CRect rectWorkArea); - -// Implementation -public: - virtual ~CFolderListBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSelectTree(NMHDR* pNMHDR, LRESULT* pResult); - - DECLARE_MESSAGE_MAP() -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListPopupWnd.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListPopupWnd.cpp deleted file mode 100644 index 5ddd19edd6832..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListPopupWnd.cpp +++ /dev/null @@ -1,216 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "FolderListPopupWnd.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const UINT idFoldersTree = 1; -const UINT idPinBtn = 2; -const int nHorzMargin = 2; - -///////////////////////////////////////////////////////////////////////////// -// CFolderListPopupWnd - -CString CFolderListPopupWnd::m_strClassName; - -CFolderListPopupWnd::CFolderListPopupWnd(const CObList& lstWorkspaces, CImageList& images, CWorkspaceObj* pSelWorkSpace) : m_wndFolders(lstWorkspaces, images), m_pSelWorkSpace(pSelWorkSpace), m_bNotify(FALSE) -{ -} - -CFolderListPopupWnd::~CFolderListPopupWnd() -{ -} - -BEGIN_MESSAGE_MAP(CFolderListPopupWnd, CWnd) - ON_WM_SIZE() - ON_WM_PAINT() - ON_WM_ERASEBKGND() - ON_WM_CREATE() - ON_WM_CANCELMODE() - ON_WM_NCDESTROY() - ON_WM_ACTIVATE() - ON_WM_ACTIVATEAPP() - ON_NOTIFY(TVN_SELCHANGED, idFoldersTree, OnSelectTree) - ON_COMMAND(idPinBtn, OnKeepVisible) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFolderListPopupWnd message handlers - -BOOL CFolderListPopupWnd::Create(const RECT& rect) -{ - if (m_strClassName.IsEmpty()) - { - m_strClassName = ::AfxRegisterWndClass(CS_SAVEBITS, ::LoadCursor(NULL, IDC_ARROW), - (HBRUSH)(COLOR_BTNFACE + 1), NULL); - } - - return CWnd::CreateEx(WS_EX_TOPMOST | WS_EX_DLGMODALFRAME, m_strClassName, _T(""), WS_POPUP | WS_VISIBLE | WS_BORDER, rect, AfxGetMainWnd(), NULL); -} - -void CFolderListPopupWnd::OnSize(UINT nType, int cx, int cy) -{ - CWnd::OnSize(nType, cx, cy); - - CRect rectBtn; - m_btnPin.GetClientRect(rectBtn); - - m_rectCaption = CRect(0, 0, cx, rectBtn.Height() + 2); - - m_btnPin.SetWindowPos(NULL, cx - rectBtn.Width() - nHorzMargin, (m_rectCaption.Height() - rectBtn.Height()) / 2, -1, -1, SWP_NOSIZE | SWP_NOZORDER); - m_wndFolders.MoveWindow(0, m_rectCaption.bottom, cx, cy - m_rectCaption.Height()); -} - -void CFolderListPopupWnd::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - dc.FillRect(m_rectCaption, &afxGlobalData.brBarFace); - - int nOldBkMode = dc.SetBkMode(TRANSPARENT); - COLORREF clrOldText = dc.SetTextColor(afxGlobalData.clrBarText); - CFont* pOldFont = (CFont*) dc.SelectObject(&afxGlobalData.fontRegular); - - CRect rectText = m_rectCaption; - rectText.left += 2 * nHorzMargin; - rectText.right -= 2 * nHorzMargin + rectText.Height(); - - dc.DrawText(m_strCaption, rectText, DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER); - - dc.SelectObject(pOldFont); - dc.SetTextColor(clrOldText); - dc.SetBkMode(nOldBkMode); -} - -BOOL CFolderListPopupWnd::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} - -BOOL CFolderListPopupWnd::PreTranslateMessage(MSG* pMsg) -{ - switch (pMsg->message) - { - case WM_KEYDOWN: - if (pMsg->wParam == VK_ESCAPE) - { - CloseMe(); - return TRUE; - } - break; - } - - return CWnd::PreTranslateMessage(pMsg); -} - -int CFolderListPopupWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rect; - rect.SetRectEmpty(); - - // Create folders tree: - m_wndFolders.Create(0, rect, this, idFoldersTree); - - m_wndFolders.SelectWorkspace(m_pSelWorkSpace); - - m_wndFolders.SetFocus(); - - // Create "Pin" button: - m_btnPin.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rect, this, idPinBtn); - m_btnPin.m_bDrawFocus = FALSE; - m_btnPin.m_nFlatStyle = CMFCButton::BUTTONSTYLE_FLAT; - m_btnPin.SetImage(IDB_PIN); - m_btnPin.SizeToContent(); - - BOOL bValidString; - bValidString = m_strCaption.LoadString(IDS_FOLDER_POPUP_CAPTION); - - m_bNotify = TRUE; - - return 0; -} - -void CFolderListPopupWnd::OnCancelMode() -{ - CWnd::OnCancelMode(); - CloseMe(); -} - -void CFolderListPopupWnd::OnNcDestroy() -{ - CWnd::OnNcDestroy(); - delete this; -} - -void CFolderListPopupWnd::OnActivateApp(BOOL bActive, DWORD dwThreadID) -{ - CWnd::OnActivateApp(bActive, dwThreadID); - - if (!bActive) - { - CloseMe(); - } -} - -void CFolderListPopupWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) -{ - CWnd::OnActivate(nState, pWndOther, bMinimized); - - if (nState == WA_INACTIVE) - { - CloseMe(); - } -} - -void CFolderListPopupWnd::OnSelectTree(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - HTREEITEM hTreeItem = m_wndFolders.GetSelectedItem(); - if (m_bNotify && hTreeItem != NULL) - { - CWorkspaceObj* pWS = (CWorkspaceObj*) m_wndFolders.GetItemData(hTreeItem); - - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, GetParentFrame()); - if (pMainFrame != NULL) - { - pMainFrame->SetWorkSpace(pWS); - } - - CloseMe(); - } - - *pResult = 0; -} - -void CFolderListPopupWnd::CloseMe(BOOL bKeep) -{ - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, GetParentFrame()); - if (pMainFrame != NULL) - { - pMainFrame->OnCloseFoldersPopup(bKeep); - } - - PostMessage(WM_CLOSE); -} - -void CFolderListPopupWnd::OnKeepVisible() -{ - CloseMe(TRUE); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListPopupWnd.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListPopupWnd.h deleted file mode 100644 index 35fd8538d1300..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FolderListPopupWnd.h +++ /dev/null @@ -1,65 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "FoldersTree.h" - -class CWorkspaceObj; - -///////////////////////////////////////////////////////////////////////////// -// CFolderListPopupWnd window - -class CFolderListPopupWnd : public CWnd -{ -// Construction -public: - CFolderListPopupWnd(const CObList& lstWorkspaces, CImageList& images, CWorkspaceObj* pSelWorkSpace); - -// Attributes -protected: - static CString m_strClassName; - CFoldersTree m_wndFolders; - CWorkspaceObj* m_pSelWorkSpace; - - CMFCButton m_btnPin; - - CRect m_rectCaption; - CString m_strCaption; - - BOOL m_bNotify; - -// Operations -public: - void CloseMe(BOOL bKeep = FALSE); - -// Overrides -public: - virtual BOOL Create(const RECT& rect); - virtual BOOL PreTranslateMessage(MSG* pMsg); - -// Implementation -public: - virtual ~CFolderListPopupWnd(); - -protected: - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnPaint(); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnCancelMode(); - afx_msg void OnNcDestroy(); - afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); - afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); - afx_msg void OnSelectTree(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnKeepVisible(); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FoldersTree.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FoldersTree.cpp deleted file mode 100644 index bf2a805aeb814..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FoldersTree.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "FoldersTree.h" -#include "WorkspaceObj.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CFoldersTree - -CFoldersTree::CFoldersTree(const CObList& lstWorkspaces, CImageList& images) : m_lstWorkspaces(lstWorkspaces), m_images(images) -{ -} - -CFoldersTree::~CFoldersTree() -{ -} - -BEGIN_MESSAGE_MAP(CFoldersTree, CTreeCtrl) - ON_WM_CREATE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFoldersTree message handlers - -BOOL CFoldersTree::PreCreateWindow(CREATESTRUCT& cs) -{ - cs.style |= WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | TVS_HASLINES | TVS_HASBUTTONS | TVS_DISABLEDRAGDROP | TVS_LINESATROOT | TVS_SHOWSELALWAYS; - return CTreeCtrl::PreCreateWindow(cs); -} - -int CFoldersTree::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CTreeCtrl::OnCreate(lpCreateStruct) == -1) - return -1; - - SetImageList(&m_images, TVSIL_NORMAL); - - // Fill folders tree: - HTREEITEM htreeRoot = NULL; - - for (POSITION pos = m_lstWorkspaces.GetHeadPosition(); pos != NULL;) - { - CWorkspaceObj* pWS = (CWorkspaceObj*) m_lstWorkspaces.GetNext(pos); - ASSERT_VALID(pWS); - - HTREEITEM hItem = InsertItem(pWS->m_strName, pWS->m_iIconIndex, pWS->m_iIconIndex); - SetItemData(hItem, (DWORD_PTR) pWS); - - m_Items.SetAt(pWS, hItem); - - if (htreeRoot == NULL) - { - htreeRoot = hItem; - } - } - - if (htreeRoot) - { - Expand(htreeRoot, TVE_EXPAND); - } - - return 0; -} - -BOOL CFoldersTree::SelectWorkspace(CWorkspaceObj* pWS) -{ - ASSERT_VALID(pWS); - - HTREEITEM hItem; - if (!m_Items.Lookup(pWS, hItem)) - { - ASSERT(FALSE); - return FALSE; - } - - SelectItem(hItem); - EnsureVisible(hItem); - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FoldersTree.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FoldersTree.h deleted file mode 100644 index b2c199e0da1a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/FoldersTree.h +++ /dev/null @@ -1,47 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CWorkspaceObj; - -///////////////////////////////////////////////////////////////////////////// -// CFoldersTree window - -class CFoldersTree : public CTreeCtrl -{ -// Construction -public: - CFoldersTree(const CObList& lstWorkspaces, CImageList& images); - -// Attributes -protected: - CTreeCtrl m_wndFolders; - const CObList& m_lstWorkspaces; - CImageList& m_images; - - CMap m_Items; - -// Operations -public: - BOOL SelectWorkspace(CWorkspaceObj* pWS); - -// Overrides -protected: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CFoldersTree(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailBar.cpp deleted file mode 100644 index 918db13a381c8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailBar.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "MailBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMailBar dialog - -CMailBar::CMailBar() -{ -} - -void CMailBar::DoDataExchange(CDataExchange* pDX) -{ - CPaneDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CMailBar, CPaneDialog) - ON_WM_SIZE() - ON_WM_ERASEBKGND() - ON_WM_CTLCOLOR() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMailBar message handlers - -void CMailBar::AdjustWidth(int cx, UINT uiCtrlID) -{ - const int nMargin = 10; - - CWnd* pWnd = GetDlgItem(uiCtrlID); - if (pWnd == NULL) - { - return; - } - - CRect rect; - pWnd->GetWindowRect(rect); - ScreenToClient(rect); - - rect.right = cx - nMargin; - - pWnd->SetWindowPos(NULL, -1, -1, rect.Width(), rect.Height(), SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CMailBar::OnSize(UINT nType, int cx, int cy) -{ - CPaneDialog::OnSize(nType, cx, cy); - - AdjustWidth(cx, IDC_MAIL_TO_NAME); - AdjustWidth(cx, IDC_MAIL_CC_NAME); - AdjustWidth(cx, IDC_MAIL_SUBJECT_NAME); - -} - -BOOL CMailBar::OnEraseBkgnd(CDC* pDC) -{ - CRect rectClient; - GetClientRect(rectClient); - - // - // CDC* pDC - // CRect rectClient - // The this pointer points to a CMailBar class which extends the CPaneDialog class. - CMFCVisualManager::GetInstance()->OnFillBarBackground(pDC, this, rectClient, rectClient); - // - - return TRUE; -} - -HBRUSH CMailBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) -{ -#define MAX_CLASS_NAME 255 -#define STATIC_CLASS _T("Static") -#define BUTTON_CLASS _T("Button") - - if (nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_BTN) - { - TCHAR lpszClassName [MAX_CLASS_NAME + 1]; - - ::GetClassName(pWnd->GetSafeHwnd(), lpszClassName, MAX_CLASS_NAME); - CString strClass = lpszClassName; - - if (strClass == STATIC_CLASS || strClass == BUTTON_CLASS) - { - pDC->SetBkMode(TRANSPARENT); - return(HBRUSH) ::GetStockObject(HOLLOW_BRUSH); - } - } - - return CPaneDialog::OnCtlColor(pDC, pWnd, nCtlColor); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailBar.h deleted file mode 100644 index 6d50c7af4f2a9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailBar.h +++ /dev/null @@ -1,44 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CMailBar dialog - -class CMailBar : public CPaneDialog -{ -// Construction -public: - CMailBar(); // standard constructor - -// Dialog Data - enum { IDD = IDD_MAILBAR }; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - virtual BOOL AllowShowOnPaneMenu() const - { - return FALSE; - } - -// Implementation -protected: - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); - - DECLARE_MESSAGE_MAP() - - void AdjustWidth(int cx, UINT uiCtrlID); -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailFrame.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailFrame.cpp deleted file mode 100644 index 73d1f26d912cb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailFrame.cpp +++ /dev/null @@ -1,223 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "MailFrame.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMailFrame - -CObList CMailFrame::m_lstMailFrames; - -IMPLEMENT_DYNCREATE(CMailFrame, CFrameWndEx) - -CMailFrame::CMailFrame() -{ - m_wndMenuBar.m_bClearHashOnClose = TRUE; -} - -CMailFrame::~CMailFrame() -{ -} - -BEGIN_MESSAGE_MAP(CMailFrame, CFrameWndEx) - ON_WM_CREATE() - ON_WM_ACTIVATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_WM_CLOSE() - ON_COMMAND(ID_MAIL_CLOSE, OnMailClose) - ON_WM_ENABLE() - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMailFrame message handlers - -int CMailFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - m_lstMailFrames.AddTail(this); - - m_pMainWnd = theApp.m_pMainWnd; - - if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - BOOL bIsLook2003 = CMFCVisualManager::GetInstance()->IsKindOf(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - - CWindowDC dc(NULL); - int nBitsPerPixel = dc.GetDeviceCaps(BITSPIXEL); - - BOOL bHiColorToolbarIcons = bIsLook2003 && nBitsPerPixel > 16; - - // Create menu bar: - if (!m_wndMenuBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, ID_MAIL_MENU)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Create main toolbar: - if (!m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_MAIL_TOOLBAR) || !m_wndToolBar.LoadToolBar(IDR_MAILFRAME, 0, 0, FALSE, 0, 0, bHiColorToolbarIcons ? IDB_MAIL_HC : 0)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString(IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText(strMainToolbarTitle); - - // Create status bar: - if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - - EnableDocking(CBRS_ALIGN_ANY); - - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - // Create mail bar: - if (!m_wndMailBar.Create(_T(""), this, FALSE, MAKEINTRESOURCE(IDD_MAILBAR), WS_VISIBLE | WS_CHILD | CBRS_TOP, ID_MAIL_BAR, AFX_CBRS_REGULAR_TABS, 0)) - { - TRACE0("Failed to create mail bar\n"); - return -1; // fail to create - } - - DockPane(&m_wndMailBar); - - CRect rect; - m_wndMailBar.GetWindowRect(rect); - m_wndMailBar.SetMinSize(rect.Size()); - - // Enable customization button fore all toolbars: - m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, IDS_CUSTOMIZE); - - // Enable conttol bar context menu(list of bars + customize command): - EnablePaneMenu( TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."), ID_VIEW_TOOLBARS); - return 0; -} - -LRESULT CMailFrame::OnToolbarReset(WPARAM wp,LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - if (uiToolBarId == IDR_MAILFRAME) - { - m_wndToolBar.SetToolBarBtnText(m_wndToolBar.CommandToIndex(ID_MAIL_SEND)); - m_wndToolBar.SetToolBarBtnText(m_wndToolBar.CommandToIndex(ID_MAIL_OPTIONS)); - } - - return 0; -} - -void CMailFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) -{ - CFrameWndEx::OnActivate(nState, pWndOther, bMinimized); - - if (nState != WA_INACTIVE) - { - theApp.SetActiveFrame(COutlookDemoApp::MailFrame); - theApp.m_pMainWnd = this; - } -} - -void CMailFrame::OnViewCustomize() -{ - // Create a customize toolbars dialog: - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* Automatic menus scaning */); - pDlgCust->Create(); -} - -void CMailFrame::OnClose() -{ - theApp.m_pMainWnd = m_pMainWnd; - - POSITION pos = m_lstMailFrames.Find(this); - if (pos != NULL) - { - m_lstMailFrames.RemoveAt(pos); - } - - CFrameWndEx::OnClose(); -} - -BOOL CMailFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) -{ - BOOL bRes = CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext); - if (bRes) - { - InitialUpdateFrame(pContext->m_pCurrentDoc, TRUE); - } - - theApp.SetActiveFrame(COutlookDemoApp::MailFrame); - return bRes; -} - -void CMailFrame::OnMailClose() -{ - SendMessage(WM_CLOSE); -} - -void CMailFrame::OnChangeLook() -{ - BOOL bIsLook2003 = CMFCVisualManager::GetInstance()->IsKindOf(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - - CWindowDC dc(NULL); - int nBitsPerPixel = dc.GetDeviceCaps(BITSPIXEL); - - BOOL bIsHiColor = bIsLook2003 && nBitsPerPixel > 16; - - for (POSITION pos = m_lstMailFrames.GetHeadPosition(); pos != NULL;) - { - CMailFrame* pFrame = (CMailFrame*) m_lstMailFrames.GetNext(pos); - ASSERT_VALID(pFrame); - - pFrame->m_wndToolBar.LoadBitmap(bIsHiColor ? IDB_MAIL_HC : IDR_MAILFRAME); - pFrame->RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - } -} - -void CMailFrame::OnEnable( BOOL bEnable ) -{ - CWnd* pWnd = GetNextWindow(); - while (pWnd != NULL) - { - if (pWnd->IsKindOf(RUNTIME_CLASS(CFrameWndEx))) - { - pWnd->EnableWindow(bEnable); - } - pWnd = pWnd->GetNextWindow(); - } -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailFrame.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailFrame.h deleted file mode 100644 index 99df4430ad337..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailFrame.h +++ /dev/null @@ -1,55 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "MailBar.h" - -///////////////////////////////////////////////////////////////////////////// -// CMailFrame frame - -class CMailFrame : public CFrameWndEx -{ - DECLARE_DYNCREATE(CMailFrame) - -public: - CMailFrame(); - virtual ~CMailFrame(); - -// Attributes -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCToolBar m_wndToolBar; - CMailBar m_wndMailBar; - CMFCStatusBar m_wndStatusBar; - CWnd* m_pMainWnd; - - static CObList m_lstMailFrames; - -// Operations -public: - static void OnChangeLook(); - -// Overrides -public: - virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL); - -// Implementation -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); - afx_msg void OnViewCustomize(); - afx_msg void OnClose(); - afx_msg void OnMailClose(); - afx_msg void OnEnable( BOOL bEnable ); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailView.cpp deleted file mode 100644 index f0c9ec8993bea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailView.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "MailView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMailView - -IMPLEMENT_DYNCREATE(CMailView, CEditView) - -CMailView::CMailView() -{ - m_nPriority = 1; -} - -CMailView::~CMailView() -{ -} - -BEGIN_MESSAGE_MAP(CMailView, CEditView) - ON_COMMAND(ID_MAIL_ATTACHMENT, OnMailAttachment) - ON_COMMAND(ID_MAIL_CHECK_NAMES, OnMailCheckNames) - ON_COMMAND(ID_MAIL_COPY_TO_FOLDER, OnMailCopyToFolder) - ON_COMMAND(ID_MAIL_DELETE, OnMailDelete) - ON_COMMAND(ID_MAIL_FLAG, OnMailFlag) - ON_COMMAND(ID_MAIL_FONTSIZE, OnMailFontsize) - ON_COMMAND(ID_MAIL_HIGHT_PRIORITY, OnMailHightPriority) - ON_UPDATE_COMMAND_UI(ID_MAIL_HIGHT_PRIORITY, OnUpdateMailHightPriority) - ON_COMMAND(ID_MAIL_ITEM, OnMailItem) - ON_COMMAND(ID_MAIL_LOW_PRIORITY, OnMailLowPriority) - ON_UPDATE_COMMAND_UI(ID_MAIL_LOW_PRIORITY, OnUpdateMailLowPriority) - ON_COMMAND(ID_MAIL_MOVE_TO_FOLDER, OnMailMoveToFolder) - ON_COMMAND(ID_MAIL_OPTIONS, OnMailOptions) - ON_COMMAND(ID_MAIL_PROPERTIES, OnMailProperties) - ON_COMMAND(ID_MAIL_SAVE, OnMailSave) - ON_COMMAND(ID_MAIL_SAVE_ATTACHMENTS, OnMailSaveAttachments) - ON_COMMAND(ID_MAIL_SAVE_STATIONERY, OnMailSaveStationery) - ON_COMMAND(ID_MAIL_SEND, OnMailSend) - ON_COMMAND(ID_MAIL_SIGNATURE, OnMailSignature) - ON_COMMAND(ID_MAIL_SPELL, OnMailSpell) - ON_COMMAND(IDC_MAIL_TO, OnMailTo) - ON_COMMAND(IDC_MAIL_CC, OnMailCc) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMailView diagnostics - -#ifdef _DEBUG -void CMailView::AssertValid() const -{ - CEditView::AssertValid(); -} - -void CMailView::Dump(CDumpContext& dc) const -{ - CEditView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMailView message handlers - -void CMailView::OnMailTo() -{ -} - -void CMailView::OnMailCc() -{ -} - -void CMailView::OnMailAttachment() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailCheckNames() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailCopyToFolder() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailDelete() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailFlag() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailFontsize() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailHightPriority() -{ - m_nPriority = m_nPriority == 2 ? 1 : 2; -} - -void CMailView::OnUpdateMailHightPriority(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_nPriority == 2); -} - -void CMailView::OnMailItem() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailLowPriority() -{ - m_nPriority = m_nPriority == 0 ? 1 : 0; -} - -void CMailView::OnUpdateMailLowPriority(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_nPriority == 0); -} - -void CMailView::OnMailMoveToFolder() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailOptions() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailProperties() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailSave() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailSaveAttachments() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailSaveStationery() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailSend() -{ - GetParentFrame()->SendMessage(WM_CLOSE); -} - -void CMailView::OnMailSignature() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnMailSpell() -{ - // TODO: Add your command handler code here -} - -void CMailView::OnInitialUpdate() -{ - CEditView::OnInitialUpdate(); - GetEditCtrl().ModifyStyle(0, WS_BORDER); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailView.h deleted file mode 100644 index d3434ae809517..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MailView.h +++ /dev/null @@ -1,62 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CMailView view - -class CMailView : public CEditView -{ -protected: - CMailView(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CMailView) - -// Attributes -public: - int m_nPriority; - -// Overrides -public: - virtual void OnInitialUpdate(); - -// Implementation -protected: - virtual ~CMailView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnMailAttachment(); - afx_msg void OnMailCheckNames(); - afx_msg void OnMailCopyToFolder(); - afx_msg void OnMailDelete(); - afx_msg void OnMailFlag(); - afx_msg void OnMailFontsize(); - afx_msg void OnMailHightPriority(); - afx_msg void OnUpdateMailHightPriority(CCmdUI* pCmdUI); - afx_msg void OnMailItem(); - afx_msg void OnMailLowPriority(); - afx_msg void OnUpdateMailLowPriority(CCmdUI* pCmdUI); - afx_msg void OnMailMoveToFolder(); - afx_msg void OnMailOptions(); - afx_msg void OnMailProperties(); - afx_msg void OnMailSave(); - afx_msg void OnMailSaveAttachments(); - afx_msg void OnMailSaveStationery(); - afx_msg void OnMailSend(); - afx_msg void OnMailSignature(); - afx_msg void OnMailSpell(); - afx_msg void OnMailTo(); - afx_msg void OnMailCc(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MainFrm.cpp deleted file mode 100644 index 7723a68ac3b90..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MainFrm.cpp +++ /dev/null @@ -1,1059 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "WorkspaceObj.h" -#include "FolderListPopupWnd.h" -#include "PreviewPane.h" -#include "MailFrame.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -BOOL CMyOutlookBar::AllowShowOnPaneMenu() const -{ - return m_bMode2003 == ((CMainFrame*)GetParent())->IsOutlookBar2003(); -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - -const int iMaxUserToolbars = 10; -const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; -const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_WM_ACTIVATE() - ON_COMMAND(ID_OUTLOOK_ADD_PAGE, OnOutlookAddPage) - ON_COMMAND(ID_OUTLOOK_ANIMATION, OnOutlookAnimation) - ON_COMMAND(ID_OUTLOOK_DELETE_PAGE, OnOutlookDeletePage) - ON_COMMAND(ID_OUTLOOK_RENAME_PAGE, OnOutlookRenamePage) - ON_COMMAND(ID_OUTLOOK_SHOW_TEXT_LABELS, OnOutlookShowTextLabels) - ON_UPDATE_COMMAND_UI(ID_OUTLOOK_RENAME_PAGE, OnUpdateOutlookRenamePage) - ON_UPDATE_COMMAND_UI(ID_OUTLOOK_DELETE_PAGE, OnUpdateOutlookDeletePage) - ON_UPDATE_COMMAND_UI(ID_OUTLOOK_ANIMATION, OnUpdateOutlookAnimation) - ON_UPDATE_COMMAND_UI(ID_OUTLOOK_SHOW_TEXT_LABELS, OnUpdateOutlookShowTextLabels) - ON_COMMAND(ID_RESET_PAGE, OnResetPage) - ON_UPDATE_COMMAND_UI(ID_RESET_PAGE, OnUpdateResetPage) - ON_WM_CLOSE() - ON_UPDATE_COMMAND_UI(ID_OUTLOOK_ADD_PAGE, OnUpdateOutlookAddPage) - ON_WM_SETTINGCHANGE() - ON_WM_ENABLE() - ON_COMMAND(ID_VIEW_CAPTIONBAR, OnViewCaptionbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTIONBAR, OnUpdateViewCaptionbar) - ON_COMMAND(ID_VIEW_FOLDER_LIST, OnViewFolderList) - ON_UPDATE_COMMAND_UI(ID_VIEW_FOLDER_LIST, OnUpdateViewFolderList) - ON_COMMAND(ID_VIEW_OUTLOOKBAR, OnViewOutlookbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_OUTLOOKBAR, OnUpdateViewOutlookbar) - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, OnToolbarCreateNew) - ON_COMMAND_RANGE(ID_VIEW_GOTO_HOME, ID_VIEW_GOTO_FAVORITES, OnViewWorkSpace) - ON_COMMAND(ID_VIEW_MY_COMPUTER, OnViewMyComputer) - ON_COMMAND(ID_SHOW_FOLDERS_POPUP, OnViewFoldersPopup) - ON_UPDATE_COMMAND_UI(ID_INDICATOR_ANIMATION, OnUpdateIndicatorSendReceive) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_ANIMATION, // status icon - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() : m_wndFolderList(m_lstWorkspaces, m_ImagesSmall) -{ - m_uiHilightedPage = (UINT)-1; - m_pCurrWorkSpace = NULL; - m_pCurrOutlookWnd = NULL; - m_pCurrOutlookPage = NULL; - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - CMFCOutlookBarTabCtrl::EnableAnimation(TRUE); - - m_bOutlookBar2003 = FALSE; -} - -CMainFrame::~CMainFrame() -{ - while (!m_lstWorkspaces.IsEmpty()) - { - delete m_lstWorkspaces.RemoveHead(); - } -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - CWindowDC dc(NULL); - const BOOL bIsHiColor = dc.GetDeviceCaps(BITSPIXEL) > 16; - - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // Load toolbar user images: - if (m_UserImages.Load(_T(".\\Userimages.bmp"))) - { - CMFCToolBar::SetUserImages(&m_UserImages); - } - - CMFCToolBar::EnableQuickCustomization(); - CMFCToolBarComboBoxButton::SetFlatMode(); - CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES); - - // Define basic commands. These commands will appear in - // the menu by default: - SetBasicCommands(); - - // Create menu bar: - if (!m_wndMenuBar.Create(this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Create main toolbar: - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString(IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText(strMainToolbarTitle); - - // Create advanced toolbar: - if (!m_wndToolBarAdvanced.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_ADVANCED_TOOLBAR) || - !m_wndToolBarAdvanced.LoadToolBar(IDR_ADVANCED)) - { - TRACE0("Failed to create advanced toolbar\n"); - return -1; // fail to create - } - - CString strAdvToolbarTitle; - bValidString = strAdvToolbarTitle.LoadString(IDS_ADV_TOOLBAR); - m_wndToolBarAdvanced.SetWindowText(strAdvToolbarTitle); - - // Create Web toolbar: - if (!m_wndToolBarWeb.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_WEB_TOOLBAR) || - !m_wndToolBarWeb.LoadToolBar(IDR_WEB)) - { - TRACE0("Failed to create web toolbar\n"); - return -1; // fail to create - } - - CString strWebToolbarTitle; - bValidString = strWebToolbarTitle.LoadString(IDS_WEB_TOOLBAR); - m_wndToolBarWeb.SetWindowText(strWebToolbarTitle); - - // Create status bar: - if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - CBitmap bmpAni; - if (bmpAni.LoadBitmap(bIsHiColor ? IDB_ANIMATION_HC : IDB_ANIMATION)) - { - m_imlStatusAnimation.Create(16, 16, - (bIsHiColor ? ILC_COLOR8 : ILC_COLOR4) | ILC_MASK, 10, 0); - m_imlStatusAnimation.Add(&bmpAni, RGB(255, 0, 255)); - m_wndStatusBar.SetPaneAnimation(1, m_imlStatusAnimation); - m_wndStatusBar.SetPaneStyle(1, SBPS_NOBORDERS); - } - - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBarAdvanced.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBarWeb.EnableDocking(CBRS_ALIGN_ANY); - - // Outlook bar will be created at left, so temporary disable docking - // at the left side: - EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT); - - m_wndBarOutlook2003.SetMode2003(); - - // Create and setup "Outlook" shortcuts bar: - if (!CreateOutlookBar( m_wndBarOutlook, ID_VIEW_OUTLOOKBAR, m_wndOutlookPane1, m_wndOutlookPane2, m_wndTree, m_wndCalendar, 100) || - !CreateOutlookBar(m_wndBarOutlook2003, ID_VIEW_OUTLOOKBAR2003, m_wndOutlookPane12003, m_wndOutlookPane22003, m_wndTree2003, m_wndCalendar2003, 200)) - { - TRACE0("Failed to create outlook bar\n"); - return -1; // fail to create - } - - m_wndBarOutlook2003.SetButtonsFont(&afxGlobalData.fontBold); - m_wndBarOutlook2003.ShowWindow(SW_HIDE); - - CImageList images; - CBitmap bmp; - if (!bmp.LoadBitmap(bIsHiColor ? IDB_OUTLOOK_SMALL_HC : IDB_OUTLOOK_SMALL)) - { - return FALSE; - } - - BITMAP bm; - bmp.GetBitmap(&bm); - - UINT nFlags = ILC_MASK; - - if (bIsHiColor) - { - nFlags |= ILC_COLOR24; - } - else - { - nFlags |= ILC_COLOR; - } - - m_ImagesSmall.Create(16, bm.bmHeight, nFlags, 0, 0); - m_ImagesSmall.Add(&bmp, RGB(255, 0, 255)); - - // Create a caption bar: - if (!CreateCaptionBar()) - { - TRACE0("Failed to create caption bar\n"); - return -1; // fail to create - } - // Create folders list: - if (!m_wndFolderList.Create(_T("Folder List"),this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FOLDER_LIST, - WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_HIDE_INPLACE | WS_CAPTION, AFX_CBRS_OUTLOOK_TABS, AFX_CBRS_CLOSE | AFX_CBRS_RESIZE)) - { - TRACE0("Failed to create folder list\n"); - return -1; // fail to create - } - - m_wndFolderList.EnableDocking(CBRS_ALIGN_LEFT); - DockPane(&m_wndFolderList); - - // Outlook bar is created and docking on the left side - // should be allowed. - EnableDocking(CBRS_ALIGN_LEFT); - EnableAutoHidePanes(CBRS_ALIGN_RIGHT); - - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane(&m_wndToolBarAdvanced); - DockPaneLeftOf(&m_wndToolBarWeb, &m_wndToolBarAdvanced); - - // Allow user-defined toolbars operations: - InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); - - // Enable customization button fore all toolbars: - m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, IDS_CUSTOMIZE); - m_wndToolBarAdvanced.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, IDS_CUSTOMIZE); - m_wndToolBarWeb.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, IDS_CUSTOMIZE); - - SetWorkSpace((CWorkspaceObj*) m_lstWorkspaces.GetHead()); - - // Enable conttol bar context menu(list of bars + customize command): - EnablePaneMenu( TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."), ID_VIEW_TOOLBARS, - FALSE /* all control bars on the context menu */, TRUE /* toolbars only on the "View" menu*/); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if ( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - -void CMainFrame::OnViewCustomize() -{ - // Create a customize toolbars dialog: - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* Automatic menus scaning */); - - pDlgCust->EnableUserDefinedToolbars(); - pDlgCust->Create(); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM wp,LPARAM lp) -{ - CPoint point(AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - m_pCurrOutlookPage = DYNAMIC_DOWNCAST( CMFCOutlookBarPane, CWnd::FromHandlePermanent((HWND) wp)); - - if (m_pCurrOutlookPage == NULL) - { - m_uiHilightedPage = (UINT)-1; - return 1l; // Default menu - } - - CMenu menu; - VERIFY(menu.LoadMenu(m_bOutlookBar2003 ? IDR_POPUP_OLBAR2003 : IDR_POPUP_OLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - SetupToolbarMenu(*pPopup, ID_VIEW_USER_TOOLBAR1, ID_VIEW_USER_TOOLBAR10); - - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create(this, point.x, point.y, pPopup->Detach()); - } - - m_uiHilightedPage = FindFocusedOutlookWnd(&m_pCurrOutlookWnd); - return 0; -} - -LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - if (uiToolBarId == IDR_MAINFRAME) - { - // Replace new button by the menu - CMenu menu; - VERIFY(menu.LoadMenu(IDR_MAINFRAME)); - - CMenu* pMenuFile = menu.GetSubMenu(0); - VERIFY(pMenuFile != NULL); - - if (pMenuFile) - { - CMenu* pMenuNew = pMenuFile->GetSubMenu(0); - VERIFY(pMenuNew != NULL); - - if (pMenuNew) - { - UINT uiNewCmdID = (m_pCurrWorkSpace == NULL) ? ID_NEW_MAIL : m_pCurrWorkSpace->m_uiDefaultNewAction; - CMFCToolBarMenuButton btnNew(uiNewCmdID, pMenuNew->GetSafeHmenu(), GetCmdMgr()->GetCmdImage(uiNewCmdID)); - m_wndToolBar.ReplaceButton(ID_FILE_NEW, btnNew); - m_wndToolBar.SetToolBarBtnText(m_wndToolBar.CommandToIndex(uiNewCmdID), _T("&New")); - } - } - - // Send/Receive appear with the text label: - m_wndToolBar.SetToolBarBtnText(m_wndToolBar.CommandToIndex(ID_SEND_RECEIVE)); - - // Replace Find Contact by combo: - m_wndToolBar.ReplaceButton(ID_FIND_CONTACT, CMFCToolBarComboBoxButton(ID_FIND_CONTACT, GetCmdMgr()->GetCmdImage(ID_FIND_CONTACT), CBS_DROPDOWN)); - } - else if (uiToolBarId == IDR_WEB) - { - CMenu menu; - VERIFY(menu.LoadMenu(IDR_DUMMY)); - CMenu* pSubMenu = menu.GetSubMenu(0); - - CMFCToolBarMenuButton btnBack(ID_WEB_BACK, pSubMenu->GetSafeHmenu(), GetCmdMgr()->GetCmdImage(ID_WEB_BACK)); - m_wndToolBarWeb.ReplaceButton(ID_WEB_BACK, btnBack); - - m_wndToolBarWeb.ReplaceButton(ID_WEB_ADDRESS, CMFCToolBarComboBoxButton(ID_WEB_ADDRESS, GetCmdMgr()->GetCmdImage(ID_WEB_ADDRESS), CBS_DROPDOWN)); - } - else if (uiToolBarId == IDR_ADVANCED) - { - CMenu menu; - VERIFY(menu.LoadMenu(IDR_DUMMY)); - CMenu* pSubMenu = menu.GetSubMenu(0); - - CMFCToolBarMenuButton btnBack(ID_VIEW_BACK, pSubMenu->GetSafeHmenu(), GetCmdMgr()->GetCmdImage(ID_VIEW_BACK)); - m_wndToolBarAdvanced.ReplaceButton(ID_VIEW_BACK, btnBack); - } - - return 0; -} - -void CMainFrame::AddWorkSpace(const CString& strName, const int iIconIndex, const UINT uiCmd, CMFCOutlookBarPane& pane, const UINT uiNewCmdID, CImageList& images) -{ - pane.AddButton(images.ExtractIcon(iIconIndex), strName, uiCmd); - - BOOL bIsAlreadyExist = FALSE; - for (POSITION pos = m_lstWorkspaces.GetHeadPosition(); pos != NULL;) - { - CWorkspaceObj* pWS = (CWorkspaceObj*) m_lstWorkspaces.GetNext(pos); - ASSERT_VALID(pWS); - - if (pWS->m_uiCmd == uiCmd) - { - bIsAlreadyExist = TRUE; - break; - } - } - - if (!bIsAlreadyExist) - { - m_lstWorkspaces.AddTail(new CWorkspaceObj(strName, uiCmd, iIconIndex, uiNewCmdID)); - } -} - -BOOL CMainFrame::CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCOutlookBarPane& pane1, CMFCOutlookBarPane& pane2, CShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth) -{ - CWindowDC dc(NULL); - const BOOL bIsHiColor = dc.GetDeviceCaps(BITSPIXEL) > 16; - - if (!bar.Create(_T("Shortcuts"), this, CRect(0, 0, nInitialWidth, 32000), uiID, WS_CHILD | WS_VISIBLE | CBRS_LEFT)) - { - return FALSE; // fail to create - } - - // - // CMFCOutlookBar& bar - CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)bar.GetUnderlyingWindow(); - // - - if (pOutlookBar == NULL) - { - ASSERT(FALSE); - return FALSE; - } - - // - pOutlookBar->EnableInPlaceEdit(TRUE); - pOutlookBar->EnableAnimation(); - pOutlookBar->EnableScrollButtons(); - pOutlookBar->SetBorderSize(10); - pOutlookBar->SetPageButtonTextAlign(TA_LEFT); - // - static UINT uiPageID = 1; - - DWORD dwPaneStyle = AFX_DEFAULT_TOOLBAR_STYLE | CBRS_FLOAT_MULTI; - - // can float, can autohide, can resize, CAN NOT CLOSE - DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE; - - pane1.Create(&bar, dwPaneStyle, uiPageID++, dwStyle); - pane1.SetOwner(this); - pane1.EnableTextLabels(); - pane1.EnableDocking(CBRS_ALIGN_ANY); - - pane2.Create(&bar, dwPaneStyle, uiPageID++, dwStyle); - pane2.SetOwner(this); - pane2.EnableTextLabels(); - pane2.EnableDocking(CBRS_ALIGN_ANY); - - CImageList images; - CBitmap bmp; - if (!bmp.LoadBitmap(bIsHiColor ? IDB_OUTLOOK_LARGE_HC : IDB_OUTLOOK_LARGE)) - { - return FALSE; - } - - BITMAP bm; - bmp.GetBitmap(&bm); - - UINT nFlags = ILC_MASK; - - if (bIsHiColor) - { - nFlags |= ILC_COLOR24; - } - else - { - nFlags |= ILC_COLOR; - } - - images.Create(32, bm.bmHeight, nFlags, 0, 0); - images.Add(&bmp, RGB(255, 0, 255)); - - AddWorkSpace(_T("Home"), 0, ID_VIEW_GOTO_HOME, pane1, ID_NEW_MAIL, images); - AddWorkSpace(_T("Calendar"), 1, ID_VIEW_GOTO_CALENDAR, pane1, ID_NEW_APPOINTMENT, images); - AddWorkSpace(_T("Drafts"), 2, ID_VIEW_GOTO_DRAFTS, pane1, ID_NEW_MAIL, images); - AddWorkSpace(_T("Inbox"), 3, ID_VIEW_GOTO_INBOX, pane1, ID_NEW_MAIL, images); - AddWorkSpace(_T("Journal"), 4, ID_VIEW_GOTO_JOURNAL, pane1, ID_NEW_JOURNAL_ENTRY, images); - AddWorkSpace(_T("Notes"), 5, ID_VIEW_GOTO_NOTES, pane1, ID_NEW_NOTE, images); - AddWorkSpace(_T("Outbox"), 6, ID_VIEW_GOTO_OUTBOX, pane1, ID_NEW_MAIL, images); - AddWorkSpace(_T("Sent Items"), 7, ID_VIEW_GOTO_SENTITEMS, pane1, ID_NEW_MAIL, images); - AddWorkSpace(_T("Tasks"), 8, ID_VIEW_GOTO_TASKS, pane1, ID_NEW_TASK, images); - - // - // CMFCOutlookBarTabCtrl* pOutlookBar - // DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE - // CMFCOutlookBarPane pane1 - // The third parameter is the image index. - pOutlookBar->AddControl(&pane1, _T("General"), 0, TRUE, dwStyle); - // - pane1.EnableDocking(CBRS_ALIGN_ANY); - pane1.SetDefaultState(); - - AddWorkSpace(_T("My Computer"), 9, ID_VIEW_MY_COMPUTER, pane2, ID_NEW_SHORTCUT, images); - AddWorkSpace(_T("Personal"), 10, ID_VIEW_GOTO_PERSONAL, pane2, ID_NEW_SHORTCUT, images); - AddWorkSpace(_T("Favorites"), 10, ID_VIEW_GOTO_FAVORITES, pane2, ID_NEW_SHORTCUT, images); - - pOutlookBar->AddControl(&pane2, _T("Other Shortcuts"), 1, TRUE, dwStyle); - pane2.EnableDocking(CBRS_ALIGN_ANY); - pane2.SetDefaultState(); - - CRect rectDummy(0, 0, 0, 0); - const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; - - int nShift = (uiID == ID_VIEW_OUTLOOKBAR) ? 0 : 2; // we are going to create the same controls for two Outlook bars (regular and 2003), so we need this to prevent controls with the same ID - - tree.Create(dwTreeStyle, rectDummy, &bar, 1200 + nShift); - pOutlookBar->AddControl(&tree, _T("Folders"), 2, TRUE, dwStyle); - - calendar.Create(rectDummy, &bar, 1201 + nShift); - pOutlookBar->AddControl(&calendar, _T("Calendar"), 3, TRUE, dwStyle); - - bar.SetPaneStyle(bar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); - bar.FillDefaultTabsOrderArray(); - - BOOL bAnimation = theApp.GetInt(_T("OutlookAnimation"), TRUE); - CMFCOutlookBarTabCtrl::EnableAnimation(bAnimation); - - return TRUE; -} - -BOOL CMainFrame::CreateCaptionBar() -{ - if (!m_wndCaption.Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this, ID_VIEW_CAPTIONBAR, -1)) - { - TRACE0("Failed to create caption bar\n"); - return FALSE; - } - - m_wndCaption.SetFlatBorder(); - m_wndCaption.SetFont(&afxGlobalData.fontBold); - - return TRUE; -} - -void CMainFrame::OnViewWorkSpace(UINT id) -{ - for (POSITION pos = m_lstWorkspaces.GetHeadPosition(); pos != NULL;) - { - CWorkspaceObj* pWS = (CWorkspaceObj*) m_lstWorkspaces.GetNext(pos); - ASSERT_VALID(pWS); - - if (pWS->m_uiCmd == id) - { - SetWorkSpace(pWS); - } - } -} - -void CMainFrame::OnViewMyComputer() -{ - OnViewWorkSpace(ID_VIEW_MY_COMPUTER); -} - -void CMainFrame::SetWorkSpace(CWorkspaceObj* pWorkSpace) -{ - ASSERT_VALID(pWorkSpace); - - m_pCurrWorkSpace = pWorkSpace; - - m_wndCaption.SetIcon(m_ImagesSmall.ExtractIcon(m_pCurrWorkSpace->m_iIconIndex)); - m_wndCaption.SetButton(m_pCurrWorkSpace->m_strName, ID_SHOW_FOLDERS_POPUP); - - m_wndCaption.Invalidate(); - m_wndCaption.UpdateWindow(); - - m_wndFolderList.SelectWorkspace(pWorkSpace); - -} - -void CMainFrame::OnViewFoldersPopup() -{ - // First, calculate popup window rectangle. - // Top left corner need to be under the caption's button: - CRect rectButton = m_wndCaption.GetButtonRect(); - m_wndCaption.ClientToScreen(&rectButton); - - // Width will be same as folder bar's width: - CRect rectFolderBar; - m_wndFolderList.GetWindowRect(&rectFolderBar); - - // Bottom will be near the main frame bottom: - CRect rectStatusBar; - m_wndStatusBar.GetWindowRect(rectStatusBar); - - CRect rectPopup(rectButton.left, rectButton.bottom, rectButton.left + rectFolderBar.Width(), rectStatusBar.bottom - 1); - - CFolderListPopupWnd* pFoldersPopup = new CFolderListPopupWnd(m_lstWorkspaces, m_ImagesSmall, m_pCurrWorkSpace); - pFoldersPopup->Create(rectPopup); - - m_wndCaption.SetButtonPressed(); -} - -void CMainFrame::OnCloseFoldersPopup(BOOL bKeep) -{ - if (bKeep) - { - m_wndCaption.EnableButton(FALSE); - ShowPane(&m_wndFolderList, TRUE, FALSE, TRUE); - } - - m_wndCaption.SetButtonPressed(FALSE); -} - -void CMainFrame::RecalcLayout(BOOL bNotify) -{ - CFrameWnd::RecalcLayout(bNotify); - - if (m_wndFolderList.GetSafeHwnd() != NULL) - { - m_wndCaption.EnableButton(!(m_wndFolderList.GetStyle() & WS_VISIBLE)); - } -} - -void CMainFrame::AdjustDockingLayout(HDWP hdwp) -{ - CFrameWnd::AdjustDockingLayout(hdwp); - if (m_wndFolderList.GetSafeHwnd() != NULL) - { - m_wndCaption.EnableButton(!(m_wndFolderList.GetStyle() & WS_VISIBLE)); - } -} - -BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) -{ - CRect rectClient; - GetClientRect(rectClient); - - m_wndSplitter.CreateStatic(this, 2, 1); - m_wndSplitter.CreateView(0, 0, pContext->m_pNewViewClass, CSize(0, rectClient.Height() / 2), pContext); - m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CPreviewPane), CSize(0, rectClient.Height() / 2), pContext); - - return TRUE; -} - -void CMainFrame::SetBasicCommands() -{ - CList lstBasicCommands; - - lstBasicCommands.AddTail(ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail(ID_FILE_NEW); - lstBasicCommands.AddTail(ID_FILE_OPEN); - lstBasicCommands.AddTail(ID_FILE_SAVE); - lstBasicCommands.AddTail(ID_FILE_PRINT); - lstBasicCommands.AddTail(ID_APP_EXIT); - lstBasicCommands.AddTail(ID_EDIT_CUT); - lstBasicCommands.AddTail(ID_EDIT_PASTE); - lstBasicCommands.AddTail(ID_EDIT_UNDO); - lstBasicCommands.AddTail(ID_APP_ABOUT); - lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail(ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail(ID_VIEW_APP_LOOK); - lstBasicCommands.AddTail(ID_NEW_MAIL); - lstBasicCommands.AddTail(ID_NEW_FAX); - lstBasicCommands.AddTail(ID_NEW_POST_FOLDER); - lstBasicCommands.AddTail(ID_NEW_APPOINTMENT); - lstBasicCommands.AddTail(ID_NEW_MEETING); - lstBasicCommands.AddTail(ID_NEW_CONTRACT); - lstBasicCommands.AddTail(ID_NEW_DISTRIBUTION_LIST); - lstBasicCommands.AddTail(ID_NEW_TASK); - lstBasicCommands.AddTail(ID_NEW_NOTE); - lstBasicCommands.AddTail(ID_DUMMY); - lstBasicCommands.AddTail(ID_VIEW_FOLDER_LIST); - lstBasicCommands.AddTail(ID_MAIL_SEND); - lstBasicCommands.AddTail(ID_MAIL_SAVE); - lstBasicCommands.AddTail(ID_FILE_SAVE_AS); - lstBasicCommands.AddTail(ID_MAIL_SAVE_ATTACHMENTS); - lstBasicCommands.AddTail(ID_MAIL_SAVE_STATIONERY); - lstBasicCommands.AddTail(ID_MAIL_DELETE); - lstBasicCommands.AddTail(ID_MAIL_MOVE_TO_FOLDER); - lstBasicCommands.AddTail(ID_FILE_PRINT_PREVIEW); - lstBasicCommands.AddTail(ID_FILE_CLOSE); - lstBasicCommands.AddTail(ID_MAIL_ATTACHMENT); - lstBasicCommands.AddTail(ID_MAIL_ITEM); - lstBasicCommands.AddTail(ID_MAIL_SIGNATURE); - lstBasicCommands.AddTail(ID_MAIL_SPELL); - lstBasicCommands.AddTail(ID_MAIL_CLOSE); - lstBasicCommands.AddTail(ID_ADDRESS_BOOK); - lstBasicCommands.AddTail(ID_VIEW_GOTO_HOME); - lstBasicCommands.AddTail(ID_VIEW_GOTO_CALENDAR); - lstBasicCommands.AddTail(ID_VIEW_GOTO_TASKS); - lstBasicCommands.AddTail(ID_VIEW_GOTO_FAVORITES); - - CMFCToolBar::SetBasicCommands(lstBasicCommands); -} - -void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) -{ - CFrameWnd::OnActivate(nState, pWndOther, bMinimized); - - if (nState != WA_INACTIVE) - { - theApp.SetActiveFrame(COutlookDemoApp::MainFrame); - theApp.m_pMainWnd = this; - } -} - -BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) -{ - if (!CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) - { - return FALSE; - } - - // Enable customization button fore all user toolbars: - for (int i = 0; i < uiLastUserToolBarId - uiFirstUserToolBarId + 1; i++) - { - CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); - if (pUserToolbar != NULL) - { - pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, IDS_CUSTOMIZE); - } - } - - return TRUE; -} - -LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) -{ - LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp); - if (lres == 0) - { - return 0; - } - - CMFCToolBar* pUserToolbar = (CMFCToolBar*) lres; - ASSERT_VALID(pUserToolbar); - - pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - pUserToolbar->AdjustLayout(); - return lres; -} - -void CMainFrame::OnOutlookAddPage() -{ - CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)m_wndBarOutlook.GetUnderlyingWindow(); - if (pOutlookBar == NULL) - { - return; - } - - CMFCOutlookBarPane* pPane = m_wndBarOutlook.CreateCustomPage(_T("New Page"), TRUE, CBRS_ALIGN_ANY); - - if (pPane != NULL) - { - OnOutlookRenamePage(); - } -} - -void CMainFrame::OnUpdateOutlookAddPage(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_bOutlookBar2003); -} - -void CMainFrame::OnOutlookAnimation() -{ - CMFCOutlookBarTabCtrl::EnableAnimation(!CMFCOutlookBarTabCtrl::IsAnimation()); -} - -void CMainFrame::OnResetPage() -{ - if (m_pCurrOutlookPage == NULL) - { - ASSERT(FALSE); - return; - } - - ASSERT_VALID(m_pCurrOutlookPage); - - if (AfxMessageBox(IDP_REST_OUTLOOK_PAGE, MB_YESNO) == IDYES) - { - m_pCurrOutlookPage->RestoreOriginalstate(); - } -} - -void CMainFrame::OnUpdateResetPage(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_bOutlookBar2003 && m_pCurrOutlookPage != NULL && m_pCurrOutlookPage->CanBeRestored()); -} - -void CMainFrame::OnOutlookDeletePage() -{ - if (m_pCurrOutlookWnd == NULL) - { - return; - } - - UINT uiPage = m_pCurrOutlookWnd->GetActiveTab(); - - CString strPageName = _T(""); - m_pCurrOutlookWnd->GetTabLabel(uiPage,strPageName); - - CString strMessage; - strMessage.Format(_T("Remove page '%s'?"), strPageName); - - if (AfxMessageBox(strMessage, MB_YESNO) == IDYES) - { - m_wndBarOutlook.RemoveCustomPage(uiPage, m_pCurrOutlookWnd); - } -} - -void CMainFrame::OnOutlookRenamePage() -{ - if (m_pCurrOutlookWnd != NULL) - { - if (!m_pCurrOutlookWnd->IsInPlaceEdit()) - { - m_pCurrOutlookWnd->EnableInPlaceEdit(TRUE); - } - m_pCurrOutlookWnd->StartRenameTab(m_pCurrOutlookWnd->GetActiveTab()); - } -} - -void CMainFrame::OnOutlookShowTextLabels() -{ - m_wndOutlookPane1.EnableTextLabels(!m_wndOutlookPane1.AreTextLabels()); - m_wndOutlookPane12003.EnableTextLabels(!m_wndOutlookPane12003.AreTextLabels()); -} - -void CMainFrame::OnUpdateOutlookRenamePage(CCmdUI* pCmdUI) -{ - BOOL bEnable = (m_pCurrOutlookWnd != NULL) && ((UINT)m_uiHilightedPage != -1); - pCmdUI->Enable(bEnable); -} - -void CMainFrame::OnUpdateOutlookDeletePage(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_bOutlookBar2003 && m_uiHilightedPage != (UINT)-1); -} - -void CMainFrame::OnUpdateOutlookAnimation(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(CMFCOutlookBarTabCtrl::IsAnimation()); -} - -void CMainFrame::OnUpdateOutlookShowTextLabels(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndOutlookPane1.AreTextLabels()); -} - -int CMainFrame::FindFocusedOutlookWnd(CMFCOutlookBarTabCtrl** ppOutlookWnd) -{ - ASSERT(ppOutlookWnd != NULL); - - if (!ppOutlookWnd) - { - return -1; - } - - *ppOutlookWnd = NULL; - // find the outlook from the current point - CPoint pt; - GetCursorPos(&pt); - - CWnd* pWndPoint = m_dockManager.PaneFromPoint(pt, 0); - *ppOutlookWnd = FindOutlookParent(pWndPoint); - - CMFCOutlookBar& bar = m_bOutlookBar2003 ? m_wndBarOutlook2003 : m_wndBarOutlook; - - // find focused outlook - if (*ppOutlookWnd != NULL) - { - CWnd* pWnd = GetFocus(); - - if (pWnd == &bar) - { - *ppOutlookWnd = (CMFCOutlookBarTabCtrl*) bar.GetUnderlyingWindow(); - } - else if (pWnd->IsKindOf(RUNTIME_CLASS(CMFCOutlookBar))) - { - *ppOutlookWnd = (CMFCOutlookBarTabCtrl*)((CMFCOutlookBar*)pWnd)->GetUnderlyingWindow(); - } - else - { - CWnd* pParent = pWnd->GetParent(); - while (pParent != NULL) - { - if (pParent->IsKindOf(RUNTIME_CLASS(CMFCOutlookBar))) - { - *ppOutlookWnd = (CMFCOutlookBarTabCtrl*)((CMFCOutlookBar*)pParent)->GetUnderlyingWindow(); - break; - } - pParent = pParent->GetParent(); - } - } - } - - if (*ppOutlookWnd != NULL) - { - return(*ppOutlookWnd)->GetActiveTab(); - } - - return -1; -} - -CMFCOutlookBarTabCtrl* CMainFrame::FindOutlookParent(CWnd* pWnd) -{ - if (pWnd == NULL) - { - return NULL; - } - - if (pWnd->IsKindOf(RUNTIME_CLASS(CMFCOutlookBar))) - { - return(CMFCOutlookBarTabCtrl*)((CMFCOutlookBar*)pWnd)->GetUnderlyingWindow(); - } - - CWnd* pParent = pWnd->GetParent(); - while (pParent != NULL) - { - if (pParent->IsKindOf(RUNTIME_CLASS(CMFCOutlookBar))) - { - return(CMFCOutlookBarTabCtrl*)((CMFCOutlookBar*)pParent)->GetUnderlyingWindow(); - - } - pParent = pParent->GetParent(); - } - return NULL; -} - -void CMainFrame::OnClose() -{ - theApp.WriteInt(_T("OutlookAnimation"), CMFCOutlookBarTabCtrl::IsAnimation()); - CFrameWnd::OnClose(); -} - -void CMainFrame::OnUpdateIndicatorSendReceive(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(); -} - -void CMainFrame::OnChangeLook(BOOL bOutlookBar2003) -{ - BOOL bIsLook2003 = CMFCVisualManager::GetInstance()->IsKindOf(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - - CMFCOutlookBar& bar = m_bOutlookBar2003 ? m_wndBarOutlook2003 : m_wndBarOutlook; - - m_bOutlookBar2003 = bOutlookBar2003; - - if ((bar.GetStyle() & WS_VISIBLE) != 0) - { - if (m_bOutlookBar2003) - { - ShowPane(&m_wndBarOutlook2003, TRUE, FALSE, TRUE); - ShowPane(&m_wndBarOutlook, FALSE, FALSE, TRUE); - } - else - { - ShowPane(&m_wndBarOutlook, TRUE, FALSE, TRUE); - ShowPane(&m_wndBarOutlook2003, FALSE, FALSE, TRUE); - } - } - - // Reload toolbar images: - CWindowDC dc(NULL); - int nBitsPerPixel = dc.GetDeviceCaps(BITSPIXEL); - - BOOL bIsHiColor = bIsLook2003 && nBitsPerPixel > 16; - - CMFCToolBar::ResetAllImages(); - - CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, bIsHiColor ? IDB_MENU_IMAGE_HC : 0); - - m_wndToolBar.LoadBitmap(bIsHiColor ? IDB_TOOLBAR_HC : IDR_MAINFRAME); - m_wndToolBarAdvanced.LoadBitmap(bIsHiColor ? IDB_ADVANCED_HC : IDR_ADVANCED); - m_wndToolBarWeb.LoadBitmap(bIsHiColor ? IDB_WEB_HC : IDR_WEB); - - CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)m_wndBarOutlook2003.GetUnderlyingWindow(); - - if (pOutlookBar != NULL) - { - pOutlookBar->SetImageList(bIsHiColor ? IDB_PAGES_HC : IDB_PAGES, 24); - pOutlookBar->SetToolbarImageList(bIsHiColor ? IDB_PAGES_SMALL_HC : IDB_PAGES_SMALL, 16); - - m_wndBarOutlook2003.RecalcLayout(); - } - - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - CMailFrame::OnChangeLook(); -} - -void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) -{ - m_wndCaption.SetFont(NULL); - - CFrameWnd::OnSettingChange(uFlags, lpszSection); - - m_wndCaption.SetFont(&afxGlobalData.fontBold); -} - -void CMainFrame::OnEnable( BOOL bEnable ) -{ - CWnd* pWnd = GetNextWindow(); - while (pWnd != NULL) - { - if (pWnd->IsKindOf(RUNTIME_CLASS(CFrameWndEx))) - { - pWnd->EnableWindow(bEnable); - } - pWnd = pWnd->GetNextWindow(); - } -} - -void CMainFrame::OnViewCaptionbar() -{ - ShowPane(&m_wndCaption, !(m_wndCaption.GetStyle() & WS_VISIBLE), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewCaptionbar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndCaption.GetStyle() & WS_VISIBLE); -} - -void CMainFrame::OnViewFolderList() -{ - ShowPane(&m_wndFolderList, !(m_wndFolderList.GetStyle() & WS_VISIBLE), FALSE, TRUE); - RecalcLayout(); -} - -void CMainFrame::OnUpdateViewFolderList(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndFolderList.GetStyle() & WS_VISIBLE); -} - -void CMainFrame::OnViewOutlookbar() -{ - CMFCOutlookBar& bar = m_bOutlookBar2003 ? m_wndBarOutlook2003 : m_wndBarOutlook; - - ShowPane(&bar, !(bar.GetStyle() & WS_VISIBLE), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewOutlookbar(CCmdUI* pCmdUI) -{ - CMFCOutlookBar& bar = m_bOutlookBar2003 ? m_wndBarOutlook2003 : m_wndBarOutlook; - pCmdUI->SetCheck(bar.GetStyle() & WS_VISIBLE); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MainFrm.h deleted file mode 100644 index 24fea1699f485..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/MainFrm.h +++ /dev/null @@ -1,174 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define CFrameWnd CFrameWndEx - -#include "FolderListBar.h" -#include "CalendarBar.h" - -class CWorkspaceObj; - -class CMyOutlookBar : public CMFCOutlookBar -{ - virtual BOOL AllowShowOnPaneMenu() const; - virtual void GetPaneName(CString& strName) const - { - strName = _T("Outlook Bar"); - } -}; - -class CShellTreeCtrl : public CMFCShellTreeCtrl -{ - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) - { - BOOL bRes = CMFCShellTreeCtrl::OnNotify(wParam, lParam, pResult); - - NMHDR* pNMHDR = (NMHDR*)lParam; - ASSERT (pNMHDR != NULL); - - if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips () != NULL) - { - GetToolTips ()->SetWindowPos (&wndTop, -1, -1, -1, -1, - SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); - } - - return bRes; - } -}; - -class CMainFrame : public CFrameWnd -{ -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - BOOL IsOutlookBar2003() const - { - return m_bOutlookBar2003; - } - -// Operations -public: - void SetWorkSpace(CWorkspaceObj* pWorkSpace); - void OnCloseFoldersPopup(BOOL bKeep); - virtual void AdjustDockingLayout(HDWP hdwp = NULL); - - void OnChangeLook(BOOL bOutlookBar2003); - -// Overrides -public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual void RecalcLayout(BOOL bNotify = TRUE); - virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL); - -protected: - virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - - CImageList m_imlStatusAnimation; - - CMFCToolBar m_wndToolBar; - CMFCToolBar m_wndToolBarAdvanced; - CMFCToolBar m_wndToolBarWeb; - - CMyOutlookBar m_wndBarOutlook; - CMyOutlookBar m_wndBarOutlook2003; - - // Outlook bar panes: - CMFCOutlookBarPane m_wndOutlookPane1; - CMFCOutlookBarPane m_wndOutlookPane2; - CShellTreeCtrl m_wndTree; - CCalendarBar m_wndCalendar; - - // Outlook bar-2003 panes: - CMFCOutlookBarPane m_wndOutlookPane12003; - CMFCOutlookBarPane m_wndOutlookPane22003; - CShellTreeCtrl m_wndTree2003; - CCalendarBar m_wndCalendar2003; - - UINT m_uiHilightedPage; - - CMFCCaptionBar m_wndCaption; - - CFolderListBar m_wndFolderList; - - CSplitterWndEx m_wndSplitter; - - CMFCToolBarImages m_UserImages; - CImageList m_ImagesSmall; - - CObList m_lstWorkspaces; // List of CWorkspaceObj - CWorkspaceObj* m_pCurrWorkSpace; - - BOOL m_bOutlookBar2003; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); - afx_msg void OnOutlookAddPage(); - afx_msg void OnOutlookAnimation(); - afx_msg void OnOutlookDeletePage(); - afx_msg void OnOutlookRenamePage(); - afx_msg void OnOutlookShowTextLabels(); - afx_msg void OnUpdateOutlookRenamePage(CCmdUI* pCmdUI); - afx_msg void OnUpdateOutlookDeletePage(CCmdUI* pCmdUI); - afx_msg void OnUpdateOutlookAnimation(CCmdUI* pCmdUI); - afx_msg void OnUpdateOutlookShowTextLabels(CCmdUI* pCmdUI); - afx_msg void OnResetPage(); - afx_msg void OnUpdateResetPage(CCmdUI* pCmdUI); - afx_msg void OnClose(); - afx_msg void OnUpdateOutlookAddPage(CCmdUI* pCmdUI); - afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); - afx_msg void OnEnable( BOOL bEnable ); - afx_msg void OnViewCaptionbar(); - afx_msg void OnUpdateViewCaptionbar(CCmdUI* pCmdUI); - afx_msg void OnViewFolderList(); - afx_msg void OnUpdateViewFolderList(CCmdUI* pCmdUI); - afx_msg void OnViewOutlookbar(); - afx_msg void OnUpdateViewOutlookbar(CCmdUI* pCmdUI); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarCreateNew(WPARAM,LPARAM); - afx_msg void OnUpdateIndicatorSendReceive(CCmdUI* pCmdUI); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnViewWorkSpace(UINT ud); - afx_msg void OnViewMyComputer(); - afx_msg void OnViewFoldersPopup(); - - DECLARE_MESSAGE_MAP() - - BOOL CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCOutlookBarPane& pane1, CMFCOutlookBarPane& pane2, CShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth); - BOOL CreateCaptionBar(); - - void SetBasicCommands(); - - void AddWorkSpace(const CString& strName, const int iIconIndex, const UINT uiCmd, CMFCOutlookBarPane& pane, const UINT uiNewCmdID, CImageList& images); - int FindFocusedOutlookWnd(CMFCOutlookBarTabCtrl** ppOutlookWnd); - CMFCOutlookBarTabCtrl* FindOutlookParent(CWnd* pWnd); - CMFCOutlookBarTabCtrl* m_pCurrOutlookWnd; - - CMFCOutlookBarPane* m_pCurrOutlookPage; -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.cpp deleted file mode 100644 index 9a8986b4e32e9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.cpp +++ /dev/null @@ -1,232 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" - -#include "MainFrm.h" -#include "OutlookDemoDoc.h" -#include "OutlookDemoView.h" - -#include "AppLookDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoApp - -BEGIN_MESSAGE_MAP(COutlookDemoApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(ID_VIEW_APP_LOOK, OnViewAppLook) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinAppEx::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoApp construction - -COutlookDemoApp::COutlookDemoApp() -{ - m_bLoadSaveFrameBarsOnly = TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only COutlookDemoApp object - -COutlookDemoApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoApp initialization - -BOOL COutlookDemoApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options(including MRU) - - SetActiveFrame(MainFrame); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - InitShellManager(); - - InitTooltipManager(); - - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - theApp.GetTooltipManager()->SetTooltipParams(0xFFFF, RUNTIME_CLASS(CMFCToolTipCtrl), ¶ms); - - // Enable user-defined tools. If you want allow more than 10 tools, // add tools entry to resources(ID_USER_TOOL11, ID_USER_TOOL12,...) - EnableUserTools(ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME, RUNTIME_CLASS(COutlookDemoDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(COutlookDemoView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - LoadCustomState(); - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - // Set application general look: - CAppLookDlg dlg(TRUE); - dlg.DoModal(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoApp message handlers - -int COutlookDemoApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void COutlookDemoApp::PreLoadState() -{ - - GetContextMenuManager()->AddMenu(_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - -void COutlookDemoApp::SetActiveFrame(OUTLOOK_FRAME frame) -{ - CString strOldRegPath = GetRegSectionPath(); - - // Save user tools: - if (GetUserToolsManager() != NULL) - { - GetUserToolsManager()->SaveState(GetRegSectionPath()); - } - - switch (frame) - { - case MainFrame: - SetRegistryBase(_T("Main Frame Settings")); - break; - - case MailFrame: - SetRegistryBase(_T("Mail Settings")); - break; - - default: - ASSERT(FALSE); - } - - // Load user tools: - if (GetUserToolsManager() != NULL) - { - GetUserToolsManager()->LoadState(strOldRegPath); - } -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void COutlookDemoApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoApp message handlers - -void COutlookDemoApp::OnViewAppLook() -{ - CAppLookDlg dlg(FALSE); - dlg.DoModal(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.h deleted file mode 100644 index e704d352016da..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.h +++ /dev/null @@ -1,49 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ -#error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoApp: -// See OutlookDemo.cpp for the implementation of this class -// - -class COutlookDemoApp : public CWinAppEx -{ -public: - COutlookDemoApp(); - - virtual void PreLoadState(); - - enum OUTLOOK_FRAME - { - MainFrame, MailFrame - }; - - void SetActiveFrame(OUTLOOK_FRAME frame); - -// Overrides -public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - afx_msg void OnViewAppLook(); - - DECLARE_MESSAGE_MAP() -}; - -extern COutlookDemoApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.rc deleted file mode 100644 index f0f0b9775676d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemo.rc +++ /dev/null @@ -1,879 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\OutlookDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#ifndef _AFXDLL\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\OutlookDemo.ico" -IDR_OUTTYPE ICON "res\\OutlookDemoDoc.ico" -IDR_MAILFRAME ICON "res\\mail.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDR_ADVANCED BITMAP "res\\advanced.bmp" -IDR_WEB BITMAP "res\\web.bmp" -IDB_OUTLOOK_LARGE BITMAP "res\\outlookl.bmp" -IDB_OUTLOOK_SMALL BITMAP "res\\outlooks.bmp" -IDR_MENU_IMAGES BITMAP "res\\menu_image.bmp" -IDB_PIN BITMAP "res\\pin.bmp" -IDB_HEADER_IMAGES BITMAP "res\\header.bmp" -IDB_LIST_IMAGES BITMAP "res\\list.bmp" -IDR_MAILFRAME BITMAP "res\\mail.bmp" -IDB_ANIMATION BITMAP "res\\animation.bmp" -IDB_PAGES BITMAP "res\\pages.bmp" -IDB_ADVANCED_HC BITMAP "Res\\advanced_hc.bmp" -IDB_WEB_HC BITMAP "Res\\web_hc.bmp" -IDB_MAIL_HC BITMAP "Res\\mail_hc.bmp" -IDB_MENU_IMAGE_HC BITMAP "Res\\menu_image_hc.bmp" -IDB_TOOLBAR_HC BITMAP "Res\\toolbar_hc.bmp" -IDB_PAGES_HC BITMAP "Res\\pages_hc.bmp" -IDB_PAGES_SMALL_HC BITMAP "Res\\pages_small_hc.bmp" -IDB_PAGES_SMALL BITMAP "res\\pages1.bmp" -IDB_OUTLOOK_LARGE_HC BITMAP "Res\\outlookl_hc.bmp" -IDB_OUTLOOK_SMALL_HC BITMAP "Res\\outlooks_hc.bmp" -IDB_ANIMATION_HC BITMAP "Res\\animation_hc.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_SEND_RECEIVE - SEPARATOR - BUTTON ID_ADDRESS_BOOK - SEPARATOR - BUTTON ID_FIND_CONTACT - SEPARATOR - BUTTON ID_APP_ABOUT -END - -IDR_ADVANCED TOOLBAR 16, 16 -BEGIN - BUTTON ID_VIEW_GOTO_HOME - SEPARATOR - BUTTON ID_VIEW_BACK - BUTTON ID_VIEW_FORWARD - SEPARATOR - BUTTON ID_VIEW_UP - BUTTON ID_VIEW_FOLDER_LIST - BUTTON ID_VIEW_PREVIEW_PANE - SEPARATOR - BUTTON ID_EDIT_UNDO - SEPARATOR - BUTTON ID_RULES_WIZARD -END - -IDR_WEB TOOLBAR 16, 16 -BEGIN - BUTTON ID_WEB_BACK - BUTTON ID_WEB_FORWARD - SEPARATOR - BUTTON ID_WEB_STOP - BUTTON ID_WEB_REFRESH - SEPARATOR - BUTTON ID_WEB_START - BUTTON ID_WEB_FIND - SEPARATOR - BUTTON ID_WEB_ADDRESS -END - -IDR_MENU_IMAGES TOOLBAR 16, 16 -BEGIN - BUTTON ID_NEW_MAIL - BUTTON ID_NEW_POST_FOLDER - BUTTON ID_NEW_FOLDER - BUTTON ID_NEW_APPOINTMENT - BUTTON ID_NEW_MEETING - BUTTON ID_NEW_CONTRACT - BUTTON ID_NEW_DISTRIBUTION_LIST - BUTTON ID_NEW_TASK - BUTTON ID_NEW_TASK_REQUEST - BUTTON ID_NEW_JOURNAL_ENTRY - BUTTON ID_NEW_NOTE - BUTTON ID_MAIL_DELETE - BUTTON ID_MAIL_MOVE_TO_FOLDER - BUTTON ID_FILE_PRINT_PREVIEW - BUTTON ID_MAIL_SPELL -END - -IDR_MAILFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_MAIL_SEND - SEPARATOR - BUTTON ID_MAIL_SAVE - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_MAIL_SIGNATURE - BUTTON ID_MAIL_ATTACHMENT - SEPARATOR - BUTTON ID_ADDRESS_BOOK - BUTTON ID_MAIL_CHECK_NAMES - SEPARATOR - BUTTON ID_MAIL_HIGHT_PRIORITY - BUTTON ID_MAIL_LOW_PRIORITY - SEPARATOR - BUTTON ID_MAIL_FLAG - SEPARATOR - BUTTON ID_MAIL_OPTIONS - BUTTON ID_MAIL_FONTSIZE - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - POPUP "&New" - BEGIN - MENUITEM "&Mail Message...", ID_NEW_MAIL - MENUITEM "Fa&x Message...", ID_NEW_FAX - MENUITEM "&Post in this Folder...", ID_NEW_POST_FOLDER - MENUITEM SEPARATOR - MENUITEM "&Folder...", ID_NEW_FOLDER - MENUITEM "Outlook Bar Shortcut...", ID_NEW_SHORTCUT - MENUITEM SEPARATOR - MENUITEM "&Appointment...", ID_NEW_APPOINTMENT - MENUITEM "Meeting Re&quest....", ID_NEW_MEETING - MENUITEM "&Contract...", ID_NEW_CONTRACT - MENUITEM "&Distribution List...", ID_NEW_DISTRIBUTION_LIST - MENUITEM "&Task...", ID_NEW_TASK - MENUITEM "Task &Request...", ID_NEW_TASK_REQUEST - MENUITEM "&Journal Entry...", ID_NEW_JOURNAL_ENTRY - MENUITEM "&Note...", ID_NEW_NOTE - END - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Go to" - BEGIN - MENUITEM "&Home", ID_VIEW_GOTO_HOME - MENUITEM "&Calendar", ID_VIEW_GOTO_CALENDAR - MENUITEM "&Drafts", ID_VIEW_GOTO_DRAFTS - MENUITEM "&Inbox", ID_VIEW_GOTO_INBOX - MENUITEM "&Journal", ID_VIEW_GOTO_JOURNAL - MENUITEM "&Notes", ID_VIEW_GOTO_NOTES - MENUITEM "&Outbox", ID_VIEW_GOTO_OUTBOX - MENUITEM "&Sent Items", ID_VIEW_GOTO_SENTITEMS - MENUITEM "&Tasks", ID_VIEW_GOTO_TASKS - MENUITEM SEPARATOR - MENUITEM "My Computer", ID_VIEW_MY_COMPUTER - MENUITEM "Personal", ID_VIEW_GOTO_PERSONAL - MENUITEM "Favorites", ID_VIEW_GOTO_FAVORITES - END - MENUITEM SEPARATOR - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM SEPARATOR - MENUITEM "&Outlook Bar", ID_VIEW_OUTLOOKBAR - MENUITEM "&Folder List", ID_VIEW_FOLDER_LIST - MENUITEM "&Preview Pane", ID_VIEW_PREVIEW_PANE - MENUITEM "&Caption bar", ID_VIEW_CAPTIONBAR - MENUITEM SEPARATOR - MENUITEM "&Application Look...", ID_VIEW_APP_LOOK - END - POPUP "&Tools" - BEGIN - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - MENUITEM "&", ID_TOOLS_ENTRY - END - POPUP "&Actions" - BEGIN - MENUITEM "New &Mail Message...", ID_NEW_MAIL - MENUITEM "New Fa&x Message...", ID_NEW_FAX - END - POPUP "&Help" - BEGIN - MENUITEM "&About OutlookDemo...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_DUMMY MENU -BEGIN - POPUP "Dummy" - BEGIN - MENUITEM "", ID_DUMMY - END -END - -IDR_MAILFRAME MENU -BEGIN - POPUP "&File" - BEGIN - POPUP "&New" - BEGIN - MENUITEM "&Mail Message...", ID_NEW_MAIL - MENUITEM "Fa&x Message...", ID_NEW_FAX - MENUITEM "&Post in this Folder...", ID_NEW_POST_FOLDER - MENUITEM SEPARATOR - MENUITEM "&Folder...", ID_NEW_FOLDER - MENUITEM "Outlook Bar Shortcut...", ID_NEW_SHORTCUT - MENUITEM SEPARATOR - MENUITEM "&Appointment...", ID_NEW_APPOINTMENT - MENUITEM "Meeting Re&quest....", ID_NEW_MEETING - MENUITEM "&Contract...", ID_NEW_CONTRACT - MENUITEM "&Distribution List...", ID_NEW_DISTRIBUTION_LIST - MENUITEM "&Task...", ID_NEW_TASK - MENUITEM "Task &Request...", ID_NEW_TASK_REQUEST - MENUITEM "&Journal Entry...", ID_NEW_JOURNAL_ENTRY - MENUITEM "&Note...", ID_NEW_NOTE - END - MENUITEM SEPARATOR - MENUITEM "S&end", ID_MAIL_SEND - MENUITEM SEPARATOR - MENUITEM "&Save", ID_MAIL_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM "Save Attachme&nts...", ID_MAIL_SAVE_ATTACHMENTS - MENUITEM "Sa&ve Stationery...", ID_MAIL_SAVE_STATIONERY - MENUITEM SEPARATOR - MENUITEM "&Delete", ID_MAIL_DELETE - MENUITEM "&Move to Folder...", ID_MAIL_MOVE_TO_FOLDER - MENUITEM "&Copy to Folder...", ID_MAIL_COPY_TO_FOLDER - MENUITEM SEPARATOR - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "&Print...", ID_FILE_PRINT - MENUITEM SEPARATOR - MENUITEM "Pr&operties...", ID_MAIL_PROPERTIES - MENUITEM SEPARATOR - MENUITEM "&Close", ID_MAIL_CLOSE - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo", ID_EDIT_UNDO - MENUITEM "&Redo", ID_EDIT_REDO - MENUITEM SEPARATOR - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END - POPUP "&Insert" - BEGIN - MENUITEM "&File...", ID_MAIL_ATTACHMENT - MENUITEM "&Item....", ID_MAIL_ITEM - MENUITEM "&Signature", ID_MAIL_SIGNATURE - END - POPUP "&Tools" - BEGIN - MENUITEM "&Spelling...", ID_MAIL_SPELL - MENUITEM "Chec&k Names...", ID_MAIL_CHECK_NAMES - MENUITEM "&Address Book...", ID_ADDRESS_BOOK - MENUITEM "&", ID_TOOLS_ENTRY - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END - POPUP "&Help" - BEGIN - MENUITEM "&About OutlookDemo...", ID_APP_ABOUT - END -END - -IDR_POPUP_OLBAR MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Shortcuts Bar &Labels", ID_OUTLOOK_SHOW_TEXT_LABELS - MENUITEM "A&nimation", ID_OUTLOOK_ANIMATION - MENUITEM SEPARATOR - MENUITEM "&Add Page", ID_OUTLOOK_ADD_PAGE - MENUITEM "&Rename Page", ID_OUTLOOK_RENAME_PAGE - MENUITEM "&Delete Page", ID_OUTLOOK_DELETE_PAGE - MENUITEM SEPARATOR - MENUITEM "&Hide Shortcuts Bar", ID_VIEW_OUTLOOKBAR - MENUITEM "R&eset Page", ID_RESET_PAGE - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -IDR_POPUP_OLBAR2003 MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Shortcuts Bar &Labels", ID_OUTLOOK_SHOW_TEXT_LABELS - MENUITEM "A&nimation", ID_OUTLOOK_ANIMATION - MENUITEM SEPARATOR - MENUITEM "&Rename Page", ID_OUTLOOK_RENAME_PAGE - MENUITEM SEPARATOR - MENUITEM "&Hide Shortcuts Bar", ID_VIEW_OUTLOOKBAR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "N", ID_NEW_MAIL, VIRTKEY, CONTROL, NOINVERT - "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT - "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About OutlookDemo" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "OutlookDemo Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT "� 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_MAILBAR DIALOGEX 0, 0, 126, 62 -STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - PUSHBUTTON "&To...",IDC_MAIL_TO,7,7,36,14 - EDITTEXT IDC_MAIL_TO_NAME,51,7,68,14,ES_AUTOHSCROLL - PUSHBUTTON "&Cc...",IDC_MAIL_CC,7,24,36,14 - EDITTEXT IDC_MAIL_CC_NAME,51,24,68,14,ES_AUTOHSCROLL - LTEXT "&Subject:",IDC_STATIC,7,43,36,8,0,WS_EX_TRANSPARENT - EDITTEXT IDC_MAIL_SUBJECT_NAME,51,41,68,14,ES_AUTOHSCROLL -END - -IDD_APP_LOOK DIALOGEX 0, 0, 292, 165 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Application Look" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "Welcome to MFC! The library supports various application looks such as Microsoft� Office 2000/XP/2003, Microsoft� Visual Studio� 97/.NET and more.",IDC_STATIC,7,12,278,19 - LTEXT "Please choose the preferred look and click OK to continue.",IDC_STATIC,17,36,214,8 - CONTROL "Microsoft� Office XP",IDC_APP_LOOK1,"Button",BS_AUTORADIOBUTTON | WS_GROUP,50,56,83,10 - CONTROL "Microsoft� Office 2003",IDC_APP_LOOK2,"Button",BS_AUTORADIOBUTTON,50,71,89,10 - CONTROL "Microsoft� Office 2007:",IDC_APP_LOOK3,"Button",BS_AUTORADIOBUTTON,50,86,91,10 - COMBOBOX IDC_STYLE2007,158,86,102,131,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "OutlookBar Office 2003-style",IDC_OUTLOOKBAR2003,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,61,101,106,10 - LTEXT "Note: you may change the application look in ""View | Application Look..."" dialog.",IDC_STATIC,17,123,268,8 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,136,278,1 - CONTROL "Show this dialog at startup",IDC_SHOW_AT_STARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,144,99,10 - DEFPUSHBUTTON "OK",IDOK,121,144,50,14 - PUSHBUTTON "Cancel",IDCANCEL,179,144,50,14 - PUSHBUTTON "Apply",IDC_APPLY,235,144,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "OutlookDemo MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "OutlookDemo" - VALUE "LegalCopyright", "Copyright (C) 2000" - VALUE "OriginalFilename", "OutlookDemo.EXE" - VALUE "ProductName", "OutlookDemo Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_MAILBAR, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 119 - VERTGUIDE, 51 - TOPMARGIN, 7 - BOTTOMMARGIN, 55 - END - - IDD_APP_LOOK, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 285 - VERTGUIDE, 17 - VERTGUIDE, 50 - TOPMARGIN, 7 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_APP_LOOK DLGINIT -BEGIN - IDC_STYLE2007, 0x403, 12, 0 -0x754c, 0x616e, 0x2d20, 0x6220, 0x756c, 0x0065, - IDC_STYLE2007, 0x403, 17, 0 -0x624f, 0x6973, 0x6964, 0x6e61, 0x2d20, 0x6220, 0x616c, 0x6b63, "\000" - IDC_STYLE2007, 0x403, 5, 0 -0x7141, 0x6175, "\000" - IDC_STYLE2007, 0x403, 7, 0 -0x6953, 0x766c, 0x7265, "\000" - 0 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "OutlookDemo\n\nOutlook\n\n\nOutlookDemo.Document\nOutlook Document" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "OutlookDemo" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" - ID_INDICATOR_ANIMATION " Send/Receive " -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE -BEGIN - ID_VIEW_USER_TOOLBAR8 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR9 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR10 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_MY_COMPUTER "Go to My Computer\nMy Computer" - ID_TOOLS_ENTRY "User-defined tools\nUser Tools" - ID_USER_TOOL1 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL2 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL3 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL4 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL5 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL6 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL7 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL8 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL9 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL10 "Activates user-defined tool\nUser Tool" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the standard toolbar\nToggle Standard ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE -BEGIN - ID_WEB_STOP "Stop the current jump\nStop" - ID_WEB_REFRESH "Refresh\nRefresh" - ID_WEB_START "Start page\nStart" - ID_WEB_FIND "Find\nFind" - ID_WEB_ADDRESS "Address\nAddress" - ID_VIEW_OUTLOOKBAR "Show or hide the Outlook bar\nToggle Outlook Bar" - ID_VIEW_CAPTIONBAR "Show or hide the caption bar\nToggle Caption Bar" - ID_VIEW_GOTO_HOME "Home Page\nHome" - ID_VIEW_GOTO_CALENDAR "Calendar\nCalendar" - ID_VIEW_GOTO_DRAFTS "Drafts\nDrafts" - ID_VIEW_GOTO_INBOX "Inbox\nInbox" - ID_VIEW_GOTO_JOURNAL "Journal\nJournal" - ID_VIEW_GOTO_NOTES "Notes\nNotes" - ID_VIEW_GOTO_OUTBOX "Outbox\nOutbox" - ID_VIEW_GOTO_SENTITEMS "Sent items\nSent Items" - ID_VIEW_GOTO_TASKS "Tasks\nTasks" -END - -STRINGTABLE -BEGIN - ID_VIEW_APP_LOOK "Modify the application general look\nApplication Look" - ID_VIEW_OUTLOOKBAR2003 "Show or hide the Outlook bar\nToggle Outlook Bar" -END - -STRINGTABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" - IDS_ADV_TOOLBAR "Advanced" - IDS_WEB_TOOLBAR "Web" - IDS_CUSTOMIZE "Customize..." - IDS_FOLDER_POPUP_CAPTION "Click push pin to keep open" - IDP_REST_OUTLOOK_PAGE "Do you really want to reset the page content?" -END - -STRINGTABLE -BEGIN - ID_VIEW_USER_TOOLBAR1 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR2 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR3 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR4 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR5 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR6 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR7 "Show or hide the user toolbar\nToggle User ToolBar" -END - -STRINGTABLE -BEGIN - ID_SEND_RECEIVE "Send and receive mails\nSend/Receive" - ID_ADDRESS_BOOK "Address Book\nAddress Book" - ID_FIND_CONTACT "Find a contact\nFind Contact" - ID_VIEW_HOME "Show start page\nHome" - ID_VIEW_BACK "View previous folder\nPrevious Folder" - ID_VIEW_FORWARD "View next folder\nNext Folder" - ID_SHOW_FOLDERS_POPUP "" - ID_VIEW_UP "Up one level\nUp one level" - ID_VIEW_FOLDER_LIST "Show or hide the folder list\nFolder List" - ID_VIEW_PREVIEW_PANE "Show or hide preview pane\nPreview Pane" - ID_MAIL_MENU "Mail\nMail" - ID_RULES_WIZARD "Rules wizard\nRules Wizard" - ID_VIEW_ADVANCED_TOOLBAR - "Show or hide the advanced toolbar\nToggle Advanced ToolBar" - ID_VIEW_WEB_TOOLBAR "Show or hide the web toolbar\nToggle Web ToolBar" - ID_WEB_BACK "Back\nBack" - ID_WEB_FORWARD "Forward\nForward" -END - -STRINGTABLE -BEGIN - ID_VIEW_GOTO_PERSONAL "Go to Personal Folder\nGo to Personal" - ID_VIEW_GOTO_FAVORITES "Go To Favorites\nFavorites" - ID_NEW_MAIL "New mail message\nNew Mail" - ID_NEW_FAX "New Fax Message\nFax Message" - ID_NEW_POST_FOLDER "Post in this Folder\nPost in this Folder" - ID_NEW_APPOINTMENT "New appointment\nAppointment" - ID_NEW_MEETING "New Meeting Request\nMeeting Request" - ID_NEW_FOLDER "Create a new folder\nNew Folder" - ID_NEW_SHORTCUT "Create new Outlook Bar Shortcut\nOutlook Bar Shortcut" - ID_NEW_CONTRACT "Create a new contract\nNew Contract" - ID_NEW_DISTRIBUTION_LIST "New Distribution List\nDistribution List" - ID_NEW_TASK "New Task\nNew Task" - ID_NEW_TASK_REQUEST "New Task Request\nTask Request" - ID_NEW_JOURNAL_ENTRY "Journal Entry\nJournal Entry" - ID_NEW_NOTE "New Note\nNote" -END - -STRINGTABLE -BEGIN - ID_MAIL_SEND "Send a mail\nSend Mail" - ID_MAIL_SAVE "Save a mail\nSave Mail" - ID_MAIL_PRINT "Print Mail\nPrint Mail" - ID_MAIL_SIGNATURE "Insert signature\nSignature" - ID_MAIL_ATTACHMENT "Insert file\nAttachment" - ID_MAIL_CHECK_NAMES "Check names\nCheck Names" - ID_MAIL_HIGHT_PRIORITY "Mail high priority\nHigh Priotity" - ID_MAIL_LOW_PRIORITY "Mail low priority\nLow Priority" - ID_MAIL_FLAG "Flag mail\nFlag" - ID_MAIL_OPTIONS "Set mail options\nOptions" - ID_MAIL_FONTSIZE "Set font size\nFont Size" - ID_MAIL_SAVE_ATTACHMENTS "Save Attachments\nSave Attachments" -END - -STRINGTABLE -BEGIN - ID_MAIL_SAVE_STATIONERY "Save Stationery\nSave Stationery" - ID_MAIL_DELETE "Delete mail\nDelete Mail" - ID_MAIL_MOVE_TO_FOLDER "Move mail to folder\nMove to Folder" - ID_MAIL_COPY_TO_FOLDER "Copy Mail to Folder\nCopy to Folder" - ID_MAIL_PROPERTIES "Mail properties\nMail properties" - ID_MAIL_ITEM "Insert a new item\nItem" - ID_MAIL_SPELL "Spell check\nSpelling" - ID_VIEW_MAIL_TOOLBAR "Show or hide the standard toolbar\nToggle Standard ToolBar" - ID_MAIL_CLOSE "Close the active document\nClose" - ID_OUTLOOK_SHOW_TEXT_LABELS - "Toggle Shortcuts Bar Labels\nShortcuts Bar Labels" - ID_OUTLOOK_ADD_PAGE "Add a new page to the shortcuts bar\nAdd Page" - ID_OUTLOOK_RENAME_PAGE "Rename the current shortcuts bar page\nRename Page" - ID_OUTLOOK_DELETE_PAGE "Remove the current page from the shortcuts bar\nDelete Page" - ID_OUTLOOK_ANIMATION "Toggle Shortcuts Bar Pages Animation\nAnimation" - ID_RESET_PAGE "Reset a current page content\nReset Page" -END - -STRINGTABLE -BEGIN - IDR_MAILFRAME "New Mail\n\nNewMail\n\n\nOutlookDemo.Document\nOutlook Document" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\OutlookDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoDoc.cpp deleted file mode 100644 index 65a20db33f4a0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoDoc.cpp +++ /dev/null @@ -1,267 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" - -#include "OutlookDemoDoc.h" -#include "MailFrame.h" -#include "MailView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoDoc - -IMPLEMENT_DYNCREATE(COutlookDemoDoc, CDocument) - -BEGIN_MESSAGE_MAP(COutlookDemoDoc, CDocument) - ON_COMMAND(ID_NEW_APPOINTMENT, OnNewAppointment) - ON_COMMAND(ID_NEW_CONTRACT, OnNewContract) - ON_COMMAND(ID_NEW_DISTRIBUTION_LIST, OnNewDistributionList) - ON_COMMAND(ID_NEW_FAX, OnNewFax) - ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) - ON_COMMAND(ID_NEW_JOURNAL_ENTRY, OnNewJournalEntry) - ON_COMMAND(ID_NEW_MAIL, OnNewMail) - ON_COMMAND(ID_NEW_MEETING, OnNewMeeting) - ON_COMMAND(ID_NEW_NOTE, OnNewNote) - ON_COMMAND(ID_NEW_POST_FOLDER, OnNewPostFolder) - ON_COMMAND(ID_NEW_SHORTCUT, OnNewShortcut) - ON_COMMAND(ID_NEW_TASK, OnNewTask) - ON_COMMAND(ID_NEW_TASK_REQUEST, OnNewTaskRequest) - ON_COMMAND(ID_SEND_RECEIVE, OnSendReceive) - ON_COMMAND(ID_ADDRESS_BOOK, OnAddressBook) - ON_COMMAND(ID_FIND_CONTACT, OnFindContact) - ON_COMMAND(ID_WEB_ADDRESS, OnWebAddress) - ON_COMMAND(ID_WEB_BACK, OnWebBack) - ON_COMMAND(ID_WEB_FIND, OnWebFind) - ON_COMMAND(ID_WEB_REFRESH, OnWebRefresh) - ON_COMMAND(ID_WEB_START, OnWebStart) - ON_COMMAND(ID_VIEW_UP, OnViewUp) - ON_COMMAND(ID_VIEW_BACK, OnViewBack) - ON_COMMAND(ID_RULES_WIZARD, OnRulesWizard) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoDoc construction/destruction - -COutlookDemoDoc::COutlookDemoDoc() -{ - // TODO: add one-time construction code here - -} - -COutlookDemoDoc::~COutlookDemoDoc() -{ -} - -BOOL COutlookDemoDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - //(SDI documents will reuse this document) - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoDoc serialization - -void COutlookDemoDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoDoc diagnostics - -#ifdef _DEBUG -void COutlookDemoDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void COutlookDemoDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoDoc commands - -void COutlookDemoDoc::OnNewAppointment() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewContract() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewDistributionList() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewFax() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewFolder() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewJournalEntry() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewMeeting() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewNote() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewPostFolder() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewShortcut() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewTask() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewTaskRequest() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnSendReceive() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnAddressBook() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnFindContact() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnWebAddress() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnWebBack() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnWebFind() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnWebRefresh() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnWebStart() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnViewUp() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnViewBack() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnRulesWizard() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoDoc::OnNewMail() -{ - theApp.SaveState(); - - CMailFrame* pMailFrame = new CMailFrame; - - CCreateContext context; - - context.m_pCurrentDoc = this; - context.m_pCurrentFrame = NULL; - context.m_pNewDocTemplate = NULL; - context.m_pLastView = NULL; - context.m_pNewViewClass = RUNTIME_CLASS(CMailView); - - pMailFrame->LoadFrame(IDR_MAILFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context); - - pMailFrame->ShowWindow(SW_SHOW); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoDoc.h deleted file mode 100644 index b0bc5b9b4af89..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoDoc.h +++ /dev/null @@ -1,58 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class COutlookDemoDoc : public CDocument -{ -protected: // create from serialization only - COutlookDemoDoc(); - DECLARE_DYNCREATE(COutlookDemoDoc) - -// Overrides -public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~COutlookDemoDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnNewAppointment(); - afx_msg void OnNewContract(); - afx_msg void OnNewDistributionList(); - afx_msg void OnNewFax(); - afx_msg void OnNewFolder(); - afx_msg void OnNewJournalEntry(); - afx_msg void OnNewMail(); - afx_msg void OnNewMeeting(); - afx_msg void OnNewNote(); - afx_msg void OnNewPostFolder(); - afx_msg void OnNewShortcut(); - afx_msg void OnNewTask(); - afx_msg void OnNewTaskRequest(); - afx_msg void OnSendReceive(); - afx_msg void OnAddressBook(); - afx_msg void OnFindContact(); - afx_msg void OnWebAddress(); - afx_msg void OnWebBack(); - afx_msg void OnWebFind(); - afx_msg void OnWebRefresh(); - afx_msg void OnWebStart(); - afx_msg void OnViewUp(); - afx_msg void OnViewBack(); - afx_msg void OnRulesWizard(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoView.cpp deleted file mode 100644 index 026fd62442a19..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoView.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" - -#include "OutlookDemoDoc.h" -#include "OutlookDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoView - -IMPLEMENT_DYNCREATE(COutlookDemoView, CListView) - -BEGIN_MESSAGE_MAP(COutlookDemoView, CListView) - ON_COMMAND(ID_VIEW_PREVIEW_PANE, OnViewPreviewPane) - ON_UPDATE_COMMAND_UI(ID_VIEW_PREVIEW_PANE, OnUpdateViewPreviewPane) - ON_WM_CREATE() - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoView construction/destruction - -COutlookDemoView::COutlookDemoView() -{ - // TODO: add construction code here -} - -COutlookDemoView::~COutlookDemoView() -{ -} - -BOOL COutlookDemoView::PreCreateWindow(CREATESTRUCT& cs) -{ - cs.style |= LVS_REPORT; - return CListView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoView drawing - -void COutlookDemoView::OnDraw(CDC* /*pDC*/) -{ -} - -void COutlookDemoView::OnInitialUpdate() -{ - CListView::OnInitialUpdate(); - - CListCtrl& wndList = GetListCtrl(); - wndList.DeleteAllItems(); - - wndList.InsertItem(0, _T("Microsoft"), 1); - wndList.SetItemText(0, 1, _T("Welcome to MFC!")); -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoView printing - -void COutlookDemoView::OnFilePrintPreview() -{ - AFXPrintPreview(this); -} - -BOOL COutlookDemoView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void COutlookDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void COutlookDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoView diagnostics - -#ifdef _DEBUG -void COutlookDemoView::AssertValid() const -{ - CListView::AssertValid(); -} - -void COutlookDemoView::Dump(CDumpContext& dc) const -{ - CListView::Dump(dc); -} - -COutlookDemoDoc* COutlookDemoView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COutlookDemoDoc))); - return(COutlookDemoDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// COutlookDemoView message handlers - -void COutlookDemoView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu(IDR_CONTEXT_MENU, point, this); -} - -void COutlookDemoView::OnViewPreviewPane() -{ - // TODO: Add your command handler code here - -} - -void COutlookDemoView::OnUpdateViewPreviewPane(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here - -} - -int COutlookDemoView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CListView::OnCreate(lpCreateStruct) == -1) - return -1; - - const int nImageWidth = 12; - - m_ImagesHeader.Create(IDB_HEADER_IMAGES, nImageWidth, 0, RGB(255, 0, 255)); - - CBitmap bmp; - if (bmp.LoadBitmap(IDB_LIST_IMAGES)) - { - m_ImagesList.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 0); - m_ImagesList.Add(&bmp, RGB(255, 0, 255)); - } - - CListCtrl& wndList = GetListCtrl(); - wndList.SetExtendedStyle(LVS_EX_FULLROWSELECT); - - wndList.SetImageList(&m_ImagesList, LVSIL_SMALL); - - wndList.InsertColumn(0, _T("From"), LVCFMT_LEFT, 100); - wndList.InsertColumn(1, _T("Subject"), LVCFMT_LEFT, 200); - - CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*) wndList.GetDlgItem(0); - ASSERT_VALID(pHeaderCtrl); - - pHeaderCtrl->SetImageList(&m_ImagesHeader); - - LVCOLUMN lvColumn; - memset(&lvColumn, 0, sizeof(LVCOLUMN)); - lvColumn.mask = LVCF_IMAGE | LVCF_WIDTH; - lvColumn.fmt = LVCFMT_COL_HAS_IMAGES; - lvColumn.cx = nImageWidth * 2 + 4; - - lvColumn.iImage = 0; - wndList.InsertColumn(2, &lvColumn); - - lvColumn.iImage = 1; - wndList.InsertColumn(3, &lvColumn); - - lvColumn.iImage = 2; - wndList.InsertColumn(4, &lvColumn); - - static int nColumnsOrder [] = { 2, 3, 4, 0, 1 }; - wndList.SetColumnOrderArray(sizeof(nColumnsOrder) / sizeof(int), nColumnsOrder); - - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoView.h deleted file mode 100644 index d8e470384b5ff..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/OutlookDemoView.h +++ /dev/null @@ -1,57 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class COutlookDemoView : public CListView -{ -protected: // create from serialization only - COutlookDemoView(); - DECLARE_DYNCREATE(COutlookDemoView) - -// Attributes -public: - COutlookDemoDoc* GetDocument(); - -protected: - CImageList m_ImagesHeader; - CImageList m_ImagesList; - -// Overrides -public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -protected: - virtual void OnInitialUpdate(); // called first time after construct - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~COutlookDemoView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnViewPreviewPane(); - afx_msg void OnUpdateViewPreviewPane(CCmdUI* pCmdUI); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in OutlookDemoView.cpp -inline COutlookDemoDoc* COutlookDemoView::GetDocument() { return(COutlookDemoDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/PreviewPane.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/PreviewPane.cpp deleted file mode 100644 index c00bc184216c5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/PreviewPane.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "PreviewPane.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int nHorzMargin = 2; -const int nVertMargin = 2; - -///////////////////////////////////////////////////////////////////////////// -// CPreviewPane - -IMPLEMENT_DYNCREATE(CPreviewPane, CView) - -CPreviewPane::CPreviewPane() -{ -} - -CPreviewPane::~CPreviewPane() -{ -} - -BEGIN_MESSAGE_MAP(CPreviewPane, CView) - ON_WM_ERASEBKGND() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPreviewPane drawing - -void CPreviewPane::OnDraw(CDC* pDC) -{ - CRect rectClient; - GetClientRect(rectClient); - - CRect rectCaption = rectClient; - rectCaption.bottom = rectCaption.top + afxGlobalData.GetTextHeight() + 4; - - CRect rectMessage = rectClient; - rectMessage.top = rectCaption.bottom; - - pDC->FillRect(rectCaption, &afxGlobalData.brBarFace); - pDC->FillRect(rectMessage, &afxGlobalData.brWindow); - - int nOldBkMode = pDC->SetBkMode(TRANSPARENT); - COLORREF clrOldText = pDC->SetTextColor(afxGlobalData.clrBarText); - CFont* pOldFont = (CFont*) pDC->SelectStockObject(DEFAULT_GUI_FONT); - - CRect rectText = rectCaption; - rectText.left += 2 * nHorzMargin; - rectText.right -= 2 * nHorzMargin + rectText.Height(); - - CString strCaption = _T("Preview area..."); - pDC->DrawText(strCaption, rectText, DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER); - - pDC->SetTextColor(afxGlobalData.clrWindowText); - - rectText = rectMessage; - rectText.DeflateRect(nHorzMargin, nVertMargin); - - CString strText = _T("Message body"); - pDC->DrawText(strText, rectText, DT_WORDBREAK | DT_END_ELLIPSIS); - - pDC->SelectObject(pOldFont); - pDC->SetTextColor(clrOldText); - pDC->SetBkMode(nOldBkMode); -} - -///////////////////////////////////////////////////////////////////////////// -// CPreviewPane diagnostics - -#ifdef _DEBUG -void CPreviewPane::AssertValid() const -{ - CView::AssertValid(); -} - -void CPreviewPane::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CPreviewPane message handlers - -BOOL CPreviewPane::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/PreviewPane.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/PreviewPane.h deleted file mode 100644 index 5989cd6c92d2a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/PreviewPane.h +++ /dev/null @@ -1,37 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CPreviewPane view - -class CPreviewPane : public CView -{ -protected: - CPreviewPane(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CPreviewPane) - -// Overrides -protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - -// Implementation -protected: - virtual ~CPreviewPane(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/ReadMe.htm deleted file mode 100644 index 75286dad8c56e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,127 +0,0 @@ - - - - OutlookDemo Sample: MFC OutlookDemo Application - - -

- OutlookDemo Sample: MFC OutlookDemo Application

-
-
-
- -

-

-
-

- The OutlookDemo sample demonstrates how to create an application similar to Microsoft - Outlook 2003/2007. You can change the current Visual Theme using the - Application Look dialog, which can be opened from the View | - Application Look… menu. Note the Outlook Bar Office 2003 style - check box. This option allows you to switch between different modes of navigation - pane (known also as outlook bar), which is docked at the left side of application - window. Click the "New" toolbar button to open a mail frame. This window emulates - a form used in Microsoft Outlook to compose email messages.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the OutlookDemo sample

-
-
    -
  1. -

    - Open the solution OutlookDemo.sln. -

    -
  2. -
  3. -

    - On the Build menu, click Build. -

    -
  4. -
  5. -

    - On the Debug menu, click Start Without Debugging. -

    -
  6. -
-
-
-
-

- Keywords

-
-

- The OutlookDemo sample demonstrates the following keywords:

-

- CBasePane; CDockablePane; CFrameWndEx; CMFCButton; CMFCCaptionBar; CMFCMenuBar; - CMFCOutlookBar; CMFCOutlookBarPane; CMFCOutlookBarTabCtrl; CMFCPopupMenu; CMFCShellTreeCtrl; - CMFCStatusBar; CMFCToolBar; CMFCToolBarComboBoxButton; CMFCToolBarImages; CMFCToolBarMenuButton; - CMFCToolBarsCustomizeDialog; CMFCToolTipCtrl; CMFCToolTipInfo; CMFCVisualManager; - CMFCVisualManagerOffice; CPaneDialog; CSplitterWndEx; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/Resource.h deleted file mode 100644 index 3fe0c33967859..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/Resource.h +++ /dev/null @@ -1,171 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by OutlookDemo.rc -// -#define IDC_APPLY 3 -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define IDS_ADV_TOOLBAR 102 -#define IDS_WEB_TOOLBAR 103 -#define IDD_MAILBAR 103 -#define IDS_CUSTOMIZE 104 -#define IDS_FOLDER_POPUP_CAPTION 105 -#define IDP_REST_OUTLOOK_PAGE 106 -#define IDR_MAINFRAME 128 -#define IDR_OUTTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_ADVANCED 148 -#define IDR_POPUP_OLBAR 150 -#define IDR_POPUP_OLBAR2003 151 -#define IDR_WEB 152 -#define IDB_OUTLOOK_LARGE 168 -#define IDB_OUTLOOK_SMALL 169 -#define IDR_MENU_IMAGES 171 -#define IDR_DUMMY 173 -#define IDB_PIN 174 -#define IDB_HEADER_IMAGES 175 -#define IDB_LIST_IMAGES 176 -#define IDR_MAILFRAME 177 -#define IDD_APP_LOOK 180 -#define IDB_ANIMATION 182 -#define IDB_PAGES 183 -#define IDB_ADVANCED_HC 185 -#define IDB_WEB_HC 186 -#define IDB_MAIL_HC 187 -#define IDB_MENU_IMAGE_HC 188 -#define IDB_TOOLBAR_HC 189 -#define IDB_PAGES_HC 190 -#define IDB_PAGES_SMALL_HC 191 -#define IDB_PAGES_SMALL 192 -#define IDB_OUTLOOK_LARGE_HC 193 -#define IDB_OUTLOOK_SMALL_HC 194 -#define IDB_ANIMATION_HC 196 -#define IDD_ABOUTBOX 999 -#define IDC_MAIL 1000 -#define IDC_APP_LOOK1 1012 -#define IDC_APP_LOOK2 1013 -#define IDC_APP_LOOK3 1014 -#define IDC_SHOW_AT_STARTUP 1015 -#define IDC_STYLE2007 1033 -#define IDC_MAIL_TO 1041 -#define IDC_MAIL_CC 1042 -#define IDC_MAIL_TO_NAME 1043 -#define IDC_MAIL_CC_NAME 1044 -#define IDC_OUTLOOKBAR2003 1044 -#define IDC_MAIL_SUBJECT_NAME 1045 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_USER_TOOLBAR1 32793 -#define ID_VIEW_USER_TOOLBAR2 32794 -#define ID_VIEW_USER_TOOLBAR3 32795 -#define ID_VIEW_USER_TOOLBAR4 32796 -#define ID_VIEW_USER_TOOLBAR5 32797 -#define ID_VIEW_USER_TOOLBAR6 32798 -#define ID_VIEW_USER_TOOLBAR7 32799 -#define ID_VIEW_USER_TOOLBAR8 32800 -#define ID_VIEW_USER_TOOLBAR9 32801 -#define ID_VIEW_USER_TOOLBAR10 32802 -#define ID_VIEW_MY_COMPUTER 32803 -#define ID_TOOLS_ENTRY 32805 -#define ID_USER_TOOL1 32806 -#define ID_USER_TOOL2 32807 -#define ID_USER_TOOL3 32808 -#define ID_USER_TOOL4 32809 -#define ID_USER_TOOL5 32810 -#define ID_USER_TOOL6 32811 -#define ID_USER_TOOL7 32812 -#define ID_USER_TOOL8 32813 -#define ID_USER_TOOL9 32814 -#define ID_USER_TOOL10 32815 -#define ID_SEND_RECEIVE 32816 -#define ID_ADDRESS_BOOK 32817 -#define ID_FIND_CONTACT 32818 -#define ID_VIEW_HOME 32819 -#define ID_VIEW_BACK 32820 -#define ID_VIEW_FORWARD 32821 -#define ID_SHOW_FOLDERS_POPUP 32822 -#define ID_VIEW_UP 32823 -#define ID_VIEW_FOLDER_LIST 32824 -#define ID_VIEW_PREVIEW_PANE 32825 -#define ID_MAIL_MENU 32826 -#define ID_RULES_WIZARD 32827 -#define ID_VIEW_ADVANCED_TOOLBAR 32828 -#define ID_VIEW_WEB_TOOLBAR 32829 -#define ID_WEB_BACK 32830 -#define ID_WEB_FORWARD 32831 -#define ID_WEB_STOP 32832 -#define ID_WEB_REFRESH 32833 -#define ID_WEB_START 32834 -#define ID_WEB_FIND 32835 -#define ID_WEB_ADDRESS 32836 -#define ID_VIEW_OUTLOOKBAR 32837 -#define ID_VIEW_CAPTIONBAR 32838 -#define ID_VIEW_GOTO_HOME 32839 -#define ID_VIEW_GOTO_CALENDAR 32840 -#define ID_VIEW_GOTO_DRAFTS 32841 -#define ID_VIEW_GOTO_INBOX 32842 -#define ID_VIEW_GOTO_JOURNAL 32843 -#define ID_VIEW_GOTO_NOTES 32844 -#define ID_VIEW_GOTO_OUTBOX 32845 -#define ID_VIEW_GOTO_SENTITEMS 32846 -#define ID_VIEW_GOTO_TASKS 32847 -#define ID_VIEW_GOTO_PERSONAL 32848 -#define ID_MAIL_BAR 32848 -#define ID_VIEW_GOTO_FAVORITES 32849 -#define ID_NEW_MAIL 32850 -#define ID_NEW_FAX 32851 -#define ID_NEW_POST_FOLDER 32852 -#define ID_NEW_APPOINTMENT 32853 -#define ID_NEW_MEETING 32854 -#define ID_NEW_FOLDER 32855 -#define ID_NEW_SHORTCUT 32856 -#define ID_NEW_CONTRACT 32857 -#define ID_NEW_DISTRIBUTION_LIST 32858 -#define ID_NEW_TASK 32859 -#define ID_NEW_TASK_REQUEST 32860 -#define ID_NEW_JOURNAL_ENTRY 32861 -#define ID_NEW_NOTE 32862 -#define ID_DUMMY 32866 -#define ID_MAIL_SEND 32867 -#define ID_MAIL_SAVE 32868 -#define ID_MAIL_PRINT 32869 -#define ID_MAIL_SIGNATURE 32871 -#define ID_MAIL_ATTACHMENT 32872 -#define ID_MAIL_CHECK_NAMES 32873 -#define ID_MAIL_HIGHT_PRIORITY 32874 -#define ID_MAIL_LOW_PRIORITY 32875 -#define ID_MAIL_FLAG 32876 -#define ID_MAIL_OPTIONS 32877 -#define ID_MAIL_FONTSIZE 32878 -#define ID_MAIL_SAVE_ATTACHMENTS 32879 -#define ID_MAIL_SAVE_STATIONERY 32880 -#define ID_MAIL_DELETE 32881 -#define ID_MAIL_MOVE_TO_FOLDER 32882 -#define ID_MAIL_COPY_TO_FOLDER 32883 -#define ID_MAIL_PROPERTIES 32884 -#define ID_MAIL_ITEM 32885 -#define ID_MAIL_SPELL 32886 -#define ID_VIEW_MAIL_TOOLBAR 32887 -#define ID_MAIL_CLOSE 32888 -#define ID_OUTLOOK_SHOW_BACKGROUND 32889 -#define ID_OUTLOOK_SHOW_TEXT_LABELS 32890 -#define ID_OUTLOOK_ADD_PAGE 32891 -#define ID_OUTLOOK_RENAME_PAGE 32892 -#define ID_OUTLOOK_DELETE_PAGE 32893 -#define ID_OUTLOOK_ANIMATION 32894 -#define ID_RESET_PAGE 32895 -#define ID_VIEW_APP_LOOK 32950 -#define ID_VIEW_OUTLOOKBAR2003 32951 -#define ID_INDICATOR_ANIMATION 59142 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 197 -#define _APS_NEXT_COMMAND_VALUE 32896 -#define _APS_NEXT_CONTROL_VALUE 1045 -#define _APS_NEXT_SYMED_VALUE 107 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/Snippets.txt deleted file mode 100644 index 0afdb66b3f0c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/Snippets.txt +++ /dev/null @@ -1,6 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp: CMFCOutlookBarTabCtrl 1 -MainFrm.cpp: CMFCOutlookBarTabCtrl 2 -MainFrm.cpp: CMFCOutlookBarTabCtrl 3 -MailBar.cpp: CMFCVisualManager::OnFillBarBackground 4 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/StdAfx.cpp deleted file mode 100644 index 1f0ba098236c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/StdAfx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// OutlookDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/WorkspaceObj.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/WorkspaceObj.cpp deleted file mode 100644 index fcd3550344c6a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/WorkspaceObj.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OutlookDemo.h" -#include "WorkspaceObj.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CWorkspaceObj::CWorkspaceObj(const CString& strName, const UINT uiCmd, const int iIconIndex, const UINT uiDefaultNewAction) : - m_strName(strName), m_uiCmd(uiCmd), m_iIconIndex(iIconIndex), m_uiDefaultNewAction(uiDefaultNewAction) -{ -} - -CWorkspaceObj::~CWorkspaceObj() -{ -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/WorkspaceObj.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/WorkspaceObj.h deleted file mode 100644 index 118bf28bda9e3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/WorkspaceObj.h +++ /dev/null @@ -1,22 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CWorkspaceObj : public CObject -{ -public: - CWorkspaceObj(const CString& strName, const UINT uiCmd, const int iIconIndex, const UINT uiDefaultNewAction); - virtual ~CWorkspaceObj(); - - const CString m_strName; - const UINT m_uiCmd; - const int m_iIconIndex; - const UINT m_uiDefaultNewAction; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/outlookdemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/outlookdemo.vcxproj deleted file mode 100644 index c864b9f7e84a6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/outlookdemo.vcxproj +++ /dev/null @@ -1,244 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2248F8B6-80A9-416F-822C-073E60798DAE} - OutlookDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - true - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - false - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - false - X64 - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX64 - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemo.rc2 deleted file mode 100644 index 5a62d5a9b7a52..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// BCGVOUTLOOKDEMO.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemoDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemoDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/OutlookDemoDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/Toolbar.bmp deleted file mode 100644 index 9b1e758c81bb3..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/advanced.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/advanced.bmp deleted file mode 100644 index 95c13c4a3c082..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/advanced.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/advanced_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/advanced_hc.bmp deleted file mode 100644 index 66bfe472573dc..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/advanced_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/animation.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/animation.bmp deleted file mode 100644 index d85c1b145e9b7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/animation.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/animation_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/animation_hc.bmp deleted file mode 100644 index 6c87d111557cf..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/animation_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/header.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/header.bmp deleted file mode 100644 index d2f77448658d7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/header.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/list.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/list.bmp deleted file mode 100644 index 9c7e5e0bc5459..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/list.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail.bmp deleted file mode 100644 index 31d472ba74bc5..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail.ico deleted file mode 100644 index a7c96b4cbe9e2..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail_hc.bmp deleted file mode 100644 index bf9e98131329c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/mail_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/menu_image.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/menu_image.bmp deleted file mode 100644 index e3d73745c75ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/menu_image.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/menu_image_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/menu_image_hc.bmp deleted file mode 100644 index 0b3fcbc63ebc1..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/menu_image_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlookl.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlookl.bmp deleted file mode 100644 index a081e17c9a1f2..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlookl.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlookl_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlookl_hc.bmp deleted file mode 100644 index 6607b554799ba..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlookl_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlooks.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlooks.bmp deleted file mode 100644 index ebe4ef91d5c44..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlooks.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlooks_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlooks_hc.bmp deleted file mode 100644 index 08bfb140cd762..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/outlooks_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages.bmp deleted file mode 100644 index 28c7202e9681f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages1.bmp deleted file mode 100644 index f48e621cb53e1..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages_hc.bmp deleted file mode 100644 index d5850bce033ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages_small_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages_small_hc.bmp deleted file mode 100644 index b6fd7c2ebfdec..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pages_small_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pin.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pin.bmp deleted file mode 100644 index 9d18bc2136ef1..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/pin.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/toolbar_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/toolbar_hc.bmp deleted file mode 100644 index 0a603637bc480..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/toolbar_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/web.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/web.bmp deleted file mode 100644 index 609d9eed1e63e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/web.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/web_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/web_hc.bmp deleted file mode 100644 index 420a8530426fc..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/res/web_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/stdafx.h deleted file mode 100644 index 02c274cb1853b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/stdafx.h +++ /dev/null @@ -1,44 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions -#include -#include - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookDemo/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/MainFrm.cpp deleted file mode 100644 index f36923ce359f0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/MainFrm.cpp +++ /dev/null @@ -1,538 +0,0 @@ -#include "stdafx.h" -#include "OutlookMultiViews.h" - -#include "MainFrm.h" - -#include "View1.h" -#include "View2.h" -#include "View3.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_COMMAND(ID_VIEW_OUTLOOKBAR, OnViewOutlookBar) - ON_UPDATE_COMMAND_UI(ID_VIEW_OUTLOOKBAR, OnUpdateViewOutlookBar) - ON_COMMAND_RANGE(ID_SHORTCUT_1, ID_SHORTCUT_4, OnOutlookBarShortcut) - ON_UPDATE_COMMAND_UI_RANGE(ID_SHORTCUT_1, ID_SHORTCUT_4, OnUpdateOutlookBarShortcut) - ON_COMMAND(ID_VIEW_CAPTIONBAR, OnViewCaptionBar) - ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTIONBAR, OnUpdateViewCaptionBar) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnUpdateAppLook) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_nAppLook = theApp.GetInt (_T("ApplicationLook"), ID_VIEW_APPLOOK_2003); - - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - OnAppLook (m_nAppLook); - - CMFCToolBar::EnableQuickCustomization (); - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_4); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - m_wndToolBar.SetWindowText (_T("Standard")); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - - //------------------------------------------------------------------ - // Outlook bar will be created at left, so temporary disable docking - // at the left side: - //------------------------------------------------------------------ - EnableDocking (CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT); - - if (!CreateShortcutsBar ()) - { - TRACE0("Failed to create shortcuts bar\n"); - return -1; // fail to create - } - - //---------------------------------------------------- - // Outlook bar is created and docking on the left side - // should be allowed. - //---------------------------------------------------- - EnableDocking (CBRS_ALIGN_LEFT); - - if (!m_wndCaptionBar.Create (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this, - ID_VIEW_CAPTIONBAR, -1)) - { - TRACE0("Failed to create caption bar\n"); - return -1; // fail to create - } - - m_wndCaptionBar.SetFlatBorder (); - m_wndCaptionBar.SetText (_T("View 1")); - m_bmpCaption.LoadBitmap (IDB_CAPTION); - m_wndCaptionBar.SetBitmap (m_bmpCaption, RGB (255, 0, 255)); - - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnViewOutlookBar() -{ - ShowPane (&m_wndShortcutsBar, - !(m_wndShortcutsBar.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewOutlookBar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndShortcutsBar.IsVisible ()); -} - -void CMainFrame::OnOutlookBarShortcut(UINT id) -{ - const int nIndex = id - ID_SHORTCUT_1; - - ASSERT( nIndex >=0 && nIndex < NUMVIEWS ); - if ( nIndex < 0 || nIndex >= NUMVIEWS ) - return; - - if (!m_pViews) - return; - - CView* pNewView = m_pViews[nIndex]; - if (!pNewView) - return; - - CView* pActiveView =GetActiveView(); - - if ( !pActiveView ) // No currently active view - return; - - if ( pNewView == pActiveView ) // Already there - return; - - m_nCurView = nIndex; // Store the new current view's index - - // exchange view window ID's so RecalcLayout() works - UINT temp = ::GetWindowLong(pActiveView->m_hWnd, GWL_ID); - ::SetWindowLong(pActiveView->m_hWnd, GWL_ID, - ::GetWindowLong(pNewView->m_hWnd, GWL_ID)); - ::SetWindowLong(pNewView->m_hWnd, GWL_ID, temp); - - // Display and update the new current view - hide the old one - pActiveView->ShowWindow(SW_HIDE); - pNewView->ShowWindow(SW_SHOW); - SetActiveView(pNewView); - RecalcLayout(); - pNewView->Invalidate(); - - CString strCaption; - strCaption.Format (_T("View %d"), nIndex + 1); - - m_wndCaptionBar.SetText (strCaption); - m_wndCaptionBar.RedrawWindow (); -} - -void CMainFrame::OnUpdateOutlookBarShortcut(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (pCmdUI->m_nID == ID_SHORTCUT_1 + m_nCurView); -} - -void CMainFrame::OnViewCaptionBar() -{ - ShowPane (&m_wndCaptionBar, - !(m_wndCaptionBar.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewCaptionBar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndCaptionBar.IsVisible ()); -} - -BOOL CMainFrame::CreateShortcutsBar () -{ - CMFCOutlookBarTabCtrl::EnableAnimation (); - - const int nInitialWidth = 150; - const CString strCaption = _T("Shortcuts"); - - // - // int nInitialWidth - // CString strCaption - if (!m_wndShortcutsBar.Create (strCaption, this, - CRect (0, 0, nInitialWidth, nInitialWidth), - ID_VIEW_OUTLOOKBAR, WS_CHILD | WS_VISIBLE | CBRS_LEFT)) - { - TRACE0("Failed to create outlook bar\n"); - return FALSE; // fail to create - } - // - - CMFCOutlookBarTabCtrl* pShortcutsBarContainer = DYNAMIC_DOWNCAST (CMFCOutlookBarTabCtrl, m_wndShortcutsBar.GetUnderlyingWindow ()); - if (pShortcutsBarContainer == NULL) - { - TRACE0("Cannot get outlook bar container\n"); - return FALSE; - } - - // - CImageList images; - images.Create (IDB_SHORTCUTS, 32, 0, RGB (255, 0, 255)); - - // Create first page: - m_wndShortcutsPane1.Create (&m_wndShortcutsBar, AFX_DEFAULT_TOOLBAR_STYLE, ID_SHORTCUTS_PANE_1); - // The this pointer points to a CMainFrame class which extends the CFrameWnd class - m_wndShortcutsPane1.SetOwner (this); - m_wndShortcutsPane1.EnableTextLabels (); - m_wndShortcutsPane1.EnableDocking (CBRS_ALIGN_ANY); - m_wndShortcutsPane1.EnablePageScrollMode(); - m_wndShortcutsPane1.SetBackColor(RGB(0,255,0)); - - m_wndShortcutsPane1.AddButton (images.ExtractIcon (0), _T("View 1"), ID_SHORTCUT_1); - m_wndShortcutsPane1.AddButton (images.ExtractIcon (1), _T("View 2"), ID_SHORTCUT_2); - m_wndShortcutsPane1.AddButton (images.ExtractIcon (2), _T("View 3"), ID_SHORTCUT_3); - m_wndShortcutsPane1.AddButton (images.ExtractIcon (3), _T("View 4"), ID_SHORTCUT_4); - // - - pShortcutsBarContainer->AddTab (&m_wndShortcutsPane1, _T("Views"), (UINT)-1, FALSE); - - return TRUE; -} - -void CMainFrame::OnAppLook(UINT id) -{ - CDockingManager::SetDockingMode (DT_SMART); - - m_nAppLook = id; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2000: - // enable Office 2000 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_XP: - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - // enable Windows XP look (in other OS Office XP look will be used): - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_2003: - // enable Office 2003 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_VS2005: - // enable VS.NET 2005 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - CMFCVisualManager::GetInstance (); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_1: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_2: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_3: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_4: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - default: - ASSERT (FALSE); - } - - CDockingManager* pDockManager = GetDockingManager (); - if (pDockManager != NULL) - { - ASSERT_VALID (pDockManager); - pDockManager->AdjustPaneFrames (); - } - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - theApp.WriteInt (_T("ApplicationLook"), m_nAppLook); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); -} - - -void CMainFrame::InitViews () -{ - m_nCurView = 0; // Save index of the currently active view class - CView* pActiveView = GetActiveView(); - - m_pViews[0] = pActiveView; - m_pViews[1] = (CView*) new CView1; - m_pViews[2] = (CView*) new CView2; - m_pViews[3] = (CView*) new CView3; - - CDocument* pCurrentDoc = GetActiveDocument(); - - // Initialize a CCreateContext to point to the active document. - // With this context, the new view is added to the document - // when the view is created in CView::OnCreate(). - CCreateContext newContext; - newContext.m_pNewViewClass = NULL; - newContext.m_pNewDocTemplate = NULL; - newContext.m_pLastView = NULL; - newContext.m_pCurrentFrame = NULL; - newContext.m_pCurrentDoc = pCurrentDoc; - - CRect rect(0, 0, 0, 0); // gets resized later - - for (int nView = 1; nView < NUMVIEWS; nView++) - { - // Create the new view. In this example, the view persists for - // the life of the application. The application automatically - // deletes the view when the application is closed. - m_pViews[nView]->Create(NULL, NULL, - (AFX_WS_DEFAULT_VIEW & ~WS_VISIBLE), - // views are created with the style of AFX_WS_DEFAULT_VIEW - // In MFC 4.0, this is (WS_BORDER | WS_VISIBLE | WS_CHILD) - rect, this, - AFX_IDW_PANE_FIRST + nView, &newContext); - - // When a document template creates a view, the WM_INITIALUPDATE - // message is sent automatically. However, this code must - // explicitly send the message, as follows. - m_pViews [nView]->OnInitialUpdate(); - } -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/MainFrm.h deleted file mode 100644 index 6ab7fc0b4e258..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/MainFrm.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#define CFrameWnd CFrameWndEx -#define NUMVIEWS 4 - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - void InitViews (); - -// Overrides - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - - // - CMFCOutlookBar m_wndShortcutsBar; - // - - // - CMFCOutlookBarPane m_wndShortcutsPane1; - // - - CMFCCaptionBar m_wndCaptionBar; - CBitmap m_bmpCaption; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnViewOutlookBar(); - afx_msg void OnUpdateViewOutlookBar(CCmdUI* pCmdUI); - afx_msg void OnOutlookBarShortcut(UINT id); - afx_msg void OnUpdateOutlookBarShortcut(CCmdUI* pCmdUI); - afx_msg void OnViewCaptionBar(); - afx_msg void OnUpdateViewCaptionBar(CCmdUI* pCmdUI); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); - - BOOL CreateShortcutsBar (); - - UINT m_nAppLook; - - // Array of views attached to single document - CView * m_pViews[NUMVIEWS]; - // Index to current view - UINT m_nCurView; -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.cpp deleted file mode 100644 index 5785580ce6ad5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "stdafx.h" -#include "OutlookMultiViews.h" - -#include "MainFrm.h" -#include "OutlookMultiViewsDoc.h" -#include "OutlookMultiViewsView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsApp - -BEGIN_MESSAGE_MAP(COutlookMultiViewsApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinAppEx::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsApp construction - -COutlookMultiViewsApp::COutlookMultiViewsApp() : CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only COutlookMultiViewsApp object - -COutlookMultiViewsApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsApp initialization - -BOOL COutlookMultiViewsApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(COutlookMultiViewsDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(COutlookMultiViewsView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - ((CMainFrame*)m_pMainWnd)->InitViews (); - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void COutlookMultiViewsApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsApp message handlers - -int COutlookMultiViewsApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void COutlookMultiViewsApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsApp message handlers - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.h deleted file mode 100644 index ab5820c337ddb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsApp: -// See OutlookMultiViews.cpp for the implementation of this class -// - -class COutlookMultiViewsApp : public CWinAppEx -{ -public: - COutlookMultiViewsApp(); - - // Override from CWinAppEx - virtual void PreLoadState (); - - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern COutlookMultiViewsApp theApp; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.rc deleted file mode 100644 index 2a842bf600ea4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViews.rc +++ /dev/null @@ -1,427 +0,0 @@ -//Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// - -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -#ifdef APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\OutlookMultiViews.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#ifndef _AFXDLL\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" - END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -IDR_MAINFRAME ICON DISCARDABLE "res\\OutlookMultiViews.ico" -IDR_OUTLOOTYPE ICON DISCARDABLE "res\\OutlookMultiViewsDoc.ico" -#endif - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_SHORTCUTS BITMAP DISCARDABLE "res\\shortcuts.bmp" -IDB_CAPTION BITMAP DISCARDABLE "res\\caption.bmp" -IDB_TOOLBAR256 BITMAP MOVEABLE PURE "res\\Toolbar256.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - - - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_2007_1 - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_2007_2 - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_2007_3 - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_2007_4 - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About OutlookMultiViews...", ID_APP_ABOUT - END -END - - - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Shortcuts Bar", ID_VIEW_OUTLOOKBAR - MENUITEM "&Caption Bar", ID_VIEW_CAPTIONBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY,CONTROL - "O", ID_FILE_OPEN, VIRTKEY,CONTROL - "S", ID_FILE_SAVE, VIRTKEY,CONTROL - "P", ID_FILE_PRINT, VIRTKEY,CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY,CONTROL - "X", ID_EDIT_CUT, VIRTKEY,CONTROL - "C", ID_EDIT_COPY, VIRTKEY,CONTROL - "V", ID_EDIT_PASTE, VIRTKEY,CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT -END - - - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About OutlookMultiViews" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "OutlookMultiViews Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "OutlookMultiViews MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "OutlookMultiViews\0" - VALUE "LegalCopyright", "Copyright (C) 2005\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename","OutlookMultiViews.EXE\0" - VALUE "ProductName", "OutlookMultiViews Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN -END -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "OutlookMultiViews\n\nOutloo\n\n\nOutlookMultiViews.Document\nOutloo Document" - -END -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "OutlookMultiViews" - AFX_IDS_IDLEMESSAGE "Ready" -END -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" - ID_VIEW_OUTLOOKBAR "Show or hide the shortcuts bar\nToggle Shortcuts Bar" - ID_SHORTCUT_1 "Shortcut 1\nShortcut 1" - ID_SHORTCUT_2 "Shortcut 2\nShortcut 2" - ID_SHORTCUT_3 "Shortcut 3\nShortcut 3" - ID_SHORTCUT_4 "Shortcut 4\nShortcut 4" - ID_VIEW_CAPTIONBAR "Show or hide the caption bar\nToggle Caption Bar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - - - - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_APPLOOK_2000 "Activate Office 2000 application look\nOffice 2000 Look" - ID_VIEW_APPLOOK_XP "Activate Office XP application look\nOffice XP Look" - ID_VIEW_APPLOOK_2003 "Activate Office 2003 application look\nOffice 2003 Look" - ID_VIEW_APPLOOK_VS2005 "Activate Visual Studio.NET 2005 application look\nVS.NET 2005 Look" - ID_VIEW_APPLOOK_WIN_XP "Activate Windows XP application look\nWindows XP Look" - ID_VIEW_APPLOOK_2007_1 "Activate Office 2007 application look\nOffice 2007 Look - Blue" - ID_VIEW_APPLOOK_2007_2 "Activate Office 2007 application look\nOffice 2007 Look - Black" - ID_VIEW_APPLOOK_2007_3 "Activate Office 2007 application look\nOffice 2007 Look - Aqua" - ID_VIEW_APPLOOK_2007_4 "Activate Office 2007 application look\nOffice 2007 Look - Silver" -END -#endif - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\\OutlookMultiViews.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -#endif // not APSTUDIO_INVOKED diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsDoc.cpp deleted file mode 100644 index e8ca8a61d70c8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsDoc.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "stdafx.h" -#include "OutlookMultiViews.h" - -#include "OutlookMultiViewsDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsDoc - -IMPLEMENT_DYNCREATE(COutlookMultiViewsDoc, CDocument) - -BEGIN_MESSAGE_MAP(COutlookMultiViewsDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsDoc construction/destruction - -COutlookMultiViewsDoc::COutlookMultiViewsDoc() -{ - // TODO: add one-time construction code here - -} - -COutlookMultiViewsDoc::~COutlookMultiViewsDoc() -{ -} - -BOOL COutlookMultiViewsDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsDoc serialization - -void COutlookMultiViewsDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsDoc diagnostics - -#ifdef _DEBUG -void COutlookMultiViewsDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void COutlookMultiViewsDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsDoc.h deleted file mode 100644 index 24c53aa622a9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsDoc.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -class COutlookMultiViewsDoc : public CDocument -{ -protected: // create from serialization only - COutlookMultiViewsDoc(); - DECLARE_DYNCREATE(COutlookMultiViewsDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~COutlookMultiViewsDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsView.cpp deleted file mode 100644 index cbe336f3e82c1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsView.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include "stdafx.h" -#include "OutlookMultiViews.h" - -#include "OutlookMultiViewsDoc.h" -#include "OutlookMultiViewsView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to switch between multiple views on a single document in a SDI application\r\n\r\nView 1"); - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsView - -IMPLEMENT_DYNCREATE(COutlookMultiViewsView, CView) - -BEGIN_MESSAGE_MAP(COutlookMultiViewsView, CView) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsView construction/destruction - -COutlookMultiViewsView::COutlookMultiViewsView() -{ - // TODO: add construction code here - -} - -COutlookMultiViewsView::~COutlookMultiViewsView() -{ -} - -BOOL COutlookMultiViewsView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsView drawing - -void COutlookMultiViewsView::OnDraw(CDC* pDC) -{ -// COutlookMultiViewsDoc* pDoc = GetDocument(); -// ASSERT_VALID(pDoc); - - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - CDrawingManager dm (*pDC); - - dm.FillGradient2 (rectFrame, RGB (246, 241, 178), RGB (234, 223, 67), 35); - - pDC->Draw3dRect (rectFrame, RGB (168, 158, 18), RGB (168, 158, 18)); - - pDC->SetBkMode (TRANSPARENT); - pDC->SetTextColor (0); - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsView printing - -void COutlookMultiViewsView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL COutlookMultiViewsView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void COutlookMultiViewsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void COutlookMultiViewsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsView diagnostics - -#ifdef _DEBUG -void COutlookMultiViewsView::AssertValid() const -{ - CView::AssertValid(); -} - -void COutlookMultiViewsView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -COutlookMultiViewsDoc* COutlookMultiViewsView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COutlookMultiViewsDoc))); - return (COutlookMultiViewsDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// COutlookMultiViewsView message handlers - -void COutlookMultiViewsView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsView.h deleted file mode 100644 index 78097fc87446a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/OutlookMultiViewsView.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -class COutlookMultiViewsView : public CView -{ -protected: // create from serialization only - COutlookMultiViewsView(); - DECLARE_DYNCREATE(COutlookMultiViewsView) - -// Attributes -public: - COutlookMultiViewsDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~COutlookMultiViewsView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in OutlookMultiViewsView.cpp -inline COutlookMultiViewsDoc* COutlookMultiViewsView::GetDocument() - { return (COutlookMultiViewsDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/ReadMe.htm deleted file mode 100644 index 0d78414dbfec9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/ReadMe.htm +++ /dev/null @@ -1,123 +0,0 @@ - - - - OutlookMultiViews Sample: An SDI Application with Multiple Views and Outlook - Bar control - - -

- OutlookMultiViews Sample: An SDI Application with Multiple Views and Outlook Bar - control

-
-
-
- -

-

-
-

- The OutlookMultiViews sample demonstrates how to switch between multiple views on - a single document in an SDI application. The sample utilizes the Outlook bar control - to list the available views and switch between them.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the OutlookMultiViews sample

-
-
    -
  1. -

    - Open the solution OutlookMultiViews.sln. -

    -
  2. -
  3. -

    - On the Build menu, click Build. -

    -
  4. -
  5. -

    - On the Debug menu, click Start Without Debugging. -

    -
  6. -
-
-
-
-

- Keywords

-
-

- The OutlookMultiViews sample demonstrates the following keywords:

-

- CDockingManager; CDrawingManager; CFrameWndEx; CMFCCaptionBar; CMFCMenuBar; CMFCOutlookBar; - CMFCOutlookBarPane; CMFCOutlookBarTabCtrl; CMFCPopupMenu; CMFCStatusBar; CMFCToolBar; - CMFCToolBarsCustomizeDialog; CMFCVisualManager; CMFCVisualManagerOffice; CMFCVisualManagerWindows; - CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/Snippets.txt deleted file mode 100644 index df84e4b3b2baa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/Snippets.txt +++ /dev/null @@ -1,6 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.h: CMFCOutlookBar 1 -MainFrm.cpp: CMFCOutlookBar 2 -MainFrm.h: CMFCOutlookBarPane 3 -MainFrm.cpp: CMFCOutlookBarPane 4 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/StdAfx.cpp deleted file mode 100644 index 466f41650d5b9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/StdAfx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// OutlookMultiViews.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/StdAfx.h deleted file mode 100644 index b9ac5b6aa9842..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/StdAfx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View1.cpp deleted file mode 100644 index f1b5b7feb102e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "stdafx.h" -#include "OutlookMultiViews.h" -#include "View1.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to switch between multiple views on a single document in a SDI application\r\n\r\nView 2"); - -///////////////////////////////////////////////////////////////////////////// -// CView1 - -IMPLEMENT_DYNCREATE(CView1, CView) - -CView1::CView1() -{ -} - -CView1::~CView1() -{ -} - - -BEGIN_MESSAGE_MAP(CView1, CView) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CView1 drawing - -void CView1::OnDraw(CDC* pDC) -{ - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - CDrawingManager dm (*pDC); - - dm.FillGradient2 (rectFrame, RGB (232, 213, 232), RGB (204, 161, 202), 35); - - pDC->Draw3dRect (rectFrame, RGB (129, 69, 129), RGB (129, 69, 129)); - - pDC->SetBkMode (TRANSPARENT); - pDC->SetTextColor (0); - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// CView1 diagnostics - -#ifdef _DEBUG -void CView1::AssertValid() const -{ - CView::AssertValid(); -} - -void CView1::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CView1 message handlers - -void CView1::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CView1::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CView1::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CView1::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CView1::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View1.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View1.h deleted file mode 100644 index 23c2706ec8891..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View1.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -class CView1 : public CView -{ -public: - CView1(); // protected constructor used by dynamic creation - virtual ~CView1(); - - DECLARE_DYNCREATE(CView1) - -// Attributes - -// Operations -public: - -// Overrides - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -protected: -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View2.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View2.cpp deleted file mode 100644 index 274eb42dcb076..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View2.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "stdafx.h" -#include "OutlookMultiViews.h" -#include "View2.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to switch between multiple views on a single document in a SDI application\r\n\r\nView 3"); - -///////////////////////////////////////////////////////////////////////////// -// CView2 - -IMPLEMENT_DYNCREATE(CView2, CView) - -CView2::CView2() -{ -} - -CView2::~CView2() -{ -} - - -BEGIN_MESSAGE_MAP(CView2, CView) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CView2 drawing - -void CView2::OnDraw(CDC* pDC) -{ - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - CDrawingManager dm (*pDC); - - dm.FillGradient2 (rectFrame, RGB (196, 245, 184), RGB (119, 231, 91), 35); - - pDC->Draw3dRect (rectFrame, RGB (39, 126, 17), RGB (39, 126, 17)); - - pDC->SetBkMode (TRANSPARENT); - pDC->SetTextColor (0); - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// CView2 diagnostics - -#ifdef _DEBUG -void CView2::AssertValid() const -{ - CView::AssertValid(); -} - -void CView2::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CView2 message handlers - -void CView2::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CView2::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CView2::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CView2::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CView2::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View2.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View2.h deleted file mode 100644 index a6caf9be32db5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View2.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -class CView2 : public CView -{ -public: - CView2(); // protected constructor used by dynamic creation - virtual ~CView2(); - - DECLARE_DYNCREATE(CView2) - -// Attributes -public: - -// Operations -public: - -// Overrides - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -protected: -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View3.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View3.cpp deleted file mode 100644 index 838c2f097c70f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View3.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "stdafx.h" -#include "OutlookMultiViews.h" -#include "View3.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to switch between multiple views on a single document in a SDI application\r\n\r\nView 4"); - -///////////////////////////////////////////////////////////////////////////// -// CView3 - -IMPLEMENT_DYNCREATE(CView3, CView) - -CView3::CView3() -{ -} - -CView3::~CView3() -{ -} - - -BEGIN_MESSAGE_MAP(CView3, CView) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CView3 drawing - -void CView3::OnDraw(CDC* pDC) -{ - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - CDrawingManager dm (*pDC); - - dm.FillGradient2 (rectFrame, RGB (219, 227, 251), RGB (167, 186, 247), 35); - - pDC->Draw3dRect (rectFrame, RGB (94, 128, 240), RGB (94, 128, 240)); - - pDC->SetBkMode (TRANSPARENT); - pDC->SetTextColor (0); - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// CView3 diagnostics - -#ifdef _DEBUG -void CView3::AssertValid() const -{ - CView::AssertValid(); -} - -void CView3::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CView3 message handlers - -void CView3::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CView3::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CView3::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CView3::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CView3::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View3.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View3.h deleted file mode 100644 index eed823e806297..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/View3.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -class CView3 : public CView -{ -public: - CView3(); // protected constructor used by dynamic creation - virtual ~CView3(); - - DECLARE_DYNCREATE(CView3) - -// Attributes -public: - -// Operations -public: - -// Overrides - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -protected: -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/outlookmultiviews.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/outlookmultiviews.vcxproj deleted file mode 100644 index 20d6df7bf355f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/outlookmultiviews.vcxproj +++ /dev/null @@ -1,282 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {3037585E-E983-4B37-A9D7-47D0EBF57DCF} - OutlookMultiViews - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/OutlookMultiViews.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX86 - - - true - .\..\bin/OutlookMultiViews.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/OutlookMultiViews.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX64 - - - true - .\..\bin/OutlookMultiViews.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - true - true - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViews.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViews.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViews.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViews.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViews.rc2 deleted file mode 100644 index 5e826871b65ce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViews.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// OUTLOOKMULTIVIEWS.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViewsDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViewsDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/OutlookMultiViewsDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/caption.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/caption.bmp deleted file mode 100644 index bffed128216e1..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/caption.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/shortcuts.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/shortcuts.bmp deleted file mode 100644 index 8099d2e2ed947..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/res/shortcuts.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/resource.h deleted file mode 100644 index d1be3ccb58a0f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/resource.h +++ /dev/null @@ -1,48 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by OUTLOOKMULTIVIEWS.RC -// -#define IDP_OLE_INIT_FAILED 100 -#define IDR_MAINFRAME 128 -#define IDR_OUTLOOTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 - -#define IDB_SHORTCUTS 148 -#define IDB_CAPTION 150 -#define IDB_TOOLBAR256 151 -#define IDD_ABOUTBOX 999 -#define IDC_COMPANY_URL 1041 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_CAPTIONBAR 32816 -#define ID_VIEW_OUTLOOKBAR 32817 -#define ID_SHORTCUT_1 32818 -#define ID_SHORTCUT_2 32819 -#define ID_SHORTCUT_3 32820 -#define ID_SHORTCUT_4 32821 -#define ID_SHORTCUTS_PANE_1 32824 -#define ID_SHORTCUTS_PANE_2 32825 -#define ID_SHORTCUTS_TREE 32826 - -#define ID_VIEW_APPLOOK_2000 32833 -#define ID_VIEW_APPLOOK_XP 32834 -#define ID_VIEW_APPLOOK_2003 32835 -#define ID_VIEW_APPLOOK_WIN_XP 32836 -#define ID_VIEW_APPLOOK_VS2005 32837 -#define ID_VIEW_APPLOOK_2007_1 32838 -#define ID_VIEW_APPLOOK_2007_2 32839 -#define ID_VIEW_APPLOOK_2007_3 32840 -#define ID_VIEW_APPLOOK_2007_4 32841 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 154 -#define _APS_NEXT_CONTROL_VALUE 1042 -#define _APS_NEXT_SYMED_VALUE 108 -#define _APS_NEXT_COMMAND_VALUE 32843 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_OutlookMultiViews/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertyPage1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertyPage1.cpp deleted file mode 100644 index fd5f83630d9ed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertyPage1.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "stdafx.h" -#include "resource.h" -#include "MyPropertyPage1.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -IMPLEMENT_DYNCREATE(CMyPropertyPage1, CMFCPropertyPage) -IMPLEMENT_DYNCREATE(CMyPropertyPage2, CMFCPropertyPage) -IMPLEMENT_DYNCREATE(CMyPropertyPage3, CMFCPropertyPage) -IMPLEMENT_DYNCREATE(CMyPropertyPage4, CMFCPropertyPage) - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage1 property page - -CMyPropertyPage1::CMyPropertyPage1() : CMFCPropertyPage(CMyPropertyPage1::IDD) -{ -} - -CMyPropertyPage1::~CMyPropertyPage1() -{ -} - -void CMyPropertyPage1::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - - -BEGIN_MESSAGE_MAP(CMyPropertyPage1, CMFCPropertyPage) -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage2 property page - -CMyPropertyPage2::CMyPropertyPage2() : CMFCPropertyPage(CMyPropertyPage2::IDD) -{ -} - -CMyPropertyPage2::~CMyPropertyPage2() -{ -} - -void CMyPropertyPage2::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - - -BEGIN_MESSAGE_MAP(CMyPropertyPage2, CMFCPropertyPage) -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage3 property page - -CMyPropertyPage3::CMyPropertyPage3() : CMFCPropertyPage(CMyPropertyPage3::IDD) -{ -} - -CMyPropertyPage3::~CMyPropertyPage3() -{ -} - -void CMyPropertyPage3::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - - -BEGIN_MESSAGE_MAP(CMyPropertyPage3, CMFCPropertyPage) -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage4 property page - -CMyPropertyPage4::CMyPropertyPage4() : CMFCPropertyPage(CMyPropertyPage4::IDD) -{ -} - -CMyPropertyPage4::~CMyPropertyPage4() -{ -} - -void CMyPropertyPage4::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - - -BEGIN_MESSAGE_MAP(CMyPropertyPage4, CMFCPropertyPage) -END_MESSAGE_MAP() - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertyPage1.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertyPage1.h deleted file mode 100644 index 2724c6c5ae401..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertyPage1.h +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage1 dialog - -class CMyPropertyPage1 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CMyPropertyPage1) - -// Construction -public: - CMyPropertyPage1(); - ~CMyPropertyPage1(); - -// Dialog Data - enum { IDD = IDD_PROPPAGE1 }; - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage2 dialog - -class CMyPropertyPage2 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CMyPropertyPage2) - -// Construction -public: - CMyPropertyPage2(); - ~CMyPropertyPage2(); - -// Dialog Data - enum { IDD = IDD_PROPPAGE2 }; - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage3 dialog - -class CMyPropertyPage3 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CMyPropertyPage3) - -// Construction -public: - CMyPropertyPage3(); - ~CMyPropertyPage3(); - -// Dialog Data - enum { IDD = IDD_PROPPAGE3 }; - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertyPage4 dialog - -class CMyPropertyPage4 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(CMyPropertyPage4) - -// Construction -public: - CMyPropertyPage4(); - ~CMyPropertyPage4(); - -// Dialog Data - enum { IDD = IDD_PROPPAGE4 }; - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertySheet.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertySheet.cpp deleted file mode 100644 index 159ea3d7f3921..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertySheet.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "stdafx.h" -#include "resource.h" -#include "MyPropertySheet.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertySheet - -IMPLEMENT_DYNAMIC(CMyPropertySheet, CMFCPropertySheet) - -CMyPropertySheet::CMyPropertySheet(CMFCPropertySheet::PropSheetLook look, - UINT uiIconsResID, int cxIcon) - : CMFCPropertySheet(IDS_PROPSHT_CAPTION, NULL) -{ - SetLook (look); - - if (uiIconsResID != 0) - { - SetIconsList (uiIconsResID, cxIcon); - } - - if (look == PropSheetLook_Tree) - { - CMFCPropertySheetCategoryInfo* pCategory1 = AddTreeCategory ( - _T("Category 1"), 0, 1); - AddPageToTree (pCategory1, &m_Page1, -1, 2); - AddPageToTree (pCategory1, &m_Page2, -1, 2); - - CMFCPropertySheetCategoryInfo* pCategory2 = AddTreeCategory ( - _T("Category 2"), 0, 1); - - AddPageToTree (pCategory2, &m_Page3, -1, 2); - AddPageToTree (pCategory2, &m_Page4, -1, 2); - } - else - { - AddPage(&m_Page1); - AddPage(&m_Page2); - AddPage(&m_Page3); - AddPage(&m_Page4); - } -} - -CMyPropertySheet::~CMyPropertySheet() -{ -} - - -BEGIN_MESSAGE_MAP(CMyPropertySheet, CMFCPropertySheet) -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertySheet message handlers - - -void CMyPropertySheet::OnDrawPageHeader (CDC* pDC, int nPage, CRect rectHeader) -{ - rectHeader.top += 2; - rectHeader.right -= 2; - rectHeader.bottom -= 2; - - pDC->FillRect (rectHeader, &afxGlobalData.brBtnFace); - pDC->Draw3dRect (rectHeader, afxGlobalData.clrBtnShadow, afxGlobalData.clrBtnShadow); - - // - // CDC* pDC - // CRect rectHeader - CDrawingManager dm (*pDC); - // Draw a shadow for a rectangular area. - // second parameter is the depth of the shadow - dm.DrawShadow (rectHeader, 2); - // - - CString strText; - strText.Format (_T("Page %d description..."), nPage + 1); - - CRect rectText = rectHeader; - rectText.DeflateRect (10, 0); - - CFont* pOldFont = pDC->SelectObject (&afxGlobalData.fontBold); - pDC->SetBkMode (TRANSPARENT); - pDC->SetTextColor (afxGlobalData.clrBtnText); - - pDC->DrawText (strText, rectText, DT_SINGLELINE | DT_VCENTER); - - pDC->SelectObject (pOldFont); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertySheet.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertySheet.h deleted file mode 100644 index c8ea0d4f5f83f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/MyPropertySheet.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include "MyPropertyPage1.h" - -///////////////////////////////////////////////////////////////////////////// -// CMyPropertySheet - -class CMyPropertySheet : public CMFCPropertySheet -{ - DECLARE_DYNAMIC(CMyPropertySheet) - -// Construction -public: - CMyPropertySheet(CMFCPropertySheet::PropSheetLook look, - UINT uiIconsResID = 0, int cxIcon = 0); - -// Attributes -public: - CMyPropertyPage1 m_Page1; - CMyPropertyPage2 m_Page2; - CMyPropertyPage3 m_Page3; - CMyPropertyPage4 m_Page4; - -// Operations -public: - -// Overrides - virtual void OnDrawPageHeader (CDC* pDC, int nPage, CRect rectHeader); - -// Implementation -public: - virtual ~CMyPropertySheet(); - -protected: - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.cpp deleted file mode 100644 index 4829b377790b3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "stdafx.h" -#include "PropSheetDemo.h" -#include "PropSheetDemoDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPropSheetDemoApp - -BEGIN_MESSAGE_MAP(CPropSheetDemoApp, CWinAppEx) - ON_COMMAND(ID_HELP, CWinAppEx::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPropSheetDemoApp construction - -CPropSheetDemoApp::CPropSheetDemoApp() -{ - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CPropSheetDemoApp object - -CPropSheetDemoApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CPropSheetDemoApp initialization - -BOOL CPropSheetDemoApp::InitInstance() -{ - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - CPropSheetDemoDlg dlg; - m_pMainWnd = &dlg; - int nResponse = (int) dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.h deleted file mode 100644 index 67a436447ce57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CPropSheetDemoApp: -// See PropSheetDemo.cpp for the implementation of this class -// - -class CPropSheetDemoApp : public CWinAppEx -{ -public: - CPropSheetDemoApp(); - -// Overrides - public: - virtual BOOL InitInstance(); - -// Implementation - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.rc deleted file mode 100644 index 502357911e12f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemo.rc +++ /dev/null @@ -1,295 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\PropSheetDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#ifndef _AFXDLL\r\n" - "#include ""afxribbon.rc"" // Ribbon and control bars\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\PropSheetDemo.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_PROPSHEETDEMO_DIALOG DIALOGEX 0, 0, 310, 274 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "PropSheetDemo" -FONT 8, "MS Sans Serif" -BEGIN - PUSHBUTTON "Display",IDC_PROP_SHEET1,244,23,50,14 - PUSHBUTTON "Display",IDC_PROP_SHEET2,244,68,50,14 - PUSHBUTTON "Display",IDC_PROP_SHEET3,244,118,50,14 - PUSHBUTTON "Display",IDC_PROP_SHEET4,244,175,50,14 - PUSHBUTTON "Close",IDCANCEL,253,253,50,14 - GROUPBOX "Simple property sheet: ",IDC_STATIC,7,7,296,39 - LTEXT "This is a simple, CPropertySheet-like window, which allows using of library controls on the property pages.", - IDC_STATIC,15,23,216,18 - GROUPBOX "Tabs on left: ",IDC_STATIC,7,52,296,40 - LTEXT "Demonstrates how to create property sheet windows with the Outlook bar on the left side.", - IDC_STATIC,15,68,216,21 - GROUPBOX "Tree on left: ",IDC_STATIC,7,102,296,49 - LTEXT "Demonstrates how to create property sheet windows with a tree control on the left side. In this style, developer can organize pages by categories.", - IDC_STATIC,15,118,216,25 - GROUPBOX "OneNote-style tabs",IDC_STATIC,7,159,296,39 - LTEXT "Demonstrates how to replace the standard tab control by the new, cool control with colored tabs and icons.", - IDC_STATIC,15,175,216,18 - PUSHBUTTON "Display",IDC_PROP_SHEET5,244,223,50,14 - GROUPBOX "List on left:",IDC_STATIC,7,207,296,39 - LTEXT "Demonstrates how to create property sheet windows with a Office 2007-style list control on the left side.", - IDC_STATIC,15,223,216,18 - CONTROL "Enable Page &Header",IDC_HEADER,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,252,82,10 -END - -IDD_PROPPAGE1 DIALOG DISCARDABLE 0, 0, 255, 153 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Page 1" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Page 1",IDC_STATIC,91,53,24,8 -END - -IDD_PROPPAGE2 DIALOG DISCARDABLE 0, 0, 255, 153 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Page 2" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Page 2",IDC_STATIC,91,53,24,8 -END - -IDD_PROPPAGE3 DIALOG DISCARDABLE 0, 0, 253, 153 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Page 3" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Page 3",IDC_STATIC,91,53,24,8 -END - -IDD_PROPPAGE4 DIALOG DISCARDABLE 0, 0, 254, 153 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Page 4" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Page 4",IDC_STATIC,91,53,24,8 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "PropSheetDemo MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "PropSheetDemo\0" - VALUE "LegalCopyright", "Copyright (C) 2003\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "PropSheetDemo.EXE\0" - VALUE "ProductName", "PropSheetDemo Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_PROPSHEETDEMO_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 303 - VERTGUIDE, 15 - VERTGUIDE, 231 - VERTGUIDE, 244 - TOPMARGIN, 7 - BOTTOMMARGIN, 267 - HORZGUIDE, 23 - END - - IDD_PROPPAGE1, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 248 - TOPMARGIN, 7 - BOTTOMMARGIN, 145 - END - - IDD_PROPPAGE2, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 248 - TOPMARGIN, 7 - BOTTOMMARGIN, 145 - END - - IDD_PROPPAGE3, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 246 - TOPMARGIN, 7 - BOTTOMMARGIN, 145 - END - - IDD_PROPPAGE4, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 247 - TOPMARGIN, 7 - BOTTOMMARGIN, 145 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_ICONS_LARGE BITMAP DISCARDABLE "res\\icons_large.bmp" -IDB_ICONS_SMALL BITMAP DISCARDABLE "res\\icons_small.bmp" -IDB_TREE_ICONS BITMAP DISCARDABLE "res\\tree_icons.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE DISCARDABLE -BEGIN - IDS_ABOUTBOX "&About PropSheetDemo..." - IDS_PROPSHT_CAPTION "Property Sheet" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "PropSheetDemo Sample" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\PropSheetDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#ifndef _AFXDLL -#include "afxribbon.rc" // Ribbon and control bars -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemoDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemoDlg.cpp deleted file mode 100644 index 6a46a5e08c314..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemoDlg.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "stdafx.h" -#include "PropSheetDemo.h" -#include "PropSheetDemoDlg.h" -#include "MyPropertySheet.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define HEADER_HEIGHT 30 - -///////////////////////////////////////////////////////////////////////////// -// CPropSheetDemoDlg dialog - -CPropSheetDemoDlg::CPropSheetDemoDlg(CWnd* pParent /*=NULL*/) - : CDialogEx(CPropSheetDemoDlg::IDD, pParent) -{ - m_bHeader = FALSE; - - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -void CPropSheetDemoDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialogEx::DoDataExchange(pDX); - DDX_Check(pDX, IDC_HEADER, m_bHeader); -} - -BEGIN_MESSAGE_MAP(CPropSheetDemoDlg, CDialogEx) - ON_WM_SYSCOMMAND() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - ON_BN_CLICKED(IDC_PROP_SHEET1, OnPropSheet1) - ON_BN_CLICKED(IDC_PROP_SHEET2, OnPropSheet2) - ON_BN_CLICKED(IDC_PROP_SHEET3, OnPropSheet3) - ON_BN_CLICKED(IDC_PROP_SHEET4, OnPropSheet4) - ON_BN_CLICKED(IDC_PROP_SHEET5, OnPropSheet5) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPropSheetDemoDlg message handlers - -BOOL CPropSheetDemoDlg::OnInitDialog() -{ - CDialogEx::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - BOOL bValidString; - CString strAboutMenu; - bValidString = strAboutMenu.LoadString(IDS_ABOUTBOX); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - // TODO: Add extra initialization here - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CPropSheetDemoDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - } - else - { - CDialogEx::OnSysCommand(nID, lParam); - } -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CPropSheetDemoDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialogEx::OnPaint(); - } -} - -// The system calls this to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CPropSheetDemoDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -void CPropSheetDemoDlg::OnPropSheet1() -{ - UpdateData (); - - CMyPropertySheet propSheet (CMFCPropertySheet::PropSheetLook_Tabs); - - propSheet.EnablePageHeader (m_bHeader ? HEADER_HEIGHT : 0); - propSheet.DoModal(); -} - -void CPropSheetDemoDlg::OnPropSheet2() -{ - UpdateData (); - - CMyPropertySheet propSheet (CMFCPropertySheet::PropSheetLook_OutlookBar, - IDB_ICONS_LARGE, 32); - - propSheet.EnablePageHeader (m_bHeader ? HEADER_HEIGHT : 0); - propSheet.DoModal(); -} - -void CPropSheetDemoDlg::OnPropSheet3() -{ - UpdateData (); - - CMyPropertySheet propSheet (CMFCPropertySheet::PropSheetLook_Tree, - IDB_TREE_ICONS, 16); - - propSheet.EnablePageHeader (m_bHeader ? HEADER_HEIGHT : 0); - propSheet.DoModal(); -} - -void CPropSheetDemoDlg::OnPropSheet4() -{ - UpdateData (); - - CMyPropertySheet propSheet (CMFCPropertySheet::PropSheetLook_OneNoteTabs, - IDB_ICONS_SMALL, 16); - propSheet.GetTab ().EnableAutoColor (); - - propSheet.EnablePageHeader (m_bHeader ? HEADER_HEIGHT : 0); - propSheet.DoModal(); -} - -void CPropSheetDemoDlg::OnPropSheet5() -{ - UpdateData (); - - CMyPropertySheet propSheet (CMFCPropertySheet::PropSheetLook_List); - - propSheet.EnablePageHeader (m_bHeader ? HEADER_HEIGHT : 0); - propSheet.DoModal(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemoDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemoDlg.h deleted file mode 100644 index 01ffcd6223a8d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/PropSheetDemoDlg.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CPropSheetDemoDlg dialog - -class CPropSheetDemoDlg : public CDialogEx -{ -// Construction -public: - CPropSheetDemoDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - enum { IDD = IDD_PROPSHEETDEMO_DIALOG }; - BOOL m_bHeader; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - HICON m_hIcon; - - virtual BOOL OnInitDialog(); - - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnPropSheet1(); - afx_msg void OnPropSheet2(); - afx_msg void OnPropSheet3(); - afx_msg void OnPropSheet4(); - afx_msg void OnPropSheet5(); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/ReadMe.htm deleted file mode 100644 index 39cc5743d695d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,119 +0,0 @@ - - - - PropSheetDemo Sample: Property Sheet Demonstration Application - - -

- PropSheetDemo Sample: Property Sheet Demonstration Application

-
-
-
- -

-

-
-

- The PropertySheetDemo sample illustrates various styles of Property Sheet control: - simple, with tabs at the left side, with tree control at the left side, OneNote-style - tabs, list of items at the left side.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the PropSheetDemo sample

-
-
    -
  1. -

    - Open the solution PropSheetDemo.sln. -

    -
  2. -
  3. -

    - On the Build menu, click Build. -

    -
  4. -
  5. -

    - On the Debug menu, click Start Without Debugging. -

    -
  6. -
-
-
-
-

- Keywords

-
-

- The PropSheetDemo sample demonstrates the following keywords:

-

- CDialogEx; CDrawingManager; CMFCPropertyPage; CMFCPropertySheet; CMFCPropertySheetCategoryInfo; - CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/Resource.h deleted file mode 100644 index 743f11263c928..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/Resource.h +++ /dev/null @@ -1,33 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by PropSheetDemo.rc -// -#define IDM_ABOUTBOX 0x0010 -#define IDS_ABOUTBOX 101 -#define IDD_PROPSHEETDEMO_DIALOG 102 -#define IDS_PROPSHT_CAPTION 103 -#define IDD_PROPPAGE1 104 -#define IDD_PROPPAGE2 105 -#define IDD_PROPPAGE3 106 -#define IDD_PROPPAGE4 107 -#define IDR_MAINFRAME 128 -#define IDB_ICONS_LARGE 129 -#define IDB_ICONS_SMALL 130 -#define IDB_TREE_ICONS 131 -#define IDC_PROP_SHEET1 1000 -#define IDC_PROP_SHEET2 1001 -#define IDC_PROP_SHEET3 1002 -#define IDC_PROP_SHEET4 1003 -#define IDC_PROP_SHEET5 1004 -#define IDC_HEADER 1005 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 132 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1006 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/Snippets.txt deleted file mode 100644 index 2568917784cd4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/Snippets.txt +++ /dev/null @@ -1,3 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MyPropertySheet.cpp: CDrawingManager::DrawShadow 1 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/StdAfx.cpp deleted file mode 100644 index efddbbf899094..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/StdAfx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// PropSheetDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/StdAfx.h deleted file mode 100644 index 81f4bac2e64e1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/StdAfx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/propsheetdemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/propsheetdemo.vcxproj deleted file mode 100644 index e106de4707d01..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/propsheetdemo.vcxproj +++ /dev/null @@ -1,255 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {E2F63C24-80ED-4BA1-B3BA-81F2B12C6D58} - PropSheetDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/PropSheetDemo.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX86 - - - true - .\..\bin/PropSheetDemo.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/PropSheetDemo.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX64 - - - true - .\..\bin/PropSheetDemo.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/PropSheetDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/PropSheetDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/PropSheetDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/PropSheetDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/PropSheetDemo.rc2 deleted file mode 100644 index 83734c064f723..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/PropSheetDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// PROPSHEETDEMO.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/icons_large.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/icons_large.bmp deleted file mode 100644 index 6873edf8e3345..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/icons_large.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/icons_small.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/icons_small.bmp deleted file mode 100644 index 141dccf45c764..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/icons_small.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/tree_icons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/tree_icons.bmp deleted file mode 100644 index 1aa6b516c9f0b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/res/tree_icons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_PropSheetDemo/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ChildFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ChildFrm.cpp deleted file mode 100644 index edbd7bd95b980..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ChildFrm.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "RebarTest.h" - -#include "ChildFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CChildFrame - -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) -END_MESSAGE_MAP() - - -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here -} - -CChildFrame::~CChildFrame() -{ -} - - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs - if( !CMDIChildWndEx::PreCreateWindow(cs) ) - return FALSE; - - return TRUE; -} - - -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWndEx::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWndEx::Dump(dc); -} - -#endif //_DEBUG - - -// CChildFrame message handlers - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ChildFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ChildFrm.h deleted file mode 100644 index 93b9f7acd4a4a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ChildFrm.h +++ /dev/null @@ -1,39 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CChildFrame : public CMDIChildWndEx -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.cpp deleted file mode 100644 index 73c2fd63df7c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.cpp +++ /dev/null @@ -1,381 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "RebarTest.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) - -const int iMaxUserToolbars = 10; -const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; -const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) - ON_WM_CREATE() - ON_WM_CLOSE() - ON_COMMAND(ID_WINDOW_MANAGER, OnWindowManager) - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_3, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_3, OnUpdateAppLook) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - - m_nAppLook = theApp.GetInt (_T("ApplicationLook"), ID_VIEW_APPLOOK_WIN_XP); - // TODO: add member initialization code here -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - OnAppLook (m_nAppLook); - - // VISUAL_MANAGER - - if (CMFCToolBar::GetUserImages () == NULL) - { - // Load toolbar user images: - if (!m_UserImages.Load (_T(".\\UserImages.bmp"))) - { - TRACE(_T("Failed to load user images\n")); - } - else - { - CMFCToolBar::SetUserImages (&m_UserImages); - } - } - - CMFCToolBar::EnableQuickCustomization (); - - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_RECORD_NEXT); - lstBasicCommands.AddTail (ID_RECORD_LAST); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_WINDOW_TILE_HORZ); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Remove menubar gripper and borders: - m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() & - ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - - if (!m_wndToolBar.CreateEx(this) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - // - // Each rebar pane will occupy its own row: - DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK; - // CMFCMenuBar m_wndMenuBar - // CMFCToolBar m_wndToolBar - if (!m_wndReBar.Create(this) || - !m_wndReBar.AddBar (&m_wndMenuBar) || - !m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle)) - { - TRACE0("Failed to create rebar\n"); - return -1; // fail to create - } - // - - m_wndMenuBar.AdjustLayout (); - m_wndToolBar.AdjustLayout (); - - // TODO: Remove this if you don't want chevrons: - m_wndMenuBar.EnableCustomizeButton (TRUE, -1, _T("")); - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - - EnableDocking(CBRS_ALIGN_ANY); - m_wndReBar.EnableDocking (CBRS_TOP); - DockPane (&m_wndReBar); - - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - - // TODO: Remove this if you don't want tool tips - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - - // Enable windows manager: - EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); - - // Enable control bar context menu (list of bars + customize command): - EnablePaneMenu ( - TRUE, // Enable - ID_VIEW_CUSTOMIZE, // Customize command ID - _T("Customize..."), // Customize command text - ID_VIEW_TOOLBARS); // Menu items with this ID will be replaced by - // toolbars menu - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWndEx::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - - -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWndEx::Dump(dc); -} - -#endif //_DEBUG - - -// CMainFrame message handlers - - - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */); - - pDlgCust->EnableUserDefinedToolbars (); - pDlgCust->Create (); -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -void CMainFrame::OnWindowManager() -{ - ShowWindowsDialog (); -} - -void CMainFrame::OnAppLook(UINT id) -{ - CDockingManager::SetDockingMode (DT_SMART); - - m_nAppLook = id; - - CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2000: - // enable Office 2000 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_XP: - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - // enable Windows XP look (in other OS Office XP look will be used): - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_2003: - // enable Office 2003 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007: - case ID_VIEW_APPLOOK_2007_1: - case ID_VIEW_APPLOOK_2007_2: - case ID_VIEW_APPLOOK_2007_3: - // enable Office 2007 look: - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2007: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case ID_VIEW_APPLOOK_2007_1: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case ID_VIEW_APPLOOK_2007_2: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - break; - - case ID_VIEW_APPLOOK_2007_3: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - } - - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_VS2005: - // enable VS 2005 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - CDockingManager::SetDockingMode (DT_SMART); - break; - } - - CDockingManager* pDockManager = GetDockingManager (); - if (pDockManager != NULL) - { - ASSERT_VALID (pDockManager); - pDockManager->AdjustPaneFrames (); - } - - CTabbedPane::ResetTabs (); - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - theApp.WriteInt (_T("ApplicationLook"), m_nAppLook); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); -} - -CMDIChildWndEx* CMainFrame::CreateDocumentWindow (LPCTSTR lpcszDocName, CObject* /*pObj*/) -{ - if (lpcszDocName != NULL && lpcszDocName [0] != '\0') - { - CDocument* pDoc = AfxGetApp()->OpenDocumentFile (lpcszDocName); - - if (pDoc != NULL) - { - POSITION pos = pDoc->GetFirstViewPosition(); - - if (pos != NULL) - { - CView* pView = pDoc->GetNextView (pos); - if (pView == NULL) - { - return NULL; - } - - return DYNAMIC_DOWNCAST (CMDIChildWndEx, pView->GetParent ()); - } - } - } - - return NULL; -} - -void CMainFrame::OnClose() -{ - SaveMDIState (theApp.GetRegSectionPath ()); - CMDIFrameWndEx::OnClose(); -} - - // RIBBON_APP diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.h deleted file mode 100644 index ee2ae8d86793b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.h +++ /dev/null @@ -1,65 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CMainFrame : public CMDIFrameWndEx -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides -public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCStatusBar m_wndStatusBar; - CMFCMenuBar m_wndMenuBar; - CMFCToolBar m_wndToolBar; - - // - CMFCReBar m_wndReBar; - // - - CMFCToolBarImages m_UserImages; -// Generated message map functions -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - void OnToolsViewUserToolbar (UINT id); - void OnUpdateToolsViewUserToolbar (CCmdUI* pCmdUI); - afx_msg void OnWindowManager(); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - afx_msg void OnClose(); - DECLARE_MESSAGE_MAP() - - virtual CMDIChildWndEx* CreateDocumentWindow (LPCTSTR lpcszDocName, CObject* /*pObj*/); - - UINT m_nAppLook; -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ReadMe.htm deleted file mode 100644 index c59e1d6f59c8f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/ReadMe.htm +++ /dev/null @@ -1,119 +0,0 @@ - - - - RebarTest Sample: Rebar Testing Application - - -

- RebarTest Sample: Rebar Testing Application

-
-
-
- -

-

-
-

- The RebarTest sample demonstrates a customizable Rebar control which hosts a toolbar.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the RebarTest sample

-
-
    -
  1. -

    - Open the solution RebarTest.sln. -

    -
  2. -
  3. -

    - On the Build menu, click Build. -

    -
  4. -
  5. -

    - On the Debug menu, click Start Without Debugging. -

    -
  6. -
-
-
-
-

- Keywords

-
-

- The RebarTest sample demonstrates the following keywords:

-

- CDockingManager; CMDIChildWndEx; CMDIFrameWndEx; CMFCMenuBar; CMFCReBar; CMFCStatusBar; - CMFCTabCtrl; CMFCToolBar; CMFCToolBarImages; CMFCToolBarsCustomizeDialog; CMFCToolTipCtrl; - CMFCToolTipInfo; CMFCVisualManager; CMFCVisualManagerOffice; CMFCVisualManagerWindows; - CTabbedPane; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.cpp deleted file mode 100644 index be11c7273166d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "RebarTest.h" -#include "MainFrm.h" - -#include "ChildFrm.h" -#include "RebarTestDoc.h" -#include "RebarTestView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CRebarTestApp - -BEGIN_MESSAGE_MAP(CRebarTestApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - - -// CRebarTestApp construction - -CRebarTestApp::CRebarTestApp() : - CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - - -// The one and only CRebarTestApp object - -CRebarTestApp theApp; - - -// CRebarTestApp initialization - -BOOL CRebarTestApp::InitInstance() -{ - // InitCommonControlsEx() is required on Windows XP if an application - // manifest specifies use of ComCtl32.dll version 6 or later to enable - // visual styles. Otherwise, any window creation will fail. - INITCOMMONCONTROLSEX InitCtrls; - InitCtrls.dwSize = sizeof(InitCtrls); - // Set this to include all the common control classes you want to use - // in your application. - InitCtrls.dwICC = ICC_WIN95_CLASSES; - InitCommonControlsEx(&InitCtrls); - - CWinApp::InitInstance(); - - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - AfxEnableControlContainer(); - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - LoadStdProfileSettings(4); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // TODO: Remove this if you don't want extended tooltips: - InitTooltipManager(); - - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - theApp.GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS (CMFCToolTipCtrl), - ¶ms); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate(IDR_RebarTestTYPE, - RUNTIME_CLASS(CRebarTestDoc), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CRebarTestView)); - if (!pDocTemplate) - return FALSE; - AddDocTemplate(pDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) - return FALSE; - m_pMainWnd = pMainFrame; - // call DragAcceptFiles only if there's a suffix - // In an MDI app, this should occur immediately after setting m_pMainWnd - - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - - if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) - { - if (!pMainFrame->LoadMDIState (GetRegSectionPath ())) - { - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - } - } - else - { - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - } - // The main window has been initialized, so show and update it - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - - return TRUE; -} - -// CRebarTestApp message handlers - -int CRebarTestApp::ExitInstance() -{ - - - return CWinAppEx::ExitInstance(); -} - -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - enum { IDD = IDD_ABOUTBOX }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - -// App command to run the dialog -void CRebarTestApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - - -// CRebarTestApp message handlers - - -void CRebarTestApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.h deleted file mode 100644 index 9dad92655afc8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - - -// CRebarTestApp: -// See RebarTest.cpp for the implementation of this class -// - -class CRebarTestApp : public CWinAppEx -{ -public: - CRebarTestApp(); - - virtual void PreLoadState (); - -// Overrides -public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - DECLARE_MESSAGE_MAP() -}; - -extern CRebarTestApp theApp; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.rc deleted file mode 100644 index 4650b05089a9b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTest.rc +++ /dev/null @@ -1,539 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#include ""res\\RebarTest.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\RebarTest.ico" -IDR_RebarTestTYPE ICON "res\\RebarTestDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDB_TOOLBAR256 BITMAP "res\\Toolbar256.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM SEPARATOR - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "Visual Studio 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "&Windows XP/Vista Native", ID_VIEW_APPLOOK_WIN_XP - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Theme", ID_VIEW_APPLOOK_2007 - MENUITEM "B&lack Theme", ID_VIEW_APPLOOK_2007_1 - MENUITEM "&Silver Theme", ID_VIEW_APPLOOK_2007_2 - MENUITEM "&Aqua Theme", ID_VIEW_APPLOOK_2007_3 - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About RebarTest...", ID_APP_ABOUT - END -END - -IDR_RebarTestTYPE MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "Visual Studio 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "&Windows XP/Vista Native", ID_VIEW_APPLOOK_WIN_XP - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Theme", ID_VIEW_APPLOOK_2007 - MENUITEM "B&lack Theme", ID_VIEW_APPLOOK_2007_1 - MENUITEM "&Silver Theme", ID_VIEW_APPLOOK_2007_2 - MENUITEM "&Aqua Theme", ID_VIEW_APPLOOK_2007_3 - END - END - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - MENUITEM "&Cascade", ID_WINDOW_CASCADE - MENUITEM "&Tile", ID_WINDOW_TILE_HORZ - MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE - END - POPUP "&Help" - BEGIN - MENUITEM "&About RebarTest...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "", ID_VIEW_USER_TOOLBAR1 - MENUITEM "", ID_VIEW_USER_TOOLBAR2 - MENUITEM "", ID_VIEW_USER_TOOLBAR3 - MENUITEM "", ID_VIEW_USER_TOOLBAR4 - MENUITEM "", ID_VIEW_USER_TOOLBAR5 - MENUITEM "", ID_VIEW_USER_TOOLBAR6 - MENUITEM "", ID_VIEW_USER_TOOLBAR7 - MENUITEM "", ID_VIEW_USER_TOOLBAR8 - MENUITEM "", ID_VIEW_USER_TOOLBAR9 - MENUITEM "", ID_VIEW_USER_TOOLBAR10 - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About RebarTest" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "RebarTest Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "00409004e4" - BEGIN - VALUE "CompanyName", "TODO: " - VALUE "FileDescription", "TODO: " - VALUE "FileVersion", "1.0.0.1" - VALUE "InternalName", "RebarTest.exe" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved." - VALUE "OriginalFilename", "RebarTest.exe" - VALUE "ProductName", "TODO: " - VALUE "ProductVersion", "1.0.0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "RebarTest" - IDR_RebarTestTYPE "\nRebarTest\nRebarTest\n\n\nRebarTest.Document\nRebarTest.Document" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "RebarTest" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_DIRECT "Send the document directly to the default printer without making changes\nQuick Print" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" - IDS_WINDOWS_MANAGER "&Windows..." -END - -STRINGTABLE -BEGIN - ID_VIEW_USER_TOOLBAR1 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR2 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR3 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR4 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR5 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR6 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR7 "Show or hide the user toolbar\nToggle User ToolBar" -END - -STRINGTABLE -BEGIN - ID_VIEW_USER_TOOLBAR8 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR9 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR10 "Show or hide the user toolbar\nToggle User ToolBar" -END - -STRINGTABLE -BEGIN - ID_VIEW_APPLOOK_2000 "Activate Office 2000 application look\nOffice 2000 Look" - ID_VIEW_APPLOOK_XP "Activate Office XP application look\nOffice XP Look" - ID_VIEW_APPLOOK_2003 "Activate Office 2003 application look\nOffice 2003 Look" - ID_VIEW_APPLOOK_WIN_XP "Activate Windows XP/Vista application look\nWindows XP/Vista Look" - ID_VIEW_APPLOOK_VS2005 "Activate Visual Studio 2005 application look\nVS 2005 Look" - ID_VIEW_APPLOOK_2007 "Activate Office 2007 (Blue) application look\nOffice 2007 Look (Blue)" -END - -STRINGTABLE -BEGIN - ID_VIEW_APPLOOK_2007_1 "Activate Office 2007 (Black) application look\nOffice 2007 Look (Black)" - ID_VIEW_APPLOOK_2007_2 "Activate Office 2007 (Silver) application look\nOffice 2007 Look (Silver)" - ID_VIEW_APPLOOK_2007_3 "Activate Office 2007 (Aqua) application look\nOffice 2007 Look (Aqua)" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) -#include "res\RebarTest.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestDoc.cpp deleted file mode 100644 index d9c06a74a403c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestDoc.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "RebarTest.h" - -#include "RebarTestDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CRebarTestDoc - -IMPLEMENT_DYNCREATE(CRebarTestDoc, CDocument) - -BEGIN_MESSAGE_MAP(CRebarTestDoc, CDocument) -END_MESSAGE_MAP() - - -// CRebarTestDoc construction/destruction - -CRebarTestDoc::CRebarTestDoc() -{ - // TODO: add one-time construction code here - -} - -CRebarTestDoc::~CRebarTestDoc() -{ -} - -BOOL CRebarTestDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - - -// CRebarTestDoc serialization - -void CRebarTestDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - - -// CRebarTestDoc diagnostics - -#ifdef _DEBUG -void CRebarTestDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CRebarTestDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - - -// CRebarTestDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestDoc.h deleted file mode 100644 index 16061b08fba6e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestDoc.h +++ /dev/null @@ -1,46 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - - -class CRebarTestDoc : public CDocument -{ -protected: // create from serialization only - CRebarTestDoc(); - DECLARE_DYNCREATE(CRebarTestDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CRebarTestDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestView.cpp deleted file mode 100644 index 106befcf1f889..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestView.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "RebarTest.h" - -#include "RebarTestDoc.h" -#include "RebarTestView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CRebarTestView - -IMPLEMENT_DYNCREATE(CRebarTestView, CView) - -BEGIN_MESSAGE_MAP(CRebarTestView, CView) - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) -END_MESSAGE_MAP() - -// CRebarTestView construction/destruction - -CRebarTestView::CRebarTestView() -{ - // TODO: add construction code here - -} - -CRebarTestView::~CRebarTestView() -{ -} - -BOOL CRebarTestView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -// CRebarTestView drawing - -void CRebarTestView::OnDraw(CDC* /*pDC*/) -{ - CRebarTestDoc* pDoc; - pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - // TODO: add draw code for native data here -} - - -// CRebarTestView printing - -void CRebarTestView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CRebarTestView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CRebarTestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CRebarTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - - -// CRebarTestView diagnostics - -#ifdef _DEBUG -void CRebarTestView::AssertValid() const -{ - CView::AssertValid(); -} - -void CRebarTestView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CRebarTestDoc* CRebarTestView::GetDocument() const // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRebarTestDoc))); - return (CRebarTestDoc*)m_pDocument; -} -#endif //_DEBUG - - -// CRebarTestView message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestView.h deleted file mode 100644 index 36150c5ca640b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/RebarTestView.h +++ /dev/null @@ -1,56 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - - -class CRebarTestView : public CView -{ -protected: // create from serialization only - CRebarTestView(); - DECLARE_DYNCREATE(CRebarTestView) - -// Attributes -public: - CRebarTestDoc* GetDocument() const; - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view -virtual BOOL PreCreateWindow(CREATESTRUCT& cs); -protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CRebarTestView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - afx_msg void OnFilePrintPreview(); - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in RebarTestView.cpp -inline CRebarTestDoc* CRebarTestView::GetDocument() const - { return reinterpret_cast(m_pDocument); } -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/Resource.h deleted file mode 100644 index 0e063a2ce1f36..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/Resource.h +++ /dev/null @@ -1,48 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by RebarTest.rc -// -#define IDD_ABOUTBOX 100 -#define IDP_OLE_INIT_FAILED 100 -#define IDR_MAINFRAME 128 -#define IDR_RebarTestTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDB_TOOLBAR256 151 -#define IDS_MAIN_TOOLBAR 101 -#define ID_VIEW_TOOLBARS 32771 -#define IDS_WINDOWS_MANAGER 107 -#define IDC_COMPANY_URL 1041 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_USER_TOOLBAR1 32793 -#define ID_VIEW_USER_TOOLBAR2 32794 -#define ID_VIEW_USER_TOOLBAR3 32795 -#define ID_VIEW_USER_TOOLBAR4 32796 -#define ID_VIEW_USER_TOOLBAR5 32797 -#define ID_VIEW_USER_TOOLBAR6 32798 -#define ID_VIEW_USER_TOOLBAR7 32799 -#define ID_VIEW_USER_TOOLBAR8 32800 -#define ID_VIEW_USER_TOOLBAR9 32801 -#define ID_VIEW_USER_TOOLBAR10 32802 -#define ID_WINDOW_MANAGER 32825 -#define ID_VIEW_APPLOOK_2000 32826 -#define ID_VIEW_APPLOOK_XP 32827 -#define ID_VIEW_APPLOOK_2003 32828 -#define ID_VIEW_APPLOOK_WIN_XP 32829 -#define ID_VIEW_APPLOOK_VS2005 32830 -#define ID_VIEW_APPLOOK_2007 32831 -#define ID_VIEW_APPLOOK_2007_1 32832 -#define ID_VIEW_APPLOOK_2007_2 32833 -#define ID_VIEW_APPLOOK_2007_3 32834 - - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 160 -#define _APS_NEXT_CONTROL_VALUE 1042 -#define _APS_NEXT_SYMED_VALUE 108 -#define _APS_NEXT_COMMAND_VALUE 32850 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/Snippets.txt deleted file mode 100644 index 166991449b2a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/Snippets.txt +++ /dev/null @@ -1,4 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.h: CMFCReBar 1 -MainFrm.cpp: CMFCReBar 2 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/UserImages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/UserImages.bmp deleted file mode 100644 index affe657025e47..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/UserImages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/rebartest.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/rebartest.vcxproj deleted file mode 100644 index 3798224c41cd6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/rebartest.vcxproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {5F7FB397-DEAD-429A-B097-09B0CCEFBC6D} - RebarTest - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - true - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - false - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level3 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - false - X64 - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level3 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX64 - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTest.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTest.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTest.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTest.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTest.rc2 deleted file mode 100644 index bba71271d464b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTest.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// RebarTest.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTestDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTestDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/RebarTestDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/stdafx.cpp deleted file mode 100644 index 005fbebe289cf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/stdafx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// RebarTest.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/stdafx.h deleted file mode 100644 index e5265594bfd45..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/stdafx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - - -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ChildFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ChildFrm.cpp deleted file mode 100644 index 33c12365fb705..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ChildFrm.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// ChildFrm.cpp : implementation of the CChildFrame class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "ChildFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CChildFrame - -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) -END_MESSAGE_MAP() - -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here -} - -CChildFrame::~CChildFrame() -{ -} - - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs - if( !CMDIChildWndEx::PreCreateWindow(cs) ) - return FALSE; - - return TRUE; -} - -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWndEx::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWndEx::Dump(dc); -} -#endif //_DEBUG - -// CChildFrame message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ChildFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ChildFrm.h deleted file mode 100644 index 00e42c9ed4f80..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ChildFrm.h +++ /dev/null @@ -1,32 +0,0 @@ -// ChildFrm.h : interface of the CChildFrame class -// - -#pragma once - -class CChildFrame : public CMDIChildWndEx -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.aps b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.aps deleted file mode 100644 index 0d81c77382b50..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.aps and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.cpp deleted file mode 100644 index bcfe53bcb2938..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// MFCRibbonApp.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include -#include "MFCRibbonApp.h" -#include "MainFrm.h" - -#include "ChildFrm.h" -#include "MFCRibbonAppDoc.h" -#include "MFCRibbonAppView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMFCRibbonAppApp - -BEGIN_MESSAGE_MAP(CMFCRibbonAppApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, &CMFCRibbonAppApp::OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) -END_MESSAGE_MAP() - - -// CMFCRibbonAppApp construction - -CMFCRibbonAppApp::CMFCRibbonAppApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -// The one and only CMFCRibbonAppApp object - -CMFCRibbonAppApp theApp; - - -// CMFCRibbonAppApp initialization - -BOOL CMFCRibbonAppApp::InitInstance() -{ - CWinAppEx::InitInstance(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need - // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization - SetRegistryKey(_T("Local AppWizard-Generated Applications")); - LoadStdProfileSettings(0); // Load standard INI file options - - InitContextMenuManager(); - - InitKeyboardManager(); - - InitTooltipManager(); - CMFCToolTipInfo ttParams; - ttParams.m_bVislManagerTheme = TRUE; - theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate(IDR_MFCRibbonAppTYPE, - RUNTIME_CLASS(CMFCRibbonAppDoc), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CMFCRibbonAppView)); - if (!pDocTemplate) - return FALSE; - AddDocTemplate(pDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) - { - delete pMainFrame; - return FALSE; - } - m_pMainWnd = pMainFrame; - // call DragAcceptFiles only if there's a suffix - // In an MDI app, this should occur immediately after setting m_pMainWnd - // Enable drag/drop open - m_pMainWnd->DragAcceptFiles(); - - // Enable DDE Execute open - EnableShellOpen(); - RegisterShellFileTypes(TRUE); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - - // Dispatch commands specified on the command line. Will return FALSE if - // app was launched with /RegServer, /Register, /Unregserver or /Unregister. - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - // The main window has been initialized, so show and update it - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - - return TRUE; -} - - - -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - enum { IDD = IDD_ABOUTBOX }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - -// App command to run the dialog -void CMFCRibbonAppApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -// CMFCRibbonAppApp customization load/save methods - -void CMFCRibbonAppApp::PreLoadState() -{ - CString strName; - strName.LoadString(IDS_EDIT_MENU); - GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); -} - -void CMFCRibbonAppApp::LoadCustomState() -{ -} - -void CMFCRibbonAppApp::SaveCustomState() -{ -} - -// CMFCRibbonAppApp message handlers - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.h deleted file mode 100644 index c98c8d0ae8b9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.h +++ /dev/null @@ -1,36 +0,0 @@ -// MFCRibbonApp.h : main header file for the MFCRibbonApp application -// -#pragma once - -#ifndef __AFXWIN_H__ - #error "include 'stdafx.h' before including this file for PCH" -#endif - -#include "resource.h" // main symbols - - -// CMFCRibbonAppApp: -// See MFCRibbonApp.cpp for the implementation of this class -// - -class CMFCRibbonAppApp : public CWinAppEx -{ -public: - CMFCRibbonAppApp(); - - -// Overrides -public: - virtual BOOL InitInstance(); - -// Implementation - UINT m_nAppLook; - virtual void PreLoadState(); - virtual void LoadCustomState(); - virtual void SaveCustomState(); - - afx_msg void OnAppAbout(); - DECLARE_MESSAGE_MAP() -}; - -extern CMFCRibbonAppApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.rc deleted file mode 100644 index e414754ed3302..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.rc +++ /dev/null @@ -1,541 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#ifndef APSTUDIO_INVOKED -#include "targetver.h" -#endif -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#ifndef APSTUDIO_INVOKED\r\n" - "#include ""targetver.h""\r\n" - "#endif\r\n" - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#include ""res\\MFCRibbonApp.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // MFC ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\MFCRibbonApp.ico" -IDR_MFCRibbonAppTYPE ICON "res\\MFCRibbonAppDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDR_MAINFRAME_256 BITMAP "res\\Toolbar256.bmp" -IDB_MAIN BITMAP "res\\main.bmp" -IDB_FILELARGE BITMAP "res\\filelarge.bmp" -IDB_FILESMALL BITMAP "res\\filesmall.bmp" -IDB_WRITELARGE BITMAP "res\\writelarge.bmp" -IDB_WRITESMALL BITMAP "res\\writesmall.bmp" -IDB_BUTTONS BITMAP "res\\buttons.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_APP_ABOUT -END - -IDR_MAINFRAME_256 TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Windows &2000", ID_VIEW_APPLOOK_WIN_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_OFF_XP - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_OFF_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS_2005 - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_OFF_2007_AQUA - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About MFCRibbonApp...", ID_APP_ABOUT - END -END - -IDR_MFCRibbonAppTYPE MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Windows &2000", ID_VIEW_APPLOOK_WIN_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_OFF_XP - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_OFF_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS_2005 - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_OFF_2007_AQUA - END - END - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - END - POPUP "&Help" - BEGIN - MENUITEM "&About MFCRibbonApp...", ID_APP_ABOUT - END -END - -IDR_POPUP_EDIT MENU -BEGIN - POPUP "Edit" - BEGIN - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END -END - -IDR_WINDOWS_MENU MENU -BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW -END - -IDR_THEME_MENU MENU -BEGIN - MENUITEM "Office 2007 (&Blue Style)", ID_VIEW_APPLOOK_OFF_2007_BLUE - MENUITEM "Office 2007 (B&lack Style)", ID_VIEW_APPLOOK_OFF_2007_BLACK - MENUITEM "Office 2007 (&Silver Style)", ID_VIEW_APPLOOK_OFF_2007_SILVER - MENUITEM "Office 2007 (&Aqua Style)", ID_VIEW_APPLOOK_OFF_2007_AQUA -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About MFCRibbonApp" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20 - LTEXT "MFCRibbonApp, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX - LTEXT "Copyright (C) 2008",IDC_STATIC,42,26,114,8 - DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "TODO: " - VALUE "FileDescription", "TODO: " - VALUE "FileVersion", "1.0.0.1" - VALUE "InternalName", "MFCRibbonApp.exe" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved." - VALUE "OriginalFilename", "MFCRibbonApp.exe" - VALUE "ProductName", "TODO: " - VALUE "ProductVersion", "1.0.0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 163 - TOPMARGIN, 7 - BOTTOMMARGIN, 55 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "MFCRibbonApp" - IDR_MFCRibbonAppTYPE "\nMFCRibbonApp\nMFCRibbonApp\nMFCRibbonApp Files (*.mfcrbnapp)\n.mfcrbnapp\nMFCRibbonApp.Document\nMFCRibbonApp.Document" - IDS_WINDOWS_MANAGER "Windows..." -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "MFCRibbonApp" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle Status Bar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" -END - -STRINGTABLE -BEGIN - IDS_STATUS_PANE1 "Pane 1" - IDS_STATUS_PANE2 "Pane 2" - ID_SLIDER_CONTROL "Slider control" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_FILE "File" - IDS_RIBBON_NEW "&New" - IDS_RIBBON_OPEN "&Open..." - IDS_RIBBON_SAVE "&Save" - IDS_RIBBON_SAVEAS "Save &As..." - IDS_RIBBON_PRINT "Print" - IDS_RIBBON_PRINT_LABEL "Preview and print the document" - IDS_RIBBON_PRINT_QUICK "&Quick Print" - IDS_RIBBON_PRINT_PREVIEW "Print Pre&view" - IDS_RIBBON_PRINT_SETUP "Print Set&up" - IDS_RIBBON_CLOSE "&Close" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_RECENT_DOCS "Recent Documents" - IDS_RIBBON_EXIT "E&xit" - IDS_RIBBON_HOME "&Home" - IDS_RIBBON_CLIPBOARD "Clipboard\nd" - IDS_RIBBON_PASTE "Paste\nv" - IDS_RIBBON_CUT "Cut\nx" - IDS_RIBBON_COPY "Copy\nc" - IDS_RIBBON_SELECTALL "Select All\na" - IDS_RIBBON_WINDOW "Window\nw" - IDS_RIBBON_WINDOWS "Windows\ni" - IDS_RIBBON_STYLE "Style" - IDS_RIBBON_STYLE_TIP "Modify Visual Style" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_STYLE_DESC "Choose one of the Office 2007 themes" - IDS_RIBBON_STATUSBAR "Status Bar" - IDS_RIBBON_VIEW "View" -END - -STRINGTABLE -BEGIN - IDS_EDIT_MENU "Edit" -END - -STRINGTABLE -BEGIN - IDS_RIBBON_CUSTOM "&Custom" - IDS_RIBBON_FAVORITES "FAVORITES" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) -#include "res\MFCRibbonApp.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#if !defined(_AFXDLL) -#include "afxribbon.rc" // MFC ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.reg b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.reg deleted file mode 100644 index 44314b013f25b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonApp.reg +++ /dev/null @@ -1,15 +0,0 @@ -REGEDIT -; This .REG file may be used by your SETUP program. -; If a SETUP program is not available, the entries below will be -; registered in your InitInstance automatically with a call to -; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll. - -HKEY_CLASSES_ROOT\.mfcrbnapp = MFCRibbonApp.Document -HKEY_CLASSES_ROOT\MFCRibbonApp.Document\shell\open\command = MFCRibbonApp.EXE %1 -HKEY_CLASSES_ROOT\MFCRibbonApp.Document\shell\open\ddeexec = [open("%1")] -HKEY_CLASSES_ROOT\MFCRibbonApp.Document\shell\open\ddeexec\application = MFCRibbonApp - ; note: the application is optional - ; (it defaults to the app name in "command") - -HKEY_CLASSES_ROOT\MFCRibbonApp.Document = MFCRibbonApp.Document - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppDoc.cpp deleted file mode 100644 index a5d318561262d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppDoc.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// MFCRibbonAppDoc.cpp : implementation of the CMFCRibbonAppDoc class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "MFCRibbonAppDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMFCRibbonAppDoc - -IMPLEMENT_DYNCREATE(CMFCRibbonAppDoc, CDocument) - -BEGIN_MESSAGE_MAP(CMFCRibbonAppDoc, CDocument) -END_MESSAGE_MAP() - - -// CMFCRibbonAppDoc construction/destruction - -CMFCRibbonAppDoc::CMFCRibbonAppDoc() -{ - // TODO: add one-time construction code here - -} - -CMFCRibbonAppDoc::~CMFCRibbonAppDoc() -{ -} - -BOOL CMFCRibbonAppDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - - -// CMFCRibbonAppDoc serialization - -void CMFCRibbonAppDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - - -// CMFCRibbonAppDoc diagnostics - -#ifdef _DEBUG -void CMFCRibbonAppDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CMFCRibbonAppDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - - -// CMFCRibbonAppDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppDoc.h deleted file mode 100644 index ebdf5767a9fc0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// MFCRibbonAppDoc.h : interface of the CMFCRibbonAppDoc class -// - - -#pragma once - - -class CMFCRibbonAppDoc : public CDocument -{ -protected: // create from serialization only - CMFCRibbonAppDoc(); - DECLARE_DYNCREATE(CMFCRibbonAppDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides -public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CMFCRibbonAppDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - DECLARE_MESSAGE_MAP() -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppView.cpp deleted file mode 100644 index f3e6566ce3fcc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppView.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// MFCRibbonAppView.cpp : implementation of the CMFCRibbonAppView class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "MFCRibbonAppDoc.h" -#include "MFCRibbonAppView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CMFCRibbonAppView - -IMPLEMENT_DYNCREATE(CMFCRibbonAppView, CView) - -BEGIN_MESSAGE_MAP(CMFCRibbonAppView, CView) -END_MESSAGE_MAP() - -// CMFCRibbonAppView construction/destruction - -CMFCRibbonAppView::CMFCRibbonAppView() -{ - // TODO: add construction code here - -} - -CMFCRibbonAppView::~CMFCRibbonAppView() -{ -} - -BOOL CMFCRibbonAppView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -// CMFCRibbonAppView drawing - -void CMFCRibbonAppView::OnDraw(CDC* /*pDC*/) -{ - CMFCRibbonAppDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - if (!pDoc) - return; - - // TODO: add draw code for native data here -} - -void CMFCRibbonAppView::OnRButtonUp(UINT nFlags, CPoint point) -{ - ClientToScreen(&point); - OnContextMenu(this, point); -} - -void CMFCRibbonAppView::OnContextMenu(CWnd* pWnd, CPoint point) -{ - theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE); -} - - -// CMFCRibbonAppView diagnostics - -#ifdef _DEBUG -void CMFCRibbonAppView::AssertValid() const -{ - CView::AssertValid(); -} - -void CMFCRibbonAppView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CMFCRibbonAppDoc* CMFCRibbonAppView::GetDocument() const // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCRibbonAppDoc))); - return (CMFCRibbonAppDoc*)m_pDocument; -} -#endif //_DEBUG - - -// CMFCRibbonAppView message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppView.h deleted file mode 100644 index a74336c23176c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MFCRibbonAppView.h +++ /dev/null @@ -1,49 +0,0 @@ -// MFCRibbonAppView.h : interface of the CMFCRibbonAppView class -// - - -#pragma once - - -class CMFCRibbonAppView : public CView -{ -protected: // create from serialization only - CMFCRibbonAppView(); - DECLARE_DYNCREATE(CMFCRibbonAppView) - -// Attributes -public: - CMFCRibbonAppDoc* GetDocument() const; - -// Operations -public: - -// Overrides -public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); -protected: - -// Implementation -public: - virtual ~CMFCRibbonAppView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - afx_msg void OnFilePrintPreview(); - afx_msg void OnRButtonUp(UINT nFlags, CPoint point); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in MFCRibbonAppView.cpp -inline CMFCRibbonAppDoc* CMFCRibbonAppView::GetDocument() const - { return reinterpret_cast(m_pDocument); } -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MainFrm.cpp deleted file mode 100644 index e09d505eb9853..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MainFrm.cpp +++ /dev/null @@ -1,746 +0,0 @@ -// MainFrm.cpp : implementation of the CMainFrame class -// - -#include "stdafx.h" -#include "MFCRibbonApp.h" - -#include "MainFrm.h" - -#include -#include -#include - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) - ON_WM_CREATE() - ON_COMMAND(ID_WINDOW_MANAGER, &CMainFrame::OnWindowManager) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_OFF_2007_AQUA, OnApplicationLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_OFF_2007_AQUA, OnUpdateApplicationLook) - ON_COMMAND( ID_SLIDER_CONTROL, OnSliding ) - ON_REGISTERED_MESSAGE( AFX_WM_ON_GET_TAB_TOOLTIP, OnTooltips ) - ON_WM_ACTIVATE() -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - //ID_INDICATOR_ICON, // status icon - ID_SEPARATOR, // status line indicator - //ID_INDICATOR_PROGRESS, // progress bar - //ID_INDICATOR_LABEL, // text label - //ID_INDICATOR_ANIMATION, // animation pane - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - - -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_OFF_2007_BLUE); - m_ribbonSlider = new CMFCRibbonSlider(ID_SLIDER_CONTROL, 500 ); -} - -CMainFrame::~CMainFrame() -{ -} - -LRESULT CMainFrame::OnTooltips(WPARAM /*wp*/, LPARAM lp) -{ - CMFCTabToolTipInfo* pInfo = (CMFCTabToolTipInfo*) lp; - ASSERT (pInfo != NULL); - ASSERT_VALID (pInfo->m_pTabWnd); - - if (!pInfo->m_pTabWnd->IsMDITab ()) - { - return 0; - } - - pInfo->m_strText.Format (_T("Tab #%d Custom Tooltip"), pInfo->m_nTabIndex + 1); - return 0; -} - -void CMainFrame::OnSliding( ) -{ - CString cstr; - - if (GetAsyncKeyState (VK_LBUTTON) == 0) - { - cstr.Format( _T( "position %d" ), m_ribbonSlider -> GetPos() ), - AfxMessageBox( cstr ); - } -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - // set the visual manager and style based on persisted value - OnApplicationLook(theApp.m_nAppLook); - - CMDITabInfo mdiTabParams; - mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; - // set to FALSE to place close button at right of tab area - mdiTabParams.m_bActiveTabCloseButton = FALSE; - // set to TRUE to enable document icons on MDI tabs - mdiTabParams.m_bTabIcons = TRUE; - // set to FALSE to disable auto-coloring of MDI tabs - mdiTabParams.m_bAutoColor = FALSE; - // set to TRUE to enable the document menu at the right edge of the tab area - mdiTabParams.m_bDocumentMenu = TRUE; - //set to TRUE to enable the user to change the tabs positions by dragging the tabs - mdiTabParams.m_bEnableTabSwap = TRUE; - // set to TRUE to give each tab window has a flat frame - mdiTabParams.m_bFlatFrame = TRUE; - // set to TRUE to enable each tab window to display the Close button on the right edge of the tab. - mdiTabParams.m_bTabCloseButton = FALSE; - // set to TRUE to enable the tabs to display tooltips. - mdiTabParams.m_bTabCustomTooltips = TRUE; - // Specifies that the tabs labels are located at the top of the page - mdiTabParams.m_tabLocation = CMFCTabCtrl::LOCATION_TOP; - EnableMDITabbedGroups(TRUE, mdiTabParams); - - // - // CMFCRibbonBar m_wndRibbonBar - m_wndRibbonBar.Create(this,WS_CHILD|CBRS_TOP); - // - InitializeRibbon(); - - if (!m_wndStatusBar.Create(this)) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - // - // - CString strTitlePane1; - CString strTitlePane2; - strTitlePane1.LoadString(IDS_STATUS_PANE1); - strTitlePane2.LoadString(IDS_STATUS_PANE2); - - CMFCRibbonStatusBarPane* rsbp = new CMFCRibbonStatusBarPane( ID_STATUSBAR_PANE1, strTitlePane1, TRUE ); - // - rsbp->SetTextAlign( TA_CENTER ); - rsbp->SetAlmostLargeText( _T( "Status bar" ) ); - CBitmap bitmap; - bitmap.LoadBitmapW( IDB_FILESMALL ); - rsbp->SetAnimationList( (HBITMAP)bitmap ); - rsbp->StartAnimation(); - // - - // - // CMFCRibbonStatusBar m_wndStatusBar - m_wndStatusBar.AddElement(rsbp, strTitlePane1); - m_wndStatusBar.AddExtendedElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE), - strTitlePane2); - // - - - // - m_wndStatusBar.AddSeparator(); - m_wndStatusBar.SetInformation(NULL); - // - - // enable Visual Studio 2005 style docking window behavior - CDockingManager::SetDockingMode(DT_SMART); - // enable Visual Studio 2005 style docking window auto-hide behavior - EnableAutoHidePanes(CBRS_ALIGN_ANY); - - // Enable enhanced windows management dialog - EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); - - // - // CMFCRibbonBar m_wndRibbonBar - // this points to CMainFrame - CMFCRibbonCustomizeDialog* cDialog = new CMFCRibbonCustomizeDialog(this, &m_wndRibbonBar); - // - - cDialog->DoModal(); - - // snippet 19 is not part of the original sample and is placed here to show how to - // use CMemDC. Exclude these lines if you want to run the sample. - - // - // this points to CMainFrame - // CDC* pDCPaint; - // pDCPaint = NULL; - // CMemDC memDC(*pDCPaint, this); - // CDC* pDC = &memDC.GetDC(); - - // set the text color and the background mode - // pDC->SetTextColor(afxGlobalData.clrBtnText); - // pDC->SetBkMode(TRANSPARENT); - // - - // Do drawing here: - // pDC->Some Draw Operations - // at this point the contents of CMemDC are copied to the screen DC. - - // - CMFCPropertyGridToolTipCtrl* pToolTipCtrl = new CMFCPropertyGridToolTipCtrl(); - CRect crect(1,1,50,50); - pToolTipCtrl->Track( crect, _T("this is a tool tip control")); - // - - // - CMFCHeaderCtrl* headerCtrl = new CMFCHeaderCtrl(); - headerCtrl->EnableMultipleSort(); - // - - // - CMFCSpinButtonCtrl* pWndSpin = new CMFCSpinButtonCtrl; - CRect rectSpin(1,1,10,10); - CMFCPropertyGridCtrl* pWndList = new CMFCPropertyGridCtrl(); - if (!pWndSpin->Create(WS_CHILD | WS_VISIBLE | UDS_ARROWKEYS | UDS_SETBUDDYINT | UDS_NOTHOUSANDS, rectSpin, pWndList, AFX_PROPLIST_ID_INPLACE)) - { - return 0; - } - // - - // - CMFCAutoHideBar* pParentBar = new CMFCAutoHideBar(); - CDockingPanesRow* pParentRow = pParentBar->GetDockSiteRow(); - // - - // - CAutoHideDockSite* pParentDockBar = DYNAMIC_DOWNCAST(CAutoHideDockSite, pParentBar->GetParentDockSite()); - pParentDockBar->SetOffsetLeft(10); - pParentDockBar->SetOffsetRight(10); - // - - // - AFX_DOCKSITE_INFO info; - CDockSite* pDockBar = (CDockSite*) info.pDockBarRTC->CreateObject(); - // - - // - CMFCTasksPane* tPane = new CMFCTasksPane(); - tPane->EnableGroupCollapse(true); - tPane->EnableHistoryMenuButtons(true); - tPane->EnableScrollButtons(true); - tPane->EnableWrapLabels(true); - tPane->SetCaption(_T("Task Pane")); - tPane->SetGroupTextColor(0,RGB(0,0,128)); - tPane->SetHorzMargin(15); - tPane->SetVertMargin(15); - tPane->Update(); - // - - // - CString strKey; - ACCEL accel; - accel.fVirt = FVIRTKEY | FCONTROL; - accel.key = VK_DOWN; - - CMFCAcceleratorKey helper(&accel); - helper.Format(strKey); - // - - // - CMFCAcceleratorKeyAssignCtrl* accelCtrl = new CMFCAcceleratorKeyAssignCtrl(); - accelCtrl->ResetKey(); - // - - // - CMFCAutoHideButton* autoHideButton = new CMFCAutoHideButton(); - CDockablePane cPane; - // CMFCAutoHideBar* pParentBar - if ( !autoHideButton->Create(pParentBar, &cPane, CBRS_ALIGN_LEFT) ) - { - return 0; - } - autoHideButton->ShowAttachedWindow(true); - autoHideButton->ShowButton(true); - // - - // - CSettingsStoreSP regSP; - CSettingsStore& reg = regSP.Create(FALSE, TRUE); - // - - // - COLORREF color; - CArray colors; - CString strAutoColorText; - CString strOtherText; - CString strDocColorsText; - CList lstDocColors; - COLORREF colorAutomatic; - int nColumns; - CMFCColorButton colorButton; - CMFCColorPopupMenu* pPopup = new CMFCColorPopupMenu(&colorButton, colors, color, strAutoColorText, strOtherText, strDocColorsText, lstDocColors, nColumns, colorAutomatic); - // - - // - CMFCCustomColorsPropertyPage* colourSheet = new CMFCCustomColorsPropertyPage(); - colourSheet->Setup(0,0,255); - // - - // - CFrameWnd* pTopFrame = AFXGetParentFrame(this); - if (pTopFrame == NULL) - { - return FALSE; - } - - CMFCDropDownFrame* pDropFrame = DYNAMIC_DOWNCAST(CMFCDropDownFrame, pTopFrame); - pDropFrame->SetAutoDestroy(true); - // - - // - COLORREF mcolor(RGB(0,255,0)); - //CBitmap bitmap; - CMFCImageEditorDialog* dialog = new CMFCImageEditorDialog(&bitmap); - CMFCImagePaintArea* wndLargeDrawArea = new CMFCImagePaintArea(dialog); - wndLargeDrawArea->SetColor(mcolor); - wndLargeDrawArea->SetMode(CMFCImagePaintArea::IMAGE_EDIT_MODE_PEN); - wndLargeDrawArea->SetBitmap(&bitmap); - // - - // - HWND hWndTab = NULL; - CBasePane* basePane = new CBasePane(); - CMFCBaseTabCtrl* pTabParent = basePane->GetParentTabWnd(hWndTab); - CMFCTabDropTarget* dropTarget = new CMFCTabDropTarget(); - dropTarget->Register(pTabParent); - // - - // - CMFCToolBarEditBoxButton* boxButton = new CMFCToolBarEditBoxButton(); - boxButton->CanBeStretched(); - boxButton->HaveHotBorder(); - boxButton->SetContents(_T("edit box button")); - boxButton->SetFlatMode(true); - boxButton->SetStyle(TBBS_PRESSED); - // - - // - CMFCCaptionButton* captionButton = new CMFCCaptionButton(AFX_HTCLOSE); - captionButton->SetMiniFrameButton(true); - // - - // - // The this pointer points to a CMainFrame class which extends the CMDIFrameWndEx class. - CMFCColorPropertySheet* pPropertySheet = new CMFCColorPropertySheet(_T("color property sheet"), this); - // - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWndEx::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -void CMainFrame::InitializeRibbon() -{ - CString strTemp; - - // Load panel images: - m_PanelImages.SetImageSize(CSize(16, 16)); - m_PanelImages.Load(IDB_BUTTONS); - - // - // Init main button: - // CMFCRibbonApplicationButton m_MainButton - m_MainButton.SetImage(IDB_MAIN); - m_MainButton.SetText(_T("\nf")); - m_MainButton.SetToolTipText(strTemp); - - // CMFCRibbonBar m_wndRibbonBar - m_wndRibbonBar.SetApplicationButton(&m_MainButton, CSize (45, 45)); - // - - - m_wndRibbonBar.EnableToolTips( true, true ); - m_wndRibbonBar.EnablePrintPreview( true ); - CMFCRibbonCategory* rc = m_wndRibbonBar.AddPrintPreviewCategory(); - m_wndRibbonBar.EnableKeyTips( true ); - - - // - // m_wndRibbonBar is declared as a protected member variable - // CMFCRibbonBar m_wndRibbonBar. - // strTemp is a CString variable. - strTemp.LoadString(IDS_RIBBON_FILE); - CMFCRibbonMainPanel* pMainPanel = m_wndRibbonBar.AddMainCategory(strTemp, - IDB_FILESMALL, IDB_FILELARGE); - // - - CString cstr; - CMFCRibbonUndoButton* undoButton = new CMFCRibbonUndoButton(ID_EDIT_UNDO, - _T("Undo button"), 0, 0); - - for (int i = 0; i < 20; i++) - { - CString str; - str.Format(_T("Action %d"), i + 1); - undoButton->AddUndoAction(str); - } - pMainPanel->Add(undoButton); - - strTemp.LoadString(IDS_RIBBON_NEW); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_NEW, strTemp, 0, 0)); - strTemp.LoadString(IDS_RIBBON_OPEN); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_OPEN, strTemp, 1, 1)); - strTemp.LoadString(IDS_RIBBON_SAVE); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SAVE, strTemp, 2, 2)); - strTemp.LoadString(IDS_RIBBON_SAVEAS); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_SAVE_AS, strTemp, 3, 3)); - - strTemp.LoadString(IDS_RIBBON_PRINT); - CMFCRibbonButton* pBtnPrint = new CMFCRibbonButton(ID_FILE_PRINT, strTemp, 6, 6); - pBtnPrint->SetKeys(_T("p"), _T("w")); - strTemp.LoadString(IDS_RIBBON_PRINT_LABEL); - pBtnPrint->AddSubItem(new CMFCRibbonLabel(strTemp)); - strTemp.LoadString(IDS_RIBBON_PRINT_QUICK); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_DIRECT, strTemp, 7, 7, TRUE)); - strTemp.LoadString(IDS_RIBBON_PRINT_PREVIEW); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_PREVIEW, strTemp, 8, 8, TRUE)); - strTemp.LoadString(IDS_RIBBON_PRINT_SETUP); - pBtnPrint->AddSubItem(new CMFCRibbonButton(ID_FILE_PRINT_SETUP, strTemp, 11, 11, TRUE)); - pMainPanel->Add(pBtnPrint); - - // - // CMFCRibbonMainPanel* pMainPanel - pMainPanel->Add(new CMFCRibbonSeparator(TRUE)); - // - - strTemp.LoadString(IDS_RIBBON_CLOSE); - pMainPanel->Add(new CMFCRibbonButton(ID_FILE_CLOSE, strTemp, 9, 9)); - - strTemp.LoadString(IDS_RIBBON_RECENT_DOCS); - pMainPanel->AddRecentFilesList(strTemp); - - strTemp.LoadString(IDS_RIBBON_EXIT); - pMainPanel->AddToBottom(new CMFCRibbonMainPanelButton(ID_APP_EXIT, strTemp, 15)); - - // Add "Home" category with "Clipboard" panel - - // - // Add "Home" category. - // CMFCRibbonBar m_wndRibbonBar - strTemp.LoadString(IDS_RIBBON_HOME); - CMFCRibbonCategory* pCategoryHome = m_wndRibbonBar.AddCategory(strTemp, - IDB_WRITESMALL, IDB_WRITELARGE); - // - - m_wndRibbonBar.ToggleMimimizeState(); - - // Create "Clipboard" panel - strTemp.LoadString(IDS_RIBBON_CLIPBOARD); - CMFCRibbonPanel* pPanelClipboard = pCategoryHome->AddPanel(strTemp, m_PanelImages.ExtractIcon(27)); - - // Create a paste button and add it to the "Clipboard" panel - strTemp.LoadString(IDS_RIBBON_PASTE); - CMFCRibbonButton* pBtnPaste = new CMFCRibbonButton(ID_EDIT_PASTE, strTemp, 0, 0); - pPanelClipboard->Add(pBtnPaste); - - // - strTemp.LoadString(IDS_RIBBON_CUT); - CMFCRibbonButton* butn = new CMFCRibbonButton(ID_EDIT_CUT, strTemp, 1); - butn ->SetKeys(_T("k")); - // - pPanelClipboard->Add(butn); - - strTemp.LoadString(IDS_RIBBON_COPY); - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_COPY, strTemp, 2)); - strTemp.LoadString(IDS_RIBBON_SELECTALL); - pPanelClipboard->Add(new CMFCRibbonButton(ID_EDIT_SELECT_ALL, strTemp, -1)); - - // Create and add a "View" panel: - strTemp.LoadString(IDS_RIBBON_VIEW); - CMFCRibbonPanel* pPanelView = pCategoryHome->AddPanel(strTemp, m_PanelImages.ExtractIcon (7)); - - // - strTemp.LoadString(IDS_RIBBON_STATUSBAR); - CMFCRibbonButton* pBtnStatusBar = new CMFCRibbonCheckBox(ID_VIEW_STATUS_BAR, strTemp); - // - pPanelView->Add(pBtnStatusBar); - - - // Create and add a "Windows" panel: - strTemp.LoadString(IDS_RIBBON_WINDOW); - CMFCRibbonPanel* pPanelWindow = pCategoryHome->AddPanel(strTemp, m_PanelImages.ExtractIcon (7)); - - strTemp.LoadString(IDS_RIBBON_WINDOWS); - - CMFCRibbonButton* pBtnWindows = new CMFCRibbonButton(ID_WINDOW_MANAGER, strTemp, -1, 1); - pBtnWindows->SetMenu(IDR_WINDOWS_MENU, TRUE); - pPanelWindow->Add(pBtnWindows); - - // - strTemp.LoadString(IDS_RIBBON_STYLE); - // The first parameter is the command ID of the button. - // The third parameter is a zero-based index of the button's small image in the - // image list of the parent category. - // The fourth parameter is a zero-based index of the button's large image in the - // image list of the parent category. - CMFCRibbonButton* pVisualStyleButton = new CMFCRibbonButton(1, strTemp, -1, -1); - - pVisualStyleButton->SetMenu(IDR_THEME_MENU, TRUE, TRUE); - - strTemp.LoadString(IDS_RIBBON_STYLE_TIP); - pVisualStyleButton->SetToolTipText(strTemp); - strTemp.LoadString(IDS_RIBBON_STYLE_DESC); - pVisualStyleButton->SetDescription(strTemp); - pVisualStyleButton->RemoveSubItem(0); - pVisualStyleButton->SetRightAlignMenu(TRUE); - // - - m_wndRibbonBar.AddToTabs(pVisualStyleButton); - m_wndRibbonBar.SetQuickAccessToolbarOnTop( false ); - - m_wndRibbonBar.RecalcLayout (); - CFrameWnd* pParentFrame = this->GetParentFrame(); - - if (pParentFrame->GetSafeHwnd () != NULL) - { - pParentFrame->RecalcLayout (); - pParentFrame->RedrawWindow (NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); - } - - // - // Add quick access commands to the toolbar - CList lstQATCmds; - - lstQATCmds.AddTail(ID_FILE_NEW); - lstQATCmds.AddTail(ID_FILE_OPEN); - lstQATCmds.AddTail(ID_FILE_SAVE); - lstQATCmds.AddTail(ID_FILE_PRINT_DIRECT); - - // CMFCRibbonBar m_wndRibbonBar - m_wndRibbonBar.SetQuickAccessCommands(lstQATCmds); - // - - // - // - CMFCRibbonQuickAccessToolBarDefaultState* qaToolBarState = - new CMFCRibbonQuickAccessToolBarDefaultState(); - qaToolBarState->AddCommand(ID_FILE_NEW, true); - qaToolBarState->AddCommand(ID_FILE_OPEN, true); - // - // CMFCRibbonBar m_wndRibbonBar - m_wndRibbonBar.SetQuickAccessDefaultState(*qaToolBarState); - // - - m_wndRibbonBar.AddToTabs(new CMFCRibbonButton(ID_APP_ABOUT, _T("\na"), m_PanelImages.ExtractIcon (0))); - - strTemp.LoadString(IDS_RIBBON_CUSTOM); - CMFCRibbonCategory* pCategoryCustom = m_wndRibbonBar.AddCategory(strTemp, IDB_FILESMALL, IDB_FILELARGE); - - // - // Create "Favorites" panel: - strTemp.LoadString(IDS_RIBBON_FAVORITES); - // CMFCRibbonCategory* pCategoryCustom - CMFCRibbonPanel* pPanelFavorites = pCategoryCustom->AddPanel(strTemp, - m_PanelImages.ExtractIcon(15)); - // - - // Create "Quick Print" button: - strTemp.LoadString(IDS_RIBBON_PRINT_QUICK); - CMFCRibbonButton* pBtnFavPrintQuick = new CMFCRibbonButton(ID_FILE_PRINT_DIRECT, strTemp, 7); - - // Create "Print" button with "Quick Print" as subitem: - strTemp.LoadString(IDS_RIBBON_PRINT); - CMFCRibbonButton* pBtnFavPrint = new CMFCRibbonButton(ID_FILE_PRINT, strTemp, 6); - pBtnFavPrint->AddSubItem(pBtnFavPrintQuick); - - // Add "Print" button to "Favorites" panel: - pPanelFavorites->Add(pBtnFavPrint); - - // - // Create a simple combo box with two entries: - // The first parameter is the id of the combo box. - // The third parameter is the width of the combo box in pixels. - // The fourth parameter is the display label of the combo box. - // The fifth parameter is the index of the small image of the combo box. - CMFCRibbonComboBox *pComboSimple = new CMFCRibbonComboBox(-1, FALSE, -1, 0, -1); - - // Add two items to the combo box and select the first item in the list: - pComboSimple->AddItem(_T("Hi!")); - pComboSimple->AddItem(_T("Hello!")); - pComboSimple->SelectItem(0); - - // Add combo button to "Favorites" panel: - // CMFCRibbonPanel* pPanelFavorites - pPanelFavorites->Add(pComboSimple); - // - - // - // Create a ribbon slider. - CMFCRibbonSlider* ribbonSlider = new CMFCRibbonSlider(); - // Set the various properties of the slider. - ribbonSlider->SetZoomButtons(true); - ribbonSlider->SetPos(50, TRUE); - ribbonSlider->SetRange(0, 100); - // Add the ribbon slider to the Favorites panel. - // CMFCRibbonPanel* pPanelFavorites - pPanelFavorites->Add(ribbonSlider); - // - - // - CArray arCollapseOrder; - arCollapseOrder.Add(0); - arCollapseOrder.Add(1); - arCollapseOrder.Add(2); - // CMFCRibbonCategory* pCategoryHome - pCategoryHome->SetCollapseOrder(arCollapseOrder); - // - - pCategoryHome->SetKeys(_T("O")); - - pCategoryHome->SetTabColor(AFX_CategoryColor_Red); - - // - // Create "Customize" page - // CMFCRibbonBar m_wndRibbonBar - CMFCRibbonCustomizePropertyPage pageCustomize(&m_wndRibbonBar); - - // Create a list of popular items: - CList lstPopular; - lstPopular.AddTail(ID_FILE_NEW); - lstPopular.AddTail(ID_FILE_OPEN); - - // add a custom category - pageCustomize.AddCustomCategory(_T("Popular Commands"), lstPopular); - // - - // - // CMFCRibbonComboBox *pComboSimple - CMFCDropDownListBox* listBox = new CMFCDropDownListBox(pComboSimple); - listBox->AddString(_T("this is a drop down list box")); - listBox->SetCurSel(0); - listBox->SetMaxHeight(100); - listBox->SetMinWidth(10); - // - - // - // - CMFCToolTipInfo* params = new CMFCToolTipInfo(); - - params->m_bBoldLabel = FALSE; - params->m_bDrawDescription = FALSE; - params->m_bDrawIcon = FALSE; - params->m_bRoundedCorners = TRUE; - params->m_bDrawSeparator = FALSE; - params->m_clrFill = RGB (255, 255, 255); - params->m_clrFillGradient = RGB (228, 228, 240); - params->m_clrText = RGB (61, 83, 80); - params->m_clrBorder = RGB (144, 149, 168); - // - - CMFCToolTipCtrl* tipCtrl = new CMFCToolTipCtrl(params); - tipCtrl->SetDescription(_T("tool tip control")); - tipCtrl->SetFixedWidth(100,150); - // -} - -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWndEx::Dump(dc); -} -#endif //_DEBUG - - -// CMainFrame message handlers - -void CMainFrame::OnWindowManager() -{ - ShowWindowsDialog(); -} - -void CMainFrame::OnApplicationLook(UINT id) -{ - CWaitCursor wait; - - theApp.m_nAppLook = id; - - switch (theApp.m_nAppLook) - { - case ID_VIEW_APPLOOK_WIN_2000: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_OFF_XP: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_OFF_2003: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - CDockingManager::SetDockingMode(DT_SMART); - break; - - case ID_VIEW_APPLOOK_VS_2005: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); - CDockingManager::SetDockingMode(DT_SMART); - break; - - default: - switch (theApp.m_nAppLook) - { - case ID_VIEW_APPLOOK_OFF_2007_BLUE: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case ID_VIEW_APPLOOK_OFF_2007_BLACK: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case ID_VIEW_APPLOOK_OFF_2007_SILVER: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); - break; - - case ID_VIEW_APPLOOK_OFF_2007_AQUA: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - } - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode(DT_SMART); - } - - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); - - theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); -} - -void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID); -} - -void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) -{ - CMDIFrameWndEx::OnActivate(nState, pWndOther, bMinimized); - - // TODO: Add your message handler code here -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MainFrm.h deleted file mode 100644 index 2680fe8b0baa0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/MainFrm.h +++ /dev/null @@ -1,52 +0,0 @@ -// MainFrm.h : interface of the CMainFrame class -// - -#pragma once - -class CMainFrame : public CMDIFrameWndEx -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides -public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCRibbonBar m_wndRibbonBar; - CMFCRibbonApplicationButton m_MainButton; - CMFCToolBarImages m_PanelImages; - CMFCRibbonStatusBar m_wndStatusBar; - CMFCRibbonSlider* m_ribbonSlider; - -// Generated message map functions -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnWindowManager(); - afx_msg void OnApplicationLook(UINT id); - afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI); - afx_msg void OnSliding(); - afx_msg LRESULT OnTooltips(WPARAM /*wp*/, LPARAM lp); - DECLARE_MESSAGE_MAP() - - void InitializeRibbon(); -public: - afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ReadMe.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ReadMe.txt deleted file mode 100644 index 11580887f8811..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/ReadMe.txt +++ /dev/null @@ -1,127 +0,0 @@ -================================================================================ - MICROSOFT FOUNDATION CLASS LIBRARY : MFCRibbonApp Project Overview -=============================================================================== - -The application wizard has created this MFCRibbonApp application for -you. This application not only demonstrates the basics of using the Microsoft -Foundation Classes but is also a starting point for writing your application. - -This file contains a summary of what you will find in each of the files that -make up your MFCRibbonApp application. - -MFCRibbonApp.vcproj - This is the main project file for VC++ projects generated using an application wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - application wizard. - -MFCRibbonApp.h - This is the main header file for the application. It includes other - project specific headers (including Resource.h) and declares the - CMFCRibbonAppApp application class. - -MFCRibbonApp.cpp - This is the main application source file that contains the application - class CMFCRibbonAppApp. - -MFCRibbonApp.rc - This is a listing of all of the Microsoft Windows resources that the - program uses. It includes the icons, bitmaps, and cursors that are stored - in the RES subdirectory. This file can be directly edited in Microsoft - Visual C++. Your project resources are in 1033. - -res\MFCRibbonApp.ico - This is an icon file, which is used as the application's icon. This - icon is included by the main resource file MFCRibbonApp.rc. - -res\MFCRibbonApp.rc2 - This file contains resources that are not edited by Microsoft - Visual C++. You should place all resources not editable by - the resource editor in this file. - -MFCRibbonApp.reg - This is an example .reg file that shows you the kind of registration - settings the framework will set for you. You can use this as a .reg - file to go along with your application or just delete it and rely - on the default RegisterShellFileTypes registration. - - -///////////////////////////////////////////////////////////////////////////// - -For the main frame window: - The project includes a standard MFC interface. - -MainFrm.h, MainFrm.cpp - These files contain the frame class CMainFrame, which is derived from - CMDIFrameWnd and controls all MDI frame features. - -res\Toolbar.bmp - This bitmap file is used to create tiled images for the toolbar. - The initial toolbar and status bar are constructed in the CMainFrame - class. Edit this toolbar bitmap using the resource editor, and - update the IDR_MAINFRAME TOOLBAR array in MFCRibbonApp.rc to add - toolbar buttons. -///////////////////////////////////////////////////////////////////////////// - -For the child frame window: - -ChildFrm.h, ChildFrm.cpp - These files define and implement the CChildFrame class, which - supports the child windows in an MDI application. - -///////////////////////////////////////////////////////////////////////////// - -The application wizard creates one document type and one view: - -MFCRibbonAppDoc.h, MFCRibbonAppDoc.cpp - the document - These files contain your CMFCRibbonAppDoc class. Edit these files to - add your special document data and to implement file saving and loading - (via CMFCRibbonAppDoc::Serialize). - The Document will have the following strings: - File extension: mfcrbnapp - File type ID: MFCRibbonApp.Document - Main frame caption: MFCRibbonApp - Doc type name: MFCRibbonApp - Filter name: MFCRibbonApp Files (*.mfcrbnapp) - File new short name: MFCRibbonApp - File type long name: MFCRibbonApp.Document - -MFCRibbonAppView.h, MFCRibbonAppView.cpp - the view of the document - These files contain your CMFCRibbonAppView class. - CMFCRibbonAppView objects are used to view CMFCRibbonAppDoc objects. - -res\MFCRibbonAppDoc.ico - This is an icon file, which is used as the icon for MDI child windows - for the CMFCRibbonAppDoc class. This icon is included by the main - resource file MFCRibbonApp.rc. - - - - -///////////////////////////////////////////////////////////////////////////// - -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named MFCRibbonApp.pch and a precompiled types file named StdAfx.obj. - -Resource.h - This is the standard header file, which defines new resource IDs. - Microsoft Visual C++ reads and updates this file. - -///////////////////////////////////////////////////////////////////////////// - -Other notes: - -The application wizard uses "TODO:" to indicate parts of the source code you -should add to or customize. - -If your application uses MFC in a shared DLL, you will need -to redistribute the MFC DLLs. If your application is in a language -other than the operating system's locale, you will also have to -redistribute the corresponding localized resources MFC90XXX.DLL. -For more information on both of these topics, please see the section on -redistributing Visual C++ applications in MSDN documentation. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/Snippets.txt deleted file mode 100644 index ceb2afe01ef76..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/Snippets.txt +++ /dev/null @@ -1,46 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp 1 -MainFrm.cpp 2 -MainFrm.cpp 3 -MainFrm.cpp 4 -MainFrm.cpp 5 -MainFrm.cpp 6 -MainFrm.cpp 7 -MainFrm.cpp 8 -MainFrm.cpp 9 -MainFrm.cpp 10 -MainFrm.cpp 11 -MainFrm.cpp 12 -MainFrm.cpp 13 -MainFrm.cpp 14 -MainFrm.cpp 15 -MainFrm.cpp 16 -MainFrm.cpp 17 -MainFrm.cpp 18 -MainFrm.cpp 19 -MainFrm.cpp:CMemDC 20 -MainFrm.cpp: CMFCRibbonQuickAccessToolBarDefaultState 21 -MainFrm.cpp: CMFCRibbonCustomizePropertyPage 22 -MainFrm.cpp: CMFCPropertyGridToolTipCtrl 23 -MainFrm.cpp: CMFCHeaderCtrl 24 -MainFrm.cpp: CMFCSpinButtonCtrl 25 -MainFrm.cpp: CDockingPanesRow 26 -MainFrm.cpp: CDockSite 27 -MainFrm.cpp: CMFCTasksPane 28 -MainFrm.cpp: CAutoHideDockSite 29 -MainFrm.cpp: CMFCAcceleratorKey 30 -MainFrm.cpp: CMFCAcceleratorKeyAssignCtrl 31 -MainFrm.cpp: CMFCAutoHideButton 32 -MainFrm.cpp: CSettingsStoreSP 33 -MainFrm.cpp: CMFCColorPopupMenu 34 -MainFrm.cpp: CMFCCustomColorsPropertyPage 35 -MainFrm.cpp: CMFCDropDownFrame 36 -MainFrm.cpp: CMFCImagePaintArea 37 -MainFrm.cpp: CMFCDropDownListBox 38 -MainFrm.cpp: CMFCTabDropTarget 39 -MainFrm.cpp: CMFCToolBarEditBoxButton 40 -MainFrm.cpp: CMFCToolTipCtrl 41 -MainFrm.cpp: CMFCToolTipInfo 42 -MainFrm.cpp: CMFCCaptionButton 43 -MainFrm.cpp: CMFCColorPropertySheet 44 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/mfcribbonapp.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/mfcribbonapp.vcxproj deleted file mode 100644 index d331b965f9933..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/mfcribbonapp.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Release - Win32 - - - - {68E86035-ED93-4DDD-99B7-15A3337B8A2D} - MFCRibbonApp - MFCProj - - - - Application - Dynamic - Unicode - v110 - - - Application - v110 - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - true - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level3 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - true - Windows - MachineX86 - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonApp.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonApp.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonApp.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonApp.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonApp.rc2 deleted file mode 100644 index 2c189044817a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonApp.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// MFCRibbonApp.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonAppDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonAppDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/MFCRibbonAppDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/buttons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/buttons.bmp deleted file mode 100644 index 565fdcd6cda0a..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/buttons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/filelarge.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/filelarge.bmp deleted file mode 100644 index bf5c47c416ff3..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/filelarge.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/filesmall.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/filesmall.bmp deleted file mode 100644 index e530a92b3f2f0..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/filesmall.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/main.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/main.bmp deleted file mode 100644 index 9393d8e6ee316..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/main.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/writelarge.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/writelarge.bmp deleted file mode 100644 index 7f11d1dc99f78..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/writelarge.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/writesmall.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/writesmall.bmp deleted file mode 100644 index eda0f16597e8d..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/res/writesmall.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/resource.h deleted file mode 100644 index 5993822cfb3c0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/resource.h +++ /dev/null @@ -1,76 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by MFCRibbonApp.rc -// -#define IDS_RIBBON_CUSTOM 1 -#define IDS_RIBBON_FAVORITES 2 -#define IDD_ABOUTBOX 100 -#define IDB_WRITESMALL 110 -#define IDB_WRITELARGE 111 -#define IDB_MAIN 112 -#define IDB_BUTTONS 113 -#define IDB_FILELARGE 114 -#define IDB_FILESMALL 115 -#define IDR_POPUP_EDIT 119 -#define ID_STATUSBAR_PANE1 120 -#define ID_STATUSBAR_PANE2 121 -#define IDS_STATUS_PANE1 122 -#define IDS_STATUS_PANE2 123 -#define ID_SLIDER_CONTROL 124 -#define IDR_MAINFRAME 128 -#define IDR_MAINFRAME_256 129 -#define IDR_MFCRibbonAppTYPE 130 -#define ID_WINDOW_MANAGER 131 -#define IDS_WINDOWS_MANAGER 132 -#define IDR_PASTE_MENU 151 -#define IDR_WINDOWS_MENU 152 -#define IDR_THEME_MENU 200 -#define ID_SET_STYLE 201 -#define ID_VIEW_APPLOOK_WIN_2000 210 -#define ID_VIEW_APPLOOK_OFF_XP 211 -#define ID_VIEW_APPLOOK_WIN_XP 212 -#define ID_VIEW_APPLOOK_OFF_2003 213 -#define ID_VIEW_APPLOOK_VS_2005 214 -#define ID_VIEW_APPLOOK_OFF_2007_BLUE 215 -#define ID_VIEW_APPLOOK_OFF_2007_BLACK 216 -#define ID_VIEW_APPLOOK_OFF_2007_SILVER 217 -#define ID_VIEW_APPLOOK_OFF_2007_AQUA 218 -#define IDS_RIBBON_FILE 260 -#define IDS_RIBBON_NEW 262 -#define IDS_RIBBON_OPEN 263 -#define IDS_RIBBON_SAVE 264 -#define IDS_RIBBON_SAVEAS 265 -#define IDS_RIBBON_PRINT 266 -#define IDS_RIBBON_PRINT_LABEL 267 -#define IDS_RIBBON_PRINT_QUICK 268 -#define IDS_RIBBON_PRINT_PREVIEW 269 -#define IDS_RIBBON_PRINT_SETUP 270 -#define IDS_RIBBON_CLOSE 271 -#define IDS_RIBBON_RECENT_DOCS 272 -#define IDS_RIBBON_EXIT 273 -#define IDS_RIBBON_HOME 274 -#define IDS_RIBBON_CLIPBOARD 275 -#define IDS_RIBBON_PASTE 276 -#define IDS_RIBBON_CUT 277 -#define IDS_RIBBON_COPY 278 -#define IDS_RIBBON_SELECTALL 279 -#define IDS_RIBBON_WINDOW 284 -#define IDS_RIBBON_WINDOWS 285 -#define IDS_RIBBON_STYLE 286 -#define IDS_RIBBON_STYLE_TIP 287 -#define IDS_RIBBON_STYLE_DESC 288 -#define IDS_RIBBON_STATUSBAR 289 -#define IDS_RIBBON_VIEW 290 -#define IDS_EDIT_MENU 306 -#define ID_WRITE_PASTEASHYPERLINK 32770 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 310 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 310 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/stdafx.cpp deleted file mode 100644 index 07ccf36321adb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/stdafx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// MFCRibbonApp.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/stdafx.h deleted file mode 100644 index 72f901ec9aeca..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/stdafx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - - - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonApp/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/MainFrm.cpp deleted file mode 100644 index 4e164a55401cc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/MainFrm.cpp +++ /dev/null @@ -1,1117 +0,0 @@ -#include "stdafx.h" -#include "RibbonGadgets.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int IdShowProgress1Timer = 1; -const int IdShowProgress2Timer = 2; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) - ON_WM_CREATE() - ON_COMMAND(ID_RIBBON_BTN_7, OnRibbonBtn7) - ON_UPDATE_COMMAND_UI(ID_RIBBON_BTN_7, OnUpdateRibbonBtn7) - ON_COMMAND(ID_RIBBON_BTN_8, OnRibbonBtn8) - ON_UPDATE_COMMAND_UI(ID_RIBBON_BTN_8, OnUpdateRibbonBtn8) - ON_COMMAND(ID_RIBBON_BTN_9, OnRibbonBtn9) - ON_UPDATE_COMMAND_UI(ID_RIBBON_BTN_9, OnUpdateRibbonBtn9) - ON_COMMAND(ID_RIBBON_OBTN_2, OnRibbonObtn2) - ON_COMMAND(ID_RIBBON_OBTN_3, OnRibbonObtn3) - ON_COMMAND(ID_RIBBON_OBTN_4, OnRibbonObtn4) - ON_COMMAND(ID_RIBBON_OBTN_8, OnRibbonObtn8) - ON_UPDATE_COMMAND_UI(ID_RIBBON_OBTN_8, OnUpdateRibbonObtn8) - ON_COMMAND(ID_RIBBON_OBTN_10, OnRibbonObtn10) - ON_UPDATE_COMMAND_UI(ID_RIBBON_OBTN_10, OnUpdateRibbonObtn10) - ON_WM_TIMER() - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2007, ID_VIEW_APPLOOK_2007_3, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2007, ID_VIEW_APPLOOK_2007_3, OnUpdateAppLook) - ON_REGISTERED_MESSAGE(AFX_WM_ON_RIBBON_CUSTOMIZE, OnRibbonCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_ON_CHANGE_RIBBON_CATEGORY, OnChangeRibbonCategory) - ON_COMMAND(ID_TOOLS_OPTIONS, OnToolsOptions) - ON_COMMAND_RANGE(ID_RIBBON_A, ID_RIBBON_Z, OnDummy) - ON_COMMAND(ID_FILE_PRINT, OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_PREVIEW, OnUpdateFilePrintPreview) - ON_WM_SYSCOLORCHANGE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() - : m_bCheckBox1 (TRUE) - , m_bCheckBox2 (FALSE) - , m_bCheckBox3 (FALSE) - , m_nProgressValue1 (-1) - , m_nProgressValue2 (-1) -{ - m_nAppLook = theApp.GetInt (_T("ApplicationLook"), ID_VIEW_APPLOOK_2007); -} - -void CMainFrame::CreateDocumentColors () -{ - typedef struct - { - COLORREF color; - TCHAR* szName; - } - ColorTableEntry; - - int i = 0; - int nNumColours = 0; - - static ColorTableEntry colorsMain [] = - { - { RGB (255, 255, 255), _T("White, Background 1") }, - { RGB (0, 0, 0), _T("Black, Text 1") }, - { RGB (238, 236, 225), _T("Tan, Background 2") }, - { RGB (31, 73, 125), _T("Dark Blue, Text 2") }, - { RGB (79, 129, 189), _T("Blue, Accent 1") }, - { RGB (192, 80, 77), _T("Red, Accent 2") }, - { RGB (155, 187, 89), _T("Olive Green, Accent 3") }, - { RGB (128, 100, 162), _T("Purple, Accent 4") }, - { RGB (75, 172, 198), _T("Aqua, Accent 5") }, - { RGB (245, 150, 70), _T("Orange, Accent 6") } - }; - - static ColorTableEntry colorsAdditional [] = - { - { RGB (242, 242, 242), _T("White, Background 1, Darker 5%") }, - { RGB (127, 127, 127), _T("Black, Text 1, Lighter 50%") }, - { RGB (214, 212, 202), _T("Tan, Background 2, Darker 10%") }, - { RGB (210, 218, 229), _T("Dark Blue, Text 2, Lighter 80%") }, - { RGB (217, 228, 240), _T("Blue, Accent 1, Lighter 80%") }, - { RGB (244, 219, 218), _T("Red, Accent 2, Lighter 80%") }, - { RGB (234, 241, 221), _T("Olive Green, Accent 3, Lighter 80%")}, - { RGB (229, 223, 235), _T("Purple, Accent 4, Lighter 80%") }, - { RGB (216, 237, 242), _T("Aqua, Accent 5, Lighter 80%") }, - { RGB (255, 234, 218), _T("Orange, Accent 6, Lighter 80%") }, - - { RGB (215, 215, 215), _T("White, Background 1, Darker 15%") }, - { RGB (89, 89, 89), _T("Black, Text 1, Lighter 35%") }, - { RGB (177, 176, 167), _T("Tan, Background 2, Darker 25%") }, - { RGB (161, 180, 201), _T("Dark Blue, Text 2, Lighter 60%") }, - { RGB (179, 202, 226), _T("Blue, Accent 1, Lighter 60%") }, - { RGB (233, 184, 182), _T("Red, Accent 2, Lighter 60%") }, - { RGB (213, 226, 188), _T("Olive Green, Accent 3, Lighter 60%")}, - { RGB (203, 191, 215), _T("Purple, Accent 4, Lighter 60%") }, - { RGB (176, 220, 231), _T("Aqua, Accent 5, Lighter 60%") }, - { RGB (255, 212, 181), _T("Orange, Accent 6, Lighter 60%") }, - - { RGB (190, 190, 190), _T("White, Background 1, Darker 25%") }, - { RGB (65, 65, 65), _T("Black, Text 1, Lighter 25%") }, - { RGB (118, 117, 112), _T("Tan, Background 2, Darker 35%") }, - { RGB (115, 143, 175), _T("Dark Blue, Text 2, Lighter 40%") }, - { RGB (143, 177, 213), _T("Blue, Accent 1, Lighter 40%") }, - { RGB (222, 149, 147), _T("Red, Accent 2, Lighter 40%") }, - { RGB (192, 213, 155), _T("Olive Green, Accent 3, Lighter 40%")}, - { RGB (177, 160, 197), _T("Purple, Accent 4, Lighter 40%") }, - { RGB (137, 203, 218), _T("Aqua, Accent 5, Lighter 40%") }, - { RGB (255, 191, 145), _T("Orange, Accent 6, Lighter 40%") }, - - { RGB (163, 163, 163), _T("White, Background 1, Darker 35%") }, - { RGB (42, 42, 42), _T("Black, Text 1, Lighter 15%") }, - { RGB (61, 61, 59), _T("Tan, Background 2, Darker 50%") }, - { RGB (20, 57, 92), _T("Dark Blue, Text 2, Darker 25%") }, - { RGB (54, 96, 139), _T("Blue, Accent 1, Darker 25%") }, - { RGB (149, 63, 60), _T("Red, Accent 2, Darker 25%") }, - { RGB (114, 139, 71), _T("Olive Green, Accent 3, Darker 25%") }, - { RGB (97, 76, 119), _T("Purple, Accent 4, Darker 25%") }, - { RGB (41, 128, 146), _T("Aqua, Accent 5, Darker 25%") }, - { RGB (190, 112, 59), _T("Orange, Accent 6, Darker 25%") }, - - { RGB (126, 126, 126), _T("White, Background 1, Darker 50%") }, - { RGB (20, 20, 20), _T("Black, Text 1, Lighter 5%") }, - { RGB (29, 29, 28), _T("Tan, Background 2, Darker 90%") }, - { RGB (17, 40, 64), _T("Dark Blue, Text 2, Darker 50%") }, - { RGB (38, 66, 94), _T("Blue, Accent 1, Darker 50%") }, - { RGB (100, 44, 43), _T("Red, Accent 2, Darker 50%") }, - { RGB (77, 93, 49), _T("Olive Green, Accent 3, Darker 50%") }, - { RGB (67, 53, 81), _T("Purple, Accent 4, Darker 50%") }, - { RGB (31, 86, 99), _T("Aqua, Accent 5, Darker 50%") }, - { RGB (126, 77, 42), _T("Orange, Accent 6, Darker 50%") }, - }; - - static ColorTableEntry colorsStandard [] = - { - { RGB (200, 15, 18), _T("Dark Red") }, - { RGB (255, 20, 24), _T("Red") }, - { RGB (255, 191, 40), _T("Orange") }, - { RGB (255, 255, 49), _T("Yellow") }, - { RGB (138, 207, 87), _T("Light Green") }, - { RGB (0, 175, 84), _T("Green") }, - { RGB (0, 174, 238), _T("Light Blue") }, - { RGB (0, 111, 189), _T("Blue") }, - { RGB (0, 36, 95), _T("Black") }, - { RGB (114, 50, 157), _T("Purple") }, - }; - - m_lstMainColors.RemoveAll (); - nNumColours = sizeof (colorsMain) / sizeof (ColorTableEntry); - - for (i = 0; i < nNumColours; i++) - { - m_lstMainColors.AddTail (colorsMain [i].color); - CMFCRibbonColorButton::SetColorName (colorsMain [i].color, colorsMain [i].szName); - }; - - m_lstAdditionalColors.RemoveAll (); - nNumColours = sizeof (colorsAdditional) / sizeof (ColorTableEntry); - - for (i = 0; i < nNumColours; i++) - { - m_lstAdditionalColors.AddTail (colorsAdditional [i].color); - CMFCRibbonColorButton::SetColorName (colorsAdditional [i].color, colorsAdditional [i].szName); - }; - - m_lstStandardColors.RemoveAll (); - nNumColours = sizeof (colorsStandard) / sizeof (ColorTableEntry); - - for (i = 0; i < nNumColours; i++) - { - m_lstStandardColors.AddTail (colorsStandard [i].color); - CMFCRibbonColorButton::SetColorName (colorsStandard [i].color, colorsStandard [i].szName); - }; -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - OnAppLook (m_nAppLook); - - if (!CreateRibbonBar ()) - { - TRACE0("Failed to create ribbon bar\n"); - return -1; // fail to create - } - - if (!m_wndStatusBar.Create(this)) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - m_wndStatusBar.AddElement (new CMFCRibbonStatusBarPane (ID_STATUSBAR_PANE1, _T("Pane 1"), TRUE), _T("Pane 1")); - m_wndStatusBar.AddExtendedElement (new CMFCRibbonStatusBarPane (ID_STATUSBAR_PANE2, _T("Pane 2"), TRUE), _T("Pane 2")); - - if (!m_wndOutput.Create (_T("Source Code"), this, CRect (0, 0, 150, 150), - TRUE /* Has gripper */, ID_VIEW_OUTPUT, - WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI, - AFX_CBRS_REGULAR_TABS, AFX_CBRS_RESIZE | AFX_CBRS_AUTOHIDE)) - { - TRACE0("Failed to create output bar\n"); - return -1; // fail to create - } - - EnableDocking(CBRS_ALIGN_ANY); - EnableAutoHidePanes(CBRS_ALIGN_ANY); - DockPane(&m_wndOutput); - - OnChangeRibbonCategory (0, 0); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWndEx::PreCreateWindow(cs) ) - return FALSE; - - cs.style &= ~FWS_ADDTOTITLE; - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - - -void CMainFrame::OnAppLook(UINT id) -{ - CDockingManager::SetDockingMode (DT_SMART); - - m_nAppLook = id; - - CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2007: - case ID_VIEW_APPLOOK_2007_1: - case ID_VIEW_APPLOOK_2007_2: - case ID_VIEW_APPLOOK_2007_3: - // enable Office 2007 look: - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2007: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case ID_VIEW_APPLOOK_2007_1: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case ID_VIEW_APPLOOK_2007_2: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - break; - - case ID_VIEW_APPLOOK_2007_3: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - } - - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - default: - ASSERT (FALSE); - } - - CDockingManager* pDockManager = GetDockingManager (); - if (pDockManager != NULL) - { - ASSERT_VALID (pDockManager); - pDockManager->AdjustPaneFrames (); - } - - CTabbedPane::ResetTabs (); - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - theApp.WriteInt (_T("ApplicationLook"), m_nAppLook); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); -} - -BOOL CMainFrame::CreateRibbonBar () -{ - if (!m_wndRibbonBar.Create(this)) - { - return FALSE; - } - - // Load panel images: - m_PanelImages.SetImageSize (CSize (16, 16)); - m_PanelImages.Load (IDB_RIBBON_ICONS); - - // Add main panel: - Add_MainPanel (); - - Add_Category1 (); - Add_Category2 (); - Add_Category3 (); - Add_Category4 (); - Add_Category5 (); - Add_Category6 (); - - // Add quick access toolbar commands: - Add_QAT (); - - // Add "Style" button to the right of tabs: - CMFCRibbonButton* pStyleButton = new CMFCRibbonButton ((UINT)-1, _T("Style\ns"), -1, -1); - pStyleButton->SetMenu (IDR_THEME_MENU, TRUE /* Right align */); - m_wndRibbonBar.AddToTabs (pStyleButton); - - // Add "About" button to the right of tabs: - m_wndRibbonBar.AddToTabs (new CMFCRibbonButton (ID_APP_ABOUT, _T("About\na"), m_PanelImages.ExtractIcon (0))); - - return TRUE; -} - -void CMainFrame::Add_MainPanel () -{ - m_MainButton.SetImage (IDB_RIBBON_MAIN); - m_MainButton.SetToolTipText (_T("File")); - m_MainButton.SetText (_T("\nf")); - - m_wndRibbonBar.SetApplicationButton (&m_MainButton, CSize (45, 45)); - - CMFCRibbonMainPanel* pMainPanel = m_wndRibbonBar.AddMainCategory (_T("File"), IDB_RIBBON_FILE_SMALL, IDB_RIBBON_FILE_LARGE); - - pMainPanel->Add (new CMFCRibbonButton (ID_FILE_NEW, _T("&New"), 0, 0)); - pMainPanel->Add (new CMFCRibbonButton (ID_FILE_OPEN, _T("&Open..."), 1, 1)); - - pMainPanel->Add (new CMFCRibbonButton (ID_FILE_SAVE, _T("&Save"), 2, 2)); - - pMainPanel->Add (new CMFCRibbonButton (ID_FILE_SAVE_AS, _T("Save &As..."), 3, 3)); - - CMFCRibbonButton* pBtnPrint = new CMFCRibbonButton (ID_FILE_PRINT, _T("&Print"), 4, 4); - - pBtnPrint->AddSubItem (new CMFCRibbonLabel (_T("Preview and print the document"))); - pBtnPrint->AddSubItem (new CMFCRibbonButton (ID_FILE_PRINT, _T("&Print"), 4, 4, TRUE)); - pBtnPrint->AddSubItem (new CMFCRibbonButton (ID_FILE_PRINT_DIRECT, _T("&Quick Print"), 6, 6, TRUE)); - pBtnPrint->AddSubItem (new CMFCRibbonButton (ID_FILE_PRINT_PREVIEW, _T("Print Pre&view"), 7, 7, TRUE)); - - pBtnPrint->SetKeys (_T("p"), _T("w")); - - pMainPanel->Add (pBtnPrint); - - pMainPanel->AddRecentFilesList (_T("Recent Documents")); - - pMainPanel->AddToBottom (new CMFCRibbonMainPanelButton (ID_TOOLS_OPTIONS, _T("Opt&ions"), 8)); - pMainPanel->AddToBottom (new CMFCRibbonMainPanelButton (ID_APP_EXIT, _T("E&xit"), 9)); -} - -void CMainFrame::Add_QAT () -{ - CMFCRibbonQuickAccessToolBarDefaultState qatState; - qatState.AddCommand (ID_FILE_NEW); - qatState.AddCommand (ID_FILE_OPEN, FALSE); - qatState.AddCommand (ID_FILE_SAVE, FALSE); - qatState.AddCommand (ID_FILE_SAVE_AS); - qatState.AddCommand (ID_FILE_PRINT_DIRECT); - qatState.AddCommand (ID_FILE_PRINT_PREVIEW, FALSE); - m_wndRibbonBar.SetQuickAccessDefaultState (qatState); -} - -void CMainFrame::Add_Category1() -{ - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Buttons"), IDB_RIBBON_CATEGORY1_SMALL, IDB_RIBBON_CATEGORY1_LARGE); - - CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Large Buttons")); - - CMFCRibbonButton* pBtn1 = new CMFCRibbonButton(ID_RIBBON_BTN_1, _T("Button"), 0, 0); - pBtn1->SetAlwaysLargeImage(); - pPanel1->Add(pBtn1); - - CMFCRibbonButton* pBtn2 = new CMFCRibbonButton(ID_RIBBON_BTN_2, _T("Menu Button"), 1, 1); - pBtn2->SetMenu(IDR_RIBBON_MENU_1); - pBtn2->SetAlwaysLargeImage(); - pPanel1->Add(pBtn2); - - CMFCRibbonButton* pBtn3 = new CMFCRibbonButton(ID_RIBBON_BTN_3, _T("Split Button"), 2, 2); - pBtn3->SetMenu(IDR_RIBBON_MENU_1, TRUE); - pBtn3->SetAlwaysLargeImage(); - pBtn3->RemoveSubItem(0); - pBtn3->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MBTN_1, _T("Item 1"), 2), 0); - pPanel1->Add(pBtn3); - - CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Small")); - - CMFCRibbonButton* pBtn4 = new CMFCRibbonButton(ID_RIBBON_BTN_4, _T("Button"), 3); - pPanel2->Add(pBtn4); - - CMFCRibbonButton* pBtn5 = new CMFCRibbonButton(ID_RIBBON_BTN_5, _T("Menu Button"), 4); - pBtn5->SetMenu(IDR_RIBBON_MENU_1); - pPanel2->Add(pBtn5); - - CMFCRibbonButton* pBtn6 = new CMFCRibbonButton(ID_RIBBON_BTN_6, _T("Split Button"), 5); - pBtn6->SetMenu(IDR_RIBBON_MENU_1, TRUE); - pBtn6->SetAlwaysLargeImage(); - pBtn6->RemoveSubItem(1); - pBtn6->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MBTN_2, _T("Item 2"), 5), 1); - pPanel2->Add(pBtn6); - - CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Check Boxes")); - - pPanel3->Add(new CMFCRibbonCheckBox(ID_RIBBON_BTN_7, _T("Check Box 1"))); - pPanel3->Add(new CMFCRibbonCheckBox(ID_RIBBON_BTN_8, _T("Check Box 2"))); - pPanel3->Add(new CMFCRibbonCheckBox(ID_RIBBON_BTN_9, _T("Check Box 3"))); - - pPanel1->SetData(ID_RIBBON_SOURCE_CODE_1_1); - pPanel2->SetData(ID_RIBBON_SOURCE_CODE_1_2); - pPanel3->SetData(ID_RIBBON_SOURCE_CODE_1_3); -} - -void CMainFrame::Add_Category2() -{ - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Palette Buttons"), IDB_RIBBON_CATEGORY2_SMALL, IDB_RIBBON_CATEGORY2_LARGE); - - CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Standard")); - - pPanel1->Add(new CMFCRibbonGallery(ID_RIBBON_PBTN_1, _T("Embedded"), 0, 0, IDB_RIBBON_PALETTE_1, 64)); - - CMFCRibbonGallery* pBtn2 = new CMFCRibbonGallery(ID_RIBBON_PBTN_2, _T("Button"), 1, 1, IDB_RIBBON_PALETTE_1, 64); - pBtn2->SetButtonMode(); - pBtn2->SetAlwaysLargeImage(); - pPanel1->Add(pBtn2); - - CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Extended")); - - CMFCRibbonGallery* pBtn3 = new CMFCRibbonGallery(ID_RIBBON_PBTN_3, _T("Resize Vertical"), 2, 2, IDB_RIBBON_PALETTE_1, 64); - pBtn3->SetButtonMode(); - pBtn3->SetIconsInRow(2); - pBtn3->EnableMenuResize(TRUE, TRUE); - pPanel2->Add(pBtn3); - - CMFCRibbonGallery* pBtn4 = new CMFCRibbonGallery(ID_RIBBON_PBTN_4, _T("Resize Both"), 3, 3, IDB_RIBBON_PALETTE_1, 64); - pBtn4->SetButtonMode(); - pBtn4->SetIconsInRow(4); - pBtn4->EnableMenuResize(TRUE); - pPanel2->Add(pBtn4); - - CMFCRibbonGallery* pBtn5 = new CMFCRibbonGallery(ID_RIBBON_PBTN_5, _T("Groups && Subitems"), 4, 4); - pBtn5->AddGroup(_T("Group 1"), IDB_RIBBON_PALETTE_1, 64); - pBtn5->AddGroup(_T("Group 2"), IDB_RIBBON_PALETTE_2, 64); - pBtn5->SetButtonMode(); - pBtn5->SetIconsInRow(4); - pBtn5->EnableMenuResize(TRUE); - pBtn5->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MENU_ITEM_1, _T("Item 1"))); - pBtn5->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MENU_ITEM_2, _T("Item 2"))); - pBtn5->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MENU_ITEM_3, _T("Item 3"))); - pPanel2->Add(pBtn5); - - pPanel1->SetData(ID_RIBBON_SOURCE_CODE_2_1); - pPanel2->SetData(ID_RIBBON_SOURCE_CODE_2_2); -} - -void CMainFrame::Add_Category3() -{ - CreateDocumentColors(); - - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Color Buttons"), IDB_RIBBON_CATEGORY3_SMALL, IDB_RIBBON_CATEGORY3_LARGE); - - CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Large")); - - CMFCRibbonColorButton* pBtn1 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_1, _T("Simple"), TRUE, 0, 0); - pBtn1->SetAlwaysLargeImage(); - pBtn1->SetDefaultCommand(FALSE); - pPanel1->Add(pBtn1); - - CMFCRibbonColorButton* pBtn2 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_2, _T("Simple with Options"), TRUE, 1, 1); - pBtn2->SetAlwaysLargeImage(); - pBtn2->SetDefaultCommand(FALSE); - pBtn2->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); - pBtn2->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); - pPanel1->Add(pBtn2); - - CMFCRibbonColorButton* pBtn3 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_3, _T("Custom"), TRUE, 2, 2); - pBtn3->SetAlwaysLargeImage(); - pBtn3->SetDefaultCommand(FALSE); - pBtn3->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); - pBtn3->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); - pBtn3->SetColumns(10); - pBtn3->SetColorBoxSize(CSize(17, 17)); - pBtn3->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); - pBtn3->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); - pBtn3->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); - pPanel1->Add(pBtn3); - - CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Small")); - - CMFCRibbonColorButton* pBtn4 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_4, _T("Simple"), TRUE, 3, -1); - pBtn4->SetDefaultCommand(FALSE); - pPanel2->Add(pBtn4); - - CMFCRibbonColorButton* pBtn5 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_5, _T("Simple with Options"), TRUE, 4, -1); - pBtn5->SetDefaultCommand(FALSE); - pBtn5->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); - pBtn5->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); - pPanel2->Add(pBtn5); - - CMFCRibbonColorButton* pBtn6 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_6, _T("Custom"), TRUE, 5, -1); - pBtn6->SetDefaultCommand(FALSE); - pBtn6->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); - pBtn6->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); - pBtn6->SetColumns(10); - pBtn6->SetColorBoxSize(CSize(17, 17)); - pBtn6->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); - pBtn6->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); - pBtn6->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); - pPanel2->Add(pBtn6); - - CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Small with Indicator")); - - CMFCRibbonColorButton* pBtn7 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_7, _T("Simple"), 6); - pBtn7->SetColor(RGB(255, 0, 0)); - pPanel3->Add(pBtn7); - - CMFCRibbonColorButton* pBtn8 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_8, _T("Simple with Options"), 7); - pBtn8->SetColor(RGB(0, 0, 255)); - pBtn8->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); - pBtn8->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); - pPanel3->Add(pBtn8); - - CMFCRibbonColorButton* pBtn9 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_9, _T("Custom"), 8); - pBtn9->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); - pBtn9->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); - pBtn9->SetColumns(10); - pBtn9->SetColorBoxSize(CSize(17, 17)); - pBtn9->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); - pBtn9->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); - pBtn9->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); - pPanel3->Add(pBtn9); - - CMFCRibbonPanel* pPanel4 = pCategory->AddPanel(_T("Embedded")); - - CMFCRibbonColorButton* pBtn10 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_10, _T("Embedded"), TRUE, 1, 1); - pBtn10->EnableOtherButton(_T("&More Colors..."), _T("More Shading Colors")); - pBtn10->SetColor(RGB(240, 240, 240)); - pBtn10->SetColumns(10); - pBtn10->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); - pBtn10->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); - pBtn10->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); - pBtn10->SetColorBoxSize(CSize(17, 17)); - pBtn10->SetButtonMode(FALSE); - pBtn10->EnableAutomaticButton(_T("&No Color"), (COLORREF)-1, TRUE, NULL, FALSE /* Bottom */); - pPanel4->Add(pBtn10); - - pPanel1->SetData(ID_RIBBON_SOURCE_CODE_3_1); - pPanel2->SetData(ID_RIBBON_SOURCE_CODE_3_2); - pPanel3->SetData(ID_RIBBON_SOURCE_CODE_3_3); - pPanel4->SetData(ID_RIBBON_SOURCE_CODE_3_4); -} - -void CMainFrame::Add_Category4() -{ - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Groups"), IDB_RIBBON_CATEGORY4_SMALL, 0); - - CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("From Toolbar")); - - pPanel1->AddToolBar(IDR_TOOLBAR); - - CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Manual")); - - CMFCRibbonButtonsGroup* pButtonsGroup1 = new CMFCRibbonButtonsGroup; - - pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_1, _T(""), 0)); - pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_2, _T(""), 1)); - - CMFCRibbonEdit* pEdit = new CMFCRibbonEdit(ID_RIBBON_GBTN_3, 65); - pEdit->SetEditText(_T("Edit")); - pButtonsGroup1->AddButton(pEdit); - - pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_4, _T(""), 2)); - pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_5, _T(""), 3)); - - pPanel2->Add(pButtonsGroup1); - - CMFCRibbonButtonsGroup* pButtonsGroup2 = new CMFCRibbonButtonsGroup; - pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_6, _T(""), 4)); - pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_7, _T(""), 5)); - pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_8, _T(""), 6)); - pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_9, _T(""), 7)); - - pPanel2->Add(pButtonsGroup2); - - CMFCRibbonButtonsGroup* pButtonsGroup3 = new CMFCRibbonButtonsGroup; - - CMFCRibbonButton* pBtn10 = new CMFCRibbonButton(ID_RIBBON_GBTN_10, _T(""), 8); - pBtn10->SetMenu(IDR_RIBBON_MENU_1); - pButtonsGroup3->AddButton(pBtn10); - - CMFCRibbonButton* pBtn11 = new CMFCRibbonButton(ID_RIBBON_GBTN_11, _T(""), 9); - pBtn11->SetMenu(IDR_RIBBON_MENU_1, TRUE); - pButtonsGroup3->AddButton(pBtn11); - - pPanel2->Add(pButtonsGroup3); - - pPanel1->SetData(ID_RIBBON_SOURCE_CODE_4_1); - pPanel2->SetData(ID_RIBBON_SOURCE_CODE_4_2); -} - -void CMainFrame::Add_Category5() -{ - int i = 0; - - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Edit and Combo"), IDB_RIBBON_CATEGORY5_SMALL, 0); - - CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Standard")); - - CMFCRibbonEdit* pBtn1 = new CMFCRibbonEdit(ID_RIBBON_EBTN_1, 90); - pBtn1->SetEditText(_T("Edit")); - pPanel1->Add(pBtn1); - - CMFCRibbonEdit* pBtn2 = new CMFCRibbonEdit(ID_RIBBON_EBTN_2, 90); - pBtn2->EnableSpinButtons(0, 99); - pBtn2->SetEditText(_T("0")); - pPanel1->Add(pBtn2); - - CMFCRibbonComboBox* pBtn3 = new CMFCRibbonComboBox(ID_RIBBON_EBTN_3, TRUE, 74); - pBtn3->AddItem(_T("Combo Box")); - for (i = 0; i < 20; i++) - { - CString str; - str.Format(_T("Item %d"), i + 1); - pBtn3->AddItem(str); - } - pBtn3->SelectItem(0); - pPanel1->Add(pBtn3); - - CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("With Icons and Labels")); - - CMFCRibbonEdit* pBtn4 = new CMFCRibbonEdit(ID_RIBBON_EBTN_4, 90, _T("Label:"), 0); - pBtn4->SetEditText(_T("Edit")); - pPanel2->Add(pBtn4); - - CMFCRibbonEdit* pBtn5 = new CMFCRibbonEdit(ID_RIBBON_EBTN_5, 90, _T("Label:"), 1); - pBtn5->EnableSpinButtons(0, 99); - pBtn5->SetEditText(_T("0")); - pPanel2->Add(pBtn5); - - CMFCRibbonComboBox* pBtn6 = new CMFCRibbonComboBox(ID_RIBBON_EBTN_6, TRUE, 74, _T("Label:"), 2); - pBtn6->AddItem(_T("Combo Box")); - for (i = 0; i < 20; i++) - { - CString str; - str.Format(_T("Item %d"), i + 1); - pBtn6->AddItem(str); - } - pBtn6->SelectItem(0); - pPanel2->Add(pBtn6); - - CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Font")); - - CMFCRibbonFontComboBox::m_bDrawUsingFont = TRUE; - CMFCRibbonFontComboBox* pBtn7 = new CMFCRibbonFontComboBox(ID_RIBBON_EBTN_7); - pBtn7->SelectItem(_T("Arial")); - pPanel3->Add(pBtn7); - - pPanel1->SetData(ID_RIBBON_SOURCE_CODE_5_1); - pPanel2->SetData(ID_RIBBON_SOURCE_CODE_5_2); - pPanel3->SetData(ID_RIBBON_SOURCE_CODE_5_3); -} - -void CMainFrame::Add_Category6() -{ - CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Other"), IDB_RIBBON_CATEGORY6_SMALL, IDB_RIBBON_CATEGORY6_LARGE); - - CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Undo")); - - // - // The third parameter is the zero-based index in the image list of the parent - // object for the button's small image. - // The fourth parameter is the zero-based index in the image list of the parent object - // for the of button's large image. - CMFCRibbonUndoButton* pBtn1 = new CMFCRibbonUndoButton(ID_RIBBON_OBTN_1, _T("Undo"), 0, 0); - for (int i = 0; i < 20; i++) - { - CString str; - str.Format(_T("Action %d"), i + 1); - pBtn1->AddUndoAction(str); - } - // - pPanel1->Add(pBtn1); - - CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Label")); - - pPanel2->Add(new CMFCRibbonLabel(_T("Label 1"))); - pPanel2->Add(new CMFCRibbonLabel(_T("Label 2"))); - pPanel2->Add(new CMFCRibbonLabel(_T("Label 3"))); - - pPanel2->Add(new CMFCRibbonSeparator()); - - pPanel2->Add(new CMFCRibbonLabel(_T("This is a multi-line label"), TRUE)); - - CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Hyperlink")); - - // - // CMFCRibbonPanel* pPanel3 - pPanel3->Add(new CMFCRibbonLinkCtrl(ID_RIBBON_OBTN_2, _T("Send email"), _T("mailto:info@microsoft.com"))); - // - pPanel3->Add(new CMFCRibbonLinkCtrl(ID_RIBBON_OBTN_3, _T("Visit site"), _T("http://www.microsoft.com"))); - pPanel3->Add(new CMFCRibbonLinkCtrl(ID_RIBBON_OBTN_4, _T("Launch Notepad"), _T("notepad"))); - - CMFCRibbonPanel* pPanel4 = pCategory->AddPanel(_T("Sliders")); - pPanel4->SetCenterColumnVert(); - - pPanel4->Add(new CMFCRibbonLabel(_T("Simple Slider:"))); - pPanel4->Add(new CMFCRibbonSlider(ID_RIBBON_OBTN_5, 70 /* Slider width */)); - - pPanel4->Add(new CMFCRibbonSeparator()); - - pPanel4->Add(new CMFCRibbonLabel(_T("Slider with Buttons:"))); - CMFCRibbonSlider* pBtn6 = new CMFCRibbonSlider(ID_RIBBON_OBTN_6, 70 /* Slider width */); - pBtn6->SetZoomButtons(); - pBtn6->SetRange(0, 100); - pBtn6->SetPos(50); - pPanel4->Add(pBtn6); - - CMFCRibbonPanel* pPanel5 = pCategory->AddPanel(_T("Progress Bars")); - pPanel5->SetCenterColumnVert(); - - pPanel5->Add(new CMFCRibbonLabel(_T("Simple Progress:"))); - pPanel5->Add(new CMFCRibbonProgressBar(ID_RIBBON_OBTN_7, 100 /* Bar width */)); - pPanel5->Add(new CMFCRibbonButton(ID_RIBBON_OBTN_8, _T("Show Progress 1"))); - - pPanel5->Add(new CMFCRibbonSeparator()); - - pPanel5->Add(new CMFCRibbonLabel(_T("Infinite Progress:"))); - CMFCRibbonProgressBar* pBtn9 = new CMFCRibbonProgressBar(ID_RIBBON_OBTN_9, 100 /* Bar width */); - pBtn9->SetInfiniteMode(); - pPanel5->Add(pBtn9); - - pPanel5->Add(new CMFCRibbonButton(ID_RIBBON_OBTN_10, _T("Show Progress 2"))); - - pPanel1->SetData(ID_RIBBON_SOURCE_CODE_6_1); - pPanel2->SetData(ID_RIBBON_SOURCE_CODE_6_2); - pPanel3->SetData(ID_RIBBON_SOURCE_CODE_6_3); - pPanel4->SetData(ID_RIBBON_SOURCE_CODE_6_4); - pPanel5->SetData(ID_RIBBON_SOURCE_CODE_6_5); -} - -LRESULT CMainFrame::OnRibbonCustomize (WPARAM /*wp*/, LPARAM /*lp*/) -{ - ShowOptions (0); - return 1; -} - -void CMainFrame::OnToolsOptions() -{ - ShowOptions (0); -} - -void CMainFrame::ShowOptions (int nPage) -{ - // Create "Customize" page: - CMFCRibbonCustomizePropertyPage pageCustomize (&m_wndRibbonBar); - - // Add "popular" items: - CList lstPopular; - - lstPopular.AddTail (ID_FILE_NEW); - lstPopular.AddTail (ID_FILE_OPEN); - lstPopular.AddTail (ID_FILE_SAVE); - lstPopular.AddTail (ID_FILE_PRINT_PREVIEW); - lstPopular.AddTail (ID_FILE_PRINT_DIRECT); - lstPopular.AddTail (ID_EDIT_UNDO); - - pageCustomize.AddCustomCategory (_T("Popular Commands"), lstPopular); - - // Add hidden commands: - CList lstHidden; - m_wndRibbonBar.GetItemIDsList (lstHidden, TRUE); - - pageCustomize.AddCustomCategory (_T("Commands not in the Ribbon"), lstHidden); - - // Add all commands: - CList lstAll; - m_wndRibbonBar.GetItemIDsList (lstAll); - - pageCustomize.AddCustomCategory (_T("All Commands"), lstAll); - - // Create property sheet: - CMFCPropertySheet propSheet (_T("Options"), this, nPage); - propSheet.m_psh.dwFlags |= PSH_NOAPPLYNOW; - - propSheet.SetLook (CMFCPropertySheet::PropSheetLook_List, 124 /* List width */); - - propSheet.AddPage (&pageCustomize); - - // TODO: add your option pages here: - // COptionsPage1 pageOptions1; - // propSheet.AddPage (&pageOptions1); - // - // COptionsPage1 pageOptions2; - // propSheet.AddPage (&pageOptions2); - - if (propSheet.DoModal() != IDOK) - { - return; - } -} - -void CMainFrame::OnDummy(UINT /*id*/) -{ -} - -void CMainFrame::OnRibbonBtn7() -{ - m_bCheckBox1 = !m_bCheckBox1; -} - -void CMainFrame::OnUpdateRibbonBtn7(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_bCheckBox1); -} - -void CMainFrame::OnRibbonBtn8() -{ - m_bCheckBox2 = !m_bCheckBox2; -} - -void CMainFrame::OnUpdateRibbonBtn8(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_bCheckBox2); -} - -void CMainFrame::OnRibbonBtn9() -{ - m_bCheckBox3 = !m_bCheckBox3; -} - -void CMainFrame::OnUpdateRibbonBtn9(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_bCheckBox3); -} - -void CMainFrame::OnLink (UINT nID) -{ - CArray ar; - m_wndRibbonBar.GetElementsByID (nID, ar); - - if (ar.GetSize () >= 1) - { - CMFCRibbonLinkCtrl* pLink = DYNAMIC_DOWNCAST (CMFCRibbonLinkCtrl, ar[0]); - if (pLink != NULL) - { - if (!pLink->OpenLink ()) - { - AfxMessageBox (_T("Link clicked.")); - } - } - } -} - -int CMainFrame::GetSliderPos (UINT nID) -{ - CArray ar; - CArray ar2; - m_wndRibbonBar.GetElementsByID (ID_RIBBON_OBTN_5, ar); - m_wndRibbonBar.GetElementsByID (ID_RIBBON_OBTN_6, ar2); - - ar.Append (ar2); - - int nPos1 = -1; - int nPos2 = -1; - - for (int k = 0; k < 2; k++) - { - for (int i = 0; i < ar.GetSize (); i++) - { - CMFCRibbonSlider* pSlider = DYNAMIC_DOWNCAST (CMFCRibbonSlider, ar[i]); - if (pSlider != NULL) - { - if (k == 0) - { - if (pSlider->GetID () != nID) - { - nPos2 = pSlider->GetPos (); - nPos1 = nPos2; - break; - } - } - else - { - if (pSlider->GetID () == nID) - { - if (pSlider->GetPos () != nPos2) - { - nPos1 = pSlider->GetPos (); - } - } - } - } - } - } - - return nPos1; -} - -void CMainFrame::SetSliderPos (int nPos, UINT nID) -{ - CArray ar; - m_wndRibbonBar.GetElementsByID (nID, ar); - - for (int i = 0; i < ar.GetSize (); i++) - { - CMFCRibbonSlider* pSlider = DYNAMIC_DOWNCAST (CMFCRibbonSlider, ar[i]); - if (pSlider != NULL) - { - if (pSlider->GetPos () != nPos) - { - pSlider->SetPos (nPos); - } - } - } -} - -void CMainFrame::SetProgressPos (int nPos, UINT nID) -{ - CArray ar; - m_wndRibbonBar.GetElementsByID (nID, ar); - - for (int i = 0; i < ar.GetSize (); i++) - { - CMFCRibbonProgressBar* pProgress = DYNAMIC_DOWNCAST (CMFCRibbonProgressBar, ar[i]); - if (pProgress != NULL) - { - if (pProgress->GetPos () != nPos) - { - pProgress->SetPos (nPos); - } - } - } -} - -void CMainFrame::OnRibbonObtn2() -{ - OnLink (ID_RIBBON_OBTN_2); -} - -void CMainFrame::OnRibbonObtn3() -{ - OnLink (ID_RIBBON_OBTN_3); -} - -void CMainFrame::OnRibbonObtn4() -{ - OnLink (ID_RIBBON_OBTN_4); -} - -void CMainFrame::OnRibbonObtn8() -{ - m_nProgressValue1 = 0; - SetTimer (IdShowProgress1Timer, 10, NULL); -} - -void CMainFrame::OnUpdateRibbonObtn8(CCmdUI* pCmdUI) -{ - pCmdUI->Enable (m_nProgressValue1 == -1); -} - -void CMainFrame::OnRibbonObtn10() -{ - m_nProgressValue2 = 0; - SetTimer (IdShowProgress2Timer, 10, NULL); -} - -void CMainFrame::OnUpdateRibbonObtn10(CCmdUI* pCmdUI) -{ - pCmdUI->Enable (m_nProgressValue2 == -1); -} - -void CMainFrame::OnTimer(UINT_PTR nIDEvent) -{ - if (nIDEvent == IdShowProgress1Timer) - { - m_nProgressValue1++; - - if (m_nProgressValue1 > 100) - { - m_nProgressValue1 = -1; - KillTimer (nIDEvent); - SetProgressPos (0, ID_RIBBON_OBTN_7); - } - else - { - SetProgressPos (m_nProgressValue1, ID_RIBBON_OBTN_7); - } - - CMFCPopupMenu::UpdateAllShadows (); - } - else if (nIDEvent == IdShowProgress2Timer) - { - m_nProgressValue2++; - - if (m_nProgressValue2 > 100) - { - m_nProgressValue2 = -1; - KillTimer (nIDEvent); - SetProgressPos (0, ID_RIBBON_OBTN_9); - } - else - { - SetProgressPos (m_nProgressValue2, ID_RIBBON_OBTN_9); - } - - CMFCPopupMenu::UpdateAllShadows (); - } -} - -LRESULT CMainFrame::OnChangeRibbonCategory(WPARAM,LPARAM) -{ - if (!m_wndOutput.IsAutoHideMode ()) - { - m_wndOutput.SetRedraw (FALSE); - } - - m_wndOutput.ClearTabs (); - - CMFCRibbonCategory* pCategory = m_wndRibbonBar.GetActiveCategory (); - if (pCategory != NULL) - { - ASSERT_VALID (pCategory); - - for (int i = 0; i < pCategory->GetPanelCount (); i++) - { - CMFCRibbonPanel* pPanel = pCategory->GetPanel (i); - ASSERT_VALID (pPanel); - - m_wndOutput.AddTab (pPanel->GetName (), (UINT)pPanel->GetData ()); - } - } - - if (!m_wndOutput.IsAutoHideMode ()) - { - m_wndOutput.SetRedraw (); - m_wndOutput.RedrawWindow (NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); - } - - return 0; -} - -void CMainFrame::OnFilePrint () -{ - if (IsPrintPreview ()) - { - PostMessage (WM_COMMAND, AFX_ID_PREVIEW_PRINT); - } -} - -void CMainFrame::OnFilePrintPreview() -{ - if (IsPrintPreview ()) - { - PostMessage (WM_COMMAND, AFX_ID_PREVIEW_CLOSE); // Force Print Preview Close - } -} - -void CMainFrame::OnUpdateFilePrintPreview(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (IsPrintPreview ()); -} - -void CMainFrame::OnSysColorChange() -{ - BOOL bWasWindowRgn = m_Impl.HasRegion (); - - CFrameWndEx::OnSysColorChange(); - - m_Impl.OnChangeVisualManager (); - - if (bWasWindowRgn && ! m_Impl.HasRegion ()) - { - SetWindowRgn (NULL, TRUE); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/MainFrm.h deleted file mode 100644 index d37d078937428..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/MainFrm.h +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once - -#include "OutputBar.h" - -class CMainFrame : public CFrameWndEx -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - void CreateDocumentColors (); - - void Add_MainPanel (); - void Add_QAT (); - void Add_Category1 (); - void Add_Category2 (); - void Add_Category3 (); - void Add_Category4 (); - void Add_Category5 (); - void Add_Category6 (); - - void OnLink (UINT nID); - - int GetSliderPos (UINT nID); - void SetSliderPos (int nPos, UINT nID); - void SetProgressPos (int nPos, UINT nID); - -protected: // control bar embedded members - CMFCRibbonBar m_wndRibbonBar; - CMFCRibbonApplicationButton m_MainButton; - CMFCToolBarImages m_PanelImages; - CMFCRibbonStatusBar m_wndStatusBar; - COutputBar m_wndOutput; - - // Document colors for demo: - CList m_lstMainColors; - CList m_lstAdditionalColors; - CList m_lstStandardColors; - - BOOL m_bCheckBox1; - BOOL m_bCheckBox2; - BOOL m_bCheckBox3; - - int m_nProgressValue1; - int m_nProgressValue2; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnRibbonBtn7(); - afx_msg void OnUpdateRibbonBtn7(CCmdUI* pCmdUI); - afx_msg void OnRibbonBtn8(); - afx_msg void OnUpdateRibbonBtn8(CCmdUI* pCmdUI); - afx_msg void OnRibbonBtn9(); - afx_msg void OnUpdateRibbonBtn9(CCmdUI* pCmdUI); - afx_msg void OnRibbonObtn2(); - afx_msg void OnRibbonObtn3(); - afx_msg void OnRibbonObtn4(); - afx_msg void OnRibbonObtn8(); - afx_msg void OnUpdateRibbonObtn8(CCmdUI* pCmdUI); - afx_msg void OnRibbonObtn10(); - afx_msg void OnUpdateRibbonObtn10(CCmdUI* pCmdUI); - afx_msg void OnTimer(UINT_PTR nIDEvent); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - afx_msg LRESULT OnRibbonCustomize (WPARAM wp, LPARAM lp); - afx_msg LRESULT OnChangeRibbonCategory(WPARAM,LPARAM); - afx_msg void OnToolsOptions(); - afx_msg void OnDummy(UINT id); - afx_msg void OnFilePrint(); - afx_msg void OnFilePrintPreview(); - afx_msg void OnUpdateFilePrintPreview(CCmdUI* pCmdUI); - afx_msg void OnSysColorChange(); - - DECLARE_MESSAGE_MAP() - - BOOL CreateRibbonBar (); - void ShowOptions (int nPage); - - UINT m_nAppLook; -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/OutputBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/OutputBar.cpp deleted file mode 100644 index 570c27bcf366b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/OutputBar.cpp +++ /dev/null @@ -1,377 +0,0 @@ -#include "stdafx.h" -#include "ribbongadgets.h" -#include "OutputBar.h" - -#include "../src/mfc/AfxImpl.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutputBar - -COutputBar::COutputBar() -{ -} - -COutputBar::~COutputBar() -{ -} - - -BEGIN_MESSAGE_MAP(COutputBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_DESTROY() - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs) - ON_COMMAND(ID_FILE_PRINT, OnFilePrint) -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// COutputBar message handlers - -int COutputBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - // Create tabs window: - if (!m_wndTabs.Create (CMFCTabCtrl::STYLE_FLAT, CRect (0, 0, 0, 0), this, 1)) - { - TRACE0("Failed to create output tab window\n"); - return -1; // fail to create - } - - // Create toolbar: - m_wndTabs.SetFlatFrame (FALSE, FALSE); - m_wndTabs.AutoDestroyWindow (FALSE); - - m_wndToolBar.Create (this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_CODE); - m_wndToolBar.LoadToolBar (IDR_CODE, 0, 0, TRUE /* Is locked */); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY); - - m_wndToolBar.SetPaneStyle ( - m_wndToolBar.GetPaneStyle () & - ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - m_wndToolBar.SetOwner (this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame (FALSE); - - m_Font.CreateFont - ( - -12, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - DEFAULT_PITCH, _T("Courier") - ); - - return 0; -} - -void COutputBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - CRect rectClient,rectCombo; - GetClientRect (rectClient); - - int cyTlb = m_wndToolBar.CalcFixedLayout (FALSE, TRUE).cy; - - m_wndToolBar.SetWindowPos (NULL, - rectClient.left, - rectClient.top, - rectClient.Width (), - cyTlb, - SWP_NOACTIVATE | SWP_NOZORDER); - - m_wndTabs.SetWindowPos (NULL, rectClient.left, rectClient.top + cyTlb, - rectClient.Width (), rectClient.Height () - cyTlb, - SWP_NOACTIVATE | SWP_NOZORDER); -} - -void COutputBar::ClearTabs () -{ - for (int i = 0; i < m_wndTabs.GetTabsNum (); i++) - { - CWnd* pWnd = m_wndTabs.GetTabWnd (i); - pWnd->DestroyWindow (); - delete pWnd; - } - - m_wndTabs.RemoveAllTabs (); -} - -void COutputBar::AddTab (LPCTSTR lpszName, UINT nID) -{ - CEdit* pWndEdit = new CEdit (); - - pWndEdit->Create (WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | - ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, - CRect (0, 0, 0, 0), &m_wndTabs, 1); - pWndEdit->SetReadOnly (); - pWndEdit->SetFont (m_Font.GetSafeHandle () == NULL ? &afxGlobalData.fontRegular : &m_Font); - - if (nID != 0) - { - LPCTSTR lpszResourceName = MAKEINTRESOURCE (nID); - ASSERT(lpszResourceName != NULL); - - HINSTANCE hInst = AfxFindResourceHandle (lpszResourceName, _T("CODE")); - HRSRC hRsrc = ::FindResource (hInst, lpszResourceName, _T("CODE")); - - if (hRsrc == NULL) - { - ASSERT(FALSE); - } - else - { - DWORD dwSize = SizeofResource (hInst, hRsrc); - HGLOBAL hGlobal = NULL; - if (dwSize != NULL) - { - hGlobal = LoadResource (hInst, hRsrc); - } - - if (hGlobal == NULL) - { - ASSERT(FALSE); - } - else - { - TCHAR* lpszText = new TCHAR[dwSize + 1]; - LPCSTR lpszResourceText = (LPCSTR)LockResource(hGlobal); -#ifdef UNICODE - MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, lpszResourceText, dwSize, lpszText, dwSize); -#else - memcpy (lpszText, lpszResourceText, dwSize); -#endif - lpszText[dwSize] = 0; - - if (lpszText == NULL) - { - ASSERT(FALSE); - } - else - { - pWndEdit->SetWindowText(lpszText); - delete lpszText; - } - - UnlockResource(hGlobal); - FreeResource(hGlobal); - } - } - } - - m_wndTabs.AddTab (pWndEdit, lpszName, (UINT)-1, FALSE); -} - -void COutputBar::OnDestroy() -{ - ClearTabs (); - CDockablePane::OnDestroy(); -} - -void COutputBar::OnEditCopy() -{ - CEdit* pWndEdit = (CEdit*) m_wndTabs.GetActiveWnd (); - ASSERT_VALID (pWndEdit); - - pWndEdit->Copy (); -} - -void ErrorReport (LPCTSTR lpszPathName, CException* e) -{ - UINT nIDP = 0; - UINT nHelpContext = 0; - CString prompt; - - if (e->IsKindOf(RUNTIME_CLASS(CFileException))) - { - TRACE(traceAppMsg, 0, "Reporting file I/O exception on save with lOsError = $%lX.\n", - ((CFileException*)e)->m_lOsError); - - CFileException* pFileException = (CFileException*)e; - if (pFileException->m_strFileName.IsEmpty()) - { - pFileException->m_strFileName = lpszPathName; - } - - LPTSTR lpszMessage = prompt.GetBuffer(255); - ASSERT(lpszMessage != NULL); - if (!e->GetErrorMessage(lpszMessage, 256, &nHelpContext)) - { - switch (((CFileException*)e)->m_cause) - { - case CFileException::fileNotFound: - case CFileException::badPath: - nIDP = AFX_IDP_FAILED_INVALID_PATH; - break; - case CFileException::diskFull: - nIDP = AFX_IDP_FAILED_DISK_FULL; - break; - case CFileException::accessDenied: - nIDP = AFX_IDP_FAILED_ACCESS_WRITE; - break; - - case CFileException::badSeek: - case CFileException::genericException: - case CFileException::tooManyOpenFiles: - case CFileException::invalidFile: - case CFileException::hardIO: - case CFileException::directoryFull: - break; - - default: - break; - } - } - prompt.ReleaseBuffer(); - } - - if (prompt.IsEmpty()) - { - TCHAR szTitle[_MAX_PATH]; - AfxGetFileTitle(lpszPathName, szTitle, _countof(szTitle)); - - if (nIDP != 0) - { - AfxFormatString1(prompt, nIDP, szTitle); - } - else - { - prompt.Format (_T("Failed to save file: %s."), szTitle); - } - } - - AfxMessageBox(prompt, MB_ICONEXCLAMATION, nHelpContext); -} - -void COutputBar::OnFileSaveAs() -{ - CEdit* pWndEdit = (CEdit*) m_wndTabs.GetActiveWnd (); - ASSERT_VALID (pWndEdit); - - CString strText; - pWndEdit->GetWindowText (strText); - if (strText.IsEmpty ()) - { - return; - } - - CFileDialog dlgFile(FALSE, _T("txt"), _T("Code.txt"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Text Documents (*.txt)|*.txt||")); - if (dlgFile.DoModal() != IDOK) - { - return; - } - - CString strPathName (dlgFile.GetPathName ()); - - CFileException fe; - CFile file; - if (file.Open(strPathName, CFile::modeCreate | - CFile::modeWrite | CFile::shareExclusive, &fe)) - { - TRY - { - CWaitCursor wait; - - file.Write((LPCTSTR)strText, strText.GetLength () * sizeof(TCHAR)); - file.Close (); - } - CATCH_ALL(e) - { - file.Abort (); - - TRY - { - ErrorReport (strPathName, e); - } - END_TRY - do { e->Delete(); } while (0); - } - END_CATCH_ALL - } - else - { - ErrorReport (strPathName, &fe); - } -} - -void COutputBar::OnFilePrint() -{ - CEdit* pWndEdit = (CEdit*) m_wndTabs.GetActiveWnd (); - ASSERT_VALID (pWndEdit); - - CString strText; - pWndEdit->GetWindowText (strText); - if (strText.IsEmpty ()) - { - return; - } - - CDC dc; - CPrintDialog printDlg(FALSE); - - if (printDlg.DoModal() == IDCANCEL) - { - return; - } - - dc.Attach(printDlg.GetPrinterDC()); - dc.m_bPrinting = TRUE; - - DOCINFO di; - ::ZeroMemory (&di, sizeof (DOCINFO)); - di.cbSize = sizeof (DOCINFO); - di.lpszDocName = _T("code"); - - BOOL bPrintingOK = dc.StartDoc(&di); - - if (bPrintingOK) - { - CFont* pFont = pWndEdit->GetFont (); - ASSERT_VALID (pFont); - - LOGFONT lf; - pFont->GetLogFont (&lf); - lf.lfHeight = -::MulDiv (abs(lf.lfHeight), dc.GetDeviceCaps(LOGPIXELSY), 72); - - CFont font; - if (font.CreateFontIndirect (&lf)) - { - CFont* pOldFont = (CFont*)dc.SelectObject (&font); - - CRect rect (0, 0,dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES)); - dc.DrawText (strText, rect, DT_WORDBREAK | DT_EXPANDTABS | DT_NOPREFIX); - - if (pOldFont != NULL) - { - dc.SelectObject (pOldFont); - } - - dc.EndDoc(); - } - else - { - bPrintingOK = FALSE; - } - } - - if (!bPrintingOK) - { - dc.AbortDoc(); - } - - dc.DeleteDC(); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/OutputBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/OutputBar.h deleted file mode 100644 index b11f7787178ad..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/OutputBar.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -class COutputToolBar : public CMFCToolBar -{ -public: - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI ((CFrameWnd*) GetOwner (), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList () const { return FALSE; } -}; - -///////////////////////////////////////////////////////////////////////////// -// COutputBar window - -class COutputBar : public CDockablePane -{ -// Construction -public: - COutputBar(); - -// Attributes -protected: - CMFCTabCtrl m_wndTabs; - COutputToolBar m_wndToolBar; - CFont m_Font; - -// Operations -public: - void ClearTabs (); - void AddTab (LPCTSTR lpszName, UINT nID); - -// Overrides - -// Implementation -public: - virtual ~COutputBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnDestroy(); - afx_msg void OnEditCopy(); - afx_msg void OnFileSaveAs(); - afx_msg void OnFilePrint(); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/ReadMe.htm deleted file mode 100644 index bb75b96ad6a58..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/ReadMe.htm +++ /dev/null @@ -1,128 +0,0 @@ - - - - RibbonGadgets Sample: Ribbon Gadgets Application - - -

- RibbonGadgets Sample: Ribbon Gadgets Application

-
-
-
- -

-

-
-

- The RibbonGadgets sample illustrates various controls that can be hosted in the - Ribbon Control. At the bottom of the main frame you can find the Source - Code window with source code text, which outlines how to create a particular - gadget. -

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the RibbonGadgets sample

-
-
    -
  1. -

    - Open the solution RibbonGadgets.sln. -

    -
  2. -
  3. -

    - On the Build menu, click Build. -

    -
  4. -
  5. -

    - On the Debug menu, click Start Without Debugging. -

    -
  6. -
-
-
-
-

- Keywords

-
-

- The RibbonGadgets sample demonstrates the following keywords:

-

- CDockablePane; CDockingManager; CFrameWndEx; CMFCPopupMenu; CMFCPropertySheet; CMFCRibbonApplicationButton; - CMFCRibbonBar; CMFCRibbonBaseElement; CMFCRibbonButton; CMFCRibbonButtonsGroup; - CMFCRibbonCategory; CMFCRibbonCheckBox; CMFCRibbonColorButton; CMFCRibbonComboBox; - CMFCRibbonCustomizePropertyPage; CMFCRibbonEdit; CMFCRibbonFontComboBox; CMFCRibbonGallery; - CMFCRibbonLabel; CMFCRibbonLinkCtrl; CMFCRibbonMainPanel; CMFCRibbonMainPanelButton; - CMFCRibbonPanel; CMFCRibbonProgressBar; CMFCRibbonQuickAccessToolBarDefaultState; - CMFCRibbonSeparator; CMFCRibbonSlider; CMFCRibbonStatusBar; CMFCRibbonStatusBarPane; - CMFCRibbonUndoButton; CMFCTabCtrl; CMFCToolBar; CMFCToolBarImages; CMFCToolTipCtrl; - CMFCToolTipInfo; CMFCVisualManager; CMFCVisualManagerOffice; CTabbedPane; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.cpp deleted file mode 100644 index 44740481c5989..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.cpp +++ /dev/null @@ -1,182 +0,0 @@ -#include "stdafx.h" -#include "RibbonGadgets.h" - -#include "MainFrm.h" -#include "RibbonGadgetsDoc.h" -#include "RibbonGadgetsView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsApp - -BEGIN_MESSAGE_MAP(CRibbonGadgetsApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinAppEx::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsApp construction - -CRibbonGadgetsApp::CRibbonGadgetsApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CRibbonGadgetsApp object - -CRibbonGadgetsApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsApp initialization - -BOOL CRibbonGadgetsApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(0); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // TODO: Remove this if you don't want extended tooltips: - InitTooltipManager(); - - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - theApp.GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS(CMFCToolTipCtrl), - ¶ms); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CRibbonGadgetsDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CRibbonGadgetsView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew; - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CRibbonGadgetsApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsApp message handlers - -int CRibbonGadgetsApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void CRibbonGadgetsApp::PreLoadState () -{ - GetContextMenuManager()->AddMenu (_T("Edit menu"), IDR_EDIT_MENU); -} - - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsApp message handlers - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.h deleted file mode 100644 index 78d8516e65a3e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsApp: -// See RibbonGadgets.cpp for the implementation of this class -// - -class CRibbonGadgetsApp : public CWinAppEx -{ -public: - CRibbonGadgetsApp(); - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CRibbonGadgetsApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.rc deleted file mode 100644 index deddbbc0fa285..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgets.rc +++ /dev/null @@ -1,518 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\RibbonGadgets.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#ifndef _AFXDLL\r\n" - "#include ""afxribbon.rc"" // ribbon and control bars\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// CODE -// - -ID_RIBBON_SOURCE_CODE_1_1 CODE "res\\Code\\src1_1.txt" -ID_RIBBON_SOURCE_CODE_1_2 CODE "res\\Code\\src1_2.txt" -ID_RIBBON_SOURCE_CODE_1_3 CODE "res\\Code\\src1_3.txt" -ID_RIBBON_SOURCE_CODE_2_1 CODE "res\\Code\\src2_1.txt" -ID_RIBBON_SOURCE_CODE_2_2 CODE "res\\Code\\src2_2.txt" -ID_RIBBON_SOURCE_CODE_3_1 CODE "res\\Code\\src3_1.txt" -ID_RIBBON_SOURCE_CODE_3_2 CODE "res\\Code\\src3_2.txt" -ID_RIBBON_SOURCE_CODE_3_3 CODE "res\\Code\\src3_3.txt" -ID_RIBBON_SOURCE_CODE_3_4 CODE "res\\Code\\src3_4.txt" -ID_RIBBON_SOURCE_CODE_4_1 CODE "res\\Code\\src4_1.txt" -ID_RIBBON_SOURCE_CODE_4_2 CODE "res\\Code\\src4_2.txt" -ID_RIBBON_SOURCE_CODE_5_1 CODE "res\\Code\\src5_1.txt" -ID_RIBBON_SOURCE_CODE_5_2 CODE "res\\Code\\src5_2.txt" -ID_RIBBON_SOURCE_CODE_5_3 CODE "res\\Code\\src5_3.txt" -ID_RIBBON_SOURCE_CODE_6_1 CODE "res\\Code\\src6_1.txt" -ID_RIBBON_SOURCE_CODE_6_2 CODE "res\\Code\\src6_2.txt" -ID_RIBBON_SOURCE_CODE_6_3 CODE "res\\Code\\src6_3.txt" -ID_RIBBON_SOURCE_CODE_6_4 CODE "res\\Code\\src6_4.txt" -ID_RIBBON_SOURCE_CODE_6_5 CODE "res\\Code\\src6_5.txt" - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\RibbonGadgets.ico" -IDR_RIBBONTYPE ICON "res\\RibbonGadgetsDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_RIBBON_ICONS BITMAP "res\\icons.bmp" -IDB_RIBBON_FILE_SMALL BITMAP "res\\filesmall.bmp" -IDB_RIBBON_FILE_LARGE BITMAP "res\\filelarge.bmp" -IDB_RIBBON_MAIN BITMAP "res\\main.bmp" -IDB_RIBBON_CATEGORY1_SMALL BITMAP "res\\CategorySmall_1.bmp" -IDB_RIBBON_CATEGORY1_LARGE BITMAP "res\\CategoryLarge_1.bmp" -IDB_RIBBON_PALETTE_1 BITMAP "res\\Palette1.bmp" -IDB_RIBBON_PALETTE_2 BITMAP "res\\Palette2.bmp" -IDR_TOOLBAR BITMAP "res\\toolbar.bmp" -IDR_CODE BITMAP "res\\code.bmp" -IDB_RIBBON_CATEGORY4_SMALL BITMAP "res\\CategorySmall_4.bmp" -IDB_RIBBON_CATEGORY5_SMALL BITMAP "res\\CategorySmall_5.bmp" -IDB_RIBBON_CATEGORY3_SMALL BITMAP "res\\CategorySmall_3.bmp" -IDB_RIBBON_CATEGORY2_LARGE BITMAP "res\\CategoryLarge_2.bmp" -IDB_RIBBON_CATEGORY2_SMALL BITMAP "res\\CategorySmall_2.bmp" -IDB_RIBBON_CATEGORY3_LARGE BITMAP "res\\CategoryLarge_3.bmp" -IDB_RIBBON_CATEGORY6_LARGE BITMAP "res\\CategoryLarge_6.bmp" -IDB_RIBBON_CATEGORY6_SMALL BITMAP "res\\CategorySmall_6.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_PASTE_MENU MENU -BEGIN - MENUITEM "&Paste", ID_EDIT_PASTE - MENUITEM "Paste &Special...", ID_EDIT_PASTE_SPECIAL -END - -IDR_THEME_MENU MENU -BEGIN - MENUITEM "&Blue Theme", ID_VIEW_APPLOOK_2007 - MENUITEM "B&lack Theme", ID_VIEW_APPLOOK_2007_1 - MENUITEM "&Silver Theme", ID_VIEW_APPLOOK_2007_2 - MENUITEM "&Aqua Theme", ID_VIEW_APPLOOK_2007_3 -END - -IDR_RIBBON_MENU_1 MENU -BEGIN - MENUITEM "Item 1", ID_RIBBON_MENU_ITEM_1 - MENUITEM "Item 2", ID_RIBBON_MENU_ITEM_2 - MENUITEM "Item 3", ID_RIBBON_MENU_ITEM_3 - MENUITEM SEPARATOR - POPUP "Popup" - BEGIN - MENUITEM "Item 4", ID_RIBBON_MENU_ITEM_4 - MENUITEM "Item 5", ID_RIBBON_MENU_ITEM_5 - MENUITEM "Item 6", ID_RIBBON_MENU_ITEM_6 - END -END - -IDR_EDIT_MENU MENU -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END -END - -IDR_RIBBON_MENU_2 MENU -BEGIN - MENUITEM "Item 1", ID_RIBBON_MENU_ITEM_1 - MENUITEM "Item 2", ID_RIBBON_MENU_ITEM_2 - MENUITEM "Item 3", ID_RIBBON_MENU_ITEM_3 -END - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About...", ID_APP_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "RibbonGadgets MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "RibbonGadgets" - VALUE "LegalCopyright", "Copyright (C) 2007" - VALUE "OriginalFilename", "RibbonGadgets.EXE" - VALUE "ProductName", "RibbonGadgets Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_TOOLBAR TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - -IDR_CODE TOOLBAR 16, 16 -BEGIN - BUTTON ID_EDIT_COPY - BUTTON ID_FILE_PRINT - BUTTON ID_FILE_SAVE_AS -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "RibbonGadgets\n\nMFCRib\n\n\nRibbonGadgets.Document\nMFCRib Document" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "RibbonGadgets" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_DIRECT "Send the document directly to the default printer without making changes\nQuick Print" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_RIBBON_GBTN_1 "Group Button 1\nGroup Button 1" - ID_RIBBON_GBTN_2 "Group Button 2\nGroup Button 2" - ID_RIBBON_GBTN_3 "Group Button 3\nGroup Button 3" - ID_RIBBON_GBTN_4 "Group Button 4\nGroup Button 4" - ID_RIBBON_GBTN_5 "Group Button 5\nGroup Button 5" - ID_RIBBON_GBTN_6 "Group Button 6\nGroup Button 6" - ID_RIBBON_GBTN_7 "Group Button 7\nGroup Button 7" - ID_RIBBON_GBTN_8 "Group Button 8\nGroup Button 8" -END - -STRINGTABLE -BEGIN - ID_RIBBON_GBTN_9 "Group Button 9\nGroup Button 9" - ID_RIBBON_GBTN_10 "Group Button 10\nGroup Button 10" - ID_RIBBON_GBTN_11 "Group Button 11\nGroup Button 11" - ID_RIBBON_EBTN_1 "Edit Box 1\nEdit Box 1" - ID_RIBBON_EBTN_2 "Edit Box 2\nEdit Box 2" - ID_RIBBON_EBTN_3 "Edit Box 3\nEdit Box 3" -END - -STRINGTABLE -BEGIN - ID_RIBBON_EBTN_4 "Edit Box 4\nEdit Box 4" - ID_RIBBON_EBTN_5 "Edit Box 5\nEdit Box 5" - ID_RIBBON_EBTN_6 "Edit Box 6\nEdit Box 6" - ID_RIBBON_EBTN_7 "Edit Box 7\nEdit Box 7" - ID_RIBBON_EBTN_8 "Edit Box 8\nEdit Box 8" - ID_RIBBON_EBTN_9 "Edit Box 9\nEdit Box 9" - ID_RIBBON_OBTN_5 "Slider 1\nSlider 1" - ID_RIBBON_OBTN_6 "Slider 2\nSlider 2" - ID_RIBBON_OBTN_7 "Progress Bar 1\nProgress Bar 1" - ID_RIBBON_OBTN_9 "Progress Bar 2\nProgress Bar 2" -END - -STRINGTABLE -BEGIN - ID_RIBBON_OBTN_11 "Date and Time Picker\nDate and Time Picker" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - ID_VIEW_APPLOOK_2007 "Activate Office 2007 application look\nOffice 2007 Look" - ID_TOOLS_OPTIONS "Changes application options\nOptions" -END - -STRINGTABLE -BEGIN - ID_STATUSBAR_PANE1 "Status bar indicator 1" - ID_STATUSBAR_PANE2 "Status bar indicator 2" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\RibbonGadgets.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bars -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsDoc.cpp deleted file mode 100644 index db63c1eb373f6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsDoc.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "stdafx.h" -#include "RibbonGadgets.h" - -#include "RibbonGadgetsDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsDoc - -IMPLEMENT_DYNCREATE(CRibbonGadgetsDoc, CDocument) - -BEGIN_MESSAGE_MAP(CRibbonGadgetsDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsDoc construction/destruction - -CRibbonGadgetsDoc::CRibbonGadgetsDoc() - : m_bStartup (TRUE) -{ - // TODO: add one-time construction code here - -} - -CRibbonGadgetsDoc::~CRibbonGadgetsDoc() -{ -} - -BOOL CRibbonGadgetsDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsDoc serialization - -void CRibbonGadgetsDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - } - else - { - } -} - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsDoc diagnostics - -#ifdef _DEBUG -void CRibbonGadgetsDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CRibbonGadgetsDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsDoc.h deleted file mode 100644 index 8b0cc83494b8e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsDoc.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -class CRibbonGadgetsDoc : public CDocument -{ -protected: // create from serialization only - CRibbonGadgetsDoc(); - DECLARE_DYNCREATE(CRibbonGadgetsDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CRibbonGadgetsDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() - -protected: - BOOL m_bStartup; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsView.cpp deleted file mode 100644 index ac190a9140220..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsView.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "stdafx.h" -#include "RibbonGadgets.h" - -#include "RibbonGadgetsDoc.h" -#include "RibbonGadgetsView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to create the various Ribbon elements.\r\n") - _T("\"Source Code\" window contains source code for the current ribbon category (tab).\r\n") - _T("Please select a specific tab on the bottom to see the panel source code.\r\n") - _T("You may copy this code into the clipboard, print it or save it in an external file."); - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsView - -IMPLEMENT_DYNCREATE(CRibbonGadgetsView, CView) - -BEGIN_MESSAGE_MAP(CRibbonGadgetsView, CView) - ON_WM_DESTROY() - ON_WM_CREATE() - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsView construction/destruction - -CRibbonGadgetsView::CRibbonGadgetsView() -{ - -} - -CRibbonGadgetsView::~CRibbonGadgetsView() -{ -} - -BOOL CRibbonGadgetsView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsView printing - -void CRibbonGadgetsView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CRibbonGadgetsView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - - -void CRibbonGadgetsView::OnDestroy() -{ - CView::OnDestroy(); -} - - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsView diagnostics - -#ifdef _DEBUG -void CRibbonGadgetsView::AssertValid() const -{ - CView::AssertValid(); -} - -void CRibbonGadgetsView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CRibbonGadgetsDoc* CRibbonGadgetsView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRibbonGadgetsDoc))); - return (CRibbonGadgetsDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CRibbonGadgetsView message handlers - -int CRibbonGadgetsView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CView::OnCreate(lpCreateStruct) == -1) - return -1; - - return 0; -} - -HMENU CRibbonGadgetsView::GetContextMenu(WORD, LPOLEOBJECT, CHARRANGE* ) -{ - return NULL; -} - -void CRibbonGadgetsView::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - theApp.ShowPopupMenu (IDR_EDIT_MENU, point, this); -} - -void CRibbonGadgetsView::OnDraw(CDC* pDC) -{ - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - pDC->FillSolidRect (rectFrame, ::GetSysColor (COLOR_INFOBK)); - - rectFrame.DeflateRect (1, 1); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - rectFrame.DeflateRect (2, 2); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - pDC->SetTextColor (::GetSysColor (COLOR_INFOTEXT)); - pDC->SetBkMode (TRANSPARENT); - - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - - pDC->SelectObject (pFontOld); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsView.h deleted file mode 100644 index d0f4d69cd5ab2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/RibbonGadgetsView.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -class CRibbonGadgetsView : public CView -{ -protected: // create from serialization only - CRibbonGadgetsView(); - DECLARE_DYNCREATE(CRibbonGadgetsView) - -// Attributes -public: - CRibbonGadgetsDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual HMENU GetContextMenu(WORD, LPOLEOBJECT, CHARRANGE* ); - virtual void OnDraw(CDC* pDC); - -// Implementation -public: - virtual ~CRibbonGadgetsView(); - -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnFilePrintPreview(); - afx_msg void OnDestroy(); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in RibbonGadgetsView.cpp -inline CRibbonGadgetsDoc* CRibbonGadgetsView::GetDocument() - { return (CRibbonGadgetsDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/Snippets.txt deleted file mode 100644 index feb5fe6108e73..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/Snippets.txt +++ /dev/null @@ -1,4 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp: CMFCRibbonLinkCtrl 1 -MainFrm.cpp: CMFCRibbonUndoButton 2 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/StdAfx.cpp deleted file mode 100644 index aaa5fcecf378f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/StdAfx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// RibbonGadgets.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/StdAfx.h deleted file mode 100644 index b9ac5b6aa9842..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/StdAfx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_1.bmp deleted file mode 100644 index 1ff926d3e1683..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_2.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_2.bmp deleted file mode 100644 index e09612adee9b4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_2.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_3.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_3.bmp deleted file mode 100644 index b61d491a41bd7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_3.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_6.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_6.bmp deleted file mode 100644 index ded0c0736b122..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategoryLarge_6.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_1.bmp deleted file mode 100644 index 25940b9ad64bc..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_2.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_2.bmp deleted file mode 100644 index 6fcfa6e260d1e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_2.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_3.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_3.bmp deleted file mode 100644 index e44226a8ef562..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_3.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_4.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_4.bmp deleted file mode 100644 index ecede6b70a69e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_4.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_5.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_5.bmp deleted file mode 100644 index 4a86ca3cb422c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_5.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_6.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_6.bmp deleted file mode 100644 index 9bc14c923a3d0..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/CategorySmall_6.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Palette1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Palette1.bmp deleted file mode 100644 index bc93afc0c6768..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Palette1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Palette2.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Palette2.bmp deleted file mode 100644 index 0fb0728458aee..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Palette2.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgets.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgets.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgets.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgets.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgets.rc2 deleted file mode 100644 index 8bdde34067724..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgets.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// RIBBONGADGETS.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgetsDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgetsDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/RibbonGadgetsDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Toolbar.bmp deleted file mode 100644 index ed1bad0a9d818..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code.bmp deleted file mode 100644 index f5d4a2568e085..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_1.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_1.txt deleted file mode 100644 index f6143874a409f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_1.txt +++ /dev/null @@ -1,17 +0,0 @@ -CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Large Buttons")); - -CMFCRibbonButton* pBtn1 = new CMFCRibbonButton(ID_RIBBON_BTN_1, _T("Button"), 0, 0); -pBtn1->SetAlwaysLargeImage(); -pPanel1->Add(pBtn1); - -CMFCRibbonButton* pBtn2 = new CMFCRibbonButton(ID_RIBBON_BTN_2, _T("Menu Button"), 1, 1); -pBtn2->SetMenu(IDR_RIBBON_MENU_1); -pBtn2->SetAlwaysLargeImage(); -pPanel1->Add(pBtn2); - -CMFCRibbonButton* pBtn3 = new CMFCRibbonButton(ID_RIBBON_BTN_3, _T("Split Button"), 2, 2); -pBtn3->SetMenu(IDR_RIBBON_MENU_1, TRUE); -pBtn3->SetAlwaysLargeImage(); -pBtn3->RemoveSubItem(0); -pBtn3->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MBTN_1, _T("Item 1"), 2), 0); -pPanel1->Add(pBtn3); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_2.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_2.txt deleted file mode 100644 index ebc9d282768b1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_2.txt +++ /dev/null @@ -1,15 +0,0 @@ -CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Small")); - -CMFCRibbonButton* pBtn4 = new CMFCRibbonButton(ID_RIBBON_BTN_4, _T("Button"), 3); -pPanel2->Add(pBtn4); - -CMFCRibbonButton* pBtn5 = new CMFCRibbonButton(ID_RIBBON_BTN_5, _T("Menu Button"), 4); -pBtn5->SetMenu(IDR_RIBBON_MENU_1); -pPanel2->Add(pBtn5); - -CMFCRibbonButton* pBtn6 = new CMFCRibbonButton(ID_RIBBON_BTN_6, _T("Split Button"), 5); -pBtn6->SetMenu(IDR_RIBBON_MENU_1, TRUE); -pBtn6->SetAlwaysLargeImage(); -pBtn6->RemoveSubItem(1); -pBtn6->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MBTN_2, _T("Item 2"), 5), 1); -pPanel2->Add(pBtn6); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_3.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_3.txt deleted file mode 100644 index e820579c00000..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src1_3.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Check Boxes")); - -pPanel3->Add(new CMFCRibbonCheckBox(ID_RIBBON_BTN_7, _T("Check Box 1"))); -pPanel3->Add(new CMFCRibbonCheckBox(ID_RIBBON_BTN_8, _T("Check Box 2"))); -pPanel3->Add(new CMFCRibbonCheckBox(ID_RIBBON_BTN_9, _T("Check Box 3"))); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src2_1.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src2_1.txt deleted file mode 100644 index 4d90ef9933c00..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src2_1.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Standard")); - -pPanel1->Add(new CMFCRibbonGallery(ID_RIBBON_PBTN_1, _T("Embedded"), 0, 0, IDB_RIBBON_PALETTE_1, 64)); - -CMFCRibbonGallery* pBtn2 = new CMFCRibbonGallery(ID_RIBBON_PBTN_2, _T("Button"), 1, 1, IDB_RIBBON_PALETTE_1, 64); -pBtn2->SetButtonMode(); -pBtn2->SetAlwaysLargeImage(); -pPanel1->Add(pBtn2); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src2_2.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src2_2.txt deleted file mode 100644 index e19c0fa8610b6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src2_2.txt +++ /dev/null @@ -1,24 +0,0 @@ -CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Extended")); - -CMFCRibbonGallery* pBtn3 = new CMFCRibbonGallery(ID_RIBBON_PBTN_3, _T("Resize Vertical"), 2, 2, IDB_RIBBON_PALETTE_1, 64); -pBtn3->SetButtonMode(); -pBtn3->SetIconsInRow(2); -pBtn3->EnableMenuResize(TRUE, TRUE); -pPanel2->Add(pBtn3); - -CMFCRibbonGallery* pBtn4 = new CMFCRibbonGallery(ID_RIBBON_PBTN_4, _T("Resize Both"), 3, 3, IDB_RIBBON_PALETTE_1, 64); -pBtn4->SetButtonMode(); -pBtn4->SetIconsInRow(4); -pBtn4->EnableMenuResize(TRUE); -pPanel2->Add(pBtn4); - -CMFCRibbonGallery* pBtn5 = new CMFCRibbonGallery(ID_RIBBON_PBTN_5, _T("Groups && Subitems"), 4, 4); -pBtn5->AddGroup(_T("Group 1"), IDB_RIBBON_PALETTE_1, 64); -pBtn5->AddGroup(_T("Group 2"), IDB_RIBBON_PALETTE_2, 64); -pBtn5->SetButtonMode(); -pBtn5->SetIconsInRow(4); -pBtn5->EnableMenuResize(TRUE); -pBtn5->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MENU_ITEM_1, _T("Item 1"))); -pBtn5->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MENU_ITEM_2, _T("Item 2"))); -pBtn5->AddSubItem(new CMFCRibbonButton(ID_RIBBON_MENU_ITEM_3, _T("Item 3"))); -pPanel2->Add(pBtn5); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_1.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_1.txt deleted file mode 100644 index ec700fa6eba3a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_1.txt +++ /dev/null @@ -1,25 +0,0 @@ -CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Large")); - -CMFCRibbonColorButton* pBtn1 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_1, _T("Simple"), TRUE, 0, 0); -pBtn1->SetAlwaysLargeImage(); -pBtn1->SetDefaultCommand(FALSE); -pPanel1->Add(pBtn1); - -CMFCRibbonColorButton* pBtn2 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_2, _T("Simple with Options"), TRUE, 1, 1); -pBtn2->SetAlwaysLargeImage(); -pBtn2->SetDefaultCommand(FALSE); -pBtn2->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); -pBtn2->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); -pPanel1->Add(pBtn2); - -CMFCRibbonColorButton* pBtn3 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_3, _T("Custom"), TRUE, 2, 2); -pBtn3->SetAlwaysLargeImage(); -pBtn3->SetDefaultCommand(FALSE); -pBtn3->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); -pBtn3->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); -pBtn3->SetColumns(10); -pBtn3->SetColorBoxSize(CSize(17, 17)); -pBtn3->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); -pBtn3->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); -pBtn3->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); -pPanel1->Add(pBtn3); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_2.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_2.txt deleted file mode 100644 index 95f457f031ca0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_2.txt +++ /dev/null @@ -1,22 +0,0 @@ -CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Small")); - -CMFCRibbonColorButton* pBtn4 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_4, _T("Simple"), TRUE, 3, -1); -pBtn4->SetDefaultCommand(FALSE); -pPanel2->Add(pBtn4); - -CMFCRibbonColorButton* pBtn5 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_5, _T("Simple with Options"), TRUE, 4, -1); -pBtn5->SetDefaultCommand(FALSE); -pBtn5->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); -pBtn5->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); -pPanel2->Add(pBtn5); - -CMFCRibbonColorButton* pBtn6 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_6, _T("Custom"), TRUE, 5, -1); -pBtn6->SetDefaultCommand(FALSE); -pBtn6->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); -pBtn6->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); -pBtn6->SetColumns(10); -pBtn6->SetColorBoxSize(CSize(17, 17)); -pBtn6->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); -pBtn6->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); -pBtn6->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); -pPanel2->Add(pBtn6); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_3.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_3.txt deleted file mode 100644 index 788a491b0d0ab..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_3.txt +++ /dev/null @@ -1,21 +0,0 @@ -CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Small with Indicator")); - -CMFCRibbonColorButton* pBtn7 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_7, _T("Simple"), 6); -pBtn7->SetColor(RGB(255, 0, 0)); -pPanel3->Add(pBtn7); - -CMFCRibbonColorButton* pBtn8 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_8, _T("Simple with Options"), 7); -pBtn8->SetColor(RGB(0, 0, 255)); -pBtn8->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); -pBtn8->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); -pPanel3->Add(pBtn8); - -CMFCRibbonColorButton* pBtn9 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_9, _T("Custom"), 8); -pBtn9->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0)); -pBtn9->EnableOtherButton(_T("&More Colors..."), _T("More Colors")); -pBtn9->SetColumns(10); -pBtn9->SetColorBoxSize(CSize(17, 17)); -pBtn9->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); -pBtn9->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); -pBtn9->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); -pPanel3->Add(pBtn9); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_4.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_4.txt deleted file mode 100644 index 6f57fd7a620a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src3_4.txt +++ /dev/null @@ -1,13 +0,0 @@ -CMFCRibbonPanel* pPanel4 = pCategory->AddPanel(_T("Embedded")); - -CMFCRibbonColorButton* pBtn10 = new CMFCRibbonColorButton(ID_RIBBON_CBTN_10, _T("Embedded"), TRUE, 1, 1); -pBtn10->EnableOtherButton(_T("&More Colors..."), _T("More Shading Colors")); -pBtn10->SetColor(RGB(240, 240, 240)); -pBtn10->SetColumns(10); -pBtn10->AddColorsGroup(_T("Theme Colors"), m_lstMainColors); -pBtn10->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE); -pBtn10->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors); -pBtn10->SetColorBoxSize(CSize(17, 17)); -pBtn10->SetButtonMode(FALSE); -pBtn10->EnableAutomaticButton(_T("&No Color"), (COLORREF)-1, TRUE, NULL, FALSE /* Bottom */); -pPanel4->Add(pBtn10); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src4_1.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src4_1.txt deleted file mode 100644 index bbf51188c122d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src4_1.txt +++ /dev/null @@ -1,3 +0,0 @@ -CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("From Toolbar")); - -pPanel1->AddToolBar(IDR_TOOLBAR); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src4_2.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src4_2.txt deleted file mode 100644 index e842b9706a93d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src4_2.txt +++ /dev/null @@ -1,35 +0,0 @@ -CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Manual")); - -CMFCRibbonButtonsGroup* pButtonsGroup1 = new CMFCRibbonButtonsGroup; - -pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_1, _T(""), 0)); -pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_2, _T(""), 1)); - -CMFCRibbonEdit* pEdit = new CMFCRibbonEdit(ID_RIBBON_GBTN_3, 65); -pEdit->SetEditText(_T("Edit")); -pButtonsGroup1->AddButton(pEdit); - -pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_4, _T(""), 2)); -pButtonsGroup1->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_5, _T(""), 3)); - -pPanel2->Add(pButtonsGroup1); - -CMFCRibbonButtonsGroup* pButtonsGroup2 = new CMFCRibbonButtonsGroup; -pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_6, _T(""), 4)); -pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_7, _T(""), 5)); -pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_8, _T(""), 6)); -pButtonsGroup2->AddButton(new CMFCRibbonButton(ID_RIBBON_GBTN_9, _T(""), 7)); - -pPanel2->Add(pButtonsGroup2); - -CMFCRibbonButtonsGroup* pButtonsGroup3 = new CMFCRibbonButtonsGroup; - -CMFCRibbonButton* pBtn10 = new CMFCRibbonButton(ID_RIBBON_GBTN_10, _T(""), 8); -pBtn10->SetMenu(IDR_RIBBON_MENU_1); -pButtonsGroup3->AddButton(pBtn10); - -CMFCRibbonButton* pBtn11 = new CMFCRibbonButton(ID_RIBBON_GBTN_11, _T(""), 9); -pBtn11->SetMenu(IDR_RIBBON_MENU_1, TRUE); -pButtonsGroup3->AddButton(pBtn11); - -pPanel2->Add(pButtonsGroup3); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_1.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_1.txt deleted file mode 100644 index 4a65ad013e0ab..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_1.txt +++ /dev/null @@ -1,21 +0,0 @@ -CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Standard")); - -CMFCRibbonEdit* pBtn1 = new CMFCRibbonEdit(ID_RIBBON_EBTN_1, 90); -pBtn1->SetEditText(_T("Edit")); -pPanel1->Add(pBtn1); - -CMFCRibbonEdit* pBtn2 = new CMFCRibbonEdit(ID_RIBBON_EBTN_2, 90); -pBtn2->EnableSpinButtons(0, 99); -pBtn2->SetEditText(_T("0")); -pPanel1->Add(pBtn2); - -CMFCRibbonComboBox* pBtn3 = new CMFCRibbonComboBox(ID_RIBBON_EBTN_3, TRUE, 74); -pBtn3->AddItem(_T("Combo Box")); -for (i = 0; i < 20; i++) -{ - CString str; - str.Format(_T("Item %d"), i + 1); - pBtn3->AddItem(str); -} -pBtn3->SelectItem(0); -pPanel1->Add(pBtn3); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_2.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_2.txt deleted file mode 100644 index 3998675e61f28..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_2.txt +++ /dev/null @@ -1,21 +0,0 @@ -CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("With Icons and Labels")); - -CMFCRibbonEdit* pBtn4 = new CMFCRibbonEdit(ID_RIBBON_EBTN_4, 90, _T("Label:"), 0); -pBtn4->SetEditText(_T("Edit")); -pPanel2->Add(pBtn4); - -CMFCRibbonEdit* pBtn5 = new CMFCRibbonEdit(ID_RIBBON_EBTN_5, 90, _T("Label:"), 1); -pBtn5->EnableSpinButtons(0, 99); -pBtn5->SetEditText(_T("0")); -pPanel2->Add(pBtn5); - -CMFCRibbonComboBox* pBtn6 = new CMFCRibbonComboBox(ID_RIBBON_EBTN_6, TRUE, 74, _T("Label:"), 2); -pBtn6->AddItem(_T("Combo Box")); -for (i = 0; i < 20; i++) -{ - CString str; - str.Format(_T("Item %d"), i + 1); - pBtn6->AddItem(str); -} -pBtn6->SelectItem(0); -pPanel2->Add(pBtn6); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_3.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_3.txt deleted file mode 100644 index 086134c534281..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src5_3.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Font")); - -CMFCRibbonFontComboBox::m_bDrawUsingFont = TRUE; -CMFCRibbonFontComboBox* pBtn7 = new CMFCRibbonFontComboBox(ID_RIBBON_EBTN_7); -pBtn7->SelectItem(_T("Arial")); -pPanel3->Add(pBtn7); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_1.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_1.txt deleted file mode 100644 index 1c910d653bcd0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_1.txt +++ /dev/null @@ -1,10 +0,0 @@ -CMFCRibbonPanel* pPanel1 = pCategory->AddPanel(_T("Undo")); - -CMFCRibbonUndoButton* pBtn1 = new CMFCRibbonUndoButton(ID_RIBBON_OBTN_1, _T("Undo"), 0, 0); -for (int i = 0; i < 20; i++) -{ - CString str; - str.Format(_T("Action %d"), i + 1); - pBtn1->AddUndoAction(str); -} -pPanel1->Add(pBtn1); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_2.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_2.txt deleted file mode 100644 index 2307a695f6145..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_2.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMFCRibbonPanel* pPanel2 = pCategory->AddPanel(_T("Label")); - -pPanel2->Add(new CMFCRibbonLabel(_T("Label 1"))); -pPanel2->Add(new CMFCRibbonLabel(_T("Label 2"))); -pPanel2->Add(new CMFCRibbonLabel(_T("Label 3"))); - -pPanel2->Add(new CMFCRibbonSeparator()); - -pPanel2->Add(new CMFCRibbonLabel(_T("This is a multi-line label"), TRUE)); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_3.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_3.txt deleted file mode 100644 index 8cba038ce835e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_3.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMFCRibbonPanel* pPanel3 = pCategory->AddPanel(_T("Hyperlink")); - -pPanel3->Add(new CMFCRibbonLinkCtrl(ID_RIBBON_OBTN_2, _T("Send email"), _T("mailto:info@microsoft.com"))); -pPanel3->Add(new CMFCRibbonLinkCtrl(ID_RIBBON_OBTN_3, _T("Visit site"), _T("http://www.microsoft.com"))); -pPanel3->Add(new CMFCRibbonLinkCtrl(ID_RIBBON_OBTN_4, _T("Launch Notepad"), _T("notepad"))); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_4.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_4.txt deleted file mode 100644 index 2db9b9d34937d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_4.txt +++ /dev/null @@ -1,14 +0,0 @@ -CMFCRibbonPanel* pPanel4 = pCategory->AddPanel(_T("Sliders")); -pPanel4->SetCenterColumnVert(); - -pPanel4->Add(new CMFCRibbonLabel(_T("Simple Slider:"))); -pPanel4->Add(new CMFCRibbonSlider(ID_RIBBON_OBTN_5, 70 /* Slider width */)); - -pPanel4->Add(new CMFCRibbonSeparator()); - -pPanel4->Add(new CMFCRibbonLabel(_T("Slider with Buttons:"))); -CMFCRibbonSlider* pBtn6 = new CMFCRibbonSlider(ID_RIBBON_OBTN_6, 70 /* Slider width */); -pBtn6->SetZoomButtons(); -pBtn6->SetRange(0, 100); -pBtn6->SetPos(50); -pPanel4->Add(pBtn6); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_5.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_5.txt deleted file mode 100644 index 55224fbb95e6b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/code/src6_5.txt +++ /dev/null @@ -1,15 +0,0 @@ -CMFCRibbonPanel* pPanel5 = pCategory->AddPanel(_T("Progress Bars")); -pPanel5->SetCenterColumnVert(); - -pPanel5->Add(new CMFCRibbonLabel(_T("Simple Progress:"))); -pPanel5->Add(new CMFCRibbonProgressBar(ID_RIBBON_OBTN_7, 100 /* Bar width */)); -pPanel5->Add(new CMFCRibbonButton(ID_RIBBON_OBTN_8, _T("Show Progress 1"))); - -pPanel5->Add(new CMFCRibbonSeparator()); - -pPanel5->Add(new CMFCRibbonLabel(_T("Infinite Progress:"))); -CMFCRibbonProgressBar* pBtn9 = new CMFCRibbonProgressBar(ID_RIBBON_OBTN_9, 100 /* Bar width */); -pBtn9->SetInfiniteMode(); -pPanel5->Add(pBtn9); - -pPanel5->Add(new CMFCRibbonButton(ID_RIBBON_OBTN_10, _T("Show Progress 2"))); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/filelarge.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/filelarge.bmp deleted file mode 100644 index 11ae1cdb1681c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/filelarge.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/filesmall.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/filesmall.bmp deleted file mode 100644 index 6a6313c73e635..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/filesmall.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/icons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/icons.bmp deleted file mode 100644 index 158726de83507..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/icons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/main.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/main.bmp deleted file mode 100644 index 9393d8e6ee316..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/res/main.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/resource.h deleted file mode 100644 index 4e65c044fe9b8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/resource.h +++ /dev/null @@ -1,136 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by RibbonGadgets.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDR_MAINFRAME 128 -#define IDR_RIBBONTYPE 129 -#define IDR_PASTE_MENU 134 -#define IDR_THEME_MENU 136 -#define IDB_RIBBON_ICONS 154 -#define IDB_RIBBON_FILE_SMALL 155 -#define IDB_RIBBON_FILE_LARGE 156 -#define IDB_RIBBON_MAIN 159 -#define IDB_RIBBON_CATEGORY1_SMALL 160 -#define IDB_RIBBON_CATEGORY1_LARGE 161 -#define IDR_RIBBON_MENU_1 162 -#define IDR_EDIT_MENU 163 -#define IDB_RIBBON_PALETTE_1 164 -#define IDR_RIBBON_MENU_2 164 -#define IDB_RIBBON_PALETTE_2 165 -#define IDR_TOOLBAR 168 -#define IDR_CODE 169 -#define IDB_RIBBON_CATEGORY4_SMALL 171 -#define IDB_RIBBON_CATEGORY5_SMALL 172 -#define IDB_RIBBON_CATEGORY3_SMALL 173 -#define IDB_RIBBON_CATEGORY2_LARGE 174 -#define IDB_RIBBON_CATEGORY2_SMALL 175 -#define IDB_RIBBON_CATEGORY3_LARGE 176 -#define IDB_RIBBON_CATEGORY6_LARGE 177 -#define IDB_RIBBON_CATEGORY6_SMALL 178 -#define IDD_ABOUTBOX 999 -#define ID_RIBBON_SOURCE_CODE_1_1 2933 -#define ID_RIBBON_SOURCE_CODE_1_2 2934 -#define ID_RIBBON_SOURCE_CODE_1_3 2935 -#define ID_RIBBON_SOURCE_CODE_2_1 2936 -#define ID_RIBBON_SOURCE_CODE_2_2 2937 -#define ID_RIBBON_SOURCE_CODE_3_1 2938 -#define ID_RIBBON_SOURCE_CODE_3_2 2939 -#define ID_RIBBON_SOURCE_CODE_3_3 2940 -#define ID_RIBBON_SOURCE_CODE_3_4 2941 -#define ID_RIBBON_SOURCE_CODE_4_1 2942 -#define ID_RIBBON_SOURCE_CODE_4_2 2943 -#define ID_RIBBON_SOURCE_CODE_5_1 2944 -#define ID_RIBBON_SOURCE_CODE_5_2 2945 -#define ID_RIBBON_SOURCE_CODE_5_3 2946 -#define ID_RIBBON_SOURCE_CODE_6_1 2947 -#define ID_RIBBON_SOURCE_CODE_6_2 2948 -#define ID_RIBBON_SOURCE_CODE_6_3 2949 -#define ID_RIBBON_SOURCE_CODE_6_4 2950 -#define ID_RIBBON_SOURCE_CODE_6_5 2951 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_OUTPUT 32833 -#define ID_VIEW_APPLOOK_2007 32838 -#define ID_VIEW_APPLOOK_2007_1 32839 -#define ID_VIEW_APPLOOK_2007_2 32840 -#define ID_VIEW_APPLOOK_2007_3 32841 -#define ID_TOOLS_OPTIONS 32847 -#define ID_STATUSBAR_PANE1 32848 -#define ID_STATUSBAR_PANE2 32849 -#define ID_RIBBON_A 32853 -#define ID_RIBBON_BTN_8 32854 -#define ID_RIBBON_BTN_1 32855 -#define ID_RIBBON_BTN_2 32857 -#define ID_RIBBON_BTN_3 32858 -#define ID_RIBBON_BTN_4 32859 -#define ID_RIBBON_BTN_5 32860 -#define ID_RIBBON_BTN_6 32861 -#define ID_RIBBON_BTN_7 32862 -#define ID_RIBBON_BTN_9 32863 -#define ID_RIBBON_MENU_ITEM_1 32864 -#define ID_RIBBON_MENU_ITEM_2 32865 -#define ID_RIBBON_MENU_ITEM_3 32866 -#define ID_RIBBON_MENU_ITEM_4 32867 -#define ID_RIBBON_MENU_ITEM_5 32868 -#define ID_RIBBON_MENU_ITEM_6 32869 -#define ID_RIBBON_MBTN_1 32870 -#define ID_RIBBON_MBTN_2 32871 -#define ID_RIBBON_PBTN_1 32881 -#define ID_RIBBON_PBTN_2 32882 -#define ID_RIBBON_PBTN_3 32883 -#define ID_RIBBON_PBTN_4 32884 -#define ID_RIBBON_PBTN_5 32885 -#define ID_RIBBON_GBTN_1 32886 -#define ID_RIBBON_GBTN_2 32887 -#define ID_RIBBON_GBTN_3 32888 -#define ID_RIBBON_GBTN_4 32889 -#define ID_RIBBON_GBTN_5 32890 -#define ID_RIBBON_GBTN_6 32891 -#define ID_RIBBON_GBTN_7 32894 -#define ID_RIBBON_GBTN_8 32895 -#define ID_RIBBON_GBTN_9 32896 -#define ID_RIBBON_GBTN_10 32897 -#define ID_RIBBON_GBTN_11 32898 -#define ID_RIBBON_CBTN_3 32900 -#define ID_RIBBON_CBTN_1 32901 -#define ID_RIBBON_CBTN_2 32902 -#define ID_RIBBON_CBTN_4 32903 -#define ID_RIBBON_CBTN_5 32904 -#define ID_RIBBON_CBTN_6 32905 -#define ID_RIBBON_CBTN_7 32906 -#define ID_RIBBON_CBTN_8 32907 -#define ID_RIBBON_CBTN_9 32908 -#define ID_RIBBON_EBTN_1 32909 -#define ID_RIBBON_EBTN_2 32910 -#define ID_RIBBON_EBTN_3 32911 -#define ID_RIBBON_EBTN_4 32913 -#define ID_RIBBON_EBTN_5 32914 -#define ID_RIBBON_EBTN_6 32915 -#define ID_RIBBON_EBTN_7 32916 -#define ID_RIBBON_EBTN_8 32917 -#define ID_RIBBON_EBTN_9 32918 -#define ID_RIBBON_OBTN_1 32919 -#define ID_RIBBON_OBTN_2 32920 -#define ID_RIBBON_OBTN_3 32921 -#define ID_RIBBON_OBTN_4 32922 -#define ID_RIBBON_OBTN_5 32923 -#define ID_RIBBON_OBTN_6 32924 -#define ID_RIBBON_OBTN_7 32925 -#define ID_RIBBON_OBTN_8 32926 -#define ID_RIBBON_OBTN_9 32927 -#define ID_RIBBON_OBTN_10 32928 -#define ID_RIBBON_OBTN_11 32929 -#define ID_RIBBON_CBTN_10 32930 -#define ID_RIBBON_Z 33000 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 198 -#define _APS_NEXT_COMMAND_VALUE 32952 -#define _APS_NEXT_CONTROL_VALUE 1042 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/ribbongadgets.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/ribbongadgets.vcxproj deleted file mode 100644 index 4049b1eeba047..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/ribbongadgets.vcxproj +++ /dev/null @@ -1,295 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C72608E4-3958-46FD-9B37-AF735962FB75} - RibbonGadgets - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/RibbonGadgets.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX86 - - - true - .\..\bin/RibbonGadgets.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/RibbonGadgets.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX64 - - - true - .\..\bin/RibbonGadgets.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RibbonGadgets/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/MainFrm.cpp deleted file mode 100644 index 068ac858a03ca..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/MainFrm.cpp +++ /dev/null @@ -1,575 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "SetPaneSize.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_COMMAND(ID_VIEW_WORKSPACE, OnViewWorkspace) - ON_UPDATE_COMMAND_UI(ID_VIEW_WORKSPACE, OnUpdateViewWorkspace) - ON_COMMAND(ID_VIEW_DLGBAR, OnViewDialogBar) - ON_UPDATE_COMMAND_UI(ID_VIEW_DLGBAR, OnUpdateViewDialogBar) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - - CMFCToolBar::EnableQuickCustomization (); - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - CImageList imagesWorkspace; - imagesWorkspace.Create (IDB_WORKSPACE, 16, 0, RGB (255, 0, 255)); - - if (!m_wndWorkSpace.Create (_T("View 1"), this, CRect (0, 0, 200, 200), - TRUE, ID_VIEW_WORKSPACE, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Workspace bar\n"); - return FALSE; // fail to create - } - - m_wndWorkSpace.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); - // - // The this pointer points to a CMainFrame class which extends the CFrameWnd class. - if (!m_wndDlgBar.Create (_T("DialogBar"), this, TRUE, - MAKEINTRESOURCE (IDD_DLG_BAR), - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI, - ID_VIEW_DLGBAR)) - { - TRACE0("Failed to create Dialog Bar\n"); - return FALSE; // fail to create - } - // - - m_wndDlgBar.SetIcon (imagesWorkspace.ExtractIcon (1), FALSE); - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY); - m_wndDlgBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - EnableAutoHidePanes(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane (&m_wndWorkSpace); - m_wndDlgBar.DockToWindow (&m_wndWorkSpace, CBRS_ALIGN_BOTTOM); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnViewWorkspace() -{ - ShowPane (&m_wndWorkSpace, - !(m_wndWorkSpace.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewWorkspace(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndWorkSpace.IsVisible ()); -} - -void CMainFrame::OnViewDialogBar() -{ - ShowPane (&m_wndDlgBar, - !(m_wndDlgBar.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewDialogBar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndDlgBar.IsVisible ()); -} - -BOOL CMainFrame::FindInternalDivider (CDockablePane* pBar, - CPaneContainer*& pContainer, - CPaneDivider*& pDivider, - BOOL& bLeftBar, - BOOL& bAloneInContainer) -{ - pContainer = NULL; - pDivider = NULL; - bLeftBar = FALSE; - bAloneInContainer = FALSE; - - CPaneDivider* pDefaultPaneDivider = pBar->GetDefaultPaneDivider (); - - // - // CDockablePane* pBar - CMultiPaneFrameWnd* pParentMiniFrame = - DYNAMIC_DOWNCAST (CMultiPaneFrameWnd, pBar->GetParentMiniFrame ()) ; - // - - CPaneContainer* pStartContainer = NULL; - - if (pParentMiniFrame != NULL) - { - // - // CMultiPaneFrameWnd* pParentMiniFrame - CPaneContainerManager& manager = pParentMiniFrame->GetPaneContainerManager (); - // - pStartContainer = manager.FindPaneContainer (pBar, bLeftBar); - } - else if (pDefaultPaneDivider != NULL) - { - pStartContainer = pDefaultPaneDivider->FindPaneContainer (pBar, bLeftBar); - } - else - { - return FALSE; - } - - if (pStartContainer != NULL) - { - pContainer = pStartContainer; - - while (pContainer != NULL) - { - if (!pContainer->IsRightPartEmpty (TRUE) && - !pContainer->IsLeftPartEmpty (TRUE)) - { - break; - } - pContainer = pContainer->GetParentPaneContainer (); - } - - if (pContainer == NULL) - { - bAloneInContainer = TRUE; - return FALSE; - } - else - { - pDivider = (CPaneDivider*) pContainer->GetPaneDivider (); - - bLeftBar = (pContainer->IsLeftPane (pBar) || - pContainer->GetLeftPaneContainer () != NULL && - ((CPaneContainer*)pContainer->GetLeftPaneContainer ())-> - FindSubPaneContainer (pBar, CPaneContainer::BC_FIND_BY_LEFT_BAR) != NULL); - return TRUE; - } - } - return FALSE; -} - -void CMainFrame::SetDlgBarSizeInContainer (UINT nSize) -{ - BOOL bLeftBar = FALSE; - BOOL bAloneInContainer = FALSE; - CPaneContainer* pContainer = NULL; - CPaneDivider* pDivider = NULL; - - BOOL bResult = FindInternalDivider (&m_wndDlgBar, pContainer, pDivider, bLeftBar, bAloneInContainer); - - if (bAloneInContainer) - { - MessageBox (_T ("DialogBar is docked alone in container.")); - return; - } - if (!bResult || pContainer == NULL || pDivider == NULL) - { - AfxMessageBox (_T ("The DialogBar is not docked.")); - return; - } - - - CRect rectContainer; - pContainer->GetWindowRect (rectContainer, FALSE); - - CRect rectDlgBar; - m_wndDlgBar.GetWindowRect (rectDlgBar); - - CPoint ptOffset (0, 0); - if (pDivider->IsHorizontal ()) - { - ptOffset.y = rectDlgBar.Height () - rectContainer.Height () * nSize / 100; - if (bLeftBar) - { - ptOffset.y = -ptOffset.y; - } - } - else - { - ptOffset.x = rectDlgBar.Width () - rectContainer.Width () * nSize / 100; - if (bLeftBar) - { - ptOffset.x = -ptOffset.x; - } - } - - pDivider->Move (ptOffset); -} -void CMainFrame::SetDlgBarHeightInPixels (UINT nHeight) -{ - BOOL bLeftBar = FALSE; - BOOL bAloneInContainer = FALSE; - CPaneContainer* pContainer = NULL; - CPaneDivider* pDivider = NULL; - - BOOL bResult = FindInternalDivider (&m_wndDlgBar, pContainer, pDivider, bLeftBar, bAloneInContainer); - - if (bAloneInContainer) - { - MessageBox (_T ("DialogBar is docked alone in container.")); - return; - } - if (!bResult || pContainer == NULL || pDivider == NULL) - { - AfxMessageBox (_T ("The DialogBar is not docked.")); - return; - } - - if (!pDivider->IsHorizontal ()) - { - MessageBox (_T ("Internal pane divider is vertical, can change width only.")); - return; - } - - CPaneContainer* pRootContainer = m_wndDlgBar.GetDefaultPaneDivider ()->FindPaneContainer (&m_wndDlgBar, bLeftBar); - - while (pRootContainer->GetParentPaneContainer () != NULL) - { - pRootContainer = pRootContainer->GetParentPaneContainer (); - } - - CRect rectContainer; - pRootContainer->GetWindowRect (rectContainer, FALSE); - - if ((UINT)rectContainer.Height () - 4 < nHeight) - { - CString strFormat = _T ("Required height exceeds allowed height in the current container.\nAllowed height is %u pixels."); - CString strMessage; - strMessage.Format (strFormat, rectContainer.Height () - 4); - MessageBox (strMessage); - return; - } - - - CRect rectDlgBar; - m_wndDlgBar.GetWindowRect (rectDlgBar); - - CPoint ptOffset (0, 0); - ptOffset.y = rectDlgBar.Height () - nHeight; - if (bLeftBar) - { - ptOffset.y = -ptOffset.y; - } - pDivider->Move (ptOffset); -} - -void CMainFrame::SetDlgBarWidthInPixels (UINT nWidth) -{ - - BOOL bLeftBar = FALSE; - BOOL bAloneInContainer = FALSE; - CPaneContainer* pContainer = NULL; - CPaneDivider* pDivider = NULL; - - BOOL bResult = FindInternalDivider (&m_wndDlgBar, pContainer, pDivider, bLeftBar, bAloneInContainer); - - if (bAloneInContainer) - { - MessageBox (_T ("DialogBar is docked alone in container.")); - return; - } - if (!bResult || pContainer == NULL || pDivider == NULL) - { - AfxMessageBox (_T ("The DialogBar is not docked.")); - return; - } - - if (pDivider->IsHorizontal ()) - { - MessageBox (_T ("Internal pane divider is horizontal, can change height only.")); - return; - } - - CPaneContainer* pRootContainer = m_wndDlgBar.GetDefaultPaneDivider ()->FindPaneContainer (&m_wndDlgBar, bLeftBar); - - while (pRootContainer->GetParentPaneContainer () != NULL) - { - pRootContainer = pRootContainer->GetParentPaneContainer (); - } - - CRect rectContainer; - pRootContainer->GetWindowRect (rectContainer, FALSE); - - if ((UINT) rectContainer.Width () - 4 < nWidth) - { - CString strFormat = _T ("Required width exceeds allowed width in the current container.\nAllowed width is %u pixels."); - CString strMessage; - strMessage.Format (strFormat, rectContainer.Width () - 4); - MessageBox (strMessage); - return; - } - - CRect rectDlgBar; - m_wndDlgBar.GetWindowRect (rectDlgBar); - - CPoint ptOffset (0, 0); - ptOffset.x = rectDlgBar.Width () - nWidth; - if (bLeftBar) - { - ptOffset.x = -ptOffset.x; - } - pDivider->Move (ptOffset); -} -void CMainFrame::SetContainerSize (UINT nSize) -{ - // - CPaneDivider* pDefaultPaneDivider = m_wndDlgBar.GetDefaultPaneDivider (); - if (pDefaultPaneDivider == NULL) - { - AfxMessageBox (_T ("The DialogBar is not docked.")); - return; - } - - BOOL bLeftBar = FALSE; - CPaneContainer* pContainer = pDefaultPaneDivider->FindPaneContainer (&m_wndDlgBar, bLeftBar); - // - - while (pContainer->GetParentPaneContainer () != NULL) - { - pContainer = pContainer->GetParentPaneContainer (); - } - - CRect rectContainer; - pContainer->GetWindowRect (rectContainer, FALSE); - - DWORD dwDividerStyle = pDefaultPaneDivider->GetCurrentAlignment (); - CPoint ptOffset (0, 0); - switch (dwDividerStyle) - { - case CBRS_ALIGN_TOP: - ptOffset.y = nSize - rectContainer.Height (); - break; - case CBRS_ALIGN_BOTTOM: - ptOffset.y = rectContainer.Height () - nSize; - break; - case CBRS_ALIGN_LEFT: - ptOffset.x = nSize - rectContainer.Width (); - break; - case CBRS_ALIGN_RIGHT: - ptOffset.x = rectContainer.Width () - nSize; - break; - } - pDefaultPaneDivider->Move (ptOffset); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/MainFrm.h deleted file mode 100644 index 87142ef735476..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/MainFrm.h +++ /dev/null @@ -1,73 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "WorkspaceBar.h" - -#define CFrameWnd CFrameWndEx - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - void SetDlgBarSizeInContainer (UINT nSize); - void SetContainerSize (UINT nSize); - void SetDlgBarHeightInPixels (UINT nHeight); - void SetDlgBarWidthInPixels (UINT nWidth); -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - CWorkspaceBar m_wndWorkSpace; - - // - CPaneDialog m_wndDlgBar; - // - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnViewWorkspace(); - afx_msg void OnUpdateViewWorkspace(CCmdUI* pCmdUI); - afx_msg void OnViewDialogBar(); - afx_msg void OnUpdateViewDialogBar(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); - -private: - BOOL FindInternalDivider (CDockablePane* pBar, - CPaneContainer*& pContainer, - CPaneDivider*& pDivider, BOOL& bLeftSlider, - BOOL& bAloneInContainer); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/ReadMe.htm deleted file mode 100644 index 386369747db31..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/ReadMe.htm +++ /dev/null @@ -1,121 +0,0 @@ - - - - SetPaneSize Sample: Setting Docking Pane Size Application - - -

- SetPaneSize Sample: Setting Docking Pane Size Application

-
-
-
- -

-

-
-

- The SetPaneSize sample demonstrates how to set docking pane size programmatically. - You can input the desired size of docking pane named DialogBar - in pixels and percents and press Set button. The size of - DialogBar will be adjusted accordingly.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the SetPaneSize sample

-
-
    -
  1. -

    - Open the solution SetPaneSize.sln. -

    -
  2. -
  3. -

    - On the Build menu, click Build. -

    -
  4. -
  5. -

    - On the Debug menu, click Start Without Debugging. -

    -
  6. -
-
-
-
-

- Keywords

-
-

- The SetPaneSize sample demonstrates the following keywords:

-

- CDockablePane; CFrameWndEx; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; CMFCToolBar; - CMFCToolBarsCustomizeDialog; CMFCVisualManager; CMultiPaneFrameWnd; CPaneContainer; - CPaneContainerManager; CPaneDialog; CPaneDivider; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.cpp deleted file mode 100644 index 99f920ea411f1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "SetPaneSize.h" - -#include "MainFrm.h" -#include "SetPaneSizeDoc.h" -#include "SetPaneSizeView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeApp - -BEGIN_MESSAGE_MAP(CSetPaneSizeApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeApp construction - -CSetPaneSizeApp::CSetPaneSizeApp() : - CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CSetPaneSizeApp object - -CSetPaneSizeApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeApp initialization - -BOOL CSetPaneSizeApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CSetPaneSizeDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CSetPaneSizeView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeApp message handlers - -int CSetPaneSizeApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void CSetPaneSizeApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CSetPaneSizeApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.h deleted file mode 100644 index c06b5bbb72cbc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.h +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeApp: -// See SetPaneSize.cpp for the implementation of this class -// - -class CSetPaneSizeApp : public CWinAppEx -{ -public: - CSetPaneSizeApp(); - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CSetPaneSizeApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.rc deleted file mode 100644 index dd2ec3acaf2b5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSize.rc +++ /dev/null @@ -1,482 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\SetPaneSize.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\SetPaneSize.ico" -IDR_SETBARTYPE ICON DISCARDABLE "res\\SetPaneSizeDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_WORKSPACE BITMAP DISCARDABLE "res\\workspace.bmp" -IDB_TOOLBAR256 BITMAP MOVEABLE PURE "res\\Toolbar256.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About SetPaneSize...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Workspace", ID_VIEW_WORKSPACE - MENUITEM "&DialogBar", ID_VIEW_DLGBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About SetPaneSize" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "SetPaneSize Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_SetPaneSize_FORM DIALOG DISCARDABLE 0, 0, 320, 200 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Set bar size in container (1 - 99%):",IDC_STATIC,7,68, - 112,11 - EDITTEXT IDC_EDIT_SIZE,151,65,25,14,ES_NUMBER - PUSHBUTTON "Set",IDC_BUTTON_SET_DLGBAR_SIZE,186,65,50,14 - LTEXT "Set width or height of container in pixels:",IDC_STATIC, - 7,49,132,11 - EDITTEXT IDC_EDIT_WIDTH,151,46,25,14,ES_NUMBER - PUSHBUTTON "Set",IDC_BUTTON_SET_CONTAINER_SIZE ,186,46,49,14 - LTEXT "You can adjust size of the DialogBar control in container\nor size of container where the Dialog bar resides", - IDC_STATIC,7,18,182,20 - LTEXT "Set bar width in container (in pixels):",IDC_STATIC,7, - 86,125,8 - LTEXT "Set bar height in container (in pixels):",IDC_STATIC,7, - 105,127,8 - EDITTEXT IDC_EDIT_WIDTH_IN_PIXELS,151,83,26,14,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_HEIGHT_IN_PIXELS,151,102,26,14,ES_AUTOHSCROLL - PUSHBUTTON "Set",IDC_BTN_SET_WIDTH_IN_PIXELS,186,83,50,14 - PUSHBUTTON "Set",IDC_BTN_SET_HEIGHT_IN_PIXELS,186,102,50,14 -END - -IDD_DLG_BAR DIALOG DISCARDABLE 0, 0, 186, 90 -STYLE WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This is a simple dialog bar",IDC_STATIC,7,7,80,13 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "SetPaneSize MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "SetPaneSize\0" - VALUE "LegalCopyright", "Copyright (C) 2004\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "SetPaneSize.EXE\0" - VALUE "ProductName", "SetPaneSize Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_SetPaneSize_FORM, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 313 - TOPMARGIN, 7 - BOTTOMMARGIN, 193 - END - - IDD_DLG_BAR, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 83 - END -END -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "SetPaneSize\n\nSetBar\n\n\nSetPaneSize.Document\nSetBar Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "SetPaneSize" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_WORKSPACE "Show or hide the workspace bar\nToggle Workspace" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_DLGBAR "Show or hide the dialod bar\nToggle Dialog Bar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\SetPaneSize.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeDoc.cpp deleted file mode 100644 index a0e74fef17e3f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "SetPaneSize.h" - -#include "SetPaneSizeDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeDoc - -IMPLEMENT_DYNCREATE(CSetPaneSizeDoc, CDocument) - -BEGIN_MESSAGE_MAP(CSetPaneSizeDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeDoc construction/destruction - -CSetPaneSizeDoc::CSetPaneSizeDoc() -{ - // TODO: add one-time construction code here - -} - -CSetPaneSizeDoc::~CSetPaneSizeDoc() -{ -} - -BOOL CSetPaneSizeDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeDoc serialization - -void CSetPaneSizeDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeDoc diagnostics - -#ifdef _DEBUG -void CSetPaneSizeDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CSetPaneSizeDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeDoc.h deleted file mode 100644 index 06a08da45d204..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CSetPaneSizeDoc : public CDocument -{ -protected: // create from serialization only - CSetPaneSizeDoc(); - DECLARE_DYNCREATE(CSetPaneSizeDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CSetPaneSizeDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeView.cpp deleted file mode 100644 index c4d7abc0604ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeView.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "SetPaneSize.h" - -#include "SetPaneSizeDoc.h" -#include "SetPaneSizeView.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeView - -IMPLEMENT_DYNCREATE(CSetPaneSizeView, CFormView) - -BEGIN_MESSAGE_MAP(CSetPaneSizeView, CFormView) - ON_BN_CLICKED(IDC_BUTTON_SET_DLGBAR_SIZE, OnButtonSetDlgBarSize) - ON_BN_CLICKED(IDC_BUTTON_SET_CONTAINER_SIZE, OnButtonSetContainerSize) - ON_BN_CLICKED(IDC_BTN_SET_HEIGHT_IN_PIXELS, OnBtnSetHeightInPixels) - ON_BN_CLICKED(IDC_BTN_SET_WIDTH_IN_PIXELS, OnBtnSetWidthInPixels) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeView construction/destruction - -CSetPaneSizeView::CSetPaneSizeView() - : CFormView(CSetPaneSizeView::IDD) -{ - m_nSizePercent = 50; - m_nContainerSize = 100; - m_nHeightInPixels = 100; - m_nWidthInPixels = 100; -} - -CSetPaneSizeView::~CSetPaneSizeView() -{ -} - -void CSetPaneSizeView::DoDataExchange(CDataExchange* pDX) -{ - CFormView::DoDataExchange(pDX); - DDX_Text(pDX, IDC_EDIT_SIZE, m_nSizePercent); - DDV_MinMaxUInt(pDX, m_nSizePercent, 1, 99); - DDX_Text(pDX, IDC_EDIT_WIDTH, m_nContainerSize); - DDV_MinMaxUInt(pDX, m_nContainerSize, 1, 2056); - DDX_Text(pDX, IDC_EDIT_HEIGHT_IN_PIXELS, m_nHeightInPixels); - DDV_MinMaxUInt(pDX, m_nHeightInPixels, 1, 2056); - DDX_Text(pDX, IDC_EDIT_WIDTH_IN_PIXELS, m_nWidthInPixels); - DDV_MinMaxUInt(pDX, m_nWidthInPixels, 1, 2056); -} - -BOOL CSetPaneSizeView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CFormView::PreCreateWindow(cs); -} - -void CSetPaneSizeView::OnInitialUpdate() -{ - // There is only one view ever, so it only needs to do the initial - // update once--otherwise the application is resized needlessly. - static BOOL bUpdatedOnce = FALSE; - if (bUpdatedOnce) - return; - bUpdatedOnce = TRUE; - - CFormView::OnInitialUpdate(); - GetParentFrame()->RecalcLayout(); - ResizeParentToFit(); - -} - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeView printing - -void CSetPaneSizeView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CSetPaneSizeView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CSetPaneSizeView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CSetPaneSizeView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CSetPaneSizeView::OnPrint(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add customized printing code here -} - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeView diagnostics - -#ifdef _DEBUG -void CSetPaneSizeView::AssertValid() const -{ - CFormView::AssertValid(); -} - -void CSetPaneSizeView::Dump(CDumpContext& dc) const -{ - CFormView::Dump(dc); -} - -CSetPaneSizeDoc* CSetPaneSizeView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSetPaneSizeDoc))); - return (CSetPaneSizeDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CSetPaneSizeView message handlers - -void CSetPaneSizeView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - -void CSetPaneSizeView::OnButtonSetDlgBarSize() -{ - UpdateData (); - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST (CMainFrame, GetTopLevelFrame()); - if (pMainFrame != NULL) - { - pMainFrame->SetDlgBarSizeInContainer (m_nSizePercent); - } -} - -void CSetPaneSizeView::OnButtonSetContainerSize() -{ - UpdateData (); - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST (CMainFrame, GetTopLevelFrame()); - if (pMainFrame != NULL) - { - pMainFrame->SetContainerSize (m_nContainerSize); - } -} - -void CSetPaneSizeView::OnBtnSetHeightInPixels() -{ - UpdateData (); - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST (CMainFrame, GetTopLevelFrame()); - if (pMainFrame != NULL) - { - pMainFrame->SetDlgBarHeightInPixels (m_nHeightInPixels); - } -} - -void CSetPaneSizeView::OnBtnSetWidthInPixels() -{ - UpdateData (); - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST (CMainFrame, GetTopLevelFrame()); - if (pMainFrame != NULL) - { - pMainFrame->SetDlgBarWidthInPixels (m_nWidthInPixels); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeView.h deleted file mode 100644 index a53b9d12c6691..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/SetPaneSizeView.h +++ /dev/null @@ -1,66 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CSetPaneSizeView : public CFormView -{ -protected: // create from serialization only - CSetPaneSizeView(); - DECLARE_DYNCREATE(CSetPaneSizeView) - -public: - enum { IDD = IDD_SetPaneSize_FORM }; - UINT m_nSizePercent; - UINT m_nContainerSize; - UINT m_nHeightInPixels; - UINT m_nWidthInPixels; - -// Attributes -public: - CSetPaneSizeDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnInitialUpdate(); // called first time after construct - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CSetPaneSizeView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnButtonSetDlgBarSize(); - afx_msg void OnButtonSetContainerSize(); - afx_msg void OnBtnSetHeightInPixels(); - afx_msg void OnBtnSetWidthInPixels(); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in SetPaneSizeView.cpp -inline CSetPaneSizeDoc* CSetPaneSizeView::GetDocument() - { return (CSetPaneSizeDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/Snippets.txt deleted file mode 100644 index d643d8f415438..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/Snippets.txt +++ /dev/null @@ -1,7 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp 1 -MainFrm.h: CPaneDialog 2 -MainFrm.cpp: CPaneDialog 3 -MainFrm.cpp: CMultiPaneFrameWnd 4 -MainFrm.cpp: CPaneContainerManager 5 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/StdAfx.cpp deleted file mode 100644 index 69fa92f6e769f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// SetPaneSize.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/StdAfx.h deleted file mode 100644 index b9ac5b6aa9842..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/StdAfx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/WorkspaceBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/WorkspaceBar.cpp deleted file mode 100644 index f63bef87bd19a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/WorkspaceBar.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "SetPaneSize.h" -#include "WorkspaceBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int nBorderSize = 1; - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar - -BEGIN_MESSAGE_MAP(CWorkspaceBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_PAINT() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar construction/destruction - -CWorkspaceBar::CWorkspaceBar() -{ - // TODO: add one-time construction code here - -} - -CWorkspaceBar::~CWorkspaceBar() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar message handlers - -int CWorkspaceBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty (); - - // Create tree windows. - // TODO: create your own tab windows here: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | - TVS_LINESATROOT | TVS_HASBUTTONS; - - if (!m_wndTree.Create (dwViewStyle, rectDummy, this, 1)) - { - TRACE0("Failed to create workspace view\n"); - return -1; // fail to create - } - - // Setup trees content: - HTREEITEM hRoot1 = m_wndTree.InsertItem (_T("Root 1")); - m_wndTree.InsertItem (_T("Item 1"), hRoot1); - m_wndTree.InsertItem (_T("Item 2"), hRoot1); - - return 0; -} - -void CWorkspaceBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - // Tab control should cover a whole client area: - m_wndTree.SetWindowPos (NULL, nBorderSize, nBorderSize, - cx - 2 * nBorderSize, cy - 2 * nBorderSize, - SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CWorkspaceBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndTree.GetWindowRect (rectTree); - ScreenToClient (rectTree); - - rectTree.InflateRect (nBorderSize, nBorderSize); - dc.Draw3dRect (rectTree, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DSHADOW)); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/WorkspaceBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/WorkspaceBar.h deleted file mode 100644 index 7c0f8d075289f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/WorkspaceBar.h +++ /dev/null @@ -1,37 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CWorkspaceBar : public CDockablePane -{ -public: - CWorkspaceBar(); - -// Attributes -protected: - CTreeCtrl m_wndTree; - -// Operations -public: - -// Overrides - -// Implementation -public: - virtual ~CWorkspaceBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnPaint(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSize.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSize.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSize.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSize.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSize.rc2 deleted file mode 100644 index cbe33e02ac48b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSize.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// SetPaneSize.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSizeDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSizeDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/SetPaneSizeDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/workspace.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/workspace.bmp deleted file mode 100644 index 45722b67f4456..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/res/workspace.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/resource.h deleted file mode 100644 index 83f5f55c7c7af..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/resource.h +++ /dev/null @@ -1,40 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by SetPaneSize.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDD_SetPaneSize_FORM 101 -#define IDS_MAIN_TOOLBAR 101 -#define IDR_MAINFRAME 128 -#define IDR_SETBARTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDB_WORKSPACE 147 -#define IDB_TOOLBAR256 151 -#define IDD_DLG_BAR 154 -#define IDD_ABOUTBOX 999 -#define IDC_COMPANY_URL 1041 -#define IDC_EDIT_SIZE 1042 -#define IDC_EDIT_WIDTH 1043 -#define IDC_BUTTON_SET_DLGBAR_SIZE 1044 -#define IDC_BUTTON_SET_CONTAINER_SIZE 1045 -#define IDC_EDIT_WIDTH_IN_PIXELS 1047 -#define IDC_EDIT_HEIGHT_IN_PIXELS 1048 -#define IDC_BTN_SET_WIDTH_IN_PIXELS 1049 -#define IDC_BTN_SET_HEIGHT_IN_PIXELS 1050 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_DLGBAR 32792 -#define ID_VIEW_WORKSPACE 32803 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 155 -#define _APS_NEXT_COMMAND_VALUE 32833 -#define _APS_NEXT_CONTROL_VALUE 1051 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/setpanesize.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/setpanesize.vcxproj deleted file mode 100644 index c8a98d3659026..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/setpanesize.vcxproj +++ /dev/null @@ -1,262 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2CA41BD5-0344-4492-BB00-CF3335804E71} - SetPaneSize - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/SetPaneSize.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/SetPaneSize.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/SetPaneSize.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/SetPaneSize.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_SetPaneSize/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/MainFrm.cpp deleted file mode 100644 index 160dba771ac8d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/MainFrm.cpp +++ /dev/null @@ -1,252 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Slider.h" -#include "SliderButton.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) - ON_WM_CREATE() - ON_WM_CLOSE() - ON_COMMAND(ID_SLIDER, OnSlider) - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - CMFCToolBar::EnableQuickCustomization (); - - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWndEx::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - // - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */); - - CSliderButton btnSlider (ID_SLIDER); - btnSlider.SetRange (0, 100); - - pDlgCust->AddButton (_T("Edit"), btnSlider); - // - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - if (uiToolBarId == IDR_MAINFRAME) - { - CSliderButton btnSlider (ID_SLIDER); - btnSlider.SetRange (0, 100); - - m_wndToolBar.ReplaceButton (ID_SLIDER, btnSlider); - } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWndEx::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnSlider() -{ - if (GetAsyncKeyState (VK_LBUTTON) == 0) - { - CString str; - str.Format (_T("Moved to: %d"), CSliderButton::GetPos (ID_SLIDER)); - - AfxMessageBox (str); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/MainFrm.h deleted file mode 100644 index e6e9e6d3ec074..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/MainFrm.h +++ /dev/null @@ -1,52 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CMainFrame : public CFrameWndEx -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSlider(); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/ReadMe.htm deleted file mode 100644 index effb6bd962fb6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/ReadMe.htm +++ /dev/null @@ -1,123 +0,0 @@ - - - - Slider Sample: MFC Toolbar Slider Application - - -

- Slider Sample: MFC Toolbar Slider Application

-
-
-
- -

-

-
-

- The Slider sample demonstrates how to implement a toolbar button that hosts an external - control.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the Slider sample

-
-
    -
  1. -

    - Open the solution file Slider.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The Slider sample demonstrates the following keywords:

-

- CFrameWndEx; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; CMFCToolBar; CMFCToolBarButton; - CMFCToolBarImages; CMFCToolBarsCustomizeDialog; CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.cpp deleted file mode 100644 index 558ad743ceb5a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Slider.h" - -#include "MainFrm.h" -#include "SliderDoc.h" -#include "SliderView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSliderApp - -BEGIN_MESSAGE_MAP(CSliderApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSliderApp construction - -CSliderApp::CSliderApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CSliderApp object - -CSliderApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CSliderApp initialization - -BOOL CSliderApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CSliderDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CSliderView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CSliderApp message handlers - -int CSliderApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CSliderApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CSliderApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.h deleted file mode 100644 index 2271bf683ab18..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CSliderApp: -// See Slider.cpp for the implementation of this class -// - -class CSliderApp : public CWinAppEx -{ -public: - CSliderApp(); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CSliderApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.rc deleted file mode 100644 index 07c74bab35ea0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Slider.rc +++ /dev/null @@ -1,418 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\Slider.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\Slider.ico" -IDR_SLIDERTYPE ICON DISCARDABLE "res\\SliderDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_SLIDER - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About Slider...", ID_APP_ABOUT - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About Slider" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "Slider Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "Slider MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "Slider\0" - VALUE "LegalCopyright", "Copyright (C) 2001\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "Slider.EXE\0" - VALUE "ProductName", "Slider Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN -END -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "Slider\n\nSlider\n\n\nSlider.Document\nSlider Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "Slider" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_SLIDER "Slider\nSlider" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\Slider.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderButton.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderButton.cpp deleted file mode 100644 index b424eb7b3649a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderButton.cpp +++ /dev/null @@ -1,352 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "SliderButton.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -IMPLEMENT_SERIAL(CSliderButton, CMFCToolBarButton, 1) - -static const int nDefaultWidth = 150; -static const int nDefaultHeight = 25; - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#pragma warning (disable : 4355) - -CSliderButton::CSliderButton() : - m_wndSlider (*this) -{ - m_dwStyle = WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_NOTICKS; - m_iWidth = nDefaultWidth; - m_nMin = 0; - m_nMax = 0; - m_nValue = 0; -} -//************************************************************************************** -CSliderButton::CSliderButton (UINT uiId, - int iImage, - DWORD dwStyle, - int iWidth) : - CMFCToolBarButton (uiId, iImage), - m_wndSlider (*this) -{ - m_dwStyle = dwStyle | WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_NOTICKS; - m_iWidth = (iWidth == 0) ? nDefaultWidth : iWidth; - m_nMin = 0; - m_nMax = 0; - m_nValue = 0; -} - -#pragma warning (default : 4355) - -//************************************************************************************** -CSliderButton::~CSliderButton() -{ - if (m_wndSlider.GetSafeHwnd () != NULL) - { - m_wndSlider.DestroyWindow (); - } -} -//************************************************************************************** -SIZE CSliderButton::OnCalculateSize (CDC* /*pDC*/, const CSize& /*sizeDefault*/, BOOL bHorz) -{ - if (!IsVisible ()) - { - if (m_wndSlider.GetSafeHwnd () != NULL) - { - m_wndSlider.ShowWindow (SW_HIDE); - } - - return CSize (0,0); - } - - if (bHorz) - { - if (m_wndSlider.GetSafeHwnd () != NULL && !IsHidden ()) - { - m_wndSlider.ShowWindow (SW_SHOWNOACTIVATE); - m_wndSlider.ModifyStyle (TBS_VERT, TBS_HORZ); - } - - return CSize (m_iWidth, nDefaultHeight); - } - else - { - if (m_wndSlider.GetSafeHwnd () != NULL && !IsHidden ()) - { - m_wndSlider.ShowWindow (SW_SHOWNOACTIVATE); - m_wndSlider.ModifyStyle (TBS_HORZ, TBS_VERT); - } - - return CSize (nDefaultHeight, m_iWidth); - } -} -//************************************************************************************** -void CSliderButton::Serialize(CArchive& ar) -{ - CMFCToolBarButton::Serialize (ar); - - if (ar.IsLoading ()) - { - ar >> m_iWidth; - ar >> m_dwStyle; - - int nMin; - int nMax; - int nValue; - - ar >> nMin; - ar >> nMax; - ar >> nValue; - - SetRange (nMin, nMax); - SetValue (nValue, FALSE); - } - else - { - ar << m_iWidth; - ar << m_dwStyle; - ar << m_nMin; - ar << m_nMax; - ar << m_nValue; - } -} -//************************************************************************************** -void CSliderButton::OnMove () -{ - if (m_wndSlider.GetSafeHwnd () != NULL && - (m_wndSlider.GetStyle () & WS_VISIBLE)) - { - m_wndSlider.SetWindowPos (NULL, - m_rect.left + 1, m_rect.top + 1, m_rect.Width () - 2, m_rect.Height () - 2, - SWP_NOZORDER | SWP_NOACTIVATE); - } -} -//************************************************************************************** -void CSliderButton::OnSize (int iSize) -{ - m_iWidth = iSize; - m_rect.right = m_rect.left + m_iWidth; - - if (m_wndSlider.GetSafeHwnd () != NULL && - (m_wndSlider.GetStyle () & WS_VISIBLE)) - { - m_wndSlider.SetWindowPos (NULL, - m_rect.left + 1, m_rect.top + 1, m_rect.Width () - 2, m_rect.Height () - 2, - SWP_NOZORDER | SWP_NOACTIVATE); - } -} -//************************************************************************************** -void CSliderButton::OnChangeParentWnd (CWnd* pWndParent) -{ - if (m_wndSlider.GetSafeHwnd () != NULL) - { - CWnd* pWndParentCurr = m_wndSlider.GetParent (); - ASSERT (pWndParentCurr != NULL); - - if (pWndParent != NULL && pWndParentCurr != NULL && - pWndParentCurr->GetSafeHwnd () == pWndParent->GetSafeHwnd ()) - { - return; - } - - m_wndSlider.DestroyWindow (); - } - - if (pWndParent == NULL || pWndParent->GetSafeHwnd () == NULL) - { - return; - } - - if (!m_wndSlider.Create (m_dwStyle, m_rect, pWndParent, m_nID)) - { - ASSERT (FALSE); - return; - } - - m_wndSlider.SetRange (m_nMin, m_nMax); - m_wndSlider.SetPos (m_nValue); - m_wndSlider.SetOwner (pWndParent->GetTopLevelFrame ()); -} -//************************************************************************************** -void CSliderButton::CopyFrom (const CMFCToolBarButton& s) -{ - CMFCToolBarButton::CopyFrom (s); - - const CSliderButton& src = (const CSliderButton&) s; - - m_dwStyle = src.m_dwStyle; - m_iWidth = src.m_iWidth; - m_nMin = src.m_nMin; - m_nMax = src.m_nMax; - m_nValue = src.m_nValue; -} -//************************************************************************************ -void CSliderButton::SetRange (int iMin, int iMax) -{ - m_nMin = iMin; - m_nMax = iMax; - - if (m_wndSlider.GetSafeHwnd () != NULL) - { - m_wndSlider.SetRange (iMin, iMax, TRUE); - } - - CObList listButtons; - if (CMFCToolBar::GetCommandButtons (m_nID, listButtons) > 0) - { - for (POSITION pos = listButtons.GetHeadPosition (); pos != NULL;) - { - CSliderButton* pSlider = DYNAMIC_DOWNCAST (CSliderButton, - listButtons.GetNext (pos)); - if (pSlider != NULL && pSlider != this) - { - pSlider->m_nMin = iMin; - pSlider->m_nMax = iMax; - - if (pSlider->m_wndSlider.GetSafeHwnd () != NULL) - { - pSlider->m_wndSlider.SetRange (iMin, iMax, TRUE); - } - } - } - } -} -//************************************************************************************ -void CSliderButton::SetValue (int iValue, BOOL bNotify) -{ - m_nValue = iValue; - if (GetHwnd () != NULL) - { - m_wndSlider.SetPos (iValue); - } - - CObList listButtons; - if (CMFCToolBar::GetCommandButtons (m_nID, listButtons) > 0) - { - for (POSITION pos = listButtons.GetHeadPosition (); pos != NULL;) - { - CSliderButton* pSlider = DYNAMIC_DOWNCAST (CSliderButton, - listButtons.GetNext (pos)); - if (pSlider != NULL && pSlider != this) - { - pSlider->m_nValue = iValue; - - if (pSlider->GetHwnd () != NULL) - { - pSlider->m_wndSlider.SetPos (iValue); - } - } - } - } - - if (bNotify && m_wndSlider.GetSafeHwnd () != NULL) - { - m_wndSlider.GetOwner ()->SendMessage (WM_COMMAND, m_nID); - } -} -//************************************************************************************ -int CSliderButton::GetPos (UINT uiCmd) -{ - CObList listButtons; - if (CMFCToolBar::GetCommandButtons (uiCmd, listButtons) > 0) - { - for (POSITION pos = listButtons.GetHeadPosition (); pos != NULL;) - { - CSliderButton* pSlider = DYNAMIC_DOWNCAST (CSliderButton, - listButtons.GetNext (pos)); - if (pSlider != NULL && pSlider->GetHwnd () != NULL) - { - return pSlider->m_wndSlider.GetPos (); - } - } - } - - return -1; -} -//**************************************************************************************** -void CSliderButton::OnShow (BOOL bShow) -{ - if (m_wndSlider.GetSafeHwnd () != NULL) - { - if (bShow) - { - m_wndSlider.ShowWindow (SW_SHOWNOACTIVATE); - OnMove (); - } - else - { - m_wndSlider.ShowWindow (SW_HIDE); - } - } -} - -///////////////////////////////////////////////////////////////////////////// -// CCustomSliderCtrl - -CCustomSliderCtrl::CCustomSliderCtrl(CSliderButton& btnSlider) : - m_btnSlider (btnSlider) -{ -} - -CCustomSliderCtrl::~CCustomSliderCtrl() -{ -} - - -BEGIN_MESSAGE_MAP(CCustomSliderCtrl, CSliderCtrl) - ON_WM_MOUSEMOVE() - ON_WM_KEYDOWN() - ON_WM_LBUTTONUP() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCustomSliderCtrl message handlers - -void CCustomSliderCtrl::OnMouseMove(UINT nFlags, CPoint point) -{ - int nPos = GetPos (); - - CSliderCtrl::OnMouseMove(nFlags, point); - - if ((nFlags & MK_LBUTTON) && GetPos () != nPos) - { - m_btnSlider.SetValue (GetPos (), TRUE); - } -} - -void CCustomSliderCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) -{ - int nPos = GetPos (); - - CSliderCtrl::OnKeyDown(nChar, nRepCnt, nFlags); - - if (GetPos () != nPos) - { - m_btnSlider.SetValue (GetPos (), TRUE); - } -} - -void CCustomSliderCtrl::OnLButtonUp(UINT nFlags, CPoint point) -{ - CSliderCtrl::OnLButtonUp(nFlags, point); - if (IsWindowVisible ()) - { - m_btnSlider.SetValue (GetPos (), TRUE); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderButton.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderButton.h deleted file mode 100644 index d269978c246a9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderButton.h +++ /dev/null @@ -1,99 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CCustomSliderCtrl window - -class CSliderButton; - -class CCustomSliderCtrl : public CSliderCtrl -{ -// Construction -public: - CCustomSliderCtrl(CSliderButton& btnSlider); - -// Attributes -public: - CSliderButton& m_btnSlider; - -// Operations -public: -// Overrides - -// Implementation -public: - virtual ~CCustomSliderCtrl(); - -protected: - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -class CSliderButton : public CMFCToolBarButton -{ - DECLARE_SERIAL(CSliderButton) - -public: - CSliderButton(); - CSliderButton (UINT uiId, - int iImage = -1, - DWORD dwStyle = 0, - int iWidth = 0); - - virtual ~CSliderButton(); - - void SetRange (int iMin, int iMax); - void SetValue (int iValue, BOOL bNotify = TRUE); - - static int GetPos (UINT uiCmd); - -// Overrides: - virtual void Serialize(CArchive& ar); - virtual void CopyFrom (const CMFCToolBarButton& src); - virtual SIZE OnCalculateSize (CDC* pDC, const CSize& sizeDefault, BOOL bHorz); - virtual void OnShow (BOOL bShow); - virtual void OnChangeParentWnd (CWnd* pWndParent); - virtual void OnMove (); - virtual void OnSize (int iSize); - virtual HWND GetHwnd () - { - return m_wndSlider.GetSafeHwnd (); - } - - virtual BOOL CanBeStretched () const - { - return TRUE; - } - - virtual BOOL HaveHotBorder () const - { - return FALSE; - } - - virtual void OnDraw (CDC* /*pDC*/, const CRect& /*rect*/, CMFCToolBarImages* /*pImages*/, - BOOL /*bHorz*/ = TRUE, BOOL /*bCustomizeMode*/ = FALSE, - BOOL /*bHighlight*/ = FALSE, - BOOL /*bDrawBorder*/ = TRUE, - BOOL /*bGrayDisabledButtons*/ = TRUE) {} -// Attributes: -public: - CCustomSliderCtrl m_wndSlider; - int m_iWidth; - DWORD m_dwStyle; - int m_nMin; - int m_nMax; - int m_nValue; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderDoc.cpp deleted file mode 100644 index e9d57b99901fb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Slider.h" - -#include "SliderDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSliderDoc - -IMPLEMENT_DYNCREATE(CSliderDoc, CDocument) - -BEGIN_MESSAGE_MAP(CSliderDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSliderDoc construction/destruction - -CSliderDoc::CSliderDoc() -{ - // TODO: add one-time construction code here - -} - -CSliderDoc::~CSliderDoc() -{ -} - -BOOL CSliderDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CSliderDoc serialization - -void CSliderDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CSliderDoc diagnostics - -#ifdef _DEBUG -void CSliderDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CSliderDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CSliderDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderDoc.h deleted file mode 100644 index 14817c7a21cbf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CSliderDoc : public CDocument -{ -protected: // create from serialization only - CSliderDoc(); - DECLARE_DYNCREATE(CSliderDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CSliderDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderView.cpp deleted file mode 100644 index 64f01959d62e1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderView.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "Slider.h" - -#include "SliderDoc.h" -#include "SliderView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to put an external control on a CMFCToolBar.\r\n\r\n") - _T("The following features are available:\r\n") - _T("* Change control size and location in customization mode;\r\n") - _T("* Ability to drag and drop control;\r\n") - _T("* Context synchronization between different control copies"); - -///////////////////////////////////////////////////////////////////////////// -// CSliderView - -IMPLEMENT_DYNCREATE(CSliderView, CView) - -BEGIN_MESSAGE_MAP(CSliderView, CView) - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSliderView construction/destruction - -CSliderView::CSliderView() -{ -} - -CSliderView::~CSliderView() -{ -} - -BOOL CSliderView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CSliderView drawing - -void CSliderView::OnDraw(CDC* pDC) -{ -// CSliderDoc* pDoc = GetDocument(); -// ASSERT_VALID(pDoc); - - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - pDC->FillSolidRect (rectFrame, ::GetSysColor (COLOR_INFOBK)); - - rectFrame.DeflateRect (1, 1); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - rectFrame.DeflateRect (2, 2); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - pDC->SetTextColor (::GetSysColor (COLOR_INFOTEXT)); - pDC->SetBkMode (TRANSPARENT); - - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// CSliderView printing - -void CSliderView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CSliderView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CSliderView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CSliderView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// CSliderView diagnostics - -#ifdef _DEBUG -void CSliderView::AssertValid() const -{ - CView::AssertValid(); -} - -void CSliderView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CSliderDoc* CSliderView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSliderDoc))); - return (CSliderDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CSliderView message handlers - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderView.h deleted file mode 100644 index c87d9c83b832e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/SliderView.h +++ /dev/null @@ -1,52 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CSliderView : public CView -{ -protected: // create from serialization only - CSliderView(); - DECLARE_DYNCREATE(CSliderView) - -// Attributes -public: - CSliderDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CSliderView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in SliderView.cpp -inline CSliderDoc* CSliderView::GetDocument() - { return (CSliderDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Snippets.txt deleted file mode 100644 index f2a6c451ac6be..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/Snippets.txt +++ /dev/null @@ -1,3 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp: CMFCToolBarsCustomizeDialog 1 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/StdAfx.cpp deleted file mode 100644 index 6572399c7157c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/StdAfx.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// stdafx.cpp : source file that includes just the standard includes -// Slider.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/StdAfx.h deleted file mode 100644 index 0a280f94d0a6c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/StdAfx.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Slider.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Slider.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Slider.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Slider.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Slider.rc2 deleted file mode 100644 index 35f343097d0ba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Slider.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// SLIDER.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/SliderDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/SliderDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/SliderDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Toolbar.bmp deleted file mode 100644 index fdf733faac500..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/resource.h deleted file mode 100644 index 7155ff17340e1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/resource.h +++ /dev/null @@ -1,25 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Slider.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define IDR_MAINFRAME 128 -#define IDR_SLIDERTYPE 129 -#define IDR_POPUP_TOOLBAR 131 -#define IDD_ABOUTBOX 999 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_SLIDER 32822 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 151 -#define _APS_NEXT_COMMAND_VALUE 32823 -#define _APS_NEXT_CONTROL_VALUE 1041 -#define _APS_NEXT_SYMED_VALUE 107 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/slider.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/slider.vcxproj deleted file mode 100644 index bf5df875dd780..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/slider.vcxproj +++ /dev/null @@ -1,253 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {0E3C3654-331B-4FAA-AF66-6FD515FFB562} - Slider - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/Slider.tlb - - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/Slider.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/Slider.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/Slider.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_Slider/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/MainFrm.cpp deleted file mode 100644 index 1e9b6977eb558..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/MainFrm.cpp +++ /dev/null @@ -1,339 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StateCollection.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int iMaxUserToolbars = 10; -const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; -const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_COMMAND(ID_SAVE_DEBUG_CONF, OnSaveDebugConf) - ON_COMMAND(ID_LOAD_DEBUG_CONF, OnLoadDebugConf) - ON_COMMAND(ID_SAVE_REGULAR_CONF, OnSaveRegularConf) - ON_COMMAND(ID_LOAD_REGULAR_CONF, OnLoadRegularConf) - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_COMMAND(ID_VIEW_WORKSPACE, OnViewWorkspace) - ON_UPDATE_COMMAND_UI(ID_VIEW_WORKSPACE, OnUpdateViewWorkspace) - ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput) - ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateViewOutput) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - CMFCToolBar::EnableQuickCustomization (); - - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_LOAD_DEBUG_CONF); - lstBasicCommands.AddTail (ID_LOAD_REGULAR_CONF); - lstBasicCommands.AddTail (ID_SAVE_DEBUG_CONF); - lstBasicCommands.AddTail (ID_SAVE_REGULAR_CONF); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - m_wndMenuBar.SetShowAllCommands (FALSE); - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - if (!m_wndWorkSpace.Create (_T("Workspace"), this, CSize (200, 200), - TRUE /* Has gripper */, ID_VIEW_WORKSPACE, - WS_CHILD | WS_VISIBLE | CBRS_LEFT)) - { - TRACE0("Failed to create workspace bar\n"); - return -1; // fail to create - } - - if (!m_wndOutput.Create (_T("Output"), this, CSize (150, 150), - TRUE /* Has gripper */, ID_VIEW_OUTPUT, - WS_CHILD | WS_VISIBLE | CBRS_BOTTOM)) - { - TRACE0("Failed to create output bar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY); - m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane(&m_wndWorkSpace); - DockPane(&m_wndOutput); - - // Allow user-defined toolbars operations: - InitUserToolbars (NULL, - uiFirstUserToolBarId, - uiLastUserToolBarId); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */); - - pDlgCust->EnableUserDefinedToolbars (); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnViewWorkspace() -{ - ShowPane (&m_wndWorkSpace, - !(m_wndWorkSpace.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewWorkspace(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndWorkSpace.IsVisible ()); -} - -void CMainFrame::OnViewOutput() -{ - ShowPane (&m_wndOutput, - !(m_wndOutput.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewOutput(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndOutput.IsVisible ()); -} - -void CMainFrame::OnSaveDebugConf() -{ - theApp.SaveState (this, _T ("Debug")); -} - -void CMainFrame::OnLoadDebugConf() -{ - CRect rectOld; - GetWindowRect (rectOld); - theApp.m_bLoadUserToolbars = FALSE; - SetRedraw (FALSE); - theApp.LoadState (this, _T ("Debug")); - SetRedraw (TRUE); - RedrawWindow (NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | - RDW_ERASE | RDW_ALLCHILDREN); - GetDesktopWindow ()->RedrawWindow (rectOld, NULL, RDW_INVALIDATE | RDW_UPDATENOW | - RDW_ERASE | RDW_ALLCHILDREN); -} - -void CMainFrame::OnSaveRegularConf() -{ - theApp.SaveState (this, _T ("Regular")) ; -} - -void CMainFrame::OnLoadRegularConf() -{ - CRect rectOld; - GetWindowRect (rectOld); - theApp.m_bLoadUserToolbars = FALSE; - SetRedraw (FALSE); - theApp.LoadState (this, _T ("Regular")) ; - SetRedraw (TRUE); - RedrawWindow (NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | - RDW_ERASE | RDW_ALLCHILDREN); - GetDesktopWindow ()->RedrawWindow (rectOld, NULL, RDW_INVALIDATE | RDW_UPDATENOW | - RDW_ERASE | RDW_ALLCHILDREN); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/MainFrm.h deleted file mode 100644 index 1ef5f84c2687c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/MainFrm.h +++ /dev/null @@ -1,66 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "WorkspaceBar.h" -#include "OutputBar.h" - -#define CFrameWnd CFrameWndEx - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - CWorkspaceBar m_wndWorkSpace; - COutputBar m_wndOutput; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSaveDebugConf(); - afx_msg void OnLoadDebugConf(); - afx_msg void OnSaveRegularConf(); - afx_msg void OnLoadRegularConf(); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnViewWorkspace(); - afx_msg void OnUpdateViewWorkspace(CCmdUI* pCmdUI); - afx_msg void OnViewOutput(); - afx_msg void OnUpdateViewOutput(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/OutputBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/OutputBar.cpp deleted file mode 100644 index 1bd6ed89677d7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/OutputBar.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StateCollection.h" -#include "OutputBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutputBar - -BEGIN_MESSAGE_MAP(COutputBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutputBar construction/destruction - -COutputBar::COutputBar() -{ - // TODO: add one-time construction code here - -} - -COutputBar::~COutputBar() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// COutputBar message handlers - -int COutputBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty (); - - // - // Create tabs window: - // CRect rectDummy - // this is a pointer to a parent window - // fourth parameter is the id of the tab control - if (!m_wndTabs.Create (CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1)) - { - TRACE0("Failed to create output tab window\n"); - return -1; // fail to create - } - // - - // Create tree windows. - // TODO: create your own tab windows here: - const DWORD dwViewStyle = - LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; - - if (!m_wndList1.Create (dwViewStyle, rectDummy, &m_wndTabs, 2) || - !m_wndList2.Create (dwViewStyle, rectDummy, &m_wndTabs, 3) || - !m_wndList3.Create (dwViewStyle, rectDummy, &m_wndTabs, 4)) - { - TRACE0("Failed to create output view\n"); - return -1; // fail to create - } - - // - // Attach list windows to tab: - // CListCtrl m_wndList1 - // CListCtrl m_wndList2 - // CListCtrl m_wndList3 - m_wndTabs.AddTab (&m_wndList1, _T("Output 1"), (UINT)-1); - m_wndTabs.AddTab (&m_wndList2, _T("Output 2"), (UINT)-1); - m_wndTabs.AddTab (&m_wndList3, _T("Output 3"), (UINT)-1); - - m_wndTabs.EnableActiveTabCloseButton(); - m_wndTabs.EnableInPlaceEdit(true); - m_wndTabs.EnableTabDocumentsMenu(); - m_wndTabs.SetActiveTab(1); - m_wndTabs.SetDrawFrame(); - m_wndTabs.SetFlatFrame(); - // - - - return 0; -} - -void COutputBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - // Tab control should cover a whole client area: - m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, - SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/OutputBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/OutputBar.h deleted file mode 100644 index f9f25508dd109..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/OutputBar.h +++ /dev/null @@ -1,42 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class COutputBar : public CDockablePane -{ -public: - COutputBar(); - -// Attributes -protected: - // - CMFCTabCtrl m_wndTabs; - // - - CListCtrl m_wndList1; - CListCtrl m_wndList2; - CListCtrl m_wndList3; - -// Operations -public: - -// Overrides - -// Implementation -public: - virtual ~COutputBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/ReadMe.htm deleted file mode 100644 index 8d68d7b8ce9f2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/ReadMe.htm +++ /dev/null @@ -1,123 +0,0 @@ - - - - StateCollection Sample: MFC Toolbar Collection Application - - -

- StateCollection Sample: MFC Toolbar Collection Application

-
-
-
- -

-

-
-

- The StateCollection sample demonstrates how to implement an application that saves - and loads different states for the menu bar, toolbars, and docking windows.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the StateCollection sample

-
-
    -
  1. -

    - Open the solution file StateCollection.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The StateCollection sample demonstrates the following keywords:

-

- CDockablePane; CFrameWndEx; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; CMFCTabCtrl; - CMFCToolBar; CMFCToolBarsCustomizeDialog; CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/Snippets.txt deleted file mode 100644 index 82209cccb054e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/Snippets.txt +++ /dev/null @@ -1,6 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -OutputBar.h: CMFCTabCtrl 1 -OuputBar.cpp: CMFCTabCtrl 2 -OutputBar.cpp: CMFCTabCtrl 3 -StateCollection.cpp: CMouseManager 4 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.cpp deleted file mode 100644 index b909fecc50218..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StateCollection.h" - -#include "MainFrm.h" -#include "StateCollectionDoc.h" -#include "StateCollectionView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionApp - -BEGIN_MESSAGE_MAP(CStateCollectionApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionApp construction - -CStateCollectionApp::CStateCollectionApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CStateCollectionApp object - -CStateCollectionApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionApp initialization - -BOOL CStateCollectionApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitMouseManager(); - InitContextMenuManager(); - InitKeyboardManager(); - - // Enable user-defined tools. If you want allow more than 10 tools, - // add tools entry to resources (ID_USER_TOOL11, ID_USER_TOOL12,...) - EnableUserTools (ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CStateCollectionDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CStateCollectionView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - LoadCustomState (); - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionApp message handlers - -int CStateCollectionApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void CStateCollectionApp::PreLoadState () -{ - // - GetMouseManager()->AddView (IDR_MAINFRAME, _T("My view"), IDR_MAINFRAME); - // - - // TODO: add another views and windows were mouse double click - // customization is required - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CStateCollectionApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.h deleted file mode 100644 index 8d6e768230ac8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.h +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionApp: -// See StateCollection.cpp for the implementation of this class -// - -class CStateCollectionApp : public CWinAppEx -{ -public: - CStateCollectionApp(); - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CStateCollectionApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.rc deleted file mode 100644 index 281884afdf6f0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollection.rc +++ /dev/null @@ -1,472 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\StateCollection.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\StateCollection.ico" -IDR_STATECTYPE ICON DISCARDABLE "res\\StateCollectionDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_WORKSPACE BITMAP DISCARDABLE "res\\workspace.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "Project" - BEGIN - MENUITEM "&Save Debug", ID_SAVE_DEBUG_CONF - MENUITEM "Save &Regular", ID_SAVE_REGULAR_CONF - MENUITEM "Load Debug", ID_LOAD_DEBUG_CONF - MENUITEM "Load R&egular", ID_LOAD_REGULAR_CONF - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Tools" - BEGIN - MENUITEM "&", ID_TOOLS_ENTRY - END - POPUP "&Help" - BEGIN - MENUITEM "&About StateCollection...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Workspace", ID_VIEW_WORKSPACE - MENUITEM "&Output", ID_VIEW_OUTPUT - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About StateCollection" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "StateCollection Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "StateCollection MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "StateCollection\0" - VALUE "LegalCopyright", "Copyright (C) 2001\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "StateCollection.EXE\0" - VALUE "ProductName", "StateCollection Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN -END -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "StateCollection\n\nStateC\n\n\nStateCollection.Document\nStateC Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "StateCollection" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_WORKSPACE "Show or hide the workspace bar\nToggle Workspace" - ID_VIEW_OUTPUT "Show or hide the output bar\nToggle Output" - ID_TOOLS_ENTRY "User-defined tools\nUser Tools" - ID_USER_TOOL1 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL2 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL3 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL4 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL5 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL6 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL7 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL8 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL9 "Activates user-defined tool\nUser Tool" - ID_USER_TOOL10 "Activates user-defined tool\nUser Tool" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_SAVE_DEBUG_CONF "Saves 'Debug' configuration\nSave configuration" - ID_SAVE_REGULAR_CONF "Saves 'Regular' configuration\nSave configuration" - ID_LOAD_DEBUG_CONF "Loads 'Debug' configuration\nLoad configuration" - ID_LOAD_REGULAR_CONF "Loads 'Regular' configuration\nLoad configuration" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\StateCollection.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionDoc.cpp deleted file mode 100644 index f6b528d0de90b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StateCollection.h" - -#include "StateCollectionDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionDoc - -IMPLEMENT_DYNCREATE(CStateCollectionDoc, CDocument) - -BEGIN_MESSAGE_MAP(CStateCollectionDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionDoc construction/destruction - -CStateCollectionDoc::CStateCollectionDoc() -{ - // TODO: add one-time construction code here - -} - -CStateCollectionDoc::~CStateCollectionDoc() -{ -} - -BOOL CStateCollectionDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionDoc serialization - -void CStateCollectionDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionDoc diagnostics - -#ifdef _DEBUG -void CStateCollectionDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CStateCollectionDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionDoc.h deleted file mode 100644 index b020674102b64..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CStateCollectionDoc : public CDocument -{ -protected: // create from serialization only - CStateCollectionDoc(); - DECLARE_DYNCREATE(CStateCollectionDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CStateCollectionDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionView.cpp deleted file mode 100644 index 24f998c625e69..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionView.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StateCollection.h" - -#include "StateCollectionDoc.h" -#include "StateCollectionView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to save/load the current configuration on the fly.\r\n") - _T("You can configure two 'environments' - Regular and Debug.\r\n") - _T("Just customize the toolbar/menu/docking bars and select 'Project|Save Debug' or 'Project|Save Regular'.\r\n") - _T("When you want to switch between configurations select 'Project|Load Debug' or 'Project|Load Regular'.\r\n") - _T("When the application is starting up, it loads the default configuration.\r\n\r\n") - _T("You can combine this code with the 'StateToFile' example for greater flexibility.\r\n") - _T("In this way you can export/import the desired configurations/profiles on the fly.\r\n") - _T("Note the use of CWinAppEx::LoadState/SaveState."); - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionView - -IMPLEMENT_DYNCREATE(CStateCollectionView, CView) - -BEGIN_MESSAGE_MAP(CStateCollectionView, CView) - ON_WM_LBUTTONDBLCLK() - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionView construction/destruction - -CStateCollectionView::CStateCollectionView() -{ - // TODO: add construction code here - -} - -CStateCollectionView::~CStateCollectionView() -{ -} - -BOOL CStateCollectionView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionView drawing - -void CStateCollectionView::OnDraw(CDC* pDC) -{ -// CStateCollectionDoc* pDoc = GetDocument(); -// ASSERT_VALID(pDoc); - - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - pDC->FillSolidRect (rectFrame, ::GetSysColor (COLOR_INFOBK)); - - rectFrame.DeflateRect (1, 1); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - rectFrame.DeflateRect (2, 2); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - pDC->SetTextColor (::GetSysColor (COLOR_INFOTEXT)); - pDC->SetBkMode (TRANSPARENT); - - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionView printing - -void CStateCollectionView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CStateCollectionView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CStateCollectionView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CStateCollectionView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionView diagnostics - -#ifdef _DEBUG -void CStateCollectionView::AssertValid() const -{ - CView::AssertValid(); -} - -void CStateCollectionView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CStateCollectionDoc* CStateCollectionView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStateCollectionDoc))); - return (CStateCollectionDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CStateCollectionView message handlers - -void CStateCollectionView::OnLButtonDblClk(UINT /*nFlags*/, CPoint /*point*/) -{ - theApp.OnViewDoubleClick (this, IDR_MAINFRAME); -} - -void CStateCollectionView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionView.h deleted file mode 100644 index 80a7d0d4c75b7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StateCollectionView.h +++ /dev/null @@ -1,54 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CStateCollectionView : public CView -{ -protected: // create from serialization only - CStateCollectionView(); - DECLARE_DYNCREATE(CStateCollectionView) - -// Attributes -public: - CStateCollectionDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CStateCollectionView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in StateCollectionView.cpp -inline CStateCollectionDoc* CStateCollectionView::GetDocument() - { return (CStateCollectionDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StdAfx.cpp deleted file mode 100644 index c4cd876137b65..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// StateCollection.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StdAfx.h deleted file mode 100644 index b9ac5b6aa9842..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/StdAfx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/WorkspaceBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/WorkspaceBar.cpp deleted file mode 100644 index 63bd3127dd5b7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/WorkspaceBar.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StateCollection.h" -#include "WorkspaceBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar - -BEGIN_MESSAGE_MAP(CWorkspaceBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar construction/destruction - -CWorkspaceBar::CWorkspaceBar() -{ - // TODO: add one-time construction code here - -} - -CWorkspaceBar::~CWorkspaceBar() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar message handlers - -int CWorkspaceBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty (); - - // Create tabs window: - if (!m_wndTabs.Create (CMFCTabCtrl::STYLE_3D, rectDummy, this, 1)) - { - TRACE0("Failed to create workspace tab window\n"); - return -1; // fail to create - } - - m_wndTabs.SetImageList (IDB_WORKSPACE, 16, RGB (255, 0, 255)); - - // Create tree windows. - // TODO: create your own tab windows here: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | - TVS_LINESATROOT | TVS_HASBUTTONS; - - if (!m_wndTree1.Create (dwViewStyle, rectDummy, &m_wndTabs, 2) || - !m_wndTree2.Create (dwViewStyle, rectDummy, &m_wndTabs, 3)) - { - TRACE0("Failed to create workspace view\n"); - return -1; // fail to create - } - - // Setup trees content: - HTREEITEM hRoot1 = m_wndTree1.InsertItem (_T("Root 1")); - m_wndTree1.InsertItem (_T("Item 1"), hRoot1); - m_wndTree1.InsertItem (_T("Item 2"), hRoot1); - - HTREEITEM hRoot2 = m_wndTree2.InsertItem (_T("Root 2")); - m_wndTree2.InsertItem (_T("Item 1"), hRoot2); - m_wndTree2.InsertItem (_T("Item 2"), hRoot2); - - // Attach tree windows to tab: - m_wndTabs.AddTab (&m_wndTree1, _T("First View"), 0 /* Image number */); - m_wndTabs.AddTab (&m_wndTree2, _T("Second View"), 1 /* Image number */); - - return 0; -} - -void CWorkspaceBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - // Tab control should cover a whole client area: - m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, - SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/WorkspaceBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/WorkspaceBar.h deleted file mode 100644 index b375c23d50131..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/WorkspaceBar.h +++ /dev/null @@ -1,39 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CWorkspaceBar : public CDockablePane -{ -public: - CWorkspaceBar(); - -// Attributes -protected: - CMFCTabCtrl m_wndTabs; - - CTreeCtrl m_wndTree1; - CTreeCtrl m_wndTree2; - -// Operations -public: - -// Overrides - -// Implementation -public: - virtual ~CWorkspaceBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollection.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollection.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollection.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollection.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollection.rc2 deleted file mode 100644 index 7d30da3bc99f6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollection.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// STATECOLLECTION.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollectionDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollectionDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/StateCollectionDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/workspace.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/workspace.bmp deleted file mode 100644 index 45722b67f4456..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/res/workspace.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/resource.h deleted file mode 100644 index 7c949e4199893..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/resource.h +++ /dev/null @@ -1,44 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by StateCollection.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define IDR_MAINFRAME 128 -#define IDR_STATECTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDB_WORKSPACE 147 -#define IDC_COMPANY_URL 1041 -#define IDD_ABOUTBOX 999 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_WORKSPACE 32803 -#define ID_VIEW_OUTPUT 32804 -#define ID_TOOLS_ENTRY 32805 -#define ID_USER_TOOL1 32806 -#define ID_USER_TOOL2 32807 -#define ID_USER_TOOL3 32808 -#define ID_USER_TOOL4 32809 -#define ID_USER_TOOL5 32810 -#define ID_USER_TOOL6 32811 -#define ID_USER_TOOL7 32812 -#define ID_USER_TOOL8 32813 -#define ID_USER_TOOL9 32814 -#define ID_USER_TOOL10 32815 -#define ID_SAVE_DEBUG_CONF 32822 -#define ID_SAVE_REGULAR_CONF 32823 -#define ID_LOAD_DEBUG_CONF 32824 -#define ID_LOAD_REGULAR_CONF 32825 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 153 -#define _APS_NEXT_COMMAND_VALUE 32826 -#define _APS_NEXT_CONTROL_VALUE 1042 -#define _APS_NEXT_SYMED_VALUE 107 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/statecollection.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/statecollection.vcxproj deleted file mode 100644 index 70b204813df2c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/statecollection.vcxproj +++ /dev/null @@ -1,266 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {7D33C9E4-B288-4C15-B6BA-7B05C340D586} - StateCollection - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/StateCollection.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/StateCollection.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/StateCollection.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/StateCollection.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StateCollection/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/MainFrm.cpp deleted file mode 100644 index 9e0c8821bec7f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/MainFrm.cpp +++ /dev/null @@ -1,223 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StatusBarDemo.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_INDICATOR_ICON, // status icon - ID_SEPARATOR, // status line indicator - ID_INDICATOR_PROGRESS, // progress bar - ID_INDICATOR_LABEL, // text label - ID_INDICATOR_ANIMATION, // animation pane - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - - CMFCToolBar::EnableQuickCustomization (); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - m_wndStatusBar.SetPaneStyle (nStatusIcon, SBPS_NOBORDERS); - m_wndStatusBar.SetPaneStyle (nStatusAnimation, SBPS_NOBORDERS); - m_wndStatusBar.SetPaneStyle (nStatusInfo, SBPS_STRETCH | SBPS_NOBORDERS); - m_wndStatusBar.SetPaneWidth (nStatusProgress, 80); - m_wndStatusBar.EnablePaneDoubleClick (); - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - CMFCButton::EnableWindowsTheming (); - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/MainFrm.h deleted file mode 100644 index d83a18d3fa21f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/MainFrm.h +++ /dev/null @@ -1,72 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define CFrameWnd CFrameWndEx - -//----------------- -// Statusbar panes: -//----------------- -// -// in MainFrm.h -const int nStatusIcon = 0; -const int nStatusInfo = 1; -const int nStatusProgress = 2; -const int nStatusLabel = 3; -const int nStatusAnimation = 4; -// - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -// -// in MainFrm.h -public: - CMFCStatusBar& GetStatusBar () - { - return m_wndStatusBar; - } -// - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/ReadMe.htm deleted file mode 100644 index 92dd57ccb3b91..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,123 +0,0 @@ - - - - StatusBarDemo Sample: MFC Status Bar Application - - -

- StatusBarDemo Sample: MFC Status Bar Application

-
-
-
- -

-

-
-

- The StatusBarDemo sample demonstrates how to add various advanced controls to a - status bar.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the StatusBarDemo sample

-
-
    -
  1. -

    - Open the solution file StatusBarDemo.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The StatusBarDemo sample demonstrates the following keywords:

-

- CFrameWndEx; CMFCButton; CMFCColorButton; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; - CMFCToolBar; CMFCToolBarsCustomizeDialog; CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/Snippets.txt deleted file mode 100644 index ff0e841f7e0e6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/Snippets.txt +++ /dev/null @@ -1,13 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -StatusBarDemoView.cpp 1 -StatusBarDemoView.cpp 2 -StatusBarDemoView.cpp 3 -StatusBarDemoView.cpp 4 -StatusBarDemoView.cpp 5 -MainFrm.h 6 -MainFrm.h 7 -StatusBarDemoView.h 8 -StatusBarDemoView.h 9 -StatusBarDemoView.h:CMFCColorButton 10 -StatusBarDemoView.h:CMFCColorButton 11 diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.cpp deleted file mode 100644 index f5349d175376d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StatusBarDemo.h" - -#include "MainFrm.h" -#include "StatusBarDemoDoc.h" -#include "StatusBarDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoApp - -BEGIN_MESSAGE_MAP(CStatusBarDemoApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoApp construction - -CStatusBarDemoApp::CStatusBarDemoApp() : - CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CStatusBarDemoApp object - -CStatusBarDemoApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoApp initialization - -BOOL CStatusBarDemoApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CStatusBarDemoDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CStatusBarDemoView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoApp message handlers - -int CStatusBarDemoApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void CStatusBarDemoApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CStatusBarDemoApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.h deleted file mode 100644 index bea0eea425b5b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.h +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoApp: -// See StatusBarDemo.cpp for the implementation of this class -// - -class CStatusBarDemoApp : public CWinAppEx -{ -public: - CStatusBarDemoApp(); - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CStatusBarDemoApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.rc deleted file mode 100644 index 8fc0bbf83d033..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemo.rc +++ /dev/null @@ -1,481 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\StatusBarDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\StatusBarDemo.ico" -IDR_STATUSTYPE ICON DISCARDABLE "res\\StatusBarDemoDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_ANIMATION BITMAP DISCARDABLE "res\\animation.bmp" -IDB_ICON1 BITMAP DISCARDABLE "res\\icon1.bmp" -IDB_ICON2 BITMAP DISCARDABLE "res\\icon2.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About StatusBarDemo...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About StatusBarDemo" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "StatusBarDemo Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_STATUSBARDEMO_FORM DIALOGEX 0, 0, 342, 212 -STYLE WS_CHILD -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - GROUPBOX "Statusbar Pane Progress: ",IDC_STATIC,7,7,172,79,0, - WS_EX_TRANSPARENT - LTEXT "CMFCStatusBar class provides an easy way to show progress bar in the status bar pane. Click ""Start progress"" button to see this feature in action.", - IDC_STATIC,25,22,147,37 - PUSHBUTTON "Start Progress",IDC_START_PROGRESS,23,62,62,14 - GROUPBOX "Statusbar Pane Animation: ",IDC_STATIC,7,90,172,79,0, - WS_EX_TRANSPARENT - LTEXT "CMFCStatusBar class provides an easy way to show animation in the status bar pane. Click ""Start animation"" button to see this feature in action.", - IDC_STATIC,23,107,147,37 - PUSHBUTTON "Start Animation",IDC_START_ANIMATION,23,148,62,14 - GROUPBOX "Statusbar Pane Icons: ",IDC_STATIC,186,7,149,79,0, - WS_EX_TRANSPARENT - LTEXT "Developer can assign an icon to the staus bar pane. Please choose an icon to be displayed in the status bar pane:", - IDC_STATIC,200,22,125,26 - CONTROL "Icon 1",IDC_ICON1,"Button",BS_AUTORADIOBUTTON | - WS_GROUP,220,55,36,10 - CONTROL "Icon 2",IDC_ICON2,"Button",BS_AUTORADIOBUTTON,220,66,36, - 10 - GROUPBOX "Statusbar Pane Colors: ",IDC_STATIC,184,90,151,79,0, - WS_EX_TRANSPARENT - LTEXT "You can change the status bar pane text and background colors:", - IDC_STATIC,200,107,125,19 - LTEXT "Text color:",IDC_STATIC,200,132,34,8 - PUSHBUTTON "",IDC_TEXT_COLOR,264,131,64,12 - LTEXT "Background color:",IDC_STATIC,200,151,59,8 - PUSHBUTTON "",IDC_BACK_COLOR,264,150,64,12 - GROUPBOX "Statusbar Tooltips and Mouse Events: ",IDC_STATIC,7,169, - 328,36,0,WS_EX_TRANSPARENT - LTEXT "Double-click ""Simple Text"" pane to show a message box. Move mouse cursor over the icon at the left statusbar side to see a tooltip.", - IDC_STATIC,23,182,312,16 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "StatusBarDemo MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "StatusBarDemo\0" - VALUE "LegalCopyright", "Copyright (C) 2004\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "StatusBarDemo.EXE\0" - VALUE "ProductName", "StatusBarDemo Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_STATUSBARDEMO_FORM, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 335 - VERTGUIDE, 23 - VERTGUIDE, 186 - VERTGUIDE, 200 - VERTGUIDE, 220 - VERTGUIDE, 264 - TOPMARGIN, 7 - BOTTOMMARGIN, 205 - HORZGUIDE, 22 - HORZGUIDE, 107 - HORZGUIDE, 169 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "StatusBarDemo\n\nStatus\n\n\nStatusBarDemo.Document\nStatus Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "StatusBarDemo" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" - ID_INDICATOR_ICON " " - ID_INDICATOR_PROGRESS " " - ID_INDICATOR_LABEL "Simple text" - ID_INDICATOR_ANIMATION " " -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\StatusBarDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoDoc.cpp deleted file mode 100644 index 030bcc247ca97..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StatusBarDemo.h" - -#include "StatusBarDemoDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoDoc - -IMPLEMENT_DYNCREATE(CStatusBarDemoDoc, CDocument) - -BEGIN_MESSAGE_MAP(CStatusBarDemoDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoDoc construction/destruction - -CStatusBarDemoDoc::CStatusBarDemoDoc() -{ - // TODO: add one-time construction code here - -} - -CStatusBarDemoDoc::~CStatusBarDemoDoc() -{ -} - -BOOL CStatusBarDemoDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoDoc serialization - -void CStatusBarDemoDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoDoc diagnostics - -#ifdef _DEBUG -void CStatusBarDemoDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CStatusBarDemoDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoDoc.h deleted file mode 100644 index 76af5ad3658dc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CStatusBarDemoDoc : public CDocument -{ -protected: // create from serialization only - CStatusBarDemoDoc(); - DECLARE_DYNCREATE(CStatusBarDemoDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CStatusBarDemoDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoView.cpp deleted file mode 100644 index 0af35e6ffa218..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoView.cpp +++ /dev/null @@ -1,269 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "StatusBarDemo.h" - -#include "StatusBarDemoDoc.h" -#include "StatusBarDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define ID_PROGRESS_TIMER 1 -#define PROGRESS_MAX 50 - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoView - -IMPLEMENT_DYNCREATE(CStatusBarDemoView, CFormView) - -BEGIN_MESSAGE_MAP(CStatusBarDemoView, CFormView) - ON_BN_CLICKED(IDC_START_PROGRESS, OnStartProgress) - ON_BN_CLICKED(IDC_START_ANIMATION, OnStartAnimation) - ON_BN_CLICKED(IDC_ICON1, OnIcon) - ON_BN_CLICKED(IDC_ICON2, OnIcon) - ON_BN_CLICKED(IDC_BACK_COLOR, OnBackColor) - ON_BN_CLICKED(IDC_TEXT_COLOR, OnTextColor) - ON_WM_TIMER() - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) - ON_COMMAND(ID_INDICATOR_LABEL, OnIndicatorLabel) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoView construction/destruction - -CStatusBarDemoView::CStatusBarDemoView() - : CFormView(CStatusBarDemoView::IDD) -{ - m_nIcon = 0; - - m_nProgressCurr = 0; - m_bInProgress = FALSE; - m_bInAnimation = FALSE; -} - -CStatusBarDemoView::~CStatusBarDemoView() -{ -} - -void CStatusBarDemoView::DoDataExchange(CDataExchange* pDX) -{ - CFormView::DoDataExchange(pDX); - DDX_Control(pDX, IDC_TEXT_COLOR, m_wndTextColor); - DDX_Control(pDX, IDC_BACK_COLOR, m_wndBackColor); - DDX_Control(pDX, IDC_START_ANIMATION, m_wndStartAnimation); - DDX_Control(pDX, IDC_START_PROGRESS, m_wndStartProgress); - DDX_Radio(pDX, IDC_ICON1, m_nIcon); -} - -BOOL CStatusBarDemoView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CFormView::PreCreateWindow(cs); -} - -void CStatusBarDemoView::OnInitialUpdate() -{ - // There is only one view ever, so it only needs to do the initial - // update once--otherwise the application is resized needlessly. - static BOOL bUpdatedOnce = FALSE; - if (bUpdatedOnce) - return; - bUpdatedOnce = TRUE; - - CFormView::OnInitialUpdate(); - - // - m_wndTextColor.EnableAutomaticButton (_T("Default"), afxGlobalData.clrBtnText); - m_wndTextColor.EnableOtherButton (_T("Other...")); - m_wndTextColor.SetColor ((COLORREF)-1); - m_wndTextColor.SetColorName((COLORREF)-1, "Default Color"); - m_wndTextColor.SetColumnsNumber(3); - // - - m_wndBackColor.EnableAutomaticButton (_T("Default"), afxGlobalData.clrBtnFace); - m_wndBackColor.EnableOtherButton (_T("Other...")); - m_wndBackColor.SetColor ((COLORREF)-1); - - if (m_imlStatusAnimation.GetSafeHandle () == NULL) - { - m_imlStatusAnimation.Create (IDB_ANIMATION, 16, 0, RGB (255, 0, 255)); - } - - if (m_bmpIcon1.GetSafeHandle () == NULL) - { - m_bmpIcon1.LoadBitmap (IDB_ICON1); - } - - if (m_bmpIcon2.GetSafeHandle () == NULL) - { - m_bmpIcon2.LoadBitmap (IDB_ICON2); - } - - // - // in StatusBarDemoView.cpp - GetStatusBar ().SetPaneIcon (nStatusIcon, m_bmpIcon1); - GetStatusBar ().SetTipText (nStatusIcon, _T("This is a tooltip")); - // -} - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoView printing - -void CStatusBarDemoView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CStatusBarDemoView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CStatusBarDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CStatusBarDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CStatusBarDemoView::OnPrint(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add customized printing code here -} - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoView diagnostics - -#ifdef _DEBUG -void CStatusBarDemoView::AssertValid() const -{ - CFormView::AssertValid(); -} - -void CStatusBarDemoView::Dump(CDumpContext& dc) const -{ - CFormView::Dump(dc); -} - -CStatusBarDemoDoc* CStatusBarDemoView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStatusBarDemoDoc))); - return (CStatusBarDemoDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CStatusBarDemoView message handlers - -void CStatusBarDemoView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - -void CStatusBarDemoView::OnStartProgress() -{ - if (m_bInProgress) - { - KillTimer (ID_PROGRESS_TIMER); - m_wndStartProgress.SetWindowText (_T("Start Progress")); - GetStatusBar ().EnablePaneProgressBar (nStatusProgress, -1); - - m_bInProgress = FALSE; - - return; - } - - // - GetStatusBar ().EnablePaneProgressBar (nStatusProgress, PROGRESS_MAX); - // - - m_nProgressCurr = 0; - m_bInProgress = TRUE; - - SetTimer (ID_PROGRESS_TIMER, 200, NULL); - m_wndStartProgress.SetWindowText (_T("Stop Progress")); -} - -void CStatusBarDemoView::OnStartAnimation() -{ - if (m_bInAnimation) - { - m_wndStartAnimation.SetWindowText (_T("Start Animation")); - // - GetStatusBar ().SetPaneAnimation (nStatusAnimation, NULL); - // - m_bInAnimation = FALSE; - return; - } - - // - GetStatusBar ().SetPaneAnimation (nStatusAnimation, m_imlStatusAnimation); - GetStatusBar ().SetPaneText (nStatusAnimation, _T("")); - GetStatusBar ().SetPaneWidth (nStatusAnimation, 16); - // - - m_wndStartAnimation.SetWindowText (_T("Stop Animation")); - m_bInAnimation = TRUE; -} - -void CStatusBarDemoView::OnIcon() -{ - UpdateData (); - GetStatusBar ().SetPaneIcon (nStatusIcon, m_nIcon == 0 ? m_bmpIcon1 : m_bmpIcon2); -} - -void CStatusBarDemoView::OnBackColor() -{ - GetStatusBar ().SetPaneBackgroundColor (nStatusLabel, m_wndBackColor.GetColor ()); -} - -void CStatusBarDemoView::OnTextColor() -{ - GetStatusBar ().SetPaneTextColor (nStatusLabel, m_wndTextColor.GetColor ()); -} - -void CStatusBarDemoView::OnIndicatorLabel() -{ - MessageBox (_T("Status bar pane double-click...")); -} - -void CStatusBarDemoView::OnTimer(UINT_PTR nIDEvent) -{ - if (nIDEvent == ID_PROGRESS_TIMER) - { - m_nProgressCurr += 5; - - if (m_nProgressCurr > PROGRESS_MAX) - { - m_nProgressCurr = 0; - } - - // - GetStatusBar ().SetPaneProgress (nStatusProgress, m_nProgressCurr); - // - } - - CFormView::OnTimer(nIDEvent); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoView.h deleted file mode 100644 index 68ac0de31d68f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StatusBarDemoView.h +++ /dev/null @@ -1,95 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "MainFrm.h" - -class CStatusBarDemoView : public CFormView -{ -protected: // create from serialization only - CStatusBarDemoView(); - DECLARE_DYNCREATE(CStatusBarDemoView) - -public: - enum { IDD = IDD_STATUSBARDEMO_FORM }; - - // - CMFCColorButton m_wndTextColor; - // - - CMFCColorButton m_wndBackColor; - CButton m_wndStartAnimation; - CButton m_wndStartProgress; - int m_nIcon; - -// Attributes -public: - CStatusBarDemoDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnInitialUpdate(); // called first time after construct - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CStatusBarDemoView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnStartProgress(); - afx_msg void OnStartAnimation(); - afx_msg void OnIcon(); - afx_msg void OnBackColor(); - afx_msg void OnTextColor(); - afx_msg void OnTimer(UINT_PTR nIDEvent); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - afx_msg void OnIndicatorLabel(); - - DECLARE_MESSAGE_MAP() - - // - // in StatusBarDemoView.h - CMFCStatusBar& GetStatusBar () const - { - return ((CMainFrame*) AfxGetMainWnd ())->GetStatusBar (); - } - // - - // - int m_nProgressCurr; - BOOL m_bInProgress; - - CImageList m_imlStatusAnimation; - BOOL m_bInAnimation; - - CBitmap m_bmpIcon1; - CBitmap m_bmpIcon2; - // -}; - -#ifndef _DEBUG // debug version in StatusBarDemoView.cpp -inline CStatusBarDemoDoc* CStatusBarDemoView::GetDocument() - { return (CStatusBarDemoDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StdAfx.cpp deleted file mode 100644 index 0752558f12d54..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// StatusBarDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StdAfx.h deleted file mode 100644 index 0a280f94d0a6c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/StdAfx.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemo.rc2 deleted file mode 100644 index e12719945000f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// STATUSBARDEMO.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemoDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemoDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/StatusBarDemoDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/animation.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/animation.bmp deleted file mode 100644 index fbaad7b775ea6..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/animation.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/icon1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/icon1.bmp deleted file mode 100644 index 38056604b3e45..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/icon1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/icon2.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/icon2.bmp deleted file mode 100644 index b36b3fa645d13..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/res/icon2.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/resource.h deleted file mode 100644 index a910fda689931..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/resource.h +++ /dev/null @@ -1,40 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by StatusBarDemo.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDD_STATUSBARDEMO_FORM 101 -#define IDS_MAIN_TOOLBAR 101 -#define ID_INDICATOR_ICON 102 -#define ID_INDICATOR_PROGRESS 103 -#define ID_INDICATOR_LABEL 104 -#define ID_INDICATOR_ANIMATION 105 -#define IDR_MAINFRAME 128 -#define IDR_STATUSTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDB_ANIMATION 154 -#define IDB_ICON1 155 -#define IDB_ICON2 156 -#define IDD_ABOUTBOX 999 -#define IDC_COMPANY_URL 1041 -#define IDC_START_PROGRESS 1043 -#define IDC_START_ANIMATION 1044 -#define IDC_ICON1 1045 -#define IDC_ICON2 1046 -#define IDC_TEXT_COLOR 1047 -#define IDC_BACK_COLOR 1048 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 156 -#define _APS_NEXT_COMMAND_VALUE 32833 -#define _APS_NEXT_CONTROL_VALUE 1048 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/statusbardemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/statusbardemo.vcxproj deleted file mode 100644 index ee79ea4490563..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/statusbardemo.vcxproj +++ /dev/null @@ -1,254 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {220D8C5D-067A-46AE-BF1D-EBA93773AF91} - StatusBarDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/StatusBarDemo.tlb - - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/StatusBarDemo.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/StatusBarDemo.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/StatusBarDemo.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_StatusBarDemo/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/MainFrm.cpp deleted file mode 100644 index ea7bf73259bcf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/MainFrm.cpp +++ /dev/null @@ -1,483 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabControl.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -class CToolbarLabel : public CMFCToolBarButton -{ - DECLARE_SERIAL(CToolbarLabel) - -public: - CToolbarLabel (UINT nID = 0, LPCTSTR lpszText = NULL); - - virtual void OnDraw (CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, - BOOL bHorz = TRUE, BOOL bCustomizeMode = FALSE, - BOOL bHighlight = FALSE, - BOOL bDrawBorder = TRUE, - BOOL bGrayDisabledButtons = TRUE); -}; - -IMPLEMENT_SERIAL(CToolbarLabel, CMFCToolBarButton, 1) - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CToolbarLabel::CToolbarLabel (UINT nID, LPCTSTR lpszText) -{ - if (lpszText != NULL) - { - m_strText = lpszText; - } - - m_bText = TRUE; - m_nID = nID; - m_iImage = -1; -} - -void CToolbarLabel::OnDraw (CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, - BOOL bHorz, BOOL /*bCustomizeMode*/, BOOL /*bHighlight*/, - BOOL /*bDrawBorder*/, BOOL /*bGrayDisabledButtons*/) -{ - UINT nStyle = m_nStyle; - m_nStyle &= ~TBBS_DISABLED; - - CMFCToolBarButton::OnDraw (pDC, rect, pImages, bHorz, FALSE, - FALSE, FALSE, FALSE); - - m_nStyle = nStyle; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_COMMAND(ID_VIEW_THEME_TOOLBAR, OnViewThemeToolbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_THEME_TOOLBAR, OnUpdateViewThemeToolbar) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnUpdateAppLook) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_nAppLook = theApp.GetInt (_T("ApplicationLook"), ID_VIEW_APPLOOK_2003); - - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - OnAppLook (m_nAppLook); - - CMFCToolBar::EnableQuickCustomization (); - - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_4); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndToolBarTheme.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_THEME_TOOLBAR) || - !m_wndToolBarTheme.LoadToolBar (IDR_THEME, 0, 0, TRUE /* Locked */)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - m_wndToolBar.SetWindowText (_T("Standard")); - m_wndToolBarTheme.SetWindowText (_T("Visual Style")); - - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBarTheme.EnableDocking(CBRS_ALIGN_ANY); - - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane(&m_wndToolBarTheme); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - m_wndToolBarTheme.EnableCustomizeButton (TRUE, -1, _T(""), FALSE); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - - if (uiToolBarId == IDR_THEME) - { - CMenu menu2007; - menu2007.LoadMenu (IDR_POPUP_STYLE_20007); - - UINT uiCmd2007 = ID_VIEW_APPLOOK_2007_1; - - if (m_nAppLook >= ID_VIEW_APPLOOK_2007_1 && - m_nAppLook <= ID_VIEW_APPLOOK_2007_4) - { - uiCmd2007 = m_nAppLook; - } - - CMFCToolBarMenuButton menuButton (uiCmd2007, menu2007.Detach (), -1); - - for (UINT uiCmd = ID_VIEW_APPLOOK_2007_1; uiCmd <= ID_VIEW_APPLOOK_2007_4; uiCmd++) - { - if (m_wndToolBarTheme.ReplaceButton (ID_VIEW_APPLOOK_2007_1, menuButton) > 0) - { - break; - } - } - - for (int i = 0; i < m_wndToolBarTheme.GetCount (); i++) - { - m_wndToolBarTheme.SetToolBarBtnText (i, NULL, TRUE, FALSE); - } - - m_wndToolBarTheme.ReplaceButton (ID_LABEL, - CToolbarLabel (ID_LABEL, _T("Visual style: "))); - } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnAppLook(UINT id) -{ - CDockingManager::SetDockingMode (DT_SMART); - - m_nAppLook = id; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2000: - // enable Office 2000 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_XP: - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - // enable Windows XP look (in other OS Office XP look will be used): - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_2003: - // enable Office 2003 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_VS2005: - // enable VS.NET 2005 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - CMFCVisualManager::GetInstance (); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_1: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - case ID_VIEW_APPLOOK_2007_2: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - case ID_VIEW_APPLOOK_2007_3: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - case ID_VIEW_APPLOOK_2007_4: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - SetupOffice2007Button (); - break; - - default: - ASSERT (FALSE); - } - - CDockingManager* pDockManager = GetDockingManager (); - if (pDockManager != NULL) - { - ASSERT_VALID (pDockManager); - pDockManager->AdjustPaneFrames (); - } - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - theApp.WriteInt (_T("ApplicationLook"), m_nAppLook); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); -} - -void CMainFrame::OnViewThemeToolbar() -{ - ShowPane (&m_wndToolBarTheme, - !(m_wndToolBarTheme.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewThemeToolbar(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndToolBarTheme.IsVisible ()); -} - -void CMainFrame::SetupOffice2007Button () -{ - // - CMFCToolBarButton* pOffice2007 = NULL; - int nIndex = -1; - - for (UINT uiCmd = ID_VIEW_APPLOOK_2007_1; uiCmd <= ID_VIEW_APPLOOK_2007_4; uiCmd++) - { - // CMFCToolBar m_wndToolBarTheme - nIndex = m_wndToolBarTheme.CommandToIndex (uiCmd); - - CMFCToolBarButton* pButton = m_wndToolBarTheme.GetButton (nIndex); - - if (pButton != NULL) - { - pOffice2007 = pButton; - break; - } - } - // - - if (pOffice2007 == NULL) - { - return; - } - - ASSERT_VALID (pOffice2007); - - pOffice2007->m_nID = m_nAppLook; - m_wndToolBarTheme.SetToolBarBtnText (nIndex, NULL, TRUE, FALSE); - m_wndToolBarTheme.AdjustSizeImmediate (); - - // - pOffice2007->EnableWindow(); - pOffice2007->SetImage(1); - pOffice2007->SetRect( CRect(1,1,1,1)); - pOffice2007->SetVisible(); - pOffice2007->Show(true); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/MainFrm.h deleted file mode 100644 index 9b669b15d3fb3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/MainFrm.h +++ /dev/null @@ -1,62 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define CFrameWnd CFrameWndEx - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - CMFCToolBar m_wndToolBarTheme; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewThemeToolbar(); - afx_msg void OnUpdateViewThemeToolbar(CCmdUI* pCmdUI); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); - - UINT m_nAppLook; - - void SetupOffice2007Button (); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/ReadMe.htm deleted file mode 100644 index 840b64eb98373..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/ReadMe.htm +++ /dev/null @@ -1,124 +0,0 @@ - - - - TabControl Sample: MFC Tab Control Application - - -

- TabControl Sample: MFC Tab Control Application

-
-
-
- -

-

-
-

- The TabControl sample demonstrates the MFC Tab Control and the different appearances - it has using different properties and visual managers.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the TabControl sample

-
-
    -
  1. -

    - Open the solution file TabControl.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The TabControl sample demonstrates the following keywords:

-

- CDockingManager; CFrameWndEx; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; CMFCTabCtrl; - CMFCToolBar; CMFCToolBarButton; CMFCToolBarImages; CMFCToolBarMenuButton; CMFCToolBarsCustomizeDialog; - CMFCVisualManager; CMFCVisualManagerOffice; CMFCVisualManagerWindows; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControl.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControl.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControl.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControl.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControl.rc2 deleted file mode 100644 index ab73c53c132b9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControl.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// TABCONTROL.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControlDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControlDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/TabControlDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/icons.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/icons.bmp deleted file mode 100644 index 6f0c1937ad2e4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/icons.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/theme.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/theme.bmp deleted file mode 100644 index 405f3d5e1130e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Res/theme.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Snippets.txt deleted file mode 100644 index 56b836a5a982c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/Snippets.txt +++ /dev/null @@ -1,4 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp: CMFCToolBarButton 1 -MainFrm.cpp: CMFCToolBarButton 2 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/StdAfx.cpp deleted file mode 100644 index 60dc52c9cf4a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// TabControl.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/StdAfx.h deleted file mode 100644 index b9ac5b6aa9842..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/StdAfx.h +++ /dev/null @@ -1,47 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.cpp deleted file mode 100644 index dddd0ed486d05..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabControl.h" - -#include "MainFrm.h" -#include "TabControlDoc.h" -#include "TabControlView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTabControlApp - -BEGIN_MESSAGE_MAP(CTabControlApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTabControlApp construction - -CTabControlApp::CTabControlApp() : - CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CTabControlApp object - -CTabControlApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CTabControlApp initialization - -BOOL CTabControlApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CTabControlDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CTabControlView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CTabControlApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CTabControlApp message handlers - -int CTabControlApp::ExitInstance() -{ - - - return CWinAppEx::ExitInstance(); -} - -void CTabControlApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CTabControlApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.h deleted file mode 100644 index 92ce40b17ca4b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.h +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CTabControlApp: -// See TabControl.cpp for the implementation of this class -// - -class CTabControlApp : public CWinAppEx -{ -public: - CTabControlApp(); - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CTabControlApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.rc deleted file mode 100644 index d425b3b51e5fe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControl.rc +++ /dev/null @@ -1,537 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\TabControl.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\TabControl.ico" -IDR_TABCONTYPE ICON DISCARDABLE "res\\TabControlDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_TOOLBAR256 BITMAP MOVEABLE PURE "res\\Toolbar256.bmp" -IDR_THEME BITMAP DISCARDABLE "res\\theme.bmp" -IDB_ICONS BITMAP DISCARDABLE "res\\icons.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - -IDR_THEME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_LABEL - BUTTON ID_VIEW_APPLOOK_2000 - BUTTON ID_VIEW_APPLOOK_XP - BUTTON ID_VIEW_APPLOOK_2003 - BUTTON ID_VIEW_APPLOOK_VS2005 - BUTTON ID_VIEW_APPLOOK_WIN_XP - BUTTON ID_VIEW_APPLOOK_2007_1 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "Visual Studio.NET 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_2007_1 - - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_2007_2 - - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_2007_3 - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_2007_4 - - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About TabControl...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Visual Style Toolbar", ID_VIEW_THEME_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -IDR_POPUP_STYLE_20007 MENU DISCARDABLE -BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_2007_1 - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_2007_2 - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_2007_3 - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_2007_4 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About TabControl" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "TabControl Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_TABCONTROL_FORM DIALOGEX 0, 0, 333, 210 -STYLE WS_CHILD -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "This sample illustrates usage of CMFCTabCtrl control. Please use properties on the right side to change tab control appearance.", - IDC_STATIC,7,7,204,29 - CONTROL "",IDC_TAB,"Static",SS_GRAYRECT | NOT WS_VISIBLE,7,37, - 204,84 - LTEXT "Tab &Style:",IDC_STATIC,224,7,33,8 - COMBOBOX IDC_TAB_STYLE,224,20,102,30,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - CONTROL "Show Tab &Icons",IDC_TAB_ICONS,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,224,41,82,10 - CONTROL "Enable Tabs S&wap",IDC_TAB_SWAP,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,224,55,82,10 - GROUPBOX "Tab Location:",IDC_STATIC,224,71,102,47,0, - WS_EX_TRANSPARENT - CONTROL "&Top",IDC_LOCATION,"Button",BS_AUTORADIOBUTTON | - WS_GROUP,232,85,29,10 - CONTROL "&Bottom",IDC_LOCATION2,"Button",BS_AUTORADIOBUTTON,232, - 100,38,10 - GROUPBOX "Tab Colors:",IDC_STATIC,224,128,102,64,0, - WS_EX_TRANSPARENT - CONTROL "&Default",IDC_COLOR,"Button",BS_AUTORADIOBUTTON | - WS_GROUP,232,142,39,10 - CONTROL "&OneNote-style",IDC_COLOR1,"Button",BS_AUTORADIOBUTTON, - 232,158,61,10 - CONTROL "&User-defined",IDC_COLOR2,"Button",BS_AUTORADIOBUTTON, - 232,174,56,10 - LTEXT "Tab Control Notifications:",IDC_STATIC,7,129,80,8 - LISTBOX IDC_NOTIFICATIONS,7,142,204,61,LBS_NOINTEGRALHEIGHT | - LBS_NOSEL | WS_VSCROLL | WS_TABSTOP -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "TabControl MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "TabControl\0" - VALUE "LegalCopyright", "Copyright (C) 2005\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "TabControl.EXE\0" - VALUE "ProductName", "TabControl Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_TABCONTROL_FORM, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 326 - VERTGUIDE, 211 - VERTGUIDE, 224 - VERTGUIDE, 232 - TOPMARGIN, 7 - BOTTOMMARGIN, 203 - END -END -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_TABCONTROL_FORM DLGINIT -BEGIN - IDC_TAB_STYLE, 0x403, 4, 0 -0x2d33, 0x0044, - IDC_TAB_STYLE, 0x403, 5, 0 -0x6c46, 0x7461, "\000" - IDC_TAB_STYLE, 0x403, 8, 0 -0x6e4f, 0x4e65, 0x746f, 0x0065, - IDC_TAB_STYLE, 0x403, 8, 0 -0x5356, 0x3220, 0x3030, 0x0035, - IDC_TAB_STYLE, 0x403, 8, 0 -0x6f52, 0x6e75, 0x6564, 0x0064, - 0 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "TabControl\n\nTabCon\n\n\nTabControl.Document\nTabCon Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "TabControl" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_APPLOOK_2000 "Activate Office 2000 application look\nOffice 2000" - ID_VIEW_APPLOOK_XP "Activate Office XP application look\nOffice XP" - ID_VIEW_APPLOOK_2003 "Activate Office 2003 application look\nOffice 2003" - ID_VIEW_APPLOOK_WIN_XP "Activate Windows XP application look\nWindows XP" - ID_VIEW_APPLOOK_VS2005 "Activate Visual Studio.NET 2005 application look\nVS.NET 2005" - ID_VIEW_APPLOOK_2007_1 "Activate Office 2007 application look\nOffice 2007 Look - Blue" - ID_VIEW_APPLOOK_2007_2 "Activate Office 2007 application look\nOffice 2007 Look - Black" - ID_VIEW_APPLOOK_2007_3 "Activate Office 2007 application look\nOffice 2007 Look - Aqua" - ID_VIEW_APPLOOK_2007_4 "Activate Office 2007 application look\nOffice 2007 Look - Silver" - ID_VIEW_THEME_TOOLBAR "Show or hide the style toolbar\nToggle Style ToolBar" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\TabControl.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlDoc.cpp deleted file mode 100644 index 0e88c903cf6a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabControl.h" - -#include "TabControlDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTabControlDoc - -IMPLEMENT_DYNCREATE(CTabControlDoc, CDocument) - -BEGIN_MESSAGE_MAP(CTabControlDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTabControlDoc construction/destruction - -CTabControlDoc::CTabControlDoc() -{ - // TODO: add one-time construction code here - -} - -CTabControlDoc::~CTabControlDoc() -{ -} - -BOOL CTabControlDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CTabControlDoc serialization - -void CTabControlDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CTabControlDoc diagnostics - -#ifdef _DEBUG -void CTabControlDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CTabControlDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTabControlDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlDoc.h deleted file mode 100644 index 5474a5508b56e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CTabControlDoc : public CDocument -{ -protected: // create from serialization only - CTabControlDoc(); - DECLARE_DYNCREATE(CTabControlDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CTabControlDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlView.cpp deleted file mode 100644 index 9538f1c072ff4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlView.cpp +++ /dev/null @@ -1,367 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabControl.h" - -#include "TabControlDoc.h" -#include "TabControlView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTabControlView - -IMPLEMENT_DYNCREATE(CTabControlView, CFormView) - -BEGIN_MESSAGE_MAP(CTabControlView, CFormView) - ON_CBN_SELCHANGE(IDC_TAB_STYLE, OnSelchangeTabStyle) - ON_BN_CLICKED(IDC_LOCATION, OnLocation) - ON_BN_CLICKED(IDC_COLOR, OnColor) - ON_BN_CLICKED(IDC_TAB_ICONS, OnTabIcons) - ON_BN_CLICKED(IDC_LOCATION2, OnLocation) - ON_BN_CLICKED(IDC_COLOR1, OnColor) - ON_BN_CLICKED(IDC_COLOR2, OnColor) - ON_BN_CLICKED(IDC_TAB_SWAP, OnTabSwap) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) - // Tab control notifications - ON_REGISTERED_MESSAGE(AFX_WM_ON_MOVE_TAB, OnMoveTab) - ON_REGISTERED_MESSAGE(AFX_WM_CHANGE_ACTIVE_TAB, OnChangeActiveTab) - ON_REGISTERED_MESSAGE(AFX_WM_CHANGING_ACTIVE_TAB, OnChangingActiveTab) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTabControlView construction/destruction - -CTabControlView::CTabControlView() - : CFormView(CTabControlView::IDD) -{ - m_nTabStyle = 0; - m_nTabLocation = 0; - m_nColor = 0; - m_bTabIcons = TRUE; - m_bTabsSwap = TRUE; -} - -CTabControlView::~CTabControlView() -{ -} - -void CTabControlView::DoDataExchange(CDataExchange* pDX) -{ - CFormView::DoDataExchange(pDX); - DDX_Control(pDX, IDC_TAB_ICONS, m_wndTabIcons); - DDX_Control(pDX, IDC_NOTIFICATIONS, m_wndNotifications); - DDX_Control(pDX, IDC_TAB, m_wndTabLoc); - DDX_CBIndex(pDX, IDC_TAB_STYLE, m_nTabStyle); - DDX_Radio(pDX, IDC_LOCATION, m_nTabLocation); - DDX_Radio(pDX, IDC_COLOR, m_nColor); - DDX_Check(pDX, IDC_TAB_ICONS, m_bTabIcons); - DDX_Check(pDX, IDC_TAB_SWAP, m_bTabsSwap); -} - -BOOL CTabControlView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CFormView::PreCreateWindow(cs); -} - -void CTabControlView::OnInitialUpdate() -{ - // There is only one view ever, so it only needs to do the initial - // update once--otherwise the application is resized needlessly. - static BOOL bUpdatedOnce = FALSE; - if (bUpdatedOnce) - return; - bUpdatedOnce = TRUE; - - CFormView::OnInitialUpdate(); - GetParentFrame()->RecalcLayout(); - - if (m_wndTab.GetSafeHwnd () != NULL) - { - return; - } - - CRect rectTab; - - m_wndTabLoc.GetWindowRect (&rectTab); - ScreenToClient (&rectTab); - - m_wndTab.Create (CMFCTabCtrl::STYLE_3D, rectTab, this, 1, - CMFCTabCtrl::LOCATION_TOP); - - m_wndTab.SetImageList (IDB_ICONS, 16, RGB (255, 0, 255)); - - m_wnd1.Create (WS_CHILD | WS_VISIBLE, CRect (0, 0, 0, 0), &m_wndTab, 1); - m_wnd1.SetFont (&afxGlobalData.fontRegular); - m_wnd1.SetWindowText (_T("Edit 1")); - - m_wnd2.Create (WS_CHILD | WS_VISIBLE, CRect (0, 0, 0, 0), &m_wndTab, 2); - m_wnd2.SetFont (&afxGlobalData.fontRegular); - m_wnd2.SetWindowText (_T("Edit 2")); - - m_wnd3.Create (WS_CHILD | WS_VISIBLE, CRect (0, 0, 0, 0), &m_wndTab, 3); - m_wnd3.SetFont (&afxGlobalData.fontRegular); - m_wnd3.SetWindowText (_T("Edit 3")); - - m_wnd4.Create (WS_CHILD | WS_VISIBLE, CRect (0, 0, 0, 0), &m_wndTab, 4); - m_wnd4.SetFont (&afxGlobalData.fontRegular); - m_wnd4.SetWindowText (_T("Edit 4")); - - m_wndTab.AddTab (&m_wnd1, _T("One"), 0, FALSE); - m_wndTab.AddTab (&m_wnd2, _T("Two"), 1, FALSE); - m_wndTab.AddTab (&m_wnd3, _T("Three"), 2, FALSE); - m_wndTab.AddTab (&m_wnd4, _T("Four"), 3, FALSE); - - m_nTabStyle = theApp.GetInt (_T("TabStyle"), 0); - m_nTabLocation = theApp.GetInt (_T("TabLocation"), 0); - m_nColor = theApp.GetInt (_T("TabColor"), 0); - m_bTabIcons = theApp.GetInt (_T("TabIcons"), TRUE); - m_bTabsSwap = theApp.GetInt (_T("TabsSwap"), TRUE); - - UpdateData (FALSE); - - OnSelchangeTabStyle(); - OnLocation(); - OnColor(); - OnTabIcons (); - OnTabSwap (); -} - -///////////////////////////////////////////////////////////////////////////// -// CTabControlView printing - -void CTabControlView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CTabControlView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CTabControlView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CTabControlView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CTabControlView::OnPrint(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add customized printing code here -} - -///////////////////////////////////////////////////////////////////////////// -// CTabControlView diagnostics - -#ifdef _DEBUG -void CTabControlView::AssertValid() const -{ - CFormView::AssertValid(); -} - -void CTabControlView::Dump(CDumpContext& dc) const -{ - CFormView::Dump(dc); -} - -CTabControlDoc* CTabControlView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTabControlDoc))); - return (CTabControlDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTabControlView message handlers - -void CTabControlView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - -void CTabControlView::OnSelchangeTabStyle() -{ - UpdateData (); - - CMFCTabCtrl::Style style; - int nTab = 0; - - m_wndTabIcons.EnableWindow (); - - for (nTab = 0; nTab < m_wndTab.GetTabsNum (); nTab++) - { - m_wndTab.SetTabIcon (nTab, m_bTabIcons ? nTab : (UINT)-1); - } - - switch (m_nTabStyle) - { - case 1: - style = CMFCTabCtrl::STYLE_FLAT; - m_wndTabIcons.EnableWindow (FALSE); - - for (nTab = 0; nTab < m_wndTab.GetTabsNum (); nTab++) - { - m_wndTab.SetTabIcon (nTab, (UINT)-1); - } - - break; - - case 2: - style = CMFCTabCtrl::STYLE_3D_ONENOTE; - break; - - case 3: - style = CMFCTabCtrl::STYLE_3D_VS2005; - break; - - case 4: - style = CMFCTabCtrl::STYLE_3D_ROUNDED; - break; - default: - style = CMFCTabCtrl::STYLE_3D; - } - - m_wndTab.ModifyTabStyle (style); - m_wndTab.RecalcLayout (); - m_wndTab.RedrawWindow (); - - theApp.WriteInt (_T("TabStyle"), m_nTabStyle); -} - -void CTabControlView::OnLocation() -{ - UpdateData (); - - CMFCTabCtrl::Location location; - - switch (m_nTabLocation) - { - case 1: - location = CMFCTabCtrl::LOCATION_BOTTOM; - break; - - default: - location = CMFCTabCtrl::LOCATION_TOP; - } - - m_wndTab.SetLocation (location); - m_wndTab.RecalcLayout (); - m_wndTab.RedrawWindow (); - - theApp.WriteInt (_T("TabLocation"), m_nTabLocation); -} - -void CTabControlView::OnColor() -{ - UpdateData (); - - CArray arColors; - - switch (m_nColor) - { - case 0: - m_wndTab.EnableAutoColor (FALSE); - break; - - case 1: - m_wndTab.EnableAutoColor (TRUE); - break; - - case 2: - arColors.Add (RGB (121, 210, 231)); - arColors.Add (RGB (190, 218, 153)); - arColors.Add (RGB (255, 170, 100)); - - m_wndTab.EnableAutoColor (TRUE); - } - - m_wndTab.SetAutoColors (arColors); - - theApp.WriteInt (_T("TabColor"), m_nColor); -} - -void CTabControlView::OnTabIcons() -{ - UpdateData (); - - for (int nTab = 0; nTab < m_wndTab.GetTabsNum (); nTab++) - { - m_wndTab.SetTabIcon (nTab, m_bTabIcons ? nTab : (UINT)-1); - } - - m_wndTab.RecalcLayout (); - m_wndTab.RedrawWindow (); - - theApp.WriteInt (_T("TabIcons"), m_bTabIcons); -} - -void CTabControlView::AddNotification (LPCTSTR lpszText) -{ - if (m_wndNotifications.GetCount () > 100) - { - m_wndNotifications.DeleteString (0); - } - - int nIndex = m_wndNotifications.AddString (lpszText); - m_wndNotifications.SetCurSel (nIndex); -} - -LRESULT CTabControlView::OnMoveTab(WPARAM wp, LPARAM lp) -{ - CString str; - str.Format (_T("AFX_WM_ON_MOVE_TAB: %d %d"), (int) wp, (int) lp); - - AddNotification (str); - return 0; -} - -LRESULT CTabControlView::OnChangeActiveTab(WPARAM wp, LPARAM /*lp*/) -{ - CString str; - str.Format (_T("AFX_WM_CHANGE_ACTIVE_TAB: %d"), (int) wp); - - AddNotification (str); - return 0; -} - -LRESULT CTabControlView::OnChangingActiveTab(WPARAM wp, LPARAM /*lp*/) -{ - CString str; - str.Format (_T("AFX_WM_CHANGING_ACTIVE_TAB: %d"), (int) wp); - - AddNotification (str); - return 0; -} - -void CTabControlView::OnTabSwap() -{ - UpdateData (); - - m_wndTab.EnableTabSwap (m_bTabsSwap); - theApp.WriteInt (_T("TabsSwap"), m_bTabsSwap); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlView.h deleted file mode 100644 index 092df1cc86e90..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/TabControlView.h +++ /dev/null @@ -1,85 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CTabControlView : public CFormView -{ -protected: // create from serialization only - CTabControlView(); - DECLARE_DYNCREATE(CTabControlView) - -public: - enum { IDD = IDD_TABCONTROL_FORM }; - CButton m_wndTabIcons; - CListBox m_wndNotifications; - CStatic m_wndTabLoc; - int m_nTabStyle; - int m_nTabLocation; - int m_nColor; - BOOL m_bTabIcons; - BOOL m_bTabsSwap; - -// Attributes -public: - CTabControlDoc* GetDocument(); - -protected: - CMFCTabCtrl m_wndTab; - - CEdit m_wnd1; - CEdit m_wnd2; - CEdit m_wnd3; - CEdit m_wnd4; - -// Operations -public: - -// Overrides - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnInitialUpdate(); // called first time after construct - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CTabControlView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - void AddNotification (LPCTSTR lpszText); - -protected: - afx_msg void OnSelchangeTabStyle(); - afx_msg void OnLocation(); - afx_msg void OnColor(); - afx_msg void OnTabIcons(); - afx_msg void OnTabSwap(); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - afx_msg LRESULT OnMoveTab(WPARAM wp, LPARAM lp); - afx_msg LRESULT OnChangeActiveTab(WPARAM wp, LPARAM lp); - afx_msg LRESULT OnChangingActiveTab(WPARAM wp, LPARAM lp); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in TabControlView.cpp -inline CTabControlDoc* CTabControlView::GetDocument() - { return (CTabControlDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/resource.h deleted file mode 100644 index 57d523c2d44ff..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/resource.h +++ /dev/null @@ -1,51 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by TabControl.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDD_TABCONTROL_FORM 101 -#define IDR_MAINFRAME 128 -#define IDR_TABCONTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDR_POPUP_STYLE_20007 132 -#define IDB_TOOLBAR256 151 -#define IDR_THEME 154 -#define IDB_ICONS 155 -#define IDD_ABOUTBOX 999 -#define IDC_COMPANY_URL 1041 -#define IDC_TAB 1042 -#define IDC_TAB_STYLE 1043 -#define IDC_LOCATION 1044 -#define IDC_LOCATION2 1045 -#define IDC_COLOR 1046 -#define IDC_COLOR1 1047 -#define IDC_COLOR2 1048 -#define IDC_TAB_ICONS 1049 -#define IDC_NOTIFICATIONS 1050 -#define IDC_TAB_SWAP 1051 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_APPLOOK_2000 32832 -#define ID_VIEW_APPLOOK_XP 32833 -#define ID_VIEW_APPLOOK_2003 32834 -#define ID_VIEW_APPLOOK_WIN_XP 32835 -#define ID_VIEW_APPLOOK_VS2005 32836 -#define ID_VIEW_APPLOOK_2007_1 32837 -#define ID_VIEW_APPLOOK_2007_2 32838 -#define ID_VIEW_APPLOOK_2007_3 32839 -#define ID_VIEW_APPLOOK_2007_4 32840 -#define ID_VIEW_THEME_TOOLBAR 32841 -#define ID_LABEL 32842 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 156 -#define _APS_NEXT_COMMAND_VALUE 32843 -#define _APS_NEXT_CONTROL_VALUE 1051 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/tabcontrol.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/tabcontrol.vcxproj deleted file mode 100644 index c1c84ca2c016d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/tabcontrol.vcxproj +++ /dev/null @@ -1,219 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {83C47F51-0A45-488E-88F5-65D1937FE772} - TabControl - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/TabControl.tlb - - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/TabControl.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/TabControl.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/TabControl.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/tabcontrol.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/tabcontrol.vcxproj.filters deleted file mode 100644 index d6a1d7252e411..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/tabcontrol.vcxproj.filters +++ /dev/null @@ -1,86 +0,0 @@ - - - - - {cbe493f5-d6f5-4b87-b2ec-22f8facd9e4f} - h;hpp;hxx;hm;inl - - - {fb72c83e-a824-458b-8094-f010084e47ea} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {f4b4ff30-8486-4f09-a7af-71d1b13a30d6} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabControl/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ChildFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ChildFrm.cpp deleted file mode 100644 index 4a642b4e12945..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ChildFrm.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" - -#include "ChildFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame - -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here - -} - -CChildFrame::~CChildFrame() -{ -} - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - if( !CMDIChildWnd::PreCreateWindow(cs) ) - return FALSE; - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWnd::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ChildFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ChildFrm.h deleted file mode 100644 index 486c6a9849fea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ChildFrm.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define CMDIChildWnd CMDIChildWndEx - -class CChildFrame : public CMDIChildWnd -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/MainFrm.cpp deleted file mode 100644 index b8589b655b1d7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/MainFrm.cpp +++ /dev/null @@ -1,232 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) - ON_WM_CREATE() - ON_WM_CLOSE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - CMFCToolBar::EnableQuickCustomization (); - - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_WINDOW_TILE_HORZ); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CMDIFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/MainFrm.h deleted file mode 100644 index 2a9f21c48fb2e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/MainFrm.h +++ /dev/null @@ -1,52 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#define CMDIFrameWnd CMDIFrameWndEx - -class CMainFrame : public CMDIFrameWnd -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ReadMe.htm deleted file mode 100644 index 2a3a825cccbce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/ReadMe.htm +++ /dev/null @@ -1,123 +0,0 @@ - - - - TabbedView Sample: MFC Tabbed View Application - - -

- TabbedView Sample: MFC Tabbed View Application

-
-
-
- -

-

-
-

- The TabbedView sample demonstrates how to create a view that contains multiple tabbed - views, like the tabs in an Excel workbook.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the TabbedView sample

-
-
    -
  1. -

    - Open the solution file TabbedView.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The TabbedView sample demonstrates the following keywords:

-

- CMDIChildWnd; CMDIFrameWnd; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; CMFCTabCtrl; - CMFCToolBar; CMFCToolBarsCustomizeDialog; CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/Snippets.txt deleted file mode 100644 index 4a55cf23cfec4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/Snippets.txt +++ /dev/null @@ -1,3 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -CTabView Class 1 diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/StdAfx.cpp deleted file mode 100644 index a7b137f9c24e8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/StdAfx.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// stdafx.cpp : source file that includes just the standard includes -// TabbedView.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/StdAfx.h deleted file mode 100644 index 071012bc8d5ea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/StdAfx.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include "afxcview.h" - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.cpp deleted file mode 100644 index 2c9087d55ebd7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" - -#include "MainFrm.h" -#include "ChildFrm.h" -#include "TabbedViewDoc.h" -#include "TabbedViewView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewApp - -BEGIN_MESSAGE_MAP(CTabbedViewApp, CWinApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewApp construction - -CTabbedViewApp::CTabbedViewApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CTabbedViewApp object - -CTabbedViewApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewApp initialization - -BOOL CTabbedViewApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate( - IDR_TABBEDTYPE, - RUNTIME_CLASS(CTabbedViewDoc), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CTabbedViewView)); - AddDocTemplate(pDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) - return FALSE; - m_pMainWnd = pMainFrame; - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - LoadCustomState (); - - // The main window has been initialized, so show and update it. - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewApp message handlers - -int CTabbedViewApp::ExitInstance() -{ - - - return CWinAppEx::ExitInstance(); -} - -void CTabbedViewApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CTabbedViewApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewApp message handlers - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.h deleted file mode 100644 index 14a4936a92b5f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.h +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewApp: -// See TabbedView.cpp for the implementation of this class -// - -class CTabbedViewApp : public CWinAppEx -{ -public: - CTabbedViewApp(); - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CTabbedViewApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.rc deleted file mode 100644 index 7e51ddac438bb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedView.rc +++ /dev/null @@ -1,483 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\TabbedView.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\TabbedView.ico" -IDR_TABBEDTYPE ICON DISCARDABLE "res\\TabbedViewDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM SEPARATOR - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About TabbedView...", ID_APP_ABOUT - END -END - -IDR_TABBEDTYPE MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - MENUITEM "&Cascade", ID_WINDOW_CASCADE - MENUITEM "&Tile", ID_WINDOW_TILE_HORZ - MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE - END - POPUP "&Help" - BEGIN - MENUITEM "&About TabbedView...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About TabbedView" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "TabbedView Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_FORMVIEW DIALOG DISCARDABLE 0, 0, 358, 62 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "FormView",IDC_STATIC,41,7,32,8 - EDITTEXT IDC_EDIT1,41,21,91,14,ES_AUTOHSCROLL - CONTROL "Check1",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,41,44,41,10 - ICON IDR_MAINFRAME,IDC_STATIC,7,7,21,20 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "TabbedView MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "TabbedView\0" - VALUE "LegalCopyright", "Copyright (C) 2001\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "TabbedView.EXE\0" - VALUE "ProductName", "TabbedView Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_FORMVIEW, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 351 - TOPMARGIN, 7 - BOTTOMMARGIN, 55 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "TabbedView" - IDR_TABBEDTYPE "\nTabbed\nTabbed\n\n\nTabbedView.Document\nTabbed Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "TabbedView" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\TabbedView.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewDoc.cpp deleted file mode 100644 index 21ffcda55a360..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" - -#include "TabbedViewDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewDoc - -IMPLEMENT_DYNCREATE(CTabbedViewDoc, CDocument) - -BEGIN_MESSAGE_MAP(CTabbedViewDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewDoc construction/destruction - -CTabbedViewDoc::CTabbedViewDoc() -{ - // TODO: add one-time construction code here - -} - -CTabbedViewDoc::~CTabbedViewDoc() -{ -} - -BOOL CTabbedViewDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewDoc serialization - -void CTabbedViewDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewDoc diagnostics - -#ifdef _DEBUG -void CTabbedViewDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CTabbedViewDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewDoc.h deleted file mode 100644 index 5dc1e91495ce4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CTabbedViewDoc : public CDocument -{ -protected: // create from serialization only - CTabbedViewDoc(); - DECLARE_DYNCREATE(CTabbedViewDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CTabbedViewDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewView.cpp deleted file mode 100644 index 3995f991e0d93..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewView.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" - -#include "TabbedViewDoc.h" -#include "TabbedViewView.h" - -#include "View1.h" -#include "View2.h" -#include "View3.h" -#include "View4.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewView - -IMPLEMENT_DYNCREATE(CTabbedViewView, CTabView) - -BEGIN_MESSAGE_MAP(CTabbedViewView, CTabView) - ON_WM_CREATE() - ON_WM_ERASEBKGND() - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CTabView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CTabView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewView construction/destruction - -CTabbedViewView::CTabbedViewView() -{ -} - -CTabbedViewView::~CTabbedViewView() -{ -} - -BOOL CTabbedViewView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CTabView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewView drawing - -void CTabbedViewView::OnDraw(CDC* /*pDC*/) -{ -// CTabbedViewDoc* pDoc = GetDocument(); -// ASSERT_VALID(pDoc); - // TODO: add draw code for native data here -} - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewView printing - -void CTabbedViewView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CTabbedViewView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CTabbedViewView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CTabbedViewView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewView diagnostics - -#ifdef _DEBUG -void CTabbedViewView::AssertValid() const -{ - CTabView::AssertValid(); -} - -void CTabbedViewView::Dump(CDumpContext& dc) const -{ - CTabView::Dump(dc); -} - -CTabbedViewDoc* CTabbedViewView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTabbedViewDoc))); - return (CTabbedViewDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTabbedViewView message handlers - -void CTabbedViewView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - -int CTabbedViewView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CTabView::OnCreate(lpCreateStruct) == -1) - return -1; - - AddView (RUNTIME_CLASS (CView1), _T("Simple"), 100); - AddView (RUNTIME_CLASS (CView2), _T("List"), 101); - AddView (RUNTIME_CLASS (CView3), _T("Form"), 102); - AddView (RUNTIME_CLASS (CView4), _T("ScrollView"), 102); - - return 0; -} - -BOOL CTabbedViewView::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewView.h deleted file mode 100644 index 05ff49436119b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/TabbedViewView.h +++ /dev/null @@ -1,62 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -// -class CTabbedViewView : public CTabView -{ -protected: // create from serialization only - CTabbedViewView(); - DECLARE_DYNCREATE(CTabbedViewView) - -// Attributes -public: - CTabbedViewDoc* GetDocument(); - -// Operations -public: - -// Overrides - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - - BOOL IsScrollBar () const - { - return TRUE; - } - -// Implementation -public: - virtual ~CTabbedViewView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; -// - -#ifndef _DEBUG // debug version in TabbedViewView.cpp -inline CTabbedViewDoc* CTabbedViewView::GetDocument() - { return (CTabbedViewDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View1.cpp deleted file mode 100644 index fc36104ba8e4c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View1.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" -#include "View1.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates usage of CTabbedView class. To create a tabbed view, you need to:\r\n\r\n") - _T("* Derive your view class from CTabbedView\r\n") - _T("* Add OnCreate handler\r\n") - _T("* Call AddView for each view\r\n\r\n") - _T("Please note that you cannot add an existing view to the tabbed view, the framework creates all tabbed views."); - -///////////////////////////////////////////////////////////////////////////// -// CView1 - -IMPLEMENT_DYNCREATE(CView1, CScrollView) - -CView1::CView1() -{ -} - -CView1::~CView1() -{ -} - - -BEGIN_MESSAGE_MAP(CView1, CScrollView) - ON_WM_WINDOWPOSCHANGING() - ON_WM_HSCROLL() - ON_WM_ERASEBKGND() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CView1 drawing - -void CView1::OnDraw(CDC* pDC) -{ - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectFill = rectClient; - pDC->DPtoLP (&rectFill); - - pDC->FillSolidRect (rectFill, ::GetSysColor (COLOR_WINDOW)); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - pDC->FillSolidRect (rectFrame, ::GetSysColor (COLOR_INFOBK)); - - rectFrame.DeflateRect (1, 1); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - rectFrame.DeflateRect (2, 2); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - pDC->SetTextColor (::GetSysColor (COLOR_INFOTEXT)); - pDC->SetBkMode (TRANSPARENT); - - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// CView1 diagnostics - -#ifdef _DEBUG -void CView1::AssertValid() const -{ - CScrollView::AssertValid(); -} - -void CView1::Dump(CDumpContext& dc) const -{ - CScrollView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CView1 message handlers - -void CView1::OnInitialUpdate() -{ - CScrollView::OnInitialUpdate(); - - SetScrollSizes (MM_TEXT, CSize (1000, 1000)); - - CMFCTabCtrl* pTabWnd = DYNAMIC_DOWNCAST (CMFCTabCtrl, GetParent ()); - ASSERT_VALID (pTabWnd); - - pTabWnd->SynchronizeScrollBar (); -} - -void CView1::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) -{ - CScrollView::OnWindowPosChanging(lpwndpos); - - // Hide horizontal scrollbar: - ShowScrollBar (SB_HORZ, FALSE); - ModifyStyle (WS_HSCROLL, 0, SWP_DRAWFRAME); -} - -void CView1::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* /*pScrollBar*/) -{ - CMFCTabCtrl* pTabWnd = DYNAMIC_DOWNCAST (CMFCTabCtrl, GetParent ()); - ASSERT_VALID (pTabWnd); - - CScrollView::OnHScroll(nSBCode, nPos, pTabWnd->GetScrollBar ()); -} - -CScrollBar* CView1::GetScrollBarCtrl(int nBar) const -{ - if (nBar == SB_HORZ) - { - CMFCTabCtrl* pTabWnd = DYNAMIC_DOWNCAST (CMFCTabCtrl, GetParent ()); - ASSERT_VALID (pTabWnd); - - return pTabWnd->GetScrollBar (); - } - - return CScrollView::GetScrollBarCtrl(nBar); -} - -BOOL CView1::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View1.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View1.h deleted file mode 100644 index 5e4016cc3a18e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View1.h +++ /dev/null @@ -1,49 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CView1 view - -class CView1 : public CScrollView -{ -protected: - CView1(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CView1) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual void OnInitialUpdate(); - virtual CScrollBar* GetScrollBarCtrl(int nBar) const; - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - -// Implementation -protected: - virtual ~CView1(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View2.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View2.cpp deleted file mode 100644 index 662ac294c9d2a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View2.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" -#include "View2.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CView2 - -IMPLEMENT_DYNCREATE(CView2, CListView) - -CView2::CView2() -{ -} - -CView2::~CView2() -{ -} - - -BEGIN_MESSAGE_MAP(CView2, CListView) - ON_WM_CONTEXTMENU() - ON_WM_WINDOWPOSCHANGING() - ON_WM_KEYDOWN() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CView2 drawing - -void CView2::OnDraw(CDC* /*pDC*/) -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CView2 diagnostics - -#ifdef _DEBUG -void CView2::AssertValid() const -{ - CListView::AssertValid(); -} - -void CView2::Dump(CDumpContext& dc) const -{ - CListView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CView2 message handlers - -BOOL CView2::PreCreateWindow(CREATESTRUCT& cs) -{ - cs.style |= LVS_REPORT; - return CListView::PreCreateWindow(cs); -} - -void CView2::OnInitialUpdate() -{ - CListView::OnInitialUpdate(); - - CListCtrl& wndList = GetListCtrl (); - - wndList.SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); - - const int nColumns = 15; - int iColumn = 0; - - // Insert columns: - for (iColumn = 0; iColumn < nColumns; iColumn++) - { - CString strColumn; - strColumn.Format (_T("Column %d"), iColumn + 1); - - wndList.InsertColumn (iColumn, strColumn, LVCFMT_LEFT, 70); - } - - // Insert items: - for (int i = 0; i < 100; i++) - { - const CString strItemFmt = _T("Item (%d, %d)"); - - CString strItem; - strItem.Format (strItemFmt, 1, i + 1); - - int iItem = wndList.InsertItem (i, strItem, 0); - - for (iColumn = 1; iColumn < nColumns; iColumn++) - { - strItem.Format (strItemFmt, iColumn + 1, i + 1); - wndList.SetItemText (iItem, iColumn, strItem); - } - } -} - -void CView2::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - -void CView2::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) -{ - CListView::OnWindowPosChanging(lpwndpos); - - // Hide horizontal scrollbar: - ShowScrollBar (SB_HORZ, FALSE); - ModifyStyle (WS_HSCROLL, 0, SWP_DRAWFRAME); -} - -void CView2::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) -{ - CListView::OnKeyDown(nChar, nRepCnt, nFlags); - - if (nChar == VK_LEFT || nChar == VK_RIGHT) - { - // Assume scroll left or right. Synchronize scorll bars: - CMFCTabCtrl* pTabWnd = DYNAMIC_DOWNCAST (CMFCTabCtrl, GetParent ()); - ASSERT_VALID (pTabWnd); - - pTabWnd->SynchronizeScrollBar (); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View2.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View2.h deleted file mode 100644 index 853ad94d1f187..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View2.h +++ /dev/null @@ -1,49 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CView2 view - -class CView2 : public CListView -{ -protected: - CView2(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CView2) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual void OnInitialUpdate(); - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -protected: - virtual ~CView2(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); - afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View3.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View3.cpp deleted file mode 100644 index 258bdaf267e35..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View3.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TabbedView.h" -#include "View3.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CView3 - -IMPLEMENT_DYNCREATE(CView3, CFormView) - -CView3::CView3() - : CFormView(CView3::IDD) -{ -} - -CView3::~CView3() -{ -} - -void CView3::DoDataExchange(CDataExchange* pDX) -{ - CFormView::DoDataExchange(pDX); -} - - -BEGIN_MESSAGE_MAP(CView3, CFormView) - ON_WM_CONTEXTMENU() - ON_WM_WINDOWPOSCHANGING() - ON_WM_ERASEBKGND() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CView3 diagnostics - -#ifdef _DEBUG -void CView3::AssertValid() const -{ - CFormView::AssertValid(); -} - -void CView3::Dump(CDumpContext& dc) const -{ - CFormView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CView3 message handlers - -void CView3::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - -void CView3::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) -{ - CFormView::OnWindowPosChanging(lpwndpos); - - // Hide horizontal scrollbar: - ShowScrollBar (SB_HORZ, FALSE); - ModifyStyle (WS_HSCROLL, 0, SWP_DRAWFRAME); -} - - -BOOL CView3::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} - -void CView3::OnDraw(CDC* pDC) -{ - CRect rectClient; - GetClientRect (rectClient); - - pDC->FillSolidRect (rectClient, ::GetSysColor (COLOR_3DFACE)); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View3.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View3.h deleted file mode 100644 index 7b97d5c98f847..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View3.h +++ /dev/null @@ -1,54 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CView3 form view - -#ifndef __AFXEXT_H__ -#include -#endif - -class CView3 : public CFormView -{ -protected: - CView3(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CView3) - -// Form Data -public: - enum { IDD = IDD_FORMVIEW }; - -// Attributes -public: - -// Operations -public: - -// Overrides - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnDraw(CDC* pDC); - -// Implementation -protected: - virtual ~CView3(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View4.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View4.cpp deleted file mode 100644 index 94e5fb0937f92..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View4.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "tabbedview.h" -#include "View4.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CView4 - -IMPLEMENT_DYNCREATE(CView4, CScrollView) - -CView4::CView4() -{ -} - -CView4::~CView4() -{ -} - - -BEGIN_MESSAGE_MAP(CView4, CScrollView) - ON_WM_WINDOWPOSCHANGING() - ON_WM_HSCROLL() - ON_WM_ERASEBKGND() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CView4 drawing - -void CView4::OnInitialUpdate() -{ - CScrollView::OnInitialUpdate(); - - CSize sizeTotal; - // TODO: calculate the total size of this view - sizeTotal.cx = sizeTotal.cy = 1000; - SetScrollSizes(MM_TEXT, sizeTotal); -} - -void CView4::OnDraw(CDC* pDC) -{ - CRect rectClient; - GetClientRect (&rectClient); - - pDC->DPtoLP (&rectClient); - pDC->FillSolidRect (rectClient, ::GetSysColor (COLOR_WINDOW)); - - CString str (_T("This is a scroll view")); - pDC->TextOut (130, 30, str); -} - -///////////////////////////////////////////////////////////////////////////// -// CView4 diagnostics - -#ifdef _DEBUG -void CView4::AssertValid() const -{ - CScrollView::AssertValid(); -} - -void CView4::Dump(CDumpContext& dc) const -{ - CScrollView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CView4 message handlers - -void CView4::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) -{ - CScrollView::OnWindowPosChanging(lpwndpos); - - // Hide horizontal scrollbar: - ShowScrollBar (SB_HORZ, FALSE); - ModifyStyle (WS_HSCROLL, 0, SWP_DRAWFRAME); -} - -CScrollBar* CView4::GetScrollBarCtrl(int nBar) const -{ - if (nBar == SB_HORZ) - { - return GetParentTab ()->GetScrollBar (); - } - - return CScrollView::GetScrollBarCtrl(nBar); -} - -void CView4::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* /*pScrollBar*/) -{ - CScrollView::OnHScroll(nSBCode, nPos, GetParentTab ()->GetScrollBar ()); -} - -BOOL CView4::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View4.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View4.h deleted file mode 100644 index ccd263a5d83ef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/View4.h +++ /dev/null @@ -1,52 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CView4 view - -class CView4 : public CScrollView -{ -protected: - CView4(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CView4) - -// Attributes -public: - CMFCTabCtrl* GetParentTab () const - { - return DYNAMIC_DOWNCAST (CMFCTabCtrl, GetParent ()); - } - -// Operations -public: - -// Overrides - public: - virtual CScrollBar* GetScrollBarCtrl(int nBar) const; - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual void OnInitialUpdate(); // first time after construct - -// Implementation -protected: - virtual ~CView4(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - - afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedView.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedView.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedView.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedView.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedView.rc2 deleted file mode 100644 index 4be031779362b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedView.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// TABBEDVIEW.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedViewDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedViewDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/TabbedViewDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/resource.h deleted file mode 100644 index e432f81857db9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/resource.h +++ /dev/null @@ -1,28 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by TabbedView.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define IDD_FORMVIEW 101 -#define IDR_MAINFRAME 128 -#define IDR_TABBEDTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDD_ABOUTBOX 999 -#define IDC_EDIT1 1041 -#define IDC_CHECK1 1042 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 151 -#define _APS_NEXT_COMMAND_VALUE 32822 -#define _APS_NEXT_CONTROL_VALUE 1043 -#define _APS_NEXT_SYMED_VALUE 107 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview - copy.vcproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview - copy.vcproj deleted file mode 100644 index 1e796c0d056af..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview - copy.vcproj +++ /dev/null @@ -1,528 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview.vcxproj deleted file mode 100644 index c628615bec9d8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview.vcxproj +++ /dev/null @@ -1,241 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {2CE6212A-85F6-4254-938F-EF97A07347AD} - TabbedView - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/TabbedView.tlb - - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - true - .\..\bin/TabbedView.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/TabbedView.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/TabbedView.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview.vcxproj.filters deleted file mode 100644 index 70c14dc4893a5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/tabbedview.vcxproj.filters +++ /dev/null @@ -1,107 +0,0 @@ - - - - - {9168a236-3a26-4d55-b402-9898375fecfd} - h;hpp;hxx;hm;inl - - - {216e78a6-6636-4fb8-a087-637ff8316615} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {54b36ce4-43a2-4e6e-bcdb-81b097f2382e} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TabbedView/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/MainFrm.cpp deleted file mode 100644 index e19b853e6620b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/MainFrm.cpp +++ /dev/null @@ -1,370 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TasksPane.h" - -#include "MainFrm.h" -#include "TasksPaneDoc.h" -#include "TasksPaneView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) - ON_COMMAND(ID_VIEW_TASKPANE, OnViewTaskpane) - ON_UPDATE_COMMAND_UI(ID_VIEW_TASKPANE, OnUpdateViewTaskpane) - ON_COMMAND(ID_TASK1, OnTask) - ON_COMMAND(ID_TASK2, OnTask) - ON_COMMAND(ID_TASK3, OnTask) - ON_COMMAND(ID_TASK4, OnTask) - ON_COMMAND(ID_TASK5, OnTask) - ON_COMMAND(ID_TASK6, OnTask) - ON_COMMAND(ID_TASK7, OnTask) - ON_COMMAND(ID_TASK8, OnTask) - ON_COMMAND(ID_TASK9, OnTask) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007, OnUpdateAppLook) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_nAppLook = ID_VIEW_APPLOOK_2000; - // TODO: add member initialization code here - - CMFCButton::EnableWindowsTheming (); -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - m_nAppLook = ID_VIEW_APPLOOK_2000 + theApp.GetInt (_T("VisualManager"), 3); - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2000: - // enable Office 2000 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_XP: - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_2003: - // enable Office 2003 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - // enable Windows XP look (in other OS Office XP look will be used): - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_VS2005: - // enable VS.NET 2005 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - break; - } - - CMFCToolBar::EnableQuickCustomization (); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - if (!CreateTaskPane ()) - { - TRACE0("Failed to create tasks pane\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndTaskPane.EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT); - EnableDocking(CBRS_ALIGN_ANY); - EnableAutoHidePanes(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane(&m_wndTaskPane); - - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnViewTaskpane() -{ - ShowPane (&m_wndTaskPane, - !(m_wndTaskPane.IsVisible ()), - FALSE, TRUE); - RecalcLayout (); -} - -void CMainFrame::OnUpdateViewTaskpane(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (m_wndTaskPane.IsVisible ()); -} - -BOOL CMainFrame::CreateTaskPane () -{ - CRect rectDummy(0, 0, 200, 400); - if (!m_wndTaskPane.Create(_T("Tasks Pane"), this, rectDummy, TRUE, ID_VIEW_TASKPANE, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | AFX_CBRS_CLOSE | AFX_CBRS_FLOAT)) - { - TRACE0("Failed to create task pane\n"); - return FALSE; // fail to create - } - - return TRUE; -} - -void CMainFrame::OnTask() -{ - MessageBox (_T("TODO: Task")); -} - -void CMainFrame::OnAppLook(UINT id) -{ - m_nAppLook = id; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2000: - // enable Office 2000 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_XP: - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_2003: - // enable Office 2003 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - // enable Windows XP look (in other OS Office XP look will be used): - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_VS2005: - // enable VS.NET 2005 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - break; - - default: - ASSERT (FALSE); - } - - m_wndTaskPane.RecalcLayout (); - - // update form-view: - CTasksPaneView* pView = (CTasksPaneView*) GetActiveView (); - ASSERT_VALID (pView); - - pView->m_nVisualManager = m_nAppLook - ID_VIEW_APPLOOK_2000; - pView->UpdateData (FALSE); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/MainFrm.h deleted file mode 100644 index 501daef193896..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/MainFrm.h +++ /dev/null @@ -1,70 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "TaskPane.h" - -#define CFrameWnd CFrameWndEx - -class CMainFrame : public CFrameWnd -{ - friend class CTasksPaneView; - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - void UpdateMRUFilesList () - { - m_wndTaskPane.UpdateMRUFilesList (); - } - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - CTaskPane m_wndTaskPane; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - afx_msg void OnViewTaskpane(); - afx_msg void OnUpdateViewTaskpane(CCmdUI* pCmdUI); - afx_msg void OnTask(); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); - BOOL CreateTaskPane (); - - UINT m_nAppLook; -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/ReadMe.htm deleted file mode 100644 index b95f3af7e1504..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/ReadMe.htm +++ /dev/null @@ -1,124 +0,0 @@ - - - - TasksPane Sample: MFC Task Pane Application - - -

- TasksPane Sample: MFC Task Pane Application

-
-
-
- -

-

-
-

- The TasksPane sample demonstrates the MFC Task Pane classes and their different - appearances using various properties and visual managers.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the TasksPane sample

-
-
    -
  1. -

    - Open the solution file TasksPane.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The TasksPane sample demonstrates the following keywords:

-

- CDockingManager; CFrameWndEx; CMFCButton; CMFCColorButton; CMFCMenuBar; CMFCPopupMenu; - CMFCStatusBar; CMFCToolBar; CMFCToolBarsCustomizeDialog; CMFCVisualManager; CMFCVisualManagerOffice; - CTaskPane; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/Resource.h deleted file mode 100644 index 6a93ae95f7944..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/Resource.h +++ /dev/null @@ -1,89 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by TasksPane.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDD_TASKSPANE_FORM 101 -#define IDS_MAIN_TOOLBAR 101 -#define IDR_MAINFRAME 128 -#define IDR_TASKSPTYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDB_TOOLBAR256 151 -#define IDB_TASKS 153 -#define IDB_TASKPANE_TOOLBAR 154 -#define IDB_TASKS_HC 155 -#define IDI_NOTE 157 -#define IDD_ABOUTBOX 999 -#define IDC_COMPANY_URL 1041 -#define IDC_CHECK_WRAPTASKS 1046 -#define IDC_CHECK_WRAPLABELS 1047 -#define IDC_CHECK_NAVTOOLBAR 1048 -#define IDC_CHECK_HISTBUTTONS 1049 -#define IDC_CHECK_HICOLORIMAGES 1050 -#define IDC_RADIO_WIN 1051 -#define IDC_RADIO_OFFICEXP 1052 -#define IDC_RADIO_OFFICE2003 1053 -#define IDC_RADIO_WINXP 1054 -#define IDC_CHECK_SCROLLBUTTONS 1055 -#define IDC_CHECK_ANIMATION 1056 -#define IDC_CHECK_MARGINS 1057 -#define IDC_CHECK_COLLAPSEGROUPS 1058 -#define IDC_EDIT_VMARGIN 1059 -#define IDC_EDIT_HMARGIN 1060 -#define IDC_EDIT_GROUPSPACING 1061 -#define IDC_EDIT_TASKSPACING 1062 -#define IDC_EDIT_CAPTIONHEIGHT 1063 -#define IDC_EDIT_TASKOFFSET 1064 -#define IDC_EDIT_ICONOFFSET 1065 -#define IDC_RADIO_VS2005 1066 -#define IDC_RADIO_OFFICE2007 1067 -#define IDC_SPIN3 1068 -#define IDC_SPIN4 1069 -#define IDC_SPIN5 1070 -#define IDC_SPIN6 1071 -#define IDC_SPIN7 1072 -#define IDC_SPIN8 1073 -#define IDC_SPIN9 1074 -#define IDC_COLOR_TASKTEXT 1075 -#define IDC_COLOR_TASKTEXTHOT 1076 -#define IDC_COLOR_GROUPTEXT 1077 -#define IDC_COLOR_GROUPTEXTHOT 1078 -#define IDC_STATIC_MARGINS1 1079 -#define IDC_STATIC_MARGINS2 1080 -#define IDC_STATIC_MARGINS3 1081 -#define IDC_STATIC_MARGINS4 1082 -#define IDC_STATIC_MARGINS5 1083 -#define IDC_STATIC_MARGINS6 1084 -#define IDC_STATIC_MARGINS7 1085 -#define IDC_CHECK_CAPTIONICON 1086 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_TASKPANE 32827 -#define ID_TASK1 32828 -#define ID_TASK2 32829 -#define ID_TASK3 32830 -#define ID_TASK4 32831 -#define ID_TASK5 32832 -#define ID_TASK6 32832 -#define ID_TASK7 32832 -#define ID_TASK8 32832 -#define ID_TASK9 32832 -#define ID_VIEW_APPLOOK_2000 32833 -#define ID_VIEW_APPLOOK_XP 32834 -#define ID_VIEW_APPLOOK_2003 32835 -#define ID_VIEW_APPLOOK_WIN_XP 32836 -#define ID_VIEW_APPLOOK_VS2005 32837 -#define ID_VIEW_APPLOOK_2007 32838 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 158 -#define _APS_NEXT_COMMAND_VALUE 32839 -#define _APS_NEXT_CONTROL_VALUE 1087 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/Snippets.txt deleted file mode 100644 index d35f89e5ebd90..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/Snippets.txt +++ /dev/null @@ -1,4 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -TasksPaneView.h: CMFCVisualManager 1 -TasksPaneView.cpp: CMFCVisualManager 2 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/StdAfx.cpp deleted file mode 100644 index f4a5e2d6cdfbd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/StdAfx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// TasksPane.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/StdAfx.h deleted file mode 100644 index e53eb99aa80fc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/StdAfx.h +++ /dev/null @@ -1,45 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TaskPane.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TaskPane.cpp deleted file mode 100644 index d39efa8e852a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TaskPane.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TasksPane.h" -#include "TaskPane.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTaskPane - -BEGIN_MESSAGE_MAP(CTaskPane, CMFCTasksPane) - ON_WM_CREATE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTaskPane construction/destruction - -CTaskPane::CTaskPane() -{ - m_nDocumentsGroup = -1; - - m_nUserColorGroup = -1; - m_nUserColorTask = -1; - // TODO: add one-time construction code here - -} - -CTaskPane::~CTaskPane() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CTaskPane message handlers - -int CTaskPane::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMFCTasksPane::OnCreate(lpCreateStruct) == -1) - return -1; - - SetCaption (_T("Tasks Pane")); - SetIconsList (IDB_TASKS, 16); - - EnableNavigationToolbar (TRUE); - - EnableWrapLabels (TRUE); - EnableOffsetCustomControls (FALSE); - - m_nDocumentsGroup = AddGroup (_T("Open a document"), FALSE, TRUE); - - // Add MRU list: - AddMRUFilesList (m_nDocumentsGroup); - AddTask (m_nDocumentsGroup, _T("More Documents..."), 0, ID_FILE_OPEN); - - int nPage1Gr2 = AddGroup (_T("Custom group")); - m_nUserColorGroup = nPage1Gr2; - - AddTask (nPage1Gr2, _T("Task 1"), 1, ID_TASK1); - m_nUserColorTask = AddTask (nPage1Gr2, _T("Task 2"), 2, ID_TASK2); - AddTask (nPage1Gr2, _T("Task 3"), 3, ID_TASK3); - AddSeparator (nPage1Gr2); - AddTask (nPage1Gr2, _T("Task 4"), 4, ID_TASK4); - AddTask (nPage1Gr2, _T("Task 5"), 5, ID_TASK5); - AddTask (nPage1Gr2, _T("Long task's name to see words wrap feature"), 6, ID_TASK6); - - int nPage1Gr3 = AddGroup (_T("Details"), TRUE); - AddLabel (nPage1Gr3, _T("The Label contains text, which can be displayed in several lines. \n\nText can include line breaking characters \'\\n\' and &underline markers \'&&\'")); - - // Add second page: - int nPage2 = AddPage (_T("Custom page")); - - int nPage2Gr1 = AddGroup (nPage2, _T("Tree Control")); - - if (!CreateTreeControl()) - { - TRACE0("Failed to create the custom window\n"); - return -1; // fail to create - } - - const int nControlHeight = 65; - - AddWindow (nPage2Gr1, m_wndTree.GetSafeHwnd (), nControlHeight); - AddTask (nPage2Gr1, _T("My favorites..."), 9, ID_TASK9); - - int nPage2Gr2 = AddGroup (nPage2, _T("Edit Control")); - - if (!CreateEditControl()) - { - TRACE0("Failed to create the custom window\n"); - return -1; // fail to create - } - - AddWindow (nPage2Gr2, m_wndEdit.GetSafeHwnd (), nControlHeight); - - // Create tasks pane windows. - // TODO: create your own tasks panes here: - - return 0; -} - -void CTaskPane::UpdateMRUFilesList () -{ - AddMRUFilesList (m_nDocumentsGroup); - RedrawWindow (); -} - -void CTaskPane::UpdateToolbar () -{ - m_wndToolBar.RedrawWindow (); -} - -BOOL CTaskPane::CreateTreeControl() -{ - CRect rectDummy (0, 0, 0, 0); - const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | - TVS_LINESATROOT | TVS_HASBUTTONS; - - if(!m_wndTree.Create (dwTreeStyle, rectDummy, this, (UINT)-1)) - { - TRACE0("Failed to create the custom window\n"); - return FALSE; - } - - m_wndTree.ModifyStyleEx (0, WS_EX_CLIENTEDGE); - - HTREEITEM hRoot = m_wndTree.InsertItem (_T("Folders")); - - m_wndTree.InsertItem (_T("Folder 1"), hRoot); - m_wndTree.InsertItem (_T("Folder 2"), hRoot); - m_wndTree.InsertItem (_T("Folder 3"), hRoot); - m_wndTree.InsertItem (_T("Folder 4"), hRoot); - - m_wndTree.Expand (hRoot, TVE_EXPAND); - - m_wndTree.RedrawWindow (); - return TRUE; -} - -BOOL CTaskPane::CreateEditControl() -{ - CRect rectDummy (0, 0, 0, 0); - DWORD dwEditStyle = WS_CHILD | WS_VISIBLE | - ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; - - m_Font.CreateStockObject (DEFAULT_GUI_FONT); - - if (!m_wndEdit.Create (dwEditStyle, rectDummy, this, (UINT)-1)) - { - TRACE0("Failed to create the edit window\n"); - return FALSE; - } - - m_wndEdit.ModifyStyleEx (0, WS_EX_CLIENTEDGE); - - m_wndEdit.SetFont (&m_Font); - m_wndEdit.SetWindowText( - _T("This is the standard multiline Edit Box.\r\nHere you can type your text.")); - - return TRUE; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TaskPane.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TaskPane.h deleted file mode 100644 index 23de1900d1fc8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TaskPane.h +++ /dev/null @@ -1,53 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CTaskPane : public CMFCTasksPane -{ - friend class CTasksPaneView; - -// Construction -public: - CTaskPane(); - -// Attributes - int m_nUserColorGroup; - int m_nUserColorTask; - -protected: - int m_nDocumentsGroup; - - CFont m_Font; - CTreeCtrl m_wndTree; - CEdit m_wndEdit; - -// Operations -public: - void UpdateMRUFilesList (); - void UpdateToolbar (); - -// Overrides -public: - -protected: - BOOL CreateTreeControl(); - BOOL CreateEditControl(); - -// Implementation -public: - virtual ~CTaskPane(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.cpp deleted file mode 100644 index c5a0a0966dce5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TasksPane.h" - -#include "MainFrm.h" -#include "TasksPaneDoc.h" -#include "TasksPaneView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneApp - -BEGIN_MESSAGE_MAP(CTasksPaneApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinAppEx::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneApp construction - -CTasksPaneApp::CTasksPaneApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CTasksPaneApp object - -CTasksPaneApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneApp initialization - -BOOL CTasksPaneApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CTasksPaneDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CTasksPaneView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CTasksPaneApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneApp message handlers - -int CTasksPaneApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void CTasksPaneApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} - - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneApp message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.h deleted file mode 100644 index 87c3ce1b00b45..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.h +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneApp: -// See TasksPane.cpp for the implementation of this class -// - -class CTasksPaneApp : public CWinAppEx -{ -public: - CTasksPaneApp(); - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - - -extern CTasksPaneApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.rc deleted file mode 100644 index 10d1a3e300cf7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPane.rc +++ /dev/null @@ -1,521 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\TasksPane.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#ifndef _AFXDLL\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar support\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\TasksPane.ico" -IDR_TASKSPTYPE ICON "res\\TasksPaneDoc.ico" -IDI_NOTE ICON "res\\new_node.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDB_TASKS BITMAP "res\\tasks.bmp" -IDB_TOOLBAR256 BITMAP "res\\Toolbar256.bmp" -IDB_TASKPANE_TOOLBAR BITMAP "res\\taskspanetoolbar.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - MENUITEM "Visual Stidio 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "Office 200&7", ID_VIEW_APPLOOK_2007 - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About TasksPane...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Task Pane", ID_VIEW_TASKPANE - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About TasksPane" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "TasksPane Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_TASKSPANE_FORM DIALOGEX 0, 0, 296, 228 -STYLE DS_SETFONT | WS_CHILD -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - GROUPBOX "Visual Manager",IDC_STATIC,16,8,124,83,WS_GROUP,WS_EX_TRANSPARENT - CONTROL "Windows 2000",IDC_RADIO_WIN,"Button",BS_AUTORADIOBUTTON | BS_NOTIFY | WS_GROUP | WS_TABSTOP,28,20,63,10 - CONTROL "Office XP",IDC_RADIO_OFFICEXP,"Button",BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,28,32,80,8 - CONTROL "Office 2003",IDC_RADIO_OFFICE2003,"Button",BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,28,42,53,10 - CONTROL "Windows XP",IDC_RADIO_WINXP,"Button",BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,28,54,57,10 - CONTROL "Visual Studio 2005",IDC_RADIO_VS2005,"Button",BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,28,66,75,10 - CONTROL "Office 2007",IDC_RADIO_OFFICE2007,"Button",BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,28,78,53,10 - GROUPBOX "Behavior",IDC_STATIC,16,95,124,126,0,WS_EX_TRANSPARENT - CONTROL "Navigation toolbar",IDC_CHECK_NAVTOOLBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,106,73,10 - CONTROL "History menu buttons",IDC_CHECK_HISTBUTTONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,118,82,10 - CONTROL "Custom images",IDC_CHECK_HICOLORIMAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,130,63,10 - CONTROL "Scroll buttons",IDC_CHECK_SCROLLBUTTONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,142,59,10 - CONTROL "Wrap words in tasks",IDC_CHECK_WRAPTASKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,156,80,10 - CONTROL "Wrap words in labels",IDC_CHECK_WRAPLABELS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,168,81,10 - CONTROL "Animation",IDC_CHECK_ANIMATION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,180,47,10 - CONTROL "Collapse groups",IDC_CHECK_COLLAPSEGROUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,192,66,10 - CONTROL "Icon in caption",IDC_CHECK_CAPTIONICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,204,63,10 - GROUPBOX "Margins",IDC_STATIC,152,8,128,136,0,WS_EX_TRANSPARENT - CONTROL "Customize margins",IDC_CHECK_MARGINS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,168,20,74,10 - LTEXT "Vertical margin",IDC_STATIC_MARGINS1,180,34,47,8 - LTEXT "Horizontal margin",IDC_STATIC_MARGINS2,172,49,55,8 - LTEXT "Group spacing",IDC_STATIC_MARGINS3,180,64,47,8 - LTEXT "Task spacing",IDC_STATIC_MARGINS4,183,79,44,8 - LTEXT "Caption min height",IDC_STATIC_MARGINS5,168,94,59,8 - LTEXT "Task offset",IDC_STATIC_MARGINS6,191,109,36,8 - LTEXT "Icon offset",IDC_STATIC_MARGINS7,193,124,34,8 - EDITTEXT IDC_EDIT_VMARGIN,232,34,32,14 - CONTROL "Spin3",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,264,34,11,14 - EDITTEXT IDC_EDIT_HMARGIN,232,49,32,14 - CONTROL "Spin4",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,263,49,11,14 - EDITTEXT IDC_EDIT_GROUPSPACING,232,64,32,14 - CONTROL "Spin5",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,264,64,11,14 - EDITTEXT IDC_EDIT_TASKSPACING,232,79,32,14 - CONTROL "Spin6",IDC_SPIN6,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,263,79,11,14 - EDITTEXT IDC_EDIT_CAPTIONHEIGHT,232,94,32,14 - CONTROL "Spin7",IDC_SPIN7,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,264,94,11,14 - EDITTEXT IDC_EDIT_TASKOFFSET,232,109,32,14 - CONTROL "Spin8",IDC_SPIN8,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,264,109,11,14 - EDITTEXT IDC_EDIT_ICONOFFSET,232,124,32,14 - CONTROL "Spin9",IDC_SPIN9,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,264,124,11,14 - GROUPBOX "Colors",IDC_STATIC,152,148,128,72,0,WS_EX_TRANSPARENT - CONTROL "Task's text",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,167,160,35,8 - PUSHBUTTON "Task's text",IDC_COLOR_TASKTEXT,208,156,56,14 - CONTROL "highlighted",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,166,174,35,8 - PUSHBUTTON "highlighted",IDC_COLOR_TASKTEXTHOT,208,171,56,14 - CONTROL "Group's text",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,164,188,38,8 - PUSHBUTTON "Group's text",IDC_COLOR_GROUPTEXT,208,186,56,14 - CONTROL "highlighted",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,166,202,35,8 - PUSHBUTTON "highlighted",IDC_COLOR_GROUPTEXTHOT,208,201,56,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "TasksPane MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "TasksPane" - VALUE "LegalCopyright", "Copyright (C) 2004" - VALUE "OriginalFilename", "TasksPane.EXE" - VALUE "ProductName", "TasksPane Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_TASKSPANE_FORM, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 289 - VERTGUIDE, 28 - VERTGUIDE, 40 - VERTGUIDE, 208 - VERTGUIDE, 232 - VERTGUIDE, 264 - TOPMARGIN, 7 - BOTTOMMARGIN, 221 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "TasksPane\n\nTasksP\n\n\nTasksPane.Document\nTasksP Document" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "TasksPane" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - ID_VIEW_TASKPANE "Show or hide the tasks pane\nToggle TaskPane" - ID_TASK1 "Some Task\nSomeTask" - ID_TASK2 "Some Task\nSomeTask" - ID_TASK3 "Some Task\nSomeTask" - ID_TASK4 "Some Task\nSomeTask" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -STRINGTABLE -BEGIN - ID_TASK5 "Some task\nSome task" - ID_VIEW_APPLOOK_2000 "Activate Office 2000 application look\nOffice 2000 Look" - ID_VIEW_APPLOOK_XP "Activate Office XP application look\nOffice XP Look" - ID_VIEW_APPLOOK_2003 "Activate Office 2003 application look\nOffice 2003 Look" - ID_VIEW_APPLOOK_WIN_XP "Activate Windows XP application look\nWindows XP Look" - ID_VIEW_APPLOOK_VS2005 "Activate VS 2005 application look\nVS 2005 Look" - ID_VIEW_APPLOOK_2007 "Activate Office 2007 application look\nOffice 2007 Look" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\TasksPane.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar support -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneDoc.cpp deleted file mode 100644 index 532eb7a3a0c24..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneDoc.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TasksPane.h" - -#include "TasksPaneDoc.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneDoc - -IMPLEMENT_DYNCREATE(CTasksPaneDoc, CDocument) - -BEGIN_MESSAGE_MAP(CTasksPaneDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneDoc construction/destruction - -CTasksPaneDoc::CTasksPaneDoc() -{ - // TODO: add one-time construction code here - -} - -CTasksPaneDoc::~CTasksPaneDoc() -{ -} - -BOOL CTasksPaneDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - -void CTasksPaneDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU) -{ - CDocument::SetPathName(lpszPathName, bAddToMRU); - - ((CMainFrame*) AfxGetMainWnd ())->UpdateMRUFilesList (); -} - - - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneDoc serialization - -void CTasksPaneDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneDoc diagnostics - -#ifdef _DEBUG -void CTasksPaneDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CTasksPaneDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneDoc.h deleted file mode 100644 index e4685015a2703..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneDoc.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CTasksPaneDoc : public CDocument -{ -protected: // create from serialization only - CTasksPaneDoc(); - DECLARE_DYNCREATE(CTasksPaneDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU = TRUE); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CTasksPaneDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneView.cpp deleted file mode 100644 index 8780d115dd254..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneView.cpp +++ /dev/null @@ -1,597 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TasksPane.h" - -#include "MainFrm.h" -#include "TasksPaneDoc.h" -#include "TasksPaneView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneView - -IMPLEMENT_DYNCREATE(CTasksPaneView, CFormView) - -BEGIN_MESSAGE_MAP(CTasksPaneView, CFormView) - ON_BN_CLICKED(IDC_RADIO_WIN, OnVisualManager) - ON_BN_CLICKED(IDC_CHECK_WRAPTASKS, OnWraptasks) - ON_BN_CLICKED(IDC_CHECK_WRAPLABELS, OnWraplabels) - ON_BN_CLICKED(IDC_CHECK_NAVTOOLBAR, OnNavtoolbar) - ON_BN_CLICKED(IDC_CHECK_HISTBUTTONS, OnHistbuttons) - ON_BN_CLICKED(IDC_CHECK_HICOLORIMAGES, OnHicolorimages) - ON_WM_DESTROY() - ON_BN_CLICKED(IDC_CHECK_SCROLLBUTTONS, OnScrollbuttons) - ON_BN_CLICKED(IDC_CHECK_ANIMATION, OnAnimation) - ON_BN_CLICKED(IDC_CHECK_COLLAPSEGROUPS, OnCollapsegroups) - ON_BN_CLICKED(IDC_CHECK_MARGINS, OnMargins) - ON_BN_CLICKED(IDC_COLOR_GROUPTEXT, OnColorGrouptext) - ON_BN_CLICKED(IDC_COLOR_GROUPTEXTHOT, OnColorGrouptexthot) - ON_BN_CLICKED(IDC_COLOR_TASKTEXT, OnColorTasktext) - ON_BN_CLICKED(IDC_COLOR_TASKTEXTHOT, OnColorTasktexthot) - ON_EN_CHANGE(IDC_EDIT_HMARGIN, OnChangeMargins) - ON_BN_CLICKED(IDC_CHECK_CAPTIONICON, OnCaptionicon) - ON_BN_CLICKED(IDC_RADIO_OFFICEXP, OnVisualManager) - ON_BN_CLICKED(IDC_RADIO_WINXP, OnVisualManager) - ON_BN_CLICKED(IDC_RADIO_OFFICE2003, OnVisualManager) - ON_EN_CHANGE(IDC_EDIT_VMARGIN, OnChangeMargins) - ON_EN_CHANGE(IDC_EDIT_GROUPSPACING, OnChangeMargins) - ON_EN_CHANGE(IDC_EDIT_TASKSPACING, OnChangeMargins) - ON_EN_CHANGE(IDC_EDIT_CAPTIONHEIGHT, OnChangeMargins) - ON_EN_CHANGE(IDC_EDIT_TASKOFFSET, OnChangeMargins) - ON_EN_CHANGE(IDC_EDIT_ICONOFFSET, OnChangeMargins) - ON_BN_CLICKED(IDC_RADIO_OFFICE2007, OnVisualManager) - ON_BN_CLICKED(IDC_RADIO_VS2005, OnVisualManager) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneView construction/destruction - -CTasksPaneView::CTasksPaneView() - : CFormView(CTasksPaneView::IDD) -{ - m_nVisualManager = theApp.GetInt (_T("VisualManager"), 2); - m_bWrapTasks = FALSE; - m_bWrapLabels = TRUE; - m_bNavToolbar = TRUE; - m_bMenuButtons = FALSE; - m_bHicolorImages = FALSE; - m_bCollapseGroups = TRUE; - m_bCustomizeMargins = FALSE; - m_bScrollButtons = TRUE; - m_bAnimation = TRUE; - m_nCaptionHeight = 0; - m_nGroupSpacing = 0; - m_nHMargin = 0; - m_nIconOffset = 0; - m_nTaskOffset = 0; - m_nTaskSpacing = 0; - m_nVMargin = 0; - m_bCaptionIcon = FALSE; -} - -CTasksPaneView::~CTasksPaneView() -{ -} - -void CTasksPaneView::DoDataExchange(CDataExchange* pDX) -{ - CFormView::DoDataExchange(pDX); - - DDX_Control(pDX, IDC_COLOR_TASKTEXTHOT, m_ColorTaskTextHot); - DDX_Control(pDX, IDC_COLOR_TASKTEXT, m_ColorTaskText); - DDX_Control(pDX, IDC_COLOR_GROUPTEXTHOT, m_ColorGroupTextHot); - DDX_Control(pDX, IDC_COLOR_GROUPTEXT, m_ColorGroupText); - - DDX_Control(pDX, IDC_SPIN3, m_VMargin); - DDX_Control(pDX, IDC_SPIN4, m_HMargin); - DDX_Control(pDX, IDC_SPIN5, m_GroupSpacing); - DDX_Control(pDX, IDC_SPIN6, m_TaskSpacing); - DDX_Control(pDX, IDC_SPIN7, m_CaptionHeight); - DDX_Control(pDX, IDC_SPIN8, m_TaskOffset); - DDX_Control(pDX, IDC_SPIN9, m_IconOffset); - - DDX_Radio(pDX, IDC_RADIO_WIN, m_nVisualManager); - DDX_Check(pDX, IDC_CHECK_WRAPTASKS, m_bWrapTasks); - DDX_Check(pDX, IDC_CHECK_WRAPLABELS, m_bWrapLabels); - DDX_Check(pDX, IDC_CHECK_NAVTOOLBAR, m_bNavToolbar); - DDX_Check(pDX, IDC_CHECK_HISTBUTTONS, m_bMenuButtons); - DDX_Check(pDX, IDC_CHECK_HICOLORIMAGES, m_bHicolorImages); - DDX_Check(pDX, IDC_CHECK_COLLAPSEGROUPS, m_bCollapseGroups); - DDX_Check(pDX, IDC_CHECK_MARGINS, m_bCustomizeMargins); - DDX_Check(pDX, IDC_CHECK_SCROLLBUTTONS, m_bScrollButtons); - DDX_Check(pDX, IDC_CHECK_ANIMATION, m_bAnimation); - DDX_Check(pDX, IDC_CHECK_CAPTIONICON, m_bCaptionIcon); - - DDX_Text(pDX, IDC_EDIT_VMARGIN, m_nVMargin); - DDV_MinMaxInt(pDX, m_nVMargin, 0, 25); - DDX_Text(pDX, IDC_EDIT_HMARGIN, m_nHMargin); - DDV_MinMaxInt(pDX, m_nHMargin, 0, 25); - DDX_Text(pDX, IDC_EDIT_GROUPSPACING, m_nGroupSpacing); - DDV_MinMaxInt(pDX, m_nGroupSpacing, 0, 25); - DDX_Text(pDX, IDC_EDIT_TASKSPACING, m_nTaskSpacing); - DDV_MinMaxInt(pDX, m_nTaskSpacing, 0, 25); - DDX_Text(pDX, IDC_EDIT_CAPTIONHEIGHT, m_nCaptionHeight); - DDV_MinMaxInt(pDX, m_nCaptionHeight, 0, 30); - DDX_Text(pDX, IDC_EDIT_TASKOFFSET, m_nTaskOffset); - DDV_MinMaxInt(pDX, m_nTaskOffset, 0, 20); - DDX_Text(pDX, IDC_EDIT_ICONOFFSET, m_nIconOffset); - DDV_MinMaxInt(pDX, m_nIconOffset, 0, 25); -} - -BOOL CTasksPaneView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CFormView::PreCreateWindow(cs); -} - -void CTasksPaneView::OnInitialUpdate() -{ - // There is only one view ever, so it only needs to do the initial - // update once--otherwise the application is resized needlessly. - static BOOL bUpdatedOnce = FALSE; - if (bUpdatedOnce) - return; - bUpdatedOnce = TRUE; - - CFormView::OnInitialUpdate(); - GetParentFrame()->RecalcLayout(); - ResizeParentToFit(); - - // Create color pickers: - m_ColorTaskTextHot.EnableAutomaticButton (_T("Default"), (COLORREF)-1); - m_ColorTaskTextHot.EnableOtherButton (_T("Other")); - m_ColorTaskTextHot.SetColor ((COLORREF)-1); - - m_ColorTaskText.EnableAutomaticButton (_T("Default"), (COLORREF)-1); - m_ColorTaskText.EnableOtherButton (_T("Other")); - m_ColorTaskText.SetColor ((COLORREF)-1); - - m_ColorGroupTextHot.EnableAutomaticButton (_T("Default"), (COLORREF)-1); - m_ColorGroupTextHot.EnableOtherButton (_T("Other")); - m_ColorGroupTextHot.SetColor ((COLORREF)-1); - - m_ColorGroupText.EnableAutomaticButton (_T("Default"), (COLORREF)-1); - m_ColorGroupText.EnableOtherButton (_T("Other")); - m_ColorGroupText.SetColor ((COLORREF)-1); - - OnMargins(); - GetDlgItem (IDC_CHECK_HISTBUTTONS)->EnableWindow (m_bNavToolbar); - - CWindowDC dc (NULL); - int nBitsPerPixel = dc.GetDeviceCaps (BITSPIXEL); - GetDlgItem (IDC_CHECK_HICOLORIMAGES)->EnableWindow (m_bNavToolbar && (nBitsPerPixel > 16)); - - m_VMargin.SetRange(0, 25); - m_HMargin.SetRange(0, 25); - m_GroupSpacing.SetRange(0, 25); - m_TaskSpacing.SetRange(0, 25); - m_CaptionHeight.SetRange(0, 30); - m_TaskOffset.SetRange(0, 20); - m_IconOffset.SetRange(0, 25); -} - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneView printing - -void CTasksPaneView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CTasksPaneView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CTasksPaneView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CTasksPaneView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CTasksPaneView::OnPrint(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add customized printing code here -} - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneView diagnostics - -#ifdef _DEBUG -void CTasksPaneView::AssertValid() const -{ - CFormView::AssertValid(); -} - -void CTasksPaneView::Dump(CDumpContext& dc) const -{ - CFormView::Dump(dc); -} - -CTasksPaneDoc* CTasksPaneView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTasksPaneDoc))); - return (CTasksPaneDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTasksPaneView message handlers - -void CTasksPaneView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} -//****************************************************************************************** -void CTasksPaneView::OnDestroy() -{ - UpdateData (); - - theApp.WriteInt (_T("VisualManager"), m_nVisualManager); - - CFormView::OnDestroy(); -} -//****************************************************************************************** -CTaskPane* CTasksPaneView::GetTasksPane() -{ - CMainFrame* pMainFrm = ((CMainFrame*) AfxGetMainWnd ()); - ASSERT_VALID (pMainFrm); - - return &(pMainFrm->m_wndTaskPane); -} -//****************************************************************************************** -void CTasksPaneView::OnVisualManager() -{ - UpdateData (); - - OnChangeMargins (); - - CMainFrame* pMainFrm = ((CMainFrame*) AfxGetMainWnd ()); - ASSERT_VALID (pMainFrm); - - pMainFrm->OnAppLook (ID_VIEW_APPLOOK_2000 + m_nVisualManager); -} -//****************************************************************************************** -void CTasksPaneView::OnWraptasks() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->EnableWrapTasks (m_bWrapTasks); - pTaskPane->RecalcLayout (); -} -//****************************************************************************************** -void CTasksPaneView::OnWraplabels() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->EnableWrapLabels (m_bWrapLabels); - pTaskPane->RecalcLayout (); -} -//****************************************************************************************** -void CTasksPaneView::OnNavtoolbar() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - CWindowDC dc (NULL); - int nBitsPerPixel = dc.GetDeviceCaps (BITSPIXEL); - if (m_bHicolorImages && (nBitsPerPixel > 16)) - { - pTaskPane->EnableNavigationToolbar (m_bNavToolbar, IDB_TASKPANE_TOOLBAR, CSize (16, 16)); - } - else - { - pTaskPane->EnableNavigationToolbar (m_bNavToolbar); - } - - pTaskPane->RecalcLayout (); - - GetDlgItem (IDC_CHECK_HISTBUTTONS)->EnableWindow (m_bNavToolbar); - GetDlgItem (IDC_CHECK_HICOLORIMAGES)->EnableWindow (m_bNavToolbar && (nBitsPerPixel > 16)); -} -//****************************************************************************************** -void CTasksPaneView::OnHistbuttons() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->EnableHistoryMenuButtons (m_bMenuButtons); - pTaskPane->RecalcLayout (); -} -//****************************************************************************************** -void CTasksPaneView::OnHicolorimages() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - CWindowDC dc (NULL); - int nBitsPerPixel = dc.GetDeviceCaps (BITSPIXEL); - if (m_bHicolorImages && (nBitsPerPixel > 16)) - { - pTaskPane->EnableNavigationToolbar (TRUE, IDB_TASKPANE_TOOLBAR, CSize (16, 16)); - } - else - { - pTaskPane->EnableNavigationToolbar (TRUE); - } - - pTaskPane->UpdateToolbar (); -} -//****************************************************************************************** -void CTasksPaneView::OnScrollbuttons() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->EnableScrollButtons (m_bScrollButtons); - pTaskPane->RecalcLayout (); -} -//****************************************************************************************** -void CTasksPaneView::OnAnimation() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->EnableAnimation (m_bAnimation); -} -//****************************************************************************************** -void CTasksPaneView::OnCollapsegroups() -{ - UpdateData (); - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->EnableGroupCollapse (m_bCollapseGroups); - pTaskPane->RecalcLayout (); -} -//****************************************************************************************** -void CTasksPaneView::OnColorGrouptext() -{ - UpdateData (); - - COLORREF clrTextHot = m_ColorGroupTextHot.GetColor (); // (COLORREF)-1, if default - COLORREF clrText = m_ColorGroupText.GetColor (); // (COLORREF)-1, if default - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->SetGroupTextColor (pTaskPane->m_nUserColorGroup, clrText, clrTextHot); -} -//****************************************************************************************** -void CTasksPaneView::OnColorGrouptexthot() -{ - UpdateData (); - - COLORREF clrTextHot = m_ColorGroupTextHot.GetColor (); // (COLORREF)-1, if default - COLORREF clrText = m_ColorGroupText.GetColor (); // (COLORREF)-1, if default - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->SetGroupTextColor (pTaskPane->m_nUserColorGroup, clrText, clrTextHot); -} -//****************************************************************************************** -void CTasksPaneView::OnColorTasktext() -{ - UpdateData (); - - COLORREF clrTextHot = m_ColorTaskTextHot.GetColor (); // (COLORREF)-1, if default - COLORREF clrText = m_ColorTaskText.GetColor (); // (COLORREF)-1, if default - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->SetTaskTextColor (pTaskPane->m_nUserColorGroup, pTaskPane->m_nUserColorTask, clrText, clrTextHot); -} -//****************************************************************************************** -void CTasksPaneView::OnColorTasktexthot() -{ - UpdateData (); - - COLORREF clrTextHot = m_ColorTaskTextHot.GetColor (); // (COLORREF)-1, if default - COLORREF clrText = m_ColorTaskText.GetColor (); // (COLORREF)-1, if default - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - pTaskPane->SetTaskTextColor (pTaskPane->m_nUserColorGroup, pTaskPane->m_nUserColorTask, clrText, clrTextHot); -} -//****************************************************************************************** -void CTasksPaneView::OnMargins() -{ - UpdateData (); - - GetDlgItem (IDC_EDIT_VMARGIN)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_EDIT_HMARGIN)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_EDIT_GROUPSPACING)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_EDIT_TASKSPACING)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_EDIT_CAPTIONHEIGHT)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_EDIT_TASKOFFSET)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_EDIT_ICONOFFSET)->EnableWindow (m_bCustomizeMargins); - - GetDlgItem (IDC_SPIN3)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_SPIN4)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_SPIN5)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_SPIN6)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_SPIN7)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_SPIN8)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_SPIN9)->EnableWindow (m_bCustomizeMargins); - - GetDlgItem (IDC_STATIC_MARGINS1)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_STATIC_MARGINS2)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_STATIC_MARGINS3)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_STATIC_MARGINS4)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_STATIC_MARGINS5)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_STATIC_MARGINS6)->EnableWindow (m_bCustomizeMargins); - GetDlgItem (IDC_STATIC_MARGINS7)->EnableWindow (m_bCustomizeMargins); - - if (m_bCustomizeMargins) - { - // - // Retrieve visual manager's default values. - m_nVMargin = CMFCVisualManager::GetInstance ()->GetTasksPaneVertMargin (); - m_nHMargin = CMFCVisualManager::GetInstance ()->GetTasksPaneHorzMargin (); - m_nGroupSpacing = CMFCVisualManager::GetInstance ()->GetTasksPaneGroupVertOffset (); - m_nTaskSpacing = CMFCVisualManager::GetInstance ()->GetTasksPaneIconVertOffset (); - m_nCaptionHeight = CMFCVisualManager::GetInstance ()->GetTasksPaneGroupCaptionHeight(); - m_nTaskOffset = CMFCVisualManager::GetInstance ()->GetTasksPaneTaskHorzOffset(); - m_nIconOffset = CMFCVisualManager::GetInstance ()->GetTasksPaneIconHorzOffset(); - // - - UpdateData (FALSE); - } - else - { - // reset visual manager's default values - OnChangeMargins (); - } -} -//****************************************************************************************** -void CTasksPaneView::OnChangeMargins () -{ - if (m_ColorTaskTextHot.GetSafeHwnd () == NULL) - { - return; - } - - if (!UpdateData()) - { - return; - } - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - if (m_bCustomizeMargins) - { - pTaskPane->SetVertMargin (m_nVMargin); - pTaskPane->SetHorzMargin (m_nHMargin); - pTaskPane->SetGroupVertOffset (m_nGroupSpacing); - pTaskPane->SetTasksIconVertOffset (m_nTaskSpacing); - pTaskPane->SetGroupCaptionHeight (m_nCaptionHeight); - pTaskPane->SetTasksHorzOffset (m_nTaskOffset); - pTaskPane->SetTasksIconHorzOffset (m_nIconOffset); - } - else - { - // use visual manager's default values - pTaskPane->SetVertMargin (-1); - pTaskPane->SetHorzMargin (-1); - pTaskPane->SetGroupVertOffset (-1); - pTaskPane->SetTasksIconVertOffset (-1); - pTaskPane->SetGroupCaptionHeight (-1); - pTaskPane->SetTasksHorzOffset (-1); - pTaskPane->SetTasksIconHorzOffset (-1); - } - - pTaskPane->RecalcLayout (); -} -//****************************************************************************************** -void CTasksPaneView::OnCaptionicon() -{ - BOOL bOld = m_bCaptionIcon; - - UpdateData (); - - if (bOld == m_bCaptionIcon) - { - return; - } - - CTaskPane* pTaskPane = GetTasksPane (); - ASSERT_VALID (pTaskPane); - - // -------------------------------------- - // Remove all groups from the first page: - // -------------------------------------- - pTaskPane->RemoveAllGroups (0); - - // ----------------- - // Add groups again: - // ----------------- - if (m_bCaptionIcon) - { - HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle (), - MAKEINTRESOURCE (IDI_NOTE), - IMAGE_ICON, - 0, - 0, - LR_SHARED); - pTaskPane->m_nDocumentsGroup = pTaskPane->AddGroup (0, _T("Open a document"), FALSE, TRUE, hIcon); - } - else - { - pTaskPane->m_nDocumentsGroup = pTaskPane->AddGroup (0, _T("Open a document"), FALSE, TRUE); - } - - // Add MRU list: - pTaskPane->AddMRUFilesList (pTaskPane->m_nDocumentsGroup); - pTaskPane->AddTask (pTaskPane->m_nDocumentsGroup, _T("More Documents..."), 0, ID_FILE_OPEN); - - int nPage1Gr2 = pTaskPane->AddGroup (0, _T("Custom group")); - pTaskPane->m_nUserColorGroup = nPage1Gr2; - - pTaskPane->AddTask (nPage1Gr2, _T("Task 1"), 1, ID_TASK1); - pTaskPane->m_nUserColorTask = - pTaskPane->AddTask (nPage1Gr2, _T("Task 2"), 2, ID_TASK2); - pTaskPane->AddTask (nPage1Gr2, _T("Task 3"), 3, ID_TASK3); - pTaskPane->AddSeparator (nPage1Gr2); - pTaskPane->AddTask (nPage1Gr2, _T("Task 4"), 4, ID_TASK4); - pTaskPane->AddTask (nPage1Gr2, _T("Task 5"), 5, ID_TASK5); - pTaskPane->AddTask (nPage1Gr2, _T("Long task's name to see words wrap feature"), 6, ID_TASK6); - - int nPage1Gr3 = pTaskPane->AddGroup (0, _T("Details"), TRUE); - pTaskPane->AddLabel (nPage1Gr3, _T("The Label contains text, which can be displayed in several lines. \n\nText can include line breaking characters \'\\n\' and &underline markers \'&&\'")); - - // Set custom colors again: - OnColorGrouptext(); - OnColorGrouptexthot(); - OnColorTasktext(); - OnColorTasktexthot(); - - pTaskPane->RecalcLayout (); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneView.h deleted file mode 100644 index d3d080c5ce6d1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/TasksPaneView.h +++ /dev/null @@ -1,113 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "TaskPane.h" - -class CTasksPaneView : public CFormView -{ -protected: // create from serialization only - CTasksPaneView(); - DECLARE_DYNCREATE(CTasksPaneView) - -public: - enum { IDD = IDD_TASKSPANE_FORM }; - CMFCColorButton m_ColorTaskTextHot; - CMFCColorButton m_ColorTaskText; - CMFCColorButton m_ColorGroupTextHot; - CMFCColorButton m_ColorGroupText; - - CSpinButtonCtrl m_VMargin; - CSpinButtonCtrl m_HMargin; - CSpinButtonCtrl m_GroupSpacing; - CSpinButtonCtrl m_TaskSpacing; - CSpinButtonCtrl m_CaptionHeight; - CSpinButtonCtrl m_TaskOffset; - CSpinButtonCtrl m_IconOffset; - - int m_nVisualManager; - - BOOL m_bWrapTasks; - BOOL m_bWrapLabels; - BOOL m_bNavToolbar; - BOOL m_bMenuButtons; - BOOL m_bHicolorImages; - BOOL m_bCollapseGroups; - BOOL m_bCustomizeMargins; - BOOL m_bScrollButtons; - BOOL m_bAnimation; - BOOL m_bCaptionIcon; - - // - int m_nVMargin; - int m_nHMargin; - int m_nGroupSpacing; - int m_nTaskSpacing; - int m_nCaptionHeight; - int m_nTaskOffset; - int m_nIconOffset; - // - -// Attributes -public: - CTasksPaneDoc* GetDocument(); - CTaskPane* GetTasksPane(); - -// Operations -public: - -// Overrides - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnInitialUpdate(); // called first time after construct - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CTasksPaneView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnVisualManager(); - afx_msg void OnWraptasks(); - afx_msg void OnWraplabels(); - afx_msg void OnNavtoolbar(); - afx_msg void OnHistbuttons(); - afx_msg void OnHicolorimages(); - afx_msg void OnDestroy(); - afx_msg void OnScrollbuttons(); - afx_msg void OnAnimation(); - afx_msg void OnCollapsegroups(); - afx_msg void OnMargins(); - afx_msg void OnColorGrouptext(); - afx_msg void OnColorGrouptexthot(); - afx_msg void OnColorTasktext(); - afx_msg void OnColorTasktexthot(); - afx_msg void OnChangeMargins(); - afx_msg void OnCaptionicon(); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in TasksPaneView.cpp -inline CTasksPaneDoc* CTasksPaneView::GetDocument() - { return (CTasksPaneDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPane.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPane.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPane.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPane.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPane.rc2 deleted file mode 100644 index 1ff082f1a012d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPane.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// TASKSPANE.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPaneDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPaneDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/TasksPaneDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/new_node.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/new_node.ico deleted file mode 100644 index 5f52d90393112..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/new_node.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/tasks.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/tasks.bmp deleted file mode 100644 index 32e89e7921096..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/tasks.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/taskspanetoolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/taskspanetoolbar.bmp deleted file mode 100644 index fb7bb7e1a1b18..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/res/taskspanetoolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/taskspane.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/taskspane.vcxproj deleted file mode 100644 index f2eef66c8370d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_TasksPane/cpp/taskspane.vcxproj +++ /dev/null @@ -1,268 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {B259618E-A44B-4EBD-86BB-4338182786FB} - TasksPane - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/TasksPane.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX86 - - - true - .\..\bin/TasksPane.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/TasksPane.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX64 - - - true - .\..\bin/TasksPane.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MainFrm.cpp deleted file mode 100644 index eb16087f14e27..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MainFrm.cpp +++ /dev/null @@ -1,341 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TooltipDemo.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) - -const int iMaxUserToolbars = 10; -const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; -const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnAppLook) - ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnUpdateAppLook) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_nAppLook = theApp.GetInt (_T("ApplicationLook"), ID_VIEW_APPLOOK_2003); - - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - OnAppLook (m_nAppLook); - - // Load toolbar user images: - if (m_UserImages.Load (_T(".\\UserImages.bmp"))) - { - CMFCToolBar::SetUserImages (&m_UserImages); - } - - CMFCToolBar::EnableQuickCustomization (); - - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); - lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_4); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - // Detect color depth. 256 color toolbars can be used in the - // high or true color modes only (bits per pixel is > 8): - CClientDC dc (this); - BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; - - UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - m_wndToolBar.SetWindowText (_T("Standard")); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - - // Allow user-defined toolbars operations: - InitUserToolbars (NULL, - uiFirstUserToolBarId, - uiLastUserToolBarId); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - - // Enable conttol bar context menu (list of bars + customize command): - EnablePaneMenu ( - TRUE, // Enable - ID_VIEW_CUSTOMIZE, // Customize command ID - _T("Customize..."), // Customize command text - ID_VIEW_TOOLBARS); // Menu items with this ID will be replaced by - // toolbars menu - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWndEx::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - pDlgCust->EnableUserDefinedToolbars (); - pDlgCust->Create (); -} - -afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) -{ - // TODO: reset toolbar with id = (UINT) wp to its initial state: - // - // UINT uiToolBarId = (UINT) wp; - // if (uiToolBarId == IDR_MAINFRAME) - // { - // do something with m_wndToolBar - // } - - return 0; -} - -void CMainFrame::OnAppLook(UINT id) -{ - CDockingManager::SetDockingMode (DT_SMART); - - m_nAppLook = id; - - CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D; - - switch (m_nAppLook) - { - case ID_VIEW_APPLOOK_2000: - // enable Office 2000 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); - break; - - case ID_VIEW_APPLOOK_XP: - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case ID_VIEW_APPLOOK_WIN_XP: - // enable Windows XP look (in other OS Office XP look will be used): - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); - break; - - case ID_VIEW_APPLOOK_2003: - // enable Office 2003 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_VS2005: - // enable VS.NET 2005 look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_1: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_2: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_3: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - case ID_VIEW_APPLOOK_2007_4: - // enable Office 2007 look: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - CDockingManager::SetDockingMode (DT_SMART); - break; - - default: - ASSERT (FALSE); - } - - CDockingManager* pDockManager = GetDockingManager (); - if (pDockManager != NULL) - { - ASSERT_VALID (pDockManager); - pDockManager->AdjustPaneFrames (); - } - - CTabbedPane::ResetTabs (); - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - theApp.WriteInt (_T("ApplicationLook"), m_nAppLook); -} - -void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) -{ - pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); -} - -BOOL CMainFrame::OnMenuButtonToolHitTest (CMFCToolBarButton* pButton, TOOLINFO* pTI) -{ - ASSERT_VALID (pButton); - ASSERT (pTI != NULL); - - if (!theApp.m_bTTInPopupMenus || - pButton->m_nID == 0 || - pButton->m_nID == (UINT)-1) - { - return FALSE; - } - - CString strText = pButton->m_strText; - strText.Remove (_T('&')); - - if (strText.IsEmpty ()) - { - return FALSE; - } - - if (pTI) - { - pTI->lpszText = (LPTSTR) ::calloc ((strText.GetLength () + 1), sizeof (TCHAR)); - if (pTI->lpszText) - { - lstrcpy (pTI->lpszText, strText); - } - } - - return TRUE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MainFrm.h deleted file mode 100644 index 3b0352ecb14a3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MainFrm.h +++ /dev/null @@ -1,58 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CMainFrame : public CFrameWndEx -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - - virtual BOOL OnMenuButtonToolHitTest (CMFCToolBarButton* pButton, TOOLINFO* pTI); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - - CMFCToolBarImages m_UserImages; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - void OnToolsViewUserToolbar (UINT id); - void OnUpdateToolsViewUserToolbar (CCmdUI* pCmdUI); - afx_msg void OnAppLook(UINT id); - afx_msg void OnUpdateAppLook(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() - - UINT m_nAppLook; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MyToolTipCtrl.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MyToolTipCtrl.cpp deleted file mode 100644 index 708791f2e17d7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MyToolTipCtrl.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TooltipDemo.h" -#include "MyToolTipCtrl.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMyToolTipCtrl - -IMPLEMENT_DYNCREATE(CMyToolTipCtrl, CMFCToolTipCtrl) - -CMyToolTipCtrl::CMyToolTipCtrl() -{ - m_hIcon = (HICON) ::LoadImage ( - AfxGetResourceHandle (), - MAKEINTRESOURCE (IDI_ICON1), - IMAGE_ICON, - afxGlobalData.m_sizeSmallIcon.cx, - afxGlobalData.m_sizeSmallIcon.cy, - LR_SHARED); -} - -CMyToolTipCtrl::~CMyToolTipCtrl() -{ -} - - -BEGIN_MESSAGE_MAP(CMyToolTipCtrl, CMFCToolTipCtrl) - ON_WM_CREATE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMyToolTipCtrl message handlers - -int CMyToolTipCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMFCToolTipCtrl::OnCreate(lpCreateStruct) == -1) - return -1; - - // Override default parameters: - m_Params.m_bRoundedCorners = TRUE; - - return 0; -} - -CSize CMyToolTipCtrl::GetIconSize () -{ - if (m_pHotButton == NULL) - { - return CSize (0, 0); - } - - ASSERT_VALID (m_pHotButton); - - if (m_pHotButton->m_nID == 0 || - m_pHotButton->m_nID == (UINT)-1) - { - return CSize (0, 0); - } - - return afxGlobalData.m_sizeSmallIcon; -} - -void CMyToolTipCtrl::SetDescription (const CString strDesrciption) -{ - CMFCToolTipCtrl::SetDescription (strDesrciption); - - if (m_pHotButton == NULL) - { - return; - } - - ASSERT_VALID (m_pHotButton); - - if (m_pHotButton->m_nID == 0 || - m_pHotButton->m_nID == (UINT)-1) - { - return; - } - - m_strDescription.Format ( - _T("This is a custom description text for toolbar/menu button with ID = %d.."), - m_pHotButton->m_nID); -} - -void CMyToolTipCtrl::OnFillBackground (CDC* pDC, CRect rect, COLORREF& clrText, COLORREF& clrLine) -{ - ASSERT_VALID (pDC); - - CDrawingManager dm (*pDC); - - dm.FillGradient2 (rect, - RGB (104, 165, 225), RGB (37, 92, 222), 45); - - clrLine = RGB (113, 166, 246); - clrText = RGB (255, 255, 255); -} - -BOOL CMyToolTipCtrl::OnDrawIcon (CDC* pDC, CRect rectImage) -{ - if (m_pHotButton == NULL) - { - return FALSE; - } - - ASSERT_VALID (m_pHotButton); - - if (m_pHotButton->m_nID == 0 || - m_pHotButton->m_nID == (UINT)-1) - { - return FALSE; - } - - ASSERT_VALID (pDC); - - ::DrawIconEx (pDC->GetSafeHdc (), - rectImage.left, rectImage.top, m_hIcon, - 0, 0, 0, NULL, DI_NORMAL); - - return TRUE; -} - -void CMyToolTipCtrl::OnDrawSeparator (CDC* pDC, int x1, int x2, int y) -{ - ASSERT_VALID (pDC); - - CDrawingManager dm (*pDC); - CRect rect (x1, y, x2, y + 1); - - dm.FillGradient (rect, - RGB (255, 201, 109), RGB (255, 247, 225), FALSE); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MyToolTipCtrl.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MyToolTipCtrl.h deleted file mode 100644 index 13244d9645cb7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/MyToolTipCtrl.h +++ /dev/null @@ -1,48 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CMyToolTipCtrl window - -class CMyToolTipCtrl : public CMFCToolTipCtrl -{ - DECLARE_DYNCREATE(CMyToolTipCtrl) - -// Construction -public: - CMyToolTipCtrl(); - -// Attributes -public: - -// Operations -public: - -// Overrides - virtual void SetDescription (const CString strDesrciption); - virtual CSize GetIconSize (); - virtual void OnFillBackground (CDC* pDC, CRect rect, COLORREF& clrText, COLORREF& clrLine); - - virtual BOOL OnDrawIcon (CDC* pDC, CRect rectImage); - virtual void OnDrawSeparator (CDC* pDC, int x1, int x2, int y); - -// Implementation -public: - virtual ~CMyToolTipCtrl(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - - DECLARE_MESSAGE_MAP() - - HICON m_hIcon; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/ReadMe.htm deleted file mode 100644 index 1dcd6181d5a55..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,50 +0,0 @@ - - - - ToolTipDemo Sample: Place holder file - - -

- ToolTipDemo Sample

-
-
-
-
-

-

- Building and Running the Sample

-
-

- To build and run the ToolTipDemo sample:

-
-
    -
  1. -

    - Open the solution ToolTipDemo.sln.

    -
  2. -
  3. -

    - Choose the appropriate platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build Solution.

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging.

    -
  8. -
-
-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/Snippets.txt deleted file mode 100644 index 0ddfbe9f4defa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/Snippets.txt +++ /dev/null @@ -1,3 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -TooltipDemoView.cpp: CSettingsStore 1 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/StdAfx.cpp deleted file mode 100644 index 68d23aab3cb26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/StdAfx.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//******************************************************************************* -// COPYRIGHT NOTES -// --------------- -// This is a sample for BCGControlBar Library for Visual Studio -// Copyright (C) 1998-2007 BCGSoft Ltd. -// All rights reserved. -// -// This source code can be used, distributed or modified -// only under terms and conditions -// of the accompanying license agreement. -//******************************************************************************* -// -// DO NOT REMOVE --- BEGIN EXTERNALLY DEVELOPED SOURCE CODE ID --- DO NOT REMOVE -// $TAG BIZDEV -// $DealPointID: 468154 -// $AgreementType: Inbound License -// $External Origin: BCGSoft CO Ltd. -// $ENDTAG DO NOT REMOVE --- END EXTERNALLY DEVELOPED SOURCE CODE ID --- DO NOT REMOVE -// -//******************************************************************************* -// -// stdafx.cpp : source file that includes just the standard includes -// TooltipDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/StdAfx.h deleted file mode 100644 index bf60cbb2750cd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/StdAfx.h +++ /dev/null @@ -1,70 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows XP or later. -#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. -#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. -#endif - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.cpp deleted file mode 100644 index 92f3dc7a8fb3f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TooltipDemo.h" - -#include "MainFrm.h" -#include "TooltipDemoDoc.h" -#include "TooltipDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoApp - -BEGIN_MESSAGE_MAP(CTooltipDemoApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinAppEx::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoApp construction - -CTooltipDemoApp::CTooltipDemoApp() -{ - m_bTTInPopupMenus = TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CTooltipDemoApp object - -CTooltipDemoApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoApp initialization - -BOOL CTooltipDemoApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("BCGSoft\\BCGControlBarVS\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - InitTooltipManager (); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CTooltipDemoDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CTooltipDemoView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoApp message handlers - -int CTooltipDemoApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -// App command to run the dialog -void CTooltipDemoApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -void CTooltipDemoApp::PreLoadState () -{ - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.h deleted file mode 100644 index 4b96963fe914a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.h +++ /dev/null @@ -1,44 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoApp: -// See TooltipDemo.cpp for the implementation of this class -// - -class CTooltipDemoApp : public CWinAppEx -{ -public: - CTooltipDemoApp(); - - BOOL m_bTTInPopupMenus; - - virtual void PreLoadState (); - -// Overrides - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - -// Implementation - afx_msg void OnAppAbout(); - - DECLARE_MESSAGE_MAP() -}; - -extern CTooltipDemoApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.rc deleted file mode 100644 index 8189867d839db..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemo.rc +++ /dev/null @@ -1,528 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\TooltipDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON DISCARDABLE "res\\icon.ico" -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\TooltipDemo.ico" -IDR_TOOLTITYPE ICON DISCARDABLE "res\\TooltipDemoDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDB_TOOLBAR256 BITMAP MOVEABLE PURE "res\\Toolbar256.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "&Application Look" - BEGIN - MENUITEM "Office &2000", ID_VIEW_APPLOOK_2000 - MENUITEM "Office &XP", ID_VIEW_APPLOOK_XP - MENUITEM "Office 200&3", ID_VIEW_APPLOOK_2003 - MENUITEM "Visual Studio 200&5", ID_VIEW_APPLOOK_VS2005 - MENUITEM "&Windows XP", ID_VIEW_APPLOOK_WIN_XP - POPUP "Office 200&7" - BEGIN - MENUITEM "&Blue Style", ID_VIEW_APPLOOK_2007_1 - - MENUITEM "B&lack Style", ID_VIEW_APPLOOK_2007_2 - - MENUITEM "&Aqua Style", ID_VIEW_APPLOOK_2007_3 - - MENUITEM "&Silver Style", ID_VIEW_APPLOOK_2007_4 - - END - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About TooltipDemo...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About ToolTipDemo" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "ToolTipDemo Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_TOOLTIPDEMO_FORM DIALOG DISCARDABLE 0, 0, 263, 212 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This sample illustrates how to use advanced tooltip features. It demonstrates the following 4 types of tooltips: standard, custom tooltip with parameters, extended and CMFCToolTipCtrl-derived tooltip object.", - IDC_STATIC,7,7,249,30 - LTEXT "Setup the required parameters and move the mouse cursor over toolbar buttons to see the tooltip.", - IDC_STATIC,7,39,249,17 - CONTROL "Use &Standard Tooltip",IDC_TT_TYPE,"Button", - BS_AUTORADIOBUTTON | WS_GROUP,35,66,83,10 - CONTROL "Use &Balloon Tooltip",IDC_TT_TYPE4,"Button", - BS_AUTORADIOBUTTON,35,79,77,10 - CONTROL "Use &Custom Tooltip with Parameters:",IDC_TT_TYPE2, - "Button",BS_AUTORADIOBUTTON,35,94,131,10 - CONTROL "Draw &Icon",IDC_DRAW_ICON,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,58,108,49,10 - CONTROL "Draw &Description",IDC_DRAW_DESCR,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,136,108,70,10 - CONTROL "&Rounded Corners",IDC_ROUNDED_CORNERS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,58,121,71,10 - CONTROL "Draw Label in Bo&ld",IDC_BOLD_LABEL,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,136,121,75,10 - CONTROL "C&ustom Colors",IDC_CUSTOM_COLORS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,58,134,61,10 - CONTROL "Draw Se¶tor",IDC_DRAW_SEPARATOR,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,136,134,65,10 - CONTROL "Us&e Extended &(Visual Manager-based) Tooltip", - IDC_TT_TYPE3,"Button",BS_AUTORADIOBUTTON,35,150,160,10 - CONTROL "Us&e Custom (CMFCToolTipCtrl-derived) Tooltip", - IDC_TT_TYPE5,"Button",BS_AUTORADIOBUTTON,35,167,167,10 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,35,189,190,1 - CONTROL "Show Tooltips in Popup &Menus", - IDC_SHOW_TOOLTIPS_IN_MENU,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,35,195,114,10 - RTEXT "(Not supported by your system)",IDC_NO_BALLOON,136,79, - 106,8 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "ToolTipDemo MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "TooltipDemo\0" - VALUE "LegalCopyright", "Copyright (C) 2007-20086\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "TooltipDemo.EXE\0" - VALUE "ProductName", "TooltipDemo Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_TOOLTIPDEMO_FORM, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 256 - VERTGUIDE, 35 - VERTGUIDE, 58 - VERTGUIDE, 136 - TOPMARGIN, 7 - BOTTOMMARGIN, 205 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "TooltipDemo\n\nToolti\n\n\nToolTipDemo.Document\nToolti Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "TooltipDemo" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_USER_TOOLBAR1 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR2 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR3 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR4 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR5 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR6 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR7 "Show or hide the user toolbar\nToggle User ToolBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_USER_TOOLBAR8 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR9 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR10 "Show or hide the user toolbar\nToggle User ToolBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_APPLOOK_2000 "Activate Office 2000 application look\nOffice 2000 Look" - ID_VIEW_APPLOOK_XP "Activate Office XP application look\nOffice XP Look" - ID_VIEW_APPLOOK_2003 "Activate Office 2003 application look\nOffice 2003 Look" - ID_VIEW_APPLOOK_WIN_XP "Activate Windows XP application look\nWindows XP Look" - ID_VIEW_APPLOOK_VS2005 "Activate Visual Studio.NET 2005 application look\nVS.NET 2005 Look" - ID_VIEW_APPLOOK_2007_1 "Activate Office 2007 application look\nOffice 2007 Look - Blue" - ID_VIEW_APPLOOK_2007_2 "Activate Office 2007 application look\nOffice 2007 Look - Black" - ID_VIEW_APPLOOK_2007_3 "Activate Office 2007 application look\nOffice 2007 Look - Aqua" - ID_VIEW_APPLOOK_2007_4 "Activate Office 2007 application look\nOffice 2007 Look - Silver" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\TooltipDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoDoc.cpp deleted file mode 100644 index 82256da3f744a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoDoc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TooltipDemo.h" - -#include "TooltipDemoDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoDoc - -IMPLEMENT_DYNCREATE(CTooltipDemoDoc, CDocument) - -BEGIN_MESSAGE_MAP(CTooltipDemoDoc, CDocument) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoDoc construction/destruction - -CTooltipDemoDoc::CTooltipDemoDoc() -{ - // TODO: add one-time construction code here - -} - -CTooltipDemoDoc::~CTooltipDemoDoc() -{ -} - -BOOL CTooltipDemoDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoDoc serialization - -void CTooltipDemoDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoDoc diagnostics - -#ifdef _DEBUG -void CTooltipDemoDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CTooltipDemoDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoDoc.h deleted file mode 100644 index d381f4b5d1d5f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoDoc.h +++ /dev/null @@ -1,40 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CTooltipDemoDoc : public CDocument -{ -protected: // create from serialization only - CTooltipDemoDoc(); - DECLARE_DYNCREATE(CTooltipDemoDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CTooltipDemoDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoView.cpp deleted file mode 100644 index 1a228346af455..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoView.cpp +++ /dev/null @@ -1,299 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "TooltipDemo.h" - -#include "TooltipDemoDoc.h" -#include "TooltipDemoView.h" - -#include "MyToolTipCtrl.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoView - -IMPLEMENT_DYNCREATE(CTooltipDemoView, CFormView) - -BEGIN_MESSAGE_MAP(CTooltipDemoView, CFormView) - ON_BN_CLICKED(IDC_BOLD_LABEL, OnApplyParams) - ON_BN_CLICKED(IDC_CUSTOM_COLORS, OnApplyParams) - ON_BN_CLICKED(IDC_DRAW_DESCR, OnApplyParams) - ON_BN_CLICKED(IDC_DRAW_ICON, OnApplyParams) - ON_BN_CLICKED(IDC_ROUNDED_CORNERS, OnApplyParams) - ON_BN_CLICKED(IDC_TT_TYPE, OnApplyParams) - ON_BN_CLICKED(IDC_TT_TYPE2, OnApplyParams) - ON_BN_CLICKED(IDC_TT_TYPE3, OnApplyParams) - ON_BN_CLICKED(IDC_DRAW_SEPARATOR, OnApplyParams) - ON_BN_CLICKED(IDC_SHOW_TOOLTIPS_IN_MENU, OnApplyParams) - ON_BN_CLICKED(IDC_TT_TYPE4, OnApplyParams) - ON_BN_CLICKED(IDC_TT_TYPE5, OnApplyParams) - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoView construction/destruction - -CTooltipDemoView::CTooltipDemoView() - : CFormView(CTooltipDemoView::IDD) -{ - m_nTTType = 0; - m_bBoldLabel = FALSE; - m_bCustomColors = FALSE; - m_bDrawDescription = FALSE; - m_bDrawIcon = FALSE; - m_bRoundedCorners = FALSE; - m_bDrawSeparator = FALSE; - m_bTTInPopupMenus = FALSE; - - m_nTTType = theApp.GetInt (_T("TTType"), 0); - m_bBoldLabel = theApp.GetInt (_T("BoldLabel"), TRUE); - m_bCustomColors = theApp.GetInt (_T("CustomColors"), TRUE); - m_bDrawDescription = theApp.GetInt (_T("DrawDescription"), TRUE); - m_bDrawIcon = theApp.GetInt (_T("DrawIcon"), TRUE); - m_bRoundedCorners = theApp.GetInt (_T("RoundedCorners"), TRUE); - m_bDrawSeparator = theApp.GetInt (_T("DrawSeparator"), TRUE); - m_bTTInPopupMenus = theApp.GetInt (_T("TTInPopupMenus"), TRUE); -} - -CTooltipDemoView::~CTooltipDemoView() -{ -} - -void CTooltipDemoView::DoDataExchange(CDataExchange* pDX) -{ - CFormView::DoDataExchange(pDX); - DDX_Radio(pDX, IDC_TT_TYPE, m_nTTType); - DDX_Check(pDX, IDC_BOLD_LABEL, m_bBoldLabel); - DDX_Check(pDX, IDC_CUSTOM_COLORS, m_bCustomColors); - DDX_Check(pDX, IDC_DRAW_DESCR, m_bDrawDescription); - DDX_Check(pDX, IDC_DRAW_ICON, m_bDrawIcon); - DDX_Check(pDX, IDC_ROUNDED_CORNERS, m_bRoundedCorners); - DDX_Check(pDX, IDC_DRAW_SEPARATOR, m_bDrawSeparator); - DDX_Check(pDX, IDC_SHOW_TOOLTIPS_IN_MENU, m_bTTInPopupMenus); -} - -BOOL CTooltipDemoView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CFormView::PreCreateWindow(cs); -} - -BOOL IsBalloonTooltipAvailable () -{ - // - CSettingsStore reg (FALSE, TRUE); - DWORD dwEnableBalloonTips = 1; - - if (reg.Open (_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced")) && - reg.Read (_T("EnableBalloonTips"), dwEnableBalloonTips)) - { - return dwEnableBalloonTips == 1; - } - // - - return TRUE; -} - -void CTooltipDemoView::OnInitialUpdate() -{ - // There is only one view ever, so it only needs to do the initial - // update once--otherwise the application is resized needlessly. - static BOOL bUpdatedOnce = FALSE; - if (bUpdatedOnce) - return; - bUpdatedOnce = TRUE; - - CFormView::OnInitialUpdate(); - GetParentFrame()->RecalcLayout(); - ResizeParentToFit(); - - // Check for balloon tooltips: - if (!IsBalloonTooltipAvailable ()) - { - if (m_nTTType == 1) - { - m_nTTType = 0; - UpdateData (FALSE); - } - - GetDlgItem (IDC_TT_TYPE4)->EnableWindow (FALSE); - } - else - { - GetDlgItem (IDC_NO_BALLOON)->ShowWindow (SW_HIDE); - } - - OnApplyParams (); -} - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoView printing - -void CTooltipDemoView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CTooltipDemoView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CTooltipDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CTooltipDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -void CTooltipDemoView::OnPrint(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add customized printing code here -} - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoView diagnostics - -#ifdef _DEBUG -void CTooltipDemoView::AssertValid() const -{ - CFormView::AssertValid(); -} - -void CTooltipDemoView::Dump(CDumpContext& dc) const -{ - CFormView::Dump(dc); -} - -CTooltipDemoDoc* CTooltipDemoView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTooltipDemoDoc))); - return (CTooltipDemoDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CTooltipDemoView message handlers - -void CTooltipDemoView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} - -void CTooltipDemoView::OnApplyParams() -{ - UpdateData (); - - EnableControls (); - - afxGlobalData.m_nMaxToolTipWidth = 200; - - theApp.WriteInt (_T("TTType"), m_nTTType); - theApp.WriteInt (_T("BoldLabel"), m_bBoldLabel); - theApp.WriteInt (_T("CustomColors"), m_bCustomColors); - theApp.WriteInt (_T("DrawDescription"), m_bDrawDescription); - theApp.WriteInt (_T("DrawIcon"), m_bDrawIcon); - theApp.WriteInt (_T("RoundedCorners"), m_bRoundedCorners); - theApp.WriteInt (_T("DrawSeparator"), m_bDrawSeparator); - theApp.WriteInt (_T("TTInPopupMenus"), m_bTTInPopupMenus); - - theApp.m_bTTInPopupMenus = m_bTTInPopupMenus; - - if (m_nTTType == 0) // Standard tooltip - { - theApp.GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - NULL, - NULL); - return; - } - - if (m_nTTType == 1) // Balloon tooltip - { - CMFCToolTipInfo paramsBalloon; - paramsBalloon.m_bBalloonTooltip = TRUE; - - theApp.GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS (CMFCToolTipCtrl), - ¶msBalloon); - return; - } - - if (m_nTTType == 3) // Visual Manager-based tooltip - { - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - theApp.GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS (CMFCToolTipCtrl), - ¶ms); - return; - } - - if (m_nTTType == 4) // Custom tooltip - { - theApp.GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS (CMyToolTipCtrl)); - return; - } - - // Custom tooltip with parameters: - CMFCToolTipInfo params; - - params.m_bBoldLabel = m_bBoldLabel; - params.m_bDrawDescription = m_bDrawDescription; - params.m_bDrawIcon = m_bDrawIcon; - params.m_bRoundedCorners = m_bRoundedCorners; - params.m_bDrawSeparator = m_bDrawSeparator; - - if (m_bCustomColors) - { - params.m_clrFill = RGB (255, 255, 255); - params.m_clrFillGradient = RGB (228, 228, 240); - params.m_clrText = RGB (61, 83, 80); - params.m_clrBorder = RGB (144, 149, 168); - } - - theApp.GetTooltipManager ()->SetTooltipParams ( - AFX_TOOLTIP_TYPE_ALL, - RUNTIME_CLASS (CMFCToolTipCtrl), - ¶ms); -} - -void CTooltipDemoView::EnableControls () -{ - BOOL bEnableParams = m_nTTType == 2; - - GetDlgItem (IDC_DRAW_ICON)->EnableWindow (bEnableParams); - GetDlgItem (IDC_DRAW_DESCR)->EnableWindow (bEnableParams); - GetDlgItem (IDC_ROUNDED_CORNERS)->EnableWindow (bEnableParams); - GetDlgItem (IDC_BOLD_LABEL)->EnableWindow (bEnableParams && m_bDrawDescription); - GetDlgItem (IDC_CUSTOM_COLORS)->EnableWindow (bEnableParams); - GetDlgItem (IDC_DRAW_SEPARATOR)->EnableWindow (bEnableParams && m_bDrawDescription); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoView.h deleted file mode 100644 index df9ca98d0e27e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/TooltipDemoView.h +++ /dev/null @@ -1,67 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CTooltipDemoView : public CFormView -{ -protected: // create from serialization only - CTooltipDemoView(); - DECLARE_DYNCREATE(CTooltipDemoView) - -public: - enum { IDD = IDD_TOOLTIPDEMO_FORM }; - int m_nTTType; - BOOL m_bBoldLabel; - BOOL m_bCustomColors; - BOOL m_bDrawDescription; - BOOL m_bDrawIcon; - BOOL m_bRoundedCorners; - BOOL m_bDrawSeparator; - BOOL m_bTTInPopupMenus; - -// Attributes -public: - CTooltipDemoDoc* GetDocument(); - -// Operations -public: - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnInitialUpdate(); // called first time after construct - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); - -// Implementation -public: - virtual ~CTooltipDemoView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg void OnApplyParams(); - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - - DECLARE_MESSAGE_MAP() - - void EnableControls (); -}; - -#ifndef _DEBUG // debug version in TooltipDemoView.cpp -inline CTooltipDemoDoc* CTooltipDemoView::GetDocument() - { return (CTooltipDemoDoc*)m_pDocument; } -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/UserImages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/UserImages.bmp deleted file mode 100644 index affe657025e47..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/UserImages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/Toolbar.bmp deleted file mode 100644 index d501723c1ceb7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/Toolbar256.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/Toolbar256.bmp deleted file mode 100644 index 91a2553037e79..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/Toolbar256.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemo.rc2 deleted file mode 100644 index 44717c6c9fa81..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// TOOLTIPDEMO.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemoDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemoDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/TooltipDemoDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/icon.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/icon.ico deleted file mode 100644 index 9219107b2ad80..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/res/icon.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/resource.h deleted file mode 100644 index 8a2c509e5b38c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/resource.h +++ /dev/null @@ -1,60 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by TooltipDemo.rc -// -#define IDD_ABOUTBOX 100 -#define IDP_OLE_INIT_FAILED 100 -#define IDD_TOOLTIPDEMO_FORM 101 -#define IDR_MAINFRAME 128 -#define IDR_TOOLTITYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDB_TOOLBAR256 151 -#define IDI_ICON1 154 -#define IDC_COMPANY_URL 1041 -#define IDC_TT_TYPE 1042 -#define IDC_TT_TYPE2 1043 -#define IDC_DRAW_ICON 1044 -#define IDC_DRAW_DESCR 1045 -#define IDC_ROUNDED_CORNERS 1046 -#define IDC_BOLD_LABEL 1047 -#define IDC_CUSTOM_COLORS 1048 -#define IDC_TT_TYPE3 1049 -#define IDC_DRAW_SEPARATOR 1050 -#define IDC_SHOW_TOOLTIPS_IN_MENU 1051 -#define IDC_TT_TYPE4 1052 -#define IDC_NO_BALLOON 1053 -#define IDC_TT_TYPE5 1054 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_VIEW_USER_TOOLBAR1 32793 -#define ID_VIEW_USER_TOOLBAR2 32794 -#define ID_VIEW_USER_TOOLBAR3 32795 -#define ID_VIEW_USER_TOOLBAR4 32796 -#define ID_VIEW_USER_TOOLBAR5 32797 -#define ID_VIEW_USER_TOOLBAR6 32798 -#define ID_VIEW_USER_TOOLBAR7 32799 -#define ID_VIEW_USER_TOOLBAR8 32800 -#define ID_VIEW_USER_TOOLBAR9 32801 -#define ID_VIEW_USER_TOOLBAR10 32802 -#define ID_VIEW_APPLOOK_2000 32833 -#define ID_VIEW_APPLOOK_XP 32834 -#define ID_VIEW_APPLOOK_2003 32835 -#define ID_VIEW_APPLOOK_WIN_XP 32836 -#define ID_VIEW_APPLOOK_VS2005 32837 -#define ID_VIEW_APPLOOK_2007_1 32838 -#define ID_VIEW_APPLOOK_2007_2 32839 -#define ID_VIEW_APPLOOK_2007_3 32840 -#define ID_VIEW_APPLOOK_2007_4 32841 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 155 -#define _APS_NEXT_COMMAND_VALUE 32843 -#define _APS_NEXT_CONTROL_VALUE 1054 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/tooltipdemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/tooltipdemo.vcxproj deleted file mode 100644 index a5f5f003b859b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolTipDemo/cpp/tooltipdemo.vcxproj +++ /dev/null @@ -1,266 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Itanium - - - Debug - Win32 - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2BDF43B9-5D59-4630-B07B-4DF615560C71} - TooltipDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - v110 - - - Application - Dynamic - MultiByte - v110 - - - v110 - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.20624.0 - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/TooltipDemo.tlb - - - - - Disabled - .\..\..\BCGControlBarVS;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX86 - - - true - .\..\bin/TooltipDemo.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/TooltipDemo.tlb - - - - - Disabled - .\..\..\BCGControlBarVS;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX64 - - - true - .\..\bin/TooltipDemo.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/MainFrm.cpp deleted file mode 100644 index 7e63b61304f47..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/MainFrm.cpp +++ /dev/null @@ -1,279 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "ToolbarDateTimePicker.h" - -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) - - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - //{{AFX_MSG_MAP(CMainFrame) - ON_WM_CREATE() - ON_COMMAND(ID_DATE, OnDate) - ON_COMMAND(ID_TIME, OnTime) - //}}AFX_MSG_MAP - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // TODO: add member initialization code here - -} - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // enable Office XP look: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - - CMFCToolBar::EnableQuickCustomization (); - - - // TODO: Define your own basic commands. Be sure, that each pulldown - // menu have at least one basic command. - - CList lstBasicCommands; - - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_DATE); - lstBasicCommands.AddTail (ID_TIME); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - if (!m_wndMenuBar.Create (this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - BOOL bValidString; - CString strMainToolbarTitle; - bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText (strMainToolbarTitle); - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -void CMainFrame::OnViewCustomize() -{ - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */ - ); - - //----Example----// - // - CMFCToolBarDateTimeCtrl dateButton (ID_DATE, - GetCmdMgr ()->GetCmdImage (ID_DATE, FALSE)); - // - - pDlgCust->ReplaceButton (ID_DATE, dateButton); - - CMFCToolBarDateTimeCtrl timeButton (ID_TIME, - GetCmdMgr ()->GetCmdImage (ID_TIME, FALSE), - DTS_TIMEFORMAT | DTS_UPDOWN); - pDlgCust->ReplaceButton (ID_TIME, timeButton); - - //----Example----// - - pDlgCust->Create (); -} - -LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp) -{ - CPoint point (AFX_GET_X_LPARAM(lp), AFX_GET_Y_LPARAM(lp)); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ()); - } - - return 0; -} - -LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM) -{ - //----Example----// - - UINT uiToolBarId = (UINT) wp; - - switch (uiToolBarId) - { - case IDR_MAINFRAME: - { - CMFCToolBarDateTimeCtrl dateButton (ID_DATE, - GetCmdMgr ()->GetCmdImage (ID_DATE, FALSE)); - m_wndToolBar.ReplaceButton (ID_DATE, dateButton); - - CMFCToolBarDateTimeCtrl timeButton (ID_TIME, - GetCmdMgr ()->GetCmdImage (ID_TIME, FALSE), - DTS_TIMEFORMAT | DTS_UPDOWN); - m_wndToolBar.ReplaceButton (ID_TIME, timeButton); - } - break; - } - - //----Example----// - - return 0; -} - -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - //--------------------------------------------------------- - // Replace ID_VIEW_TOOLBARS menu item to the toolbars list: - //--------------------------------------------------------- - CFrameWnd::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && - pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0) - { - if (CMFCToolBar::IsCustomizeMode ()) - { - //---------------------------------------------------- - // Don't show toolbars list in the customization mode! - //---------------------------------------------------- - return FALSE; - } - - pMenuPopup->RemoveAllItems (); - - CMenu menu; - VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if (pPopup) - { - pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE); - } - } - - return TRUE; -} - -void CMainFrame::OnDate() -{ - MessageBox (_T("Change date...")); -} - -void CMainFrame::OnTime() -{ - MessageBox (_T("Change time....")); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/MainFrm.h deleted file mode 100644 index 04a7c668b5841..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/MainFrm.h +++ /dev/null @@ -1,73 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#if !defined(AFX_MAINFRM_H__301D021A_120B_40D3_944D_8AEBC3BF7EDD__INCLUDED_) -#define AFX_MAINFRM_H__301D021A_120B_40D3_944D_8AEBC3BF7EDD__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define CFrameWnd CFrameWndEx - -class CMainFrame : public CFrameWnd -{ - -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMainFrame) - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - -// Generated message map functions -protected: - //{{AFX_MSG(CMainFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnDate(); - afx_msg void OnTime(); - //}}AFX_MSG - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnToolbarContextMenu(WPARAM,LPARAM); - DECLARE_MESSAGE_MAP() - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MAINFRM_H__301D021A_120B_40D3_944D_8AEBC3BF7EDD__INCLUDED_) diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ReadMe.htm deleted file mode 100644 index e450c59dde532..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ReadMe.htm +++ /dev/null @@ -1,123 +0,0 @@ - - - - ToolbarDateTimePicker Sample: MFC Toolbar Date Time Picker Application - - -

- ToolbarDateTimePicker Sample: MFC Toolbar Date Time Picker Application

-
-
-
- -

-

-
-

- The ToolbarDateTimePicker sample demonstrates how to integrate a date/time picker - control with the toolbar

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the ToolbarDateTimePicker sample

-
-
    -
  1. -

    - Open the solution file ToolbarDateTimePicker.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The ToolbarDateTimePicker sample demonstrates the following keywords:

-

- CFrameWndEx; CMFCMenuBar; CMFCPopupMenu; CMFCStatusBar; CMFCToolBar; CMFCToolBarDateTimeCtrl; - CMFCToolBarsCustomizeDialog; CMFCVisualManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/Snippets.txt deleted file mode 100644 index c6ee5d4c438d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/Snippets.txt +++ /dev/null @@ -1,3 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -MainFrm.cpp: CMFCToolBarDateTimeCtrl 1 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/StdAfx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/StdAfx.cpp deleted file mode 100644 index b599f87799905..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// ToolbarDateTimePicker.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/StdAfx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/StdAfx.h deleted file mode 100644 index d63f9eeba1b63..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/StdAfx.h +++ /dev/null @@ -1,42 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__9A2D8C2E_AB38_4923_9131_FF96FC525213__INCLUDED_) -#define AFX_STDAFX_H__9A2D8C2E_AB38_4923_9131_FF96FC525213__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include "targetver.h" - -#include // MFC core and standard components -#include // MFC extensions -#include -#include // MFC Automation classes -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - - -#include // MFC support for ribbon and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__9A2D8C2E_AB38_4923_9131_FF96FC525213__INCLUDED_) diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.cpp deleted file mode 100644 index f758023b7eb07..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "ToolbarDateTimePicker.h" - -#include "MainFrm.h" -#include "ToolbarDateTimePickerDoc.h" -#include "ToolbarDateTimePickerView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerApp - -BEGIN_MESSAGE_MAP(CToolbarDateTimePickerApp, CWinApp) - //{{AFX_MSG_MAP(CToolbarDateTimePickerApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerApp construction - -CToolbarDateTimePickerApp::CToolbarDateTimePickerApp() : - CWinAppEx (TRUE /* m_bResourceSmartUpdate */) -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CToolbarDateTimePickerApp object - -CToolbarDateTimePickerApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerApp initialization - -BOOL CToolbarDateTimePickerApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - -#if _MSC_VER < 1400 -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif -#endif - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - SetRegistryBase (_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - CSingleDocTemplate* pDocTemplate; - pDocTemplate = new CSingleDocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CToolbarDateTimePickerDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CToolbarDateTimePickerView)); - AddDocTemplate(pDocTemplate); - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CToolbarDateTimePickerApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerApp message handlers - -int CToolbarDateTimePickerApp::ExitInstance() -{ - - - return CWinAppEx::ExitInstance(); -} - -void CToolbarDateTimePickerApp::PreLoadState () -{ - - GetContextMenuManager()->AddMenu (_T("My menu"), IDR_CONTEXT_MENU); - - // TODO: add another context menus here -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.h deleted file mode 100644 index 6b85f16c7227c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.h +++ /dev/null @@ -1,61 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#if !defined(AFX_TOOLBARDATETIMEPICKER_H__4B2F9451_37DA_46B8_B199_0D4496B694E4__INCLUDED_) -#define AFX_TOOLBARDATETIMEPICKER_H__4B2F9451_37DA_46B8_B199_0D4496B694E4__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerApp: -// See ToolbarDateTimePicker.cpp for the implementation of this class -// - -class CToolbarDateTimePickerApp : public CWinAppEx -{ -public: - CToolbarDateTimePickerApp(); - - virtual void PreLoadState (); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CToolbarDateTimePickerApp) - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - //}}AFX_VIRTUAL - -// Implementation - //{{AFX_MSG(CToolbarDateTimePickerApp) - afx_msg void OnAppAbout(); - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -extern CToolbarDateTimePickerApp theApp; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TOOLBARDATETIMEPICKER_H__4B2F9451_37DA_46B8_B199_0D4496B694E4__INCLUDED_) diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.rc deleted file mode 100644 index 8b8c5857b79ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePicker.rc +++ /dev/null @@ -1,430 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\ToolbarDateTimePicker.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#if !defined(_AFXDLL)\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\ToolbarDateTimePicker.ico" -IDR_TOOLBATYPE ICON DISCARDABLE "res\\ToolbarDateTimePickerDoc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_DATE - BUTTON ID_TIME - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "&Date...", ID_DATE - MENUITEM "&Time...", ID_TIME - END - POPUP "&View" - BEGIN - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Help" - BEGIN - MENUITEM "&About ToolbarDateTimePicker...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU DISCARDABLE -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_POPUP_TOOLBAR MENU DISCARDABLE -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL - "O", ID_FILE_OPEN, VIRTKEY, CONTROL - "S", ID_FILE_SAVE, VIRTKEY, CONTROL - "P", ID_FILE_PRINT, VIRTKEY, CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL - "X", ID_EDIT_CUT, VIRTKEY, CONTROL - "C", ID_EDIT_COPY, VIRTKEY, CONTROL - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About ToolbarDateTimePicker" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "ToolbarDateTimePicker Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "ToolbarDateTimePicker MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "ToolbarDateTimePicker\0" - VALUE "LegalCopyright", "Copyright (C) 2004\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "ToolbarDateTimePicker.EXE\0" - VALUE "ProductName", "ToolbarDateTimePicker Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "ToolbarDateTimePicker\n\nToolba\n\n\nToolbarDateTimePicker.Document\nToolba Document" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "ToolbarDateTimePicker" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompt to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompt to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus\nCustomize" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_DATE "Date picker\nDate Picker" - ID_TIME "Time picker\nTime Picker" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\ToolbarDateTimePicker.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerDoc.cpp deleted file mode 100644 index 298569e2e24a4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerDoc.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "ToolbarDateTimePicker.h" - -#include "ToolbarDateTimePickerDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerDoc - -IMPLEMENT_DYNCREATE(CToolbarDateTimePickerDoc, CDocument) - -BEGIN_MESSAGE_MAP(CToolbarDateTimePickerDoc, CDocument) - //{{AFX_MSG_MAP(CToolbarDateTimePickerDoc) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerDoc construction/destruction - -CToolbarDateTimePickerDoc::CToolbarDateTimePickerDoc() -{ - // TODO: add one-time construction code here - -} - -CToolbarDateTimePickerDoc::~CToolbarDateTimePickerDoc() -{ -} - -BOOL CToolbarDateTimePickerDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerDoc serialization - -void CToolbarDateTimePickerDoc::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - // TODO: add storing code here - } - else - { - // TODO: add loading code here - } -} - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerDoc diagnostics - -#ifdef _DEBUG -void CToolbarDateTimePickerDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CToolbarDateTimePickerDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerDoc commands diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerDoc.h deleted file mode 100644 index bbe5632210a00..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerDoc.h +++ /dev/null @@ -1,63 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#if !defined(AFX_TOOLBARDATETIMEPICKERDOC_H__59449EAA_D51E_42FC_8364_38B835B1AC28__INCLUDED_) -#define AFX_TOOLBARDATETIMEPICKERDOC_H__59449EAA_D51E_42FC_8364_38B835B1AC28__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -class CToolbarDateTimePickerDoc : public CDocument -{ -protected: // create from serialization only - CToolbarDateTimePickerDoc(); - DECLARE_DYNCREATE(CToolbarDateTimePickerDoc) - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CToolbarDateTimePickerDoc) - public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CToolbarDateTimePickerDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CToolbarDateTimePickerDoc) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TOOLBARDATETIMEPICKERDOC_H__59449EAA_D51E_42FC_8364_38B835B1AC28__INCLUDED_) diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerView.cpp deleted file mode 100644 index 0aaaa78e2fb46..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerView.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "ToolbarDateTimePicker.h" - -#include "ToolbarDateTimePickerDoc.h" -#include "ToolbarDateTimePickerView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static const CString strInfo = - _T("This sample illustrates how to use a date/time picker integrated with the toolbar control.\r\n\r\n") - _T("The project was generated by Application Wizard\r\n") - _T("Please note //----Example----// comments in the example source code\r\n"); - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerView - -IMPLEMENT_DYNCREATE(CToolbarDateTimePickerView, CView) - -BEGIN_MESSAGE_MAP(CToolbarDateTimePickerView, CView) - //{{AFX_MSG_MAP(CToolbarDateTimePickerView) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP - ON_WM_CONTEXTMENU() - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerView construction/destruction - -CToolbarDateTimePickerView::CToolbarDateTimePickerView() -{ - // TODO: add construction code here - -} - -CToolbarDateTimePickerView::~CToolbarDateTimePickerView() -{ -} - -BOOL CToolbarDateTimePickerView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerView drawing - -void CToolbarDateTimePickerView::OnDraw(CDC* pDC) -{ - CToolbarDateTimePickerDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - const int iOffset = 20; - - CFont* pFontOld = (CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT); - ASSERT (pFontOld != NULL); - - CRect rectClient; - GetClientRect (&rectClient); - - CRect rectText = rectClient; - rectText.DeflateRect (iOffset, iOffset); - pDC->DrawText (strInfo, rectText, DT_CALCRECT | DT_WORDBREAK); - - rectText.OffsetRect ( (rectClient.Width () - rectText.Width () - 2 * iOffset) / 2, - (rectClient.Height () - rectText.Height () - 2 * iOffset) / 2); - - CRect rectFrame = rectText; - rectFrame.InflateRect (iOffset, iOffset); - - pDC->FillSolidRect (rectFrame, ::GetSysColor (COLOR_INFOBK)); - - rectFrame.DeflateRect (1, 1); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - rectFrame.DeflateRect (2, 2); - pDC->Draw3dRect (rectFrame, ::GetSysColor (COLOR_3DSHADOW), - ::GetSysColor (COLOR_3DLIGHT)); - - pDC->SetTextColor (::GetSysColor (COLOR_INFOTEXT)); - pDC->SetBkMode (TRANSPARENT); - - pDC->DrawText (strInfo, rectText, DT_WORDBREAK); - - pDC->SelectObject (pFontOld); -} - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerView printing - -void CToolbarDateTimePickerView::OnFilePrintPreview() -{ - AFXPrintPreview (this); -} - -BOOL CToolbarDateTimePickerView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CToolbarDateTimePickerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add extra initialization before printing -} - -void CToolbarDateTimePickerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ - // TODO: add cleanup after printing -} - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerView diagnostics - -#ifdef _DEBUG -void CToolbarDateTimePickerView::AssertValid() const -{ - CView::AssertValid(); -} - -void CToolbarDateTimePickerView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -CToolbarDateTimePickerDoc* CToolbarDateTimePickerView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CToolbarDateTimePickerDoc))); - return (CToolbarDateTimePickerDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CToolbarDateTimePickerView message handlers - -void CToolbarDateTimePickerView::OnContextMenu(CWnd*, CPoint point) -{ - theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerView.h deleted file mode 100644 index ef00e050b1174..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/ToolbarDateTimePickerView.h +++ /dev/null @@ -1,75 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#if !defined(AFX_TOOLBARDATETIMEPICKERVIEW_H__2921CCF1_7FF3_4E5E_A361_E8FF8F313192__INCLUDED_) -#define AFX_TOOLBARDATETIMEPICKERVIEW_H__2921CCF1_7FF3_4E5E_A361_E8FF8F313192__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -class CToolbarDateTimePickerView : public CView -{ -protected: // create from serialization only - CToolbarDateTimePickerView(); - DECLARE_DYNCREATE(CToolbarDateTimePickerView) - -// Attributes -public: - CToolbarDateTimePickerDoc* GetDocument(); - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CToolbarDateTimePickerView) - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CToolbarDateTimePickerView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CToolbarDateTimePickerView) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnFilePrintPreview(); - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in ToolbarDateTimePickerView.cpp -inline CToolbarDateTimePickerDoc* CToolbarDateTimePickerView::GetDocument() - { return (CToolbarDateTimePickerDoc*)m_pDocument; } -#endif - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TOOLBARDATETIMEPICKERVIEW_H__2921CCF1_7FF3_4E5E_A361_E8FF8F313192__INCLUDED_) diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/Toolbar.bmp deleted file mode 100644 index 6eefffb7499c0..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePicker.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePicker.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePicker.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePicker.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePicker.rc2 deleted file mode 100644 index 7a4e4d6768082..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePicker.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// TOOLBARDATETIMEPICKER.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePickerDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePickerDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/res/ToolbarDateTimePickerDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/resource.h deleted file mode 100644 index 673b40e914892..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/resource.h +++ /dev/null @@ -1,29 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by ToolbarDateTimePicker.rc -// -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define IDR_MAINFRAME 128 -#define IDR_TOOLBATYPE 129 -#define IDR_CONTEXT_MENU 130 -#define IDR_POPUP_TOOLBAR 131 -#define IDD_ABOUTBOX 999 -#define IDC_COMPANY_URL 1041 -#define IDC_DATETIMEPICKER1 1042 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_TOOLBARS 32771 -#define ID_DATE 32833 -#define ID_TIME 32834 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 154 -#define _APS_NEXT_COMMAND_VALUE 32835 -#define _APS_NEXT_CONTROL_VALUE 1043 -#define _APS_NEXT_SYMED_VALUE 108 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/toolbardatetimepicker.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/toolbardatetimepicker.vcxproj deleted file mode 100644 index 67b897f02d798..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/toolbardatetimepicker.vcxproj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {DC8F4072-97AB-4084-AF09-30A70A750A74} - ToolbarDateTimePicker - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - false - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\bin/ToolbarDateTimePicker.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - false - - - MachineX86 - - - true - .\..\bin/ToolbarDateTimePicker.bsc - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\bin/ToolbarDateTimePicker.tlb - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - stdafx.h - $(IntDir)$(TargetName).pch - $(IntDir) - $(IntDir) - $(IntDir)$(TargetName).pdb - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - %(DelayLoadDLLs) - true - $(IntDir)$(TargetName).pdb - Windows - MachineX64 - - - true - .\..\bin/ToolbarDateTimePicker.bsc - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - Create - %(PreprocessorDefinitions) - Create - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - true - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/toolbardatetimepicker.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/toolbardatetimepicker.vcxproj.filters deleted file mode 100644 index b8006fd839846..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_ToolbarDateTimePicker/cpp/toolbardatetimepicker.vcxproj.filters +++ /dev/null @@ -1,77 +0,0 @@ - - - - - {37f62ad8-4f47-4c2a-847b-1f4f6c2d8b85} - h;hpp;hxx;hm;inl - - - {a1156fcb-da38-45be-8834-46b56b44dc1d} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {84161595-f43f-4f4f-81c1-657a801e99d0} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/AppLookDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/AppLookDlg.cpp deleted file mode 100644 index ea56f03c077d5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/AppLookDlg.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "AppLookDlg.h" -#include "MainFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg dialog - -CAppLookDlg::CAppLookDlg(BOOL bStartup, CWnd* pParent /*=NULL*/) : - CDialog(CAppLookDlg::IDD, pParent), m_bStartup(bStartup) -{ - m_bShowAtStartup = FALSE; - m_bOneNoteTabs = TRUE; - m_bDockTabColors = FALSE; - m_bRoundedTabs = FALSE; - m_bCustomTooltips = TRUE; - m_nAppLook = 3; - m_nStyle = 0; - m_bActiveTabCloseButton = FALSE; - - m_nAppLook = theApp.GetInt(_T("AppLook"), 3); - m_nStyle = theApp.GetInt(_T("AppStyle"), 0);; - m_bShowAtStartup = theApp.GetInt(_T("ShowAppLookAtStartup"), TRUE); - m_bOneNoteTabs = theApp.GetInt(_T("OneNoteTabs"), TRUE); - m_bDockTabColors = theApp.GetInt(_T("DockTabColors"), FALSE); - m_bRoundedTabs = theApp.GetInt(_T("RoundedTabs"), FALSE); - m_bCustomTooltips = theApp.GetInt(_T("CustomTooltips"), TRUE); - m_bActiveTabCloseButton = theApp.GetInt(_T("ActiveTabCloseButton"), FALSE); -} - -void CAppLookDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_STYLE, m_wndStyle); - DDX_Control(pDX, IDC_ROUNDED_TABS, m_wndRoundedTabs); - DDX_Control(pDX, IDC_DOCK_TAB_COLORS, m_wndDockTabColors); - DDX_Control(pDX, IDC_ONENOTE_TABS, m_wndOneNoteTabs); - DDX_Control(pDX, IDOK, m_wndOK); - DDX_Control(pDX, IDCANCEL, m_wndCancel); - DDX_Check(pDX, IDC_SHOW_AT_STARTUP, m_bShowAtStartup); - DDX_Check(pDX, IDC_ONENOTE_TABS, m_bOneNoteTabs); - DDX_Check(pDX, IDC_DOCK_TAB_COLORS, m_bDockTabColors); - DDX_Check(pDX, IDC_ROUNDED_TABS, m_bRoundedTabs); - DDX_Check(pDX, IDC_CUSTOM_TOOLTIPS, m_bCustomTooltips); - DDX_CBIndex(pDX, IDC_APP_LOOK, m_nAppLook); - DDX_CBIndex(pDX, IDC_STYLE, m_nStyle); - DDX_Check(pDX, IDC_ACTIVETAB_CLOSE_BUTTON, m_bActiveTabCloseButton); -} - -BEGIN_MESSAGE_MAP(CAppLookDlg, CDialog) - ON_BN_CLICKED(IDC_APPLY, OnApply) - ON_CBN_SELENDOK(IDC_APP_LOOK, OnAppLook) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg message handlers - -BOOL CAppLookDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - UpdateData(FALSE); - OnAppLook(); - - if (m_bStartup) - { - SetLook(); - - if (!m_bShowAtStartup) - { - EndDialog(IDCANCEL); - return TRUE; - } - - CRect rectBtn; - - // Hide "Cancel" button: - m_wndCancel.GetWindowRect(rectBtn); - ScreenToClient(rectBtn); - - m_wndOK.MoveWindow(rectBtn); - - m_wndCancel.EnableWindow(FALSE); - m_wndCancel.ShowWindow(SW_HIDE); - } - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CAppLookDlg::OnOK() -{ - SetLook(); - CDialog::OnOK(); -} - -void CAppLookDlg::SetLook() -{ - CWaitCursor wait; - - UpdateData(); - - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); - if (pMainFrame != NULL) - { - pMainFrame->LockWindowUpdate(); - } - - CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D; - - switch (m_nAppLook) - { - case 0: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); - break; - - case 1: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); - break; - - case 2: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); - break; - - case 3: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); - - if (m_bRoundedTabs) - { - CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D_ROUNDED; - } - - CMFCVisualManagerVS2005::m_bRoundedAutohideButtons = m_bRoundedTabs; - break; - - case 4: - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); - CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; - break; - - case 5: - switch (m_nStyle) - { - case 0: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case 1: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case 2: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - - case 3: - CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); - break; - } - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); - break; - } - - theApp.WriteInt(_T("AppLook"), m_nAppLook); - theApp.WriteInt(_T("ShowAppLookAtStartup"), m_bShowAtStartup); - theApp.WriteInt(_T("OneNoteTabs"), m_bOneNoteTabs); - theApp.WriteInt(_T("DockTabColors"), m_bDockTabColors); - theApp.WriteInt(_T("RoundedTabs"), m_bRoundedTabs); - theApp.WriteInt(_T("CustomTooltips"), m_bCustomTooltips); - theApp.WriteInt(_T("AppStyle"), m_nStyle); - theApp.WriteInt(_T("ActiveTabCloseButton"), m_bActiveTabCloseButton); - - switch (m_nAppLook) - { - case 2: // Office 2003 - case 3: // VS.NET 2005 - case 4: // Windows XP - case 5: // Office 2007 - { - CWindowDC dc(NULL); - theApp.m_bHiColorIcons = dc.GetDeviceCaps(BITSPIXEL) >= 16; - - CDockingManager::SetDockingMode(DT_SMART); - } - break; - - default: - theApp.m_bHiColorIcons = FALSE; - } - - CTabbedPane::ResetTabs(); - - if (m_bCustomTooltips) - { - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), ¶ms); - } - else - { - theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, NULL, NULL); - } - - if (pMainFrame != NULL) - { - pMainFrame->OnChangeLook(m_bOneNoteTabs/* OneNote tabs */, m_bOneNoteTabs /* MDI tab colors*/, m_nAppLook != 0 /* VS.NET look */, m_bDockTabColors /* Dock tab colors*/, m_nAppLook == 3 /* VS.NET 2005 MDI tabs */, m_bActiveTabCloseButton); - - pMainFrame->UnlockWindowUpdate(); - pMainFrame->RedrawWindow(); - } -} - -void CAppLookDlg::OnApply() -{ - SetLook(); - - if (!m_bStartup) - { - m_wndCancel.SetWindowText(_T("Close")); - } -} - -void CAppLookDlg::OnAppLook() -{ - UpdateData(); - - m_wndRoundedTabs.EnableWindow(m_nAppLook == 3); - m_wndStyle.EnableWindow(m_nAppLook == 5); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/AppLookDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/AppLookDlg.h deleted file mode 100644 index 45ba6721dfcd9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/AppLookDlg.h +++ /dev/null @@ -1,54 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg dialog - -class CAppLookDlg : public CDialog -{ -// Construction -public: - CAppLookDlg(BOOL bStartup, CWnd* pParent = NULL); // standard constructor - -// Dialog Data - enum { IDD = IDD_APP_LOOK }; - CComboBox m_wndStyle; - CButton m_wndRoundedTabs; - CButton m_wndDockTabColors; - CButton m_wndOneNoteTabs; - CButton m_wndOK; - CButton m_wndCancel; - BOOL m_bShowAtStartup; - BOOL m_bOneNoteTabs; - BOOL m_bDockTabColors; - BOOL m_bRoundedTabs; - BOOL m_bCustomTooltips; - int m_nAppLook; - int m_nStyle; - BOOL m_bActiveTabCloseButton; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void OnApply(); - afx_msg void OnAppLook(); - - DECLARE_MESSAGE_MAP() - - const BOOL m_bStartup; - - void SetLook(); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ChildFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ChildFrm.cpp deleted file mode 100644 index 3ee0acaf1d4ac..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ChildFrm.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "StartView.h" - -#include "ChildFrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame - -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) - ON_WM_CREATE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here - -} - -CChildFrame::~CChildFrame() -{ -} - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - cs.style &= ~WS_SYSMENU; - - if (!CMDIChildWndEx::PreCreateWindow(cs)) - return FALSE; - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWndEx::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame message handlers - -int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - return 0; -} - -void CChildFrame::ActivateFrame(int nCmdShow) -{ - nCmdShow = SW_MAXIMIZE; - CMDIChildWndEx::ActivateFrame(nCmdShow); -} - -// -BOOL CChildFrame::IsReadOnly() -{ - return DYNAMIC_DOWNCAST(CStartView, GetActiveView()) != NULL; -} -// - -// -LPCTSTR CChildFrame::GetDocumentName(CObject** pObj) -{ - if (DYNAMIC_DOWNCAST(CStartView, GetActiveView()) != NULL) - { - return g_strStartViewName; - } - return CMDIChildWndEx::GetDocumentName(pObj); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ChildFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ChildFrm.h deleted file mode 100644 index c333d84a18a28..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ChildFrm.h +++ /dev/null @@ -1,43 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -static CString g_strStartViewName = _T("mslocal://StartPage"); - -// -class CChildFrame : public CMDIChildWndEx -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Overrides -public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual void ActivateFrame(int nCmdShow = -1); - - virtual BOOL IsReadOnly(); - virtual LPCTSTR GetDocumentName(CObject** pObj); - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - - DECLARE_MESSAGE_MAP() -}; -// - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassTreeWnd.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassTreeWnd.cpp deleted file mode 100644 index 54c5987588498..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassTreeWnd.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "ClassTreeWnd.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CClassTreeWnd - -CClassTreeWnd::CClassTreeWnd() -{ -} - -CClassTreeWnd::~CClassTreeWnd() -{ -} - -BEGIN_MESSAGE_MAP(CClassTreeWnd, CTreeCtrl) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CClassTreeWnd message handlers - -BOOL CClassTreeWnd::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); - - NMHDR* pNMHDR = (NMHDR*)lParam; - ASSERT(pNMHDR != NULL); - - if (pNMHDR->code == TTN_SHOW && GetToolTips() != NULL) - { - GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); - } - - return bRes; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassTreeWnd.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassTreeWnd.h deleted file mode 100644 index 9f408eedb452e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassTreeWnd.h +++ /dev/null @@ -1,31 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CClassTreeWnd window - -class CClassTreeWnd : public CTreeCtrl -{ -// Construction -public: - CClassTreeWnd(); - -// Overrides -protected: - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - -// Implementation -public: - virtual ~CClassTreeWnd(); - -protected: - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassViewBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassViewBar.cpp deleted file mode 100644 index d9d28d9d21efd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassViewBar.cpp +++ /dev/null @@ -1,341 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "MainFrm.h" -#include "ClassViewBar.h" - -class CClassViewMenuButton : public CMFCToolBarMenuButton -{ - friend class CClassViewBar; - - DECLARE_SERIAL(CClassViewMenuButton) - -public: - CClassViewMenuButton(HMENU hMenu = NULL) : CMFCToolBarMenuButton((UINT)-1, hMenu, -1) - { - } - - virtual void OnDraw(CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, - BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE) - { - pImages = CMFCToolBar::GetImages(); - - CAfxDrawState ds; - pImages->PrepareDrawImage(ds); - - CMFCToolBarMenuButton::OnDraw(pDC, rect, pImages, bHorz, bCustomizeMode, bHighlight, bDrawBorder, bGrayDisabledButtons); - - pImages->EndDrawImage(ds); - } -}; - -IMPLEMENT_SERIAL(CClassViewMenuButton, CMFCToolBarMenuButton, 1) - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CClassViewBar::CClassViewBar() -{ - m_nCurrSort = ID_SORTING_GROUPBYTYPE; -} - -CClassViewBar::~CClassViewBar() -{ -} - -BEGIN_MESSAGE_MAP(CClassViewBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_CLASS_ADD_MEMEBER_FUNCTION, OnClassAddMemeberFunction) - ON_COMMAND(ID_CLASS_ADD_MEMEBER_VARIABLE, OnClassAddMemeberVariable) - ON_COMMAND(ID_CLASS_DEFINITION, OnClassDefinition) - ON_COMMAND(ID_CLASS_PROPERTIES, OnClassProperties) - ON_COMMAND(ID_NEW_FOLDER, OnNewFolder) - ON_WM_PAINT() - ON_WM_SETFOCUS() - ON_COMMAND_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnSort) - ON_UPDATE_COMMAND_UI_RANGE(ID_SORTING_GROUPBYTYPE, ID_SORTING_SORTBYACCESS, OnUpdateSort) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CClassViewBar message handlers - -int CClassViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create views: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - - if (!m_wndClassView.Create(dwViewStyle, rectDummy, this, 2)) - { - TRACE0("Failed to create Class View\n"); - return -1; // fail to create - } - - // Load images: - m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SORT); - m_wndToolBar.LoadToolBar(IDR_SORT, 0, 0, TRUE /* Is locked */); - - OnChangeVisualStyle(); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - m_wndToolBar.SetOwner(this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame(FALSE); - - CMenu menuSort; - menuSort.LoadMenu(IDR_POPUP_SORT); - - m_wndToolBar.ReplaceButton(ID_SORT_MENU, CClassViewMenuButton(menuSort.GetSubMenu(0)->GetSafeHmenu())); - - CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); - - if (pButton != NULL) - { - pButton->m_bText = FALSE; - pButton->m_bImage = TRUE; - pButton->SetImage(GetCmdMgr()->GetCmdImage(m_nCurrSort)); - pButton->SetMessageWnd(this); - } - - // Fill view context(dummy code, don't seek here something magic :-)): - FillClassView(); - - return 0; -} - -void CClassViewBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout(); -} - -void CClassViewBar::FillClassView() -{ - HTREEITEM hRoot = m_wndClassView.InsertItem(_T("Hello classes"), 0, 0); - m_wndClassView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); - - HTREEITEM hClass = m_wndClassView.InsertItem(_T("CAboutDlg"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("CAboutDlg()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("DoDataExchange(CDataExchange* pDX)"), 4, 4, hClass); - - m_wndClassView.Expand(hRoot, TVE_EXPAND); - - hClass = m_wndClassView.InsertItem(_T("CHelloApp"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("CHelloApp()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("InitInstance()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("OnAppAbout()"), 3, 3, hClass); - - hClass = m_wndClassView.InsertItem(_T("CHelloDoc"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("AssertValid()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("CHelloDoc()"), 4, 4, hClass); - m_wndClassView.InsertItem(_T("~CHelloDoc()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("Dump(CDumpContext& dc)"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("OnNewDocument()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("Serialize()"), 3, 3, hClass); - - hClass = m_wndClassView.InsertItem(_T("CHelloView"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("AssertValid()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("CHelloView()"), 4, 4, hClass); - m_wndClassView.InsertItem(_T("~CHelloView()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("Dump(CDumpContext& dc)"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("GetDocument()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("OnDraw(CDC* pDC)"), 3, 3, hClass); - m_wndClassView.Expand(hClass, TVE_EXPAND); - - hClass = m_wndClassView.InsertItem(_T("CMainFrame"), 1, 1, hRoot); - m_wndClassView.InsertItem(_T("AssertValid()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("CMainFrame()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("~CMainFrame()"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("Dump(CDumpContext& dc)"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("OnCreate(LPCREATESTRUCT lpCreateStruct)"), 4, 4, hClass); - m_wndClassView.InsertItem(_T("PreCreateWindow(CREATESTRUCT& cs)"), 3, 3, hClass); - m_wndClassView.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass); - m_wndClassView.InsertItem(_T("m_wndToolBar"), 6, 6, hClass); - m_wndClassView.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass); - - hClass = m_wndClassView.InsertItem(_T("Globals"), 2, 2, hRoot); - m_wndClassView.InsertItem(_T("theApp"), 5, 5, hClass); - m_wndClassView.Expand(hClass, TVE_EXPAND); -} - -void CClassViewBar::OnContextMenu(CWnd* pWnd, CPoint point) -{ - CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndClassView; - ASSERT_VALID(pWndTree); - - if (pWnd != pWndTree) - { - CDockablePane::OnContextMenu(pWnd, point); - return; - } - - if (point != CPoint(-1, -1)) - { - // Select clicked item: - CPoint ptTree = point; - pWndTree->ScreenToClient(&ptTree); - - HTREEITEM hTreeItem = pWndTree->HitTest(ptTree); - if (hTreeItem != NULL) - { - pWndTree->SelectItem(hTreeItem); - } - } - - pWndTree->SetFocus(); - CMenu menu; - menu.LoadMenu(IDR_POPUP_SORT); - - CMenu* pSumMenu = menu.GetSubMenu(0); - - if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - - if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) - return; - - ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); - UpdateDialogControls(this, FALSE); - } -} - -void CClassViewBar::AdjustLayout() -{ - if (GetSafeHwnd() == NULL) - { - return; - } - - CRect rectClient; - GetClientRect(rectClient); - - int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; - - m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndClassView.SetWindowPos(NULL, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); -} - -BOOL CClassViewBar::PreTranslateMessage(MSG* pMsg) -{ - return CDockablePane::PreTranslateMessage(pMsg); -} - -void CClassViewBar::OnSort(UINT id) -{ - if (m_nCurrSort == id) - { - return; - } - - m_nCurrSort = id; - - CClassViewMenuButton* pButton = DYNAMIC_DOWNCAST(CClassViewMenuButton, m_wndToolBar.GetButton(0)); - - if (pButton != NULL) - { - pButton->SetImage(GetCmdMgr()->GetCmdImage(id)); - m_wndToolBar.Invalidate(); - m_wndToolBar.UpdateWindow(); - } -} - -void CClassViewBar::OnUpdateSort(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(pCmdUI->m_nID == m_nCurrSort); -} - -void CClassViewBar::OnClassAddMemeberFunction() -{ - AfxMessageBox(_T("Add member function...")); -} - -void CClassViewBar::OnClassAddMemeberVariable() -{ - // TODO: Add your command handler code here -} - -void CClassViewBar::OnClassDefinition() -{ - // TODO: Add your command handler code here -} - -void CClassViewBar::OnClassProperties() -{ - // TODO: Add your command handler code here -} - -void CClassViewBar::OnNewFolder() -{ - AfxMessageBox(_T("New Folder...")); -} - -void CClassViewBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndClassView.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void CClassViewBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - - m_wndClassView.SetFocus(); -} - -void CClassViewBar::OnChangeVisualStyle() -{ - m_ClassViewImages.DeleteImageList(); - - UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_24 : IDB_CLASS_VIEW; - - CBitmap bmp; - if (!bmp.LoadBitmap(uiBmpId)) - { - TRACE(_T("Can't load bitmap: %x\n"), uiBmpId); - ASSERT(FALSE); - return; - } - - BITMAP bmpObj; - bmp.GetBitmap(&bmpObj); - - UINT nFlags = ILC_MASK; - - nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; - - m_ClassViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); - m_ClassViewImages.Add(&bmp, RGB(255, 0, 0)); - - m_wndClassView.SetImageList(&m_ClassViewImages, TVSIL_NORMAL); - - m_wndToolBar.CleanUpLockedImages(); - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SORT24 : IDR_SORT, 0, 0, TRUE /* Locked */); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassViewBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassViewBar.h deleted file mode 100644 index 0bff9eff3913e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ClassViewBar.h +++ /dev/null @@ -1,62 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "ClassTreeWnd.h" - -class CClassToolBar : public CMFCToolBar -{ - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList() const { return FALSE; } -}; - -class CClassViewBar : public CDockablePane -{ -public: - CClassViewBar(); - virtual ~CClassViewBar(); - - void AdjustLayout(); - void OnChangeVisualStyle(); - -protected: - CClassToolBar m_wndToolBar; - CClassTreeWnd m_wndClassView; - CImageList m_ClassViewImages; - UINT m_nCurrSort; - - void FillClassView(); - -// Overrides -public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnClassAddMemeberFunction(); - afx_msg void OnClassAddMemeberVariable(); - afx_msg void OnClassDefinition(); - afx_msg void OnClassProperties(); - afx_msg void OnNewFolder(); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg LRESULT OnChangeActiveTab(WPARAM, LPARAM); - afx_msg void OnSort(UINT id); - afx_msg void OnUpdateSort(CCmdUI* pCmdUI); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/DynamicHelpView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/DynamicHelpView.cpp deleted file mode 100644 index ae8b15af9da2e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/DynamicHelpView.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "MainFrm.h" -#include "DynamicHelpView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int idTree = 1; - -///////////////////////////////////////////////////////////////////////////// -// CExplorerBar - -CDynamicHelpViewBar::CDynamicHelpViewBar() -{ -} - -CDynamicHelpViewBar::~CDynamicHelpViewBar() -{ -} - -BEGIN_MESSAGE_MAP(CDynamicHelpViewBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_COMMAND(ID_DHELP1, OnDhelp1) - ON_UPDATE_COMMAND_UI(ID_DHELP1, OnUpdateDhelp1) - ON_COMMAND(ID_DHELP2, OnDhelp2) - ON_UPDATE_COMMAND_UI(ID_DHELP2, OnUpdateDhelp2) - ON_COMMAND(ID_DHELP3, OnDhelp3) - ON_UPDATE_COMMAND_UI(ID_DHELP3, OnUpdateDhelp3) - ON_WM_PAINT() - ON_WM_SETFOCUS() - ON_NOTIFY(TVN_SELCHANGED, idTree, OnSelectTree) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDynamicHelpView message handlers - -int CDynamicHelpViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - SetWindowText(_T("Articles")); - - CRect rectDummy(0, 0, 0, 0); - m_wndArticles.Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |TVS_TRACKSELECT | TVS_NOTOOLTIPS | TVS_SINGLEEXPAND, rectDummy, this, idTree); - - m_DynamicHelpImages.Create(IDB_DYNAMICHELP, 16, 0, RGB(255, 0, 0)); - m_wndArticles.SetImageList(&m_DynamicHelpImages, TVSIL_NORMAL); - - m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_DYNAMIC_HELP); - m_wndToolBar.LoadToolBar(IDR_DYNAMIC_HELP, 0, 0, TRUE /* Is locked */); - - OnChangeVisualStyle(); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - m_wndToolBar.SetOwner(this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame(FALSE); - - FillHelp(); - AdjustLayout(); - return 0; -} - -void CDynamicHelpViewBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout(); -} - -void CDynamicHelpViewBar::OnEraseWorkArea(CDC* /*pDC*/, CRect /*rectWorkArea*/) -{ - // Do nothing, favorites tree covers the whole working area -} - -void CDynamicHelpViewBar::OnSelectTree(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - // NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; - - HTREEITEM hTreeItem = m_wndArticles.GetSelectedItem(); - if (hTreeItem != NULL) - { - } - - *pResult = 0; -} - -void CDynamicHelpViewBar::FillHelp() -{ - HTREEITEM hTreeItem = m_wndArticles.InsertItem(_T("Samples"), 0, 2, NULL); - m_wndArticles.SetItemData(hTreeItem, (DWORD) 1); - - hTreeItem = m_wndArticles.InsertItem(_T("Visual Studio Sample"), 5, 5, hTreeItem); - m_wndArticles.SetItemData(hTreeItem, (DWORD) 2); - - hTreeItem = m_wndArticles.InsertItem(_T("Getting Started"), 1, 3, NULL); - m_wndArticles.SetItemData(hTreeItem, (DWORD) 1); - - hTreeItem = m_wndArticles.InsertItem(_T("Customizing Dynamic Help"), 5, 5, hTreeItem); - m_wndArticles.SetItemData(hTreeItem, (DWORD) 2); -} - -void CDynamicHelpViewBar::AdjustLayout() -{ - if (GetSafeHwnd() == NULL) - { - return; - } - - CRect rectClient; - GetClientRect(rectClient); - - int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; - - m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndArticles.SetWindowPos(NULL, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CDynamicHelpViewBar::OnDhelp1() -{ - // TODO: Add your command handler code here -} - -void CDynamicHelpViewBar::OnUpdateDhelp1(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here -} - -void CDynamicHelpViewBar::OnDhelp2() -{ - // TODO: Add your command handler code here -} - -void CDynamicHelpViewBar::OnUpdateDhelp2(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here -} - -void CDynamicHelpViewBar::OnDhelp3() -{ - // TODO: Add your command handler code here -} - -void CDynamicHelpViewBar::OnUpdateDhelp3(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here -} - -void CDynamicHelpViewBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndArticles.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void CDynamicHelpViewBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - m_wndArticles.SetFocus(); -} - -void CDynamicHelpViewBar::OnChangeVisualStyle() -{ - m_wndToolBar.CleanUpLockedImages(); - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_HELPTOOLBAR_24 : IDR_DYNAMIC_HELP, 0, 0, TRUE /* Locked */); - - m_DynamicHelpImages.DeleteImageList(); - - UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_DYNAMICHELP24 : IDB_DYNAMICHELP; - - CBitmap bmp; - if (!bmp.LoadBitmap(uiBmpId)) - { - TRACE(_T("Can't load bitmap: %x\n"), uiBmpId); - ASSERT(FALSE); - return; - } - - BITMAP bmpObj; - bmp.GetBitmap(&bmpObj); - - UINT nFlags = ILC_MASK; - - nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; - - m_DynamicHelpImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); - m_DynamicHelpImages.Add(&bmp, RGB(255, 255, 255)); - - m_wndArticles.SetImageList(&m_DynamicHelpImages, TVSIL_NORMAL); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/DynamicHelpView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/DynamicHelpView.h deleted file mode 100644 index 0362fbf025516..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/DynamicHelpView.h +++ /dev/null @@ -1,67 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CHelpToolBar : public CMFCToolBar -{ -public: - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList() const { return FALSE; } -}; - -///////////////////////////////////////////////////////////////////////////// -// CDynamicHelpVieBar window - -class CDynamicHelpViewBar : public CDockablePane -{ -// Construction -public: - CDynamicHelpViewBar(); - - void AdjustLayout(); - -// Attributes -protected: - CHelpToolBar m_wndToolBar; - CTreeCtrl m_wndArticles; - CImageList m_DynamicHelpImages; - -// Operations -public: - void OnChangeVisualStyle(); - -protected: - virtual void OnEraseWorkArea(CDC* pDC, CRect rectWorkArea); - void FillHelp(); - -// Implementation -public: - virtual ~CDynamicHelpViewBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnDhelp1(); - afx_msg void OnUpdateDhelp1(CCmdUI* pCmdUI); - afx_msg void OnDhelp2(); - afx_msg void OnUpdateDhelp2(CCmdUI* pCmdUI); - afx_msg void OnDhelp3(); - afx_msg void OnUpdateDhelp3(CCmdUI* pCmdUI); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnSelectTree(NMHDR* pNMHDR, LRESULT* pResult); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FileViewBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FileViewBar.cpp deleted file mode 100644 index bbb667431ef3a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FileViewBar.cpp +++ /dev/null @@ -1,262 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "mainfrm.h" -#include "FileViewBar.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CFileViewBar - -CFileViewBar::CFileViewBar() -{ -} - -CFileViewBar::~CFileViewBar() -{ -} - -BEGIN_MESSAGE_MAP(CFileViewBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_PROPERTIES, OnProperties) - ON_COMMAND(ID_SOLUTION_OPEN, OnSolutionOpen) - ON_COMMAND(ID_SOLUTION_OPEN_WITH, OnSolutionOpenWith) - ON_COMMAND(ID_DUMMY_COMPILE, OnDummyCompile) - ON_COMMAND(ID_EDIT_CUT, OnEditCut) - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) - ON_WM_PAINT() - ON_WM_SETFOCUS() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWorkspaceBar message handlers - -int CFileViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create view: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; - - if (!m_wndFileView.Create(dwViewStyle, rectDummy, this, 4)) - { - TRACE0("Failed to create solution explorer\n"); - return -1; // fail to create - } - - // Load view images: - m_FileViewImages.Create(IDB_FILE_VIEW, 16, 0, RGB(255, 0, 255)); - m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); - - m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_SOLUTION_EXPLORER); - m_wndToolBar.LoadToolBar(IDR_SOLUTION_EXPLORER, 0, 0, TRUE /* Is locked */); - - OnChangeVisualStyle(); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - - m_wndToolBar.SetOwner(this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame(FALSE); - - // Fill view context(dummy code, don't seek here something magic :-)): - FillFileView(); - AdjustLayout(); - - return 0; -} - -void CFileViewBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout(); -} - -void CFileViewBar::FillFileView() -{ - HTREEITEM hRoot = m_wndFileView.InsertItem(_T("Hello files"), 0, 0); - m_wndFileView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); - - HTREEITEM hSrc = m_wndFileView.InsertItem(_T("Source Files"), 0, 0, hRoot); - - m_wndFileView.InsertItem(_T("Hello.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("Hello.rc"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("HelloDoc.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("HelloView.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("MainFrm.cpp"), 1, 1, hSrc); - m_wndFileView.InsertItem(_T("StdAfx.cpp"), 1, 1, hSrc); - - HTREEITEM hInc = m_wndFileView.InsertItem(_T("Header Files"), 0, 0, hRoot); - - m_wndFileView.InsertItem(_T("Hello.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("HelloDoc.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("HelloView.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("resource.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("MainFrm.h"), 2, 2, hInc); - m_wndFileView.InsertItem(_T("StdAfx.h"), 2, 2, hInc); - - HTREEITEM hRes = m_wndFileView.InsertItem(_T("Resource Files"), 0, 0, hRoot); - - m_wndFileView.InsertItem(_T("Hello.ico"), 2, 2, hRes); - m_wndFileView.InsertItem(_T("Hello.rc2"), 2, 2, hRes); - m_wndFileView.InsertItem(_T("HelloDoc.ico"), 2, 2, hRes); - m_wndFileView.InsertItem(_T("Toolbar.bmp"), 2, 2, hRes); - - m_wndFileView.Expand(hRoot, TVE_EXPAND); - m_wndFileView.Expand(hSrc, TVE_EXPAND); - m_wndFileView.Expand(hInc, TVE_EXPAND); -} - -void CFileViewBar::OnContextMenu(CWnd* pWnd, CPoint point) -{ - CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; - ASSERT_VALID(pWndTree); - - if (pWnd != pWndTree) - { - CDockablePane::OnContextMenu(pWnd, point); - return; - } - - if (point != CPoint(-1, -1)) - { - // Select clicked item: - CPoint ptTree = point; - pWndTree->ScreenToClient(&ptTree); - - HTREEITEM hTreeItem = pWndTree->HitTest(ptTree); - if (hTreeItem != NULL) - { - pWndTree->SelectItem(hTreeItem); - } - } - - pWndTree->SetFocus(); - theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_SOLUTION, point.x, point.y, this, TRUE); -} - -void CFileViewBar::AdjustLayout() -{ - if (GetSafeHwnd() == NULL) - { - return; - } - - CRect rectClient; - GetClientRect(rectClient); - - int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; - - m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndFileView.SetWindowPos(NULL, rectClient.left + 1, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CFileViewBar::OnProperties() -{ - AfxMessageBox(_T("Properties....")); - -} - -void CFileViewBar::OnSolutionOpen() -{ - // TODO: Add your command handler code here -} - -void CFileViewBar::OnSolutionOpenWith() -{ - // TODO: Add your command handler code here -} - -void CFileViewBar::OnDummyCompile() -{ - // TODO: Add your command handler code here -} - -void CFileViewBar::OnEditCut() -{ - // TODO: Add your command handler code here -} - -void CFileViewBar::OnEditCopy() -{ - // TODO: Add your command handler code here -} - -void CFileViewBar::OnEditClear() -{ - // TODO: Add your command handler code here -} - -void CFileViewBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndFileView.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void CFileViewBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - - m_wndFileView.SetFocus(); -} - -void CFileViewBar::OnChangeVisualStyle() -{ - m_wndToolBar.CleanUpLockedImages(); - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_SOLUTION_EXPLORER_24 : IDR_SOLUTION_EXPLORER, 0, 0, TRUE /* Locked */); - - m_FileViewImages.DeleteImageList(); - - UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_FILE_VIEW24 : IDB_FILE_VIEW; - - CBitmap bmp; - if (!bmp.LoadBitmap(uiBmpId)) - { - TRACE(_T("Can't load bitmap: %x\n"), uiBmpId); - ASSERT(FALSE); - return; - } - - BITMAP bmpObj; - bmp.GetBitmap(&bmpObj); - - UINT nFlags = ILC_MASK; - - nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; - - m_FileViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); - m_FileViewImages.Add(&bmp, RGB(255, 0, 255)); - - m_wndFileView.SetImageList(&m_FileViewImages, TVSIL_NORMAL); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FileViewBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FileViewBar.h deleted file mode 100644 index 7388b892301cd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FileViewBar.h +++ /dev/null @@ -1,63 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "ClassTreeWnd.h" - -class CFileViewToolBar : public CMFCToolBar -{ - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList() const { return FALSE; } -}; - -class CFileViewBar : public CDockablePane -{ -// Construction -public: - CFileViewBar(); - - void AdjustLayout(); - void OnChangeVisualStyle(); - -// Attributes -protected: - - CClassTreeWnd m_wndFileView; - CImageList m_FileViewImages; - CFileViewToolBar m_wndToolBar; - -protected: - void FillFileView(); - -// Implementation -public: - virtual ~CFileViewBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnProperties(); - afx_msg void OnSolutionOpen(); - afx_msg void OnSolutionOpenWith(); - afx_msg void OnDummyCompile(); - afx_msg void OnEditCut(); - afx_msg void OnEditCopy(); - afx_msg void OnEditClear(); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FindComboBox.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FindComboBox.cpp deleted file mode 100644 index fb394266735aa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FindComboBox.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "FindComboBox.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CFindComboButton - -IMPLEMENT_SERIAL(CFindComboButton, CMFCToolBarComboBoxButton, 1) - -BOOL CFindComboButton::m_bHasFocus = FALSE; - -BOOL CFindComboButton::NotifyCommand(int iNotifyCode) -{ - BOOL bRes = CMFCToolBarComboBoxButton::NotifyCommand(iNotifyCode); - - switch (iNotifyCode) - { - case CBN_KILLFOCUS: - m_bHasFocus = FALSE; - bRes = TRUE; - break; - - case CBN_SETFOCUS: - m_bHasFocus = TRUE; - bRes = TRUE; - break; - } - - return bRes; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FindComboBox.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FindComboBox.h deleted file mode 100644 index 621456e1dd1ea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/FindComboBox.h +++ /dev/null @@ -1,36 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CFindComboButton : public CMFCToolBarComboBoxButton -{ - DECLARE_SERIAL(CFindComboButton) - -// Construction -public: - CFindComboButton() : CMFCToolBarComboBoxButton(ID_EDIT_FIND_COMBO, GetCmdMgr()->GetCmdImage(ID_EDIT_FIND), CBS_DROPDOWN) - { - } - -// Attributes: -public: - static BOOL HasFocus() - { - return m_bHasFocus; - } - -protected: - static BOOL m_bHasFocus; - -// Overrides -protected: - virtual BOOL NotifyCommand(int iNotifyCode); -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/MainFrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/MainFrm.cpp deleted file mode 100644 index 375e627767fd9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/MainFrm.cpp +++ /dev/null @@ -1,951 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "FindComboBox.h" -#include "OptionsDlg.h" -#include "MainFrm.h" - -#include "ChildFrm.h" -#include "UndoBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) - -const int iMaxUserToolbars = 10; -const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; -const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) - ON_WM_CREATE() - ON_COMMAND(ID_WINDOW_MANAGER, OnWindowManager) - ON_COMMAND(ID_HELP_KEYBOARDMAP, OnHelpKeyboardmap) - ON_COMMAND(ID_FILE_NEW_PROJECT, OnFileNewProject) - ON_COMMAND(ID_FILE_NEW_BLANK_SOLUTION, OnFileNewBlankSolution) - ON_COMMAND(ID_FILE_OPEN_SOLUTION, OnFileOpenSolution) - ON_COMMAND(ID_FILE_CLOSE_SOLUTION, OnFileCloseSolution) - ON_COMMAND(ID_FILE_SAVE_ALL, OnFileSaveAll) - ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh) - ON_COMMAND(ID_TOOLS_CONNECT_TO_DATABASE, OnToolsConnectToDatabase) - ON_COMMAND(ID_TOOLS_DEBUG_PROCESSES, OnToolsDebugProcesses) - ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullScreen) - ON_COMMAND(ID_TOOLS_OPTIONS, OnToolsOptions) - ON_COMMAND(ID_HELP_WEB, OnHelpWeb) - ON_COMMAND(ID_MDI_MOVE_TO_NEXT_GROUP, OnMdiMoveToNextGroup) - ON_COMMAND(ID_MDI_MOVE_TO_PREV_GROUP, OnMdiMoveToPrevGroup) - ON_COMMAND(ID_MDI_NEW_HORZ_TAB_GROUP, OnMdiNewHorzTabGroup) - ON_COMMAND(ID_MDI_NEW_VERT_GROUP, OnMdiNewVertGroup) - ON_COMMAND(ID_MDI_CANCEL, OnMdiCancel) - ON_WM_CLOSE() - ON_COMMAND(ID_VIEW_CLASS, OnViewClass) - ON_UPDATE_COMMAND_UI(ID_VIEW_CLASS, OnUpdateViewClass) - ON_COMMAND(ID_VIEW_FILE, OnViewFile) - ON_UPDATE_COMMAND_UI(ID_VIEW_FILE, OnUpdateViewFile) - ON_COMMAND(ID_VIEW_RESOURCE, OnViewResource) - ON_UPDATE_COMMAND_UI(ID_VIEW_RESOURCE, OnUpdateViewResource) - ON_COMMAND(ID_VIEW_PROPERTIES, OnViewProperties) - ON_UPDATE_COMMAND_UI(ID_VIEW_PROPERTIES, OnUpdateViewProperties) - ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput) - ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateViewOutput) - ON_COMMAND(ID_VIEW_WATCH, OnViewWatch) - ON_UPDATE_COMMAND_UI(ID_VIEW_WATCH, OnUpdateViewWatch) - ON_COMMAND(ID_VIEW_DYNAMICHELP, OnViewDynamichelp) - ON_UPDATE_COMMAND_UI(ID_VIEW_DYNAMICHELP, OnUpdateViewDynamichelp) - ON_COMMAND(ID_MDI_TABBED_DOCUMENT, OnMdiTabbedDocument) - ON_UPDATE_COMMAND_UI(ID_MDI_TABBED_DOCUMENT, OnUpdateMdiTabbedDocument) - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) - ON_REGISTERED_MESSAGE(AFX_WM_ON_GET_TAB_TOOLTIP, OnGetTabToolTip) - ON_REGISTERED_MESSAGE(AFX_WM_CUSTOMIZEHELP, OnHelpCustomizeToolbars) - ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, OnToolbarCreateNew) - ON_WM_SYSCOLORCHANGE() -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -// -CMainFrame::CMainFrame() -{ - CMFCPopupMenu::SetForceShadow(TRUE); - - m_bCanConvertControlBarToMDIChild = TRUE; -} -// - -CMainFrame::~CMainFrame() -{ -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); - - CMFCToolBarComboBoxButton::SetFlatMode(); - - // Load toolbar user images: - if (m_UserImages.Load(_T("UserImages.bmp"))) - { - CMFCToolBar::SetUserImages(&m_UserImages); - } - - CMFCToolBar::EnableQuickCustomization(); - - // Create menu bar: - if (!m_wndMenuBar.Create(this)) - { - TRACE0("Failed to create menubar\n"); - return -1; // fail to create - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); - - // Menu will not take the focus on activation: - CMFCPopupMenu::SetForceMenuFocus(FALSE); - - // - // Create Resource toolbar: - // The this pointer points to CMainFrame class which extends the CMDIFrameWndEx class - if (!m_wndToolbarResource.Create(this, WS_CHILD|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, IDR_TOOLBAR_RESOURCE) || !m_wndToolbarResource.LoadToolBar(IDR_TOOLBAR_RESOURCE)) - { - TRACE0("Failed to create build toolbar\n"); - return FALSE; // fail to create - } - // - - // Create main toolbar: - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - CString strMainToolbarTitle; - strMainToolbarTitle.LoadString(IDS_MAIN_TOOLBAR); - m_wndToolBar.SetWindowText(strMainToolbarTitle); - - // Create Build toolbar: - if (!m_wndToolbarBuild.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, ID_VIEW_BUILD_TOOLBAR) || !m_wndToolbarBuild.LoadToolBar(IDR_BUILD)) - { - TRACE0("Failed to create build toolbar\n"); - return FALSE; // fail to create - } - - CString strBuildToolbarTitle; - strBuildToolbarTitle.LoadString(IDS_BUILD_TOOLBAR); - m_wndToolbarBuild.SetWindowText(strBuildToolbarTitle); - - // Create Edit toolbar: - if (!m_wndToolbarEdit.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, ID_VIEW_EDIT_TOOLBAR) || !m_wndToolbarEdit.LoadToolBar(IDR_EDIT)) - { - TRACE0("Failed to create edit toolbar\n"); - return FALSE; // fail to create - } - - CString strEditToolbarTitle; - strEditToolbarTitle.LoadString(IDS_EDIT_TOOLBAR); - m_wndToolbarEdit.SetWindowText(strEditToolbarTitle); - - // Load menu items images(not placed on the standard toolbars): - CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES); - - // Create status bar: - if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - m_wndStatusBar.SetPaneStyle(0, SBPS_STRETCH); - - // Create docking control windows: - if (!CreateDockingBars()) - { - return -1; - } - - m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - m_wndToolbarBuild.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - m_wndToolbarEdit.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolbarBuild.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolbarEdit.EnableDocking(CBRS_ALIGN_ANY); - m_wndToolbarResource.EnableDocking(CBRS_ALIGN_ANY); - m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); - m_wndResourceView.EnableDocking(CBRS_ALIGN_ANY); - m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); - m_wndOutputView.EnableDocking(CBRS_ALIGN_ANY); - m_wndDynamicHelpView.EnableDocking(CBRS_ALIGN_ANY); - m_wndPropertiesBar.EnableDocking(CBRS_ALIGN_ANY); - - m_wndWatchBar.EnableDocking(CBRS_ALIGN_ANY); - - // - EnableDocking(CBRS_ALIGN_ANY); - // - - // - EnableAutoHidePanes(CBRS_ALIGN_ANY); - // - - // - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane(&m_wndPropertiesBar); - - // - DockPane(&m_wndToolbarBuild); - // - DockPaneLeftOf(&m_wndToolbarEdit, &m_wndToolbarBuild); - // - - DockPane(&m_wndClassView); - - CDockablePane* pTabbedBar = NULL; - m_wndResourceView.AttachToTabWnd(&m_wndClassView, DM_SHOW, TRUE, &pTabbedBar); - m_wndFileView.AttachToTabWnd(pTabbedBar, DM_SHOW, TRUE, &pTabbedBar); - - DockPane(&m_wndOutputView); - - m_wndDynamicHelpView.DockToWindow(&m_wndPropertiesBar, CBRS_ALIGN_BOTTOM); - m_wndWatchBar.DockToWindow(&m_wndOutputView, CBRS_ALIGN_LEFT); - - CRect rectMainToolBar; - m_wndToolBar.GetWindowRect(&rectMainToolBar); - - // Allow user-defined toolbars operations: - InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); - - // - // Enable windows manager: - EnableWindowsDialog(ID_WINDOW_MANAGER, _T("Windows..."), TRUE); - // - - // - // Enable pane context menu(list of bars + customize command): - EnablePaneMenu( TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."), ID_VIEW_TOOLBARS, FALSE, TRUE); - // - - EnableFullScreenMode(ID_VIEW_FULLSCREEN); - return 0; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - -void CMainFrame::OnViewCustomize() -{ - // Create a customize toolbars dialog: - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* Automatic menus scaning */, AFX_CUSTOMIZE_MENU_SHADOWS | AFX_CUSTOMIZE_TEXT_LABELS | AFX_CUSTOMIZE_MENU_ANIMATIONS); - - pDlgCust->EnableUserDefinedToolbars(); - - // Setup combboxes: - pDlgCust->ReplaceButton(ID_EDIT_FIND, CFindComboButton()); - - CMFCToolBarComboBoxButton comboButtonConfig(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, GetCmdMgr()->GetCmdImage(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, FALSE), CBS_DROPDOWNLIST); - comboButtonConfig.AddItem(_T("Win32 Debug")); - comboButtonConfig.AddItem(_T("Win32 Release")); - comboButtonConfig.SelectItem(0); - - // - // CMFCToolBarsCustomizeDialog* pDlgCust - // CMFCToolBarComboBoxButton comboButtonConfig - pDlgCust->ReplaceButton(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, comboButtonConfig); - // - - // - // Add dropdown resources button - // CMFCToolBarsCustomizeDialog* pDlgCust - // CMFCDropDownToolBar m_wndToolbarResource - pDlgCust->AddButton(_T("Build"), CMFCDropDownToolbarButton(_T("Add Resource"), &m_wndToolbarResource)); - // - - // Setup undo/redo buttons: - pDlgCust->ReplaceButton(ID_EDIT_UNDO, CUndoButton(ID_EDIT_UNDO, _T("&Undo"))); - pDlgCust->ReplaceButton(ID_EDIT_REDO, CUndoButton(ID_EDIT_REDO, _T("&Redo"))); - - pDlgCust->Create(); -} - -LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM) -{ - UINT uiToolBarId = (UINT) wp; - - switch (uiToolBarId) - { - case IDR_MAINFRAME: - { - ASSERT(m_wndToolbarResource.GetSafeHwnd() != NULL); - - // Replace dropdown resources button: - m_wndToolBar.ReplaceButton(ID_DUMMY_INSERT_RESOURCE, CMFCDropDownToolbarButton(_T("Add Resource"), &m_wndToolbarResource)); - - // Replace "Find..." button by combobox: - m_wndToolBar.ReplaceButton(ID_EDIT_FIND, CFindComboButton()); - - // Replace "Undo" button by menubutton: - m_wndToolBar.ReplaceButton(ID_EDIT_UNDO, CUndoButton(ID_EDIT_UNDO, _T("&Undo"))); - m_wndToolBar.ReplaceButton(ID_EDIT_REDO, CUndoButton(ID_EDIT_REDO, _T("&Redo"))); - } - break; - - case IDR_BUILD: - { - // Replace "Confoguration..." button by combobox: - CMFCToolBarComboBoxButton comboButton(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, GetCmdMgr()->GetCmdImage(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, FALSE), CBS_DROPDOWNLIST); - comboButton.AddItem(_T("Win32 Debug")); - comboButton.AddItem(_T("Win32 Release")); - comboButton.SelectItem(0); - - m_wndToolbarBuild.ReplaceButton(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, comboButton); - } - break; - } - - return 0; -} - -LRESULT CMainFrame::OnHelpCustomizeToolbars(WPARAM /*wp*/, LPARAM /*lp*/) -{ - // int iPageNum = (int) wp; - - // CMFCToolBarsCustomizeDialog* pDlg = (CMFCToolBarsCustomizeDialog*) lp; - // ASSERT_VALID(pDlg); - - // TODO: show help about page number iPageNum - - return 0; -} - -// -BOOL CMainFrame::OnShowMDITabContextMenu(CPoint point, DWORD dwAllowedItems, BOOL bDrop) -{ - CMenu menu; - VERIFY(menu.LoadMenu(bDrop ? IDR_POPUP_DROP_MDITABS : IDR_POPUP_MDITABS)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - if ((dwAllowedItems & AFX_MDI_CREATE_HORZ_GROUP) == 0) - { - pPopup->DeleteMenu(ID_MDI_NEW_HORZ_TAB_GROUP, MF_BYCOMMAND); - } - - if ((dwAllowedItems & AFX_MDI_CREATE_VERT_GROUP) == 0) - { - pPopup->DeleteMenu(ID_MDI_NEW_VERT_GROUP, MF_BYCOMMAND); - } - - if ((dwAllowedItems & AFX_MDI_CAN_MOVE_NEXT) == 0) - { - pPopup->DeleteMenu(ID_MDI_MOVE_TO_NEXT_GROUP, MF_BYCOMMAND); - } - - if ((dwAllowedItems & AFX_MDI_CAN_MOVE_PREV) == 0) - { - pPopup->DeleteMenu(ID_MDI_MOVE_TO_PREV_GROUP, MF_BYCOMMAND); - } - - if ((dwAllowedItems & AFX_MDI_CAN_BE_DOCKED) == 0) - { - pPopup->DeleteMenu(ID_MDI_TABBED_DOCUMENT, MF_BYCOMMAND); - } - - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - pPopupMenu->SetAutoDestroy(FALSE); - pPopupMenu->Create(this, point.x, point.y, pPopup->GetSafeHmenu()); - - return TRUE; -} -// - -// -void CMainFrame::OnWindowManager() -{ - ShowWindowsDialog(); -} -// - -BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) -{ - if (!CMDIFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) - { - return FALSE; - } - - // Add some tools for example.... - // - CUserToolsManager* pUserToolsManager = theApp.GetUserToolsManager(); - if (pUserToolsManager != NULL && pUserToolsManager->GetUserTools().IsEmpty()) - { - // - // CUserToolsManager* pUserToolsManager - CUserTool* pTool1 = pUserToolsManager->CreateNewTool(); - pTool1->m_strLabel = _T("&Notepad"); - pTool1->SetCommand(_T("notepad.exe")); - // - - CUserTool* pTool2 = pUserToolsManager->CreateNewTool(); - pTool2->m_strLabel = _T("Paint &Brush"); - pTool2->SetCommand(_T("mspaint.exe")); - - CUserTool* pTool3 = pUserToolsManager->CreateNewTool(); - pTool3->m_strLabel = _T("&Windows Explorer"); - pTool3->SetCommand(_T("explorer.exe")); - - CUserTool* pTool4 = pUserToolsManager->CreateNewTool(); - pTool4->m_strLabel = _T("Microsoft On-&Line"); - pTool4->SetCommand(_T("http://www.microsoft.com")); - } - // - - CMDITabInfo mdiTabParams; - mdiTabParams.m_bTabCustomTooltips = TRUE; - - EnableMDITabbedGroups(TRUE, mdiTabParams); - - // Enable customization button fore all user toolbars: - for (int i = 0; i < iMaxUserToolbars; i ++) - { - CMFCToolBar* pUserToolbar = GetUserToolBarByIndex(i); - if (pUserToolbar != NULL) - { - pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - } - } - - return TRUE; -} - -BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) -{ - // If control located on toolbar has focus, we should - // redirect clipboard commands to this control: - if (CFindComboButton::HasFocus() && HIWORD(wParam) == 1) // Command from accelerator - { - UINT uiCmd = LOWORD(wParam); - switch (uiCmd) - { - case ID_EDIT_PASTE: - ::SendMessage(::GetFocus(), WM_PASTE, 0, 0); - return TRUE; - - case ID_EDIT_COPY: - ::SendMessage(::GetFocus(), WM_COPY, 0, 0); - return TRUE; - - case ID_EDIT_CUT: - ::SendMessage(::GetFocus(), WM_CUT, 0, 0); - return TRUE; - } - } - - return CMDIFrameWndEx::OnCommand(wParam, lParam); -} - -void CMainFrame::OnHelpKeyboardmap() -{ - // - // this points to a CMainFrame class which extends the - // CMDIFrameWndEx class - CMFCKeyMapDialog dlg(this, TRUE /* Enable Print */); - // - dlg.DoModal(); -} - -LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) -{ - LRESULT lres = CMDIFrameWndEx::OnToolbarCreateNew(wp,lp); - if (lres == 0) - { - return 0; - } - - CMFCToolBar* pUserToolbar = (CMFCToolBar*) lres; - ASSERT_VALID(pUserToolbar); - - pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return lres; -} - -BOOL CMainFrame::CreateDockingBars() -{ - // Crate class view: - if (!m_wndClassView.Create(_T("Class View"), this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASS, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Class View bar\n"); - return FALSE; // fail to create - } - - // Create resource view: - if (!m_wndResourceView.Create(_T("Resource View"), this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_RESOURCE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Resource View bar\n"); - return FALSE; // fail to create - } - - // Create file view: - if (!m_wndFileView.Create(_T("Solution Explorer"), this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Solution Explorer bar\n"); - return FALSE; // fail to create - } - - //////////////////////////////////New Output//////////////////////////////////////// - if (!m_wndOutputView.Create(_T("Output"), this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUT, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create output bar\n"); - return FALSE; // fail to create - } - - if (!m_wndDynamicHelpView.Create(_T("Dynamic Help"), this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_DYNAMICHELP, WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Dynamic Help Bar\n"); - return FALSE; // fail to create - } - - // Create watch bar: - if (!m_wndWatchBar.Create(_T("Watch"), this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_WATCH, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create watch bar\n"); - return FALSE; // fail to create - } - - if (!m_wndPropertiesBar.Create(_T("Properties"), this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIES, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) - { - TRACE0("Failed to create Properties Bar\n"); - return FALSE; // fail to create - } - - SetDockingBarsIcons(FALSE); - - return TRUE; -} - -void CMainFrame::SetDockingBarsIcons(BOOL bHiColorIcons) -{ - HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndClassView.SetIcon(hClassViewIcon, FALSE); - - HICON hResViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_RES_VIEW_HC : IDI_RES_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndResourceView.SetIcon(hResViewIcon, FALSE); - - HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndFileView.SetIcon(hFileViewIcon, FALSE); - - HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_BAR_HC : IDI_OUTPUT_BAR), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndOutputView.SetIcon(hOutputBarIcon, FALSE); - - HICON hDynamicHelpIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_DYNAMICHELP_VIEW_HC : IDI_DYNAMICHELP_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndDynamicHelpView.SetIcon(hDynamicHelpIcon, FALSE); - - HICON hWatchBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_WATCH_BAR_HC : IDI_WATCH_BAR), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndWatchBar.SetIcon(hWatchBarIcon, FALSE); - - HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROP_BAR_HC : IDI_PROPERTIES_BAR), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0); - m_wndPropertiesBar.SetIcon(hPropertiesBarIcon, FALSE); - - UpdateMDITabbedBarsIcons(); -} - -void CMainFrame::OnFileNewProject() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnFileNewBlankSolution() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnFileOpenSolution() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnFileCloseSolution() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnFileSaveAll() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnViewRefresh() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnToolsConnectToDatabase() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnToolsDebugProcesses() -{ - // TODO: Add your command handler code here -} - -void CMainFrame::OnViewFullScreen() -{ - ShowFullScreen(); -} - -CMFCToolBarComboBoxButton* CMainFrame::GetFindCombo() -{ - CMFCToolBarComboBoxButton* pFindCombo = NULL; - - CObList listButtons; - if (CMFCToolBar::GetCommandButtons(ID_EDIT_FIND_COMBO, listButtons) > 0) - { - for (POSITION posCombo = listButtons.GetHeadPosition(); - pFindCombo == NULL && posCombo != NULL;) - { - // - // CObList listButtons - // POSITION posCombo - CMFCToolBarComboBoxButton* pCombo = DYNAMIC_DOWNCAST(CMFCToolBarComboBoxButton, listButtons.GetNext(posCombo)); - // - - if (pCombo != NULL && pCombo->GetEditCtrl()->GetSafeHwnd() == ::GetFocus()) - { - pFindCombo = pCombo; - - // - pCombo->EnableWindow(true); - pCombo->SetCenterVert(); - pCombo->SetDropDownHeight(25); - pCombo->SetFlatMode(); - pCombo->SetText(_T("this is a combo box")); - // - } - } - } - - return pFindCombo; -} - -void CMainFrame::OnToolsOptions() -{ - COptionsDlg dlgOptions(_T("Options"), this); - dlgOptions.DoModal(); -} - -void CMainFrame::OnChangeLook(BOOL bOneNoteTabs, BOOL bMDITabColors, BOOL bIsVSDotNetLook, BOOL bDockTabColors, BOOL bMDITabsVS2005Look, BOOL bActiveTabCloseButton) -{ - // - CMDITabInfo mdiTabParams; - mdiTabParams.m_bTabCustomTooltips = TRUE; - - if (bMDITabsVS2005Look) - { - mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_VS2005; - mdiTabParams.m_bDocumentMenu = TRUE; - } - else if (bOneNoteTabs) - { - mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; - mdiTabParams.m_bAutoColor = bMDITabColors; - } - - if (bActiveTabCloseButton) - { - mdiTabParams.m_bTabCloseButton = FALSE; - mdiTabParams.m_bActiveTabCloseButton = TRUE; - } - - EnableMDITabbedGroups(TRUE, mdiTabParams); - // - - m_wndPropertiesBar.SetVSDotNetLook(bIsVSDotNetLook); - - m_wndPropertiesBar.OnChangeVisualStyle(); - m_wndDynamicHelpView.OnChangeVisualStyle(); - m_wndClassView.OnChangeVisualStyle(); - m_wndFileView.OnChangeVisualStyle(); - m_wndResourceView.OnChangeVisualStyle(); - - CTabbedPane::EnableTabAutoColor(bDockTabColors); - - // Reload toolbar images: - CMFCToolBar::ResetAllImages(); - - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_TOOLBAR24 : IDR_MAINFRAME); - m_wndToolbarBuild.LoadBitmap(theApp.m_bHiColorIcons ? IDB_BUILD24 : IDR_BUILD); - m_wndToolbarEdit.LoadBitmap(theApp.m_bHiColorIcons ? IDB_EDIT24 : IDR_EDIT); - - CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENUIMAGES24 : 0); - SetDockingBarsIcons(theApp.m_bHiColorIcons); - - // - CDockingManager* pDockManager = GetDockingManager(); - ASSERT_VALID(pDockManager); - pDockManager->AdjustPaneFrames(); - pDockManager->EnableDockSiteMenu(); - pDockManager->SetDockingMode(DT_STANDARD); - // - - RecalcLayout(); - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); -} - -void CMainFrame::OnHelpWeb() -{ - ::ShellExecute(NULL, NULL, _T("http://www.microsoft.com"), NULL, NULL, NULL); -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - return CMDIFrameWndEx::PreCreateWindow(cs); -} - -BOOL CMainFrame::DestroyWindow() -{ - return CMDIFrameWndEx::DestroyWindow(); -} - -void CMainFrame::OnMdiMoveToNextGroup() -{ - MDITabMoveToNextGroup(); -} - -void CMainFrame::OnMdiMoveToPrevGroup() -{ - MDITabMoveToNextGroup(FALSE); -} - -// -void CMainFrame::OnMdiNewHorzTabGroup() -{ - MDITabNewGroup(FALSE); -} -// - -void CMainFrame::OnMdiNewVertGroup() -{ - MDITabNewGroup(); -} - -void CMainFrame::OnMdiCancel() -{ - // TODO: Add your command handler code here -} - -// -CMDIChildWndEx* CMainFrame::CreateDocumentWindow(LPCTSTR lpcszDocName, CObject* /*pObj*/) -{ - if (lpcszDocName != NULL && lpcszDocName [0] != '\0') - { - CDocument* pDoc = NULL; - if (g_strStartViewName.Compare(lpcszDocName) == 0) - { - pDoc = theApp.m_pStartDocTemplate->OpenDocumentFile(NULL); - } - else - { - pDoc = AfxGetApp()->OpenDocumentFile(lpcszDocName); - } - - if (pDoc != NULL) - { - POSITION pos = pDoc->GetFirstViewPosition(); - - if (pos != NULL) - { - CView* pView = pDoc->GetNextView(pos); - return DYNAMIC_DOWNCAST(CMDIChildWndEx, pView->GetParent()); - } - } - - } - - return NULL; -} -// - -// -void CMainFrame::OnClose() -{ - SaveMDIState(theApp.GetRegSectionPath()); - CMDIFrameWndEx::OnClose(); -} -// - -LRESULT CMainFrame::OnGetTabToolTip(WPARAM /*wp*/, LPARAM lp) -{ - CMFCTabToolTipInfo* pInfo = (CMFCTabToolTipInfo*) lp; - ASSERT(pInfo != NULL); - ASSERT_VALID(pInfo->m_pTabWnd); - - if (!pInfo->m_pTabWnd->IsMDITab()) - { - return 0; - } - - CFrameWnd* pFrame = DYNAMIC_DOWNCAST(CFrameWnd, pInfo->m_pTabWnd->GetTabWnd(pInfo->m_nTabIndex)); - if (pFrame == NULL) - { - return 0; - } - - CDocument* pDoc = pFrame->GetActiveDocument(); - if (pDoc == NULL) - { - return 0; - } - - pInfo->m_strText = pDoc->GetPathName(); - return 0; -} - -void CMainFrame::OnViewClass() -{ - m_wndClassView.ShowPane(!m_wndClassView.IsVisible(), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewClass(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndClassView.IsVisible()); -} - -void CMainFrame::OnViewFile() -{ - m_wndFileView.ShowPane(!m_wndFileView.IsVisible(), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewFile(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndFileView.IsVisible()); -} - -void CMainFrame::OnViewResource() -{ - m_wndResourceView.ShowPane(!m_wndResourceView.IsVisible(), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewResource(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndResourceView.IsVisible()); -} - -void CMainFrame::OnViewProperties() -{ - m_wndPropertiesBar.ShowPane(!m_wndPropertiesBar.IsVisible(), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewProperties(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndPropertiesBar.IsVisible()); -} - -void CMainFrame::OnViewOutput() -{ - m_wndOutputView.ShowPane(!m_wndOutputView.IsVisible(), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewOutput(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndOutputView.IsVisible()); -} - -void CMainFrame::OnViewWatch() -{ - m_wndWatchBar.ShowPane(!m_wndWatchBar.IsVisible(), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewWatch(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndWatchBar.IsVisible()); -} - -void CMainFrame::OnViewDynamichelp() -{ - m_wndDynamicHelpView.ShowPane(!m_wndDynamicHelpView.IsVisible(), FALSE, TRUE); -} - -void CMainFrame::OnUpdateViewDynamichelp(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndDynamicHelpView.IsVisible()); -} - -// -void CMainFrame::OnMdiTabbedDocument() -{ - CMDIChildWndEx* pMDIChild = DYNAMIC_DOWNCAST(CMDIChildWndEx, MDIGetActive()); - if (pMDIChild == NULL) - { - ASSERT(FALSE); - return; - } - - TabbedDocumentToControlBar(pMDIChild); -} -// - -void CMainFrame::OnUpdateMdiTabbedDocument(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(); -} - -void CMainFrame::OnSysColorChange() -{ - BOOL bWasWindowRgn = m_Impl.HasRegion (); - - CMDIFrameWndEx::OnSysColorChange(); - - m_Impl.OnChangeVisualManager (); - - if (bWasWindowRgn && ! m_Impl.HasRegion ()) - { - SetWindowRgn (NULL, TRUE); - } -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/MainFrm.h deleted file mode 100644 index 9c4518e10541a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/MainFrm.h +++ /dev/null @@ -1,127 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "WatchBar.h" -#include "ClassViewBar.h" -#include "ResourceView.h" -#include "FileViewBar.h" -#include "OutputView.h" -#include "DynamicHelpView.h" -#include "PropertiesViewBar.h" - -class CMainFrame : public CMDIFrameWndEx -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Operations -public: - void OnChangeLook(BOOL bOneNoteTabs, BOOL bMDITabColors, BOOL bIsVSDotNetLook, BOOL bDockTabColors, BOOL bMDITabsVS2005Look, BOOL bActiveTabCloseButton); - -// Overrides -public: - virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL); - virtual BOOL DestroyWindow(); - -protected: - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - - virtual CMDIChildWndEx* CreateDocumentWindow(LPCTSTR lpcszDocName, CObject* pObj); - virtual BOOL OnShowMDITabContextMenu(CPoint point, DWORD dwAllowedItems, BOOL bDrop); - -// Implementation -public: - static CMFCToolBarComboBoxButton* GetFindCombo(); - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: // control bar embedded members - CMFCMenuBar m_wndMenuBar; - CMFCStatusBar m_wndStatusBar; - CMFCToolBar m_wndToolBar; - CMFCToolBar m_wndToolbarBuild; - CMFCToolBar m_wndToolbarEdit; - - // - CMFCDropDownToolBar m_wndToolbarResource; - // - - CClassViewBar m_wndClassView; - CResourceViewBar m_wndResourceView; - CFileViewBar m_wndFileView; - - CDynamicHelpViewBar m_wndDynamicHelpView; - COutputViewBar m_wndOutputView; - CPropertiesViewBar m_wndPropertiesBar; - - CWatchBar m_wndWatchBar; - - CMFCToolBarImages m_UserImages; - -private: - BOOL IsEditViewActive(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnWindowManager(); - afx_msg void OnHelpKeyboardmap(); - afx_msg void OnFileNewProject(); - afx_msg void OnFileNewBlankSolution(); - afx_msg void OnFileOpenSolution(); - afx_msg void OnFileCloseSolution(); - afx_msg void OnFileSaveAll(); - afx_msg void OnViewRefresh(); - afx_msg void OnToolsConnectToDatabase(); - afx_msg void OnToolsDebugProcesses(); - afx_msg void OnViewFullScreen(); - afx_msg void OnToolsOptions(); - afx_msg void OnHelpWeb(); - afx_msg void OnMdiMoveToNextGroup(); - afx_msg void OnMdiMoveToPrevGroup(); - afx_msg void OnMdiNewHorzTabGroup(); - afx_msg void OnMdiNewVertGroup(); - afx_msg void OnMdiCancel(); - afx_msg void OnClose(); - afx_msg void OnViewClass(); - afx_msg void OnUpdateViewClass(CCmdUI* pCmdUI); - afx_msg void OnViewFile(); - afx_msg void OnUpdateViewFile(CCmdUI* pCmdUI); - afx_msg void OnViewResource(); - afx_msg void OnUpdateViewResource(CCmdUI* pCmdUI); - afx_msg void OnViewProperties(); - afx_msg void OnUpdateViewProperties(CCmdUI* pCmdUI); - afx_msg void OnViewOutput(); - afx_msg void OnUpdateViewOutput(CCmdUI* pCmdUI); - afx_msg void OnViewWatch(); - afx_msg void OnUpdateViewWatch(CCmdUI* pCmdUI); - afx_msg void OnViewDynamichelp(); - afx_msg void OnUpdateViewDynamichelp(CCmdUI* pCmdUI); - afx_msg void OnMdiTabbedDocument(); - afx_msg void OnUpdateMdiTabbedDocument(CCmdUI* pCmdUI); - afx_msg void OnViewCustomize(); - afx_msg LRESULT OnToolbarReset(WPARAM,LPARAM); - afx_msg LRESULT OnGetTabToolTip(WPARAM wp, LPARAM lp); - afx_msg LRESULT OnHelpCustomizeToolbars(WPARAM wp, LPARAM lp); - LRESULT OnToolbarCreateNew(WPARAM wp,LPARAM lp); - afx_msg void OnSysColorChange(); - - DECLARE_MESSAGE_MAP() - - BOOL CreateDockingBars(); - void SetDockingBarsIcons(BOOL bHiColorIcons); -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsDlg.cpp deleted file mode 100644 index 6bb9112c3fbad..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsDlg.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OptionsDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COptionsDlg - -IMPLEMENT_DYNAMIC(COptionsDlg, CMFCPropertySheet) - -COptionsDlg::COptionsDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) -:CMFCPropertySheet(pszCaption, pParentWnd, iSelectPage) -{ - SetLook(CMFCPropertySheet::PropSheetLook_Tree, 150 /* Tree control width */); - SetIconsList(IDB_OPTIONSIMAGES, 16 /* Image width */); - - // - // The second parameter is the zero based index of an icon that is displayed when - // the control property page is not selected. - // The third parameter is the zero based index of an icon that is displayed when - // the control property page is selected. - CMFCPropertySheetCategoryInfo* pCat1 = AddTreeCategory(_T("Environment"), 0, 1); - // - - AddPageToTree(pCat1, &m_Page11, -1, 2); - AddPageToTree(pCat1, &m_Page12, -1, 2); - - CMFCPropertySheetCategoryInfo* pCat2 = AddTreeCategory(_T("Source Control"), 0, 1); - - AddPageToTree(pCat2, &m_Page21, -1, 2); - AddPageToTree(pCat2, &m_Page22, -1, 2); - - CMFCPropertySheetCategoryInfo* pCat3 = AddTreeCategory(_T("Text Editor"), 0, 1); - - AddPageToTree(pCat3, &m_Page31, -1, 2); - AddPageToTree(pCat3, &m_Page32, -1, 2); -} - -COptionsDlg::~COptionsDlg() -{ -} - -BEGIN_MESSAGE_MAP(COptionsDlg, CMFCPropertySheet) -END_MESSAGE_MAP() - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsDlg.h deleted file mode 100644 index 774ee577f22a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsDlg.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "OptionsPages.h" - -///////////////////////////////////////////////////////////////////////////// -// COptionsDlg - -class COptionsDlg : public CMFCPropertySheet -{ - DECLARE_DYNAMIC(COptionsDlg) - -// Construction -public: - COptionsDlg(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - -// Attributes -public: - COptionsPage1 m_Page11; - COptionsPage12 m_Page12; - COptionsPage21 m_Page21; - COptionsPage22 m_Page22; - COptionsPage31 m_Page31; - COptionsPage32 m_Page32; - -// Implementation -public: - virtual ~COptionsDlg(); - -protected: - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsPages.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsPages.cpp deleted file mode 100644 index 5bb66df83d6ce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsPages.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright(c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "OptionsPages.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage1 property page - -IMPLEMENT_DYNCREATE(COptionsPage1, CMFCPropertyPage) - -COptionsPage1::COptionsPage1() : CMFCPropertyPage(COptionsPage1::IDD) -{ -} - -COptionsPage1::~COptionsPage1() -{ -} - -void COptionsPage1::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(COptionsPage1, CMFCPropertyPage) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage12 property page - -IMPLEMENT_DYNCREATE(COptionsPage12, CMFCPropertyPage) - -COptionsPage12::COptionsPage12() : CMFCPropertyPage(COptionsPage12::IDD) -{ -} - -COptionsPage12::~COptionsPage12() -{ -} - -void COptionsPage12::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(COptionsPage12, CMFCPropertyPage) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage21 property page - -IMPLEMENT_DYNCREATE(COptionsPage21, CMFCPropertyPage) - -COptionsPage21::COptionsPage21() : CMFCPropertyPage(COptionsPage21::IDD) -{ -} - -COptionsPage21::~COptionsPage21() -{ -} - -void COptionsPage21::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(COptionsPage21, CMFCPropertyPage) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage22 property page - -IMPLEMENT_DYNCREATE(COptionsPage22, CMFCPropertyPage) - -COptionsPage22::COptionsPage22() : CMFCPropertyPage(COptionsPage22::IDD) -{ -} - -COptionsPage22::~COptionsPage22() -{ -} - -void COptionsPage22::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(COptionsPage22, CMFCPropertyPage) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage31 property page - -IMPLEMENT_DYNCREATE(COptionsPage31, CMFCPropertyPage) - -COptionsPage31::COptionsPage31() : CMFCPropertyPage(COptionsPage31::IDD) -{ -} - -COptionsPage31::~COptionsPage31() -{ -} - -void COptionsPage31::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(COptionsPage31, CMFCPropertyPage) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage32 property page - -IMPLEMENT_DYNCREATE(COptionsPage32, CMFCPropertyPage) - -COptionsPage32::COptionsPage32() : CMFCPropertyPage(COptionsPage32::IDD) -{ -} - -COptionsPage32::~COptionsPage32() -{ -} - -void COptionsPage32::DoDataExchange(CDataExchange* pDX) -{ - CMFCPropertyPage::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(COptionsPage32, CMFCPropertyPage) -END_MESSAGE_MAP() - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsPages.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsPages.h deleted file mode 100644 index 05e9352e54aa4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OptionsPages.h +++ /dev/null @@ -1,151 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "resource.h" - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage1 dialog - -class COptionsPage1 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(COptionsPage1) - -// Construction -public: - COptionsPage1(); - ~COptionsPage1(); - - enum { IDD = IDD_OPTIONSPAGE1 }; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage12 dialog - -class COptionsPage12 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(COptionsPage12) - -// Construction -public: - COptionsPage12(); - ~COptionsPage12(); - - enum { IDD = IDD_OPTIONSPAGE2 }; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage21 dialog - -class COptionsPage21 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(COptionsPage21) - -// Construction -public: - COptionsPage21(); - ~COptionsPage21(); - - enum { IDD = IDD_OPTIONSPAGE3 }; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage22 dialog - -class COptionsPage22 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(COptionsPage22) - -// Construction -public: - COptionsPage22(); - ~COptionsPage22(); - - enum { IDD = IDD_OPTIONSPAGE4 }; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage31 dialog - -class COptionsPage31 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(COptionsPage31) - -// Construction -public: - COptionsPage31(); - ~COptionsPage31(); - - enum { IDD = IDD_OPTIONSPAGE5 }; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// COptionsPage32 dialog - -class COptionsPage32 : public CMFCPropertyPage -{ - DECLARE_DYNCREATE(COptionsPage32) - -// Construction -public: - COptionsPage32(); - ~COptionsPage32(); - - enum { IDD = IDD_OPTIONSPAGE6 }; - -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -// Implementation -protected: - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputBar.cpp deleted file mode 100644 index a7462acd2971a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputBar.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "MainFrm.h" -#include "OutputBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutputBar - -COutputBar::COutputBar() -{ -} - -COutputBar::~COutputBar() -{ -} - -BEGIN_MESSAGE_MAP(COutputBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutputBar message handlers - -int COutputBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - m_Font.CreateStockObject(DEFAULT_GUI_FONT); - - CRect rectClient(0, 0, lpCreateStruct->cx, lpCreateStruct->cy); - - // Create tabs window: - if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT_SHARED_HORZ_SCROLL, rectClient, this, 101)) - { - TRACE0("Failed to create output tab window\n"); - return -1; // fail to create - } - - // Create output panes: - const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; - - m_wndOutputBuild.Create(dwStyle, rectClient, &m_wndTabs, 1); - m_wndOutputBuild.SetFont(&m_Font); - m_wndOutputBuild.SetOwner(this); - - m_wndOutputDebug.Create(dwStyle, rectClient, &m_wndTabs, 2); - m_wndOutputDebug.SetFont(&m_Font); - m_wndOutputDebug.SetOwner(this); - - m_wndOutputFind1.Create(dwStyle, rectClient, &m_wndTabs, 3); - m_wndOutputFind1.SetFont(&m_Font); - m_wndOutputFind1.SetOwner(this); - - m_wndOutputFind2.Create(dwStyle, rectClient, &m_wndTabs, 4); - m_wndOutputFind2.SetFont(&m_Font); - m_wndOutputFind2.SetOwner(this); - - m_wndOutputSQL.Create(dwStyle, rectClient, &m_wndTabs, 5); - m_wndOutputSQL.SetFont(&m_Font); - m_wndOutputSQL.SetOwner(this); - - // Fill view context(dummy code, don't seek here something magic :-)): - FillBuildWindow(); - FillDebugWindow(); - - // Attach views to tab: - m_wndTabs.AddTab(&m_wndOutputBuild, _T("Build"), (UINT)-1); - m_wndTabs.AddTab(&m_wndOutputDebug, _T("Debug"), (UINT)-1); - m_wndTabs.AddTab(&m_wndOutputFind1, _T("Find in Files 1"), (UINT)-1); - m_wndTabs.AddTab(&m_wndOutputFind2, _T("Find in Files 2"), (UINT)-1); - m_wndTabs.AddTab(&m_wndOutputSQL, _T("SQL Debugging"), (UINT)-1); - - return 0; -} - -void COutputBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - CRect rc; - GetClientRect(rc); - - m_wndTabs.SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW); - - AdjusrHorzScroll(m_wndOutputBuild); - AdjusrHorzScroll(m_wndOutputDebug); - AdjusrHorzScroll(m_wndOutputFind1); - AdjusrHorzScroll(m_wndOutputFind2); - AdjusrHorzScroll(m_wndOutputSQL); -} - -void COutputBar::AdjusrHorzScroll(CListBox& wndListBox) -{ - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(&m_Font); - - int cxExtentMax = 0; - - for (int i = 0; i < wndListBox.GetCount(); i ++) - { - CString strItem; - wndListBox.GetText(i, strItem); - - cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx); - } - - wndListBox.SetHorizontalExtent(cxExtentMax); - dc.SelectObject(pOldFont); -} - -void COutputBar::FillBuildWindow() -{ - m_wndOutputBuild.AddString(_T("--------------------Configuration: Hello - Win32 Debug--------------------")); - m_wndOutputBuild.AddString(_T("Compiling...")); - m_wndOutputBuild.AddString(_T("Hello.cpp...")); - m_wndOutputBuild.AddString(_T("Linking...")); - m_wndOutputBuild.AddString(_T("")); - m_wndOutputBuild.AddString(_T("Hello.exe - 0 error(s), 0 warning(s)")); - -} - -void COutputBar::FillDebugWindow() -{ - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\ntdll.dll', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\winmm.dll', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\USER32.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\KERNEL32.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\GDI32.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\ADVAPI32.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\RPCRT4.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded symbols for 'C:\\WINNT\\System32\\MFC42D.DLL'")); - m_wndOutputDebug.AddString(_T("Loaded symbols for 'C:\\WINNT\\System32\\MSVCRTD.DLL'")); - m_wndOutputDebug.AddString(_T("Loaded symbols for 'C:\\WINNT\\System32\\MFCO42D.DLL'")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\MMDRV.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\sndblst.dll', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\COMCTL32.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("CONTROLBAR.DLL Initializing!")); - m_wndOutputDebug.AddString(_T("Loaded 'C:\\WINNT\\System32\\OLE32.DLL', no matching symbolic information found.")); - m_wndOutputDebug.AddString(_T("The thread 0x142 has exited with code 0(0x0).")); - m_wndOutputDebug.AddString(_T("CONTROLBAR.DLL Terminating!")); - m_wndOutputDebug.AddString(_T("The thread 0x15C has exited with code 0(0x0).")); - m_wndOutputDebug.AddString(_T("The program 'Hello.exe' has exited with code 0(0x0).")); -} -///////////////////////////////////////////////////////////////////////////// -// COutputList1 - -COutputList1::COutputList1() -{ -} - -COutputList1::~COutputList1() -{ -} - -BEGIN_MESSAGE_MAP(COutputList1, CListBox) - ON_WM_WINDOWPOSCHANGING() - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) - ON_COMMAND(ID_OUTPUT_GOTO_ERROR, OnOutputGotoError) - ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutputList1 message handlers - -void COutputList1::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) -{ - CListBox::OnWindowPosChanging(lpwndpos); - - // Hide horizontal scrollbar: - ShowScrollBar(SB_HORZ, FALSE); - ModifyStyle(WS_HSCROLL, 0, SWP_DRAWFRAME); -} - -void COutputList1::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - CMenu menu; - menu.LoadMenu(IDR_POPUP_OUTPUT); - - CMenu* pSumMenu = menu.GetSubMenu(0); - - if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - - if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) - return; - - ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); - UpdateDialogControls(this, FALSE); - } -} - -void COutputList1::OnEditCopy() -{ - MessageBox(_T("Copy output")); -} - -void COutputList1::OnEditClear() -{ - MessageBox(_T("Clear output")); -} - -void COutputList1::OnOutputGotoError() -{ - // TODO: Add your command handler code here -} - -// -void COutputList1::OnViewOutput() -{ - CBasePane* pParentBar = DYNAMIC_DOWNCAST(CBasePane, GetOwner()); - CFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CFrameWndEx, GetTopLevelFrame()); - - if (pMainFrame != NULL && pParentBar != NULL) - { - pMainFrame->SetFocus(); - pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputBar.h deleted file mode 100644 index 9d5c96dcf97ff..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputBar.h +++ /dev/null @@ -1,79 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// COutputList1 window - -class COutputList1 : public CListBox -{ -// Construction -public: - COutputList1(); - -// Implementation -public: - virtual ~COutputList1(); - -protected: - afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnEditCopy(); - afx_msg void OnEditClear(); - afx_msg void OnOutputGotoError(); - afx_msg void OnViewOutput(); - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// COutputBar window - -class COutputBar : public CDockablePane -{ -// Construction -public: - COutputBar(); - -// Attributes -protected: - CMFCTabCtrl m_wndTabs; - CFont m_Font; - - COutputList1 m_wndOutputBuild; - COutputList1 m_wndOutputDebug; - COutputList1 m_wndOutputFind1; - COutputList1 m_wndOutputFind2; - COutputList1 m_wndOutputSQL; - -// Operations -public: - void SetFlatTabs(BOOL bFlat = TRUE, BOOL bRepaint = TRUE) - { - m_wndTabs.SetFlatFrame(bFlat, bRepaint); - } - -protected: - void FillBuildWindow(); - void FillDebugWindow(); - void AdjusrHorzScroll(CListBox& wndListBox); - -// Implementation -public: - virtual ~COutputBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - - DECLARE_MESSAGE_MAP() -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputView.cpp deleted file mode 100644 index 88483869d5a44..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputView.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "MainFrm.h" -#include "OutputView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COutputBar - -COutputViewBar::COutputViewBar() -{ -} - -COutputViewBar::~COutputViewBar() -{ -} - -BEGIN_MESSAGE_MAP(COutputViewBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_PAINT() - ON_WM_SETFOCUS() -END_MESSAGE_MAP() - -int COutputViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - m_Font.CreateStockObject(DEFAULT_GUI_FONT); - - CRect rectClient(0, 0, lpCreateStruct->cx, lpCreateStruct->cy); - - // Create output pane: - const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; - - if (!m_wndOutput.Create(dwStyle, rectClient, this, 1)) - { - TRACE0("Failed to create output window\n"); - return -1; // fail to create - } - - m_wndOutput.SetFont(&m_Font); - - // Fill view context(dummy code, don't seek here something magic :-)): - FillDebugWindow(); - return 0; -} - -void COutputViewBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - CRect rc; - GetClientRect(rc); - - m_wndOutput.SetWindowPos(NULL, rc.left + 1, rc.top + 1, rc.Width() - 2, rc.Height() - 2, SWP_NOACTIVATE | SWP_NOZORDER ); - - AdjusrHorzScroll(m_wndOutput); -} - -void COutputViewBar::AdjusrHorzScroll(CListBox& wndListBox) -{ - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(&m_Font); - - int cxExtentMax = 0; - - for (int i = 0; i < wndListBox.GetCount(); i ++) - { - CString strItem; - wndListBox.GetText(i, strItem); - - cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx); - } - - wndListBox.SetHorizontalExtent(cxExtentMax); - dc.SelectObject(pOldFont); -} - -void COutputViewBar::FillDebugWindow() -{ - m_wndOutput.AddString(_T("The program has started successfully.")); - m_wndOutput.AddString(_T("Enjoy using it!")); -} - -///////////////////////////////////////////////////////////////////////////// -// COutputList1 - -COutputList::COutputList() -{ -} - -COutputList::~COutputList() -{ -} - -BEGIN_MESSAGE_MAP(COutputList, CListBox) - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) - ON_COMMAND(ID_OUTPUT_GOTO_ERROR, OnOutputGotoError) - ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput) - ON_WM_WINDOWPOSCHANGING() -END_MESSAGE_MAP() -///////////////////////////////////////////////////////////////////////////// -// COutputList message handlers - -void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - CMenu menu; - menu.LoadMenu(IDR_POPUP_OUTPUT); - - CMenu* pSumMenu = menu.GetSubMenu(0); - - if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) - { - CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu; - - if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE)) - return; - - ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu); - UpdateDialogControls(this, FALSE); - } - - SetFocus(); -} - -void COutputList::OnEditCopy() -{ - MessageBox(_T("Copy output")); -} - -void COutputList::OnEditClear() -{ - MessageBox(_T("Clear output")); -} - -void COutputList::OnOutputGotoError() -{ - // TODO: Add your command handler code here -} - -void COutputList::OnViewOutput() -{ - // - // GetOwner is an inherited method. - CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner()); - // - CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame()); - - if (pMainFrame != NULL && pParentBar != NULL) - { - pMainFrame->SetFocus(); - pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE); - pMainFrame->RecalcLayout(); - - // - pParentBar->EnableAutohideAll(); - pParentBar->EnableGripper(true); - pParentBar->SetAutoHideMode(true, CBRS_ALIGN_LEFT); - pParentBar->ShowPane(true,false,true); - pParentBar->Slide(true); - // - } -} - -void COutputViewBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndOutput.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void COutputViewBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - m_wndOutput.SetFocus(); -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputView.h deleted file mode 100644 index 735b1bbb5216e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/OutputView.h +++ /dev/null @@ -1,63 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// COutputList window - -class COutputList : public CListBox -{ -// Construction -public: - COutputList(); - -// Implementation -public: - virtual ~COutputList(); - -protected: - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnEditCopy(); - afx_msg void OnEditClear(); - afx_msg void OnOutputGotoError(); - afx_msg void OnViewOutput(); - - DECLARE_MESSAGE_MAP() -}; - -class COutputViewBar : public CDockablePane -{ -// Construction -public: - COutputViewBar(); - -// Attributes -protected: - CFont m_Font; - COutputList m_wndOutput; - -protected: - void FillDebugWindow(); - void FillBuildWindow(); - void AdjusrHorzScroll(CListBox& wndListBox); - -// Implementation -public: - virtual ~COutputViewBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/PropertiesViewBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/PropertiesViewBar.cpp deleted file mode 100644 index b37a57be00156..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/PropertiesViewBar.cpp +++ /dev/null @@ -1,271 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "MainFrm.h" -#include "PropertiesViewBar.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CResourceViewBar - -CPropertiesViewBar::CPropertiesViewBar() -{ -} - -CPropertiesViewBar::~CPropertiesViewBar() -{ -} - -BEGIN_MESSAGE_MAP(CPropertiesViewBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_COMMAND(ID_SORTINGPROP, OnSortingprop) - ON_UPDATE_COMMAND_UI(ID_SORTINGPROP, OnUpdateSortingprop) - ON_COMMAND(ID_PROPERIES1, OnProperies1) - ON_UPDATE_COMMAND_UI(ID_PROPERIES1, OnUpdateProperies1) - ON_COMMAND(ID_PROPERIES2, OnProperies2) - ON_UPDATE_COMMAND_UI(ID_PROPERIES2, OnUpdateProperies2) - ON_COMMAND(ID_EXPAND, OnExpand) - ON_UPDATE_COMMAND_UI(ID_EXPAND, OnUpdateExpand) - ON_WM_SETFOCUS() - ON_WM_SETTINGCHANGE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CResourceViewBar message handlers - -void CPropertiesViewBar::AdjustLayout() -{ - if (GetSafeHwnd() == NULL) - { - return; - } - - CRect rectClient,rectCombo; - GetClientRect(rectClient); - - m_wndObjectCombo.GetWindowRect(&rectCombo); - - int cyCmb = rectCombo.Size().cy; - int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy; - - m_wndObjectCombo.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), 200, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER); - m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb + cyTlb, rectClient.Width(), rectClient.Height() -(cyCmb+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER); -} - -int CPropertiesViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create combo: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST - | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - - if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1)) - { - TRACE0("Failed to create Properies Combo \n"); - return -1; // fail to create - } - - m_wndObjectCombo.AddString(_T("IDD_ABOUTBOX(Dialog)")); - m_wndObjectCombo.SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT))); - m_wndObjectCombo.SetCurSel(0); - - if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2)) - { - TRACE0("Failed to create Properies Grid \n"); - return -1; // fail to create - } - - InitPropList(); - - m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES); - m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* Is locked */); - - OnChangeVisualStyle(); - - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); - m_wndToolBar.SetOwner(this); - - // All commands will be routed via this control , not via the parent frame: - m_wndToolBar.SetRouteCommandsViaFrame(FALSE); - - AdjustLayout(); - return 0; -} - -void CPropertiesViewBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - AdjustLayout(); -} - -void CPropertiesViewBar::OnSortingprop() -{ - m_wndPropList.SetAlphabeticMode(); -} - -void CPropertiesViewBar::OnUpdateSortingprop(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); -} - -void CPropertiesViewBar::OnExpand() -{ - m_wndPropList.SetAlphabeticMode(FALSE); -} - -void CPropertiesViewBar::OnUpdateExpand(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(!m_wndPropList.IsAlphabeticMode()); -} - -void CPropertiesViewBar::OnProperies1() -{ - // TODO: Add your command handler code here -} - -void CPropertiesViewBar::OnUpdateProperies1(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here -} - -void CPropertiesViewBar::OnProperies2() -{ - // TODO: Add your command handler code here -} - -void CPropertiesViewBar::OnUpdateProperies2(CCmdUI* /*pCmdUI*/) -{ - // TODO: Add your command update UI handler code here -} - -void CPropertiesViewBar::InitPropList() -{ - SetPropListFont(); - - m_wndPropList.EnableHeaderCtrl(FALSE); - m_wndPropList.EnableDescriptionArea(); - m_wndPropList.SetVSDotNetLook(); - m_wndPropList.MarkModifiedProperties(); - - CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Appearance")); - - pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("3D Look"), (_variant_t) false, _T("Specifies the dialog's font will be nonbold and controls will have a 3D border"))); - - CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Border"), _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame")); - pProp->AddOption(_T("None")); - pProp->AddOption(_T("Thin")); - pProp->AddOption(_T("Resizable")); - pProp->AddOption(_T("Dialog Frame")); - pProp->AllowEdit(FALSE); - - pGroup1->AddSubItem(pProp); - pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (_variant_t) _T("About"), _T("Specifies the text that will be displayed in the dialog's title bar"))); - - m_wndPropList.AddProperty(pGroup1); - - CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("Window Size"), 0, TRUE); - - pProp = new CMFCPropertyGridProperty(_T("Height"), (_variant_t) 250l, _T("Specifies the dialog's height")); - pProp->EnableSpinControl(TRUE, 0, 1000); - pSize->AddSubItem(pProp); - - pProp = new CMFCPropertyGridProperty( _T("Width"), (_variant_t) 150l, _T("Specifies the dialog's width")); - pProp->EnableSpinControl(); - pSize->AddSubItem(pProp); - - m_wndPropList.AddProperty(pSize); - - CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("Font")); - - LOGFONT lf; - CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); - font->GetLogFont(&lf); - - lstrcpy(lf.lfFaceName, _T("Arial")); - - pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the dialog"))); - pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (_variant_t) true, _T("Specifies that the dialog uses MS Shell Dlg font"))); - - m_wndPropList.AddProperty(pGroup2); - - CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("Misc")); - pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("IDD_ABOUT_BOX(dialog)")); - pProp->Enable(FALSE); - pGroup3->AddSubItem(pProp); - - CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default dialog color")); - pColorProp->EnableOtherButton(_T("Other...")); - pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE)); - pGroup3->AddSubItem(pColorProp); - - // - // CMFCPropertyGridProperty* pGroup3 - static TCHAR BASED_CODE szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||"); - pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the dialog icon"))); - // - - pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\"))); - - m_wndPropList.AddProperty(pGroup3); - - CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("Hierarchy")); - - CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level")); - pGroup4->AddSubItem(pGroup41); - - CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level")); - pGroup41->AddSubItem(pGroup411); - - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description"))); - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description"))); - pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description"))); - - pGroup4->Expand(FALSE); - m_wndPropList.AddProperty(pGroup4); -} - -void CPropertiesViewBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - - m_wndPropList.SetFocus(); - -} - -void CPropertiesViewBar::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) -{ - CDockablePane::OnSettingChange(uFlags, lpszSection); - SetPropListFont(); -} - -void CPropertiesViewBar::SetPropListFont() -{ - m_wndPropList.SetFont(&afxGlobalData.fontRegular); -} - -void CPropertiesViewBar::OnChangeVisualStyle() -{ - m_wndToolBar.CleanUpLockedImages(); - m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROP24 : IDR_PROPERTIES, 0, 0, TRUE /* Locked */); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/PropertiesViewBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/PropertiesViewBar.h deleted file mode 100644 index a1c614089f874..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/PropertiesViewBar.h +++ /dev/null @@ -1,70 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CPropertiesToolBar : public CMFCToolBar -{ -public: - virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) - { - CMFCToolBar::OnUpdateCmdUI((CFrameWnd*) GetOwner(), bDisableIfNoHndler); - } - - virtual BOOL AllowShowOnList() const { return FALSE; } -}; - -class CPropertiesViewBar : public CDockablePane -{ -// Construction -public: - CPropertiesViewBar(); - - void AdjustLayout(); - -// Attributes -public: - void SetVSDotNetLook(BOOL bSet) - { - m_wndPropList.SetVSDotNetLook(bSet); - m_wndPropList.SetGroupNameFullWidth(bSet); - } - - void OnChangeVisualStyle(); - -protected: - CComboBox m_wndObjectCombo; - CPropertiesToolBar m_wndToolBar; - CMFCPropertyGridCtrl m_wndPropList; - CFont m_fntPropList; - -// Implementation -public: - virtual ~CPropertiesViewBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSortingprop(); - afx_msg void OnUpdateSortingprop(CCmdUI* pCmdUI); - afx_msg void OnProperies1(); - afx_msg void OnUpdateProperies1(CCmdUI* pCmdUI); - afx_msg void OnProperies2(); - afx_msg void OnUpdateProperies2(CCmdUI* pCmdUI); - afx_msg void OnExpand(); - afx_msg void OnUpdateExpand(CCmdUI* pCmdUI); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); - - DECLARE_MESSAGE_MAP() - - void InitPropList(); - void SetPropListFont(); -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ReadMe.htm b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ReadMe.htm deleted file mode 100644 index 0ac9265ed0d45..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ReadMe.htm +++ /dev/null @@ -1,132 +0,0 @@ - - - - VisualStudioDemo Sample: MFC Visual Studio Application - - -

- VisualStudioDemo Sample: MFC Visual Studio Application

-
-
-
- -

-

-
-

- The VisualStudioDemo sample demonstrates how to implement an application with many - of the same user interface features and some of the capabilities of Visual Studio. - Many of the Visual Studio user interface elements, including customizable docking - menubar and toolbars, and docking windows, are demonstrated.

-
- - - - - - - -
- Security Note:
-

- This sample code is provided to illustrate a concept and should not be used in applications - or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes - no liability for incidental or consequential damages should the sample code be used - for purposes other than as intended.

-
-
-

- To get samples and instructions for installing them:

-
    -
  • -

    - On the Visual Studio Help menu, click Samples.

    -

    - For more information, see - Locating Sample Files.

    -
  • -
  • -

    - The most recent version and complete list of samples is available online from the - Visual Studio 2008 Samples page.

    -
  • -
  • -

    - You can also locate samples on your computer's hard disk. By default, samples and - a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. - For Express editions of Visual Studio, all samples are located online.

    -
  • -
-
-

- Building and Running the Sample

-
-
-
-
- - - - - - - -
-

- To build and run the VisualStudioDemo sample

-
-
    -
  1. -

    - Open the solution file VisualStudioDemo.sln. -

    -
  2. -
  3. -

    - Select the appropriate solution platform and configuration.

    -
  4. -
  5. -

    - On the Build menu, click Build. -

    -
  6. -
  7. -

    - On the Debug menu, click Start Debugging or Start Without Debugging. -

    -
  8. -
-
-
-
-

- Keywords

-
-

- The VisualStudioDemo sample demonstrates the following keywords:

-

- CBasePane; CDockablePane; CDockingManager; CFrameWndEx; CMDIChildWnd; CMDIChildWndEx; - CMDIFrameWndEx; CMDITabInfo; CMFCDropDownToolBar; CMFCDropDownToolbarButton; CMFCKeyMapDialog; - CMFCListCtrl; CMFCMenuBar; CMFCPopupMenu; CMFCPopupMenuBar; CMFCPropertyGridColorProperty; - CMFCPropertyGridCtrl; CMFCPropertyGridFileProperty; CMFCPropertyGridFontProperty; - CMFCPropertyGridProperty; CMFCPropertyPage; CMFCPropertySheet; CMFCPropertySheetCategoryInfo; - CMFCStatusBar; CMFCTabCtrl; CMFCTabToolTipInfo; CMFCToolBar; CMFCToolBarComboBoxButton; - CMFCToolBarImages; CMFCToolBarMenuButton; CMFCToolBarsCustomizeDialog; CMFCToolTipCtrl; - CMFCToolTipInfo; CMFCVisualManager; CMFCVisualManagerOffice; CMFCVisualManagerVS; - CMFCVisualManagerWindows; CTabbedPane; CUserTool; CUserToolsManager; CWinAppEx; -

-
-
- -
- - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/Resource.h deleted file mode 100644 index d37e2e9b893d5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/Resource.h +++ /dev/null @@ -1,311 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by VisualStudioDemo.rc -// -#define IDC_APPLY 3 -#define IDP_OLE_INIT_FAILED 100 -#define IDS_MAIN_TOOLBAR 101 -#define IDS_STRING_NOT_FOUND_FMT 102 -#define IDS_BUILD_TOOLBAR 103 -#define IDS_RESOURCE_TOOLBAR 104 -#define IDS_EDIT_TOOLBAR 106 -#define ID_EDIT_FINDNEXT 108 -#define ID_VIEW_EDITCTRL 112 -#define ID_EDIT_FINDPREV 113 -#define ID_EDIT_SHOWHINT 116 -#define IDS_EDITFAILED 121 -#define IDS_PGUPFAILED 122 -#define IDR_MAINFRAME 128 -#define IDR_DEVTYPE0 129 -#define IDR_DEVTYPE_CPP 130 -#define IDR_CONTEXT_MENU 132 -#define IDI_CLASS_VIEW 132 -#define IDR_POPUP_TOOLBAR 133 -#define IDI_RES_VIEW 133 -#define IDB_WORKSPACE 134 -#define IDI_FILE_VIEW 134 -#define IDB_CLASS_VIEW 135 -#define IDI_OUTPUT_BAR 135 -#define IDB_RESOURCE_VIEW 136 -#define IDI_WATCH_BAR 136 -#define IDB_FILE_VIEW 137 -#define IDR_BUILD 138 -#define IDR_POPUP_SORT 139 -#define IDR_MENU_IMAGES 142 -#define IDB_CHECK 143 -#define IDR_POPUP_OUTPUT 144 -#define IDR_TOOLBAR_RESOURCE 145 -#define IDR_SORT 146 -#define IDR_MENU_DIRS 147 -#define IDI_DYNAMICHELP_VIEW 148 -#define IDR_DYNAMIC_HELP 149 -#define IDD_OPTIONSPAGE2 149 -#define IDB_DYNAMICHELP 150 -#define IDD_OPTIONSPAGE3 150 -#define IDR_PROPERTIES 151 -#define IDD_OPTIONSPAGE4 151 -#define IDD_OPTIONSPAGE5 152 -#define IDI_PROPERTIES_BAR 153 -#define IDD_OPTIONSPAGE6 153 -#define IDR_SOLUTION_EXPLORER 154 -#define IDD_OPTIONSPAGE1 154 -#define IDR_EDIT 155 -#define IDI_CLASS_VIEW_HC 158 -#define IDR_MENU_ARGS 161 -#define IDR_POPUP_SOLUTION 162 -#define IDR_POPUP_RESOURCE 163 -#define IDR_POPUP_CONTROLBAR 164 -#define IDB_TOOLS_PAGE1 168 -#define IDB_TOOLS_PAGE2 169 -#define IDD_FINDDIALOG 169 -#define IDB_TOOLS_PAGE3 170 -#define IDB_IMG_INTELLISENSE 173 -#define IDB_OPTIONSIMAGES 174 -#define ID_EXAMPLE_CPP 177 -#define IDR_POPUP_MDITABS 177 -#define ID_EXAMPLE_WEB 178 -#define IDR_POPUP_DROP_MDITABS 178 -#define IDD_APP_LOOK 180 -#define IDR_EDITOR_XML_SETTINGS_WEB 182 -#define IDR_EDITOR_XML_SETTINGS_CPP 183 -#define IDB_MENUIMAGES24 185 -#define IDB_TOOLBAR24 186 -#define IDB_BUILD24 187 -#define IDB_EDIT24 188 -#define IDI_FILE_VIEW_HC 189 -#define IDB_IMG_INTELLISENSE_HC 189 -#define IDI_RES_VIEW_HC 190 -#define IDI_PROP_BAR_HC 192 -#define IDI_DYNAMICHELP_VIEW_HC 193 -#define IDI_WATCH_BAR_HC 194 -#define IDI_OUTPUT_BAR_HC 195 -#define IDB_SOLUTION_EXPLORER_24 195 -#define IDB_PROP24 196 -#define IDB_CLASS_VIEW_24 197 -#define IDB_SORT24 198 -#define IDB_TOOLS_PAGE1_HC 200 -#define IDD_GOTO_LINE 201 -#define IDB_TOOLS_PAGE2_HC 201 -#define IDB_TOOLS_PAGE3_HC 202 -#define IDB_FILE_VIEW24 203 -#define IDB_HELPTOOLBAR_24 204 -#define IDB_DYNAMICHELP24 205 -#define IDB_RESOURCE_VIEW24 206 -#define IDB_BREAK 207 -#define IDB_CURRENT 208 -#define IDR_START 209 -#define IDD_ABOUTBOX 999 -#define IDC_MAIL 1000 -#define IDC_URL 1001 -#define IDC_FINDDIALOG_MATCHWHOLEWORDONLYCHECK 1001 -#define IDC_VERSION 1002 -#define IDC_FINDDIALOG_MATCHCASECHECK 1002 -#define IDC_FINDDIALOG_REGULAREXPRESSIONCHECK 1003 -#define IDC_FINDDIALOG_SEARCHALLOPENDOCUMENTSCHECK 1004 -#define IDC_FINDDIALOG_UPRADIO 1005 -#define IDC_FINDDIALOG_DOWNRADIO 1006 -#define IDC_FINDDIALOG_MARKALLBUTTON 1007 -#define IDC_RADIO1 1007 -#define IDC_FINDDIALOG_REGULARBUTTON 1008 -#define IDC_RADIO2 1008 -#define IDC_BUTTON1 1009 -#define IDC_RADIO3 1009 -#define IDC_COMBO1 1010 -#define IDC_FINDDIALOG_FINDCOMBO 1011 -#define IDC_CHECK1 1011 -#define IDC_EDIT2 1012 -#define IDC_CHECK5 1012 -#define IDC_APP_LOOK1 1012 -#define IDC_EDIT3 1013 -#define IDC_CHECK8 1013 -#define IDC_APP_LOOK2 1013 -#define IDC_CHECK2 1014 -#define IDC_CHECK9 1014 -#define IDC_APP_LOOK3 1014 -#define IDC_CHECK3 1015 -#define IDC_CHECK10 1015 -#define IDC_SHOW_AT_STARTUP 1015 -#define IDC_CHECK4 1016 -#define IDC_CHECK11 1016 -#define IDC_ONENOTE_TABS 1016 -#define IDC_CHECK6 1017 -#define IDC_EDIT1 1017 -#define IDC_CHECK12 1017 -#define IDC_DOCK_TAB_COLORS 1017 -#define IDC_CHECK7 1018 -#define IDC_CHECK13 1018 -#define IDC_EDIT4 1018 -#define IDC_XP_COLORS 1018 -#define IDC_APP_LOOK4 1018 -#define IDC_LINE 1018 -#define IDC_ACTIVETAB_CLOSE_BUTTON 1018 -#define IDC_RADIO4 1019 -#define IDC_APP_LOOK5 1019 -#define IDC_RADIO5 1020 -#define IDC_ROUNDED_TABS 1020 -#define IDC_CUSTOM_TOOLTIPS 1021 -#define IDC_APP_LOOK6 1022 -#define IDC_APP_LOOK 1023 -#define IDC_STYLE 1024 -#define ID_VIEW_CUSTOMIZE 32770 -#define ID_VIEW_USER_TOOLBAR1 32771 -#define ID_VIEW_USER_TOOLBAR2 32772 -#define ID_VIEW_USER_TOOLBAR3 32773 -#define ID_VIEW_USER_TOOLBAR4 32774 -#define ID_VIEW_USER_TOOLBAR5 32775 -#define ID_VIEW_USER_TOOLBAR6 32776 -#define ID_VIEW_USER_TOOLBAR7 32777 -#define ID_VIEW_USER_TOOLBAR8 32778 -#define ID_VIEW_USER_TOOLBAR9 32779 -#define ID_VIEW_USER_TOOLBAR10 32780 -#define ID_VIEW_TOOLBARS 32781 -#define ID_VIEW_WORKSPACE 32782 -#define ID_VIEW_OUTPUT 32783 -#define ID_WINDOW_MANAGER 32784 -#define ID_VIEW_DYNAMICHELP 32785 -#define ID_DUMMY_COMPILE 32787 -#define ID_DUMMY_BUILD 32788 -#define ID_DUMMY_STOP_BUILD 32789 -#define ID_SORT_MENU 32789 -#define ID_DUMMY_EXECUTE 32790 -#define ID_DUMMY_GO 32791 -#define ID_DUMMY_SELECT_ACTIVE_CONFIGURATION 32794 -#define ID_DUMMY_REMOVE_ALL_BREAKPOINTS 32796 -#define ID_VIEW_BUILD_TOOLBAR 32797 -#define ID_DUMMY_REBUILD_ALL 32798 -#define ID_DUMMY_CLEAN 32799 -#define IDS_DUMMY_UNDO_ACTION 32800 -#define ID_VIEW_CB_CAPTION 32804 -#define ID_VIEW_FORCE_GRADIENT 32805 -#define ID_USER_TOOL1 32806 -#define ID_USER_TOOL2 32807 -#define ID_USER_TOOL3 32808 -#define ID_USER_TOOL4 32809 -#define ID_USER_TOOL5 32810 -#define ID_USER_TOOL6 32811 -#define ID_USER_TOOL7 32812 -#define ID_USER_TOOL8 32813 -#define ID_USER_TOOL9 32814 -#define ID_USER_TOOL10 32815 -#define ID_TOOLS_MACRO 32816 -#define ID_TOOLS_ENTRY 32819 -#define ID_NEW_DIALOG 32823 -#define ID_NEW_MENU 32824 -#define ID_NEW_CURSOR 32825 -#define ID_NEW_ICON 32826 -#define ID_NEW_BITMAP 32827 -#define ID_NEW_TOOLBAR 32828 -#define ID_NEW_ACCELERATOR 32829 -#define ID_NEW_STRING_TABLE 32830 -#define ID_NEW_VERSION 32831 -#define ID_OUTPUT_GOTO_ERROR 32833 -#define ID_CLASS_DEFINITION 32836 -#define ID_CLASS_ADD_MEMEBER_FUNCTION 32837 -#define ID_CLASS_ADD_MEMEBER_VARIABLE 32838 -#define ID_CLASS_PROPERTIES 32839 -#define ID_RESOURCE_OPEN 32840 -#define ID_RESOURCE_OPEN_BINARY 32841 -#define ID_DUMMY_INSERT_RESOURCE 32842 -#define ID_VIEW_TAB_FLAT_BORDERS 32844 -#define ID_HELP_KEYBOARDMAP 32845 -#define ID_VIEW_DOCUMENT_TAB 32845 -#define ID_MENU_DIR1 32847 -#define ID_MENU_DIR2 32848 -#define ID_MENU_DIR3 32849 -#define ID_MDITABS_ICONS 32850 -#define ID_MDITABS_TOP 32851 -#define ID_MDITABS_BOTTOM 32852 -#define ID_VIEW_MDI_TABS 32853 -#define ID_MDITABS_CLOSE 32855 -#define ID_VIEW_CLASS 32856 -#define ID_VIEW_RESOURCE 32857 -#define ID_VIEW_FILE 32858 -#define ID_MENU_ITEM1 32866 -#define ID_MENU_ITEM2 32867 -#define ID_MENU_ITEM3 32868 -#define ID_SORTING_GROUPBYTYPE 32869 -#define ID_SORTING_SORTALF 32870 -#define ID_SORTING_SORTBYTYPE 32871 -#define ID_SORTING_SORTBYACCESS 32872 -#define ID_DHELP1 32873 -#define ID_DHELP2 32874 -#define ID_DHELP3 32875 -#define ID_EXPAND 32878 -#define ID_SORTINGPROP 32879 -#define ID_PROPERIES1 32880 -#define ID_PROPERIES2 32881 -#define ID_NEW_FOLDER 32882 -#define ID_PROPERTIES 32883 -#define ID_SOLUTION_OPEN 32884 -#define ID_SOLUTION_OPEN_WITH 32885 -#define ID_FILE_NEW_PROJECT 32886 -#define ID_FILE_NEW_BLANK_SOLUTION 32887 -#define ID_FILE_OPEN_SOLUTION 32888 -#define ID_FILE_CLOSE_SOLUTION 32889 -#define ID_FILE_SAVE_ALL 32892 -#define ID_TOOLS_DEBUG_PROCESSES 32893 -#define ID_TOOLS_CONNECT_TO_DATABASE 32894 -#define ID_WINDOW_CLOSE_ALL 32895 -#define ID_HELP_SHOW_START 32896 -#define ID_VIEW_REFRESH 32897 -#define ID_VIEW_PROPERTIES 32900 -#define ID_VIEW_WATCH 32901 -#define ID_VIEW_FULLSCREEN 32902 -#define ID_EDIT_TOGGLEBOOKMARK 32925 -#define ID_EDIT_NEXTBOOKMARK 32926 -#define ID_EDIT_PREVIOUSBOOKMARK 32927 -#define ID_EDIT_TOGGLEBREAKPOINT 32928 -#define ID_EDIT_CLEAR_ALLBOOKMARKS 32930 -#define ID_EDIT_INCREASE_IDENT 32931 -#define ID_EDIT_DECREASE_IDENT 32932 -#define ID_VIEW_EDIT_TOOLBAR 32933 -#define ID_EDIT_LISTMEMBERS 32935 -#define IDS_UAT_UNDEFINED 32936 -#define IDS_UAT_INSERTDATA 32937 -#define IDS_UAT_TYPING 32937 -#define IDS_UAT_DELETEDATA 32938 -#define IDS_UAT_DELETE 32938 -#define IDS_UAT_INDENTDATA 32939 -#define IDS_UAT_INDENT 32939 -#define IDS_UAT_UNKNOWN 32940 -#define IDS_UAT_CUT 32941 -#define IDS_UAT_PASTE 32942 -#define IDS_UAT_BACKSPACE 32943 -#define IDS_UAT_UNINDENT 32944 -#define IDS_UAT_DRAGDROP 32945 -#define IDS_UAT_TAB 32946 -#define IDS_UAT_ENTER 32947 -#define ID_EDIT_FIND_COMBO 32948 -#define ID_TOOLS_OPTIONS 32949 -#define ID_VIEW_APP_LOOK 32950 -#define ID_HELP_WEB 32951 -#define ID_EDIT_HIDESELECTION 32952 -#define ID_EDIT_TOGGLEOUTLINING 32953 -#define ID_EDIT_STOPHIDINGCURRENT 32954 -#define ID_EDIT_TOGGLEALLOUTLINING 32955 -#define ID_EDIT_COLLAPSETODEFINITIONS 32956 -#define ID_EDIT_STOPOUTLINING 32957 -#define ID_EDIT_AUTOOUTLINING 32958 -#define ID_EDIT_ENABLEOUTLINING 32959 -#define ID_EDIT_NEXT_WORD 32960 -#define ID_EDIT_LINENUMBERS 32961 -#define IDS_UAT_REPLACE 32962 -#define ID_EDIT_GOTO_LINE 32963 -#define ID_MDI_NEW_VERT_GROUP 32965 -#define ID_MDI_NEW_HORZ_TAB_GROUP 32966 -#define ID_MDI_MOVE_TO_PREV_GROUP 32967 -#define ID_MDI_CANCEL 32968 -#define ID_MDI_MOVE_TO_NEXT_GROUP 32969 -#define ID_MDI_TABBED_DOCUMENT 32974 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 210 -#define _APS_NEXT_COMMAND_VALUE 32975 -#define _APS_NEXT_CONTROL_VALUE 1025 -#define _APS_NEXT_SYMED_VALUE 123 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ResourceView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ResourceView.cpp deleted file mode 100644 index 2558e0ca9db2a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ResourceView.cpp +++ /dev/null @@ -1,218 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "MainFrm.h" -#include "ResourceView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CResourceViewBar - -CResourceViewBar::CResourceViewBar() -{ -} - -CResourceViewBar::~CResourceViewBar() -{ -} - -BEGIN_MESSAGE_MAP(CResourceViewBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_EDIT_CUT, OnEditCut) - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) - ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) - ON_WM_PAINT() - ON_WM_SETFOCUS() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CResourceViewBar message handlers - -int CResourceViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create view: - const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; - - if (!m_wndResourceView.Create(dwViewStyle, rectDummy, this, 3)) - { - TRACE0("Failed to create workspace view\n"); - return -1; // fail to create - } - - // Load view images: - m_ResourceViewImages.Create(IDB_RESOURCE_VIEW, 16, 0, RGB(255, 0, 255)); - m_wndResourceView.SetImageList(&m_ResourceViewImages, TVSIL_NORMAL); - - // Fill view context(dummy code, don't seek here something magic :-)): - FillResourceView(); - - OnChangeVisualStyle(); - return 0; -} - -void CResourceViewBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - if (CanAdjustLayout()) - { - m_wndResourceView.SetWindowPos(NULL, 1, 1, cx - 2, cy - 2, SWP_NOACTIVATE | SWP_NOZORDER); - } -} - -void CResourceViewBar::FillResourceView() -{ - HTREEITEM hRoot = m_wndResourceView.InsertItem(_T("Hello resources"), 0, 0); - m_wndResourceView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); - - HTREEITEM hFolder = m_wndResourceView.InsertItem(_T("Accelerator"), 0, 0, hRoot); - m_wndResourceView.InsertItem(_T("IDR_MAINFRAME"), 1, 1, hFolder); - - m_wndResourceView.Expand(hRoot, TVE_EXPAND); - - hFolder = m_wndResourceView.InsertItem(_T("Dialog"), 0, 0, hRoot); - m_wndResourceView.InsertItem(_T("IDD_ABOUTBOX"), 3, 3, hFolder); - - hFolder = m_wndResourceView.InsertItem(_T("Icon"), 0, 0, hRoot); - m_wndResourceView.InsertItem(_T("IDR_HELLO"), 4, 4, hFolder); - m_wndResourceView.InsertItem(_T("IDR_MAINFRAME"), 4, 4, hFolder); - - m_wndResourceView.Expand(hFolder, TVE_EXPAND); - - hFolder = m_wndResourceView.InsertItem(_T("Menu"), 0, 0, hRoot); - m_wndResourceView.InsertItem(_T("IDR_CONTEXT_MENU"), 5, 5, hFolder); - m_wndResourceView.InsertItem(_T("IDR_HELLO"), 5, 5, hFolder); - m_wndResourceView.InsertItem(_T("IDR_MAINFRAME"), 5, 5, hFolder); - m_wndResourceView.InsertItem(_T("IDR_POPUP_TOOLBAR"), 5, 5, hFolder); - - m_wndResourceView.Expand(hFolder, TVE_EXPAND); - - hFolder = m_wndResourceView.InsertItem(_T("String Table"), 0, 0, hRoot); - m_wndResourceView.InsertItem(_T("String Table"), 6, 6, hFolder); - - hFolder = m_wndResourceView.InsertItem(_T("Toolbar"), 0, 0, hRoot); - m_wndResourceView.InsertItem(_T("IDR_MAINFRAME"), 7, 7, hFolder); - - hFolder = m_wndResourceView.InsertItem(_T("Version"), 0, 0, hRoot); - m_wndResourceView.InsertItem(_T("VS_VERSION_INFO"), 8, 8, hFolder); -} - -void CResourceViewBar::OnContextMenu(CWnd* pWnd, CPoint point) -{ - CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndResourceView; - ASSERT_VALID(pWndTree); - - if (pWnd != pWndTree) - { - CDockablePane::OnContextMenu(pWnd, point); - return; - } - - if (point != CPoint(-1, -1)) - { - // Select clicked item: - CPoint ptTree = point; - pWndTree->ScreenToClient(&ptTree); - - HTREEITEM hTreeItem = pWndTree->HitTest(ptTree); - if (hTreeItem != NULL) - { - pWndTree->SelectItem(hTreeItem); - } - } - - pWndTree->SetFocus(); - theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_RESOURCE, point.x, point.y, this, TRUE); -} - -void CResourceViewBar::OnEditCut() -{ - // TODO: Add your command handler code here - -} - -void CResourceViewBar::OnEditCopy() -{ - // TODO: Add your command handler code here - -} - -void CResourceViewBar::OnEditPaste() -{ - // TODO: Add your command handler code here - -} - -void CResourceViewBar::OnEditClear() -{ - // TODO: Add your command handler code here - -} - -void CResourceViewBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndResourceView.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void CResourceViewBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - m_wndResourceView.SetFocus(); -} - -void CResourceViewBar::OnChangeVisualStyle() -{ - m_ResourceViewImages.DeleteImageList(); - - UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_RESOURCE_VIEW24 : IDB_RESOURCE_VIEW; - - CBitmap bmp; - if (!bmp.LoadBitmap(uiBmpId)) - { - TRACE(_T("Can't load bitmap: %x\n"), uiBmpId); - ASSERT(FALSE); - return; - } - - BITMAP bmpObj; - bmp.GetBitmap(&bmpObj); - - UINT nFlags = ILC_MASK; - - nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; - - m_ResourceViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); - m_ResourceViewImages.Add(&bmp, RGB(255, 0, 255)); - - m_wndResourceView.SetImageList(&m_ResourceViewImages, TVSIL_NORMAL); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ResourceView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ResourceView.h deleted file mode 100644 index 165b2086339ae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/ResourceView.h +++ /dev/null @@ -1,48 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "ClassTreeWnd.h" - -class CResourceViewBar : public CDockablePane -{ -// Construction -public: - CResourceViewBar(); - -// Attributes -protected: - CClassTreeWnd m_wndResourceView; - CImageList m_ResourceViewImages; - -public: - void OnChangeVisualStyle(); - -protected: - void FillResourceView(); - -// Implementation -public: - virtual ~CResourceViewBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnEditCut(); - afx_msg void OnEditCopy(); - afx_msg void OnEditPaste(); - afx_msg void OnEditClear(); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/Snippets.txt deleted file mode 100644 index 74b48fbfac846..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/Snippets.txt +++ /dev/null @@ -1,40 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -EnableUserTools 1 -CMDIChildWndEx::IsReadOnly 2 -CMDIChildWndEx Class 3 -CMDIFrameWndEx::DockPane 4 -CMDIFrameWndEx::DockPaneLeftOf 5 -CMDIFrameWndEx::EnableAutoHidePanes 6 -CMDIFrameWndEx::EnableDocking 7 -CMDIFrameWndEx::EnableMDITabbedGroups etc. 8 -CMDIFrameWndEx::EnablePaneMenu 9 -CMDIFrameWndEx::EnableWindowsDialog 10 -CMDIFrameWndEx::LoadMDIState 11 -CMDIFrameWndEx::MDITabNewGroup 12 -CMDIFrameWndEx::m_bCanCovertControlBarToMDIChild 13 -CMDIFrameWndEx::OnShowMDITabContextMenu 14 -CMDIFrameWndEx::SaveMDIState 15 -CMDIFrameWndEx::ShowPane 16 -CMDIChildWndEx::GetDocumentName 17 -CMDIFrameWndEx::ShowWindowsDialog 18 -CMDIFrameWndEx::TabbedDocumentToControlBar 19 -CMDIFrameWndEx::CreateDocumentWindow 20 -MainFrm.cpp: CMFCKeyMapDialog constructor 21 -PropertiesViewBar.cpp: CMFCPropertyGridFileProperty 22 -OptionsDlg.cpp: CMFCPropertySheetCategoryInfo 23 -MainFrm.cpp: CDockingManager 24 -WatchBar.h: CMFCListCtrl 25 -WatchBar.cpp: CMFCListCtrl 26 -OutputView.cpp: CDockablePane 27 -OutputView.cpp: CDockablePane 28 -MainFrm.h: CMFCDropDownToolBar 29 -MainFrm.cpp: CMFCDropDownToolBar 30 -MainFrm.cpp: CMFCDropDownToolBarButton 31 -StartView.h: CMFCToolBarImages 32 -StartView.cpp: CMFCToolBarImages 33 -MainFrm.cpp: CMFCToolBarsCustomizeDialog::ReplaceButton 34 -MainFrm.cpp: CUserTool 35 -MainFrm.cpp: CMFCToolBarComboBoxButton 36 -MainFrm.cpp: CMFCToolBarComboBoxButton 37 -MainFrm.cpp: CUserToolsManager 38 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/StartView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/StartView.cpp deleted file mode 100644 index a1110666f9d94..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/StartView.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "StartView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CStartView - -#define IDC_START_IMAGE 1 - -IMPLEMENT_DYNCREATE(CStartView, CView) - -CStartView::CStartView() -{ -} - -CStartView::~CStartView() -{ -} - -BEGIN_MESSAGE_MAP(CStartView, CView) - ON_WM_ERASEBKGND() - ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnDisableUpdate) - ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_AS, OnDisableUpdate) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_SETUP, OnDisableUpdate) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_PREVIEW, OnDisableUpdate) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnDisableUpdate) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStartView diagnostics - -#ifdef _DEBUG -void CStartView::AssertValid() const -{ - CView::AssertValid(); -} - -void CStartView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CStartView message handlers - -void CStartView::OnInitialUpdate() -{ - CDocument* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - if (m_Image.GetCount() == 0) - { - // - m_Image.SetImageSize (CSize (32, 32)); - m_Image.Load(IDR_START); - m_Image.SetTransparentColor(RGB(255, 0, 255)); - // - } - - pDoc->SetTitle(_T("Start Page")); -} - -void CStartView::OnDraw(CDC* pDC) -{ - ASSERT_VALID(pDC); - - CRect rectClient; - GetClientRect(rectClient); - - pDC->FillSolidRect(rectClient, RGB(255, 255, 255)); - - m_Image.DrawEx(pDC, rectClient, 0); -} - -BOOL CStartView::OnEraseBkgnd(CDC* /*pDC*/) -{ - return TRUE; -} - -void CStartView::OnDisableUpdate(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(FALSE); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/StartView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/StartView.h deleted file mode 100644 index 947d9d2193b79..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/StartView.h +++ /dev/null @@ -1,45 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CStartView view - -class CStartView : public CView -{ -protected: - CStartView(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CStartView) - -// Attributes -public: - // - CMFCToolBarImages m_Image; - // - -// Overrides -public: - virtual void OnInitialUpdate(); - -protected: - virtual void OnDraw(CDC* pDC); - -// Implementation -protected: - virtual ~CStartView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnDisableUpdate(CCmdUI* pCmdUI); - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoBar.cpp deleted file mode 100644 index 814a41878ac30..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoBar.cpp +++ /dev/null @@ -1,276 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "UndoBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -IMPLEMENT_SERIAL(CUndoBar, CMFCPopupMenuBar, 1) - -const int ID_LIST = 1; - -///////////////////////////////////////////////////////////////////////////// -// CUndoBar - -#pragma warning(disable: 4355) -CUndoBar::CUndoBar() : m_wndList(*this), m_nLabelHeight(0) -#pragma warning(default: 4355) -{ - m_rectLabel.SetRectEmpty(); -} - -CUndoBar::~CUndoBar() -{ -} - -BEGIN_MESSAGE_MAP(CUndoBar, CMFCPopupMenuBar) - ON_WM_SIZE() - ON_WM_CREATE() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CUndoBar message handlers - -void CUndoBar::OnFillBackground(CDC* pDC) -{ - ASSERT_VALID(pDC); - - CRect rectClient; - GetClientRect(rectClient); - - ::FillRect(pDC->GetSafeHdc(), &rectClient, ::GetSysColorBrush(COLOR_3DFACE)); - - // Draw label: - pDC->Draw3dRect(m_rectLabel, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DHILIGHT)); - - CFont* pOldFont = pDC->SelectObject((CFont*) &CMFCMenuBar::GetMenuFont()); - pDC->SetBkMode(TRANSPARENT); - pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT)); - - CRect rectText = m_rectLabel; - rectText.DeflateRect(1, 1); - pDC->DrawText(m_strLabel, rectText, DT_CENTER | DT_VCENTER); - - pDC->SelectObject(pOldFont); -} - -CSize CUndoBar::CalcSize(BOOL /*bVertDock*/) -{ - return CSize(160, 115); -} - -CUndoButton* CUndoBar::GetParentButton() const -{ - // Get parent button: - CUndoButton* pUndoButton = NULL; - - CUndoMenu* pParentMenu = DYNAMIC_DOWNCAST(CUndoMenu, GetParent()); - if (pParentMenu != NULL) - { - pUndoButton = DYNAMIC_DOWNCAST(CUndoButton, pParentMenu->GetParentButton()); - } - - return pUndoButton; -} - -void CUndoBar::OnSize(UINT nType, int cx, int cy) -{ - const int nMargin = 5; - - CMFCPopupMenuBar::OnSize(nType, cx, cy); - - CRect rectClient; - GetClientRect(rectClient); - - rectClient.DeflateRect(nMargin, nMargin); - - m_rectLabel = rectClient; - m_rectLabel.top = m_rectLabel.bottom - m_nLabelHeight; - - CRect rectList = rectClient; - rectList.bottom = m_rectLabel.top - nMargin; - - m_wndList.MoveWindow(rectList); -} - -int CUndoBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMFCPopupMenuBar::OnCreate(lpCreateStruct) == -1) - return -1; - - CFont* pMenuFont = (CFont*) &CMFCMenuBar::GetMenuFont(); - - // Set label height: - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(pMenuFont); - - TEXTMETRIC tm; - dc.GetTextMetrics(&tm); - - m_nLabelHeight = tm.tmHeight + 2; - - dc.SelectObject(pOldFont); - - CRect rectDummy(0, 0, 0, 0); - m_wndList.Create(WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_VSCROLL | LBS_MULTIPLESEL, rectDummy, this, ID_LIST); - m_wndList.ModifyStyleEx(0, WS_EX_CLIENTEDGE); - - m_wndList.SetFont(pMenuFont); - - CUndoButton* pUndoButton = GetParentButton(); - ASSERT_VALID(pUndoButton); - - for (POSITION pos = pUndoButton->m_lstActions.GetHeadPosition(); pos != NULL;) - { - m_wndList.AddString(pUndoButton->m_lstActions.GetNext(pos)); - } - - return 0; -} - -void CUndoBar::DoUndo() -{ - CUndoButton* pUndoButton = GetParentButton(); - ASSERT_VALID(pUndoButton); - - pUndoButton->m_nSelNum = m_wndList.GetSelCount() + 1; - - CMDIChildWnd* pChildFrame = ((CMDIFrameWndEx*)GetTopLevelFrame())->MDIGetActive(); - if (pChildFrame) - { - CEditView* pView = DYNAMIC_DOWNCAST(CEditView, pChildFrame->GetActiveView()); - if (pView != NULL) - { - //pView->OnEditUndo(); TODO - } - else - { - ASSERT(FALSE); - } - } - else - { - ASSERT(FALSE); - } - - GetParent()->PostMessage(WM_CLOSE); -} - -void CUndoBar::SetLabel(const CString& strLabel) -{ - m_strLabel = strLabel; - - if (GetSafeHwnd() != NULL) - { - InvalidateRect(m_rectLabel); - UpdateWindow(); - } -} - -////////////////////////////////////////////////////////////////////////////// -// CUndoButton - -IMPLEMENT_SERIAL(CUndoButton, CMFCToolBarMenuButton, 1) - -CMFCPopupMenu* CUndoButton::CreatePopupMenu() -{ - if (CMFCToolBar::IsCustomizeMode() ||(m_nStyle & TBBS_DISABLED)) - { - return NULL; - } - - CUndoMenu* pPopupMenu = new CUndoMenu; - - ResetSelNum(); - -#if 0 - CMDIChildWnd* pChildFrame = ((CMDIFrameWndEx*)::AfxGetMainWnd())->MDIGetActive(); - if (pChildFrame) - { - CVisualStudioDemoView* pView = (CVisualStudioDemoView*)pChildFrame->GetActiveView(); - - if (pView && pView->IsKindOf(RUNTIME_CLASS(CVisualStudioDemoView))) - { - CDWordArray dwaUAT; - - // Setup undo actions: - switch (m_nID) - { - case ID_EDIT_UNDO: - pView->GetUndoActions(m_lstActions); - - break; - case ID_EDIT_REDO: - pView->GetRedoActions(m_lstActions); - - break; - default: - break; - } - } - else - { - ASSERT(FALSE); - m_lstActions.RemoveAll(); - } - } - else - { - ASSERT(FALSE); - m_lstActions.RemoveAll(); - } -#endif - - return pPopupMenu; -} - -////////////////////////////////////////////////////////////////////////////// -// CUndoMenu - -IMPLEMENT_SERIAL(CUndoMenu, CMFCPopupMenu, 1) - -BEGIN_MESSAGE_MAP(CUndoMenu, CMFCPopupMenu) - ON_WM_CREATE() -END_MESSAGE_MAP() - -int CUndoMenu::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMiniFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - DWORD toolbarStyle = AFX_DEFAULT_TOOLBAR_STYLE; - if (m_AnimationType != NO_ANIMATION && !CMFCToolBar::IsCustomizeMode()) - { - toolbarStyle &= ~WS_VISIBLE; - } - - if (!m_wndUndoBar.Create(this, toolbarStyle | CBRS_TOOLTIPS | CBRS_FLYBY, 1)) - { - TRACE(_T("Can't create popup menu bar\n")); - return -1; - } - - CWnd* pWndParent = GetParent(); - ASSERT_VALID(pWndParent); - - m_wndUndoBar.SetOwner(pWndParent); - m_wndUndoBar.SetPaneStyle(m_wndUndoBar.GetPaneStyle() | CBRS_TOOLTIPS); - - ActivatePopupMenu(GetTopLevelFrame(), this); - RecalcLayout(); - - return 0; -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoBar.h deleted file mode 100644 index 823589d5f9820..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoBar.h +++ /dev/null @@ -1,127 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#include "UndoListBox.h" - -class CUndoButton; - -///////////////////////////////////////////////////////////////////////////// -// CUndoBar window - -class CUndoBar : public CMFCPopupMenuBar -{ - DECLARE_SERIAL(CUndoBar) - -// Construction -public: - CUndoBar(); - -// Attributes -protected: - CUndoListBox m_wndList; - CRect m_rectLabel; - int m_nLabelHeight; - CString m_strLabel; - -// Operations -public: - void DoUndo(); - void SetLabel(const CString& strLabel); - -// Overrides - virtual void OnFillBackground(CDC* pDC); - virtual CSize CalcSize(BOOL bVertDock); - -// Implementation -public: - virtual ~CUndoBar(); - -protected: - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - - DECLARE_MESSAGE_MAP() - - CUndoButton* GetParentButton() const; -}; - -////////////////////////////////////////////////////////////////////////////// -// CUndoMenu - -class CUndoMenu : public CMFCPopupMenu -{ - DECLARE_SERIAL(CUndoMenu) - - virtual CMFCPopupMenuBar* GetMenuBar() - { - return &m_wndUndoBar; - } - - CUndoBar m_wndUndoBar; - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - - DECLARE_MESSAGE_MAP() -}; - -////////////////////////////////////////////////////////////////////////////// -// CUndoButton - -class CUndoButton : public CMFCToolBarMenuButton -{ - friend class CUndoBar; - - DECLARE_SERIAL(CUndoButton) - -public: - CUndoButton() - { - } - - CUndoButton(UINT uiCmdID, LPCTSTR lpszText) : CMFCToolBarMenuButton(uiCmdID, NULL, GetCmdMgr()->GetCmdImage(uiCmdID, FALSE), lpszText) - { - m_nSelNum = 0; - } - - CStringList m_lstActions; - int m_nSelNum; - - int GetSelNum() - { - return m_nSelNum; - } - - void ResetSelNum() - { - m_nSelNum = 0; - } - -protected: - virtual CMFCPopupMenu* CreatePopupMenu(); - - virtual BOOL IsEmptyMenuAllowed() const - { - return TRUE; - } - - virtual void OnChangeParentWnd(CWnd* pWndParent) - { - CMFCToolBarMenuButton::OnChangeParentWnd(pWndParent); - m_bDrawDownArrow = TRUE; - } - - virtual BOOL IsExclusive() const - { - return TRUE; - } -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoListBox.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoListBox.cpp deleted file mode 100644 index 19100ce038646..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoListBox.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "UndoListBox.h" -#include "UndoBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CUndoListBox - -CUndoListBox::CUndoListBox(CUndoBar& bar) : m_Bar(bar) -{ -} - -CUndoListBox::~CUndoListBox() -{ -} - -BEGIN_MESSAGE_MAP(CUndoListBox, CListBox) - ON_WM_MOUSEMOVE() - ON_WM_LBUTTONUP() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CUndoListBox message handlers - -void CUndoListBox::OnLButtonUp(UINT nFlags, CPoint point) -{ - BOOL bOutside; - ItemFromPoint(point, bOutside); - - if (!bOutside) - { - m_Bar.DoUndo(); - } - - if (IsWindow(GetSafeHwnd())) - { - CListBox::OnLButtonUp(nFlags, point); - } -} - -void CUndoListBox::OnMouseMove(UINT nFlags, CPoint point) -{ - CListBox::OnMouseMove(nFlags, point); - - BOOL bOutside; - int iItem = ItemFromPoint(point, bOutside); - - if (!bOutside) - { - SelItemRange(FALSE, iItem + 1, GetCount() - 1); - - if (iItem == 0) - { - SetSel(0); - } - else - { - SelItemRange(TRUE, 0, iItem); - } - - CString strLabel; - strLabel.Format(_T("Undo %d Actions"), iItem + 1); - - m_Bar.SetLabel(strLabel); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoListBox.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoListBox.h deleted file mode 100644 index e6bfa9d3af76c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/UndoListBox.h +++ /dev/null @@ -1,36 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CUndoBar; - -///////////////////////////////////////////////////////////////////////////// -// CUndoListBox window - -class CUndoListBox : public CListBox -{ -// Construction -public: - CUndoListBox(CUndoBar& bar); - -// Attributes -protected: - CUndoBar& m_Bar; - -// Implementation -public: - virtual ~CUndoListBox(); - -protected: - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.cpp deleted file mode 100644 index 124aef5d27d29..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.cpp +++ /dev/null @@ -1,280 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" - -#include "MainFrm.h" -#include "ChildFrm.h" -#include "VisualStudioDemoDoc.h" -#include "VisualStudioDemoView.h" -#include "StartView.h" -#include "AppLookDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CVisualStudioDemoApp - -BEGIN_MESSAGE_MAP(CVisualStudioDemoApp, CWinAppEx) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(ID_HELP_SHOW_START, OnHelpShowStart) - ON_COMMAND(ID_VIEW_APP_LOOK, OnViewAppLook) - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinAppEx::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinAppEx::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinAppEx::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CVisualStudioDemoApp construction - -CVisualStudioDemoApp::CVisualStudioDemoApp() -{ - m_pStartDocTemplate = NULL; - m_pDocTemplateCpp = NULL; - - m_bHiColorIcons = FALSE; -} - -CVisualStudioDemoApp::~CVisualStudioDemoApp() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CVisualStudioDemoApp object - -CVisualStudioDemoApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CVisualStudioDemoApp initialization - -BOOL CVisualStudioDemoApp::InitInstance() -{ - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - SetRegistryKey(_T("Microsoft\\MFC\\Samples")); - - LoadStdProfileSettings(); // Load standard INI file options(including MRU) - - SetRegistryBase(_T("Settings")); - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - InitContextMenuManager(); - InitKeyboardManager(); - InitTooltipManager(); - - // - EnableUserTools(ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10, RUNTIME_CLASS(CUserTool), IDR_MENU_ARGS, IDR_MENU_DIRS); - // - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - m_pDocTemplateCpp = new CMultiDocTemplate(IDR_DEVTYPE_CPP, RUNTIME_CLASS(CVisualStudioDemoDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CVisualStudioDemoView)); - AddDocTemplate(m_pDocTemplateCpp); - - m_pStartDocTemplate = new CMultiDocTemplate(IDR_DEVTYPE0, RUNTIME_CLASS(CVisualStudioDemoDoc), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CStartView)); - AddDocTemplate(m_pStartDocTemplate); - - // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame; - - EnableLoadWindowPlacement(FALSE); - - if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) - return FALSE; - m_pMainWnd = pMainFrame; - - // - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) - { - if (!pMainFrame->LoadMDIState(GetRegSectionPath())) - { - m_pStartDocTemplate->OpenDocumentFile(NULL); - } - } - else - { - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - } - // - - m_pMainWnd->DragAcceptFiles(); - - // The main window has been initialized, so show and update it. - if (!ReloadWindowPlacement(pMainFrame)) - { - pMainFrame->ShowWindow(m_nCmdShow); - pMainFrame->UpdateWindow(); - } - - CAppLookDlg dlg(TRUE, m_pMainWnd); - dlg.DoModal(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CVisualStudioDemoApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// Customization load/save methods - -void CVisualStudioDemoApp::PreLoadState() -{ - GetContextMenuManager()->AddMenu(_T("Edit Context menu"), IDR_CONTEXT_MENU); - GetContextMenuManager()->AddMenu(_T("Resource"), IDR_POPUP_RESOURCE); - GetContextMenuManager()->AddMenu(_T("Solution Explorer"), IDR_POPUP_SOLUTION); -} - -void CVisualStudioDemoApp::LoadCustomState() -{ -} - -void CVisualStudioDemoApp::SaveCustomState() -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CVisualStudioDemoApp message handlers - -int CVisualStudioDemoApp::ExitInstance() -{ - return CWinAppEx::ExitInstance(); -} - -void CVisualStudioDemoApp::OnHelpShowStart() -{ - ASSERT_VALID(m_pStartDocTemplate); - - POSITION pos = m_pStartDocTemplate->GetFirstDocPosition(); - if (pos == NULL) - { - m_pStartDocTemplate->OpenDocumentFile(NULL); - return; - } - - CDocument* pDoc = m_pStartDocTemplate->GetNextDoc(pos); - ASSERT_VALID(pDoc); - - pos = pDoc->GetFirstViewPosition(); - ASSERT(pos != NULL); - - CView* pView = pDoc->GetNextView(pos); - ASSERT_VALID(pView); - - CFrameWnd* pFrame = pView->GetParentFrame(); - ASSERT_VALID(pFrame); - - CMainFrame* pMainFrame = (CMainFrame*) AfxGetMainWnd(); - ASSERT_VALID(pMainFrame); - - ::SendMessage(pMainFrame->m_hWndMDIClient, WM_MDIACTIVATE, (WPARAM) pFrame->GetSafeHwnd(), 0); -} - -void CVisualStudioDemoApp::OnViewAppLook() -{ - CAppLookDlg dlg(FALSE, m_pMainWnd); - dlg.DoModal(); -} - -BOOL CVisualStudioDemoApp::SaveAllModified() -{ - if (!CWinAppEx::SaveAllModified()) - { - return FALSE; - } - - CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, m_pMainWnd); - if (pMainFrame != NULL) - { - pMainFrame->SaveMDIState(GetRegSectionPath()); - } - - return TRUE; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.h deleted file mode 100644 index 24c71602360a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.h +++ /dev/null @@ -1,52 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -#ifndef __AFXWIN_H__ -#error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CVisualStudioDemoApp: -// See VisualStudioDemo.cpp for the implementation of this class -// - -class CVisualStudioDemoApp : public CWinAppEx -{ -public: - CVisualStudioDemoApp(); - virtual ~CVisualStudioDemoApp(); - - BOOL m_bHiColorIcons; - - virtual void PreLoadState(); - virtual void LoadCustomState(); - virtual void SaveCustomState(); - - CMultiDocTemplate* m_pDocTemplateCpp; - CMultiDocTemplate* m_pStartDocTemplate; - - // Overrides -public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - virtual BOOL SaveAllModified(); - - // Implementation - afx_msg void OnAppAbout(); - afx_msg void OnHelpShowStart(); - afx_msg void OnViewAppLook(); - - DECLARE_MESSAGE_MAP() -}; - -extern CVisualStudioDemoApp theApp; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.rc b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.rc deleted file mode 100644 index bb19b4fe49437..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemo.rc +++ /dev/null @@ -1,1489 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\VisualStudioDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#include ""afxprint.rc"" // printing/print preview resources\r\n" - "#ifndef _AFXDLL\r\n" - "#include ""afxribbon.rc"" // ribbon and control bar resources\r\n" - "#endif\r\n" - "#endif\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// PNG -// - -IDR_START PNG "res\\start.png" - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\VisualStudioDemo.ico" -IDR_DEVTYPE0 ICON "res\\VisualStudioDemoDoc.ico" -IDI_CLASS_VIEW ICON "res\\class_view.ico" -IDI_RES_VIEW ICON "res\\res_view.ico" -IDI_FILE_VIEW ICON "res\\file_view.ico" -IDI_OUTPUT_BAR ICON "res\\output_bar.ico" -IDI_WATCH_BAR ICON "res\\watch_bar.ico" -IDI_DYNAMICHELP_VIEW ICON "res\\dynamichelp.ico" -IDI_PROPERTIES_BAR ICON "res\\properti.ico" -IDI_CLASS_VIEW_HC ICON "res\\class_view_hc.ico" -IDI_FILE_VIEW_HC ICON "res\\file_view_hc.ico" -IDI_RES_VIEW_HC ICON "res\\res_view_hc.ico" -IDI_PROP_BAR_HC ICON "res\\prop_bar_hc.ico" -IDI_DYNAMICHELP_VIEW_HC ICON "res\\dynamichelp_hc.ico" -IDI_WATCH_BAR_HC ICON "res\\watch_bar_hc.ico" -IDI_OUTPUT_BAR_HC ICON "res\\output_bar_hc.ico" -IDR_DEVTYPE_CPP ICON "res\\cpp.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "A", ID_EDIT_SELECT_ALL, VIRTKEY, CONTROL, NOINVERT - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT - "G", ID_EDIT_GOTO_LINE, VIRTKEY, CONTROL, NOINVERT - "H", ID_EDIT_REPLACE, VIRTKEY, CONTROL, NOINVERT - "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT - "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT - "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT - "T", ID_EDIT_SHOWHINT, VIRTKEY, CONTROL, NOINVERT - "T", ID_EDIT_LISTMEMBERS, VIRTKEY, CONTROL, ALT, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_F2, ID_EDIT_NEXTBOOKMARK, VIRTKEY, NOINVERT - VK_F2, ID_EDIT_TOGGLEBOOKMARK, VIRTKEY, CONTROL, NOINVERT - VK_F2, ID_EDIT_PREVIOUSBOOKMARK, VIRTKEY, SHIFT, NOINVERT - VK_F3, ID_EDIT_FINDNEXT, VIRTKEY, NOINVERT - VK_F3, ID_EDIT_NEXT_WORD, VIRTKEY, CONTROL, NOINVERT - VK_F3, ID_EDIT_FINDPREV, VIRTKEY, SHIFT, NOINVERT - VK_F5, ID_DUMMY_GO, VIRTKEY, NOINVERT - VK_F5, ID_DUMMY_EXECUTE, VIRTKEY, CONTROL, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_F7, ID_DUMMY_BUILD, VIRTKEY, NOINVERT - VK_F7, ID_DUMMY_COMPILE, VIRTKEY, CONTROL, NOINVERT - VK_F9, ID_EDIT_TOGGLEBREAKPOINT, VIRTKEY, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Y", ID_EDIT_REDO, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "FileDescription", "VisualStudioDemo MFC Application" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "VisualStudioDemo" - VALUE "LegalCopyright", "Copyright (C) 2001" - VALUE "OriginalFilename", "VisualStudioDemo.EXE" - VALUE "ProductName", "VisualStudioDemo Application" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 34, 22, 217, 55 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About VisualStudioDemo" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "VisualStudioDemo Application",IDC_STATIC,40,10,119,8 - LTEXT " 2007 - 2008 Microsoft Corporation. All rights reserved.", - IDC_STATIC,40,25,122,19 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_FINDDIALOG DIALOGEX 0, 0, 270, 82 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTEXTHELP -CAPTION "Find" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "Fi&nd what:",IDC_STATIC,7,9,41,8 - COMBOBOX IDC_FINDDIALOG_FINDCOMBO,48,7,145,12,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON ">",IDC_FINDDIALOG_REGULARBUTTON,197,7,10,12,BS_CENTER - CONTROL "Match &whole word only",IDC_FINDDIALOG_MATCHWHOLEWORDONLYCHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,28,107,10 - CONTROL "Match &case",IDC_FINDDIALOG_MATCHCASECHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,40,97,10 - CONTROL "Regular &expression",IDC_FINDDIALOG_REGULAREXPRESSIONCHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,52,102,10 - CONTROL "Search &all open documents",IDC_FINDDIALOG_SEARCHALLOPENDOCUMENTSCHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,64,112,10 - GROUPBOX "Direction",IDC_STATIC,119,34,74,35 - CONTROL "&Up",IDC_FINDDIALOG_UPRADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP,124,44,50,10 - CONTROL "&Down",IDC_FINDDIALOG_DOWNRADIO,"Button",BS_AUTORADIOBUTTON,124,55,55,10 - DEFPUSHBUTTON "&Find Next",IDOK,213,7,50,14 - PUSHBUTTON "&Mark All",IDC_FINDDIALOG_MARKALLBUTTON,213,26,50,14 - PUSHBUTTON "Cancel",IDCANCEL,213,45,50,14 -END - -IDD_OPTIONSPAGE1 DIALOG 0, 0, 235, 182 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "General" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Settings",IDC_STATIC,7,7,26,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,43,11,185,1 - CONTROL "&Tabbed Documents",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,22,22,79,10 - CONTROL "&MDI Environment",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,22,34,71,10 - PUSHBUTTON "Reset Window &Layout",IDC_BUTTON1,22,50,89,14 - LTEXT "At start&up:",IDC_STATIC,130,22,33,8 - COMBOBOX IDC_COMBO1,130,33,98,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "Show status &bar",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,71,67,10 - LTEXT "Display",IDC_STATIC,22,101,24,8 - EDITTEXT IDC_EDIT2,51,99,23,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "items in Window menu",IDC_STATIC,81,101,72,8 - LTEXT "Display",IDC_STATIC,22,118,24,8 - EDITTEXT IDC_EDIT3,51,115,23,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "items in most recently used lists",IDC_STATIC,81,118,98,8 - CONTROL "Animate environment tools",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,82,96,10 - LTEXT "Docked Tool Window Behavior",IDC_STATIC,7,141,100,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,116,145,112,1 - CONTROL "Close button affects active tab only",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,153,127,10 - CONTROL "Auto Hide button affects active tab only",IDC_CHECK4, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,165,141,10 -END - -IDD_OPTIONSPAGE2 DIALOG 0, 0, 235, 182 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Documents" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Settings",IDC_STATIC,7,7,26,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,43,11,185,1 - CONTROL "Re-use current document window if saved",IDC_CHECK1, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,21,149,10 - CONTROL "Detect if file is changed outside the environment",IDC_CHECK5, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,35,167,10 - CONTROL "Auto-load changes",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,49,49,75,10 - CONTROL "Allow editing read-only files",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,63,100,10 - CONTROL "Open file using directory of currently active document",IDC_CHECK4, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,77,183,10 - LTEXT "Find and Replace",IDC_STATIC,7,98,57,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,70,102,158,1 - CONTROL "Show message boxes",IDC_CHECK6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,112,85,10 - CONTROL "Initialize Find Text from editor",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,125,107,10 -END - -IDD_OPTIONSPAGE3 DIALOG 0, 0, 235, 182 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "General" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Source Control ",IDC_STATIC,7,7,50,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,60,11,168,1 - LTEXT "Use",IDC_STATIC,42,28,14,8 - COMBOBOX IDC_COMBO1,61,26,91,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "settings",IDC_STATIC,158,28,25,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,52,221,1 - CONTROL "Get everything when a solution is opened",IDC_CHECK1, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,42,62,146,10 - CONTROL "Check in everything when closing a solution ",IDC_CHECK5, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,42,75,156,10 - CONTROL "Display silent check out command in menus",IDC_CHECK8, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,42,88,153,10 - CONTROL "Display silent check in command in menus",IDC_CHECK9, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,42,101,149,10 - CONTROL "Keep items checked out when checking in",IDC_CHECK10, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,42,114,151,10 -END - -IDD_OPTIONSPAGE4 DIALOG 0, 0, 235, 182 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "SCC Provider" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Source Control ",IDC_STATIC,7,7,50,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,60,11,168,1 - LTEXT "Use",IDC_STATIC,42,28,14,8 - COMBOBOX IDC_COMBO1,61,26,91,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "settings",IDC_STATIC,158,28,25,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,52,221,1 - LTEXT "Login ID:",IDC_STATIC,42,63,30,8 - EDITTEXT IDC_EDIT1,42,74,94,14,ES_AUTOHSCROLL - CONTROL "Perform background status updates",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,42,92,128,10 -END - -IDD_OPTIONSPAGE5 DIALOG 0, 0, 235, 182 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "General" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Settings",IDC_STATIC,7,7,26,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,37,11,191,1 - CONTROL "Go to selection anchor after escape",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,25,129,10 - CONTROL "Go to selection anchor after escape",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,37,129,10 - CONTROL "Include insertion point movements in Undo list",IDC_CHECK8, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,49,159,10 - CONTROL "Automatic delimiter highlighting",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,61,112,10 - LTEXT "Display",IDC_STATIC,7,84,24,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,38,89,190,1 - CONTROL "Selection margin",IDC_CHECK10,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,100,68,10 - CONTROL "Indicator margin",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,113,66,10 - CONTROL "Vertical scroll bar",IDC_CHECK12,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,126,69,10 - CONTROL "Horizontal scroll bar",IDC_CHECK13,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,139,77,10 -END - -IDD_OPTIONSPAGE6 DIALOG 0, 0, 235, 182 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Tabs" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Indenting",IDC_STATIC,7,7,26,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,37,11,191,1 - CONTROL "None",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,33,26,33,10 - CONTROL "Block",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,33,40,34,10 - CONTROL "Smart",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,33,54,34,10 - LTEXT "Tabs",IDC_STATIC,7,75,17,8 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,37,79,191,1 - LTEXT "Tab size:",IDC_STATIC,33,94,30,8 - EDITTEXT IDC_EDIT1,77,92,24,14,ES_AUTOHSCROLL - LTEXT "Indent size:",IDC_STATIC,33,111,33,8 - EDITTEXT IDC_EDIT4,77,109,24,14,ES_AUTOHSCROLL - CONTROL "Insert spaces",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,33,138,58,10 - CONTROL "Keep tabs",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON,33,152,48,10 -END - -IDD_APP_LOOK DIALOGEX 0, 0, 292, 225 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Application Look" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "Welcome to MFC! The library supports various application looks such as Microsoft Office 2000/XP/2003/2007, Visual Studio 97/.NET/2005 and more.",IDC_STATIC,7,12,278,19 - LTEXT "Please choose the preferred look and click OK to continue.",IDC_STATIC,17,34,214,8 - LTEXT "&Visual Manager:",IDC_STATIC,19,51,52,8 - COMBOBOX IDC_APP_LOOK,112,50,140,199,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "&Style (Office 2007 only):",IDC_STATIC,19,76,76,8 - COMBOBOX IDC_STYLE,112,75,72,165,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Show ""Close"" Button on the &Active Tab",IDC_ACTIVETAB_CLOSE_BUTTON, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,99,141,10 - CONTROL "One&Note-style MDI tabs",IDC_ONENOTE_TABS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,114,97,10 - CONTROL "Docking Tab &Colors",IDC_DOCK_TAB_COLORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,129,79,10 - CONTROL "&3D Rounded Docking Tabs and Auto Hide Buttons (VS 2005 only)",IDC_ROUNDED_TABS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,144,225,10 - CONTROL "Show Extended &Tooltips",IDC_CUSTOM_TOOLTIPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,159,93,10 - LTEXT "Note: you may change the application look in ""View | Application Look..."" dialog.",IDC_STATIC,17,179,268,8 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,194,229,1 - CONTROL "S&how this dialog at startup",IDC_SHOW_AT_STARTUP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,205,99,10 - DEFPUSHBUTTON "OK",IDOK,127,204,50,14 - PUSHBUTTON "Cancel",IDCANCEL,181,204,50,14 - PUSHBUTTON "Apply",IDC_APPLY,235,204,50,14 -END - -IDD_GOTO_LINE DIALOG 0, 0, 186, 46 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Go To" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "&Enter line number:",IDC_STATIC,7,7,58,8 - EDITTEXT IDC_LINE,7,19,107,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "&Go To",IDOK,129,7,50,14 - PUSHBUTTON "Close",IDCANCEL,129,24,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_DEVTYPE0 MENU -BEGIN - POPUP "&File" - BEGIN - POPUP "&New" - BEGIN - MENUITEM "&Project...", ID_FILE_NEW_PROJECT - MENUITEM "&File...", ID_FILE_NEW - MENUITEM "&Blank Solution...", ID_FILE_NEW_BLANK_SOLUTION - END - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM SEPARATOR - MENUITEM "&Op&en Solution...", ID_FILE_OPEN_SOLUTION - MENUITEM "&Close Solu&tion...", ID_FILE_CLOSE_SOLUTION - MENUITEM SEPARATOR - MENUITEM "Save A&ll", ID_FILE_SAVE_ALL - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM "&Redo\tCtrl+Y", ID_EDIT_REDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "Select &All", ID_EDIT_SELECT_ALL - MENUITEM SEPARATOR - MENUITEM "&Find...", ID_EDIT_FIND - MENUITEM "R&eplace...", ID_EDIT_REPLACE - END - POPUP "&View" - BEGIN - MENUITEM "F&ull Screen", ID_VIEW_FULLSCREEN - MENUITEM SEPARATOR - MENUITEM "&Solution Explorer", ID_VIEW_FILE - MENUITEM "&Class View", ID_VIEW_CLASS - MENUITEM "R&esource View", ID_VIEW_RESOURCE - MENUITEM "&Properties View", ID_VIEW_PROPERTIES - MENUITEM "&Output", ID_VIEW_OUTPUT - MENUITEM "W&atch", ID_VIEW_WATCH - MENUITEM SEPARATOR - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM SEPARATOR - MENUITEM "&Refresh", ID_VIEW_REFRESH - MENUITEM "&Application Look...", ID_VIEW_APP_LOOK - END - POPUP "&Build" - BEGIN - MENUITEM "&Compile", ID_DUMMY_COMPILE - MENUITEM "&Build", ID_DUMMY_BUILD - MENUITEM "Rebuild &All", ID_DUMMY_REBUILD_ALL - MENUITEM "C&lean", ID_DUMMY_CLEAN - MENUITEM SEPARATOR - MENUITEM "&Go", ID_DUMMY_GO - MENUITEM "&Execute", ID_DUMMY_EXECUTE - MENUITEM SEPARATOR - MENUITEM "&Select Active Configuration", ID_DUMMY_SELECT_ACTIVE_CONFIGURATION - END - POPUP "&Tools" - BEGIN - MENUITEM "Debug &Process...", ID_TOOLS_DEBUG_PROCESSES - MENUITEM "Connect to &Database...", ID_TOOLS_CONNECT_TO_DATABASE - MENUITEM SEPARATOR - MENUITEM "&Macro...", ID_TOOLS_MACRO - MENUITEM SEPARATOR - MENUITEM "", ID_TOOLS_ENTRY - MENUITEM SEPARATOR - MENUITEM "&Options...", ID_TOOLS_OPTIONS - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - MENUITEM "Close &All Documents...", ID_WINDOW_CLOSE_ALL - END - POPUP "&Help" - BEGIN - MENUITEM "&Dynamic Help", ID_VIEW_DYNAMICHELP - MENUITEM "&Keyboard Map...", ID_HELP_KEYBOARDMAP - MENUITEM "&Show Start Page", ID_HELP_SHOW_START - MENUITEM "Microsoft on the &Web", ID_HELP_WEB - MENUITEM SEPARATOR - MENUITEM "&About VisualStudioDemo...", ID_APP_ABOUT - END -END - -IDR_DEVTYPE_CPP MENU -BEGIN - POPUP "&File" - BEGIN - POPUP "&New" - BEGIN - MENUITEM "&Project...", ID_FILE_NEW_PROJECT - MENUITEM "&File...", ID_FILE_NEW - MENUITEM "&Blank Solution...", ID_FILE_NEW_BLANK_SOLUTION - END - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM SEPARATOR - MENUITEM "&Op&en Solution...", ID_FILE_OPEN_SOLUTION - MENUITEM "&Close Solu&tion...", ID_FILE_CLOSE_SOLUTION - MENUITEM SEPARATOR - MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE - MENUITEM "Save &As...", ID_FILE_SAVE_AS - MENUITEM "Save A&ll", ID_FILE_SAVE_ALL - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM "&Redo\tCtrl+Y", ID_EDIT_REDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "Select &All", ID_EDIT_SELECT_ALL - MENUITEM SEPARATOR - MENUITEM "&Find...", ID_EDIT_FIND - MENUITEM "R&eplace...", ID_EDIT_REPLACE - END - POPUP "&View" - BEGIN - MENUITEM "F&ull Screen", ID_VIEW_FULLSCREEN - MENUITEM SEPARATOR - MENUITEM "&Solution Explorer", ID_VIEW_FILE - MENUITEM "&Class View", ID_VIEW_CLASS - MENUITEM "R&esource View", ID_VIEW_RESOURCE - MENUITEM "&Properties View", ID_VIEW_PROPERTIES - MENUITEM "&Output", ID_VIEW_OUTPUT - MENUITEM "W&atch", ID_VIEW_WATCH - MENUITEM SEPARATOR - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "Status &Bar", ID_VIEW_STATUS_BAR - MENUITEM SEPARATOR - MENUITEM "&Refresh", ID_VIEW_REFRESH - MENUITEM "&Application Look...", ID_VIEW_APP_LOOK - END - POPUP "&Build" - BEGIN - MENUITEM "&Compile", ID_DUMMY_COMPILE - MENUITEM "&Build", ID_DUMMY_BUILD - MENUITEM "Rebuild &All", ID_DUMMY_REBUILD_ALL - MENUITEM "C&lean", ID_DUMMY_CLEAN - MENUITEM SEPARATOR - MENUITEM "&Go", ID_DUMMY_GO - MENUITEM "&Execute", ID_DUMMY_EXECUTE - MENUITEM SEPARATOR - MENUITEM "&Select Active Configuration", ID_DUMMY_SELECT_ACTIVE_CONFIGURATION - END - POPUP "&Tools" - BEGIN - MENUITEM "Debug &Process...", ID_TOOLS_DEBUG_PROCESSES - MENUITEM "Connect to &Database...", ID_TOOLS_CONNECT_TO_DATABASE - MENUITEM SEPARATOR - MENUITEM "&Macro...", ID_TOOLS_MACRO - MENUITEM SEPARATOR - MENUITEM "", ID_TOOLS_ENTRY - MENUITEM SEPARATOR - MENUITEM "&Options...", ID_TOOLS_OPTIONS - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END - POPUP "&Window" - BEGIN - MENUITEM "&New Window", ID_WINDOW_NEW - MENUITEM "Close &All Documents...", ID_WINDOW_CLOSE_ALL - END - POPUP "&Help" - BEGIN - MENUITEM "&Dynamic Help", ID_VIEW_DYNAMICHELP - MENUITEM "&Keyboard Map...", ID_HELP_KEYBOARDMAP - MENUITEM "&Show Start Page", ID_HELP_SHOW_START - MENUITEM "Microsoft on the &Web", ID_HELP_WEB - MENUITEM SEPARATOR - MENUITEM "&About VisualStudioDemo...", ID_APP_ABOUT - END -END - -IDR_CONTEXT_MENU MENU -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_MAINFRAME MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New\tCtrl+N", ID_FILE_NEW - MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN - MENUITEM SEPARATOR - MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP - MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&View" - BEGIN - MENUITEM "&Solution Explorer", ID_VIEW_FILE - MENUITEM "&Class View", ID_VIEW_CLASS - MENUITEM "R&esource View", ID_VIEW_RESOURCE - MENUITEM "&Properties View", ID_VIEW_PROPERTIES - MENUITEM "&Output", ID_VIEW_OUTPUT - MENUITEM "W&atch", ID_VIEW_WATCH - MENUITEM SEPARATOR - POPUP "&Toolbars" - BEGIN - MENUITEM "", ID_VIEW_TOOLBARS - END - MENUITEM "Status &Bar", ID_VIEW_STATUS_BAR - MENUITEM "&Application Look...", ID_VIEW_APP_LOOK - END - POPUP "&Tools" - BEGIN - MENUITEM "&Macro...", ID_TOOLS_MACRO - MENUITEM "&Options...", ID_TOOLS_OPTIONS - MENUITEM "", ID_TOOLS_ENTRY - END - POPUP "&Help" - BEGIN - MENUITEM "&Dynamic Help", ID_VIEW_DYNAMICHELP - MENUITEM "&Keyboard Map...", ID_HELP_KEYBOARDMAP - MENUITEM "&Show Start Page", ID_HELP_SHOW_START - MENUITEM "Microsoft on the &Web", ID_HELP_WEB - MENUITEM SEPARATOR - MENUITEM "&About VisualStudioDemo...", ID_APP_ABOUT - END -END - -IDR_MENU_ARGS MENU -BEGIN - POPUP "_DUMMY_" - BEGIN - MENUITEM "Item 1", ID_MENU_ITEM1 - MENUITEM "Item 2", ID_MENU_ITEM2 - MENUITEM "Item 3", ID_MENU_ITEM3 - END -END - -IDR_MENU_DIRS MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "Dir &1", ID_MENU_DIR1 - MENUITEM "Dir &2", ID_MENU_DIR2 - MENUITEM "Dir &3", ID_MENU_DIR3 - END -END - -IDR_POPUP_OUTPUT MENU -BEGIN - POPUP "Popup" - BEGIN - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Clear", ID_EDIT_CLEAR - MENUITEM SEPARATOR - MENUITEM "&Go To Error/Tag", ID_OUTPUT_GOTO_ERROR - MENUITEM SEPARATOR - MENUITEM "&Hide", ID_VIEW_OUTPUT - END -END - -IDR_POPUP_TOOLBAR MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "&Standard", ID_VIEW_TOOLBAR - MENUITEM "&Build", ID_VIEW_BUILD_TOOLBAR - MENUITEM "&Edit", ID_VIEW_EDIT_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "", ID_VIEW_USER_TOOLBAR1 - MENUITEM "", ID_VIEW_USER_TOOLBAR2 - MENUITEM "", ID_VIEW_USER_TOOLBAR3 - MENUITEM "", ID_VIEW_USER_TOOLBAR4 - MENUITEM "", ID_VIEW_USER_TOOLBAR5 - MENUITEM "", ID_VIEW_USER_TOOLBAR6 - MENUITEM "", ID_VIEW_USER_TOOLBAR7 - MENUITEM "", ID_VIEW_USER_TOOLBAR8 - MENUITEM "", ID_VIEW_USER_TOOLBAR9 - MENUITEM "", ID_VIEW_USER_TOOLBAR10 - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -IDR_POPUP_SORT MENU -BEGIN - POPUP "Sorting" - BEGIN - MENUITEM "&Sort Alphabeticaly", ID_SORTING_SORTALF - MENUITEM "Sort by &Type", ID_SORTING_SORTBYTYPE - MENUITEM "Sort by Acc&ess", ID_SORTING_SORTBYACCESS - MENUITEM "Group by t&ype", ID_SORTING_GROUPBYTYPE - END -END - -IDR_POPUP_SOLUTION MENU -BEGIN - POPUP "Solution" - BEGIN - MENUITEM "&Open", ID_SOLUTION_OPEN - MENUITEM "Open &With....", ID_SOLUTION_OPEN_WITH - MENUITEM SEPARATOR - MENUITEM "&Compile", ID_DUMMY_COMPILE - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Remove", ID_EDIT_CLEAR - MENUITEM SEPARATOR - MENUITEM "&Properties...", ID_PROPERTIES - END -END - -IDR_POPUP_RESOURCE MENU -BEGIN - POPUP "Resource" - BEGIN - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - MENUITEM "&Delete", ID_EDIT_CLEAR - END -END - -IDR_POPUP_CONTROLBAR MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "&Solution Explorer", ID_VIEW_FILE - MENUITEM "&Class View", ID_VIEW_CLASS - MENUITEM "R&esource View", ID_VIEW_RESOURCE - MENUITEM "&Properties View", ID_VIEW_PROPERTIES - MENUITEM "&Output", ID_VIEW_OUTPUT - MENUITEM "W&atch", ID_VIEW_WATCH - MENUITEM "&Dynamic Help", ID_VIEW_DYNAMICHELP - MENUITEM SEPARATOR - MENUITEM "&Standard Toolbar", ID_VIEW_TOOLBAR - MENUITEM "Edit Toolbar", ID_VIEW_EDIT_TOOLBAR - MENUITEM "&Build Toolbar", ID_VIEW_BUILD_TOOLBAR - MENUITEM SEPARATOR - MENUITEM "", ID_VIEW_USER_TOOLBAR1 - MENUITEM "", ID_VIEW_USER_TOOLBAR2 - MENUITEM "", ID_VIEW_USER_TOOLBAR3 - MENUITEM "", ID_VIEW_USER_TOOLBAR4 - MENUITEM "", ID_VIEW_USER_TOOLBAR5 - MENUITEM "", ID_VIEW_USER_TOOLBAR6 - MENUITEM "", ID_VIEW_USER_TOOLBAR7 - MENUITEM "", ID_VIEW_USER_TOOLBAR8 - MENUITEM "", ID_VIEW_USER_TOOLBAR9 - MENUITEM "", ID_VIEW_USER_TOOLBAR10 - MENUITEM SEPARATOR - MENUITEM "&Customize...", ID_VIEW_CUSTOMIZE - END -END - -IDR_POPUP_MDITABS MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "&Save", ID_FILE_SAVE - MENUITEM "&Close", ID_FILE_CLOSE - MENUITEM "&Tabbed Document", ID_MDI_TABBED_DOCUMENT - MENUITEM SEPARATOR - MENUITEM "New &Horizontal Tab Group", ID_MDI_NEW_HORZ_TAB_GROUP - MENUITEM "New &Vertical Tab Group", ID_MDI_NEW_VERT_GROUP - MENUITEM "Move to Ne&xt Tab Group", ID_MDI_MOVE_TO_NEXT_GROUP - MENUITEM "Move to P&revious Tab Group", ID_MDI_MOVE_TO_PREV_GROUP - END -END - -IDR_POPUP_DROP_MDITABS MENU -BEGIN - POPUP "DUMMY" - BEGIN - MENUITEM "New &Horizontal Tab Group", ID_MDI_NEW_HORZ_TAB_GROUP - MENUITEM "New &Vertical Tab Group", ID_MDI_NEW_VERT_GROUP - MENUITEM "Move to Ne&xt Tab Group", ID_MDI_MOVE_TO_NEXT_GROUP - MENUITEM "Move to P&revious Tab Group", ID_MDI_MOVE_TO_PREV_GROUP - MENUITEM SEPARATOR - MENUITEM "&Cancel", ID_MDI_CANCEL - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_BUILD TOOLBAR 16, 16 -BEGIN - BUTTON ID_DUMMY_SELECT_ACTIVE_CONFIGURATION - SEPARATOR - BUTTON ID_DUMMY_COMPILE - BUTTON ID_DUMMY_BUILD - BUTTON ID_DUMMY_STOP_BUILD - SEPARATOR - BUTTON ID_DUMMY_EXECUTE - BUTTON ID_DUMMY_GO - BUTTON ID_EDIT_TOGGLEBREAKPOINT - BUTTON ID_DUMMY_REMOVE_ALL_BREAKPOINTS -END - -IDR_MAINFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - BUTTON ID_FILE_SAVE_ALL - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_DUMMY_INSERT_RESOURCE - SEPARATOR - BUTTON ID_EDIT_UNDO - BUTTON ID_EDIT_REDO - SEPARATOR - BUTTON ID_VIEW_OUTPUT - SEPARATOR - BUTTON ID_EDIT_FIND - SEPARATOR - BUTTON ID_FILE_PRINT - SEPARATOR - BUTTON ID_APP_ABOUT -END - -IDR_MENU_IMAGES TOOLBAR 16, 16 -BEGIN - BUTTON ID_WINDOW_MANAGER - SEPARATOR - BUTTON ID_WINDOW_CASCADE - BUTTON ID_WINDOW_TILE_HORZ - BUTTON ID_TOOLS_MACRO - BUTTON ID_SORTING_SORTALF - BUTTON ID_SORTING_SORTBYTYPE - BUTTON ID_SORTING_SORTBYACCESS - BUTTON ID_SORTING_GROUPBYTYPE - BUTTON ID_SOLUTION_OPEN - BUTTON ID_EDIT_CLEAR - BUTTON ID_FILE_NEW_BLANK_SOLUTION - BUTTON ID_FILE_NEW_PROJECT - BUTTON ID_FILE_OPEN_SOLUTION - BUTTON ID_FILE_CLOSE_SOLUTION - BUTTON ID_TOOLS_DEBUG_PROCESSES - BUTTON ID_TOOLS_CONNECT_TO_DATABASE - BUTTON ID_HELP_SHOW_START - BUTTON ID_VIEW_FILE - BUTTON ID_VIEW_CLASS - BUTTON ID_VIEW_RESOURCE - BUTTON ID_VIEW_PROPERTIES - BUTTON ID_VIEW_OUTPUT - BUTTON ID_VIEW_WATCH - BUTTON ID_VIEW_REFRESH - BUTTON ID_VIEW_DYNAMICHELP - BUTTON ID_EDIT_LISTMEMBERS - BUTTON ID_VIEW_FULLSCREEN - BUTTON ID_MDI_NEW_HORZ_TAB_GROUP - BUTTON ID_MDI_NEW_VERT_GROUP -END - -IDR_TOOLBAR_RESOURCE TOOLBAR 16, 16 -BEGIN - BUTTON ID_NEW_DIALOG - BUTTON ID_NEW_MENU - BUTTON ID_NEW_CURSOR - BUTTON ID_NEW_ICON - BUTTON ID_NEW_BITMAP - BUTTON ID_NEW_TOOLBAR - BUTTON ID_NEW_ACCELERATOR - BUTTON ID_NEW_STRING_TABLE - BUTTON ID_NEW_VERSION -END - -IDR_SORT TOOLBAR 16, 16 -BEGIN - BUTTON ID_SORT_MENU - BUTTON ID_NEW_FOLDER -END - -IDR_DYNAMIC_HELP TOOLBAR 16, 16 -BEGIN - BUTTON ID_DHELP1 - BUTTON ID_DHELP2 - BUTTON ID_DHELP3 -END - -IDR_PROPERTIES TOOLBAR 16, 16 -BEGIN - BUTTON ID_EXPAND - BUTTON ID_SORTINGPROP - BUTTON ID_PROPERIES1 - BUTTON ID_PROPERIES2 -END - -IDR_SOLUTION_EXPLORER TOOLBAR 16, 16 -BEGIN - BUTTON ID_PROPERTIES -END - -IDR_EDIT TOOLBAR 16, 16 -BEGIN - BUTTON ID_EDIT_TOGGLEBOOKMARK - BUTTON ID_EDIT_NEXTBOOKMARK - BUTTON ID_EDIT_PREVIOUSBOOKMARK - BUTTON ID_EDIT_CLEAR_ALLBOOKMARKS - SEPARATOR - BUTTON ID_EDIT_FIND - SEPARATOR - BUTTON ID_EDIT_INCREASE_IDENT - BUTTON ID_EDIT_DECREASE_IDENT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_BUILD BITMAP "res\\build.bmp" -IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" -IDR_MENU_IMAGES BITMAP "res\\menuimages.bmp" -IDR_TOOLBAR_RESOURCE BITMAP "res\\toolbar_.bmp" -IDB_CHECK BITMAP "res\\check.bmp" -IDB_CLASS_VIEW BITMAP "res\\classview.bmp" -IDB_FILE_VIEW BITMAP "res\\fileview.bmp" -IDB_RESOURCE_VIEW BITMAP "res\\resource.bmp" -IDB_WORKSPACE BITMAP "res\\workspc.bmp" -IDR_DYNAMIC_HELP BITMAP "res\\toolbar1.bmp" -IDR_SORT BITMAP "res\\sort.bmp" -IDB_DYNAMICHELP BITMAP "res\\dynamich.bmp" -IDR_PROPERTIES BITMAP "res\\properti.bmp" -IDR_SOLUTION_EXPLORER BITMAP "res\\solution.bmp" -IDR_EDIT BITMAP "res\\edit.bmp" -IDB_IMG_INTELLISENSE BITMAP "res\\intellisense.bmp" -IDB_OPTIONSIMAGES BITMAP "res\\optionsimages.bmp" -IDB_MENUIMAGES24 BITMAP "res\\menuimages24.bmp" -IDB_TOOLBAR24 BITMAP "res\\Toolbar24.bmp" -IDB_BUILD24 BITMAP "res\\build24.bmp" -IDB_EDIT24 BITMAP "res\\edit24.bmp" -IDB_IMG_INTELLISENSE_HC BITMAP "res\\img_inte_hc.bmp" -IDB_SOLUTION_EXPLORER_24 BITMAP "res\\solution24.bmp" -IDB_PROP24 BITMAP "res\\prop24.bmp" -IDB_CLASS_VIEW_24 BITMAP "res\\classview_hc.bmp" -IDB_SORT24 BITMAP "res\\sort24.bmp" -IDB_FILE_VIEW24 BITMAP "res\\filevie24.bmp" -IDB_HELPTOOLBAR_24 BITMAP "res\\help24.bmp" -IDB_DYNAMICHELP24 BITMAP "res\\dynamich24.bmp" -IDB_RESOURCE_VIEW24 BITMAP "res\\resource24.bmp" -IDB_CURRENT BITMAP "res\\current.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_FINDDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 263 - TOPMARGIN, 7 - BOTTOMMARGIN, 75 - END - - IDD_OPTIONSPAGE1, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 175 - END - - IDD_OPTIONSPAGE2, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - VERTGUIDE, 26 - VERTGUIDE, 49 - TOPMARGIN, 7 - BOTTOMMARGIN, 175 - END - - IDD_OPTIONSPAGE3, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - VERTGUIDE, 42 - TOPMARGIN, 7 - BOTTOMMARGIN, 175 - HORZGUIDE, 28 - END - - IDD_OPTIONSPAGE4, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - VERTGUIDE, 42 - TOPMARGIN, 7 - BOTTOMMARGIN, 175 - END - - IDD_OPTIONSPAGE5, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - VERTGUIDE, 30 - TOPMARGIN, 7 - BOTTOMMARGIN, 175 - END - - IDD_OPTIONSPAGE6, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - VERTGUIDE, 33 - VERTGUIDE, 77 - TOPMARGIN, 7 - BOTTOMMARGIN, 175 - END - - IDD_APP_LOOK, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 285 - VERTGUIDE, 17 - VERTGUIDE, 112 - TOPMARGIN, 7 - BOTTOMMARGIN, 267 - END - - IDD_GOTO_LINE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 39 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_OPTIONSPAGE1 DLGINIT -BEGIN - IDC_COMBO1, 0x403, 16, 0 -0x6853, 0x776f, 0x5320, 0x6174, 0x7472, 0x5020, 0x6761, 0x0065, - 0 -END - -IDD_OPTIONSPAGE3 DLGINIT -BEGIN - IDC_COMBO1, 0x403, 19, 0 -0x6956, 0x7573, 0x6c61, 0x5320, 0x756f, 0x6372, 0x2065, 0x6153, 0x6566, -"\000" - 0 -END - -IDD_OPTIONSPAGE4 DLGINIT -BEGIN - IDC_COMBO1, 0x403, 19, 0 -0x6956, 0x7573, 0x6c61, 0x5320, 0x756f, 0x6372, 0x2065, 0x6153, 0x6566, -"\000" - 0 -END - -IDD_APP_LOOK DLGINIT -BEGIN - IDC_APP_LOOK, 0x403, 29, 0 -0x694d, 0x7263, 0x736f, 0x666f, 0xae74, 0x5620, 0x7369, 0x6175, 0x206c, -0x7453, 0x6475, 0x6f69, 0x20ae, 0x3739, "\000" - IDC_APP_LOOK, 0x403, 35, 0 -0x694d, 0x7263, 0x736f, 0x666f, 0xae74, 0x5620, 0x7369, 0x6175, 0x206c, -0x7453, 0x6475, 0x6f69, 0x4e2e, 0x5445, 0x20ae, 0x3032, 0x3330, "\000" - IDC_APP_LOOK, 0x403, 23, 0 -0x694d, 0x7263, 0x736f, 0x666f, 0xae74, 0x4f20, 0x6666, 0x6369, 0x2065, -0x3032, 0x3330, "\000" - IDC_APP_LOOK, 0x403, 31, 0 -0x694d, 0x7263, 0x736f, 0x666f, 0xae74, 0x5620, 0x7369, 0x6175, 0x206c, -0x7453, 0x6475, 0x6f69, 0x20ae, 0x3032, 0x3530, "\000" - IDC_APP_LOOK, 0x403, 35, 0 -0x694d, 0x7263, 0x736f, 0x666f, 0xae74, 0x5720, 0x6e69, 0x6f64, 0x7377, -0x20ae, 0x5058, 0x6e20, 0x7461, 0x7669, 0x2065, 0x6f6c, 0x6b6f, "\000" - IDC_APP_LOOK, 0x403, 23, 0 -0x694d, 0x7263, 0x736f, 0x666f, 0xae74, 0x4f20, 0x6666, 0x6369, 0x2065, -0x3032, 0x3730, "\000" - IDC_STYLE, 0x403, 12, 0 -0x754c, 0x616e, 0x2d20, 0x6220, 0x756c, 0x0065, - IDC_STYLE, 0x403, 17, 0 -0x624f, 0x6973, 0x6964, 0x6e61, 0x2d20, 0x6220, 0x616c, 0x6b63, "\000" - IDC_STYLE, 0x403, 5, 0 -0x7141, 0x6175, "\000" - IDC_STYLE, 0x403, 7, 0 -0x6953, 0x766c, 0x7265, "\000" - 0 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "VisualStudioDemo" - IDR_DEVTYPE0 "\n\n\n\n\nVisualStudioDemo.Document\nVisualStudioDemo Document" - IDR_DEVTYPE_CPP "\nC++ example - \nC++ File\nC++ Files (.cpp)\n.cpp\nVisualStudioDemo.Document\nVisualStudioDemo Document" -END - -STRINGTABLE -BEGIN - IDS_MAIN_TOOLBAR "Standard" - IDS_STRING_NOT_FOUND_FMT "Cannot find the string ""%s""" - IDS_BUILD_TOOLBAR "Build" - IDS_RESOURCE_TOOLBAR "Resource" - IDS_EDIT_TOOLBAR "Edit" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "VisualStudioDemo" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Create a new document\nNew" - ID_FILE_OPEN "Open an existing document\nOpen" - ID_FILE_CLOSE "Close the active document\nClose" - ID_FILE_SAVE "Save the active document\nSave" - ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Print the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_NEW "Open another window for the active document\nNew Window" - ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" - ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" - ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - IDS_UAT_UNINDENT "Unindent" - IDS_UAT_DRAGDROP "Drag/drop" - IDS_UAT_TAB "Tab" - IDS_UAT_ENTER "Enter" - ID_EDIT_FIND_COMBO "Find the text\nFind" - ID_TOOLS_OPTIONS "Changes options\nOptions" - ID_VIEW_APP_LOOK "Modify the application general look\nApplication Look" - ID_HELP_WEB "Open the Microsoft Home page\nMicrosoft on the Web" - ID_EDIT_HIDESELECTION "Adds the user-defined collapsible node for the currently selected text\nHide Selection" - ID_EDIT_TOGGLEOUTLINING "Toggles outlining inside selection\nToggle Outlining" - ID_EDIT_STOPHIDINGCURRENT - "Deletes the user-defined collapsible node(s) inside selection\nStop Hiding Current" - ID_EDIT_TOGGLEALLOUTLINING - "Toggles outlinings for the whole text\nToggle All Outlining" - ID_EDIT_COLLAPSETODEFINITIONS - "Collapses the members of all outlining types\nCollapse to Definitions" - ID_EDIT_STOPOUTLINING "Cancels auto-outlining mode\nStop Outlining" - ID_EDIT_AUTOOUTLINING "Enables/disables auto-outlining mode\nEnable Auto-Outlining" - ID_EDIT_ENABLEOUTLINING "Enables/disables outlining mode\nEnable Outlining" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" - AFX_IDS_MDICHILD "Activate this window" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - IDS_EDITFAILED "You cannon edit the document!" - IDS_PGUPFAILED "PgUp is failed!" -END - -STRINGTABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customize toolbars and menus.\nCustomize" - ID_VIEW_USER_TOOLBAR1 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR2 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR3 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR4 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR5 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR6 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR7 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR8 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR9 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR10 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_WORKSPACE "Show or hide the workspace\nWorkSpace" - ID_VIEW_OUTPUT "Show or hide the output\nOutput" -END - -STRINGTABLE -BEGIN - ID_EDIT_NEXT_WORD "Find next word\nFind Next word" - ID_EDIT_LINENUMBERS "Shows/hides the line numbers\nLine Numbers" - IDS_UAT_REPLACE "Replace" - ID_EDIT_GOTO_LINE "Move to a specified location\nGo to line" - ID_MDI_NEW_VERT_GROUP "Create a new vertical tab group" - ID_MDI_NEW_HORZ_TAB_GROUP "Create a new horizontal tab group" - ID_MDI_MOVE_TO_PREV_GROUP - "Move the current view to the previous tab group" - ID_MDI_MOVE_TO_NEXT_GROUP "Move the current view to the next tab group" - ID_MDI_TABBED_DOCUMENT "Tabbed Document\nTabbed Document" -END - -STRINGTABLE -BEGIN - ID_WINDOW_MANAGER "Manages the currently open windows\nWindow List" - ID_VIEW_DYNAMICHELP "Show or hide the Dynamic Help\nDynamicHelp" - ID_DUMMY_COMPILE "Compile the file\nCompile" - ID_DUMMY_BUILD "Build the project\nBuild" - ID_DUMMY_STOP_BUILD "Stop the build\nStop Build" - ID_DUMMY_EXECUTE "Execute the program\nExecute Program" - ID_DUMMY_GO "Starts or continues the program\nGo" - ID_DUMMY_SELECT_ACTIVE_CONFIGURATION - "Selects the active configuration\nSelect Active Configuration" - ID_DUMMY_REMOVE_ALL_BREAKPOINTS - "Removes all breakpoints\nRemove All Breakpoints" - ID_VIEW_BUILD_TOOLBAR "Show or hide the build toolbar\nToggle Build ToolBar" - ID_DUMMY_REBUILD_ALL "Rebuilds the active project\nRebuild All" - ID_DUMMY_CLEAN "Cleans the project\nClean" -END - -STRINGTABLE -BEGIN - ID_EDIT_TOGGLEBREAKPOINT - "Inserts or removes a breakpoint\nInsert/Remove Breakpoint" - ID_EDIT_CLEAR_ALLBOOKMARKS - "Clear all bookmarks in the window\nClear All Bookmarks" - ID_EDIT_INCREASE_IDENT "Idents the selection text right one tab stop\nIncrease Ident" - ID_EDIT_DECREASE_IDENT "Idents the selection text left one tab stop\nDecrease Ident" - ID_VIEW_EDIT_TOOLBAR "Show or hide the edit toolbar\nToggle Build ToolBar" - ID_EDIT_LISTMEMBERS "Brings up the completion list box\nList Members" - IDS_UAT_UNDEFINED "" - IDS_UAT_TYPING "Typing" - IDS_UAT_DELETE "Delete" - IDS_UAT_INDENT "Indent" - IDS_UAT_UNKNOWN "" - IDS_UAT_CUT "Cut" - IDS_UAT_PASTE "Paste" - IDS_UAT_BACKSPACE "Backspace" -END - -STRINGTABLE -BEGIN - IDS_DUMMY_UNDO_ACTION "Undoes this action\nUndo" - ID_VIEW_CB_CAPTION "Toggle control bar captions\nControl Bar Captions" - ID_VIEW_FORCE_GRADIENT "Force Gradiend Captions\nGradiend Captions" - ID_USER_TOOL1 "Activates user-defined tool" - ID_USER_TOOL2 "Activates user-defined tool" - ID_USER_TOOL3 "Activates user-defined tool" - ID_USER_TOOL4 "Activates user-defined tool" - ID_USER_TOOL5 "Activates user-defined tool" - ID_USER_TOOL6 "Activates user-defined tool" - ID_USER_TOOL7 "Activates user-defined tool" - ID_USER_TOOL8 "Activates user-defined tool" - ID_USER_TOOL9 "Activates user-defined tool" - ID_USER_TOOL10 "Activates user-defined tool" -END - -STRINGTABLE -BEGIN - ID_HELP_SHOW_START "Show Start Page\nShow Start Page" - ID_VIEW_REFRESH "Refresh\nRefresh" - ID_VIEW_PROPERTIES "Show or hide the Properties View\nProperties View" - ID_VIEW_WATCH "Show or hide the watch\nToggle Watch" - ID_VIEW_FULLSCREEN "Toggles full screen mode On and Off\nToggles Full Screen" -END - -STRINGTABLE -BEGIN - ID_TOOLS_MACRO "Create and edit macro\nMacro" - ID_TOOLS_ENTRY "\n" - ID_NEW_DIALOG "Creates a new dialog resource\nNew Dialog" - ID_NEW_MENU "Creates a new menu resource\nNew Menu" - ID_NEW_CURSOR "Creates a new cursor resource\nNew Cursor" - ID_NEW_ICON "Creates a new icon resource\nNew Icon" - ID_NEW_BITMAP "Creates a new bitmap resource\nNew Bitmap" - ID_NEW_TOOLBAR "Creates a new toolbar resource\nNew Toolbar" - ID_NEW_ACCELERATOR "Creates a new accelerator resource\nNew Accelerator" - ID_NEW_STRING_TABLE "Creates a new string table resource\nNew String Table" - ID_NEW_VERSION "Creates a new version resource\nNew Version" -END - -STRINGTABLE -BEGIN - ID_OUTPUT_GOTO_ERROR "Moves to the line containing current error or tag\nGo to Error" - ID_CLASS_DEFINITION "Displayes the definition of the selected item\nDefinition" - ID_CLASS_ADD_MEMEBER_FUNCTION - "Add a member function to the selected class\nAdd Member Function" - ID_CLASS_ADD_MEMEBER_VARIABLE - "Add a member variable to the selected class\nAdd Member Variable" - ID_CLASS_PROPERTIES "Edits the current selection properties" - ID_RESOURCE_OPEN "Open the selected resource for editing\nOpen" - ID_RESOURCE_OPEN_BINARY "Open the selected resource for binary editing\nOpen Binary" - ID_VIEW_TAB_FLAT_BORDERS "Toggle Tab Flat Borders\nTab &Flat Borders" - ID_HELP_KEYBOARDMAP "Displays all keyboard commands\nKeyboard Map" - ID_MENU_DIR1 "Toggles Full Screen mode on and off\nFull Screen" -END - -STRINGTABLE -BEGIN - ID_MENU_ITEM1 "$(ITem1)" - ID_MENU_ITEM2 "$(ITem2)" - ID_MENU_ITEM3 "$(ITem3)" - ID_DHELP1 "Help Content\nHelp Content" - ID_DHELP2 "Help Index\nIndex" - ID_DHELP3 "Help Search\nSearch" - ID_EXPAND "Categorized\nCategorized" - ID_SORTINGPROP "Alphabetic\nAlphabetic" -END - -STRINGTABLE -BEGIN - ID_MENU_DIR2 "$(Dir2)" - ID_MENU_DIR3 "$(Dir3)" - ID_MDITABS_ICONS "Toggle MDI Tab Icons\nMDI Icons" - ID_MDITABS_TOP "Show MDI Tabs on top\nTop" - ID_MDITABS_BOTTOM "Show MDI Tabs at bottom\nBottom" - ID_VIEW_MDI_TABS "Toggle MDI Tabs\nShow/Hide Tabs" - ID_MDITABS_CLOSE "Close clicked document\nClose Document" - ID_VIEW_CLASS "Show or hide the Class View\nClassView" - ID_VIEW_RESOURCE "Show or hide the Resource View\nResourceView" - ID_VIEW_FILE "Show or hide the Solution Explorer\nSolutionExplorer" -END - -STRINGTABLE -BEGIN - ID_PROPERIES1 "Properties\nProperties" - ID_PROPERIES2 "Events\nEvents" - ID_NEW_FOLDER "New Folder\nNew Folder" - ID_PROPERTIES "Show Properties\nProperties" - ID_SOLUTION_OPEN "Open file\nOpen" - ID_SOLUTION_OPEN_WITH "Open Solution\nOpen With...." - ID_FILE_NEW_PROJECT "Create a new project\nNew Project" - ID_FILE_NEW_BLANK_SOLUTION "Create a new blank solution\nBlank Solution" - ID_FILE_OPEN_SOLUTION "Open Solution\nOpen Solution" - ID_FILE_CLOSE_SOLUTION "Close Solution\nClose Solution" - ID_FILE_SAVE_ALL "Save All\nSave All" - ID_TOOLS_DEBUG_PROCESSES "Show Debug Processes\nDebug Processes" - ID_TOOLS_CONNECT_TO_DATABASE "Connect to Database\nConnect to Database" - ID_WINDOW_CLOSE_ALL "Close All Documents\nClose All Documents" -END - -STRINGTABLE -BEGIN - ID_EDIT_TOGGLEBOOKMARK "Inserts or removes a Bookmark\nToggle Bookmark" - ID_EDIT_NEXTBOOKMARK "Go to the next temporary bookmark\nNext Bookmark" - ID_EDIT_PREVIOUSBOOKMARK - "Go to the previous temporary bookmark\nPrevious Bookmark" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\VisualStudioDemo.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif -#endif -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoDoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoDoc.cpp deleted file mode 100644 index 84f75d573b200..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoDoc.cpp +++ /dev/null @@ -1,203 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" - -#include "VisualStudioDemoDoc.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CVisualStudioDemoDoc - -IMPLEMENT_DYNCREATE(CVisualStudioDemoDoc, CDocument) - -BEGIN_MESSAGE_MAP(CVisualStudioDemoDoc, CDocument) - //{{AFX_MSG_MAP(CVisualStudioDemoDoc) - ON_COMMAND(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, OnDummySelectActiveConfiguration) - ON_COMMAND(ID_DUMMY_BUILD, &CVisualStudioDemoDoc::OnDummyBuild) - ON_COMMAND(ID_DUMMY_COMPILE, &CVisualStudioDemoDoc::OnDummyCompile) - ON_COMMAND(ID_DUMMY_EXECUTE, &CVisualStudioDemoDoc::OnDummyExecute) - ON_COMMAND(ID_DUMMY_GO, &CVisualStudioDemoDoc::OnDummyGo) - ON_COMMAND(ID_DUMMY_REBUILD_ALL, &CVisualStudioDemoDoc::OnDummyRebuildAll) - ON_COMMAND(ID_DUMMY_REMOVE_ALL_BREAKPOINTS, &CVisualStudioDemoDoc::OnDummyRemoveAllBreakpoints) - ON_COMMAND(ID_DUMMY_CLEAN, &CVisualStudioDemoDoc::OnDummyClean) - ON_COMMAND(ID_NEW_DIALOG, OnNewDialog) - ON_COMMAND(ID_NEW_ACCELERATOR, OnNewAccelerator) - ON_COMMAND(ID_NEW_BITMAP, OnNewBitmap) - ON_COMMAND(ID_NEW_CURSOR, OnNewCursor) - ON_COMMAND(ID_NEW_ICON, OnNewIcon) - ON_COMMAND(ID_NEW_MENU, OnNewMenu) - ON_COMMAND(ID_NEW_STRING_TABLE, OnNewStringTable) - ON_COMMAND(ID_NEW_TOOLBAR, OnNewToolbar) - ON_COMMAND(ID_NEW_VERSION, OnNewVersion) - ON_CBN_SELENDOK(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, OnDummySelectActiveConfiguration) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// CVisualStudioDemoDoc construction/destruction - -CVisualStudioDemoDoc::CVisualStudioDemoDoc() -{ - // TODO: add one-time construction code here -} - -CVisualStudioDemoDoc::~CVisualStudioDemoDoc() -{ -} - -BOOL CVisualStudioDemoDoc::OnNewDocument() -{ - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - //(SDI documents will reuse this document) - return TRUE; -} - -void CVisualStudioDemoDoc::OnDummySelectActiveConfiguration() -{ - CMFCToolBarComboBoxButton* pSrcCombo = NULL; - - CObList listButtons; - if (CMFCToolBar::GetCommandButtons(ID_DUMMY_SELECT_ACTIVE_CONFIGURATION, listButtons) > 0) - { - for (POSITION posCombo = listButtons.GetHeadPosition(); - pSrcCombo == NULL && posCombo != NULL;) - { - CMFCToolBarComboBoxButton* pCombo = DYNAMIC_DOWNCAST(CMFCToolBarComboBoxButton, listButtons.GetNext(posCombo)); - - if (pCombo != NULL && CMFCToolBar::IsLastCommandFromButton(pCombo)) - { - pSrcCombo = pCombo; - } - } - } - - if (pSrcCombo != NULL) - { - ASSERT_VALID(pSrcCombo); - - LPCTSTR lpszSelItem = pSrcCombo->GetItem(); - CString strSelItem = (lpszSelItem == NULL) ? _T("") : lpszSelItem; - - AfxMessageBox(strSelItem); - } - else - { - AfxMessageBox(_T("Show \"Set Active Configuration\" dialog....")); - } -} - -// CVisualStudioDemoDoc serialization - -void CVisualStudioDemoDoc::Serialize(CArchive& ar) -{ - // CEditView contains an edit control which handles all serialization - reinterpret_cast(m_viewList.GetHead())->SerializeRaw(ar); -} - -// CVisualStudioDemoDoc diagnostics - -#ifdef _DEBUG -void CVisualStudioDemoDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CVisualStudioDemoDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -// CVisualStudioDemoDoc commands - -void CVisualStudioDemoDoc::OnDummyBuild() -{ - // TODO: Add your command handler code here -} - -void CVisualStudioDemoDoc::OnDummyCompile() -{ - // TODO: Add your command handler code here -} - -void CVisualStudioDemoDoc::OnDummyExecute() -{ - // TODO: Add your command handler code here -} - -void CVisualStudioDemoDoc::OnDummyGo() -{ - // TODO: Add your command handler code here -} - -void CVisualStudioDemoDoc::OnDummyRebuildAll() -{ - // TODO: Add your command handler code here -} - -void CVisualStudioDemoDoc::OnDummyRemoveAllBreakpoints() -{ - // TODO: Add your command handler code here -} - -void CVisualStudioDemoDoc::OnDummyClean() -{ - // TODO: Add your command handler code here -} -void CVisualStudioDemoDoc::OnNewDialog() -{ - AfxMessageBox(_T("New Dialog")); -} - -void CVisualStudioDemoDoc::OnNewAccelerator() -{ - AfxMessageBox(_T("New Accelerator")); -} - -void CVisualStudioDemoDoc::OnNewBitmap() -{ - AfxMessageBox(_T("New Bitmap")); -} - -void CVisualStudioDemoDoc::OnNewCursor() -{ - AfxMessageBox(_T("New Cursor")); -} - -void CVisualStudioDemoDoc::OnNewIcon() -{ - AfxMessageBox(_T("New Icon")); -} - -void CVisualStudioDemoDoc::OnNewMenu() -{ - AfxMessageBox(_T("New Menu")); -} - -void CVisualStudioDemoDoc::OnNewStringTable() -{ - AfxMessageBox(_T("New StringTable")); -} - -void CVisualStudioDemoDoc::OnNewToolbar() -{ - AfxMessageBox(_T("New Toolbar")); -} - -void CVisualStudioDemoDoc::OnNewVersion() -{ - AfxMessageBox(_T("New Version")); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoDoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoDoc.h deleted file mode 100644 index a8f4f36a3f4b4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoDoc.h +++ /dev/null @@ -1,53 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CVisualStudioDemoDoc : public CDocument -{ -protected: // create from serialization only - CVisualStudioDemoDoc(); - DECLARE_DYNCREATE(CVisualStudioDemoDoc) - -// Overrides -public: - virtual BOOL OnNewDocument(); - virtual void Serialize(CArchive& ar); - -// Implementation -public: - virtual ~CVisualStudioDemoDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - //{{AFX_MSG(CVisualStudioDemoDoc) - afx_msg void OnDummySelectActiveConfiguration(); - afx_msg void OnDummyBuild(); - afx_msg void OnDummyCompile(); - afx_msg void OnDummyExecute(); - afx_msg void OnDummyGo(); - afx_msg void OnDummyRebuildAll(); - afx_msg void OnDummyRemoveAllBreakpoints(); - afx_msg void OnDummyClean(); - afx_msg void OnNewDialog(); - afx_msg void OnNewAccelerator(); - afx_msg void OnNewBitmap(); - afx_msg void OnNewCursor(); - afx_msg void OnNewIcon(); - afx_msg void OnNewMenu(); - afx_msg void OnNewStringTable(); - afx_msg void OnNewToolbar(); - afx_msg void OnNewVersion(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoView.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoView.cpp deleted file mode 100644 index 9cfb13c3e4ba1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoView.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "MainFrm.h" -#include "VisualStudioDemo.h" - -#include "VisualStudioDemoDoc.h" -#include "VisualStudioDemoView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// CVisualStudioDemoView - -IMPLEMENT_DYNCREATE(CVisualStudioDemoView, CEditView) - -BEGIN_MESSAGE_MAP(CVisualStudioDemoView, CEditView) - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, &CEditView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, &CEditView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CVisualStudioDemoView::OnFilePrintPreview) - ON_COMMAND(ID_EDIT_TOGGLEBREAKPOINT, &CVisualStudioDemoView::OnEditTogglebreakpoint) - ON_COMMAND(ID_EDIT_FIND_COMBO, OnFind) -END_MESSAGE_MAP() - -// CVisualStudioDemoView construction/destruction - -CVisualStudioDemoView::CVisualStudioDemoView() -{ - // TODO: add construction code here -} - -CVisualStudioDemoView::~CVisualStudioDemoView() -{ -} - -BOOL CVisualStudioDemoView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - BOOL bPreCreated = CEditView::PreCreateWindow(cs); - cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL); // Enable word-wrapping - - return bPreCreated; -} - -// CVisualStudioDemoView printing - -BOOL CVisualStudioDemoView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default CEditView preparation - return CEditView::OnPreparePrinting(pInfo); -} - -void CVisualStudioDemoView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) -{ - // Default CEditView begin printing - CEditView::OnBeginPrinting(pDC, pInfo); -} - -void CVisualStudioDemoView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo) -{ - // Default CEditView end printing - CEditView::OnEndPrinting(pDC, pInfo); -} - -void CVisualStudioDemoView::OnFilePrintPreview() -{ - AFXPrintPreview(this); -} - -// CVisualStudioDemoView diagnostics - -#ifdef _DEBUG -void CVisualStudioDemoView::AssertValid() const -{ - CEditView::AssertValid(); -} - -void CVisualStudioDemoView::Dump(CDumpContext& dc) const -{ - CEditView::Dump(dc); -} - -CVisualStudioDemoDoc* CVisualStudioDemoView::GetDocument() const // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVisualStudioDemoDoc))); - return(CVisualStudioDemoDoc*)m_pDocument; -} -#endif //_DEBUG - -// CVisualStudioDemoView message handlers - -void CVisualStudioDemoView::OnEditTogglebreakpoint() -{ - // TODO: Add your command handler code here -} - -void CVisualStudioDemoView::OnFind() -{ - CString strFindText; - VerifyFindString(((CMainFrame*)AfxGetMainWnd())->GetFindCombo(), strFindText); - - if (!strFindText.IsEmpty()) - { - FindText(strFindText); - } -} - -void CVisualStudioDemoView::VerifyFindString(CMFCToolBarComboBoxButton* pFindCombo, CString& strFindText) -{ - if (pFindCombo == NULL) - { - return; - } - - BOOL bIsLastCommandFromButton = CMFCToolBar::IsLastCommandFromButton(pFindCombo); - - if (bIsLastCommandFromButton) - { - strFindText = pFindCombo->GetText(); - } - - CComboBox* pCombo = pFindCombo->GetComboBox(); - - if (!strFindText.IsEmpty()) - { - const int nCount = pCombo->GetCount(); - int ind = 0; - CString strCmpText; - - while (ind < nCount) - { - pCombo->GetLBText(ind, strCmpText); - - if (strCmpText.GetLength() == strFindText.GetLength()) - { - if (strCmpText == strFindText) - break; - } - - ind++; - } - - if (ind < nCount) - { - pCombo->DeleteString(ind); - } - - pCombo->InsertString(0,strFindText); - pCombo->SetCurSel(0); - - if (!bIsLastCommandFromButton) - { - pFindCombo->SetText(strFindText); - } - } -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoView.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoView.h deleted file mode 100644 index 2e022c0ee56cf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/VisualStudioDemoView.h +++ /dev/null @@ -1,54 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -class CVisualStudioDemoView : public CEditView -{ -protected: // create from serialization only - CVisualStudioDemoView(); - DECLARE_DYNCREATE(CVisualStudioDemoView) - - // Attributes -public: - CVisualStudioDemoDoc* GetDocument() const; - - // Operations -public: - - // Overrides -public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); -protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); - - // Implementation -public: - virtual ~CVisualStudioDemoView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -private: - void VerifyFindString(CMFCToolBarComboBoxButton* pFindCombo, CString& strFindText); -protected: - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnEditTogglebreakpoint(); - afx_msg void OnFind(); - afx_msg void OnFilePrintPreview(); -}; - -#ifndef _DEBUG // debug version in VisualStudioDemoView.cpp -inline CVisualStudioDemoDoc* CVisualStudioDemoView::GetDocument() const { return reinterpret_cast(m_pDocument); } -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/WatchBar.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/WatchBar.cpp deleted file mode 100644 index 1bb5c6b8d9c71..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/WatchBar.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "VisualStudioDemo.h" -#include "WatchBar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define ID_LIST_1 1 - -///////////////////////////////////////////////////////////////////////////// -// CWatchBar - -CWatchBar::CWatchBar() -{ -} - -CWatchBar::~CWatchBar() -{ -} - -BEGIN_MESSAGE_MAP(CWatchBar, CDockablePane) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_PAINT() - ON_WM_SETFOCUS() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWatchBar message handlers - -int CWatchBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CDockablePane::OnCreate(lpCreateStruct) == -1) - return -1; - - m_Font.CreateStockObject(DEFAULT_GUI_FONT); - - CRect rectDummy; - rectDummy.SetRectEmpty(); - - // Create output pane: - const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_VSCROLL | LVS_REPORT; - - // - // DWORD dwStyle - // CRect rectDummy - m_wndWatch.Create(dwStyle, rectDummy, this, ID_LIST_1); - m_wndWatch.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); - m_wndWatch.InsertColumn(0, _T("Variable"), LVCFMT_LEFT, 100); - m_wndWatch.InsertColumn(1, _T("Value"), LVCFMT_LEFT, 100); - - m_wndWatch.InsertItem(0, _T("m_nCount")); - m_wndWatch.SetItemText(0, 1, _T("100")); - - m_wndWatch.SetFont(&m_Font); - // - - return 0; -} - -void CWatchBar::OnSize(UINT nType, int cx, int cy) -{ - CDockablePane::OnSize(nType, cx, cy); - - if (CanAdjustLayout()) - { - CRect rc; - GetClientRect(rc); - - m_wndWatch.SetWindowPos(NULL, rc.left + 1, rc.top + 1, rc.Width() - 2, rc.Height() - 2, SWP_NOACTIVATE | SWP_NOZORDER); - } -} - -void CWatchBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rectTree; - m_wndWatch.GetWindowRect(rectTree); - ScreenToClient(rectTree); - - rectTree.InflateRect(1, 1); - dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); -} - -void CWatchBar::OnSetFocus(CWnd* pOldWnd) -{ - CDockablePane::OnSetFocus(pOldWnd); - m_wndWatch.SetFocus(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/WatchBar.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/WatchBar.h deleted file mode 100644 index 0c03aad3388e9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/WatchBar.h +++ /dev/null @@ -1,41 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CWatchBar window - -class CWatchBar : public CDockablePane -{ -// Construction -public: - CWatchBar(); - -// Attributes -protected: - CFont m_Font; - - // - CMFCListCtrl m_wndWatch; - // - -// Implementation -public: - virtual ~CWatchBar(); - -protected: - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - - DECLARE_MESSAGE_MAP() -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/Toolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/Toolbar.bmp deleted file mode 100644 index bc42142a05ca1..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/Toolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/Toolbar24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/Toolbar24.bmp deleted file mode 100644 index 25f4636f98f7b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/Toolbar24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemo.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemo.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemo.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemo.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemo.rc2 deleted file mode 100644 index 6a887b3432bec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemo.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// BCGVVisualStudioGUIDemo.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemoDoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemoDoc.ico deleted file mode 100644 index 96365d434ce66..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/VisualStudioDemoDoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/build.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/build.bmp deleted file mode 100644 index 15057696ce035..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/build.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/build24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/build24.bmp deleted file mode 100644 index ede06e049767c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/build24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/check.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/check.bmp deleted file mode 100644 index 33a3c58d9e948..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/check.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/class_view.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/class_view.ico deleted file mode 100644 index bf6b0ddcfc446..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/class_view.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/class_view_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/class_view_hc.ico deleted file mode 100644 index 3112bf258700b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/class_view_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/classview.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/classview.bmp deleted file mode 100644 index 1e02aa1aed9c4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/classview.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/classview_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/classview_hc.bmp deleted file mode 100644 index 6b22e786bcd9f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/classview_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/cpp.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/cpp.ico deleted file mode 100644 index c1f18e447bdd5..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/cpp.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/current.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/current.bmp deleted file mode 100644 index 77d744f543269..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/current.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/director.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/director.bmp deleted file mode 100644 index 49d4fe91fed34..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/director.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamich.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamich.bmp deleted file mode 100644 index 2d92010eabd8c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamich.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamich24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamich24.bmp deleted file mode 100644 index 39fad8c4f2641..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamich24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamichelp.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamichelp.ico deleted file mode 100644 index fd7e5ae1e9ca0..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamichelp.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamichelp_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamichelp_hc.ico deleted file mode 100644 index c1c61297ec75d..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/dynamichelp_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/edit.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/edit.bmp deleted file mode 100644 index 69c17ece03820..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/edit.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/edit24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/edit24.bmp deleted file mode 100644 index 95b206743c7cb..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/edit24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/file_view.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/file_view.ico deleted file mode 100644 index 0f93f52ab0185..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/file_view.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/file_view_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/file_view_hc.ico deleted file mode 100644 index 42ec43574f325..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/file_view_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/filevie24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/filevie24.bmp deleted file mode 100644 index b60f48381c687..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/filevie24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/fileview.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/fileview.bmp deleted file mode 100644 index a2d62d0cb7f23..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/fileview.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/help24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/help24.bmp deleted file mode 100644 index a77a96f0f68f4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/help24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/img_inte_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/img_inte_hc.bmp deleted file mode 100644 index 44a254458a996..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/img_inte_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/intellisense.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/intellisense.bmp deleted file mode 100644 index a071848945916..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/intellisense.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/lable.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/lable.bmp deleted file mode 100644 index f563619477ce1..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/lable.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/menuimages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/menuimages.bmp deleted file mode 100644 index 9d816ccecd94f..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/menuimages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/menuimages24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/menuimages24.bmp deleted file mode 100644 index 04c3430d343f4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/menuimages24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/optionsimages.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/optionsimages.bmp deleted file mode 100644 index 1aa6b516c9f0b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/optionsimages.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/output_bar.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/output_bar.ico deleted file mode 100644 index d14f99150a44b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/output_bar.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/output_bar_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/output_bar_hc.ico deleted file mode 100644 index fdd27e85abee6..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/output_bar_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/prop24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/prop24.bmp deleted file mode 100644 index 6e90ff49bfdf9..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/prop24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/prop_bar_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/prop_bar_hc.ico deleted file mode 100644 index 05a6d0e43de08..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/prop_bar_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/properti.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/properti.bmp deleted file mode 100644 index 8bf6601aaac49..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/properti.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/properti.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/properti.ico deleted file mode 100644 index b8cb52eed2c87..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/properti.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/res_view.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/res_view.ico deleted file mode 100644 index 24c1e701d0165..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/res_view.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/res_view_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/res_view_hc.ico deleted file mode 100644 index e27a4241d97e8..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/res_view_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/resource.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/resource.bmp deleted file mode 100644 index 8b30401cd8598..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/resource.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/resource24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/resource24.bmp deleted file mode 100644 index 251e14bc033ff..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/resource24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/solution.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/solution.bmp deleted file mode 100644 index a4ef154527a80..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/solution.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/solution24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/solution24.bmp deleted file mode 100644 index 559214a9bd70b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/solution24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/sort.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/sort.bmp deleted file mode 100644 index 4e2155debf2dd..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/sort.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/sort24.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/sort24.bmp deleted file mode 100644 index 5e1c3772dd759..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/sort24.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/start.png b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/start.png deleted file mode 100644 index cb060ab501dc4..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/start.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/toolbar1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/toolbar1.bmp deleted file mode 100644 index 9327881c25e61..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/toolbar1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/toolbar_.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/toolbar_.bmp deleted file mode 100644 index d2e1d6466fe23..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/toolbar_.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/watch_bar.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/watch_bar.ico deleted file mode 100644 index 3dcf9a7b840b8..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/watch_bar.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/watch_bar_hc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/watch_bar_hc.ico deleted file mode 100644 index 30586c4467376..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/watch_bar_hc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/web.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/web.ico deleted file mode 100644 index d71c79c0c1f03..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/web.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/workspc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/workspc.bmp deleted file mode 100644 index 9e9f45656ccfe..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/res/workspc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/stdafx.cpp deleted file mode 100644 index 1a2a0b06c6ac1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/stdafx.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -// stdafx.cpp : source file that includes just the standard includes -// VisualStudioDemo.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/stdafx.h deleted file mode 100644 index 81597ff8ec8f9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/stdafx.h +++ /dev/null @@ -1,54 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#include // MFC core and standard components -#include // MFC extensions - -#include -#include // MFC Automation classes - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC support for ribbons and control bars - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/visualstudiodemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/visualstudiodemo.vcxproj deleted file mode 100644 index 431565cc87e30..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_VisualStudioDemo/cpp/visualstudiodemo.vcxproj +++ /dev/null @@ -1,255 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {84C70F4F-3B25-434A-AA96-69588C917014} - VisualStudioDemo - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - false - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - false - X64 - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - %(DelayLoadDLLs) - true - Windows - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/AppLookDlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/AppLookDlg.cpp deleted file mode 100644 index 599723688eb91..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/AppLookDlg.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// -// AppLookDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "wordpad.h" -#include "AppLookDlg.h" -#include "mainfrm.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg dialog - -CAppLookDlg::CAppLookDlg(BOOL bStartup, CWnd* pParent /*=NULL*/) - : CDialog(CAppLookDlg::IDD, pParent), - m_bStartup (bStartup) -{ - //{{AFX_DATA_INIT(CAppLookDlg) - m_nAppLook = 1; - m_bShowAtStartup = FALSE; - m_nStyle2007 = 0; - //}}AFX_DATA_INIT - - m_nAppLook = theApp.GetInt (_T("AppLook"), 1); - m_bShowAtStartup = theApp.GetInt (_T("ShowAppLookAtStartup"), TRUE); - m_nStyle2007 = theApp.GetInt (_T("Style2007"), 0); - - theApp.m_bHiColorIcons = m_nAppLook == 1 || m_nAppLook == 2; -} - - -void CAppLookDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAppLookDlg) - DDX_Control(pDX, IDC_STYLE2007, m_wndStyle2007); - DDX_Control(pDX, IDOK, m_wndOK); - DDX_Control(pDX, IDCANCEL, m_wndCancel); - DDX_Radio(pDX, IDC_APP_LOOK1, m_nAppLook); - DDX_Check(pDX, IDC_SHOW_AT_STARTUP, m_bShowAtStartup); - DDX_CBIndex(pDX, IDC_STYLE2007, m_nStyle2007); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CAppLookDlg, CDialog) - //{{AFX_MSG_MAP(CAppLookDlg) - ON_BN_CLICKED(IDC_APPLY, OnApply) - ON_BN_CLICKED(IDC_APP_LOOK1, OnAppLook) - ON_BN_CLICKED(IDC_APP_LOOK2, OnAppLook) - ON_BN_CLICKED(IDC_APP_LOOK3, OnAppLook) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg message handlers - -BOOL CAppLookDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - if (m_bStartup) - { - SetLook (); - - if (!m_bShowAtStartup) - { - EndDialog (IDCANCEL); - return TRUE; - } - - CRect rectBtn; - - // Hide "Cancel" button: - m_wndCancel.GetWindowRect (rectBtn); - ScreenToClient (rectBtn); - - m_wndOK.MoveWindow (rectBtn); - - m_wndCancel.ShowWindow (SW_HIDE); - } - - m_wndStyle2007.EnableWindow (m_nAppLook == 2); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CAppLookDlg::OnOK() -{ - CDialog::OnOK(); - SetLook (); -} - -void CAppLookDlg::OnApply() -{ - SetLook (); - - if (!m_bStartup) - { - m_wndCancel.SetWindowText (_T("Close")); - } -} - -void CAppLookDlg::SetLook () -{ - UpdateData (); - - switch (m_nAppLook) - { - case 0: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - break; - - case 1: - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - break; - - case 2: - switch (m_nStyle2007) - { - case 0: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); - break; - - case 1: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); - break; - - case 2: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); - break; - - case 3: - CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); - break; - } - - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); - break; - } - - theApp.WriteInt (_T("AppLook"), m_nAppLook); - theApp.WriteInt (_T("Style2007"), m_nStyle2007); - theApp.WriteInt (_T("ShowAppLookAtStartup"), m_bShowAtStartup); - - theApp.m_bHiColorIcons = m_nAppLook == 1 || m_nAppLook == 2; - - CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, AfxGetMainWnd ()); - if (pMainFrame != NULL) - { - pMainFrame->OnChangeLook (); - } -} - -void CAppLookDlg::OnAppLook() -{ - UpdateData (); - - m_wndStyle2007.EnableWindow (m_nAppLook == 2); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/AppLookDlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/AppLookDlg.h deleted file mode 100644 index fdb54dd27cab2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/AppLookDlg.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CAppLookDlg dialog - -class CAppLookDlg : public CDialog -{ -// Construction -public: - CAppLookDlg(BOOL bStartup, CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CAppLookDlg) - enum { IDD = IDD_APP_LOOK }; - CComboBox m_wndStyle2007; - CButton m_wndOK; - CButton m_wndCancel; - int m_nAppLook; - BOOL m_bShowAtStartup; - int m_nStyle2007; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAppLookDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CAppLookDlg) - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void OnApply(); - afx_msg void OnAppLook(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - const BOOL m_bStartup; - - void SetLook (); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/MainFrm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/MainFrm.h deleted file mode 100644 index dfec9c247502b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/MainFrm.h +++ /dev/null @@ -1,109 +0,0 @@ -// -// mainfrm.h : interface of the CMainFrame class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "formatba.h" -#include "ruler.h" -#include "taskpane.h" - -// -class CMainFrame : public CFrameWndEx -{ -protected: // create from serialization only - CMainFrame(); - DECLARE_DYNCREATE(CMainFrame) - -// Attributes -public: - HICON m_hIconDoc; - HICON m_hIconText; - HICON m_hIconWrite; - HICON GetIcon(int nDocType); - -// Operations -public: - void UpdateMRUFilesList () - { - m_wndTaskPane.UpdateMRUFilesList (); - } - - void OnChangeLook (); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMainFrame) - public: - virtual void ActivateFrame(int nCmdShow = -1); - virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL); - protected: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - - virtual BOOL OnShowPopupMenu (CMFCPopupMenu* pMenuPopup); - virtual BOOL OnTearOffMenu (CMFCPopupMenu* pMenuPopup, CPane* pBar); - -protected: - void AdjustObjectSubmenu (CMFCPopupMenu* pMenuPopup); - void AdjustColorsMenu (CMFCPopupMenu* pMenuPopup, UINT uiId); - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -public: - CMFCMenuBar m_wndMenuBar; - CMFCToolBar m_wndToolBar; - CMFCStatusBar m_wndStatusBar; - CFormatBar m_wndFormatBar; - CRulerBar m_wndRulerBar; - CTaskPane m_wndTaskPane; - -protected: // control bar embedded members - BOOL CreateMenuBar(); - BOOL CreateToolBar(); - BOOL CreateFormatBar(); - BOOL CreateStatusBar(); - BOOL CreateRulerBar(); - BOOL CreateTaskPane (); - -// Generated message map functions -protected: - //{{AFX_MSG(CMainFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSysColorChange(); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnMove(int x, int y); - afx_msg void OnHelpFinder(); - afx_msg void OnDropFiles(HDROP hDropInfo); - afx_msg void OnFontChange(); - afx_msg BOOL OnQueryNewPalette(); - afx_msg void OnPaletteChanged(CWnd* pFocusWnd); - afx_msg void OnDevModeChange(LPTSTR lpDeviceName); - afx_msg void OnViewCustomize(); - afx_msg void OnViewFullScreen(); - //}}AFX_MSG - afx_msg LRESULT OnBarState(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnOpenMsg(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnHelpCustomizeToolbars(WPARAM wp, LPARAM lp); - afx_msg LRESULT OnStartCustomize(WPARAM wp, LPARAM lp); - afx_msg LRESULT OnToolbarCreateNew(WPARAM,LPARAM); - afx_msg LRESULT OnGetDocumentColors(WPARAM,LPARAM); - afx_msg void OnDummy(); - afx_msg void OnAskQuestion(); - DECLARE_MESSAGE_MAP() -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/Resource.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/Resource.h deleted file mode 100644 index 6f0d73fcf2cc6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/Resource.h +++ /dev/null @@ -1,256 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by wordpad.rc -// -#define IDC_APPLY 3 -#define IDR_SRVR_INPLACE 4 -#define IDR_SRVR_EMBEDDED 5 -#define IDR_CNTR_INPLACE 6 -#define IDP_OLE_INIT_FAILED 100 -#define IDP_FAILED_TO_CREATE 102 -#define IDS_INVALID_MEASUREMENT 103 -#define IDS_PLEASE_WAIT 104 -#define IDS_COMPLETE 105 -#define IDS_SAVE_UNSUPPORTED 106 -#define IDS_CLOSE_TEXT 107 -#define IDS_RICHED_LOAD_FAIL 108 -#define IDS_DEFAULTFONT 109 -#define IDS_TF_BUTTONS 110 -#define IDC_COMBO_ALIGNMENT 111 -#define IDS_DEFAULTTEXTFONT 111 -#define IDS_SAVE_FORMAT_TEXT 112 -#define IDS_SAVE_FORMAT 113 -#define IDS_SAVING 113 -#define IDS_CLIP_RTF 114 -#define IDS_FORMATTING 115 -#define IDS_LEFT 116 -#define IDS_CENTER 117 -#define IDS_RIGHT 118 -#define IDS_NOWRAP 119 -#define IDS_MEASUREMENT_RANGE 119 -#define IDS_WRAPTOWINDOW 120 -#define IDS_INVALID_NUMBER 120 -#define IDS_WRAPTORULER 121 -#define IDS_INVALID_FONTSIZE 121 -#define IDS_INCHES 122 -#define IDS_CENTIMETERS 123 -#define IDS_POINTS 124 -#define IDS_PICAS 125 -#define IDS_WORD6_WARNING 126 -#define IDS_WORD6_WARNING_BUTTONS 127 -#define IDR_MAINFRAME 128 -#define IDS_TEXT_DOC 129 -#define IDS_RICHTEXT_DOC 130 -#define IDB_BITMAP_TT 130 -#define IDS_WRITE_DOC 131 -#define IDB_RULER_BLOCK 131 -#define IDS_ALL_DOC 132 -#define IDB_RULER_BLOCKM 132 -#define IDS_WINWORD6_DOC 133 -#define IDB_RULER_DOWN 133 -#define IDS_WINWORD2_DOC 134 -#define IDB_RULER_DOWNM 134 -#define IDB_RULER_TAB 135 -#define IDS_EXE_DOC 135 -#define IDB_RULER_TABM 136 -#define IDS_FILE_EXISTS 136 -#define IDB_RULER_UP 137 -#define IDS_MAPILOAD_FAILED 137 -#define IDS_OEMTEXT_DOC 137 -#define IDB_RULER_UPM 138 -#define IDS_CLIP_TEXT 138 -#define IDB_FORMATBAR 139 -#define IDS_CLIP_FILENAME 139 -#define IDR_FORMATBAR 139 -#define IDR_MAINFRAME1 140 -#define IDB_FORMATBAR_BIG 141 -#define IDR_FORMATBAR_BIG 141 -#define IDR_MAINFRAME_BIG 142 -#define IDD_FORMAT_PARA 143 -#define IDR_MAINFRAME1_BIG 143 -#define IDR_SRVR_INPLACE_BIG 144 -#define IDD_FORMAT_TAB 145 -#define IDD_LISTDIALOG 147 -#define IDD_OPTIONS 148 -#define IDS_DT1 149 -#define IDD_PAGE_SETUP_DIALOG 150 -#define IDS_DT2 150 -#define IDR_MENU1 151 -#define IDS_DT3 151 -#define IDD_DATEDIALOG 151 -#define IDS_DT4 152 -#define IDR_TEXT_POPUP 152 -#define IDS_DT5 153 -#define IDS_DT6 154 -#define IDI_ICON_DOC 154 -#define IDS_DT7 155 -#define IDI_ICON_WRITE 155 -#define IDS_DT8 156 -#define IDS_DT9 157 -#define IDD_SPLASH 157 -#define IDS_DT10 158 -#define IDD_OPTIONS_UNITS 158 -#define IDS_DT11 159 -#define IDD_OPTIONS_WRAP 159 -#define IDS_DT12 160 -#define IDD_OPTIONS_MARGINS 160 -#define IDD_FILENEWDIALOG 160 -#define IDS_DT13 161 -#define IDB_BITMAP48 162 -#define IDB_BITMAP_PRINTER 163 -#define IDS_FINISHED_SEARCH 164 -#define IDC_FONTNAME 165 -#define IDI_ICON_TEXT 165 -#define IDC_FONTSIZE 166 -#define IDS_TITLE_FORMATBAR 167 -#define IDB_PRINTER 167 -#define IDB_FONTTYPE 167 -#define IDS_TITLE_TOOLBAR 168 -#define IDS_INCH1_ABBREV 169 -#define IDS_INCH2_ABBREV 170 -#define IDS_INCH3_ABBREV 171 -#define IDS_INCH4_ABBREV 172 -#define IDR_TOOLBAR_IMAGES 172 -#define IDS_CM_ABBREV 173 -#define IDR_TOOLBAR_IMAGES_BIG 173 -#define IDS_POINT_ABBREV 174 -#define IDS_PICA_ABBREV 175 -#define IDS_NOMORETABS 176 -#define IDS_MAPI_FAIL 177 -#define IDS_ERRSPACE 178 -#define IDS_CANT_LOAD 179 -#define IDS_TOOMANYFILES 180 -#define IDD_APP_LOOK 180 -#define IDS_DIRFULL 181 -#define IDS_SHAREVIOLATION 182 -#define IDB_TASKS 182 -#define IDS_TEXT_OPTIONS 183 -#define IDS_RTF_OPTIONS 184 -#define IDS_WORD6_OPTIONS 185 -#define IDS_OPTIONS 186 -#define IDR_TOOLBAR_IMAGES_HC 186 -#define IDS_WRITE_OPTIONS 187 -#define IDB_MAINFRAME_HC 187 -#define IDS_EMBEDDED_OPTIONS 188 -#define IDB_TASKS_HC 188 -#define IDS_TEXT_DOCUMENT 189 -#define IDB_TASKSPANE_TOOLBAR 189 -#define IDS_RTF_DOCUMENT 190 -#define IDR_BORDER_TYPE 190 -#define IDS_WORD6_DOCUMENT 191 -#define IDS_WRITEPROTECT 192 -#define IDR_BORDER_PALETTE 192 -#define IDS_TITLE_MENUBAR 193 -#define IDS_ABOUT_INFO 194 -#define IDC_EDIT_LEFT 1000 -#define IDC_EDIT_RIGHT 1001 -#define IDC_EDIT_FIRST_LINE 1002 -#define IDC_BUTTON_SET 1005 -#define IDC_EDIT_BM 1005 -#define IDC_BUTTON_CLEAR 1006 -#define IDC_EDIT_LM 1006 -#define IDC_BUTTON_CLEARALL 1007 -#define IDC_EDIT_RM 1007 -#define IDC_STATIC_HEADING 1009 -#define IDC_COMBO_WRAP 1011 -#define IDC_COMBO_UNITS 1012 -#define IDC_APP_LOOK1 1012 -#define IDC_APP_LOOK2 1013 -#define IDC_APP_LOOK3 1014 -#define IDC_SHOW_AT_STARTUP 1015 -#define IDC_EDIT_TM 1016 -#define IDC_TEXT_ALIGNMENT 1017 -#define IDC_LISTDIALOG_LIST 1018 -#define IDC_DATEDIALOG_LIST 1018 -#define IDC_COMBO1 1019 -#define IDC_TEXT_WRAP 1020 -#define IDC_TEXT_UNITS 1021 -#define IDC_BOX 1022 -#define IDC_BIGICON 1023 -#define IDC_UNITS_IN 1024 -#define IDC_UNITS_CM 1025 -#define IDC_WRAP_RULER 1025 -#define IDC_UNITS_PT 1026 -#define IDC_WRAP_WINDOW 1026 -#define IDC_UNITS_PI 1027 -#define IDC_WRAP_NONE 1027 -#define IDC_CHECK_TOOLBAR 1028 -#define IDC_CHECK_FORMATBAR 1029 -#define IDC_WORDSEL 1029 -#define IDC_CHECK_RULERBAR 1030 -#define IDC_CHECK_STATUSBAR 1031 -#define IDC_BOXT 1032 -#define IDC_STYLE2007 1033 -#define ID_CANCEL_EDIT_CNTR 32768 -#define ID_CANCEL_EDIT_SRVR 32769 -#define ID_PAGE_SETUP 32771 -#define ID_COLOR_TEAROFF 32772 -#define ID_FREE_TEAROFF1 32773 -#define ID_FREE_TEAROFF2 32774 -#define ID_BORDER_TEAROFF 32775 -#define ID_VIEW_OPTIONS 32776 -#define ID_INSERT_BULLET 32777 -#define ID_INSERT_DATE_TIME 32778 -#define ID_FORMAT_PARAGRAPH 32780 -#define ID_FORMAT_TABS 32781 -#define ID_CHAR_BOLD 32799 -#define ID_CHAR_ITALIC 32800 -#define ID_CHAR_COLOR 32801 -#define ID_CHAR_UNDERLINE 32802 -#define ID_PARA_LEFT 32803 -#define ID_PARA_CENTER 32804 -#define ID_PARA_RIGHT 32805 -#define ID_PEN_PERIOD 32807 -#define ID_PEN_SPACE 32808 -#define ID_PEN_BACKSPACE 32809 -#define ID_PEN_NEWLINE 32810 -#define ID_OLE_VERB_POPUP 32811 -#define ID_PEN_TOGGLE 32812 -#define ID_PEN_LENS 32813 -#define ID_PEN_TAB 32814 -#define ID_VIEW_CUSTOMIZE 32816 -#define ID_VIEW_USER_TOOLBAR1 32819 -#define ID_VIEW_USER_TOOLBAR2 32820 -#define ID_VIEW_USER_TOOLBAR3 32821 -#define ID_VIEW_USER_TOOLBAR4 32822 -#define ID_VIEW_USER_TOOLBAR5 32823 -#define ID_VIEW_USER_TOOLBAR6 32824 -#define ID_VIEW_USER_TOOLBAR7 32825 -#define ID_VIEW_USER_TOOLBAR8 32826 -#define ID_VIEW_USER_TOOLBAR9 32827 -#define ID_VIEW_USER_TOOLBAR10 32828 -#define ID_VIEW_FULLSCREEN 32883 -#define ID_VIEW_TOOLBARS 32885 -#define ID_VIEW_TASK_PANE 32886 -#define ID_VIEW_APP_LOOK 32950 -#define ID_BORDER_1 32952 -#define ID_BORDER_2 32953 -#define ID_BORDER_3 32954 -#define ID_BORDER_4 32955 -#define ID_BORDER_5 32956 -#define ID_BORDER_6 32957 -#define ID_BORDER_7 32958 -#define ID_BORDER_8 32959 -#define ID_BORDER_9 32960 -#define ID_BORDER_10 32961 -#define ID_BORDER_11 32962 -#define ID_BORDER_12 32963 -#define ID_BORDER_13 32964 -#define ID_VIEW_FULL_SCREEN 32965 -#define ID_HELP_FIND 32968 -#define ID_COLOR_AUTOMATIC 57876 -#define ID_VIEW_FORMATBAR 59396 -#define ID_VIEW_RULER 59397 -#define ID_DUMMY 59398 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 194 -#define _APS_NEXT_COMMAND_VALUE 32969 -#define _APS_NEXT_CONTROL_VALUE 1034 -#define _APS_NEXT_SYMED_VALUE 111 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/Snippets.txt b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/Snippets.txt deleted file mode 100644 index 8c0283a183424..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/Snippets.txt +++ /dev/null @@ -1,14 +0,0 @@ -File Snippet # -------------------------------------------------------------------------- -ipframe.cpp 1 -mainfrm.cpp 2 -MainFrm.h: CFrameWndEx 3 -mainfrm.cpp: CFrameWndEx 4 -formatba.h:CMFCColorMenuButton 5 -formatba.cpp:CMFCColorMenuButton 6 -formatba.cpp: CMFCToolBarFontComboBox: constructor 7 -wordpvw.cpp: CMFCToolBarFontSizeComboBox 8 -formatba.cpp: CMFCToolBarMenuButton: constructor 9 -formatba.cpp: CMFCToolBarMenuButton 10 -mainfrm.cpp: CMFCToolBarsCustomizeDialog::AddToolBar 11 -wordpad.cpp: CMenuTearOffManager 12 \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/TaskPane.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/TaskPane.cpp deleted file mode 100644 index 3d5ead80ec492..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/TaskPane.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// -// TaskPane.cpp : implementation file -// - -#include "stdafx.h" -#include "wordpad.h" -#include "TaskPane.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTaskPane - -CTaskPane::CTaskPane() -{ - m_nDocumentsGroup = -1; -} - -CTaskPane::~CTaskPane() -{ -} - - -BEGIN_MESSAGE_MAP(CTaskPane, CMFCTasksPane) - //{{AFX_MSG_MAP(CTaskPane) - ON_WM_CREATE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CTaskPane message handlers - -int CTaskPane::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMFCTasksPane::OnCreate(lpCreateStruct) == -1) - return -1; - - SetIconsList (IDB_TASKS, 16); - - SetCaption (_T("Tasks Pane")); - SetPageCaption (0, _T("New document")); - - m_nDocumentsGroup = AddGroup (_T("Open a document"), FALSE, TRUE); - - // Add MRU list - AddMRUFilesList (m_nDocumentsGroup); - AddTask (m_nDocumentsGroup, _T("More Documents..."), 0, ID_FILE_OPEN); - - int nPage1Gr2 = AddGroup (_T("New")); - - AddTask (nPage1Gr2, _T("Blank Document"), 1, ID_FILE_NEW); - - AddTask (nPage1Gr2, _T("Blank Web Page"), 2, ID_DUMMY); - AddSeparator (nPage1Gr2); - AddTask (nPage1Gr2, _T("Blank Email message"), 3, ID_DUMMY); - - int nPage1Gr3 = AddGroup (_T("New from existing document")); - - AddTask (nPage1Gr3, _T("Choose document..."), 4, ID_DUMMY); - - int nPage1Gr4 = AddGroup (_T("New from template")); - - AddTask (nPage1Gr4, _T("General Templates..."), 5, ID_DUMMY); - AddTask (nPage1Gr4, _T("Templates on my Web Sites..."), 6, ID_DUMMY); - AddTask (nPage1Gr4, _T("Templates on Microsoft.com..."), 7, ID_DUMMY); - - int nPage1Gr5 = AddGroup (_T(""), TRUE /* Group at bottom */); - - AddTask (nPage1Gr5, _T("Add Network Place..."), 8, ID_DUMMY); - AddTask (nPage1Gr5, _T("Help..."), 9, ID_DUMMY); - AddLabel (nPage1Gr5, _T("Label")); - - //-------- - // Page 2: - //-------- - int nPage2 = AddPage (_T("Basic Search")); - - int nPage2Gr1 = AddGroup (nPage2, _T("Search for:")); - - AddTask (nPage2Gr1, _T("Search Tips..."), 9, ID_DUMMY); - - int nPage2Gr3 = AddGroup (nPage2, _T("See also:")); - - AddTask (nPage2Gr3, _T("Advanced Search"), 9, ID_DUMMY); - AddTask (nPage2Gr3, _T("Find in this document..."), 9, ID_DUMMY); - - //-------- - // Page 3: - //-------- - int nPage3 = AddPage (_T("Custom page")); - - int nPage3Gr1 = AddGroup (nPage3, _T("Folders")); - - if (!CreateTreeWindow()) - { - TRACE0("Failed to create the custom window\n"); - return -1; // fail to create - } - - AddWindow (nPage3Gr1, m_wndTree.GetSafeHwnd (), 65); - AddTask (nPage3Gr1, _T("My favorites..."), 0, ID_DUMMY); - - int nPage3Gr2 = AddGroup (nPage3, _T("Enter your text")); - - CRect rectDummy; - rectDummy.SetRectEmpty (); - DWORD dwEditStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | - ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_WANTRETURN; - m_Font.CreateStockObject (DEFAULT_GUI_FONT); - if (!m_wndEdit.Create (dwEditStyle, rectDummy, this, (UINT)-1)) - { - TRACE0("Failed to create the edit window\n"); - return -1; // fail to create - } - m_wndEdit.SetFont (&m_Font); - m_wndEdit.SetWindowText( - _T("This is the standard multiline Edit Box.\r\nHere you can type your text.")); - - AddWindow (nPage3Gr2, m_wndEdit.GetSafeHwnd (), 65); - return 0; -} - -void CTaskPane::UpdateMRUFilesList () -{ - AddMRUFilesList (m_nDocumentsGroup); - RedrawWindow (); -} - -BOOL CTaskPane::CreateTreeWindow() -{ - CRect rectDummy (0, 0, 0, 0); - const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | - TVS_LINESATROOT | TVS_HASBUTTONS; - - if(!m_wndTree.Create (dwTreeStyle, rectDummy, this, (UINT)-1)) - { - TRACE0("Failed to create the custom window\n"); - return FALSE; // fail to create - } - - TCHAR szWinDir [MAX_PATH + 1]; - GetWindowsDirectory (szWinDir, MAX_PATH); - - SHFILEINFO sfi; - HIMAGELIST himSystem = (HIMAGELIST)SHGetFileInfo (szWinDir, - 0, - &sfi, - sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - int iIndex = sfi.iIcon; - - m_wndTree.SetImageList (CImageList::FromHandle (himSystem), TVSIL_NORMAL); - - HTREEITEM hRoot = m_wndTree.InsertItem (_T("Folders"), iIndex, iIndex); - m_wndTree.InsertItem (_T("Folder 1"), iIndex, iIndex, hRoot); - m_wndTree.InsertItem (_T("Folder 2"), iIndex, iIndex, hRoot); - m_wndTree.InsertItem (_T("Folder 3"), iIndex, iIndex, hRoot); - m_wndTree.InsertItem (_T("Folder 4"), iIndex, iIndex, hRoot); - m_wndTree.Expand (hRoot, TVE_EXPAND); - - m_wndTree.RedrawWindow (); - - return TRUE; -} - -void CTaskPane::UpdateIcons () -{ - SetIconsList (theApp.m_bHiColorIcons ? IDB_TASKS_HC : IDB_TASKS, 16); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/TaskPane.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/TaskPane.h deleted file mode 100644 index bec110165a9ee..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/TaskPane.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// TaskPane.h : header file -// - -#pragma once - -///////////////////////////////////////////////////////////////////////////// -// CTaskPane window - -class CTaskPane : public CMFCTasksPane -{ -// Construction -public: - CTaskPane(); - -// Attributes -protected: - int m_nDocumentsGroup; - CFont m_Font; - CTreeCtrl m_wndTree; - CEdit m_wndEdit; - -// Operations -public: - void UpdateMRUFilesList (); - void UpdateIcons (); - -// Overrides -public: - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CTaskPane) - //}}AFX_VIRTUAL - -protected: - BOOL CreateTreeWindow(); - -// Implementation -public: - virtual ~CTaskPane(); - - // Generated message map functions -protected: - //{{AFX_MSG(CTaskPane) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/buttondi.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/buttondi.cpp deleted file mode 100644 index ce413fa5736c6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/buttondi.cpp +++ /dev/null @@ -1,362 +0,0 @@ -// -// buttondi.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "resource.h" -#include "buttondi.h" -#include "strings.h" -#include "wordpad.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -#ifndef DS_CONTEXTHELP -#define DS_CONTEXTHELP 0x2000L -#endif - -static const int nFontSize = 10; - -///////////////////////////////////////////////////////////////////////////// -// CButtonDialog dialog - -int CButtonDialog::DisplayMessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, - LPCTSTR lpszButtons, WORD wStyle, int nDef, int nCancel, - DWORD* pHelpIDs, CWnd* pParentWnd) -{ - CButtonDialog dlg(lpszText, lpszCaption, lpszButtons, wStyle, pHelpIDs, - pParentWnd); - dlg.SetDefault(nDef); - dlg.SetCancel(nCancel); - return (int) dlg.DoModal(); -} - -CButtonDialog::CButtonDialog(LPCTSTR lpszText, LPCTSTR lpszCaption, - LPCTSTR lpszButtons, WORD wStyle, DWORD* pHelpIDs , - CWnd* pParentWnd) : CCSDialog() -{ - - ASSERT(lpszText != NULL); - ASSERT(lpszCaption != NULL); - if (HIWORD(lpszText) == NULL) - VERIFY(m_strText.LoadString(LOWORD((UINT_PTR)lpszText))); - else - m_strText = lpszText; - if (HIWORD(lpszCaption) == NULL) - VERIFY(m_strCaption.LoadString(LOWORD((UINT_PTR)lpszCaption))); - else - m_strCaption = lpszCaption; - if (lpszButtons != NULL) - AddButtons(lpszButtons); - - m_pParentWnd = pParentWnd; - m_nDefButton = 0; - m_nCancel = -1; - m_pButtons = NULL; - m_wStyle = wStyle; - m_nBaseID = nFontSize; // don't use IDOK, IDCANCEL, etc - m_hDlgTmp = NULL; - - LOGFONT lf; - memcpy(&lf, &theApp.m_lf, sizeof(LOGFONT)); - lf.lfHeight = -nFontSize; - lf.lfWidth = 0; - lf.lfWeight = FW_NORMAL; - VERIFY(m_font.CreateFontIndirect(&lf)); - -// m_font.CreateFont(-nFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, -// FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, -// DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, szFontName); - m_pHelpIDs = pHelpIDs; -} - -CButtonDialog::~CButtonDialog() -{ - delete [] m_pButtons; - if (m_hDlgTmp != NULL) - GlobalFree(m_hDlgTmp); -} - -BEGIN_MESSAGE_MAP(CButtonDialog, CCSDialog) - //{{AFX_MSG_MAP(CButtonDialog) - ON_WM_CREATE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CButtonDialog message handlers - -int CButtonDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (m_pHelpIDs != NULL) - { - for (int i=0;istyle = DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU; - if (theApp.m_bWin4) - lpDlgTmp->style |= DS_CONTEXTHELP; - lpDlgTmp->dwExtendedStyle = 0; - lpDlgTmp->cdit = 0; - lpDlgTmp->x = 0; - lpDlgTmp->y = 0; - lpDlgTmp->cx = 100; - lpDlgTmp->cy = 100; - - LPWSTR lpStr = (LPWSTR)(lpDlgTmp + 1); /* Move ptr to the variable fields */ - - *lpStr++ = 0; /* No Menu resource for Message Box */ - *lpStr++ = 0; /* No Class name for MessageBox */ - - int nLen = m_strCaption.GetLength(); - wcscpy(lpStr, T2CW(m_strCaption)); - - lpStr += nLen+1; - WORD* pWord = (WORD*)lpStr; - *pWord = 10; // 10 pt font - pWord++; - lpStr = (LPWSTR) pWord; - - wcscpy(lpStr, T2W(theApp.m_lf.lfFaceName)); -} - -///////////////////////////////////////////////////////////////////////////// -// CButtonDialog overridables - -BOOL CButtonDialog::OnCommand(WPARAM wParam, LPARAM /*lParam*/) -{ - if (wParam == IDCANCEL && m_nCancel != -1) - { - EndDialog(m_nCancel); - return TRUE; - } - if (::GetDlgItem(m_hWnd, (int)wParam)==NULL) - return FALSE; - EndDialog((int)wParam-m_nBaseID); - return TRUE; -} - -INT_PTR CButtonDialog::DoModal() -{ - ASSERT(m_strArray.GetSize() != 0); - if (m_strArray.GetSize() == 0) - return (m_nCancel != -1) ? m_nCancel : 0; - - // compute size of header - // Fixed portions of DLG template header = sizeof(DLGTEMPLATE); - // One null byte for menu name and one for class name = 2 - // Caption text plus NULL = m_strCaption.GetLength()+1 - int nSize = sizeof(DLGTEMPLATE); - nSize += (2 + m_strCaption.GetLength()+1+lstrlen(theApp.m_lf.lfFaceName)+1)*2 +sizeof(WORD); - m_hDlgTmp = GlobalAlloc(GPTR, nSize); - if (m_hDlgTmp == NULL) - return IDCANCEL; - LPDLGTEMPLATE lpDlgTmp = (LPDLGTEMPLATE)GlobalLock(m_hDlgTmp); - FillInHeader(lpDlgTmp); - GlobalUnlock(m_hDlgTmp); - InitModalIndirect(m_hDlgTmp); - - return CCSDialog::DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CButtonDialog implementation - -void CButtonDialog::PositionControls() -{ - CSize sizeBase = GetBaseUnits(); - int nButtonHeight = (sizeBase.cy*14)/8; - int nHeight = 0; - int nSep,nLeftMargin,nRightMargin,nTopMargin,nBottomMargin; - int nButtonAdj; - int nWidth = 0; - int i = 0; - CRect rectText; - - // a) 5/8 screen Width - // b) Caption - // c) nLeftMargin ICON nSep TEXT nRightMargin - // d) nLeftMargin Button1 nSep Button2 ... nRightMargin - // client width is max(b,d, min(c,a)) - - CSize sizeIcon(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); - nSep = sizeIcon.cx/2; - nLeftMargin = nSep; - nRightMargin = nSep; - nTopMargin = nSep; - nBottomMargin = nSep; - - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(&m_font); - - nButtonAdj = dc.GetTextExtent(_T("XXX"),3).cx; // padding on buttons - - int nScreenWidth58 = dc.GetDeviceCaps(HORZRES)*5/8; - int nCaptionWidth = dc.GetTextExtent(m_strCaption, m_strCaption. - GetLength()).cx; - CSize sizeText = dc.GetTextExtent(m_strText,m_strText.GetLength()); - int nTextIconWidth = nLeftMargin+sizeIcon.cx+nSep+sizeText.cx+nRightMargin; - int nButtons = (int)m_strArray.GetSize(); - int nButtonsWidth = nLeftMargin+nRightMargin+(nButtons-1)*nSep; - for (i=0;i nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep) - { - sizeText.cx = nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep; -// int nTextWidth = nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep; -// rectText.SetRect(0, 0, nTextWidth, 32767); - rectText.SetRect(0, 0, sizeText.cx, 32767); - /* Ask DrawText for the right cy */ - sizeText.cy = dc.DrawText(m_strText, m_strText.GetLength(), &rectText, - DT_CALCRECT | DT_WORDBREAK | DT_EXPANDTABS | DT_NOPREFIX); - } - - m_staticText.SetWindowPos(NULL, nSep+sizeIcon.cx+nSep, nTopMargin, - sizeText.cx, sizeText.cy, SWP_NOZORDER); - - sizeText.cy = max(sizeText.cy, sizeIcon.cy); // at least icon height - nHeight = nTopMargin + sizeText.cy + nSep + nButtonHeight + nBottomMargin; - - CRect rect; - rect.left = (nWidth - (nButtonsWidth - nLeftMargin - nRightMargin))/2; - rect.top = nTopMargin + sizeText.cy + nSep; - rect.bottom = rect.top + nButtonHeight; - - for (i=0;iDeleteMenu(SC_CLOSE, MF_BYCOMMAND); - } - dc.SelectObject(pOldFont); -} - -CSize CButtonDialog::GetBaseUnits() -{ - CDisplayIC dc; - CFont* pFont = dc.SelectObject(&m_font); - TEXTMETRIC tm; - VERIFY(dc.GetTextMetrics(&tm)); - dc.SelectObject(pFont); - return CSize(tm.tmAveCharWidth, tm.tmHeight); -} - -LPCTSTR CButtonDialog::GetIconID(WORD wFlags) -{ - LPCTSTR lpszIcon = NULL; - wFlags &= MB_ICONMASK; - if (wFlags == MB_ICONHAND) - lpszIcon = IDI_HAND; - else if (wFlags == MB_ICONQUESTION) - lpszIcon = IDI_QUESTION; - else if (wFlags == MB_ICONEXCLAMATION) - lpszIcon = IDI_EXCLAMATION; - else if (wFlags == MB_ICONASTERISK) - lpszIcon = IDI_ASTERISK; - return lpszIcon; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/buttondi.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/buttondi.h deleted file mode 100644 index 7a7e8665b1974..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/buttondi.h +++ /dev/null @@ -1,68 +0,0 @@ -// buttondi.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CButtonDialog dialog - -class CButtonDialog : public CCSDialog -{ -// Construction -public: - CButtonDialog(LPCTSTR lpszText, LPCTSTR lpszCaption, LPCTSTR lpszButtons, - WORD wStyle, DWORD* pHelpIDs = NULL, CWnd* pParentWnd = NULL); - ~CButtonDialog(); - -// Attributes - CFont m_font; -// Operations - static int DisplayMessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, - LPCTSTR lpszButtons, WORD wStyle, int nDef = 0, int nCancel = -1, - DWORD* pHelpIDs = NULL, CWnd* pParentWnd = NULL); - - void AddButton(CString& strButton) { m_strArray.Add(strButton);} - void AddButtons(LPCTSTR lpszButton); - void SetCancel(int nCancel) - { ASSERT(nCancel < m_strArray.GetSize()); m_nCancel = nCancel;} - void SetDefault(int nDef) - { ASSERT(nDef < m_strArray.GetSize()); m_nDefButton = nDef;} - void FillInHeader(LPDLGTEMPLATE lpDlgTmp); - -// Overridables - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - virtual INT_PTR DoModal(); - -// Implementation -protected: - virtual const DWORD* GetHelpIDs() {return m_pHelpIDs;} - DWORD* m_pHelpIDs; - int m_nDefButton; - int m_nCancel; - HGLOBAL m_hDlgTmp; - UINT m_nBaseID; - WORD m_wStyle; - CButton* m_pButtons; - CStatic m_staticIcon; - CStatic m_staticText; - CString m_strCaption; - CString m_strText; - CStringArray m_strArray; - CSize GetBaseUnits(); - LPCTSTR GetIconID(WORD wFlags); - void PositionControls(); - - // Generated message map functions - //{{AFX_MSG(CButtonDialog) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/chicdial.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/chicdial.cpp deleted file mode 100644 index 57ae4d4e10811..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/chicdial.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// -// chicdial.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CCSDialog dialog - -CCSDialog::CCSDialog(UINT nIDTemplate, CWnd* pParentWnd) - : CDialog(nIDTemplate, pParentWnd) -{ -} - -CCSDialog::CCSDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd) - : CDialog(lpszTemplateName, pParentWnd) -{ -} - -CCSDialog::CCSDialog() : CDialog() -{ -} - -BEGIN_MESSAGE_MAP(CCSDialog, CDialog) - //{{AFX_MSG_MAP(CCSDialog) - //}}AFX_MSG_MAP - ON_MESSAGE(WM_HELP, OnHelp) - ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu) -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CCSDialog message handlers - -LRESULT CCSDialog::OnHelp(WPARAM, LPARAM lParam) -{ - ::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, AfxGetApp()->m_pszHelpFilePath, - HELP_WM_HELP, (ULONG_PTR)(LPVOID)GetHelpIDs()); - return 0; -} - -LRESULT CCSDialog::OnHelpContextMenu(WPARAM wParam, LPARAM) -{ - ::WinHelp((HWND)wParam, AfxGetApp()->m_pszHelpFilePath, - HELP_CONTEXTMENU, (ULONG_PTR)(LPVOID)GetHelpIDs()); - return 0; -} - -BOOL CCSDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - ModifyStyleEx(0, WS_EX_CONTEXTHELP); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -///////////////////////////////////////////////////////////////////////////// -// CCSPropertyPage - -CCSPropertyPage::CCSPropertyPage(UINT nIDTemplate, UINT nIDCaption) - : CPropertyPage(nIDTemplate, nIDCaption) -{ -} - -CCSPropertyPage::CCSPropertyPage(LPCTSTR lpszTemplateName, - UINT nIDCaption) : CPropertyPage(lpszTemplateName, nIDCaption) -{ -} - -BEGIN_MESSAGE_MAP(CCSPropertyPage, CPropertyPage) - //{{AFX_MSG_MAP(CCSPropertyPage) - //}}AFX_MSG_MAP - ON_MESSAGE(WM_HELP, OnHelp) - ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu) -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CCSPropertyPage message handlers - -LRESULT CCSPropertyPage::OnHelp(WPARAM, LPARAM lParam) -{ - ::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, AfxGetApp()->m_pszHelpFilePath, - HELP_WM_HELP, (ULONG_PTR)(LPVOID)GetHelpIDs()); - return 0; -} - -LRESULT CCSPropertyPage::OnHelpContextMenu(WPARAM wParam, LPARAM) -{ - ::WinHelp((HWND)wParam, AfxGetApp()->m_pszHelpFilePath, - HELP_CONTEXTMENU, (ULONG_PTR)(LPVOID)GetHelpIDs()); - return 0; -} - -///////////////////////////////////////////////////////////////////////////// -// CCSPropertySheet - -BEGIN_MESSAGE_MAP(CCSPropertySheet, CPropertySheet) - //{{AFX_MSG_MAP(CCSPropertySheet) - //}}AFX_MSG_MAP - ON_MESSAGE(WM_HELP, OnHelp) - ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu) -END_MESSAGE_MAP() - -CCSPropertySheet::CCSPropertySheet(UINT nIDCaption, CWnd *pParentWnd, - UINT iSelectPage) : CPropertySheet(nIDCaption, pParentWnd, iSelectPage) -{ -} - -CCSPropertySheet::CCSPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd, - UINT iSelectPage) : CPropertySheet(pszCaption, pParentWnd, iSelectPage) -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CCSPropertySheet message handlers - -LRESULT CCSPropertySheet::OnHelp(WPARAM wParam, LPARAM lParam) -{ - GetActivePage()->SendMessage(WM_HELP, wParam, lParam); - return 0; -} - -LRESULT CCSPropertySheet::OnHelpContextMenu(WPARAM wParam, LPARAM lParam) -{ - GetActivePage()->SendMessage(WM_CONTEXTMENU, wParam, lParam); - return 0; -} - -BOOL CCSPropertySheet::PreCreateWindow(CREATESTRUCT& cs) -{ - cs.dwExStyle |= WS_EX_CONTEXTHELP; - return CPropertySheet::PreCreateWindow(cs); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/chicdial.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/chicdial.h deleted file mode 100644 index 1b5f834569ba4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/chicdial.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// chicdial.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CCSDialog dialog - -class CCSDialog : public CDialog -{ -// Construction -public: - CCSDialog(); - CCSDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL); - CCSDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL); - -// Implementation -protected: - virtual const DWORD* GetHelpIDs() = 0; - - // Generated message map functions - //{{AFX_MSG(CCSDialog) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - afx_msg LRESULT OnHelp(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnHelpContextMenu(WPARAM wParam, LPARAM lParam); - DECLARE_MESSAGE_MAP() -}; - -class CCSPropertyPage : public CPropertyPage -{ -// Construction -public: - CCSPropertyPage(UINT nIDTemplate, UINT nIDCaption = 0); - CCSPropertyPage(LPCTSTR lpszTemplateName, UINT nIDCaption = 0); - -// Implementation -protected: - virtual const DWORD* GetHelpIDs() = 0; - - // Generated message map functions - //{{AFX_MSG(CCSPropertyPage) - //}}AFX_MSG - afx_msg LRESULT OnHelp(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnHelpContextMenu(WPARAM wParam, LPARAM lParam); - DECLARE_MESSAGE_MAP() -}; - -class CCSPropertySheet : public CPropertySheet -{ -// Construction -public: - CCSPropertySheet(UINT nIDCaption, CWnd *pParentWnd = NULL, - UINT iSelectPage = 0); - CCSPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, - UINT iSelectPage = 0); -// Implementation -protected: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - // Generated message map functions - //{{AFX_MSG(CCSPropertySheet) - //}}AFX_MSG - afx_msg LRESULT OnHelp(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnHelpContextMenu(WPARAM wParam, LPARAM lParam); - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/cntritem.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/cntritem.cpp deleted file mode 100644 index 1880d41b251b5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/cntritem.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// cntritem.cpp : implementation of the CWordPadCntrItem class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" - -#include "wordpdoc.h" -#include "wordpvw.h" -#include "cntritem.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CWordPadCntrItem implementation - -IMPLEMENT_SERIAL(CWordPadCntrItem, CRichEditCntrItem, 0) - -CWordPadCntrItem::CWordPadCntrItem(REOBJECT *preo, CWordPadDoc* pContainer) - : CRichEditCntrItem(preo, pContainer) -{ -} - - -BOOL CWordPadCntrItem::OnShowPanes(CFrameWnd* pFrameWnd, BOOL bShow) -{ - CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST (CMDIFrameWndEx, pFrameWnd); - if (pMainFrame != NULL) - { - return pMainFrame->OnShowPanes (bShow); - } - else // Maybe, SDI frame... - { - CFrameWndEx* pFrame = DYNAMIC_DOWNCAST (CFrameWndEx, pFrameWnd); - if (pFrame != NULL) - { - return pFrame->OnShowPanes (bShow); - } - } - - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadCntrItem diagnostics - -#ifdef _DEBUG -void CWordPadCntrItem::AssertValid() const -{ - CRichEditCntrItem::AssertValid(); -} - -void CWordPadCntrItem::Dump(CDumpContext& dc) const -{ - CRichEditCntrItem::Dump(dc); -} -#endif - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/cntritem.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/cntritem.h deleted file mode 100644 index 58987c5c9c2b9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/cntritem.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// cntritem.h : interface of the CWordPadCntrItem class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CWordPadDoc; -class CWordPadView; - -class CWordPadCntrItem : public CRichEditCntrItem -{ - DECLARE_SERIAL(CWordPadCntrItem) - -// Constructors -public: - CWordPadCntrItem(REOBJECT* preo = NULL, CWordPadDoc* pContainer = NULL); - // Note: pContainer is allowed to be NULL to enable IMPLEMENT_SERIALIZE. - // IMPLEMENT_SERIALIZE requires the class have a constructor with - // zero arguments. Normally, OLE items are constructed with a - // non-NULL document pointer. - -// Attributes -public: - CWordPadDoc* GetDocument() - { return (CWordPadDoc*)COleClientItem::GetDocument(); } - CWordPadView* GetActiveView() - { return (CWordPadView*)COleClientItem::GetActiveView(); } - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CWordPadCntrItem) - public: - protected: - //}}AFX_VIRTUAL - - virtual BOOL OnShowPanes(CFrameWnd* pFrameWnd, BOOL bShow); - -// Implementation -public: -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif -}; - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/datedial.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/datedial.cpp deleted file mode 100644 index 7c050f7dcb690..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/datedial.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// -// datedial.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "datedial.h" -#include "helpids.h" -#include - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -SYSTEMTIME CDateDialog::m_time; -LCID CDateDialog::m_id; -CListBox* CDateDialog::m_pListBox = NULL; - -///////////////////////////////////////////////////////////////////////////// -// CDateDialog dialog - -const DWORD CDateDialog::m_nHelpIDs[] = -{ - IDC_DATEDIALOG_LIST, IDH_WORDPAD_TIMEDATE, - IDC_STATIC_HEADING, IDH_WORDPAD_TIMEDATE, - IDOK, IDH_WORDPAD_TIMEDATE, - IDCANCEL, IDH_WORDPAD_TIMEDATE, - 0 , 0 -}; - -CDateDialog::CDateDialog(CWnd* pParent /*=NULL*/) - : CCSDialog(CDateDialog::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDateDialog) - m_strSel = _T(""); - //}}AFX_DATA_INIT -} - - -void CDateDialog::DoDataExchange(CDataExchange* pDX) -{ - CCSDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDateDialog) - DDX_Control(pDX, IDC_DATEDIALOG_LIST, m_listBox); - DDX_LBString(pDX, IDC_DATEDIALOG_LIST, m_strSel); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CDateDialog, CCSDialog) - //{{AFX_MSG_MAP(CDateDialog) - ON_LBN_DBLCLK(IDC_DATEDIALOG_LIST, OnDblclkDatedialogList) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CDateDialog message handlers - -BOOL CDateDialog::OnInitDialog() -{ - CCSDialog::OnInitDialog(); - - m_pListBox = &m_listBox; // set static member - GetLocalTime(&m_time); - m_id = GetUserDefaultLCID(); - - EnumDateFormats(DateFmtEnumProc, m_id, DATE_SHORTDATE); - EnumDateFormats(DateFmtEnumProc, m_id, DATE_LONGDATE); - EnumTimeFormats(TimeFmtEnumProc, m_id, 0); - - m_pListBox = NULL; - m_listBox.SetCurSel(0); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -BOOL CALLBACK CDateDialog::DateFmtEnumProc(LPTSTR lpszFormatString) -{ - ASSERT(m_pListBox != NULL); - TCHAR buf[256]; - VERIFY(GetDateFormat(m_id, 0, &m_time, lpszFormatString, buf, 256)); - // we can end up with same format because a format with leading - // zeroes may be the same as one without when a number is big enough - // e.g. 09/10/94 9/10/94 are different but 10/10/94 and 10/10/94 are - // the same - if (m_pListBox->FindStringExact(-1,buf) == CB_ERR) - m_pListBox->AddString(buf); - return TRUE; -} - -BOOL CALLBACK CDateDialog::TimeFmtEnumProc(LPTSTR lpszFormatString) -{ - ASSERT(m_pListBox != NULL); - TCHAR buf[256]; - VERIFY(GetTimeFormat(m_id, 0, &m_time, lpszFormatString, buf, 256)); - // we can end up with same format because a format with leading - // zeroes may be the same as one without when a number is big enough - // e.g. 09/10/94 9/10/94 are different but 10/10/94 and 10/10/94 are - // the same - if (m_pListBox->FindStringExact(-1,buf) == CB_ERR) - m_pListBox->AddString(buf); - return TRUE; -} - -void CDateDialog::OnDblclkDatedialogList() -{ - OnOK(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/datedial.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/datedial.h deleted file mode 100644 index 92dc1cde37e57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/datedial.h +++ /dev/null @@ -1,56 +0,0 @@ -// -// datedial.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CDateDialog dialog - -class CDateDialog : public CCSDialog -{ -// Construction -public: - CDateDialog(CWnd* pParent = NULL); // standard constructor - -// Attributes - static SYSTEMTIME m_time; - static LCID m_id; - static CListBox* m_pListBox; - static BOOL CALLBACK DateFmtEnumProc(LPTSTR lpszFormatString); - static BOOL CALLBACK TimeFmtEnumProc(LPTSTR lpszFormatString); - -// Dialog Data - //{{AFX_DATA(CDateDialog) - enum { IDD = IDD_DATEDIALOG }; - CListBox m_listBox; - CString m_strSel; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDateDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - static const DWORD m_nHelpIDs[]; - virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} - - // Generated message map functions - //{{AFX_MSG(CDateDialog) - virtual BOOL OnInitDialog(); - afx_msg void OnDblclkDatedialogList(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ddxm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ddxm.cpp deleted file mode 100644 index c7c62b621fedd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ddxm.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// ddxm.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "ddxm.h" -#include "wordpad.h" -#include "resource.h" - -// this routine prints a floatingpoint number with 2 digits after the decimal -void PASCAL DDX_Twips(CDataExchange* pDX, int nIDC, int& value) -{ - HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); - TCHAR szT[64]; - - if (pDX->m_bSaveAndValidate) - { - ::GetWindowText(hWndCtrl, szT, sizeof(szT)); - if (szT[0] != NULL) // not empty - { - if (!theApp.ParseMeasurement(szT, value)) - { - AfxMessageBox(IDS_INVALID_MEASUREMENT,MB_OK|MB_ICONINFORMATION); - pDX->Fail(); // throws exception - } - theApp.PrintTwips(szT, value, 2); - theApp.ParseMeasurement(szT, value); - } - else // empty - value = INT_MAX; - } - else - { - // convert from twips to default units - if (value != INT_MAX) - { - theApp.PrintTwips(szT, value, 2); - SetWindowText(hWndCtrl, szT); - } - } -} - -void PASCAL DDV_MinMaxTwips(CDataExchange* pDX, int value, int minVal, int maxVal) -{ - ASSERT(minVal <= maxVal); - if (value < minVal || value > maxVal) - { - // "The measurement must be between %1 and %2." - if (!pDX->m_bSaveAndValidate) - { - TRACE0("Warning: initial dialog data is out of range.\n"); - return; // don't stop now - } - TCHAR szMin[32]; - TCHAR szMax[32]; - theApp.PrintTwips(szMin, minVal, 2); - theApp.PrintTwips(szMax, maxVal, 2); - CString prompt; - AfxFormatString2(prompt, IDS_MEASUREMENT_RANGE, szMin, szMax); - AfxMessageBox(prompt, MB_ICONEXCLAMATION, AFX_IDS_APP_TITLE); - prompt.Empty(); // exception prep - pDX->Fail(); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ddxm.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ddxm.h deleted file mode 100644 index d048dd238fe15..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ddxm.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include -void PASCAL DDX_Twips(CDataExchange* pDX, int nIDC, int& value); -void PASCAL DDV_MinMaxTwips(CDataExchange* pDX, int value, int minVal, int maxVal); -#define DDXM_BLANK INT_MAX diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/docopt.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/docopt.cpp deleted file mode 100644 index 55be2da95ed19..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/docopt.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// -// docopt.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "docopt.h" -#include "helpids.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDocOptPage property page - -const DWORD CDocOptPage::m_nHelpIDs[] = -{ - IDC_BOX, IDH_COMM_GROUPBOX, - IDC_WRAP_NONE, IDH_WORDPAD_WRAP_NO, - IDC_WRAP_WINDOW, IDH_WORDPAD_WRAP_WINDOW, - IDC_WRAP_RULER, IDH_WORDPAD_WRAP_RULER, - IDC_BOXT, IDH_COMM_GROUPBOX, - IDC_CHECK_TOOLBAR, IDH_WORDPAD_CHECK_TOOLBAR, - IDC_CHECK_FORMATBAR, IDH_WORDPAD_CHECK_FORMATBAR, - IDC_CHECK_STATUSBAR, IDH_WORDPAD_CHECK_STATUSBAR, - IDC_CHECK_RULERBAR, IDH_WORDPAD_CHECK_RULERBAR, - 0, 0 -}; - -CDocOptPage::CDocOptPage() : CCSPropertyPage(CDocOptPage::IDD) -{ - //{{AFX_DATA_INIT(CDocOptPage) - m_nWordWrap = -1; - m_bFormatBar = FALSE; - m_bRulerBar = FALSE; - m_bStatusBar = FALSE; - m_bToolBar = FALSE; - //}}AFX_DATA_INIT -} - -CDocOptPage::CDocOptPage(UINT nIDCaption) : - CCSPropertyPage(CDocOptPage::IDD, nIDCaption) -{ - m_nWordWrap = -1; - m_bFormatBar = FALSE; - m_bRulerBar = FALSE; - m_bStatusBar = FALSE; - m_bToolBar = FALSE; -} - -CDocOptPage::~CDocOptPage() -{ -} - -void CDocOptPage::DoDataExchange(CDataExchange* pDX) -{ - CCSPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDocOptPage) - DDX_Radio(pDX, IDC_WRAP_NONE, m_nWordWrap); - DDX_Check(pDX, IDC_CHECK_FORMATBAR, m_bFormatBar); - DDX_Check(pDX, IDC_CHECK_RULERBAR, m_bRulerBar); - DDX_Check(pDX, IDC_CHECK_STATUSBAR, m_bStatusBar); - DDX_Check(pDX, IDC_CHECK_TOOLBAR, m_bToolBar); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CDocOptPage, CCSPropertyPage) - //{{AFX_MSG_MAP(CDocOptPage) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CDocOptPage message handlers - -///////////////////////////////////////////////////////////////////////////// -// CEmbeddedOptPage property page - -CEmbeddedOptPage::CEmbeddedOptPage() : CDocOptPage(IDS_EMBEDDED_OPTIONS) -{ -} - -BOOL CEmbeddedOptPage::OnInitDialog() -{ - BOOL b = CDocOptPage::OnInitDialog(); - GetDlgItem(IDC_CHECK_STATUSBAR)->ShowWindow(SW_HIDE); - return b; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/docopt.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/docopt.h deleted file mode 100644 index 4a48cbedfd965..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/docopt.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// docopt.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CDocOptPage dialog - -class CDocOptPage : public CCSPropertyPage -{ -// Construction -public: - CDocOptPage(); - CDocOptPage(UINT nIDCaption); - ~CDocOptPage(); - -// Dialog Data - //{{AFX_DATA(CDocOptPage) - enum { IDD = IDD_OPTIONS_WRAP }; - int m_nWordWrap; - BOOL m_bFormatBar; - BOOL m_bRulerBar; - BOOL m_bStatusBar; - BOOL m_bToolBar; - //}}AFX_DATA - - -// Overrides - static const DWORD m_nHelpIDs[]; - virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(CDocOptPage) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - // Generated message map functions - //{{AFX_MSG(CDocOptPage) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -class CEmbeddedOptPage : public CDocOptPage -{ -// Construction -public: - CEmbeddedOptPage(); -// Overrides - BOOL OnInitDialog(); -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/doctype.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/doctype.cpp deleted file mode 100644 index 5e23f1843f45d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/doctype.cpp +++ /dev/null @@ -1,269 +0,0 @@ -// -// richdoc.cpp : implementation of the CRichEditDoc class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "resource.h" -#include "strings.h" - -#include "multconv.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -static const BYTE byteRTFPrefix[5] = {'{', '\\', 'r', 't', 'f'}; -static const BYTE byteWord2Prefix[4] = {0xDB, 0xA5, 0x2D, 0x00}; -static const BYTE byteCompFilePrefix[8] = {0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1}; -static const BYTE byteWrite1Prefix[2] = {0x31, 0xBE}; -static const BYTE byteWrite2Prefix[2] = {0x32, 0xBE}; -static const BYTE byteExePrefix[2] = {0x4D, 0x5A}; - -///////////////////////////////////////////////////////////////////////////// - -static BOOL IsConverterFormat(LPCTSTR pszConverter, LPCTSTR pszPathName); -static BOOL IsWord6(LPCTSTR pszConverter, LPCTSTR pszPathName); - -DocType doctypes[NUM_DOC_TYPES] = -{ - DECLARE_DOCTYPE(WINWORD2, FALSE, FALSE, FALSE, NULL), - DECLARE_DOCTYPE(WINWORD6, TRUE, FALSE, TRUE, szWordConverter), - DECLARE_DOCTYPE_SYN(WORDPAD, WINWORD6, TRUE, TRUE, FALSE, szWordConverter), - DECLARE_DOCTYPE(WRITE, TRUE, FALSE, FALSE, szWriteConverter), - DECLARE_DOCTYPE(RICHTEXT, TRUE, TRUE, FALSE, NULL), - DECLARE_DOCTYPE(TEXT, TRUE, TRUE, FALSE, NULL), - DECLARE_DOCTYPE(OEMTEXT, TRUE, TRUE, FALSE, NULL), - DECLARE_DOCTYPE(ALL, TRUE, FALSE, FALSE, NULL), - DECLARE_DOCTYPE(EXE, FALSE, FALSE, FALSE, NULL), - DECLARE_DOCTYPE_NULL(EMBEDDED, FALSE, FALSE, FALSE, NULL) -}; - -CString DocType::GetString(int nID) -{ - ASSERT(idStr != NULL); - CString str; - VERIFY(str.LoadString(idStr)); - CString strSub; - AfxExtractSubString(strSub, str, nID); - return strSub; -} - -static BOOL IsConverterFormat(LPCSTR pszConverter, LPCTSTR pszPathName) -{ - CConverter conv(pszConverter); - return conv.IsFormatCorrect(pszPathName); -} - -static BOOL IsLeadMatch(CFile& file, const BYTE* pb, UINT nCount) -{ - // check for match at beginning of file - BOOL b = FALSE; - BYTE* buf = new BYTE[nCount]; - - TRY - { - file.SeekToBegin(); - memset(buf, 0, nCount); - file.Read(buf, nCount); - if (memcmp(buf, pb, nCount) == 0) - b = TRUE; - } - END_TRY - - delete [] buf; - return b; -} - -static BOOL IsWord6(LPCTSTR pszPathName) -{ - USES_CONVERSION; - BOOL bRes = FALSE; - // see who created it - LPSTORAGE lpStorage; - SCODE sc = StgOpenStorage(T2COLE(pszPathName), NULL, - STGM_READ|STGM_SHARE_EXCLUSIVE, 0, 0, &lpStorage); - if (sc == NOERROR) - { - LPSTREAM lpStream; - sc = lpStorage->OpenStream(T2COLE(szSumInfo), NULL, - STGM_READ|STGM_SHARE_EXCLUSIVE, NULL, &lpStream); - if (sc == NOERROR) - { - lpStream->Release(); - bRes = TRUE; - } - lpStorage->Release(); - } - return bRes; -} - -int GetDocTypeFromName(LPCTSTR pszPathName, CFileException& fe) -{ - CFile file; - ASSERT(pszPathName != NULL); - - if (!file.Open(pszPathName, CFile::modeRead | CFile::shareDenyWrite, &fe)) - return -1; - - CFileStatus stat; - VERIFY(file.GetStatus(stat)); - - if (stat.m_size == 0) // file is empty - { - CString ext = CString(pszPathName).Right(4); - if (ext[0] != '.') - return RD_TEXT; - if (lstrcmpi(ext, _T(".doc"))==0) - return RD_WORDPAD; - if (lstrcmpi(ext, _T(".rtf"))==0) - return RD_RICHTEXT; - return RD_TEXT; - } - // RTF - if (IsLeadMatch(file, byteRTFPrefix, sizeof(byteRTFPrefix))) - return RD_RICHTEXT; - // WORD 2 - if (IsLeadMatch(file, byteWord2Prefix, sizeof(byteWord2Prefix))) - return RD_WINWORD2; - // EXE - if (IsLeadMatch(file, byteExePrefix, sizeof(byteExePrefix))) - return RD_EXE; - // write file can start with 31BE or 32BE depending on whether it has - // OLE objects in it or not - if (IsLeadMatch(file, byteWrite1Prefix, sizeof(byteWrite1Prefix)) || - IsLeadMatch(file, byteWrite2Prefix, sizeof(byteWrite2Prefix))) - { - file.Close(); - if (IsConverterFormat(szWriteConverter, pszPathName)) - return RD_WRITE; - else - return RD_TEXT; - } - - // test for compound file - if (IsLeadMatch(file, byteCompFilePrefix, sizeof(byteCompFilePrefix))) - { - file.Close(); - if (IsConverterFormat(szWordConverter, pszPathName)) - { - if (IsWord6(pszPathName)) - return RD_WINWORD6; - else - return RD_WORDPAD; - } - return RD_TEXT; - } - return RD_TEXT; -} - -void ScanForConverters() -{ - static BOOL bScanned = FALSE; - if (bScanned) - return; - - for (int i=0;iGetSafeHandle() != NULL); - pFont = theApp.m_dcScreen.SelectObject(pFont); - TEXTMETRIC tm; - VERIFY(theApp.m_dcScreen.GetTextMetrics(&tm)); - - theApp.m_dcScreen.SelectObject(pFont); - return CSize(tm.tmAveCharWidth, tm.tmHeight); -} - -IMPLEMENT_SERIAL(CFormatBar, CMFCToolBar, 1) - -CFormatBar::CFormatBar() -{ - CFont fnt; - fnt.Attach(GetStockObject(theApp.m_nDefFont)); - m_szBaseUnits = GetBaseUnits(&fnt); - CMFCToolBarFontComboBox::m_nFontHeight = m_szBaseUnits.cy; - m_nNumColours = 0; -} - -BEGIN_MESSAGE_MAP(CFormatBar, CMFCToolBar) - //{{AFX_MSG_MAP(CFormatBar) - //}}AFX_MSG_MAP - // Global help commands -END_MESSAGE_MAP() - -void CFormatBar::OnReset () -{ - // Insert font name combo: - CMFCToolBarFontComboBox* pFontButton = CreateFontComboButton (); - ASSERT_VALID (pFontButton); - - int iIndex = CommandToIndex (IDC_FONTNAME); - RemoveButton (iIndex); - - if (iIndex > GetCount ()) - { - iIndex = GetCount (); - } - - InsertButton (*pFontButton, iIndex); - delete pFontButton; - - // Insert font size combo: - CMFCToolBarFontSizeComboBox comboButtonFontSize (IDC_FONTSIZE, - GetCmdMgr ()->GetCmdImage (IDC_FONTSIZE, FALSE), - WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN, - 10*m_szBaseUnits.cx + 10); - - iIndex = CommandToIndex (IDC_FONTSIZE); - RemoveButton (iIndex); - - if (iIndex > GetCount ()) - { - iIndex = GetCount (); - } - - InsertButton (comboButtonFontSize, iIndex); - - // Insert the color menu button: - CMFCColorMenuButton* pColorButton = CreateColorButton (); - ReplaceButton (ID_CHAR_COLOR, *pColorButton); - delete pColorButton; - - // Insert border type button: - CMFCToolBarMenuButton* pBorderTypeButton = CreateBorderTypeButton (); - ReplaceButton (ID_BORDER_1, *pBorderTypeButton); - delete pBorderTypeButton; -} -//*************************************************************************************** -void CFormatBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) -{ - USES_CONVERSION; - - CMFCToolBar::OnUpdateCmdUI(pTarget, bDisableIfNoHndler); - - CWordPadView* pView = (CWordPadView*) GetTopLevelFrame ()->GetActiveView (); - ASSERT_VALID (pView); - - if (pView->GetSafeHwnd () != ::GetFocus ()) - { - return; - } - - CString strFontName; - - // get the current font from the view and update - WPD_CHARFORMAT cf = pView->GetCharFormatSelection (); - - CObList listButtons; - if (CMFCToolBar::GetCommandButtons (IDC_FONTNAME, listButtons) > 0) - { - for (POSITION posCombo = listButtons.GetHeadPosition (); posCombo != NULL;) - { - CMFCToolBarFontComboBox* pCombo = - DYNAMIC_DOWNCAST (CMFCToolBarFontComboBox, listButtons.GetNext (posCombo)); - - if (pCombo != NULL && !pCombo->HasFocus ()) - { - if ((cf.dwMask & (CFM_FACE|CFM_CHARSET)) == (CFM_FACE|CFM_CHARSET)) - { - strFontName = cf.szFaceName; - pCombo->SetFont (strFontName, DEFAULT_CHARSET, TRUE); - } - else - { - pCombo->SetText(_T("")); - } - } - } - } - - if (CMFCToolBar::GetCommandButtons (IDC_FONTSIZE, listButtons) > 0) - { - for (POSITION posCombo = listButtons.GetHeadPosition (); posCombo != NULL;) - { - CMFCToolBarFontSizeComboBox* pCombo = - DYNAMIC_DOWNCAST (CMFCToolBarFontSizeComboBox, listButtons.GetNext (posCombo)); - - if (pCombo != NULL && !pCombo->HasFocus ()) - { - if (!strFontName.IsEmpty () && pCombo->GetCount () == 0) - { - pCombo->RebuildFontSizes (strFontName); - } - - pCombo->SetTwipSize( (cf.dwMask & CFM_SIZE) ? cf.yHeight : -1); - } - } - } - - pView->SetFocus (); -} -//*************************************************************************************** -// -CMFCToolBarFontComboBox* CFormatBar::CreateFontComboButton () -{ - // CSize m_szBaseUnits - return new CMFCToolBarFontComboBox (IDC_FONTNAME, - GetCmdMgr ()->GetCmdImage (IDC_FONTNAME, FALSE), - TRUETYPE_FONTTYPE | DEVICE_FONTTYPE, - DEFAULT_CHARSET, - WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | - CBS_AUTOHSCROLL | CBS_HASSTRINGS | CBS_OWNERDRAWFIXED, - (3*LF_FACESIZE*m_szBaseUnits.cx)/2); -} -// - -// To hold the colours and their names -typedef struct { - COLORREF crColour; - TCHAR *szName; -} ColourTableEntry; - -#define MAX_COLOURS 100 - -static ColourTableEntry crColours[] = -{ - { RGB(0x00, 0x00, 0x00), _T("Black") }, - { RGB(0xA5, 0x2A, 0x00), _T("Brown") }, - { RGB(0x00, 0x40, 0x40), _T("Dark Olive Green") }, - { RGB(0x00, 0x55, 0x00), _T("Dark Green") }, - { RGB(0x00, 0x00, 0x5E), _T("Dark Teal") }, - { RGB(0x00, 0x00, 0x8B), _T("Dark Blue") }, - { RGB(0x4B, 0x00, 0x82), _T("Indigo") }, - { RGB(0x28, 0x28, 0x28), _T("Gray-80%") }, - - { RGB(0x8B, 0x00, 0x00), _T("Dark Red") }, - { RGB(0xFF, 0x68, 0x20), _T("Orange") }, - { RGB(0x8B, 0x8B, 0x00), _T("Dark Yellow") }, - { RGB(0x00, 0x93, 0x00), _T("Green") }, - { RGB(0x38, 0x8E, 0x8E), _T("Teal") }, - { RGB(0x00, 0x00, 0xFF), _T("Blue") }, - { RGB(0x7B, 0x7B, 0xC0), _T("Blue-Gray") }, - { RGB(0x66, 0x66, 0x66), _T("Gray-50%") }, - - { RGB(0xFF, 0x00, 0x00), _T("Red") }, - { RGB(0xFF, 0xAD, 0x5B), _T("Light Orange") }, - { RGB(0x32, 0xCD, 0x32), _T("Lime") }, - { RGB(0x3C, 0xB3, 0x71), _T("Sea Green") }, - { RGB(51, 204, 204), _T("Aqua") }, - { RGB(0x7D, 0x9E, 0xC0), _T("Light Blue") }, - { RGB(0x80, 0x00, 0x80), _T("Violet") }, - { RGB(0x7F, 0x7F, 0x7F), _T("Gray-40%") }, - - { RGB(0xFF, 0xC0, 0xCB), _T("Pink") }, - { RGB(0xFF, 0xD7, 0x00), _T("Gold") }, - { RGB(0xFF, 0xFF, 0x00), _T("Yellow") }, - { RGB(0x00, 0xFF, 0x00), _T("Bright Green") }, - { RGB(0x00, 0xFF, 0xFF), _T("Turquoise") }, - { RGB(0, 204, 255), _T("Sky Blue") }, - { RGB(234, 128, 102), _T("Plum") }, - { RGB(0xC0, 0xC0, 0xC0), _T("Gray-25%") }, - - { RGB(0xFF, 0xE4, 0xE1), _T("Rose") }, - { RGB(255, 254, 153), _T("Tan") }, - { RGB(0xFF, 0xFF, 0xE0), _T("Light Yellow") }, - { RGB(204, 255, 204), _T("Light Green ") }, - { RGB(204, 255, 255), _T("Light Turquoise") }, - { RGB(153, 204, 255), _T("Pale Blue") }, - { RGB(204, 153, 255), _T("Lavender") }, - { RGB(0xFF, 0xFF, 0xFF), _T("White") } -}; - -// -CMFCColorMenuButton* CFormatBar::CreateColorButton () -{ - if (m_palColorPicker.GetSafeHandle () == NULL) - { - m_nNumColours = sizeof (crColours)/sizeof(ColourTableEntry); - ASSERT(m_nNumColours <= MAX_COLOURS); - if (m_nNumColours > MAX_COLOURS) - m_nNumColours = MAX_COLOURS; - - // Create the palette - struct - { - LOGPALETTE LogPalette; - PALETTEENTRY PalEntry[MAX_COLOURS]; - }pal; - - LOGPALETTE* pLogPalette = (LOGPALETTE*) &pal; - pLogPalette->palVersion = 0x300; - pLogPalette->palNumEntries = (WORD) m_nNumColours; - - for (int i = 0; i < m_nNumColours; i++) - { - pLogPalette->palPalEntry[i].peRed = GetRValue(crColours[i].crColour); - pLogPalette->palPalEntry[i].peGreen = GetGValue(crColours[i].crColour); - pLogPalette->palPalEntry[i].peBlue = GetBValue(crColours[i].crColour); - pLogPalette->palPalEntry[i].peFlags = 0; - } - - m_palColorPicker.CreatePalette (pLogPalette); - } - - - CMFCColorMenuButton* pColorButton = new - CMFCColorMenuButton (ID_CHAR_COLOR, _T("Text Color..."), &m_palColorPicker); - - pColorButton->EnableAutomaticButton (_T("Automatic"), RGB (0, 0, 0)); - pColorButton->EnableOtherButton (_T("More Colors...")); - pColorButton->EnableDocumentColors (_T("Document's Colors")); - pColorButton->EnableTearOff (ID_COLOR_TEAROFF, 5, 2); - pColorButton->SetColumnsNumber (8); - pColorButton->SetColor(RGB(0,0,255)); - - // Initialize color names: - for (int i = 0; i < m_nNumColours; i++) - { - CMFCColorMenuButton::SetColorName (crColours[i].crColour, crColours[i].szName); - } - - return pColorButton; -} -// - -CMFCToolBarMenuButton* CFormatBar::CreateBorderTypeButton () -{ - CMenu menu; - VERIFY(menu.LoadMenu (IDR_BORDER_PALETTE)); - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - // - CMFCToolBarMenuButton* pBorderType = new - CMFCToolBarMenuButton (ID_BORDER_1, pPopup->GetSafeHmenu (), - GetCmdMgr ()->GetCmdImage (ID_BORDER_1, FALSE), - _T("Borders")); - // - // - pBorderType->SetMenuPaletteMode (TRUE, 2 /* Rows number */); - pBorderType->SetTearOff (ID_BORDER_TEAROFF); - // - return pBorderType; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatba.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatba.h deleted file mode 100644 index a93f35387697e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatba.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// formatba.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifndef __FORMATBA_H__ -#define __FORMATBA_H__ - -///////////////////////////////////////////////////////////////////////////// -// CFormatBar dialog -class CFormatBar : public CMFCToolBar -{ - DECLARE_SERIAL(CFormatBar) - -// Construction -public: - CFormatBar(); - -// Operations -public: - virtual void CFormatBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); - - CMFCColorMenuButton* CreateColorButton (); - CMFCToolBarFontComboBox* CreateFontComboButton (); - CMFCToolBarMenuButton* CreateBorderTypeButton (); - -// Attributes -public: - CSize m_szBaseUnits; - -protected: - // - CPalette m_palColorPicker; // Palette for color picker - int m_nNumColours; - // - -// Implementation -protected: - virtual void OnReset (); - - // Generated message map functions - //{{AFX_MSG(CFormatBar) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -#endif - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatpa.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatpa.cpp deleted file mode 100644 index 28aab142da09d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatpa.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// -// formatpa.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "formatpa.h" -#include "ddxm.h" -#include "helpids.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -const DWORD CFormatParaDlg::m_nHelpIDs[] = -{ - IDC_EDIT_LEFT, IDH_WORDPAD_INDENT_LEFT, - IDC_EDIT_RIGHT, IDH_WORDPAD_INDENT_RIGHT, - IDC_EDIT_FIRST_LINE, IDH_WORDPAD_INDENT_FIRST, - IDC_BOX, IDH_COMM_GROUPBOX, - IDC_COMBO_ALIGNMENT, IDH_WORDPAD_ALIGN, - IDC_TEXT_ALIGNMENT, IDH_WORDPAD_ALIGN, - 0, 0 -}; - -///////////////////////////////////////////////////////////////////////////// -// CFormatParaDlg dialog - -CFormatParaDlg::CFormatParaDlg(WPD_PARAFORMAT& pf, CWnd* pParent /*=NULL*/) - : CCSDialog(CFormatParaDlg::IDD, pParent) -{ - m_pf = pf; - if (m_pf.dwMask & PFM_ALIGNMENT) - { - if (m_pf.wAlignment & PFA_LEFT && m_pf.wAlignment & PFA_RIGHT) - m_nAlignment = 2; - else - m_nAlignment = (m_pf.wAlignment & PFA_LEFT) ? 0 : 1; - } - else - m_nAlignment = -1; - //{{AFX_DATA_INIT(CFormatParaDlg) - m_nFirst = 0; - m_nLeft = 0; - m_nRight = 0; - //}}AFX_DATA_INIT -} - -void CFormatParaDlg::DoDataExchange(CDataExchange* pDX) -{ - CCSDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CFormatParaDlg) - DDX_CBIndex(pDX, IDC_COMBO_ALIGNMENT, m_nAlignment); - DDX_Twips(pDX, IDC_EDIT_FIRST_LINE, m_nFirst); - DDV_MinMaxTwips(pDX, m_nFirst, -31680, 31680); - DDX_Twips(pDX, IDC_EDIT_LEFT, m_nLeft); - DDV_MinMaxTwips(pDX, m_nLeft, -31680, 31680); - DDX_Twips(pDX, IDC_EDIT_RIGHT, m_nRight); - DDV_MinMaxTwips(pDX, m_nRight, -31680, 31680); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CFormatParaDlg, CCSDialog) - //{{AFX_MSG_MAP(CFormatParaDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CFormatParaDlg message handlers - -void CFormatParaDlg::OnOK() -{ - CCSDialog::OnOK(); - m_pf.dwMask = 0; - if (m_nAlignment >= 0) - { - ASSERT(m_nAlignment < 3); - m_pf.dwMask |= PFM_ALIGNMENT; - m_pf.wAlignment = (WORD)((m_nAlignment == 0) ? PFA_LEFT : - (m_nAlignment == 1) ? PFA_RIGHT : PFA_CENTER); - } - if (m_nRight != DDXM_BLANK) - m_pf.dwMask |= PFM_RIGHTINDENT; - if (m_nLeft != DDXM_BLANK && m_nFirst != DDXM_BLANK) - m_pf.dwMask |= PFM_STARTINDENT; - if (m_nFirst != DDXM_BLANK) - m_pf.dwMask |= PFM_OFFSET; - - m_pf.dxRightIndent = m_nRight; - m_pf.dxOffset = -m_nFirst; - m_pf.dxStartIndent = m_nLeft + m_nFirst; -} - -BOOL CFormatParaDlg::OnInitDialog() -{ - CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_COMBO_ALIGNMENT); - CString str; - str.LoadString(IDS_LEFT); - pBox->AddString(str); - str.LoadString(IDS_RIGHT); - pBox->AddString(str); - str.LoadString(IDS_CENTER); - pBox->AddString(str); - - if (m_nWordWrap == 0) - { - GetDlgItem(IDC_COMBO_ALIGNMENT)->EnableWindow(FALSE); - GetDlgItem(IDC_TEXT_ALIGNMENT)->EnableWindow(FALSE); - } - - m_nRight = (m_pf.dwMask & PFM_RIGHTINDENT) ? m_pf.dxRightIndent : DDXM_BLANK; - if (m_pf.dwMask & PFM_OFFSET) - { - m_nFirst = -m_pf.dxOffset; - m_nLeft = (m_pf.dwMask & PFM_STARTINDENT) ? - m_pf.dxStartIndent + m_pf.dxOffset : DDXM_BLANK; - } - else - m_nLeft = m_nFirst = DDXM_BLANK; - - CCSDialog::OnInitDialog(); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatpa.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatpa.h deleted file mode 100644 index 9b736de6b0f01..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatpa.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// formatpa.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CFormatParaDlg dialog - -class CFormatParaDlg : public CCSDialog -{ -// Construction -public: - CFormatParaDlg(WPD_PARAFORMAT& pf, CWnd* pParent = NULL); // standard constructor - WPD_PARAFORMAT m_pf; - -// Attributes - int m_nWordWrap; - -// Dialog Data - //{{AFX_DATA(CFormatParaDlg) - enum { IDD = IDD_FORMAT_PARA }; - int m_nAlignment; - int m_nFirst; - int m_nLeft; - int m_nRight; - //}}AFX_DATA - -// Implementation -protected: - static const DWORD m_nHelpIDs[]; - virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnOK(); - - // Generated message map functions - //{{AFX_MSG(CFormatParaDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatta.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatta.cpp deleted file mode 100644 index 8a72527f551f5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatta.cpp +++ /dev/null @@ -1,268 +0,0 @@ -// -// formatta.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "formatta.h" -#include "ddxm.h" -#include "helpids.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -const DWORD CFormatTabDlg::m_nHelpIDs[] = -{ - IDC_BUTTON_SET, IDH_WORDPAD_TABSET, - IDC_BUTTON_CLEAR, IDH_WORDPAD_TABCLEAR, - IDC_BUTTON_CLEARALL, IDH_WORDPAD_TAB_CLEARALL, - IDC_COMBO1, IDH_WORDPAD_TABSTOPS, - IDC_BOX, IDH_COMM_GROUPBOX, - 0, 0 -}; - -///////////////////////////////////////////////////////////////////////////// -// CFormatTabDlg dialog - -CFormatTabDlg::CFormatTabDlg(WPD_PARAFORMAT& pf, CWnd* pParent /*=NULL*/) - : CCSDialog(CFormatTabDlg::IDD, pParent) -{ - m_pf = pf; - m_tabarray = new LONG[MAX_TAB_STOPS]; - m_nCount = 0; - if (m_pf.dwMask & PFM_TABSTOPS) - { - m_nCount = m_pf.cTabCount; - ASSERT(m_pf.cTabCount <= MAX_TAB_STOPS); - for (int i=0;im_bSaveAndValidate) - UpdateListBox(); -} - -BEGIN_MESSAGE_MAP(CFormatTabDlg, CCSDialog) - //{{AFX_MSG_MAP(CFormatTabDlg) - ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnClickedClear) - ON_BN_CLICKED(IDC_BUTTON_CLEARALL, OnClickedClearAll) - ON_BN_CLICKED(IDC_BUTTON_SET, OnClickedSet) - ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditChange) - ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchange) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CFormatTabDlg message handlers - -void CFormatTabDlg::OnClickedClear() -{ - int nTab; - int nSel = m_comboBox.GetCurSel(); - if (nSel == CB_ERR) - { - CDataExchange dx(this, TRUE); - DDX_Twips(&dx, IDC_COMBO1, nTab); - DDV_MinMaxTwips(&dx, nTab, 0, 31680); - if (nTab != DDXM_BLANK) - { - if (RemoveTabFromArray(nTab)) - UpdateListBox(); - } - } - else - { - ASSERT(nSel < m_nCount); - RemoveTabFromArrayByIndex(nSel); - UpdateListBox(); - } - UpdateButtons(); - SetEditFocus(); -} - -void CFormatTabDlg::OnClickedClearAll() -{ - m_nCount = 0; - m_comboBox.ResetContent(); - UpdateButtons(); - SetEditFocus(); -} - -void CFormatTabDlg::OnClickedSet() -{ - Set(); - UpdateButtons(); - SetEditFocus(); -} - -BOOL CFormatTabDlg::Set() -{ - int nTab; - CDataExchange dx(this, TRUE); - DDX_Twips(&dx, IDC_COMBO1, nTab); - DDV_MinMaxTwips(&dx, nTab, 0, 31680); - if (nTab != DDXM_BLANK) - { - if (m_nCount == MAX_TAB_STOPS) - { - AfxMessageBox(IDS_NOMORETABS); - m_comboBox.Clear(); - return FALSE; - } - if (AddTabToArray(nTab)) - UpdateListBox(); - return TRUE; - } - return FALSE; -} - -void CFormatTabDlg::SetEditFocus() -{ - m_comboBox.SetFocus(); - m_comboBox.SetEditSel(0,-1); -} - -BOOL CFormatTabDlg::RemoveTabFromArray(LONG lTab) -{ - int i; - for (i=0;i= 0); - m_comboBox.ResetContent(); - for (i=0;i 0); - BOOL bHasText = (m_comboBox.GetWindowTextLength() > 0); - UpdateButton(m_buttonSet, bHasText); - UpdateButton(m_buttonClear, bHasText); - WORD wID = LOWORD(GetDefID()); - if (bHasText && wID != IDC_BUTTON_SET) - SetDefID(IDC_BUTTON_SET); - else if (!bHasText && wID != IDOK) - SetDefID(IDOK); -} - -BOOL CFormatTabDlg::OnInitDialog() -{ - CCSDialog::OnInitDialog(); - UpdateButtons(); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CFormatTabDlg::OnSelchange() -{ - UpdateButton(m_buttonClearAll, m_nCount > 0); - // force these since if the edit control is empty and - // an item in the box is clicked on, the edit control will - // not be filled in first - UpdateButton(m_buttonSet, TRUE); - UpdateButton(m_buttonClear, TRUE); - WORD wID = LOWORD(GetDefID()); - if (wID != IDC_BUTTON_SET) - SetDefID(IDC_BUTTON_SET); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatta.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatta.h deleted file mode 100644 index 27999a0048c8a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/formatta.h +++ /dev/null @@ -1,61 +0,0 @@ -// -// formatta.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CFormatTabDlg dialog - -class CFormatTabDlg : public CCSDialog -{ -// Construction -public: - CFormatTabDlg(WPD_PARAFORMAT& pf, CWnd* pParent = NULL); // standard constructor - ~CFormatTabDlg(); - WPD_PARAFORMAT m_pf; - LONG* m_tabarray; - int m_nCount; - -// Dialog Data - //{{AFX_DATA(CFormatTabDlg) - enum { IDD = IDD_FORMAT_TAB }; - CButton m_buttonClearAll; - CButton m_buttonSet; - CButton m_buttonClear; - CComboBox m_comboBox; - //}}AFX_DATA - -// Implementation -protected: - static const DWORD m_nHelpIDs[]; - virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} - void UpdateButton(CButton& button, BOOL b); - void UpdateButtons(); - BOOL Set(); - BOOL AddTabToArray(LONG lTab); - BOOL RemoveTabFromArray(LONG lTab); - void RemoveTabFromArrayByIndex(int nIndex); - void UpdateListBox(); - void SetEditFocus(); - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnOK(); - - // Generated message map functions - //{{AFX_MSG(CFormatTabDlg) - afx_msg void OnClickedClear(); - afx_msg void OnClickedClearAll(); - afx_msg void OnClickedSet(); - afx_msg void OnEditChange(); - virtual BOOL OnInitDialog(); - afx_msg void OnSelchange(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/helpids.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/helpids.h deleted file mode 100644 index 6a37245ac6ae5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/helpids.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#define IDH_WORDPAD_TIMEDATE 1001 - -#define IDH_WORDPAD_ALIGN 1003 -#define IDH_WORDPAD_TABSET 1004 -#define IDH_WORDPAD_TABCLEAR 1005 -#define IDH_WORDPAD_TAB_CLEARALL 1006 -#define IDH_WORDPAD_TABSTOPS 1007 -#define IDH_WORDPAD_TEXTFILE 1008 -#define IDH_WORDPAD_FORMATTED 1009 - -#define IDH_WORDPAD_WORD6FILE 1017 -#define IDH_WORDPAD_FILENEW_DOC 1018 -#define IDH_WORDPAD_OPTIONS_AUTOWORDSEL 1019 - -#define IDH_WORDPAD_INDENT_LEFT 1020 -#define IDH_WORDPAD_INDENT_RIGHT 1021 -#define IDH_WORDPAD_INDENT_FIRST 1022 - -#define IDH_WORDPAD_WRAP_NO 1023 -#define IDH_WORDPAD_WRAP_WINDOW 1024 -#define IDH_WORDPAD_WRAP_RULER 1025 - -#define IDH_COMM_GROUPBOX 1026 - -#define IDH_WORDPAD_INCHES 1027 -#define IDH_WORDPAD_CENTIMETERS 1028 -#define IDH_WORDPAD_POINTS 1029 -#define IDH_WORDPAD_PICAS 1030 - -#define IDH_WORDPAD_CHECK_TOOLBAR 1031 -#define IDH_WORDPAD_CHECK_FORMATBAR 1032 -#define IDH_WORDPAD_CHECK_STATUSBAR 1033 -#define IDH_WORDPAD_CHECK_RULERBAR 1034 - -#define IDH_WORDPAD_TOPMARGIN 1035 -#define IDH_WORDPAD_BOTTOMMARGIN 1036 -#define IDH_WORDPAD_LEFTMARGIN 1037 -#define IDH_WORDPAD_RIGHTMARGIN 1038 diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ipframe.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ipframe.cpp deleted file mode 100644 index b418eae86d012..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ipframe.cpp +++ /dev/null @@ -1,384 +0,0 @@ -// -// ipframe.cpp : implementation of the CInPlaceFrame class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "formatba.h" -#include "ruler.h" -#include "ipframe.h" -#include "wordpdoc.h" -#include "wordpvw.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -const UINT uiMenuBarId = AFX_IDW_CONTROLBAR_FIRST + 20; - -///////////////////////////////////////////////////////////////////////////// -// CInPlaceFrame - -IMPLEMENT_DYNCREATE(CInPlaceFrame, COleIPFrameWndEx) - -BEGIN_MESSAGE_MAP(CInPlaceFrame, COleIPFrameWndEx) - //{{AFX_MSG_MAP(CInPlaceFrame) - ON_WM_CREATE() - ON_WM_DESTROY() - ON_COMMAND(ID_HELP, OnHelpFinder) - ON_COMMAND(ID_PEN_TOGGLE, OnPenToggle) - ON_COMMAND(ID_HELP_INDEX, OnHelpFinder) - //}}AFX_MSG_MAP - ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR, OnUpdateControlBarMenu) - ON_COMMAND_EX(ID_VIEW_TOOLBAR, OnBarCheck) - ON_UPDATE_COMMAND_UI(ID_VIEW_FORMATBAR, OnUpdateControlBarMenu) - ON_COMMAND_EX(ID_VIEW_FORMATBAR, OnBarCheck) - ON_UPDATE_COMMAND_UI(ID_VIEW_RULER, OnUpdateControlBarMenu) - ON_COMMAND_EX(ID_VIEW_RULER, OnBarCheck) - ON_MESSAGE(WM_SIZECHILD, OnResizeChild) - ON_MESSAGE(WPM_BARSTATE, OnBarState) - ON_COMMAND(ID_DEFAULT_HELP, OnHelpFinder) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// arrays of IDs used to initialize control bars - -static UINT BASED_CODE toolButtons[] = -{ - // same order as in the bitmap 'itoolbar.bmp' - ID_EDIT_CUT, - ID_EDIT_COPY, - ID_EDIT_PASTE, - - ID_SEPARATOR, - ID_PEN_TOGGLE, - ID_PEN_PERIOD, - ID_PEN_SPACE, - ID_PEN_BACKSPACE, - ID_PEN_NEWLINE, - ID_PEN_LENS -}; - -#define NUM_PEN_ITEMS 7 -#define NUM_PEN_TOGGLE 5 - -static UINT BASED_CODE format[] = -{ - // same order as in the bitmap 'format.bmp' - IDC_FONTNAME, - ID_SEPARATOR, - IDC_FONTSIZE, - ID_SEPARATOR, - ID_CHAR_BOLD, - ID_CHAR_ITALIC, - ID_CHAR_UNDERLINE, - ID_CHAR_COLOR, - ID_SEPARATOR, - ID_PARA_LEFT, - ID_PARA_CENTER, - ID_PARA_RIGHT, - ID_SEPARATOR, - ID_INSERT_BULLET, -}; - -///////////////////////////////////////////////////////////////////////////// -// CInPlaceFrame construction/destruction - -CInPlaceFrame::CInPlaceFrame() : m_wndRulerBar(FALSE) -{ -} - -int CInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (COleIPFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - // CResizeBar implements in-place resizing. - if (!m_wndResizeBar.Create(this)) - { - TRACE0("Failed to create resize bar\n"); - return -1; // fail to create - } - - if (!CreateRulerBar(this)) - return FALSE; - - // By default, it is a good idea to register a drop-target that does - // nothing with your frame window. This prevents drops from - // "falling through" to a container that supports drag-drop. - m_dropTarget.Register(this); - - return 0; -} - -// OnCreateControlBars is called by the framework to create control bars on the -// container application's windows. pWndFrame is the top level frame window of -// the container and is always non-NULL. pWndDoc is the doc level frame window -// and will be NULL when the container is an SDI application. A server -// application can place MFC control bars on either window. -BOOL CInPlaceFrame::OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* /*pWndDoc*/) -{ - if (!CreateMenuBar()) - return -1; - - if (!CreateToolBar(pWndFrame)) - return FALSE; - - if (!CreateFormatBar(pWndFrame)) - return FALSE; - - // set owner to this window, so messages are delivered to correct app - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndFormatBar.EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM); - - COleCntrFrameWndEx* pFrame = DYNAMIC_DOWNCAST (COleCntrFrameWndEx, m_pMainFrame); - if (pFrame == NULL) - { - return FALSE; - } - - ASSERT_VALID (pFrame); - - pFrame->EnableDocking(CBRS_ALIGN_ANY); - pFrame->DockPane(&m_wndToolBar); - pFrame->DockPane(&m_wndFormatBar); - - m_wndToolBar.SetOwner(this); - m_wndFormatBar.SetOwner(this); - m_wndRulerBar.SetOwner(this); - OnBarState(1, RD_EMBEDDED); //load bar state - return TRUE; -} - -BOOL CInPlaceFrame::CreateMenuBar() -{ - //---------------------------------------------- - // Create menu bar (replaces the standard menu): - //---------------------------------------------- - if (!m_wndMenuBar.Create (this, WS_CHILD | WS_VISIBLE | CBRS_TOP, uiMenuBarId)) - { - TRACE0("Failed to create menubar\n"); - return FALSE; - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER | CBRS_BORDER_3D); - - CString str; - str.LoadString(IDS_TITLE_MENUBAR); - m_wndMenuBar.SetWindowText(str); - return TRUE; -} - -BOOL CInPlaceFrame::CreateToolBar(CWnd* pWndFrame) -{ - // Create toolbar on client's frame window - ASSERT(m_wndToolBar.m_hWnd == NULL); - int nPen = GetSystemMetrics(SM_PENWINDOWS) ? NUM_PEN_TOGGLE : - NUM_PEN_ITEMS; - - if (!m_wndToolBar.Create(pWndFrame, WS_CHILD|WS_VISIBLE|CBRS_TOP| - CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC | CBRS_GRIPPER | CBRS_BORDER_3D)|| - !m_wndToolBar.LoadBitmap(IDR_SRVR_INPLACE) || - !m_wndToolBar.SetButtons(toolButtons, - sizeof(toolButtons)/sizeof(UINT) - nPen)) - { - TRACE0("Failed to create toolbar\n"); - return FALSE; // fail to create - } - - CString str; - str.LoadString(IDS_TITLE_TOOLBAR); - m_wndToolBar.SetWindowText(str); - return TRUE; -} - -BOOL CInPlaceFrame::CreateFormatBar(CWnd* pWndFrame) -{ - ASSERT(m_wndFormatBar.m_hWnd == NULL); - m_wndFormatBar.m_hWndOwner = m_hWnd; - - if (!m_wndFormatBar.Create(pWndFrame, WS_CHILD|WS_VISIBLE|CBRS_TOP| - CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC | CBRS_GRIPPER | CBRS_BORDER_3D, - ID_VIEW_FORMATBAR) || - !m_wndFormatBar.LoadBitmap(IDB_FORMATBAR) || - !m_wndFormatBar.SetButtons(format, - sizeof(format)/sizeof(UINT))) - { - TRACE0("Failed to create FormatBar\n"); - return FALSE; // fail to create - } - - CString str; - str.LoadString(IDS_TITLE_FORMATBAR); - m_wndFormatBar.SetWindowText(str); - return TRUE; -} - -BOOL CInPlaceFrame::CreateRulerBar(CWnd* pWndFrame) -{ - if (!m_wndRulerBar.Create(pWndFrame, - WS_CHILD|WS_VISIBLE|CBRS_ALIGN_TOP|CBRS_HIDE_INPLACE, ID_VIEW_RULER)) - { - TRACE0("Failed to create ruler\n"); - return FALSE; // fail to create - } - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CInPlaceFrame Operations - -///////////////////////////////////////////////////////////////////////////// -// CInPlaceFrame diagnostics - -#ifdef _DEBUG -void CInPlaceFrame::AssertValid() const -{ - COleIPFrameWndEx::AssertValid(); -} - -void CInPlaceFrame::Dump(CDumpContext& dc) const -{ - COleIPFrameWndEx::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CInPlaceFrame commands -// -void CInPlaceFrame::OnDestroy() -{ - m_wndToolBar.DestroyWindow(); - m_wndFormatBar.DestroyWindow(); - COleIPFrameWndEx::OnDestroy(); -} - -void CInPlaceFrame::RepositionFrame(LPCRECT lpPosRect, LPCRECT lpClipRect) -{ - CRect rectNew = lpPosRect; - rectNew.left -= HORZ_TEXTOFFSET; - rectNew.top -= VERT_TEXTOFFSET; - m_wndResizeBar.BringWindowToTop(); - COleIPFrameWndEx::RepositionFrame(&rectNew, lpClipRect); - CWnd* pWnd = GetActiveView(); - if (pWnd != NULL) - pWnd->BringWindowToTop(); - m_wndRulerBar.BringWindowToTop(); -} - -void CInPlaceFrame::RecalcLayout(BOOL bNotify) -{ - if (m_wndResizeBar.m_hWnd != NULL) - m_wndResizeBar.BringWindowToTop(); - COleIPFrameWndEx::RecalcLayout(bNotify); - CWnd* pWnd = GetActiveView(); - if (pWnd != NULL) - pWnd->BringWindowToTop(); - if (m_wndRulerBar.m_hWnd != NULL) - m_wndRulerBar.BringWindowToTop(); - - // at least 12 pt region plus ruler if it exists - CDisplayIC dc; - CSize size; - size.cy = MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72)+1; - size.cx = dc.GetDeviceCaps(LOGPIXELSX)/4; // 1/4" - size.cx += HORZ_TEXTOFFSET; //adjust for offset - size.cy += VERT_TEXTOFFSET; - if (m_wndRulerBar.m_hWnd != NULL && m_wndRulerBar.IsVisible()) - { - CRect rect; - m_wndRulerBar.GetWindowRect(&rect); - size.cy += rect.Height(); - } - m_wndResizeBar.SetMinSize(size); -} - -void CInPlaceFrame::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType) -{ - COleIPFrameWndEx::CalcWindowRect(lpClientRect, nAdjustType); -} -// -LRESULT CInPlaceFrame::OnResizeChild(WPARAM /*wParam*/, LPARAM lParam) -{ - // notify the container that the rectangle has changed! - CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument(); - if (pDoc == NULL) - return 0; - - ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CWordPadDoc))); - - // get new rect and parent - CRect rectNew; - rectNew.CopyRect((LPCRECT)lParam); - CWnd* pParentWnd = GetParent(); - ASSERT_VALID(pParentWnd); - - // convert rectNew relative to pParentWnd - ClientToScreen(&rectNew); - pParentWnd->ScreenToClient(&rectNew); - - if (m_wndRulerBar.GetStyle()&WS_VISIBLE) - { - CRect rect; - m_wndRulerBar.GetWindowRect(&rect); - rectNew.top += rect.Height(); - } - rectNew.left += HORZ_TEXTOFFSET; - rectNew.top += VERT_TEXTOFFSET; - - // adjust the new rectangle for the current control bars - CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST); - ASSERT(pLeftOver != NULL); - CRect rectCur = m_rectPos; - pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside); - rectNew.left += m_rectPos.left - rectCur.left; - rectNew.top += m_rectPos.top - rectCur.top; - rectNew.right -= rectCur.right - m_rectPos.right; - rectNew.bottom -= rectCur.bottom - m_rectPos.bottom; - OnRequestPositionChange(rectNew); - - return 0; -} - -LRESULT CInPlaceFrame::OnBarState(WPARAM wParam, LPARAM lParam) -{ - if (lParam == -1) - return 0L; - if (wParam == 0) - { - GetDockState(theApp.GetDockState(RD_EMBEDDED)); - ASSERT(m_pMainFrame != NULL); - m_pMainFrame->GetDockState(theApp.GetDockState(RD_EMBEDDED, FALSE)); - } - else - { - SetDockState(theApp.GetDockState(RD_EMBEDDED)); - m_pMainFrame->SetDockState(theApp.GetDockState(RD_EMBEDDED, FALSE)); - } - return 0L; -} - -void CInPlaceFrame::OnHelpFinder() -{ - theApp.WinHelp(0, HELP_FINDER); -} - -void CInPlaceFrame::OnPenToggle() -{ - static int nPen = 0; - m_wndToolBar.SetButtons(toolButtons, sizeof(toolButtons)/sizeof(UINT) - nPen); - nPen = (nPen == 0) ? NUM_PEN_TOGGLE : 0; - m_wndToolBar.Invalidate(); - m_wndToolBar.GetParentFrame()->RecalcLayout(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ipframe.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ipframe.h deleted file mode 100644 index c5a1e9a0b50b5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ipframe.h +++ /dev/null @@ -1,75 +0,0 @@ -// -// ipframe.h : interface of the CInPlaceFrame class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CWordPadResizeBar : public COleResizeBar -{ -public: - void SetMinSize(CSize size) {m_tracker.m_sizeMin = size;} -}; - -class CInPlaceFrame : public COleIPFrameWndEx -{ - DECLARE_DYNCREATE(CInPlaceFrame) -public: - CInPlaceFrame(); - -// Attributes -public: - CMFCToolBar m_wndMenuBar; - CMFCToolBar m_wndToolBar; - CFormatBar m_wndFormatBar; - CRulerBar m_wndRulerBar; - CWordPadResizeBar m_wndResizeBar; - COleDropTarget m_dropTarget; - -// Operations -public: - virtual void RecalcLayout(BOOL bNotify = TRUE); - virtual void CalcWindowRect(LPRECT lpClientRect, - UINT nAdjustType = adjustBorder); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CInPlaceFrame) - public: - virtual BOOL OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* pWndDoc); - virtual void RepositionFrame(LPCRECT lpPosRect, LPCRECT lpClipRect); - //}}AFX_VIRTUAL - -// Implementation -public: -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - BOOL CreateMenuBar(); - BOOL CreateToolBar(CWnd* pWndFrame); - BOOL CreateFormatBar(CWnd* pWndFrame); - BOOL CreateRulerBar(CWnd* pWndFrame); - -// Generated message map functions -protected: - //{{AFX_MSG(CInPlaceFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnDestroy(); - afx_msg void OnHelpFinder(); - afx_msg void OnPenToggle(); - //}}AFX_MSG - LRESULT OnResizeChild(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnBarState(WPARAM wParam, LPARAM lParam); - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/key.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/key.cpp deleted file mode 100644 index 7f0b177e086b7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/key.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -// key.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "key.h" -#include - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CKey - -void CKey::Close() -{ - if (m_hKey != NULL) - { - LONG lRes = RegCloseKey(m_hKey); - if (lRes != ERROR_SUCCESS) - { - ASSERT(FALSE); - } - m_hKey = NULL; - } -} - -BOOL CKey::Create(HKEY hKey, LPCTSTR lpszKeyName) -{ - ASSERT(hKey != NULL); - return (RegCreateKey(hKey, lpszKeyName, &m_hKey) == ERROR_SUCCESS); -} - -BOOL CKey::Open(HKEY hKey, LPCTSTR lpszKeyName) -{ - ASSERT(hKey != NULL); - return (RegOpenKey(hKey, lpszKeyName, &m_hKey) == ERROR_SUCCESS); -} - -BOOL CKey::SetStringValue(LPCTSTR lpszValue, LPCTSTR lpszValueName) -{ - ASSERT(m_hKey != NULL); - return (RegSetValueEx(m_hKey, lpszValueName, NULL, REG_SZ, - (BYTE * const)lpszValue, (lstrlen(lpszValue)+1)*sizeof(TCHAR)) == ERROR_SUCCESS); -} - -BOOL CKey::GetStringValue(CString& str, LPCTSTR lpszValueName) -{ - ASSERT(m_hKey != NULL); - str.Empty(); - DWORD dw = 0; - DWORD dwType = 0; - LONG lRes = RegQueryValueEx(m_hKey, (LPTSTR)lpszValueName, NULL, &dwType, - NULL, &dw); - if (lRes == ERROR_SUCCESS) - { - ASSERT(dwType == REG_SZ); - LPTSTR lpsz = str.GetBufferSetLength(dw); - lRes = RegQueryValueEx(m_hKey, (LPTSTR)lpszValueName, NULL, &dwType, (BYTE*)lpsz, &dw); - ASSERT(lRes == ERROR_SUCCESS); - str.ReleaseBuffer(); - return TRUE; - } - return FALSE; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/key.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/key.h deleted file mode 100644 index 71d3d5fbdaf02..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/key.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// key.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CKey - -class CKey -{ -public: - CKey() {m_hKey = NULL;} - ~CKey() {Close();} - -// Attributes -public: - HKEY m_hKey; - BOOL SetStringValue(LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL); - BOOL GetStringValue(CString& str, LPCTSTR lpszValueName = NULL); - -// Operations -public: - BOOL Create(HKEY hKey, LPCTSTR lpszKeyName); - BOOL Open(HKEY hKey, LPCTSTR lpszKeyName); - void Close(); - -// Overrides - -// Implementation -protected: -}; - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/listdlg.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/listdlg.cpp deleted file mode 100644 index bdf5d7eefa99b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/listdlg.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// listdlg.cpp : Defines the class behaviors for the application. -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "resource.h" -#include "listdlg.h" - -#pragma warning(disable:4793) - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -BEGIN_MESSAGE_MAP(CListDlg, CDialog) - //{{AFX_MSG_MAP(CListDlg) - ON_LBN_DBLCLK(IDC_LISTDIALOG_LIST, OnOK) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -CListDlg::CListDlg(UINT idStrDlgTitle, UINT idStrListTitle, - const CStringList& listItems, int nDefSel) : CDialog(CListDlg::IDD), - m_listItems(listItems) -{ - VERIFY(m_strDlgTitle.LoadString(idStrDlgTitle)); - VERIFY(m_strListTitle.LoadString(idStrListTitle)); - m_nSelection = nDefSel; -} - -BOOL CListDlg::OnInitDialog() -{ - SetWindowText(m_strDlgTitle); -// fix this - SetDlgItemText(IDC_STATIC_HEADING, m_strListTitle); - CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LISTDIALOG_LIST); - ASSERT(pListBox != NULL); - // fill with document templates in list - - POSITION pos = m_listItems.GetHeadPosition(); - while (pos != NULL) - { - if ( pListBox->AddString(m_listItems.GetNext(pos)) == -1) - return FALSE; - } - pListBox->SetCurSel(m_nSelection); - - return CDialog::OnInitDialog(); -} - -void CListDlg::OnOK() -{ - CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LISTDIALOG_LIST); - ASSERT(pListBox != NULL); - m_nSelection = pListBox->GetCurSel(); - CDialog::OnOK(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/listdlg.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/listdlg.h deleted file mode 100644 index 9d4a4dc5aa3fc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/listdlg.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CListDlg : public CDialog -{ -public: - //{{AFX_DATA(CListDlg) - enum { IDD = IDD_LISTDIALOG }; - //}}AFX_DATA - CListDlg::CListDlg(UINT idStrDlgTitle, UINT idStrListTitle, - const CStringList& listItems, int nDefSel=0); - CString m_strDlgTitle,m_strListTitle; - const CStringList& m_listItems; - int m_nSelection; - -protected: - BOOL OnInitDialog(); - //{{AFX_MSG(CListDlg) - afx_msg void OnOK(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/mainfrm.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/mainfrm.cpp deleted file mode 100644 index e69e220499522..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/mainfrm.cpp +++ /dev/null @@ -1,822 +0,0 @@ -// -// mainfrm.cpp : implementation of the CMainFrame class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" - -#include "wordpad.h" -#include "mainfrm.h" -#include "wordpdoc.h" -#include "wordpvw.h" -#include "strings.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -const int iMaxUserToolbars = 10; - -const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; -const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx) - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx) - //{{AFX_MSG_MAP(CMainFrame) - ON_WM_CREATE() - ON_WM_SYSCOLORCHANGE() - ON_WM_SIZE() - ON_WM_MOVE() - ON_COMMAND(ID_HELP, OnHelpFinder) - ON_WM_DROPFILES() - ON_WM_FONTCHANGE() - ON_WM_QUERYNEWPALETTE() - ON_WM_PALETTECHANGED() - ON_WM_DEVMODECHANGE() - ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) - ON_COMMAND(ID_HELP_INDEX, OnHelpFinder) - ON_COMMAND(ID_VIEW_FULL_SCREEN, OnViewFullScreen) - //}}AFX_MSG_MAP - // Global help commands - ON_COMMAND(ID_CONTEXT_HELP, CFrameWndEx::OnContextHelp) - ON_COMMAND(ID_DEFAULT_HELP, OnHelpFinder) - ON_MESSAGE(WPM_BARSTATE, OnBarState) - ON_REGISTERED_MESSAGE(CWordPadApp::m_nOpenMsg, OnOpenMsg) - ON_REGISTERED_MESSAGE(AFX_WM_CUSTOMIZEHELP, OnHelpCustomizeToolbars) - ON_REGISTERED_MESSAGE(AFX_WM_CUSTOMIZETOOLBAR, OnStartCustomize) - ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, OnToolbarCreateNew) - ON_REGISTERED_MESSAGE(AFX_WM_GETDOCUMENTCOLORS, OnGetDocumentColors) - ON_COMMAND(ID_DUMMY, OnDummy) - ON_COMMAND(ID_HELP_FIND, OnAskQuestion) -END_MESSAGE_MAP() - -static UINT BASED_CODE indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - m_hIconDoc = theApp.LoadIcon(IDI_ICON_DOC); - m_hIconText = theApp.LoadIcon(IDI_ICON_TEXT); - m_hIconWrite = theApp.LoadIcon(IDI_ICON_WRITE); -} - -CMainFrame::~CMainFrame() -{ -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - WNDCLASS wndcls; - - BOOL bRes = CFrameWndEx::PreCreateWindow(cs); - HINSTANCE hInst = AfxGetInstanceHandle(); - - // see if the class already exists - if (!::GetClassInfo(hInst, szWordPadClass, &wndcls)) - { - // get default stuff - ::GetClassInfo(hInst, cs.lpszClass, &wndcls); - wndcls.style &= ~(CS_HREDRAW|CS_VREDRAW); - // register a new class - wndcls.lpszClassName = szWordPadClass; - wndcls.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDR_MAINFRAME)); - ASSERT(wndcls.hIcon != NULL); - if (!AfxRegisterClass(&wndcls)) - AfxThrowResourceException(); - } - cs.lpszClass = szWordPadClass; - CRect rect = theApp.m_rectInitialFrame; - if (rect.Width() > 0 && rect.Height() > 0) - { - // make sure window will be visible - CDisplayIC dc; - CRect rectDisplay(0, 0, dc.GetDeviceCaps(HORZRES), - dc.GetDeviceCaps(VERTRES)); - if (rectDisplay.PtInRect(rect.TopLeft()) && - rectDisplay.PtInRect(rect.BottomRight())) - { - cs.x = rect.left; - cs.y = rect.top; - cs.cx = rect.Width(); - cs.cy = rect.Height(); - } - } - return bRes; -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); - CMFCToolBarComboBoxButton::SetFlatMode (); - CMFCToolBarComboBoxButton::SetCenterVert (); - - CMFCFontComboBox::m_bDrawUsingFont = TRUE; - - if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) - return -1; - - if (!CreateMenuBar()) - return -1; - - if (!CreateToolBar()) - return -1; - - if (!CreateFormatBar()) - return -1; - - if (!CreateStatusBar()) - return -1; - - EnableDocking(CBRS_ALIGN_ANY); - - if (!CreateTaskPane()) - return -1; - - if (!CreateRulerBar()) - return -1; - - CMFCToolBar::AddToolBarForImageCollection (IDR_TOOLBAR_IMAGES); - CMFCToolBar::AddToolBarForImageCollection (IDR_BORDER_TYPE); - - CMFCToolBar::EnableQuickCustomization (); - - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndFormatBar.EnableDocking(CBRS_ALIGN_ANY); - m_wndTaskPane.EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT); - - DockPane(&m_wndMenuBar); - DockPane(&m_wndToolBar); - DockPane(&m_wndFormatBar); - DockPane(&m_wndTaskPane); - - CWnd* pView = GetDlgItem(AFX_IDW_PANE_FIRST); - if (pView != NULL) - { - pView->SetWindowPos(&wndBottom, 0, 0, 0, 0, - SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE); - } - - //---------------------------------------- - // Allow user-defined toolbars operations: - //---------------------------------------- - InitUserToolbars (NULL, - uiFirstUserToolBarId, - uiLastUserToolBarId); - - //-------------------- - // Set basic commands: - //-------------------- - CList lstBasicCommands; - lstBasicCommands.AddTail (ID_FILE_NEW); - lstBasicCommands.AddTail (ID_FILE_OPEN); - lstBasicCommands.AddTail (ID_FILE_SAVE); - lstBasicCommands.AddTail (ID_FILE_PRINT); - lstBasicCommands.AddTail (ID_APP_EXIT); - lstBasicCommands.AddTail (ID_EDIT_UNDO); - lstBasicCommands.AddTail (ID_EDIT_CUT); - lstBasicCommands.AddTail (ID_EDIT_COPY); - lstBasicCommands.AddTail (ID_EDIT_PASTE); - lstBasicCommands.AddTail (ID_EDIT_SELECT_ALL); - lstBasicCommands.AddTail (ID_EDIT_FIND); - lstBasicCommands.AddTail (ID_EDIT_REPEAT); - lstBasicCommands.AddTail (ID_EDIT_REPLACE); - lstBasicCommands.AddTail (ID_OLE_EDIT_PROPERTIES); - lstBasicCommands.AddTail (ID_VIEW_OPTIONS); - lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); - lstBasicCommands.AddTail (ID_VIEW_APP_LOOK); - lstBasicCommands.AddTail (ID_VIEW_FULL_SCREEN); - lstBasicCommands.AddTail (ID_OLE_INSERT_NEW); - lstBasicCommands.AddTail (ID_FORMAT_FONT); - lstBasicCommands.AddTail (ID_INSERT_BULLET); - lstBasicCommands.AddTail (ID_CHAR_COLOR); - lstBasicCommands.AddTail (ID_HELP_INDEX); - lstBasicCommands.AddTail (ID_APP_ABOUT); - lstBasicCommands.AddTail (ID_PARA_LEFT); - lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); - - CMFCToolBar::SetBasicCommands (lstBasicCommands); - - //-------------------------------------------------------------------- - // Enable conttol bar context menu (list of bars + customize command): - //-------------------------------------------------------------------- - EnablePaneMenu ( TRUE, ID_VIEW_CUSTOMIZE, - _T("Customize..."), ID_VIEW_TOOLBARS, - FALSE, TRUE); - - EnableFullScreenMode (ID_VIEW_FULL_SCREEN); - EnableFullScreenMainMenu (FALSE); - - return 0; -} - -BOOL CMainFrame::CreateMenuBar() -{ - //---------------------------------------------- - // Create menu bar (replaces the standard menu): - //---------------------------------------------- - if (!m_wndMenuBar.Create (this/*, WS_CHILD | WS_VISIBLE | CBRS_TOP, uiMenuBarId*/)) - { - TRACE0("Failed to create menubar\n"); - return FALSE; - } - - m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER | CBRS_BORDER_3D); - - m_wndMenuBar.EnableHelpCombobox (ID_HELP_FIND, _T("Type a question for help")); - - CString str; - str.LoadString(IDS_TITLE_MENUBAR); - m_wndMenuBar.SetWindowText(str); - return TRUE; -} - -BOOL CMainFrame::CreateToolBar() -{ - if (!m_wndToolBar.Create(this, - WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC | - CBRS_GRIPPER | CBRS_BORDER_3D)|| - !m_wndToolBar.LoadToolBar (IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return FALSE; // fail to create - } - - CString str; - str.LoadString(IDS_TITLE_TOOLBAR); - m_wndToolBar.SetWindowText(str); - - m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return TRUE; -} - -BOOL CMainFrame::CreateFormatBar() -{ - if (!m_wndFormatBar.Create(this, - WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| - CBRS_GRIPPER | CBRS_BORDER_3D, - ID_VIEW_FORMATBAR) || - !m_wndFormatBar.LoadToolBar (IDR_FORMATBAR)) - { - TRACE0("Failed to create FormatBar\n"); - return FALSE; // fail to create - } - - CString str; - str.LoadString(IDS_TITLE_FORMATBAR); - m_wndFormatBar.SetWindowText(str); - - m_wndFormatBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - return TRUE; -} - -BOOL CMainFrame::CreateTaskPane () -{ - CRect rectDummy(0, 0, 200, 400); - if (!m_wndTaskPane.Create(_T("Tasks Pane"), this, rectDummy, TRUE, ID_VIEW_TASK_PANE, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | AFX_CBRS_CLOSE | AFX_CBRS_FLOAT)) - { - TRACE0("Failed to create task pane\n"); - return FALSE; // fail to create - } - - m_wndTaskPane.EnableDocking (CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT); - DockPane(&m_wndTaskPane); - - return TRUE; -} - -BOOL CMainFrame::CreateRulerBar() -{ - if (!m_wndRulerBar.Create(this, - WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_HIDE_INPLACE, ID_VIEW_RULER)) - { - TRACE0("Failed to create ruler\n"); - return FALSE; // fail to create - } - return TRUE; -} - -BOOL CMainFrame::CreateStatusBar() -{ - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return FALSE; // fail to create - } - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame Operations - -HICON CMainFrame::GetIcon(int nDocType) -{ - switch (nDocType) - { - case RD_WINWORD6: - case RD_WORDPAD: - case RD_EMBEDDED: - case RD_RICHTEXT: - return m_hIconDoc; - case RD_TEXT: - case RD_OEMTEXT: - return m_hIconText; - case RD_WRITE: - return m_hIconWrite; - } - return m_hIconDoc; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWndEx::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWndEx::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - -void CMainFrame::OnFontChange() -{ - m_wndFormatBar.SendMessage(CWordPadApp::m_nPrinterChangedMsg); -} - -void CMainFrame::OnDevModeChange(LPTSTR lpDeviceName) -{ - theApp.NotifyPrinterChanged(); - CFrameWndEx::OnDevModeChange(lpDeviceName); //sends message to descendants -} - -void CMainFrame::OnSysColorChange() -{ - CFrameWndEx::OnSysColorChange(); - OnChangeLook (); -} - -void CMainFrame::ActivateFrame(int nCmdShow) -{ - CFrameWndEx::ActivateFrame(nCmdShow); - // make sure and display the toolbar, ruler, etc while loading a document. - OnIdleUpdateCmdUI(0, 0); - UpdateWindow(); -} - -void CMainFrame::OnSize(UINT nType, int cx, int cy) -{ - CFrameWndEx::OnSize(nType, cx, cy); - theApp.m_bMaximized = (nType == SIZE_MAXIMIZED); - if (nType == SIZE_RESTORED) - GetWindowRect(theApp.m_rectInitialFrame); -} - -LRESULT CMainFrame::OnBarState(WPARAM wParam, LPARAM lParam) -{ - if (lParam == -1) - return 0L; - ASSERT(lParam != RD_EMBEDDED); - if (wParam != 0) - { - if (IsTextType((int) lParam)) - { - // in text mode hide the ruler and format bar so that it is the default - // - // This CMainFrame class extends the CFrameWndEx class. - // GetPane is a method in the CFrameWndEx class which - // Returns a pointer to the pane that has the specified ID. - CBasePane* pBar = GetPane(ID_VIEW_FORMATBAR); - if (pBar != NULL) - { - // Set the docking mode, the pane alignment, and the pane style. - pBar->SetDockingMode(DT_STANDARD); - pBar->SetPaneAlignment(CBRS_ALIGN_LEFT); - pBar->SetPaneStyle(pBar->GetCurrentAlignment() | CBRS_TOOLTIPS); - pBar->ShowPane(TRUE, FALSE, FALSE); - } - // - - pBar = GetPane(ID_VIEW_RULER); - if (pBar != NULL) - { - pBar->ShowPane(FALSE, FALSE, FALSE); - } - } - HICON hIcon = GetIcon((int)lParam); - SendMessage(WM_SETICON, TRUE, (LPARAM)hIcon); - - } - return 0L; -} - -void CMainFrame::OnMove(int x, int y) -{ - CFrameWndEx::OnMove(x, y); - WINDOWPLACEMENT wp; - wp.length = sizeof(wp); - GetWindowPlacement(&wp); - theApp.m_rectInitialFrame = wp.rcNormalPosition; - CView* pView = GetActiveView(); - if (pView != NULL) - pView->SendMessage(WM_MOVE); -} - -LRESULT CMainFrame::OnOpenMsg(WPARAM, LPARAM lParam) -{ - TCHAR szAtomName[256]; - szAtomName[0] = NULL; - GlobalGetAtomName((ATOM)lParam, szAtomName, 256); - CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument(); - if (szAtomName[0] != NULL && pDoc != NULL) - { - if (lstrcmpi(szAtomName, pDoc->GetPathName()) == 0) - return TRUE; - } - return FALSE; -} - -void CMainFrame::OnHelpFinder() -{ - theApp.WinHelp(0, HELP_FINDER); -} - -void CMainFrame::OnDropFiles(HDROP hDropInfo) -{ - TCHAR szFileName[_MAX_PATH]; - ::DragQueryFile(hDropInfo, 0, szFileName, _MAX_PATH); - ::DragFinish(hDropInfo); - theApp.OpenDocumentFile(szFileName); -} - -BOOL CMainFrame::OnQueryNewPalette() -{ - CView* pView = GetActiveView(); - if (pView != NULL) - return (BOOL) pView->SendMessage(WM_QUERYNEWPALETTE); - return FALSE; -} - -void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) -{ - CView* pView = GetActiveView(); - if (pView != NULL) - pView->SendMessage(WM_PALETTECHANGED, (WPARAM)pFocusWnd->GetSafeHwnd()); -} - -void CMainFrame::OnViewCustomize() -{ - CWordPadView* pView = DYNAMIC_DOWNCAST (CWordPadView, GetActiveView()); - if (pView != NULL && pView->GetInPlaceActiveItem () != NULL) - { - return; - } - - //------------------------------------ - // Create a customize toolbars dialog: - //------------------------------------ - // - CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, - TRUE /* Automatic menus scaning */, - AFX_CUSTOMIZE_MENU_SHADOWS | AFX_CUSTOMIZE_TEXT_LABELS | - AFX_CUSTOMIZE_MENU_ANIMATIONS); - - pDlgCust->AddToolBar (_T("Format"), IDR_FORMATBAR); - // - - CMFCToolBarFontComboBox* pFontButton = m_wndFormatBar.CreateFontComboButton (); - pDlgCust->ReplaceButton (IDC_FONTNAME, *pFontButton); - delete pFontButton; - - CMFCToolBarFontSizeComboBox comboButtonFontSize (IDC_FONTSIZE, - GetCmdMgr ()->GetCmdImage (IDC_FONTSIZE, FALSE), - WS_TABSTOP|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL|CBS_DROPDOWN, - 10*m_wndFormatBar.m_szBaseUnits.cx + 10); - pDlgCust->ReplaceButton (IDC_FONTSIZE, comboButtonFontSize); - - CMFCColorMenuButton* pColorButton = m_wndFormatBar.CreateColorButton (); - pDlgCust->ReplaceButton (ID_CHAR_COLOR, *pColorButton); - delete pColorButton; - - CMFCToolBarMenuButton* pBorderTypeButton = m_wndFormatBar.CreateBorderTypeButton (); - pDlgCust->ReplaceButton (ID_BORDER_1, *pBorderTypeButton); - delete pBorderTypeButton; - - pDlgCust->EnableUserDefinedToolbars (); - pDlgCust->Create (); -} - -// -BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup) -{ - BOOL bRes = CFrameWndEx::OnShowPopupMenu (pMenuPopup); - - if (pMenuPopup != NULL && !pMenuPopup->IsCustomizePane()) - { - AdjustObjectSubmenu (pMenuPopup); - AdjustColorsMenu (pMenuPopup, ID_CHAR_COLOR); - } - - return bRes; -} -// - -void CMainFrame::AdjustObjectSubmenu (CMFCPopupMenu* pMenuPopup) -{ - ASSERT (pMenuPopup != NULL); - - if (pMenuPopup->GetParentPopupMenu () != NULL) - { - return; - } - - CMFCPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar (); - ASSERT (pMenuBar != NULL); - - int iIndex = pMenuBar->CommandToIndex (ID_OLE_VERB_POPUP); - if (iIndex < 0) - { - return; - } - - CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument(); - ASSERT_VALID (pDoc); - - // check for single selection - COleClientItem* pItem = pDoc->GetPrimarySelectedItem(GetActiveView()); - if (pItem == NULL || pItem->GetType() == OT_STATIC) - { - // no selection, or is 'static' item - return; - } - - // only include Convert... if there is a handler for ID_OLE_EDIT_CONVERT - UINT nConvertID = ID_OLE_EDIT_CONVERT; - AFX_CMDHANDLERINFO info; - if (!pDoc->OnCmdMsg(ID_OLE_EDIT_CONVERT, CN_COMMAND, NULL, &info)) - nConvertID = 0; - - HMENU hMenu = pMenuBar->ExportToMenu (); - ASSERT(hMenu != NULL); - - // update the menu - AfxOleSetEditMenu(pItem, - CMenu::FromHandle (hMenu), iIndex, - ID_OLE_VERB_FIRST, ID_OLE_VERB_LAST, nConvertID); - - pMenuBar->ImportFromMenu (hMenu); - ::DestroyMenu (hMenu); -} - -void CMainFrame::AdjustColorsMenu (CMFCPopupMenu* pMenuPopup, UINT uiID) -{ - CMFCPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar (); - ASSERT (pMenuBar != NULL); - - int iIndex = pMenuBar->CommandToIndex (uiID); - if (iIndex < 0) - { - return; - } - - if (DYNAMIC_DOWNCAST (CMFCColorMenuButton, pMenuBar->GetButton (iIndex)) != NULL) - { - return; - } - - CMFCColorMenuButton* pColorButton = m_wndFormatBar.CreateColorButton (); - pMenuBar->ReplaceButton (ID_CHAR_COLOR, *pColorButton, TRUE); - delete pColorButton; -} -//********************************************************************************** -LRESULT CMainFrame::OnHelpCustomizeToolbars(WPARAM wp, LPARAM /*lp*/) -{ - int iPageNum = (int) wp; - - // Test! - CString str; - str.Format (_T("Help about page number %d"), iPageNum); - - MessageBox (str); - - return 0; -} -//*************************************************************************************** -LRESULT CMainFrame::OnStartCustomize(WPARAM, LPARAM) -{ - CWordPadView* pView = DYNAMIC_DOWNCAST (CWordPadView, GetActiveView()); - if (pView == NULL) - { - return 0; - } - - pView->GetRichEditCtrl().SetSel (-1, 0); - return 0; -} -//*************************************************************************************** -LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp) -{ - LRESULT lres = CFrameWndEx::OnToolbarCreateNew (wp,lp); - if (lres == 0) - { - return 0; - } - - CMFCToolBar* pUserToolbar = (CMFCToolBar*) lres; - ASSERT_VALID (pUserToolbar); - - pUserToolbar->EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - pUserToolbar->AdjustLayout (); - return lres; -} -//******************************************************************************* -BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) -{ - //---------------------------------------------------- - // If Font/Size combobox has focus, we should redirect - // clipboard commands to its editbox: - //---------------------------------------------------- - if (HIWORD (wParam) == 1) // Command from accelerator - { - if (CMFCToolBarComboBoxButton::GetByCmd (IDC_FONTNAME, TRUE) != NULL || - CMFCToolBarComboBoxButton::GetByCmd (IDC_FONTSIZE, TRUE) != NULL) - { - // Either font combox or size combo are focused - UINT uiCmd = LOWORD (wParam); - switch (uiCmd) - { - case ID_EDIT_PASTE: - ::SendMessage (::GetFocus (), WM_PASTE, 0, 0); - return TRUE; - - case ID_EDIT_COPY: - ::SendMessage (::GetFocus (), WM_COPY, 0, 0); - return TRUE; - - case ID_EDIT_CUT: - ::SendMessage (::GetFocus (), WM_CUT, 0, 0); - return TRUE; - } - } - } - - return CFrameWndEx::OnCommand(wParam, lParam); -} -//************************************************************************************* -LRESULT CMainFrame::OnGetDocumentColors(WPARAM, LPARAM lp) -{ - CList* pLstDocColors = - (CList*) lp; - ASSERT_VALID (pLstDocColors); - - CWordPadView* pView = DYNAMIC_DOWNCAST (CWordPadView, GetActiveView()); - if (pView != NULL) - { - pView->GetDocumentColors (*pLstDocColors); - } - - return 0; -} -//************************************************************************************* -BOOL CMainFrame::OnTearOffMenu (CMFCPopupMenu* /*pMenuPopup*/, CPane* pBar) -{ - CMFCColorBar* pColorBar = DYNAMIC_DOWNCAST (CMFCColorBar, pBar); - if (pColorBar != NULL) - { - CWordPadView* pView = DYNAMIC_DOWNCAST (CWordPadView, GetActiveView()); - if (pView != NULL) - { - CList lstDocColors; - pView->GetDocumentColors (lstDocColors); - - pColorBar->SetDocumentColors (_T("Document's Colors"), lstDocColors); - } - } - - return TRUE; -} -//************************************************************************************** -BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) -{ - if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext)) - { - return FALSE; - } - - //---------------------------------------------------- - // Enable customization button fore all user toolbars: - //---------------------------------------------------- - for (int i = 0; i < iMaxUserToolbars; i ++) - { - CMFCToolBar* pUserToolbar = GetUserToolBarByIndex (i); - if (pUserToolbar != NULL) - { - pUserToolbar->EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); - } - } - - return TRUE; -} - -void CMainFrame::OnChangeLook () -{ - BOOL bIsLook2003 = CMFCVisualManager::GetInstance ()->IsKindOf ( - RUNTIME_CLASS (CMFCVisualManagerOffice2003)); - - m_wndRulerBar.CreateGDIObjects (); - m_wndRulerBar.RedrawWindow (); - - CWindowDC dc (NULL); - int nBitsPerPixel = dc.GetDeviceCaps (BITSPIXEL); - - m_wndTaskPane.UpdateIcons (); - m_wndTaskPane.EnableNavigationToolbar (bIsLook2003, - theApp.m_bHiColorIcons && nBitsPerPixel > 16 ? IDB_TASKSPANE_TOOLBAR : 0, CSize (16, 16)); - m_wndTaskPane.RecalcLayout (FALSE); - - //----------------------- - // Reload toolbar images: - //----------------------- - CMFCToolBar::ResetAllImages (); - - m_wndToolBar.LoadBitmap ( - theApp.m_bHiColorIcons && nBitsPerPixel > 16 ? IDB_MAINFRAME_HC : IDR_MAINFRAME); - - m_wndFormatBar.LoadBitmap (IDR_FORMATBAR); - - CMFCToolBar::AddToolBarForImageCollection (IDR_TOOLBAR_IMAGES, - theApp.m_bHiColorIcons && nBitsPerPixel > 16 ? IDR_TOOLBAR_IMAGES_HC : 0); - - CMFCToolBar::AddToolBarForImageCollection (IDR_BORDER_TYPE, IDR_BORDER_TYPE); - - RecalcLayout (); - RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); -} - -void CMainFrame::OnDummy() -{ - AfxMessageBox (ID_DUMMY); -} - -void CMainFrame::OnViewFullScreen() -{ - ShowFullScreen (); -} - -void CMainFrame::OnAskQuestion() -{ - CMFCToolBarComboBoxButton* pHelpCombo = m_wndMenuBar.GetHelpCombobox (); - if (pHelpCombo == NULL) - { - return; - } - - CString strQuestion = pHelpCombo->GetText (); - strQuestion.TrimLeft (); - strQuestion.TrimRight (); - - if (strQuestion.IsEmpty ()) - { - return; - } - - pHelpCombo->AddItem (strQuestion); - - CString str; - str.Format (_T("The question is: %s"), strQuestion); - - MessageBox (str); - - SetFocus (); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/mswd6_32.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/mswd6_32.h deleted file mode 100644 index 53f0fe364121a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/mswd6_32.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifndef MSWD6_32_H -#define MSWD6_32_H - -typedef unsigned long (pascal *PFN_RTF_CALLBACK)(int, int); - -extern "C" int pascal InitConverter32(HANDLE, char *); -extern "C" HANDLE pascal RegisterApp32(unsigned long, void *); -extern "C" int pascal IsFormatCorrect32(HANDLE, HANDLE); -extern "C" int pascal ForeignToRtf32(HANDLE, void *, HANDLE, HANDLE, HANDLE, PFN_RTF_CALLBACK); -extern "C" int pascal RtfToForeign32(HANDLE, LPSTORAGE, HANDLE, HANDLE, PFN_RTF_CALLBACK); - -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/multconv.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/multconv.cpp deleted file mode 100644 index b078c06a0545f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/multconv.cpp +++ /dev/null @@ -1,503 +0,0 @@ -// -// convert.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "multconv.h" -#include "mswd6_32.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -#ifdef CONVERTERS -CConverter* CConverter::m_pThis = NULL; -#endif - -#define BUFFSIZE 4096 - -CTrackFile::CTrackFile(CFrameWnd* pWnd) : CFile() -{ - m_nLastPercent = -1; - m_dwLength = 0; - m_pFrameWnd = pWnd; - VERIFY(m_strComplete.LoadString(IDS_COMPLETE)); - VERIFY(m_strWait.LoadString(IDS_PLEASE_WAIT)); - VERIFY(m_strSaving.LoadString(IDS_SAVING)); -// OutputPercent(0); -} - -CTrackFile::~CTrackFile() -{ - OutputPercent(100); - if (m_pFrameWnd != NULL) - m_pFrameWnd->SetMessageText(AFX_IDS_IDLEMESSAGE); -} - -UINT CTrackFile::Read(void FAR* lpBuf, UINT nCount) -{ - UINT n = CFile::Read(lpBuf, nCount); - if (m_dwLength != 0) - OutputPercent((int)((GetPosition()*100)/m_dwLength)); - return n; -} - -void CTrackFile::Write(const void FAR* lpBuf, UINT nCount) -{ - CFile::Write(lpBuf, nCount); - OutputString(m_strSaving); -// if (m_dwLength != 0) -// OutputPercent((int)((GetPosition()*100)/m_dwLength)); -} - -void CTrackFile::OutputString(LPCTSTR lpsz) -{ - if (m_pFrameWnd != NULL) - { - m_pFrameWnd->SetMessageText(lpsz); - CWnd* pBarWnd = m_pFrameWnd->GetMessageBar(); - if (pBarWnd != NULL) - pBarWnd->UpdateWindow(); - } -} - -void CTrackFile::OutputPercent(int nPercentComplete) -{ - if (m_pFrameWnd != NULL && m_nLastPercent != nPercentComplete) - { - m_nLastPercent = nPercentComplete; - TCHAR buf[64]; - int n = nPercentComplete; - wsprintf(buf, (n==100) ? m_strWait : m_strComplete, n); - OutputString(buf); - } -} - -COEMFile::COEMFile(CFrameWnd* pWnd) : CTrackFile(pWnd) -{ -} - -UINT COEMFile::Read(void FAR* lpBuf, UINT nCount) -{ - UINT n = CTrackFile::Read(lpBuf, nCount); - OemToCharBuffA((const char*)lpBuf, (char*)lpBuf, n); - return n; -} - -void COEMFile::Write(const void FAR* lpBuf, UINT nCount) -{ - CharToOemBuffA((const char*)lpBuf, (char*)lpBuf, nCount); - CTrackFile::Write(lpBuf, nCount); -} - -#ifdef CONVERTERS - -HGLOBAL CConverter::StringToHGLOBAL(LPCSTR pstr) -{ - HGLOBAL hMem = NULL; - if (pstr != NULL) - { - hMem = GlobalAlloc(GHND, (lstrlenA(pstr)*2)+1); - char* p = (char*) GlobalLock(hMem); - ASSERT(p != NULL); - if (p != NULL) - lstrcpyA(p, pstr); - GlobalUnlock(hMem); - } - return hMem; -} - -CConverter::CConverter(LPCSTR pszLibName, CFrameWnd* pWnd) : CTrackFile(pWnd) -{ - USES_CONVERSION; - m_hBuff = NULL; - m_pBuf = NULL; - m_nBytesAvail = 0; - m_nBytesWritten = 0; - m_nPercent = 0; - m_hEventFile = NULL; - m_hEventConv = NULL; - m_bDone = TRUE; - m_bConvErr = FALSE; - m_hFileName = NULL; - OFSTRUCT ofs; - if (OpenFile(pszLibName, &ofs, OF_EXIST) == HFILE_ERROR) - { - m_hLibCnv = NULL; - return; - } - m_hLibCnv = LoadLibraryA(pszLibName); - if (m_hLibCnv < (HINSTANCE)HINSTANCE_ERROR) - m_hLibCnv = NULL; - else - { - LoadFunctions(); - ASSERT(m_pInitConverter != NULL); - if (m_pInitConverter != NULL) - { - CString str = AfxGetAppName(); - str.MakeUpper(); - VERIFY(m_pInitConverter(AfxGetMainWnd()->GetSafeHwnd(), T2CA(str))); - } - } -} - -CConverter::CConverter(CFrameWnd* pWnd) : CTrackFile(pWnd) -{ - m_pInitConverter = NULL; - m_pIsFormatCorrect = NULL; - m_pForeignToRtf = NULL; - m_pRtfToForeign = NULL; - m_bConvErr = FALSE; - m_hFileName = NULL; -} - -CConverter::~CConverter() -{ - if (!m_bDone) // converter thread hasn't exited - { - WaitForConverter(); - m_nBytesAvail = 0; - VERIFY(ResetEvent(m_hEventFile)); - m_nBytesAvail = 0; - SetEvent(m_hEventConv); - WaitForConverter();// wait for DoConversion exit - VERIFY(ResetEvent(m_hEventFile)); - } - - if (m_hEventFile != NULL) - VERIFY(CloseHandle(m_hEventFile)); - if (m_hEventConv != NULL) - VERIFY(CloseHandle(m_hEventConv)); - if (m_hLibCnv != NULL) - FreeLibrary(m_hLibCnv); - if (m_hFileName != NULL) - GlobalFree(m_hFileName); -} - -void CConverter::WaitForConverter() -{ - // while event not signalled -- process messages - while (MsgWaitForMultipleObjects(1, &m_hEventFile, FALSE, INFINITE, - QS_SENDMESSAGE) != WAIT_OBJECT_0) - { - MSG msg; - PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE); - } -} - -void CConverter::WaitForBuffer() -{ - // while event not signalled -- process messages - while (MsgWaitForMultipleObjects(1, &m_hEventConv, FALSE, INFINITE, - QS_SENDMESSAGE) != WAIT_OBJECT_0) - { - MSG msg; - PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE); - } -} - -UINT CConverter::ConverterThread(LPVOID) -{ - ASSERT(m_pThis != NULL); - - HRESULT hRes = OleInitialize(NULL); - if (hRes != S_OK && hRes != S_FALSE) - { - ASSERT(FALSE); - } - m_pThis->DoConversion(); - OleUninitialize(); - - return 0; -} - -BOOL CConverter::IsFormatCorrect(LPCTSTR pszFileName) -{ - USES_CONVERSION; - int nRet; - if (m_hLibCnv == NULL || m_pIsFormatCorrect == NULL) - return FALSE; - - char buf[_MAX_PATH]; - strcpy(buf, T2CA(pszFileName)); - - CharToOemA(buf, buf); - - HGLOBAL hFileName = StringToHGLOBAL(buf); - HGLOBAL hDesc = GlobalAlloc(GHND, 256); - ASSERT(hDesc != NULL); - nRet = m_pIsFormatCorrect(hFileName, hDesc); - GlobalFree(hDesc); - GlobalFree(hFileName); - return (nRet == 1) ? TRUE : FALSE; -} - -// static callback function -int CALLBACK CConverter::WriteOutStatic(int cch, int nPercentComplete) -{ - ASSERT(m_pThis != NULL); - return m_pThis->WriteOut(cch, nPercentComplete); -} - -int CALLBACK CConverter::WriteOut(int cch, int nPercentComplete) -{ - ASSERT(m_hBuff != NULL); - m_nPercent = nPercentComplete; - if (m_hBuff == NULL) - return -9; - if (cch != 0) - { - WaitForBuffer(); - VERIFY(ResetEvent(m_hEventConv)); - m_nBytesAvail = cch; - SetEvent(m_hEventFile); - WaitForBuffer(); - } - return 0; //everything OK -} - -int CALLBACK CConverter::ReadInStatic(int /*flags*/, int nPercentComplete) -{ - ASSERT(m_pThis != NULL); - return m_pThis->ReadIn(nPercentComplete); -} - -int CALLBACK CConverter::ReadIn(int /*nPercentComplete*/) -{ - ASSERT(m_hBuff != NULL); - if (m_hBuff == NULL) - return -8; - - SetEvent(m_hEventFile); - WaitForBuffer(); - VERIFY(ResetEvent(m_hEventConv)); - - return m_nBytesAvail; -} - -BOOL CConverter::DoConversion() -{ - USES_CONVERSION; - m_nLastPercent = -1; -// m_dwLength = 0; // prevent Read/Write from displaying - m_nPercent = 0; - - ASSERT(m_hBuff != NULL); - ASSERT(m_pThis != NULL); - HGLOBAL hDesc = StringToHGLOBAL(""); - HGLOBAL hSubset = StringToHGLOBAL(""); - - int nRet; - if (m_bForeignToRtf) - { - ASSERT(m_pForeignToRtf != NULL); - ASSERT(m_hFileName != NULL); - nRet = m_pForeignToRtf(m_hFileName, NULL, m_hBuff, hDesc, hSubset, - (LPFNOUT)WriteOutStatic); - // wait for next CConverter::Read to come through - WaitForBuffer(); - VERIFY(ResetEvent(m_hEventConv)); - } - else - { - ASSERT(m_pRtfToForeign != NULL); - ASSERT(m_hFileName != NULL); - nRet = m_pRtfToForeign(m_hFileName, NULL, m_hBuff, hDesc, - (LPFNIN)ReadInStatic); - // don't need to wait for m_hEventConv - } - - GlobalFree(hDesc); - GlobalFree(hSubset); - if (m_pBuf != NULL) - GlobalUnlock(m_hBuff); - GlobalFree(m_hBuff); - - if (nRet != 0) - m_bConvErr = TRUE; - - m_bDone = TRUE; - m_nPercent = 100; - m_nLastPercent = -1; - - SetEvent(m_hEventFile); - - return (nRet == 0); -} - -void CConverter::LoadFunctions() -{ - m_pInitConverter = (PINITCONVERTER)GetProcAddress(m_hLibCnv, "InitConverter32"); - m_pIsFormatCorrect = (PISFORMATCORRECT)GetProcAddress(m_hLibCnv, "IsFormatCorrect32"); - m_pForeignToRtf = (PFOREIGNTORTF)GetProcAddress(m_hLibCnv, "ForeignToRtf32"); - m_pRtfToForeign = (PRTFTOFOREIGN)GetProcAddress(m_hLibCnv, "RtfToForeign32"); -} -#endif - -/////////////////////////////////////////////////////////////////////////////// - -BOOL CConverter::Open(LPCTSTR pszFileName, UINT nOpenFlags, - CFileException* pException) -{ - USES_CONVERSION; - // we convert to oem and back because of the following case - // test(c).txt becomes testc.txt in OEM and stays testc.txt to Ansi - char buf[_MAX_PATH]; - strcpy(buf, T2CA(pszFileName)); - CharToOemA(buf, buf); - OemToCharA(buf, buf); - - LPTSTR lpszFileNameT = A2T(buf); - - // let's make sure we could do what is wanted directly even though we aren't - m_bCloseOnDelete = FALSE; - m_hFile = hFileNull; - - BOOL bOpen = CFile::Open(lpszFileNameT, nOpenFlags, pException); - CFile::Close(); - if (!bOpen) - return FALSE; - - m_bForeignToRtf = !(nOpenFlags & (CFile::modeReadWrite | CFile::modeWrite)); - - // check for reading empty file - if (m_bForeignToRtf) - { - CFileStatus stat; - if (CFile::GetStatus(lpszFileNameT, stat) && stat.m_size == 0) - return TRUE; - } - - //set security attributes to inherit handle - SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - //create the events - m_hEventFile = CreateEvent(&sa, TRUE, FALSE, NULL); - m_hEventConv = CreateEvent(&sa, TRUE, FALSE, NULL); - //create the converter thread and create the events - - CharToOemA(buf, buf); - ASSERT(m_hFileName == NULL); - m_hFileName = StringToHGLOBAL(buf); - - m_pThis = this; - m_bDone = FALSE; - m_hBuff = GlobalAlloc(GHND, BUFFSIZE); - ASSERT(m_hBuff != NULL); - - AfxBeginThread(ConverterThread, this, THREAD_PRIORITY_NORMAL, 0, 0, &sa); - - return TRUE; -} - -// m_hEventConv -- the main thread signals this event when ready for more data -// m_hEventFile -- the converter signals this event when data is ready - -UINT CConverter::Read(void FAR* lpBuf, UINT nCount) -{ - ASSERT(m_bForeignToRtf); - if (m_bDone) - return 0; - // if converter is done - int cch = nCount; - BYTE* pBuf = (BYTE*)lpBuf; - while (cch != 0) - { - if (m_nBytesAvail == 0) - { - if (m_pBuf != NULL) - GlobalUnlock(m_hBuff); - m_pBuf = NULL; - SetEvent(m_hEventConv); - WaitForConverter(); - VERIFY(ResetEvent(m_hEventFile)); - if (m_bConvErr) - AfxThrowFileException(CFileException::genericException); - if (m_bDone) - return nCount - cch; - m_pBuf = (BYTE*)GlobalLock(m_hBuff); - ASSERT(m_pBuf != NULL); - } - int nBytes = min(cch, m_nBytesAvail); - memcpy(pBuf, m_pBuf, nBytes); - pBuf += nBytes; - m_pBuf += nBytes; - m_nBytesAvail -= nBytes; - cch -= nBytes; - OutputPercent(m_nPercent); - } - return nCount - cch; -} - -void CConverter::Write(const void FAR* lpBuf, UINT nCount) -{ - ASSERT(!m_bForeignToRtf); - - m_nBytesWritten += nCount; - while (nCount != 0) - { - WaitForConverter(); - VERIFY(ResetEvent(m_hEventFile)); - if (m_bConvErr) - AfxThrowFileException(CFileException::genericException); - m_nBytesAvail = min(nCount, BUFFSIZE); - nCount -= m_nBytesAvail; - BYTE* pBuf = (BYTE*)GlobalLock(m_hBuff); - ASSERT(pBuf != NULL); - memcpy(pBuf, lpBuf, m_nBytesAvail); - GlobalUnlock(m_hBuff); - SetEvent(m_hEventConv); - } - OutputString(m_strSaving); -} - -LONG CConverter::Seek(LONG lOff, UINT nFrom) -{ - if (lOff != 0 && nFrom != current) - AfxThrowNotSupportedException(); - return 0; -} - -void CConverter::Flush() -{ -} - -void CConverter::Close() -{ -} - -void CConverter::Abort() -{ -} - -CFile* CConverter::Duplicate() const -{ - AfxThrowNotSupportedException(); - return NULL; -} - -void CConverter::LockRange(DWORD, DWORD) -{ - AfxThrowNotSupportedException(); -} - -void CConverter::UnlockRange(DWORD, DWORD) -{ - AfxThrowNotSupportedException(); -} - -void CConverter::SetLength(DWORD) -{ - AfxThrowNotSupportedException(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/multconv.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/multconv.h deleted file mode 100644 index 2435187de6517..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/multconv.h +++ /dev/null @@ -1,141 +0,0 @@ -// -// convert.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifdef CONVERTERS - -///////////////////////////////////////////////////////////////////////////// -// CConverter - -typedef int (CALLBACK *LPFNOUT)(int cch, int nPercentComplete); -typedef int (CALLBACK *LPFNIN)(int flags, int nPercentComplete); -typedef BOOL (FAR PASCAL *PINITCONVERTER)(HWND hWnd, LPCSTR lpszModuleName); -typedef BOOL (FAR PASCAL *PISFORMATCORRECT)(HANDLE ghszFile, HANDLE ghszClass); -typedef int (FAR PASCAL *PFOREIGNTORTF)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff, - HANDLE ghszClass, HANDLE ghszSubset, LPFNOUT lpfnOut); -typedef int (FAR PASCAL *PRTFTOFOREIGN)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff, - HANDLE ghszClass, LPFNIN lpfnIn); - -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTrackFile -class CTrackFile : public CFile -{ -public: -//Construction - CTrackFile(CFrameWnd* pWnd); - ~CTrackFile(); - -//Attributes - int m_nLastPercent; - ULONGLONG m_dwLength; - CFrameWnd* m_pFrameWnd; - CString m_strComplete; - CString m_strWait; - CString m_strSaving; -//Operations - void OutputPercent(int nPercentComplete = 0); - void OutputString(LPCTSTR lpsz); - virtual UINT Read(void FAR* lpBuf, UINT nCount); - virtual void Write(const void FAR* lpBuf, UINT nCount); -}; - -class COEMFile : public CTrackFile -{ -public: - COEMFile(CFrameWnd* pWnd); - virtual UINT Read(void FAR* lpBuf, UINT nCount); - virtual void Write(const void FAR* lpBuf, UINT nCount); -}; - -#ifdef CONVERTERS - -class CConverter : public CTrackFile -{ -public: - CConverter(LPCSTR pszLibName, CFrameWnd* pWnd = NULL); -protected: - CConverter(CFrameWnd* pWnd = NULL); - -public: -//Attributes - int m_nPercent; - BOOL m_bDone; - BOOL m_bConvErr; - - virtual ULONGLONG GetPosition() const - { - return 0; - } - - virtual ULONGLONG GetLength() const - { - ASSERT_VALID(this); - return 1; - } - -// Operations - BOOL IsFormatCorrect(LPCTSTR pszFileName); - BOOL DoConversion(); - virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, - CFileException* pError = NULL); - void WaitForConverter(); - void WaitForBuffer(); - -// Overridables - virtual LONG Seek(LONG lOff, UINT nFrom); - - virtual UINT Read(void* lpBuf, UINT nCount); - virtual void Write(const void* lpBuf, UINT nCount); - - virtual void Abort(); - virtual void Flush(); - virtual void Close(); - -// Unsupported - virtual CFile* Duplicate() const; - virtual void LockRange(DWORD dwPos, DWORD dwCount); - virtual void UnlockRange(DWORD dwPos, DWORD dwCount); - virtual void SetLength(DWORD dwNewLen); - -//Implementation -public: - ~CConverter(); - -protected: - int m_nBytesAvail; - int m_nBytesWritten; - BYTE* m_pBuf; - HANDLE m_hEventFile; - HANDLE m_hEventConv; - BOOL m_bForeignToRtf; - HGLOBAL m_hBuff; - HGLOBAL m_hFileName; - void LoadFunctions(); - HINSTANCE m_hLibCnv; - PINITCONVERTER m_pInitConverter; - PISFORMATCORRECT m_pIsFormatCorrect; - PFOREIGNTORTF m_pForeignToRtf; - PRTFTOFOREIGN m_pRtfToForeign; - int CALLBACK WriteOut(int cch, int nPercentComplete); - int CALLBACK ReadIn(int nPercentComplete); - static HGLOBAL StringToHGLOBAL(LPCSTR pstr); - static int CALLBACK WriteOutStatic(int cch, int nPercentComplete); - static int CALLBACK ReadInStatic(int flags, int nPercentComplete); - static UINT ConverterThread(LPVOID pParam); - static CConverter *m_pThis; -}; - -#endif - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/options.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/options.cpp deleted file mode 100644 index 66b78595dc0d5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/options.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// options.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "strings.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDocOptions - -void CDocOptions::SaveDockState(CDockState& ds, LPCTSTR lpszProfileName, LPCTSTR lpszLayout) -{ - CMemFile file; - CArchive ar(&file, CArchive::store); - ds.Serialize(ar); - ar.Close(); - int nSize = (int) file.GetLength(); - ASSERT(nSize < 4096); - BYTE* p = new BYTE[nSize]; - file.SeekToBegin(); - file.Read(p, nSize); - theApp.WriteProfileBinary(lpszProfileName, lpszLayout, p, nSize); - delete [] p; -} - -void CDocOptions::SaveOptions(LPCTSTR lpszProfileName) -{ - SaveDockState(m_ds1, lpszProfileName, szLayout1); - SaveDockState(m_ds2, lpszProfileName, szLayout2); - theApp.WriteProfileInt(lpszProfileName, szWrap, m_nWordWrap); -} - -void CDocOptions::LoadDockState(CDockState& ds, LPCTSTR lpszProfileName, LPCTSTR lpszLayout) -{ - BYTE* p; - UINT nLen = 0; - if (theApp.GetProfileBinary(lpszProfileName, lpszLayout, &p, &nLen)) - { - ASSERT(nLen < 4096); - CMemFile file; - file.Write(p, nLen); - file.SeekToBegin(); - CArchive ar(&file, CArchive::load); - ds.Serialize(ar); - ar.Close(); - delete p; - } -} - -void CDocOptions::LoadOptions(LPCTSTR lpszProfileName) -{ - LoadDockState(m_ds1, lpszProfileName, szLayout1); - LoadDockState(m_ds2, lpszProfileName, szLayout2); - m_nWordWrap = theApp.GetProfileInt(lpszProfileName, szWrap, m_nDefWrap); -} - -///////////////////////////////////////////////////////////////////////////// -// CUnit - -const CUnit& CUnit::operator=(const CUnit& unit) -{ - m_nTPU = unit.m_nTPU; - m_nSmallDiv = unit.m_nSmallDiv; - m_nMediumDiv = unit.m_nMediumDiv; - m_nLargeDiv = unit.m_nLargeDiv; - m_nMinMove = unit.m_nMinMove; - m_nAbbrevID = unit.m_nAbbrevID; - m_bSpaceAbbrev = unit.m_bSpaceAbbrev; - m_strAbbrev = unit.m_strAbbrev; - return *this; -} - -CUnit::CUnit(int nTPU, int nSmallDiv, int nMediumDiv, int nLargeDiv, - int nMinMove, UINT nAbbrevID, BOOL bSpaceAbbrev) -{ - m_nTPU = nTPU; - m_nSmallDiv = nSmallDiv; - m_nMediumDiv = nMediumDiv; - m_nLargeDiv = nLargeDiv; - m_nMinMove = nMinMove; - m_nAbbrevID = nAbbrevID; - m_bSpaceAbbrev = bSpaceAbbrev; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/options.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/options.h deleted file mode 100644 index 7f717eb69df55..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/options.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// options.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CUnit -{ -public: - int m_nTPU; - int m_nSmallDiv; // small divisions - small line displayed - int m_nMediumDiv; // medium divisions - large line displayed - int m_nLargeDiv; // large divisions - numbers displayed - int m_nMinMove; // minimum tracking movements - UINT m_nAbbrevID; - BOOL m_bSpaceAbbrev; // put space before abbreviation - CString m_strAbbrev;// cm, pt, pi, ", in, inch, inches - - CUnit() {} - CUnit(int nTPU, int nSmallDiv, int nMediumDiv, int nLargeDiv, - int nMinMove, UINT nAbbrevID, BOOL bSpaceAbbrev); - const CUnit& operator=(const CUnit& unit); -}; - -class CDocOptions -{ -public: - CDocOptions(int nDefWrap) {m_nDefWrap = nDefWrap;} - CDockState m_ds1; - CDockState m_ds2; - int m_nWordWrap; - int m_nDefWrap; - void SaveOptions(LPCTSTR lpsz); - void LoadOptions(LPCTSTR lpsz); - void SaveDockState(CDockState& ds, LPCTSTR lpszProfileName, - LPCTSTR lpszLayout); - void LoadDockState(CDockState& ds, LPCTSTR lpszProfileName, - LPCTSTR lpszLayout); - CDockState& GetDockState(BOOL bPrimary) {return (bPrimary) ? m_ds1 : m_ds2;} -}; - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/optionsh.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/optionsh.cpp deleted file mode 100644 index 608ffdcf5ed3c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/optionsh.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// -// optionsh.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "unitspag.h" -#include "docopt.h" -#include "optionsh.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// COptionSheet - -COptionSheet::COptionSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) - : CCSPropertySheet(nIDCaption, pParentWnd, iSelectPage), - pageText(IDS_TEXT_OPTIONS), pageRTF(IDS_RTF_OPTIONS), - pageWord(IDS_WORD6_OPTIONS), pageWrite(IDS_WRITE_OPTIONS), - pageEmbedded() -{ - units.m_nUnits = theApp.GetUnits(); - units.m_bWordSel = theApp.m_bWordSel; - pageText.m_nWordWrap = theApp.GetDocOptions(RD_TEXT).m_nWordWrap; - pageRTF.m_nWordWrap = theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap; - pageWord.m_nWordWrap = theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap; - pageWrite.m_nWordWrap = theApp.GetDocOptions(RD_WRITE).m_nWordWrap; - pageEmbedded.m_nWordWrap = theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap; - SetPageButtons(pageText, theApp.GetDockState(RD_TEXT)); - SetPageButtons(pageRTF, theApp.GetDockState(RD_RICHTEXT)); - SetPageButtons(pageWord, theApp.GetDockState(RD_WINWORD6)); - SetPageButtons(pageWrite, theApp.GetDockState(RD_WRITE)); - SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED)); - SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE)); - AddPage(&units); - AddPage(&pageText); - AddPage(&pageRTF); - AddPage(&pageWord); - AddPage(&pageWrite); - AddPage(&pageEmbedded); -} - -void COptionSheet::SetPageButtons(CDocOptPage& page, CDockState& ds) -{ - if (ds.m_arrBarInfo.GetSize() == 0) - { - page.m_bFormatBar = page.m_bRulerBar = TRUE; - page.m_bToolBar = page.m_bStatusBar = TRUE; - } - else - { - for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++) - { - CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i]; - ASSERT(pInfo != NULL); - if (pInfo) - { - switch (pInfo->m_nBarID) - { - case ID_VIEW_FORMATBAR: - page.m_bFormatBar = page.m_bFormatBar || pInfo->m_bVisible; - break; - case ID_VIEW_RULER: - page.m_bRulerBar = page.m_bRulerBar || pInfo->m_bVisible; - break; - case ID_VIEW_TOOLBAR: - page.m_bToolBar = page.m_bToolBar || pInfo->m_bVisible; - break; - case ID_VIEW_STATUS_BAR: - page.m_bStatusBar = page.m_bStatusBar || pInfo->m_bVisible; - break; - } - } - } - } -} - -void COptionSheet::SetState(CDocOptPage& page, CDockState& ds) -{ - for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++) - { - CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i]; - ASSERT(pInfo != NULL); - if (pInfo) - { - switch (pInfo->m_nBarID) - { - case ID_VIEW_FORMATBAR: - pInfo->m_bVisible = page.m_bFormatBar; - break; - case ID_VIEW_RULER: - pInfo->m_bVisible = page.m_bRulerBar; - break; - case ID_VIEW_TOOLBAR: - pInfo->m_bVisible = page.m_bToolBar; - break; - case ID_VIEW_STATUS_BAR: - pInfo->m_bVisible = page.m_bStatusBar; - break; - } - } - } -} - -BEGIN_MESSAGE_MAP(COptionSheet, CCSPropertySheet) - //{{AFX_MSG_MAP(COptionSheet) - ON_WM_CREATE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// COptionSheet message handlers - -INT_PTR COptionSheet::DoModal() -{ - INT_PTR nRes = CCSPropertySheet::DoModal(); - if (nRes == IDOK) - { - SetState(pageText, theApp.GetDockState(RD_TEXT)); - SetState(pageRTF, theApp.GetDockState(RD_RICHTEXT)); - SetState(pageWord, theApp.GetDockState(RD_WINWORD6)); - SetState(pageWrite, theApp.GetDockState(RD_WRITE)); - SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED)); - SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE)); - theApp.SetUnits(units.m_nUnits); - theApp.m_bWordSel = units.m_bWordSel; - theApp.GetDocOptions(RD_TEXT).m_nWordWrap = pageText.m_nWordWrap; - theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap = pageRTF.m_nWordWrap; - theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap = pageWord.m_nWordWrap; - theApp.GetDocOptions(RD_WRITE).m_nWordWrap = pageWrite.m_nWordWrap; - theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap = pageEmbedded.m_nWordWrap; - } - return nRes; -} - -///////////////////////////////////////////////////////////////////////////// -// COptionSheet message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/optionsh.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/optionsh.h deleted file mode 100644 index 9cbf4d3a0f05c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/optionsh.h +++ /dev/null @@ -1,53 +0,0 @@ -// -// optionsh.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// COptionSheet - -class COptionSheet : public CCSPropertySheet -{ -// Construction -public: - COptionSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - -// Attributes -public: - CUnitsPage units; - CDocOptPage pageText; - CDocOptPage pageRTF; - CDocOptPage pageWord; - CDocOptPage pageWrite; - CEmbeddedOptPage pageEmbedded; - -// Operations -public: - INT_PTR DoModal(); - void SetPageButtons(CDocOptPage& page, CDockState& ds); - void SetState(CDocOptPage& page, CDockState& ds); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(COptionSheet) - //}}AFX_VIRTUAL - -// Implementation -public: - - // Generated message map functions -protected: - //{{AFX_MSG(COptionSheet) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/pageset.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/pageset.cpp deleted file mode 100644 index 8daa6d029cc5e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/pageset.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -// pageset.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "resource.h" -#include "pageset.h" -#include "ruler.h" -#include "ddxm.h" -#include "helpids.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPageSetupDlg dialog - -const DWORD CPageSetupDlg::m_nHelpIDs[] = -{ - IDC_EDIT_TM, IDH_WORDPAD_TOPMARGIN, - IDC_EDIT_BM, IDH_WORDPAD_BOTTOMMARGIN, - IDC_EDIT_LM, IDH_WORDPAD_LEFTMARGIN, - IDC_EDIT_RM, IDH_WORDPAD_RIGHTMARGIN, - IDC_BOX, IDH_COMM_GROUPBOX, - 0, 0 -}; - -CPageSetupDlg::CPageSetupDlg(CWnd* pParent /*=NULL*/) - : CCSDialog(CPageSetupDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CPageSetupDlg) - m_nTopMargin = 0; - m_nRightMargin = 0; - m_nLeftMargin = 0; - m_nBottomMargin = 0; - //}}AFX_DATA_INIT -} - -void CPageSetupDlg::DoDataExchange(CDataExchange* pDX) -{ - CCSDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPageSetupDlg) - DDX_Twips(pDX, IDC_EDIT_TM, m_nTopMargin); - DDV_MinMaxTwips(pDX, m_nTopMargin, -31680, 31680); - DDX_Twips(pDX, IDC_EDIT_RM, m_nRightMargin); - DDV_MinMaxTwips(pDX, m_nRightMargin, -31680, 31680); - DDX_Twips(pDX, IDC_EDIT_LM, m_nLeftMargin); - DDV_MinMaxTwips(pDX, m_nLeftMargin, -31680, 31680); - DDX_Twips(pDX, IDC_EDIT_BM, m_nBottomMargin); - DDV_MinMaxTwips(pDX, m_nBottomMargin, -31680, 31680); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CPageSetupDlg, CCSDialog) - //{{AFX_MSG_MAP(CPageSetupDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPageSetupDlg message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/pageset.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/pageset.h deleted file mode 100644 index bcea987392729..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/pageset.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// pageset.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CPageSetupDlg dialog - -class CPageSetupDlg : public CCSDialog -{ -// Construction -public: - CPageSetupDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CPageSetupDlg) - enum { IDD = IDD_PAGE_SETUP_DIALOG }; - int m_nTopMargin; - int m_nRightMargin; - int m_nLeftMargin; - int m_nBottomMargin; - //}}AFX_DATA - -// Implementation - static const DWORD m_nHelpIDs[]; - virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - // Generated message map functions - //{{AFX_MSG(CPageSetupDlg) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/bitmap1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/bitmap1.bmp deleted file mode 100644 index 0b9671321c04c..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/bitmap1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/border_type.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/border_type.bmp deleted file mode 100644 index 5c17a198744d0..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/border_type.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/font.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/font.bmp deleted file mode 100644 index 16c86a6d42cbc..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/font.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/formatba.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/formatba.bmp deleted file mode 100644 index 2764eefb08fdb..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/formatba.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/full_scr.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/full_scr.bmp deleted file mode 100644 index 8fdbd72165395..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/full_scr.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/iconnote.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/iconnote.ico deleted file mode 100644 index 99ffb4c6d7485..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/iconnote.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/main1.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/main1.bmp deleted file mode 100644 index 98d34f9b3a5f6..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/main1.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/mainfram_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/mainfram_hc.bmp deleted file mode 100644 index 23633f0bd808e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/mainfram_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rtfdoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rtfdoc.ico deleted file mode 100644 index 726f83de4cd40..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rtfdoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerbl.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerbl.bmp deleted file mode 100644 index 1b0e5b90eefce..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerbl.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerblm.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerblm.bmp deleted file mode 100644 index 9c2b707343340..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerblm.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerdo.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerdo.bmp deleted file mode 100644 index dfb59f839aaab..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerdo.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerdom.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerdom.bmp deleted file mode 100644 index 64807f2d43411..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerdom.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerta.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerta.bmp deleted file mode 100644 index 1cb900982df74..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerta.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulertam.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulertam.bmp deleted file mode 100644 index 91ebe55174b24..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulertam.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerup.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerup.bmp deleted file mode 100644 index 617db27f7ab64..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerup.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerupm.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerupm.bmp deleted file mode 100644 index 84549f91742cb..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/rulerupm.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/srvr.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/srvr.bmp deleted file mode 100644 index eabfe8536cfcf..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/srvr.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/tasks.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/tasks.bmp deleted file mode 100644 index e2ab28aaed303..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/tasks.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/tasks_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/tasks_hc.bmp deleted file mode 100644 index 2c1044bd28dcd..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/tasks_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/taskspanetoolbar.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/taskspanetoolbar.bmp deleted file mode 100644 index 60a0501611b25..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/taskspanetoolbar.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/textdoc.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/textdoc.ico deleted file mode 100644 index d523c8a1d1a54..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/textdoc.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/toolbar_images.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/toolbar_images.bmp deleted file mode 100644 index 510aabbbf8942..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/toolbar_images.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/toolbar_images_hc.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/toolbar_images_hc.bmp deleted file mode 100644 index 9f6d934c21187..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/toolbar_images_hc.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordp48.bmp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordp48.bmp deleted file mode 100644 index f77087b78108b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordp48.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordpad.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordpad.ico deleted file mode 100644 index d56fbcdfdf6ea..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordpad.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordpad.rc2 b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordpad.rc2 deleted file mode 100644 index 726eca82595fe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/wordpad.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// WORDPAD.RC2 - resources App Studio does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by App Studio -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/write.ico b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/write.ico deleted file mode 100644 index c2662c61d3eb3..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/res/write.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ruler.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ruler.cpp deleted file mode 100644 index f12158d42fb9e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ruler.cpp +++ /dev/null @@ -1,890 +0,0 @@ -// -// ruler.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "ruler.h" -#include "wordpvw.h" -#include "wordpdoc.h" -#include "strings.h" -#include - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -#define HEIGHT 17 -#define RULERBARHEIGHT 17 - -CRulerItem::CRulerItem(UINT nBitmapID) -{ - m_nAlignment = TA_CENTER; - m_pDC = NULL; - m_bTrack = FALSE; - m_hbm = NULL; - m_hbmMask = NULL; - if (nBitmapID != 0) - { - m_hbmMask = ::LoadBitmap( - AfxFindResourceHandle(MAKEINTRESOURCE(nBitmapID+1), RT_BITMAP), - MAKEINTRESOURCE(nBitmapID+1)); - ASSERT(m_hbmMask != NULL); - VERIFY(LoadMaskedBitmap(MAKEINTRESOURCE(nBitmapID))); - BITMAP bm; - ::GetObject(m_hbm, sizeof(BITMAP), &bm); - m_size = CSize(bm.bmWidth, bm.bmHeight); - } -} - -CRulerItem::~CRulerItem() -{ - if (m_hbm != NULL) - ::DeleteObject(m_hbm); - if (m_hbmMask != NULL) - ::DeleteObject(m_hbmMask); -} - -BOOL CRulerItem::LoadMaskedBitmap(LPCTSTR lpszResourceName) -{ - ASSERT(lpszResourceName != NULL); - - if (m_hbm != NULL) - ::DeleteObject(m_hbm); - - HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_BITMAP); - HRSRC hRsrc = ::FindResource(hInst, lpszResourceName, RT_BITMAP); - if (hRsrc == NULL) - return FALSE; - - m_hbm = AfxLoadSysColorBitmap(hInst, hRsrc); - return (m_hbm != NULL); -} - -void CRulerItem::SetHorzPosTwips(int nXPos) -{ - if (GetHorzPosTwips() != nXPos) - { - if (m_bTrack) - DrawFocusLine(); - Invalidate(); - m_nXPosTwips = nXPos; - Invalidate(); - if (m_bTrack) - DrawFocusLine(); - } -} - -void CRulerItem::TrackHorzPosTwips(int nXPos, BOOL /*bOnRuler*/) -{ - int nMin = GetMin(); - int nMax = GetMax(); - if (nXPos < nMin) - nXPos = nMin; - if (nXPos > nMax) - nXPos = nMax; - SetHorzPosTwips(nXPos); -} - -void CRulerItem::DrawFocusLine() -{ - if (GetHorzPosTwips() != 0) - { - m_rcTrack.left = m_rcTrack.right = GetHorzPosPix(); - ASSERT(m_pDC != NULL); - int nLeft = m_rcTrack.left + 16; - m_pDC->MoveTo(nLeft, m_rcTrack.top); - m_pDC->LineTo(nLeft, m_rcTrack.bottom); - } -} - -void CRulerItem::SetTrack(BOOL b) -{ - m_bTrack = b; - - if (m_pDC != NULL) // just in case we lost focus Capture somewhere - { - DrawFocusLine(); - m_pDC->RestoreDC(-1); - delete m_pDC ; - m_pDC = NULL; - } - if (m_bTrack) - { - CWordPadView* pView = (CWordPadView*)m_pRuler->GetView(); - ASSERT(pView != NULL); - pView->GetClientRect(&m_rcTrack); - m_pDC = new CWindowDC(pView); - m_pDC->SaveDC(); - m_pDC->SelectObject(&m_pRuler->penFocusLine); - m_pDC->SetROP2(R2_XORPEN); - DrawFocusLine(); - } -} - -void CRulerItem::Invalidate() -{ - CRect rc = GetHitRectPix(); - m_pRuler->RulerToClient(rc.TopLeft()); - m_pRuler->RulerToClient(rc.BottomRight()); - m_pRuler->InvalidateRect(rc); -} - -CRect CRulerItem::GetHitRectPix() -{ - int nx = GetHorzPosPix(); - return CRect( - CPoint( - (m_nAlignment == TA_CENTER) ? (nx - m_size.cx/2) : - (m_nAlignment == TA_LEFT) ? nx : nx - m_size.cx - , m_nYPosPix - ), - m_size); -} - -void CRulerItem::Draw(CDC& dc) -{ - CDC dcBitmap; - dcBitmap.CreateCompatibleDC(&dc); - CPoint pt(GetHorzPosPix(), GetVertPosPix()); - - HGDIOBJ hbm = ::SelectObject(dcBitmap.m_hDC, m_hbmMask); - - // do mask part - if (m_nAlignment == TA_CENTER) - dc.BitBlt(pt.x - m_size.cx/2, pt.y, m_size.cx, m_size.cy, &dcBitmap, 0, 0, SRCAND); - else if (m_nAlignment == TA_LEFT) - dc.BitBlt(pt.x, pt.y, m_size.cx, m_size.cy, &dcBitmap, 0, 0, SRCAND); - else // TA_RIGHT - dc.BitBlt(pt.x - m_size.cx, pt.y, m_size.cx, m_size.cy, &dcBitmap, 0, 0, SRCAND); - - // do image part - ::SelectObject(dcBitmap.m_hDC, m_hbm); - - if (m_nAlignment == TA_CENTER) - dc.BitBlt(pt.x - m_size.cx/2, pt.y, m_size.cx, m_size.cy, &dcBitmap, 0, 0, SRCINVERT); - else if (m_nAlignment == TA_LEFT) - dc.BitBlt(pt.x, pt.y, m_size.cx, m_size.cy, &dcBitmap, 0, 0, SRCINVERT); - else // TA_RIGHT - dc.BitBlt(pt.x - m_size.cx, pt.y, m_size.cx, m_size.cy, &dcBitmap, 0, 0, SRCINVERT); - - ::SelectObject(dcBitmap.m_hDC, hbm); -} - -CComboRulerItem::CComboRulerItem(UINT nBitmapID1, UINT nBitmapID2, CRulerItem& item) - : CRulerItem(nBitmapID1), m_secondary(nBitmapID2) , m_link(item) -{ - m_bHitPrimary = TRUE; -} - -BOOL CComboRulerItem::HitTestPix(CPoint pt) -{ - m_bHitPrimary = FALSE; - if (CRulerItem::GetHitRectPix().PtInRect(pt)) - m_bHitPrimary = TRUE; - else - return m_secondary.HitTestPix(pt); - return TRUE; -} - -void CComboRulerItem::Draw(CDC& dc) -{ - CRulerItem::Draw(dc); - m_secondary.Draw(dc); -} - -void CComboRulerItem::SetHorzPosTwips(int nXPos) -{ - if (m_bHitPrimary) // only change linked items by delta - m_link.SetHorzPosTwips(m_link.GetHorzPosTwips() + nXPos - GetHorzPosTwips()); - CRulerItem::SetHorzPosTwips(nXPos); - m_secondary.SetHorzPosTwips(nXPos); -} - -void CComboRulerItem::TrackHorzPosTwips(int nXPos, BOOL /*bOnRuler*/) -{ - int nMin = GetMin(); - int nMax = GetMax(); - if (nXPos < nMin) - nXPos = nMin; - if (nXPos > nMax) - nXPos = nMax; - SetHorzPosTwips(nXPos); -} - -void CComboRulerItem::SetVertPos(int nYPos) -{ - m_secondary.SetVertPos(nYPos); - nYPos += m_secondary.GetHitRectPix().Height(); - CRulerItem::SetVertPos(nYPos); -} - -void CComboRulerItem::SetAlignment(int nAlign) -{ - CRulerItem::SetAlignment(nAlign); - m_secondary.SetAlignment(nAlign); -} - -void CComboRulerItem::SetRuler(CRulerBar* pRuler) -{ - m_pRuler = pRuler; - m_secondary.SetRuler(pRuler); -} - -void CComboRulerItem::SetBounds(int nMin, int nMax) -{ - CRulerItem::SetBounds(nMin, nMax); - m_secondary.SetBounds(nMin, nMax); -} - -int CComboRulerItem::GetMin() -{ - if (m_bHitPrimary) - { - int nPDist = GetHorzPosTwips() - CRulerItem::GetMin(); - int nLDist = m_link.GetHorzPosTwips() - m_link.GetMin(); - return GetHorzPosTwips() - min(nPDist, nLDist); - } - else - return CRulerItem::GetMin(); -} - -int CComboRulerItem::GetMax() -{ - if (m_bHitPrimary) - { - int nPDist = CRulerItem::GetMax() - GetHorzPosTwips(); - int nLDist = m_link.GetMax() - m_link.GetHorzPosTwips(); - int nMinDist = (nPDist < nLDist) ? nPDist : nLDist; - return GetHorzPosTwips() + nMinDist; - } - else - return CRulerItem::GetMax(); -} - -void CTabRulerItem::TrackHorzPosTwips(int nXPos, BOOL bOnRuler) -{ - if (bOnRuler) - CRulerItem::TrackHorzPosTwips(nXPos, bOnRuler); - else - CRulerItem::TrackHorzPosTwips(0, bOnRuler); -} - - -BEGIN_MESSAGE_MAP(CRulerBar, CPane) - //{{AFX_MSG_MAP(CRulerBar) - ON_WM_LBUTTONDOWN() - ON_WM_LBUTTONUP() - ON_WM_MOUSEMOVE() - ON_WM_SYSCOLORCHANGE() - ON_WM_WINDOWPOSCHANGING() - ON_WM_SHOWWINDOW() - ON_WM_WINDOWPOSCHANGED() - ON_WM_CREATE() - //}}AFX_MSG_MAP - ON_MESSAGE(WM_SIZEPARENT, OnSizeParent) - // Global help commands -END_MESSAGE_MAP() - -CRulerBar::CRulerBar(BOOL b3DExt) : - m_leftmargin(IDB_RULER_BLOCK, IDB_RULER_UP, m_indent), - m_indent(IDB_RULER_DOWN), - m_rightmargin(IDB_RULER_UP), - m_tabItem(IDB_RULER_TAB) -{ - m_bDeferInProgress = FALSE; - m_leftmargin.SetRuler(this); - m_indent.SetRuler(this); - m_rightmargin.SetRuler(this); - - // all of the tab stops share handles - for (int i=0;iGetPaperSize(), pView->GetMargins()); - Update(pView->GetParaFormatSelection()); - CRect rect; - pView->GetRichEditCtrl().GetRect(&rect); - CPoint pt = rect.TopLeft(); - pView->ClientToScreen(&pt); - ScreenToClient(&pt); - if (m_cxLeftBorder != pt.x) - { - m_cxLeftBorder = pt.x; - Invalidate(); - } - int nScroll = pView->GetScrollPos(SB_HORZ); - if (nScroll != m_nScroll) - { - m_nScroll = nScroll; - Invalidate(); - } - } -} - -CSize CRulerBar::GetBaseUnits() -{ - ASSERT(fnt.GetSafeHandle() != NULL); - CFont* pFont = theApp.m_dcScreen.SelectObject(&fnt); - TEXTMETRIC tm; - VERIFY(theApp.m_dcScreen.GetTextMetrics(&tm) == TRUE); - theApp.m_dcScreen.SelectObject(pFont); -// return CSize(tm.tmAveCharWidth, tm.tmHeight+tm.tmDescent); - return CSize(tm.tmAveCharWidth, tm.tmHeight); -} - -BOOL CRulerBar::Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID) -{ - ASSERT_VALID(pParentWnd); // must have a parent - - dwStyle |= WS_CLIPSIBLINGS; - // force WS_CLIPSIBLINGS (avoids SetWindowPos bugs) - m_dwStyle = (dwStyle & CBRS_ALL); - - if (nID == AFX_IDW_TOOLBAR) - { - m_dwStyle |= CBRS_HIDE_INPLACE; - } - - dwStyle &= ~CBRS_ALL; - - // create the HWND - CRect rect; - rect.SetRectEmpty(); - LPCTSTR lpszClass = AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW), - (HBRUSH)(COLOR_BTNFACE+1), NULL); - - if (!CWnd::Create(lpszClass, NULL, dwStyle, rect, pParentWnd, nID)) - return FALSE; - // NOTE: Parent must resize itself for control bar to be resized - - int i; - int nMax = 100; - for (i=0;iIsKindOf (RUNTIME_CLASS (CFrameWndEx))) - { - ((CFrameWndEx*) pParentWnd)->AddPane (this); - } - else if (pParentWnd->IsKindOf (RUNTIME_CLASS (CMDIFrameWndEx))) - { - ((CMDIFrameWndEx*) pParentWnd)->AddPane (this); - } - else if (pParentWnd->IsKindOf (RUNTIME_CLASS (COleIPFrameWndEx))) - { - ((COleIPFrameWndEx*) pParentWnd)->AddPane (this); - } - else - { - ASSERT (FALSE); - } - - SetWindowText (_T("Ruler")); - return TRUE; -} - -CSize CRulerBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) -{ - ASSERT(bHorz); - CSize m_size = CPane::CalcFixedLayout(bStretch, bHorz); - CRect rectSize; - rectSize.SetRectEmpty(); - CalcInsideRect(rectSize, bHorz); // will be negative size - m_size.cy = RULERBARHEIGHT - rectSize.Height(); - return m_size; -} - -void CRulerBar::Update(const WPD_PARAFORMAT& pf) -{ - ASSERT(pf.cTabCount <= MAX_TAB_STOPS); - - m_leftmargin.SetHorzPosTwips((int)(pf.dxStartIndent + pf.dxOffset)); - m_indent.SetHorzPosTwips((int)pf.dxStartIndent); - m_rightmargin.SetHorzPosTwips(PrintWidth() - (int) pf.dxRightIndent); - - int i = 0; - for (i=0;iSaveDC(); - // offset coordinate system - CPoint pointOffset(0,0); - RulerToClient(pointOffset); - pDC->SetViewportOrg(pointOffset); - - DrawFace(*pDC); - DrawTickMarks(*pDC); - - DrawTabs(*pDC); - m_leftmargin.Draw(*pDC); - m_indent.Draw(*pDC); - m_rightmargin.Draw(*pDC); - - pDC->RestoreDC(-1); - } - // Do not call CControlBar::OnPaint() for painting messages -} - -void CRulerBar::DrawTabs(CDC& dc) -{ - int i; - int nPos = 0; - for (i=0;i nPos) - nPos = (m_pTabItems[i].GetHorzPosTwips()); - m_pTabItems[i].Draw(dc); - } - int nPageWidth = PrintWidth(); - nPos = nPos - nPos%720 + 720; - dc.SelectObject(&penBtnShadow); - for ( ; nPos < nPageWidth; nPos += 720) - { - int nx = XTwipsToRuler(nPos); - dc.MoveTo(nx, HEIGHT - 1); - dc.LineTo(nx, HEIGHT + 1); - } -} - -void CRulerBar::DrawFace(CDC& dc) -{ - int nPageWidth = XTwipsToRuler(PrintWidth()); - int nPageEdge = XTwipsToRuler(PrintWidth() + m_rectMargin.right); - - dc.SaveDC(); - - dc.SelectObject(&penBtnShadow); - dc.MoveTo(0,0); - dc.LineTo(nPageEdge - 1, 0); - dc.LineTo(nPageEdge - 1, HEIGHT - 2); - dc.LineTo(nPageWidth - 1, HEIGHT - 2); - dc.LineTo(nPageWidth - 1, 1); - dc.LineTo(nPageWidth, 1); - dc.LineTo(nPageWidth, HEIGHT -2); - - dc.SelectObject(&penBtnHighLight); - dc.MoveTo(nPageWidth, HEIGHT - 1); - dc.LineTo(nPageEdge, HEIGHT -1); - dc.MoveTo(nPageWidth + 1, HEIGHT - 3); - dc.LineTo(nPageWidth + 1, 1); - dc.LineTo(nPageEdge - 1, 1); - - dc.SelectObject(&penWindow); - dc.MoveTo(0, HEIGHT - 1); - dc.LineTo(nPageWidth, HEIGHT -1); - - dc.SelectObject(&penBtnFace); - dc.MoveTo(1, HEIGHT - 2); - dc.LineTo(nPageWidth - 1, HEIGHT - 2); - - dc.SelectObject(&penWindowFrame); - dc.MoveTo(0, HEIGHT - 2); - dc.LineTo(0, 1); - dc.LineTo(nPageWidth - 1, 1); - - dc.FillRect(CRect(1, 2, nPageWidth - 1, HEIGHT-2), &brushWindow); - dc.FillRect(CRect(nPageWidth + 2, 2, nPageEdge - 1, HEIGHT-2), &brushBtnFace); - - CRect rcClient; - GetClientRect(&rcClient); - ClientToRuler(rcClient); - rcClient.top = HEIGHT; - rcClient.bottom = HEIGHT + 2; - dc.FillRect(rcClient, &brushBtnFace); - - CRect rectFill(rcClient.left, HEIGHT+4, rcClient.right, HEIGHT+9); - dc.FillRect(rectFill, &brushWindow); - - if (m_bDraw3DExt) // draws the 3D extension into the view - { - dc.SelectObject(&penBtnShadow); - dc.MoveTo(rcClient.left, HEIGHT+8); - dc.LineTo(rcClient.left, HEIGHT+2); - dc.LineTo(rcClient.right-1, HEIGHT+2); - - dc.SelectObject(&penWindowFrame); - dc.MoveTo(rcClient.left+1, HEIGHT+8); - dc.LineTo(rcClient.left+1, HEIGHT+3); - dc.LineTo(rcClient.right-2, HEIGHT+3); - - dc.SelectObject(&penBtnHighLight); - dc.MoveTo(rcClient.right-1, HEIGHT+2); - dc.LineTo(rcClient.right-1, HEIGHT+8); - - dc.SelectObject(&penBtnFace); - dc.MoveTo(rcClient.right-2, HEIGHT+3); - dc.LineTo(rcClient.right-2, HEIGHT+8); - } - else - { - dc.SelectObject(&penBtnShadow); - dc.MoveTo(rcClient.left, HEIGHT+2); - dc.LineTo(rcClient.right, HEIGHT+2); - - dc.SelectObject(&penWindowFrame); - dc.MoveTo(rcClient.left, HEIGHT+3); - dc.LineTo(rcClient.right, HEIGHT+3); - } - - dc.RestoreDC(-1); -} - -void CRulerBar::DrawTickMarks(CDC& dc) -{ - dc.SaveDC(); - - dc.SelectObject(&penWindowText); - dc.SelectObject(&fnt); - dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); - dc.SetBkMode(TRANSPARENT); - - DrawDiv(dc, m_unit.m_nSmallDiv, m_unit.m_nLargeDiv, 2); - DrawDiv(dc, m_unit.m_nMediumDiv, m_unit.m_nLargeDiv, 5); - DrawNumbers(dc, m_unit.m_nLargeDiv, m_unit.m_nTPU); - - dc.RestoreDC(-1); -} - -void CRulerBar::DrawNumbers(CDC& dc, int nInc, int nTPU) -{ - int nPageWidth = PrintWidth(); - int nPageEdge = nPageWidth + m_rectMargin.right; - TCHAR buf[10]; - - int nTwips, nPixel, nLen; - - for (nTwips = nInc; nTwips < nPageEdge; nTwips += nInc) - { - if (nTwips == nPageWidth) - continue; - nPixel = XTwipsToRuler(nTwips); - wsprintf(buf, _T("%d"), nTwips/nTPU); - nLen = lstrlen(buf); - CSize sz = dc.GetTextExtent(buf, nLen); - dc.ExtTextOut(nPixel - sz.cx/2, HEIGHT/2 - sz.cy/2, 0, NULL, buf, nLen, NULL); - } -} - -void CRulerBar::DrawDiv(CDC& dc, int nInc, int nLargeDiv, int nLength) -{ - int nPageWidth = PrintWidth(); - int nPageEdge = nPageWidth + m_rectMargin.right; - - int nTwips, nPixel; - - for (nTwips = nInc; nTwips < nPageEdge; nTwips += nInc) - { - if (nTwips == nPageWidth || nTwips%nLargeDiv == 0) - continue; - nPixel = XTwipsToRuler(nTwips); - dc.MoveTo(nPixel, HEIGHT/2 - nLength/2); - dc.LineTo(nPixel, HEIGHT/2 - nLength/2 + nLength); - } -} - -void CRulerBar::OnLButtonDown(UINT nFlags, CPoint point) -{ - CPoint pt = point; - ClientToRuler(pt); - - m_pSelItem = NULL; - if (m_leftmargin.HitTestPix(pt)) - m_pSelItem = &m_leftmargin; - else if (m_indent.HitTestPix(pt)) - m_pSelItem = &m_indent; - else if (m_rightmargin.HitTestPix(pt)) - m_pSelItem = &m_rightmargin; - else - m_pSelItem = GetHitTabPix(pt); - if (m_pSelItem == NULL) - m_pSelItem = GetFreeTab(); - if (m_pSelItem == NULL) - return; - SetCapture(); - - m_pSelItem->SetTrack(TRUE); - SetMarginBounds(); - OnMouseMove(nFlags, point); -} - -void CRulerBar::SetMarginBounds() -{ - m_leftmargin.SetBounds(0, m_rightmargin.GetHorzPosTwips()); - m_indent.SetBounds(0, m_rightmargin.GetHorzPosTwips()); - - int nMin = (m_leftmargin.GetHorzPosTwips() > m_indent.GetHorzPosTwips()) ? - m_leftmargin.GetHorzPosTwips() : m_indent.GetHorzPosTwips(); - int nMax = PrintWidth() + m_rectMargin.right; - m_rightmargin.SetBounds(nMin, nMax); - - // tabs can go from zero to the right page edge - for (int i=0;iSetTrack(FALSE); - ReleaseCapture(); - CWordPadView* pView = (CWordPadView*)GetView(); - ASSERT(pView != NULL); - WPD_PARAFORMAT& pf = pView->GetParaFormatSelection(); - FillInParaFormat(pf); - pView->SetParaFormat(pf); - m_pSelItem = NULL; -} - -void CRulerBar::OnMouseMove(UINT nFlags, CPoint point) -{ - CPane::OnMouseMove(nFlags, point); -// use ::GetCapture to avoid creating temporaries - if (::GetCapture() != m_hWnd) - return; - ASSERT(m_pSelItem != NULL); - CRect rc(0,0, XTwipsToRuler(PrintWidth() + m_rectMargin.right), HEIGHT); - RulerToClient(rc); - BOOL bOnRuler = rc.PtInRect(point); - -// snap to minimum movement - point.x = XClientToTwips(point.x); - point.x += m_unit.m_nMinMove/2; - point.x -= point.x%m_unit.m_nMinMove; - - m_pSelItem->TrackHorzPosTwips(point.x, bOnRuler); - UpdateWindow(); -} - -void CRulerBar::OnSysColorChange() -{ - CPane::OnSysColorChange(); - CreateGDIObjects(); - Invalidate(); -} - -void CRulerBar::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) -{ - CPane::OnWindowPosChanging(lpwndpos); - CRect rect; - GetClientRect(rect); - int minx = min(rect.Width(), lpwndpos->cx); - int maxx = max(rect.Width(), lpwndpos->cx); - rect.SetRect(minx-2, rect.bottom - 6, minx, rect.bottom); - InvalidateRect(rect); - rect.SetRect(maxx-2, rect.bottom - 6, maxx, rect.bottom); - InvalidateRect(rect); -} - -void CRulerBar::OnShowWindow(BOOL bShow, UINT nStatus) -{ - CPane::OnShowWindow(bShow, nStatus); - m_bDeferInProgress = FALSE; -} - -void CRulerBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) -{ - CPane::OnWindowPosChanged(lpwndpos); - m_bDeferInProgress = FALSE; -} - -LRESULT CRulerBar::OnSizeParent(WPARAM /*wParam*/, LPARAM /*lParam*/) -{ -/* BOOL bVis = GetStyle() & WS_VISIBLE; - if ((bVis && (m_nStateFlags & delayHide)) || - (!bVis && (m_nStateFlags & delayShow))) - { - m_bDeferInProgress = TRUE; - } - return CControlBar::OnSizeParent(wParam, lParam);*/ - AdjustDockingLayout (); - return 0; -} - -int CRulerBar::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CPane::OnCreate(lpCreateStruct) == -1) - return -1; - - CreateGDIObjects(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ruler.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ruler.h deleted file mode 100644 index 91e47897f9f09..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/ruler.h +++ /dev/null @@ -1,205 +0,0 @@ -// -// riched.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifndef __RULER_H__ -#define __RULER_H__ - -class CWordPadView; -class CWordPadDoc; -class CRulerBar; - -// ruler items include left margin, right margin, indent, and tabs - -// horz positions in twips -- necessary to avoid rounding errors -// vertical position in pixels -class CRulerItem -{ -public: - CRulerItem(UINT nBitmapID = 0); - ~CRulerItem(); - virtual BOOL HitTestPix(CPoint pt) { return GetHitRectPix().PtInRect(pt); } - virtual void Draw(CDC& dc); - virtual void SetHorzPosTwips(int nXPos); - virtual void TrackHorzPosTwips(int nXPos, BOOL bOnRuler = TRUE); - virtual void SetVertPos(int nYPos) { m_nYPosPix = nYPos; } - virtual void SetAlignment(int nAlign) {m_nAlignment = nAlign;} - virtual void SetRuler(CRulerBar* pRuler) {m_pRuler = pRuler;} - virtual void SetBounds(int nMin, int nMax) { m_nMin = nMin; m_nMax = nMax; } - int GetMin() { return m_nMin;} - int GetMax() { return m_nMax;} - void Invalidate(); - int GetVertPosPix() { return m_nYPosPix;} - int GetHorzPosTwips() { return m_nXPosTwips;} - int GetHorzPosPix(); - CRect GetHitRectPix(); - void DrawFocusLine(); - void SetTrack(BOOL b); - - HBITMAP m_hbm; - HBITMAP m_hbmMask; - CSize m_size; // size of item in pixels - -// Operations - BOOL LoadMaskedBitmap(LPCTSTR lpszResourceName); - -protected: - int m_nYPosPix; - int m_nXPosTwips; - int m_nAlignment; - BOOL m_bTrack; - CRulerBar* m_pRuler; - CRect m_rcTrack; - CDC* m_pDC; // dc used for drawing tracking line - int m_nMin, m_nMax; -}; - -class CComboRulerItem : public CRulerItem -{ -public: - CComboRulerItem(UINT nBitmapID1, UINT nBitmapID2, CRulerItem& item); - virtual BOOL HitTestPix(CPoint pt); - virtual void Draw(CDC& dc); - virtual void SetHorzPosTwips(int nXPos); - virtual void TrackHorzPosTwips(int nXPos, BOOL bOnRuler = TRUE); - virtual void SetVertPos(int nYPos); - virtual void SetAlignment(int nAlign); - virtual void SetRuler(CRulerBar* pRuler); - virtual void SetBounds(int nMin, int nMax); - int GetMin(); - int GetMax(); -protected: - CRulerItem m_secondary; - CRulerItem& m_link; - BOOL m_bHitPrimary; -}; - -class CTabRulerItem : public CRulerItem -{ -public: - CTabRulerItem() { SetAlignment(TA_LEFT); } - virtual void Draw(CDC& dc) {if (GetHorzPosTwips() != 0) CRulerItem::Draw(dc);} - virtual void TrackHorzPosTwips(int nXPos, BOOL bOnRuler = TRUE); - virtual BOOL HitTestPix(CPoint pt) { return (GetHorzPosTwips() != 0) ? CRulerItem::HitTestPix(pt) : FALSE;} -}; - -///////////////////////////////////////////////////////////////////////////// -// CRulerBar - -class CRulerBar : public CPane -{ -// Construction -public: - CRulerBar(BOOL b3DExt = TRUE); - ~CRulerBar(); - -// Operations -public: - virtual BOOL Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID); -protected: - void Update(const WPD_PARAFORMAT& pf); - void Update(CSize sizePaper, const CRect& rectMargins); - -// Attributes -public: - BOOL m_bDeferInProgress; - BOOL m_bDraw3DExt; - CUnit m_unit; - CRulerItem* m_pSelItem; - CFont fnt; - CSize GetBaseUnits(); - CComboRulerItem m_leftmargin; - CRulerItem m_indent; - CRulerItem m_rightmargin; - CRulerItem m_tabItem; - CTabRulerItem m_pTabItems[MAX_TAB_STOPS]; - CSize m_sizePaper; - CRect m_rectMargin; - int PrintWidth() {return m_sizePaper.cx - m_rectMargin.left - - m_rectMargin.right;} - int m_nTabs; - int m_logx; - int m_nLinePos; - int m_nScroll; // in pixels - - CPen penFocusLine; - CPen penBtnHighLight; - CPen penBtnShadow; - CPen penWindowFrame; - CPen penBtnText; - CPen penBtnFace; - CPen penWindowText; - CPen penWindow; - CBrush brushWindow; - CBrush brushBtnFace; - -// Implementation -public: - virtual void DoPaint(CDC* pDC); - virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz); - void ClientToRuler(CPoint& pt) {pt.Offset(-m_cxLeftBorder+m_nScroll, -m_cyTopBorder);} - void ClientToRuler(CRect& rect) {rect.OffsetRect(-m_cxLeftBorder+m_nScroll, -m_cyTopBorder);} - void RulerToClient(CPoint& pt) {pt.Offset(m_cxLeftBorder-m_nScroll, m_cyTopBorder);} - void RulerToClient(CRect& rect) {rect.OffsetRect(m_cxLeftBorder-m_nScroll, m_cyTopBorder);} - - int XTwipsToClient(int nT) {return MulDiv(nT, m_logx, 1440) + m_cxLeftBorder - m_nScroll;} - int XClientToTwips(int nC) {return MulDiv(nC - m_cxLeftBorder + m_nScroll, 1440, m_logx);} - - int XTwipsToRuler(int nT) {return MulDiv(nT, m_logx, 1440);} - int XRulerToTwips(int nR) {return MulDiv(nR, 1440, m_logx);} - - int XRulerToClient(int nR) {return nR + m_cxLeftBorder - m_nScroll;} - int XClientToRuler(int nC) {return nC - m_cxLeftBorder + m_nScroll;} - - void CreateGDIObjects(); - -protected: - virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); - void DrawFace(CDC& dc); - void DrawTickMarks(CDC& dC); - void DrawNumbers(CDC& dc, int nInc, int nTPU); - void DrawDiv(CDC& dc, int nInc, int nLargeDiv, int nLength); - void DrawTabs(CDC& dc); - void FillInParaFormat(WPD_PARAFORMAT& pf); - void SortTabs(); - void SetMarginBounds(); - CRulerItem* GetFreeTab(); - CView* GetView() - { - ASSERT(GetParent() != NULL); - return ((CFrameWnd*)GetParent())->GetActiveView(); - } - CDocument* GetDocument() { return GetView()->GetDocument(); } - - CTabRulerItem* GetHitTabPix(CPoint pt); - - // Generated message map functions - //{{AFX_MSG(CRulerBar) - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnSysColorChange(); - afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); - afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); - afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - //}}AFX_MSG - afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam); - DECLARE_MESSAGE_MAP() - - friend class CRulerItem; -}; - -inline int CRulerItem::GetHorzPosPix() - { return m_pRuler->XTwipsToRuler(m_nXPosTwips); } - -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/splash.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/splash.cpp deleted file mode 100644 index d4067df1d0573..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/splash.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// -// splash.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSplashWnd dialog - -BOOL CSplashWnd::Create(CWnd* pParent) -{ - //{{AFX_DATA_INIT(CSplashWnd) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - - if (!CDialog::Create(CSplashWnd::IDD, pParent)) - { - TRACE0("Warning: creation of CSplashWnd dialog failed\n"); - return FALSE; - } - - return TRUE; -} - -BOOL CSplashWnd::OnInitDialog() -{ - CDialog::OnInitDialog(); - CenterWindow(); - - // initialize the big icon control - m_icon.SubclassDlgItem(IDC_BIGICON, this); - m_icon.SizeToContent(); - - return TRUE; // return TRUE unless you set the focus to a control -} - -///////////////////////////////////////////////////////////////////////////// -// CSplashWnd message handlers - -///////////////////////////////////////////////////////////////////////////// -// CBigIcon - -BEGIN_MESSAGE_MAP(CBigIcon, CButton) - //{{AFX_MSG_MAP(CBigIcon) - ON_WM_DRAWITEM() - ON_WM_ERASEBKGND() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CBigIcon message handlers - -#define CY_SHADOW 4 -#define CX_SHADOW 4 - -void CBigIcon::SizeToContent() -{ - m_bitmap.LoadBitmap(IDB_BITMAP48); - BITMAP bm; - m_bitmap.GetObject(sizeof(bm), &bm); - m_sizeBitmap = CSize(bm.bmWidth, bm.bmHeight); - // get system icon size - - // a big icon should be twice the size of an icon + shadows - SetWindowPos(NULL, 0, 0, bm.bmWidth + CX_SHADOW + 4, bm.bmHeight + CY_SHADOW + 4, - SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); -} - -void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) -{ - CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); - ASSERT(pDC != NULL); - - CRect rect; - GetClientRect(rect); - int cxClient = rect.Width(); - int cyClient = rect.Height(); - - // draw border around icon - CPen pen; - pen.CreateStockObject(BLACK_PEN); - CPen* pPenOld = pDC->SelectObject(&pen); - pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW); - if (pPenOld) - pDC->SelectObject(pPenOld); - - // draw shadows around icon - CBrush br; - br.CreateStockObject(DKGRAY_BRUSH); - rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient); - pDC->FillRect(rect, &br); - rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient); - pDC->FillRect(rect, &br); - - // draw the bitmap contents - CDC dcMem; - if (!dcMem.CreateCompatibleDC(pDC)) - return; - CBitmap* pBitmapOld = dcMem.SelectObject(&m_bitmap); - if (pBitmapOld == NULL) - return; - - pDC->BitBlt(2, 2, m_sizeBitmap.cx, m_sizeBitmap.cy, &dcMem, 0, 0, SRCCOPY); - - dcMem.SelectObject(pBitmapOld); -} - -BOOL CBigIcon::OnEraseBkgnd(CDC*) -{ - return TRUE; // we don't do any erasing... -} - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/splash.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/splash.h deleted file mode 100644 index fbd2f0dba4320..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/splash.h +++ /dev/null @@ -1,61 +0,0 @@ -// -// splash.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CBigIcon window - -class CBigIcon : public CButton -{ -// Attributes -public: - CBitmap m_bitmap; - CSize m_sizeBitmap; - -// Operations -public: - void SizeToContent(); - -// Implementation -protected: - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - - //{{AFX_MSG(CBigIcon) - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// CSplash dialog - -class CSplashWnd : public CDialog -{ -// Construction -public: - BOOL Create(CWnd* pParent); - -// Dialog Data - //{{AFX_DATA(CSplashWnd) - enum { IDD = IDD_SPLASH }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - -// Implementation -protected: - CBigIcon m_icon; // self-draw button - - // Generated message map functions - //{{AFX_MSG(CSplashWnd) - virtual BOOL OnInitDialog(); - //}}AFX_MSG -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/srvritem.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/srvritem.cpp deleted file mode 100644 index 0437b872498f3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/srvritem.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// srvritem.cpp : implementation of the CWordPadSrvrItem class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "wordpdoc.h" -#include "wordpvw.h" -#include "srvritem.h" -#include - -IMPLEMENT_DYNAMIC(CEmbeddedItem, COleServerItem) - -extern CLIPFORMAT cfRTF; - -CEmbeddedItem::CEmbeddedItem(CWordPadDoc* pContainerDoc, int nBeg, int nEnd) - : COleServerItem(pContainerDoc, TRUE) -{ - ASSERT(pContainerDoc != NULL); - ASSERT_VALID(pContainerDoc); - m_nBeg = nBeg; - m_nEnd = nEnd; -} - -CWordPadView* CEmbeddedItem::GetView() const -{ - CDocument* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - POSITION pos = pDoc->GetFirstViewPosition(); - if (pos == NULL) - return NULL; - - CWordPadView* pView = (CWordPadView*)pDoc->GetNextView(pos); - ASSERT_VALID(pView); - ASSERT(pView->IsKindOf(RUNTIME_CLASS(CWordPadView))); - return pView; -} - -void CEmbeddedItem::Serialize(CArchive& ar) -{ - if (m_lpRichDataObj != NULL) - { - ASSERT(ar.IsStoring()); - FORMATETC etc = {NULL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; - etc.cfFormat = (CLIPFORMAT)cfRTF; - STGMEDIUM stg; - if (SUCCEEDED(m_lpRichDataObj->GetData(&etc, &stg))) - { - LPBYTE p = (LPBYTE)GlobalLock(stg.hGlobal); - if (p != NULL) - { - ar.Write(p, (UINT)GlobalSize(stg.hGlobal)); - GlobalUnlock(stg.hGlobal); - } - ASSERT(stg.tymed == TYMED_HGLOBAL); - ReleaseStgMedium(&stg); - } - } - else - GetDocument()->Serialize(ar); -} - -BOOL CEmbeddedItem::OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize) -{ - if (dwDrawAspect != DVASPECT_CONTENT) - return COleServerItem::OnGetExtent(dwDrawAspect, rSize); - - CClientDC dc(NULL); - return OnDrawEx(&dc, rSize, FALSE); -} - -BOOL CEmbeddedItem::OnDraw(CDC* pDC, CSize& rSize) -{ - return OnDrawEx(pDC, rSize, TRUE); -} - -BOOL CEmbeddedItem::OnDrawEx(CDC* pDC, CSize& rSize, BOOL bOutput) -{ - CDisplayIC dc; - CWordPadView* pView = GetView(); - if (pView == NULL) - return FALSE; - ASSERT_VALID(pView); - - int nWrap = pView->m_nWordWrap; - - CRect rect;//rect in twips - rect.left = rect.top = 0; - rect.bottom = 32767; // bottomless - - rect.right = 32767; - if (nWrap == 0) // no word wrap - rect.right = 32767; - else if (nWrap == 1) // wrap to window - { - CRect rectClient; - pView->GetClientRect(&rectClient); - rect.right = rectClient.right - HORZ_TEXTOFFSET; - rect.right = MulDiv(rect.right, 1440, dc.GetDeviceCaps(LOGPIXELSX)); - } - else if (nWrap == 2) // wrap to ruler - rect.right = pView->GetPrintWidth(); - - // first just determine the correct extents of the text - pDC->SetBkMode(TRANSPARENT); - - if (pView->PrintInsideRect(pDC, rect, m_nBeg, m_nEnd, FALSE) == 0) - { - // default to 12pts high and 4" wide if no text - rect.bottom = rect.top+12*20+1; // 12 pts high - rect.right = rect.left+ 4*1440; - } - rect.bottom+=3*(1440/dc.GetDeviceCaps(LOGPIXELSX)); // three pixels - - // then, really output the text - CRect rectOut = rect; // don't pass rect because it will get clobbered - if (bOutput) - pView->PrintInsideRect(pDC, rectOut, m_nBeg, m_nEnd, TRUE); - ASSERT(rectOut.right == rect.right); - - // adjust for border (rect.left is already adjusted) - if (pView->GetStyle() & WS_HSCROLL) - ++rect.bottom; // account for border on scroll bar! - - // return HIMETRIC size - rSize = rect.Size(); - rSize.cx = MulDiv(rSize.cx, 2540, 1440); // convert twips to HIMETRIC - rSize.cy = MulDiv(rSize.cy, 2540, 1440); // convert twips to HIMETRIC - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/srvritem.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/srvritem.h deleted file mode 100644 index 23bcc538daa6c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/srvritem.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// srvritem.h : interface of the CWordPadSrvrItem class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CWordPadDoc; -class CWordPadView; - -class CEmbeddedItem : public COleServerItem -{ - DECLARE_DYNAMIC(CEmbeddedItem) - -// Constructors -public: - CEmbeddedItem(CWordPadDoc* pContainerDoc, int nBeg = 0, int nEnd = -1); - -// Attributes - int m_nBeg; - int m_nEnd; - LPDATAOBJECT m_lpRichDataObj; - CWordPadDoc* GetDocument() const - { return (CWordPadDoc*) COleServerItem::GetDocument(); } - CWordPadView* GetView() const; - -// Implementation -public: - BOOL OnDrawEx(CDC* pDC, CSize& rSize, BOOL bOutput); - virtual BOOL OnDraw(CDC* pDC, CSize& rSize); - virtual BOOL OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize); - -protected: - virtual void Serialize(CArchive& ar); // overridden for document i/o -}; - - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/stdafx.cpp deleted file mode 100644 index 8f88f6b65263e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/stdafx.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// stdafx.cpp : source file that includes just the standard includes -// wordpad.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/stdafx.h deleted file mode 100644 index 1eef1e29de5ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/stdafx.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#ifndef _SECURE_ATL -#define _SECURE_ATL 1 -#endif - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// turns off MFC's hiding of some common and often safely ignored warning messages -#define _AFX_ALL_WARNINGS - -#define CONVERTERS - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC OLE classes -#include // MFC OLE dialog classes -#include -#include - -#pragma warning (disable : 4189) -#include -#pragma warning (default : 4189) - -#define HORZ_TEXTOFFSET 15 -#define VERT_TEXTOFFSET 5 - -class CDisplayIC : public CDC -{ -public: - CDisplayIC() { CreateIC(_T("DISPLAY"), NULL, NULL, NULL); } -}; - -#define WPD_CHARFORMAT CHARFORMAT2 -#define WPD_PARAFORMAT PARAFORMAT2 - -struct CCharFormat : public WPD_CHARFORMAT -{ - CCharFormat() {cbSize = sizeof(WPD_CHARFORMAT);} - BOOL operator==(CCharFormat& cf); -}; - -struct CParaFormat : public WPD_PARAFORMAT -{ - CParaFormat() {cbSize = sizeof(WPD_PARAFORMAT);} - BOOL operator==(WPD_PARAFORMAT& pf); -}; - -#include "doctype.h" -#include "chicdial.h" - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC ribbon and control bar support - -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_IA64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif - - -#pragma warning (disable : 4996) diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/strings.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/strings.cpp deleted file mode 100644 index 46aec6d22a46e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/strings.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// strings.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "strings.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -const TCHAR szWordPadClass[] = _T("WordPadClass"); -const TCHAR szLayout1[] = _T("Layout2"); -const TCHAR szLayout2[] = _T("LayoutAux2"); -const TCHAR szRegKey[] = _T("Microsoft\\MFC\\Samples"); - -const TCHAR szTextSection[] = _T("Text"); -const TCHAR szRTFSection[] = _T("RTF"); -const TCHAR szWordSection[] = _T("Word6"); -const TCHAR szWriteSection[] =_T("Write"); -const TCHAR szIPSection[] = _T("IP"); -const TCHAR szWrap[] = _T("Wrap"); -const TCHAR szPageMargin[] = _T("PageMargin"); - -const TCHAR szSection[] = _T("Options"); -const TCHAR szWordSel[] = _T("WordSel"); -const TCHAR szUnits[] = _T("Units"); -const TCHAR szFrameRect[] = _T("FrameRect"); -const TCHAR szMaximized[] = _T("Maximized"); - -const TCHAR szSumInfo[] = _T("\005SummaryInformation"); - -const char szWordConverter[] = "MSWD6_32.WPC"; -const char szWriteConverter[] = "WRITE32.WPC"; - -const TCHAR szContents[] = _T("Contents"); diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/strings.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/strings.h deleted file mode 100644 index 35b394c59b2fc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/strings.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// strings.h : defines all extern const strings -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -extern const TCHAR szWordPadClass[]; -extern const TCHAR szLayout1[]; -extern const TCHAR szLayout2[]; -extern const TCHAR szRegKey[]; - -extern const TCHAR szTextSection[]; -extern const TCHAR szRTFSection[]; -extern const TCHAR szWordSection[]; -extern const TCHAR szWriteSection[]; -extern const TCHAR szIPSection[]; -extern const TCHAR szWrap[]; -extern const TCHAR szPageMargin[]; - -extern const TCHAR szSection[]; -extern const TCHAR szWordSel[]; -extern const TCHAR szUnits[]; -extern const TCHAR szFrameRect[]; -extern const TCHAR szMaximized[]; -extern const TCHAR szDeleteTemp[]; - -extern const TCHAR szSumInfo[]; - -extern const char szWordConverter[]; -extern const char szWriteConverter[]; - -extern const TCHAR szContents[]; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/targetver.h deleted file mode 100644 index 11730d5da5b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/targetver.h +++ /dev/null @@ -1,26 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/unitspag.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/unitspag.cpp deleted file mode 100644 index 90ce39cf1d72b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/unitspag.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// unitspag.cpp : implementation file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "unitspag.h" -#include "helpids.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CUnitsPage dialog - -const DWORD CUnitsPage::m_nHelpIDs[] = -{ - IDC_BOX, IDH_COMM_GROUPBOX, - IDC_UNITS_IN, IDH_WORDPAD_INCHES, - IDC_UNITS_CM, IDH_WORDPAD_CENTIMETERS, - IDC_UNITS_PT, IDH_WORDPAD_POINTS, - IDC_UNITS_PI, IDH_WORDPAD_PICAS, - IDC_WORDSEL, IDH_WORDPAD_OPTIONS_AUTOWORDSEL, - 0, 0 -}; - -CUnitsPage::CUnitsPage() : CCSPropertyPage(CUnitsPage::IDD) -{ - //{{AFX_DATA_INIT(CUnitsPage) - m_nUnits = -1; - m_bWordSel = FALSE; - //}}AFX_DATA_INIT -} - - -void CUnitsPage::DoDataExchange(CDataExchange* pDX) -{ - CCSPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CUnitsPage) - DDX_Radio(pDX, IDC_UNITS_IN, m_nUnits); - DDX_Check(pDX, IDC_WORDSEL, m_bWordSel); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CUnitsPage, CCSPropertyPage) - //{{AFX_MSG_MAP(CUnitsPage) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CUnitsPage message handlers diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/unitspag.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/unitspag.h deleted file mode 100644 index 0fb08b83eecdc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/unitspag.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// unitspag.h : header file -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CUnitsPage dialog - -class CUnitsPage : public CCSPropertyPage -{ -// Construction -public: - CUnitsPage(); // standard constructor - -// Dialog Data - //{{AFX_DATA(CUnitsPage) - enum { IDD = IDD_OPTIONS_UNITS }; - int m_nUnits; - BOOL m_bWordSel; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CUnitsPage) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - static const DWORD m_nHelpIDs[]; - virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} - - // Generated message map functions - //{{AFX_MSG(CUnitsPage) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.cpp deleted file mode 100644 index 660e4affd06a9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.cpp +++ /dev/null @@ -1,966 +0,0 @@ -// -// wordpad.cpp : Defines the class behaviors for the application. -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" - -#include "wordpad.h" -#include "mainfrm.h" -#include "ipframe.h" -#include "wordpdoc.h" -#include "wordpvw.h" -#include "strings.h" -#include "key.h" -#include "filenewd.h" -#include -#include -#include - -#include "AppLookDlg.h" - -extern BOOL AFXAPI AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn); -static BOOL RegisterHelper(LPCTSTR* rglpszRegister, LPCTSTR* rglpszSymbols, - BOOL bReplace); - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -CLIPFORMAT cfEmbeddedObject; -CLIPFORMAT cfRTF; -CLIPFORMAT cfRTO; - -int CWordPadApp::m_nOpenMsg = RegisterWindowMessage(_T("WordPadOpenMessage")); -int CWordPadApp::m_nPrinterChangedMsg = RegisterWindowMessage(_T("WordPadPrinterChanged")); - -const int CWordPadApp::m_nPrimaryNumUnits = 4; -const int CWordPadApp::m_nNumUnits = 7; - -CUnit CWordPadApp::m_units[7] = -{ -// TPU, SmallDiv, MedDiv, LargeDiv, MinMove, szAbbrev, bSpace -CUnit(1440, 180, 720, 1440, 90, IDS_INCH1_ABBREV, FALSE),//inches -CUnit(568, 142, 284, 568, 142, IDS_CM_ABBREV, TRUE),//centimeters -CUnit(20, 120, 720, 720, 100, IDS_POINT_ABBREV, TRUE),//points -CUnit(240, 240, 1440, 1440, 120, IDS_PICA_ABBREV, TRUE),//picas -CUnit(1440, 180, 720, 1440, 90, IDS_INCH2_ABBREV, FALSE),//in -CUnit(1440, 180, 720, 1440, 90, IDS_INCH3_ABBREV, FALSE),//inch -CUnit(1440, 180, 720, 1440, 90, IDS_INCH4_ABBREV, FALSE)//inches -}; - -static UINT DoRegistry(LPVOID lpv) -{ - ASSERT(lpv != NULL); - ((CWordPadApp*)lpv)->UpdateRegistry(); - return 0; -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadApp - -BEGIN_MESSAGE_MAP(CWordPadApp, CWinAppEx) - //{{AFX_MSG_MAP(CWordPadApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(ID_FILE_NEW, OnFileNew) - ON_COMMAND(ID_FILE_OPEN, OnFileOpen) - ON_COMMAND(ID_VIEW_APP_LOOK, OnViewAppLook) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void CWordPadCommandLineInfo::ParseParam(const char* pszParam,BOOL bFlag,BOOL bLast) -{ - if (bFlag) - { - if (lstrcmpA(pszParam, "t") == 0) - { - m_bForceTextMode = TRUE; - return; - } - } - CCommandLineInfo::ParseParam(pszParam, bFlag, bLast); -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadApp construction - -CWordPadApp::CWordPadApp() : - CWinAppEx (TRUE), - m_optionsText(0), m_optionsRTF(1), - m_optionsWord(2), m_optionsWrite(2), m_optionsIP(2), m_optionsNull(0) -{ - _tsetlocale(LC_ALL, _T("")); - - m_nFilterIndex = 1; - DWORD dwVersion = ::GetVersion(); - m_bWin4 = (BYTE)dwVersion >= 4; -#ifndef _UNICODE - m_bWin31 = (dwVersion > 0x80000000 && !m_bWin4); -#endif - m_nDefFont = (m_bWin4) ? DEFAULT_GUI_FONT : ANSI_VAR_FONT; - m_dcScreen.Attach(::GetDC(NULL)); - m_bForceOEM = FALSE; - m_bHiColorIcons = FALSE; -} - -CWordPadApp::~CWordPadApp() -{ - if (m_dcScreen.m_hDC != NULL) - ::ReleaseDC(NULL, m_dcScreen.Detach()); -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CWordPadApp object - -CWordPadApp theApp; - -// Register the application's document templates. Document templates -// serve as the connection between documents, frame windows and views. -static CSingleDocTemplate DocTemplate( - IDR_MAINFRAME, - RUNTIME_CLASS(CWordPadDoc), - RUNTIME_CLASS(CMainFrame), // main SDI frame window - RUNTIME_CLASS(CWordPadView)); - -// This identifier was generated to be statistically unique for your app. -// You may change it if you prefer to choose a specific identifier. -static const CLSID BASED_CODE clsid = -{ 0x73FDDC80L, 0xAEA9, 0x101A, { 0x98, 0xA7, 0x00, 0xAA, 0x00, 0x37, 0x49, 0x59} }; - -///////////////////////////////////////////////////////////////////////////// -// CWordPadApp initialization - -BOOL CWordPadApp::InitInstance() -{ - ParseCommandLine(cmdInfo); - - if (::FindWindow(szWordPadClass, NULL) && IsDocOpen(cmdInfo.m_strFileName)) - return FALSE; - - SetRegistryKey(szRegKey); - LoadOptions(); - - Enable3dControls(); - CSplashWnd splash; - BOOL bSplash = cmdInfo.m_bShowSplash; - if (!cmdInfo.m_bRunEmbedded) - { - switch (m_nCmdShow) - { - case SW_HIDE: - case SW_SHOWMINIMIZED: - case SW_MINIMIZE: - case SW_SHOWMINNOACTIVE: - bSplash = FALSE; - break; - case SW_RESTORE: - case SW_SHOW: - case SW_SHOWDEFAULT: - case SW_SHOWNA: - case SW_SHOWNOACTIVATE: - case SW_SHOWNORMAL: - case SW_SHOWMAXIMIZED: - if (m_bMaximized) - m_nCmdShow = SW_SHOWMAXIMIZED; - break; - } - } - else - { - //Excel 4 will start OLE servers minimized - m_nCmdShow = SW_SHOWNORMAL; - } - int nCmdShow = m_nCmdShow; - - if (bSplash) - { - // only show splash if not embedded - splash.Create(NULL); - splash.ShowWindow(SW_SHOW); - splash.UpdateWindow(); - } - - LoadAbbrevStrings(); - - m_hDevNames = CreateDevNames(); - NotifyPrinterChanged((m_hDevNames == NULL)); - - free((void*)m_pszHelpFilePath); - m_pszHelpFilePath = _T("WORDPAD.HLP"); - - // Initialize OLE libraries - if (!AfxOleInit()) - { - AfxMessageBox(IDP_OLE_INIT_FAILED); - return FALSE; - } - RegisterFormats(); - - // Initialize RichEdit control - if (LoadLibrary(_T("RICHED32.DLL")) == NULL) - { - AfxMessageBox(IDS_RICHED_LOAD_FAIL, MB_OK|MB_ICONEXCLAMATION); - return FALSE; - } - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - // Initialize all Managers for usage. They are automatically constructed - // if not yet present - SetRegistryBase (_T("SettingsPro")); - - InitContextMenuManager(); - InitKeyboardManager(); - - InitTooltipManager(); - - CMFCToolTipInfo params; - params.m_bVislManagerTheme = TRUE; - - theApp.GetTooltipManager ()->SetTooltipParams ( - 0xFFFF, - RUNTIME_CLASS (CMFCToolTipCtrl), - ¶ms); - - // - // The EnableTearOffMenus method is inherited from the CWinAppEx class. - EnableTearOffMenus (NULL, ID_FREE_TEAROFF1, ID_FREE_TEAROFF2); - // - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - DocTemplate.SetContainerInfo(IDR_CNTR_INPLACE); - DocTemplate.SetServerInfo( - IDR_SRVR_EMBEDDED, IDR_SRVR_INPLACE, - RUNTIME_CLASS(CInPlaceFrame)); - - // Connect the COleTemplateServer to the document template. - // The COleTemplateServer creates new documents on behalf - // of requesting OLE containers by using information - // specified in the document template. - m_server.ConnectTemplate(clsid, &DocTemplate, TRUE); - // Note: SDI applications register server objects only if /Embedding - // or /Automation is present on the command line. - - // Check to see if launched as OLE server - if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) - { - // Register all OLE server (factories) as running. This enables the - // OLE libraries to create objects from other applications. - COleTemplateServer::RegisterAll(); - AfxOleSetUserCtrl(FALSE); - - // Application was run with /Embedding or /Automation. Don't show the - // main window in this case. - return TRUE; - } - - // make sure the main window is showing - m_bPromptForType = FALSE; - OnFileNew(); - m_bPromptForType = TRUE; - // destroy splash window - if (cmdInfo.m_bShowSplash) - splash.DestroyWindow(); - m_nCmdShow = -1; - if (m_pMainWnd == NULL) // i.e. OnFileNew failed - return FALSE; - - if (!cmdInfo.m_strFileName.IsEmpty()) // open an existing document - m_nCmdShow = nCmdShow; - - // Dispatch commands specified on the command line - if (cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew && - !ProcessShellCommand(cmdInfo)) - { - return FALSE; - } - - LoadCustomState (); - - // Enable File Manager drag/drop open - m_pMainWnd->DragAcceptFiles(); - - // When a server application is launched stand-alone, it is a good idea - // to update the system registry in case it has been damaged. - // do registry stuff in separate thread -#ifndef _UNICODE - if (m_bWin31) // no threads on Win32s - UpdateRegistry(); - else -#endif - AfxBeginThread(DoRegistry, this, THREAD_PRIORITY_IDLE); - - // Set application general look: - CAppLookDlg dlg (TRUE); - dlg.DoModal (); - - return TRUE; -} - -BOOL CWordPadApp::IsDocOpen(LPCTSTR lpszFileName) -{ - if (lpszFileName[0] == NULL) - return FALSE; - TCHAR szPath[_MAX_PATH]; - AfxFullPath(szPath, lpszFileName); - ATOM atom = GlobalAddAtom(szPath); - ASSERT(atom != NULL); - if (atom == NULL) - return FALSE; - EnumWindows(StaticEnumProc, (LPARAM)&atom); - if (atom == NULL) - return TRUE; - DeleteAtom(atom); - return FALSE; -} - -BOOL CALLBACK CWordPadApp::StaticEnumProc(HWND hWnd, LPARAM lParam) -{ - TCHAR szClassName[30]; - GetClassName(hWnd, szClassName, 30); - if (lstrcmp(szClassName, szWordPadClass) != 0) - return TRUE; - - ATOM* pAtom = (ATOM*)lParam; - ASSERT(pAtom != NULL); - DWORD_PTR dw = NULL; - ::SendMessageTimeout(hWnd, m_nOpenMsg, NULL, (LPARAM)*pAtom, - SMTO_ABORTIFHUNG, 500, &dw); - if (dw) - { - ::SetForegroundWindow(hWnd); - DeleteAtom(*pAtom); - *pAtom = NULL; - return FALSE; - } - return TRUE; -} - -void CWordPadApp::RegisterFormats() -{ - cfEmbeddedObject = (CLIPFORMAT)::RegisterClipboardFormat(_T("Embedded Object")); - cfRTF = (CLIPFORMAT)::RegisterClipboardFormat(CF_RTF); - cfRTO = (CLIPFORMAT)::RegisterClipboardFormat(CF_RETEXTOBJ); -} - -CDocOptions& CWordPadApp::GetDocOptions(int nDocType) -{ - switch (nDocType) - { - case RD_WINWORD6: - case RD_WORDPAD: - return m_optionsWord; - case RD_RICHTEXT: - return m_optionsRTF; - case RD_TEXT: - case RD_OEMTEXT: - return m_optionsText; - case RD_WRITE: - return m_optionsWrite; - case RD_EMBEDDED: - return m_optionsIP; - } - ASSERT(FALSE); - return m_optionsNull; -} - -CDockState& CWordPadApp::GetDockState(int nDocType, BOOL bPrimary) -{ - return GetDocOptions(nDocType).GetDockState(bPrimary); -} - -void CWordPadApp::SaveOptions() -{ - WriteProfileInt(szSection, szWordSel, m_bWordSel); - WriteProfileInt(szSection, szUnits, GetUnits()); - WriteProfileInt(szSection, szMaximized, m_bMaximized); - WriteProfileBinary(szSection, szFrameRect, (BYTE*)&m_rectInitialFrame, - sizeof(CRect)); - WriteProfileBinary(szSection, szPageMargin, (BYTE*)&m_rectPageMargin, - sizeof(CRect)); - m_optionsText.SaveOptions(szTextSection); - m_optionsRTF.SaveOptions(szRTFSection); - m_optionsWord.SaveOptions(szWordSection); - m_optionsWrite.SaveOptions(szWriteSection); - m_optionsIP.SaveOptions(szIPSection); -} - -void CWordPadApp::LoadOptions() -{ - BYTE* pb = NULL; - UINT nLen = 0; - - HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); - if (hFont == NULL) - hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); - VERIFY(::GetObject(hFont, sizeof(LOGFONT), &m_lf)); - - m_bWordSel = GetProfileInt(szSection, szWordSel, TRUE); - TCHAR buf[2]; - buf[0] = NULL; - GetLocaleInfo(GetUserDefaultLCID(), LOCALE_IMEASURE, buf, 2); - int nDefUnits = buf[0] == '1' ? 0 : 1; - SetUnits(GetProfileInt(szSection, szUnits, nDefUnits)); - m_bMaximized = GetProfileInt(szSection, szMaximized, (int)FALSE); - - if (GetProfileBinary(szSection, szFrameRect, &pb, &nLen)) - { - ASSERT(nLen == sizeof(CRect)); - memcpy(&m_rectInitialFrame, pb, sizeof(CRect)); - delete pb; - } - else - m_rectInitialFrame.SetRect(0,0,0,0); - - CRect rectScreen(0, 0, GetSystemMetrics(SM_CXSCREEN), - GetSystemMetrics(SM_CYSCREEN)); - CRect rectInt; - rectInt.IntersectRect(&rectScreen, &m_rectInitialFrame); - if (rectInt.Width() < 10 || rectInt.Height() < 10) - m_rectInitialFrame.SetRect(0, 0, 0, 0); - - if (GetProfileBinary(szSection, szPageMargin, &pb, &nLen)) - { - ASSERT(nLen == sizeof(CRect)); - memcpy(&m_rectPageMargin, pb, sizeof(CRect)); - delete pb; - } - else - m_rectPageMargin.SetRect(1800, 1440, 1800, 1440); - - m_optionsText.LoadOptions(szTextSection); - m_optionsRTF.LoadOptions(szRTFSection); - m_optionsWord.LoadOptions(szWordSection); - m_optionsWrite.LoadOptions(szWriteSection); - m_optionsIP.LoadOptions(szIPSection); -} - -void CWordPadApp::LoadAbbrevStrings() -{ - for (int i=0;i= div/2) - pVal[i]++; - - while ((pVal[i] == 10) && (i != 0)) - { - pVal[i] = 0; - pVal[--i]++; - } - - while (nDec && pVal[nDec] == 0) - nDec--; - - _stprintf(buf, _T("%.*f"), nDec, (float)nValue/(float)div); - - if (m_units[m_nUnits].m_bSpaceAbbrev) - lstrcat(buf, _T(" ")); - lstrcat(buf, GetAbbrev()); - delete []pVal; -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadApp commands - -void CWordPadApp::OnAppAbout() -{ - CString strTitle; - VERIFY(strTitle.LoadString(AFX_IDS_APP_TITLE)); - - CString strInfo; - strInfo.LoadString (IDS_ABOUT_INFO); - - ShellAbout(m_pMainWnd->GetSafeHwnd(), strTitle, - strInfo, - LoadIcon(IDR_MAINFRAME)); -} - -int CWordPadApp::ExitInstance() -{ - m_pszHelpFilePath = NULL; - - FreeLibrary(GetModuleHandle(_T("RICHED32.DLL"))); - SaveOptions(); - - return CWinAppEx::ExitInstance(); -} - -void CWordPadApp::OnFileNew() -{ - int nDocType = -1; - if (!m_bPromptForType) - { - if (cmdInfo.m_bForceTextMode) - nDocType = RD_TEXT; - else if (!cmdInfo.m_strFileName.IsEmpty()) - { - CFileException fe; - nDocType = GetDocTypeFromName(cmdInfo.m_strFileName, fe); - } - if (nDocType == -1) - nDocType = RD_DEFAULT; - } - else - { - CFileNewDialog dlg; - if (dlg.DoModal() == IDCANCEL) - return; - - nDocType = (dlg.m_nSel == 0) ? RD_DEFAULT: //Word 6 - (dlg.m_nSel == 1) ? RD_RICHTEXT : //RTF - RD_TEXT ; //text - - if (nDocType != RD_TEXT) - cmdInfo.m_bForceTextMode = FALSE; - } - m_nNewDocType = nDocType; - DocTemplate.OpenDocumentFile(NULL); - // if returns NULL, the user has already been alerted -} - -// prompt for file name - used for open and save as -// static function called from app -BOOL CWordPadApp::PromptForFileName(CString& fileName, UINT nIDSTitle, - DWORD dwFlags, BOOL bOpenFileDialog, int* pType) -{ - ScanForConverters(); - CFileDialog dlgFile(bOpenFileDialog); - CString title; - - VERIFY(title.LoadString(nIDSTitle)); - - dlgFile.m_ofn.Flags |= dwFlags; -// dlgFile.m_ofn.Flags &= ~OFN_SHOWHELP; - - int nIndex = m_nFilterIndex; - if (!bOpenFileDialog) - { - int nDocType = (pType != NULL) ? *pType : RD_DEFAULT; - nIndex = GetIndexFromType(nDocType, bOpenFileDialog); - if (nIndex == -1) - nIndex = GetIndexFromType(RD_DEFAULT, bOpenFileDialog); - if (nIndex == -1) - nIndex = GetIndexFromType(RD_NATIVE, bOpenFileDialog); - ASSERT(nIndex != -1); - nIndex++; - } - dlgFile.m_ofn.nFilterIndex = nIndex; - // strDefExt is necessary to hold onto the memory from GetExtFromType - CString strDefExt = GetExtFromType(GetTypeFromIndex(nIndex-1, bOpenFileDialog)); - dlgFile.m_ofn.lpstrDefExt = strDefExt; - - - CString strFilter = GetFileTypes(bOpenFileDialog); - dlgFile.m_ofn.lpstrFilter = strFilter; - dlgFile.m_ofn.lpstrTitle = title; - dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); - - BOOL bRet = (dlgFile.DoModal() == IDOK) ? TRUE : FALSE; - fileName.ReleaseBuffer(); - if (bRet) - { - if (bOpenFileDialog) - m_nFilterIndex = dlgFile.m_ofn.nFilterIndex; - if (pType != NULL) - { - int nIndex = (int)dlgFile.m_ofn.nFilterIndex - 1; - ASSERT(nIndex >= 0); - *pType = GetTypeFromIndex(nIndex, bOpenFileDialog); - } - } - - return bRet; -} - -void CWordPadApp::OnFileOpen() -{ - // prompt the user (with all document templates) - CString newName; - int nType = RD_DEFAULT; - if (!PromptForFileName(newName, AFX_IDS_OPENFILE, - OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, TRUE, &nType)) - return; // open cancelled - - if (nType == RD_OEMTEXT) - m_bForceOEM = TRUE; - OpenDocumentFile(newName); - m_bForceOEM = FALSE; - // if returns NULL, the user has already been alerted -} - -BOOL CWordPadApp::OnDDECommand(LPTSTR /*lpszCommand*/) -{ - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// DDE and ShellExecute support - -//HKEY_CLASSES_ROOT\.RTF = rtffile -//HKEY_CLASSES_ROOT\rtffile = -//HKEY_CLASSES_ROOT\rtffile\CLSID = {73FDDC80-AEA9-101A-98A7-00AA00374959} -//HKEY_CLASSES_ROOT\rtffile\protocol\StdFileEditing\server = WORDPAD.EXE -//HKEY_CLASSES_ROOT\rtffile\protocol\StdFileEditing\verb\0 = &Edit -//HKEY_CLASSES_ROOT\rtffile\shell\open\command = WORDPAD.EXE %1 -//HKEY_CLASSES_ROOT\rtffile\shell\print\command = WORDPAD.EXE /p %1 - -#define REGENTRY(key, value) _T(key) _T("\0\0") _T(value) -#define REGENTRYX(key, valuename, value) _T(key) _T("\0") _T(valuename) _T("\0") _T(value) - -static const TCHAR sz00[] = REGENTRY("%2", "%5"); -static const TCHAR sz01[] = REGENTRY("%2\\CLSID", "%1"); -static const TCHAR sz02[] = REGENTRY("%2\\Insertable", ""); -static const TCHAR sz03[] = REGENTRY("%2\\protocol\\StdFileEditing\\verb\\0", "&Edit"); -static const TCHAR sz04[] = REGENTRY("%2\\protocol\\StdFileEditing\\server", "%3"); -static const TCHAR sz05[] = REGENTRY("CLSID\\%1", "%5"); -static const TCHAR sz06[] = REGENTRY("CLSID\\%1\\ProgID", "%2"); -static const TCHAR sz07[] = REGENTRY("CLSID\\%1\\InprocHandler32", "ole32.dll"); -static const TCHAR sz08[] = REGENTRY("CLSID\\%1\\LocalServer32", "%3"); -static const TCHAR sz09[] = REGENTRY("CLSID\\%1\\Verb\\0", "&Edit,0,2"); -static const TCHAR sz10[] = REGENTRY("CLSID\\%1\\Verb\\1", "&Open,0,2"); -static const TCHAR sz11[] = REGENTRY("CLSID\\%1\\Insertable", ""); -static const TCHAR sz12[] = REGENTRY("CLSID\\%1\\AuxUserType\\2", "%4"); -static const TCHAR sz13[] = REGENTRY("CLSID\\%1\\AuxUserType\\3", "%6"); -static const TCHAR sz14[] = REGENTRY("CLSID\\%1\\DefaultIcon", "%3,1"); -static const TCHAR sz15[] = REGENTRY("CLSID\\%1\\MiscStatus", "0"); -static const TCHAR sz16[] = REGENTRY("%2\\shell\\open\\command", "%3 \"%%1\""); -static const TCHAR sz17[] = REGENTRY("%2\\shell\\print\\command", "%3 /p \"%%1\""); -static const TCHAR sz18[] = REGENTRY("%7", "%2"); -static const TCHAR sz19[] = REGENTRY("%2", ""); // like sz00 only no long type name -static const TCHAR sz20[] = REGENTRY("%2\\shell\\printto\\command", "%3 /pt \"%%1\" \"%%2\" \"%%3\" \"%%4\""); -static const TCHAR sz21[] = REGENTRY("%2\\DefaultIcon", "%3,%8"); -static const TCHAR sz22[] = REGENTRYX("%7\\ShellNew", "NullFile", "true"); -static const TCHAR sz23[] = REGENTRYX("%7\\ShellNew", "Data", "{\\rtf1}"); - -// %1 - class ID -// %2 - class name WordPad.Document.1 -// %3 - SFN executable path C:\PROGRA~1\ACCESS~1\WORDPAD.EXE -// %4 - short type name Document -// %5 - long type name Microsoft WordPad Document -// %6 - long application name Microsoft WordPad -// %7 = extension .rtf -// %8 = default icon 0,1,2,3 -#define NUM_REG_ARGS 8 - -static const LPCTSTR rglpszWordPadRegister[] = -{sz00, sz02, sz03, sz05, sz09, sz10, sz11, sz15, NULL}; - -static const LPCTSTR rglpszWordPadOverwrite[] = -{sz01, sz04, sz06, sz07, sz08, sz12, sz13, sz14, sz16, sz17, sz20, NULL}; - -//static const LPCTSTR rglpszExtRegister[] = -//{sz00, sz18, NULL}; - -//static const LPCTSTR rglpszExtOverwrite[] = -//{sz01, sz16, sz17, sz21, NULL}; - -static const LPCTSTR rglpszWriExtRegister[] = -{sz18, NULL}; -static const LPCTSTR rglpszWriRegister[] = -{sz00, sz01, sz16, sz17, sz20, sz21, NULL}; - -static const LPCTSTR rglpszRtfExtRegister[] = -{sz18, sz23, NULL}; -static const LPCTSTR rglpszRtfRegister[] = -{sz00, sz01, sz16, sz17, sz20, sz21, NULL}; - -static const LPCTSTR rglpszTxtExtRegister[] = -{sz18, sz22, NULL}; -static const LPCTSTR rglpszTxtRegister[] = -{sz00, sz01, sz16, sz17, sz20, sz21, NULL}; - -static const LPCTSTR rglpszDocExtRegister[] = -{sz18, sz22, NULL}; -static const LPCTSTR rglpszDocRegister[] = -{sz00, sz01, sz16, sz17, sz20, sz21, NULL}; - -static void RegisterExt(LPCTSTR lpszExt, LPCTSTR lpszProgID, UINT nIDTypeName, - LPCTSTR* rglpszSymbols, LPCTSTR* rglpszExtRegister, - LPCTSTR* rglpszRegister, int nIcon) -{ - // don't overwrite anything with the extensions - CString strWhole; - VERIFY(strWhole.LoadString(nIDTypeName)); - CString str; - AfxExtractSubString(str, strWhole, DOCTYPE_PROGID); - - rglpszSymbols[1] = lpszProgID; - rglpszSymbols[4] = str; - rglpszSymbols[6] = lpszExt; - TCHAR buf[10]; - wsprintf(buf, _T("%d"), nIcon); - rglpszSymbols[7] = buf; - // check for .ext and progid - CKey key; - if (!key.Open(HKEY_CLASSES_ROOT, lpszExt)) // .ext doesn't exist - RegisterHelper(rglpszExtRegister, rglpszSymbols, TRUE); - key.Close(); - if (!key.Open(HKEY_CLASSES_ROOT, lpszProgID)) // ProgID doesn't exist (i.e. txtfile) - RegisterHelper(rglpszRegister, rglpszSymbols, TRUE); -} - -void CWordPadApp::UpdateRegistry() -{ - USES_CONVERSION; - LPOLESTR lpszClassID = NULL; - CDocTemplate* pDocTemplate = &DocTemplate; - - // get registration info from doc template string - CString strServerName; - CString strLocalServerName; - CString strLocalShortName; - - if (!pDocTemplate->GetDocString(strServerName, - CDocTemplate::regFileTypeId) || strServerName.IsEmpty()) - { - TRACE0("Error: not enough information in DocTemplate to register OLE server.\n"); - return; - } - if (!pDocTemplate->GetDocString(strLocalServerName, - CDocTemplate::regFileTypeName)) - strLocalServerName = strServerName; // use non-localized name - if (!pDocTemplate->GetDocString(strLocalShortName, - CDocTemplate::fileNewName)) - strLocalShortName = strLocalServerName; // use long name - - ASSERT(strServerName.Find(' ') == -1); // no spaces allowed - - ::StringFromCLSID(clsid, &lpszClassID); - ASSERT (lpszClassID != NULL); - - // get path name to server - TCHAR szLongPathName[_MAX_PATH]; - TCHAR szShortPathName[_MAX_PATH]; - ::GetModuleFileName(AfxGetInstanceHandle(), szLongPathName, _MAX_PATH); - ::GetShortPathName(szLongPathName, szShortPathName, _MAX_PATH); - - LPCTSTR rglpszSymbols[NUM_REG_ARGS]; - rglpszSymbols[0] = OLE2CT(lpszClassID); - rglpszSymbols[1] = strServerName; - rglpszSymbols[2] = szShortPathName; - rglpszSymbols[3] = strLocalShortName; - rglpszSymbols[4] = strLocalServerName; - rglpszSymbols[5] = m_pszAppName; // will usually be long, readable name - rglpszSymbols[6] = NULL; - - if (RegisterHelper((LPCTSTR*)rglpszWordPadRegister, rglpszSymbols, FALSE)) - RegisterHelper((LPCTSTR*)rglpszWordPadOverwrite, rglpszSymbols, TRUE); - -// RegisterExt(_T(".txt"), _T("txtfile"), IDS_TEXT_DOC, rglpszSymbols, -// (LPCTSTR*)rglpszTxtExtRegister, (LPCTSTR*)rglpszTxtRegister, 3); - RegisterExt(_T(".rtf"), _T("rtffile"), IDS_RICHTEXT_DOC, rglpszSymbols, - (LPCTSTR*)rglpszRtfExtRegister, (LPCTSTR*)rglpszRtfRegister, 1); - RegisterExt(_T(".wri"), _T("wrifile"), IDS_WRITE_DOC, rglpszSymbols, - (LPCTSTR*)rglpszWriExtRegister, (LPCTSTR*)rglpszWriRegister, 2); - RegisterExt(_T(".doc"), _T("WordPad.Document.1"), IDS_WINWORD6_DOC, rglpszSymbols, - (LPCTSTR*)rglpszDocExtRegister, (LPCTSTR*)rglpszDocRegister, 1); - - // free memory for class ID - ASSERT(lpszClassID != NULL); - CoTaskMemFree(lpszClassID); -} - -BOOL RegisterHelper(LPCTSTR* rglpszRegister, LPCTSTR* rglpszSymbols, - BOOL bReplace) -{ - ASSERT(rglpszRegister != NULL); - ASSERT(rglpszSymbols != NULL); - - CString strKey; - CString strValueName; - CString strValue; - - // keeping a key open makes this go a bit faster - CKey keyTemp; - VERIFY(keyTemp.Create(HKEY_CLASSES_ROOT, _T("CLSID"))); - - BOOL bResult = TRUE; - while (*rglpszRegister != NULL) - { - LPCTSTR lpszKey = *rglpszRegister++; - if (*lpszKey == '\0') - continue; - - LPCTSTR lpszValueName = lpszKey + lstrlen(lpszKey) + 1; - LPCTSTR lpszValue = lpszValueName + lstrlen(lpszValueName) + 1; - - strKey.ReleaseBuffer( - FormatMessage(FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY, lpszKey, NULL, NULL, - strKey.GetBuffer(256), 256, (va_list*) rglpszSymbols)); - strValueName = lpszValueName; - strValue.ReleaseBuffer( - FormatMessage(FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY, lpszValue, NULL, NULL, - strValue.GetBuffer(256), 256, (va_list*) rglpszSymbols)); - - if (strKey.IsEmpty()) - { - TRACE1("Warning: skipping empty key '%s'.\n", lpszKey); - continue; - } - - CKey key; - if (key.Create(HKEY_CLASSES_ROOT, strKey)) - { - if (!bReplace) - { - CString str; - if (key.GetStringValue(str, strValueName) && !str.IsEmpty()) - continue; - } - - if (!key.SetStringValue(strValue, strValueName)) - { - TRACE2("Error: failed setting key '%s' to value '%s'.\n", - (LPCTSTR)strKey, (LPCTSTR)strValue); - bResult = FALSE; - break; - } - } - } - - return bResult; -} - -void CWordPadApp::WinHelp(DWORD dwData, UINT nCmd) -{ - if (nCmd == HELP_INDEX || nCmd == HELP_CONTENTS) - nCmd = HELP_FINDER; - CWinApp::WinHelp(dwData, nCmd); -} - -BOOL CWordPadApp::PreTranslateMessage(MSG* pMsg) -{ - if (pMsg->message == WM_PAINT) - return FALSE; - // CWinApp::PreTranslateMessage does nothing but call base - return CWinThread::PreTranslateMessage(pMsg); -} - -void CWordPadApp::NotifyPrinterChanged(BOOL bUpdatePrinterSelection) -{ - if (bUpdatePrinterSelection) - UpdatePrinterSelection(FALSE); - POSITION pos = m_listPrinterNotify.GetHeadPosition(); - while (pos != NULL) - { - HWND hWnd = m_listPrinterNotify.GetNext(pos); - ::SendMessage(hWnd, m_nPrinterChangedMsg, 0, 0); - } -} - -BOOL CWordPadApp::IsIdleMessage(MSG* pMsg) -{ - if (pMsg->message == WM_MOUSEMOVE || pMsg->message == WM_NCMOUSEMOVE) - return FALSE; - return CWinApp::IsIdleMessage(pMsg); -} - -HGLOBAL CWordPadApp::CreateDevNames() -{ - HGLOBAL hDev = NULL; - if (!cmdInfo.m_strDriverName.IsEmpty() && !cmdInfo.m_strPrinterName.IsEmpty() && - !cmdInfo.m_strPortName.IsEmpty()) - { - hDev = GlobalAlloc(GPTR, 4*sizeof(WORD)+ - cmdInfo.m_strDriverName.GetLength() + 1 + - cmdInfo.m_strPrinterName.GetLength() + 1 + - cmdInfo.m_strPortName.GetLength()+1); - LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(hDev); - lpDev->wDriverOffset = sizeof(WORD)*4; - lstrcpy((TCHAR*)lpDev + lpDev->wDriverOffset, cmdInfo.m_strDriverName); - - lpDev->wDeviceOffset = (WORD)(lpDev->wDriverOffset + cmdInfo.m_strDriverName.GetLength()+1); - lstrcpy((TCHAR*)lpDev + lpDev->wDeviceOffset, cmdInfo.m_strPrinterName); - - lpDev->wOutputOffset = (WORD)(lpDev->wDeviceOffset + cmdInfo.m_strPrinterName.GetLength()+1); - lstrcpy((TCHAR*)lpDev + lpDev->wOutputOffset, cmdInfo.m_strPortName); - - lpDev->wDefault = 0; - } - return hDev; -} - -///////////////////////////////////////////////////////////////////////////// -// Customization load methods - -void CWordPadApp::PreLoadState () -{ - GetContextMenuManager()->AddMenu (_T("Context menu"), IDR_TEXT_POPUP); -} - -void CWordPadApp::OnViewAppLook() -{ - CAppLookDlg dlg (FALSE); - dlg.DoModal (); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.h deleted file mode 100644 index d2ce7e8b173ff..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.h +++ /dev/null @@ -1,140 +0,0 @@ -// -// wordpad.h : main header file for the WORDPAD application -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols -#include "splash.h" -#include "options.h" -#include "afxtempl.h" - -#define WPM_BARSTATE WM_USER - -///////////////////////////////////////////////////////////////////////////// -// CWordPadApp: -// See wordpad.cpp for the implementation of this class -// - -class CWordPadCommandLineInfo : public CCommandLineInfo -{ -public: - CWordPadCommandLineInfo() {m_bForceTextMode = FALSE;} - BOOL m_bForceTextMode; - virtual void ParseParam(const char* pszParam,BOOL bFlag,BOOL bLast); -}; - -class CWordPadApp : public CWinAppEx -{ -public: - CWordPadApp(); - ~CWordPadApp(); - - virtual void PreLoadState (); - -//Attributes - CWordPadCommandLineInfo cmdInfo; - CDC m_dcScreen; - LOGFONT m_lf; - int m_nDefFont; - static int m_nOpenMsg; - static int m_nPrinterChangedMsg; - CRect m_rectPageMargin; - CRect m_rectInitialFrame; - BOOL m_bMaximized; - BOOL m_bPromptForType; - BOOL m_bWin4; - BOOL m_bHiColorIcons; - -#ifndef _UNICODE - BOOL m_bWin31; -#endif - BOOL m_bForceTextMode; - BOOL m_bWordSel; - BOOL m_bForceOEM; - int m_nFilterIndex; - int m_nNewDocType; - CDocOptions m_optionsText; - CDocOptions m_optionsRTF; - CDocOptions m_optionsWord; //wrap to ruler - CDocOptions m_optionsWrite; //wrap to ruler - CDocOptions m_optionsIP; //wrap to ruler - CDocOptions m_optionsNull; - CList m_listPrinterNotify; - - BOOL IsDocOpen(LPCTSTR lpszFileName); - -// Get - int GetUnits() {return m_nUnits;} - int GetTPU() { return GetTPU(m_nUnits);} - int GetTPU(int n) { return m_units[n].m_nTPU;} - LPCTSTR GetAbbrev() { return m_units[m_nUnits].m_strAbbrev;} - LPCTSTR GetAbbrev(int n) { return m_units[n].m_strAbbrev;} - const CUnit& GetUnit() {return m_units[m_nUnits];} - CDockState& GetDockState(int nDocType, BOOL bPrimary = TRUE); - CDocOptions& GetDocOptions(int nDocType); - -// Set - void SetUnits(int n) - { ASSERT(n>=0 && n >", ID_OLE_VERB_FIRST - END - POPUP "&View" - BEGIN - MENUITEM "&Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Format Bar", ID_VIEW_FORMATBAR - MENUITEM "&Ruler", ID_VIEW_RULER - MENUITEM SEPARATOR - MENUITEM "&Options...", ID_VIEW_OPTIONS - END - POPUP "&Insert" - BEGIN - MENUITEM "&Date and Time...", ID_INSERT_DATE_TIME - MENUITEM "&Object...", ID_OLE_INSERT_NEW - END - POPUP "F&ormat" - BEGIN - MENUITEM "&Font...", ID_FORMAT_FONT - MENUITEM "&Bullet Style", ID_INSERT_BULLET - MENUITEM "&Paragraph...", ID_FORMAT_PARAGRAPH - MENUITEM "&Tabs...", ID_FORMAT_TABS - END - MENUITEM SEPARATOR - MENUITEM SEPARATOR - POPUP "&Help" - BEGIN - MENUITEM "&Help Topics", ID_HELP_INDEX - MENUITEM SEPARATOR - MENUITEM "&About WordPad", ID_APP_ABOUT - END -END - -IDR_SRVR_EMBEDDED MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Update\tCtrl+S", ID_FILE_UPDATE - MENUITEM "Save Copy &As...", ID_FILE_SAVE_COPY_AS - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - MENUITEM "Paste &Special...", ID_EDIT_PASTE_SPECIAL - MENUITEM "Cle&ar\tDel", ID_EDIT_CLEAR - MENUITEM "Select A&ll\tCtrl+A", ID_EDIT_SELECT_ALL - MENUITEM SEPARATOR - MENUITEM "&Find...\tCtrl+F", ID_EDIT_FIND - MENUITEM "Find &Next\tF3", ID_EDIT_REPEAT - MENUITEM "R&eplace...\tCtrl+H", ID_EDIT_REPLACE - MENUITEM SEPARATOR - MENUITEM "Lin&ks...", ID_OLE_EDIT_LINKS - MENUITEM "Object P&roperties\tAlt+Enter", ID_OLE_EDIT_PROPERTIES - MENUITEM "<>", ID_OLE_VERB_FIRST - END - POPUP "&View" - BEGIN - MENUITEM "&Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Format Bar", ID_VIEW_FORMATBAR - MENUITEM "&Ruler", ID_VIEW_RULER - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Insert" - BEGIN - MENUITEM "&Date and Time...", ID_INSERT_DATE_TIME - MENUITEM "&Object...", ID_OLE_INSERT_NEW - END - POPUP "F&ormat" - BEGIN - MENUITEM "&Font...", ID_FORMAT_FONT - MENUITEM "&Bullet Style", ID_INSERT_BULLET - MENUITEM "&Paragraph...", ID_FORMAT_PARAGRAPH - MENUITEM "&Tabs...", ID_FORMAT_TABS - END - POPUP "&Help" - BEGIN - MENUITEM "&Help Topics", ID_HELP_INDEX - MENUITEM SEPARATOR - MENUITEM "&About WordPad", ID_APP_ABOUT - END -END - -IDR_TEXT_POPUP MENU -BEGIN - POPUP "TEXT_POPUP" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "&Font...", ID_FORMAT_FONT - MENUITEM "&Bullet Style", ID_INSERT_BULLET - MENUITEM "P&aragraph...", ID_FORMAT_PARAGRAPH - MENUITEM SEPARATOR - MENUITEM "Object P&roperties", ID_OLE_EDIT_PROPERTIES - MENUITEM "&Object...", ID_OLE_VERB_POPUP - END -END - -IDR_BORDER_PALETTE MENU -BEGIN - POPUP "_BORDER_" - BEGIN - MENUITEM "Border", ID_BORDER_1 - MENUITEM "Border", ID_BORDER_2 - MENUITEM "Border", ID_BORDER_3 - MENUITEM "Border", ID_BORDER_4 - MENUITEM "Border", ID_BORDER_5 - MENUITEM "Border", ID_BORDER_6 - MENUITEM "Border", ID_BORDER_7 - MENUITEM "Border", ID_BORDER_8 - MENUITEM "Border", ID_BORDER_9 - MENUITEM "Border", ID_BORDER_10 - MENUITEM "Border", ID_BORDER_11 - MENUITEM "Border", ID_BORDER_12 - MENUITEM "Border", ID_BORDER_13 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS -BEGIN - "A", ID_EDIT_SELECT_ALL, VIRTKEY, CONTROL, NOINVERT - "B", ID_CHAR_BOLD, VIRTKEY, CONTROL, NOINVERT - "B", ID_CHAR_BOLD, VIRTKEY, SHIFT, CONTROL, NOINVERT - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "E", ID_PARA_CENTER, VIRTKEY, CONTROL, NOINVERT - "F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT - "H", ID_EDIT_REPLACE, VIRTKEY, CONTROL, NOINVERT - "I", ID_CHAR_ITALIC, VIRTKEY, CONTROL, NOINVERT - "I", ID_CHAR_ITALIC, VIRTKEY, SHIFT, CONTROL, NOINVERT - "L", ID_PARA_LEFT, VIRTKEY, CONTROL, NOINVERT - "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT - "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT - "R", ID_PARA_RIGHT, VIRTKEY, CONTROL, NOINVERT - "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT - "U", ID_CHAR_UNDERLINE, VIRTKEY, CONTROL, NOINVERT - "U", ID_CHAR_UNDERLINE, VIRTKEY, SHIFT, CONTROL, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_ESCAPE, ID_CANCEL_EDIT_CNTR, VIRTKEY, NOINVERT - VK_F1, ID_HELP, VIRTKEY, NOINVERT - VK_F1, ID_CONTEXT_HELP, VIRTKEY, SHIFT, NOINVERT - VK_F3, ID_EDIT_REPEAT, VIRTKEY, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - VK_RETURN, ID_OLE_EDIT_PROPERTIES, VIRTKEY, ALT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - -IDR_CNTR_INPLACE ACCELERATORS -BEGIN - "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT - "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT - "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT - VK_ESCAPE, ID_CANCEL_EDIT_CNTR, VIRTKEY, NOINVERT - VK_F1, ID_HELP, VIRTKEY, NOINVERT - VK_F1, ID_CONTEXT_HELP, VIRTKEY, SHIFT, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT -END - -IDR_SRVR_INPLACE ACCELERATORS -BEGIN - "A", ID_EDIT_SELECT_ALL, VIRTKEY, CONTROL, NOINVERT - "B", ID_CHAR_BOLD, VIRTKEY, CONTROL, NOINVERT - "B", ID_CHAR_BOLD, VIRTKEY, SHIFT, CONTROL, NOINVERT - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "E", ID_PARA_CENTER, VIRTKEY, CONTROL, NOINVERT - "F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT - "H", ID_EDIT_REPLACE, VIRTKEY, CONTROL, NOINVERT - "I", ID_CHAR_ITALIC, VIRTKEY, CONTROL, NOINVERT - "I", ID_CHAR_ITALIC, VIRTKEY, SHIFT, CONTROL, NOINVERT - "L", ID_PARA_LEFT, VIRTKEY, CONTROL, NOINVERT - "R", ID_PARA_RIGHT, VIRTKEY, CONTROL, NOINVERT - "U", ID_CHAR_UNDERLINE, VIRTKEY, CONTROL, NOINVERT - "U", ID_CHAR_UNDERLINE, VIRTKEY, SHIFT, CONTROL, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_ESCAPE, ID_CANCEL_EDIT_SRVR, VIRTKEY, NOINVERT - VK_F1, ID_HELP, VIRTKEY, NOINVERT - VK_F1, ID_CONTEXT_HELP, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - VK_RETURN, ID_OLE_EDIT_PROPERTIES, VIRTKEY, ALT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - -IDR_SRVR_EMBEDDED ACCELERATORS -BEGIN - "B", ID_CHAR_BOLD, VIRTKEY, CONTROL, NOINVERT - "B", ID_CHAR_BOLD, VIRTKEY, SHIFT, CONTROL, NOINVERT - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "E", ID_PARA_CENTER, VIRTKEY, CONTROL, NOINVERT - "F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT - "H", ID_EDIT_REPLACE, VIRTKEY, CONTROL, NOINVERT - "I", ID_CHAR_ITALIC, VIRTKEY, CONTROL, NOINVERT - "I", ID_CHAR_ITALIC, VIRTKEY, SHIFT, CONTROL, NOINVERT - "L", ID_PARA_LEFT, VIRTKEY, CONTROL, NOINVERT - "P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT - "R", ID_PARA_RIGHT, VIRTKEY, CONTROL, NOINVERT - "S", ID_FILE_UPDATE, VIRTKEY, CONTROL, NOINVERT - "U", ID_CHAR_UNDERLINE, VIRTKEY, CONTROL, NOINVERT - "U", ID_CHAR_UNDERLINE, VIRTKEY, SHIFT, CONTROL, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_ESCAPE, ID_CANCEL_EDIT_CNTR, VIRTKEY, NOINVERT - VK_F1, ID_HELP, VIRTKEY, NOINVERT - VK_F1, ID_CONTEXT_HELP, VIRTKEY, SHIFT, NOINVERT - VK_F3, ID_EDIT_REPEAT, VIRTKEY, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - VK_RETURN, ID_OLE_EDIT_PROPERTIES, VIRTKEY, ALT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_FORMAT_PARA DIALOG 0, 0, 185, 112 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Paragraph" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Indentation",IDC_BOX,7,7,114,75 - LTEXT "&Left:",IDC_STATIC,13,21,29,8 - EDITTEXT IDC_EDIT_LEFT,52,19,60,14,ES_AUTOHSCROLL - LTEXT "&Right:",IDC_STATIC,13,42,29,8,NOT WS_GROUP - EDITTEXT IDC_EDIT_RIGHT,52,40,60,14,ES_AUTOHSCROLL - LTEXT "&First line:",IDC_STATIC,13,63,32,8,NOT WS_GROUP - EDITTEXT IDC_EDIT_FIRST_LINE,52,60,60,14,ES_AUTOHSCROLL - LTEXT "&Alignment:",IDC_TEXT_ALIGNMENT,13,91,37,8 - COMBOBOX IDC_COMBO_ALIGNMENT,52,89,60,45,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "OK",IDOK,128,10,50,14 - PUSHBUTTON "Cancel",IDCANCEL,128,27,50,14 -END - -IDD_FORMAT_TAB DIALOG 0, 0, 186, 119 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Tabs" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "&Tab stop position",IDC_BOX,7,7,114,103 - COMBOBOX IDC_COMBO1,13,18,101,68,CBS_SIMPLE | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Set",IDC_BUTTON_SET,13,87,48,14 - PUSHBUTTON "Cl&ear",IDC_BUTTON_CLEAR,66,87,48,14 - DEFPUSHBUTTON "OK",IDOK,128,10,50,14 - PUSHBUTTON "Cancel",IDCANCEL,128,27,50,14 - PUSHBUTTON "Clear A&ll",IDC_BUTTON_CLEARALL,128,44,50,14 -END - -IDD_PAGE_SETUP_DIALOG DIALOG 0, 0, 185, 112 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Page Setup" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Page Margins",IDC_BOX,7,7,114,98 - LTEXT "&Top:",IDC_STATIC,13,21,31,8 - EDITTEXT IDC_EDIT_TM,52,19,60,14,ES_AUTOHSCROLL - LTEXT "&Bottom:",IDC_STATIC,13,42,30,8 - EDITTEXT IDC_EDIT_BM,52,40,60,14,ES_AUTOHSCROLL - LTEXT "&Left:",IDC_STATIC,13,63,30,8 - EDITTEXT IDC_EDIT_LM,52,61,60,14,ES_AUTOHSCROLL - LTEXT "&Right:",IDC_STATIC,13,84,30,8 - EDITTEXT IDC_EDIT_RM,52,82,60,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,128,10,50,14 - PUSHBUTTON "Cancel",IDCANCEL,128,27,50,14 -END - -IDD_DATEDIALOG DIALOG 0, 0, 185, 112 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Date and Time" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "&Available formats:",IDC_STATIC_HEADING,7,7,111,8,NOT WS_GROUP - LISTBOX IDC_DATEDIALOG_LIST,7,17,113,87,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "OK",IDOK,127,17,50,14 - PUSHBUTTON "Cancel",IDCANCEL,127,34,50,14 -END - -IDD_SPLASH DIALOG 0, 0, 253, 92 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "",IDC_BIGICON,"Button",BS_OWNERDRAW | WS_DISABLED,6,6,38,40 - LTEXT "WordPad Version 1.0",IDC_STATIC,60,6,164,8,NOT WS_GROUP - LTEXT "Microsoft Foundation Classes",IDC_STATIC,60,15,164,8,NOT WS_GROUP - CONTROL "",IDC_STATIC,"Static",SS_BLACKRECT,60,30,188,1 - LTEXT "Warning: This computer program is protected by",IDC_STATIC,60,36,188,8 - LTEXT "copyright law and international treaties. Unauthorized",IDC_STATIC,60,44,188,8 - LTEXT "reproduction or distribution of this program, or any",IDC_STATIC,60,52,188,8 - LTEXT "portion of it, may result in severe civil and criminal",IDC_STATIC,60,60,188,8 - LTEXT "penalties, and will be prosecuted to the maximum",IDC_STATIC,60,68,188,8 - LTEXT "extent possible under law.",IDC_STATIC,60,76,188,8 -END - -IDD_OPTIONS_UNITS DIALOG 0, 0, 280, 86 -STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION -CAPTION "Options" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "&Inches",IDC_UNITS_IN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,21,54,10 - CONTROL "&Centimeters",IDC_UNITS_CM,"Button",BS_AUTORADIOBUTTON,74,21,68,10 - CONTROL "&Points",IDC_UNITS_PT,"Button",BS_AUTORADIOBUTTON,13,39,54,10 - CONTROL "Pic&as",IDC_UNITS_PI,"Button",BS_AUTORADIOBUTTON,74,39,68,10 - GROUPBOX "Measurement units",IDC_BOX,7,7,264,53 - CONTROL "Automatic &word selection",IDC_WORDSEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,66,106,10 -END - -IDD_OPTIONS_WRAP DIALOG 0, 0, 280, 86 -STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Word wrap",IDC_BOX,7,7,128,72 - CONTROL "&No wrap",IDC_WRAP_NONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,21,81,10 - CONTROL "&Wrap to window",IDC_WRAP_WINDOW,"Button",BS_AUTORADIOBUTTON,13,39,81,10 - CONTROL "Wr&ap to ruler",IDC_WRAP_RULER,"Button",BS_AUTORADIOBUTTON,13,57,81,10 - GROUPBOX "Toolbars",IDC_BOXT,144,7,128,72 - CONTROL "&Toolbar",IDC_CHECK_TOOLBAR,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,153,21,68,10 - CONTROL "&Format bar",IDC_CHECK_FORMATBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,153,35,68,10 - CONTROL "&Ruler",IDC_CHECK_RULERBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,153,49,68,10 - CONTROL "&Status bar",IDC_CHECK_STATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,153,63,68,10 -END - -IDD_FILENEWDIALOG DIALOG 0, 0, 185, 112 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "New" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "New document type:",IDC_STATIC_HEADING,7,7,111,8,NOT WS_GROUP - LISTBOX IDC_DATEDIALOG_LIST,7,17,114,87,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "OK",IDOK,127,17,50,14 - PUSHBUTTON "Cancel",IDCANCEL,127,34,50,14 -END - -IDD_APP_LOOK DIALOGEX 0, 0, 292, 160 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Application Look" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "Welcome to the MFC Library! The library supports various application looks such as Microsoft Office XP/2003/2007, Microsoft Visual Studio 2005 and more.",IDC_STATIC,7,7,278,19 - LTEXT "Please choose the preferred look and click OK to continue.",IDC_STATIC,17,31,214,8 - CONTROL "Microsoft Office XP",IDC_APP_LOOK1,"Button",BS_AUTORADIOBUTTON | WS_GROUP,50,53,83,10 - CONTROL "Microsoft Office 2003",IDC_APP_LOOK2,"Button",BS_AUTORADIOBUTTON,50,70,89,10 - CONTROL "Microsoft Office 2007:",IDC_APP_LOOK3,"Button",BS_AUTORADIOBUTTON,50,87,91,10 - COMBOBOX IDC_STYLE2007,158,86,102,131,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Note: you may change the application look in ""View | Application Look..."" dialog.",IDC_STATIC,17,114,268,8 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,131,278,1 - CONTROL "Show this dialog at startup",IDC_SHOW_AT_STARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,139,99,10 - DEFPUSHBUTTON "OK",IDOK,121,139,50,14 - PUSHBUTTON "Cancel",IDCANCEL,179,139,50,14 - PUSHBUTTON "Apply",IDC_APPLY,235,139,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 4,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "Microsoft Corporation" - VALUE "FileDescription", "WordPad MFC Application" - VALUE "FileVersion", "1.0" - VALUE "InternalName", "wordpad" - VALUE "LegalCopyright", "Copyright Microsoft Corp. 1998" - VALUE "OriginalFilename", "WORDPAD.EXE" - VALUE "ProductName", "Microsoft Windows (TM) Operating System" - VALUE "ProductVersion", "4.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_RULER_BLOCK BITMAP "res\\rulerbl.bmp" -IDB_RULER_DOWN BITMAP "res\\rulerdo.bmp" -IDB_RULER_TAB BITMAP "res\\rulerta.bmp" -IDB_RULER_UP BITMAP "res\\rulerup.bmp" -IDR_FORMATBAR BITMAP "res\\formatba.bmp" -IDR_SRVR_INPLACE BITMAP "res\\srvr.bmp" -IDR_MAINFRAME BITMAP "RES\\main1.BMP" -IDB_BITMAP48 BITMAP "res\\WORDP48.bmp" -IDB_FONTTYPE BITMAP "res\\font.bmp" -IDB_RULER_BLOCKM BITMAP "res\\rulerblm.bmp" -IDB_RULER_DOWNM BITMAP "res\\rulerdom.bmp" -IDB_RULER_TABM BITMAP "res\\rulertam.bmp" -IDB_RULER_UPM BITMAP "res\\rulerupm.bmp" -IDR_TOOLBAR_IMAGES BITMAP "res\\toolbar_images.bmp" -IDB_TASKS BITMAP "res\\tasks.bmp" -IDR_TOOLBAR_IMAGES_HC BITMAP "res\\toolbar_images_hc.bmp" -IDB_MAINFRAME_HC BITMAP "res\\mainfram_hc.bmp" -IDB_TASKS_HC BITMAP "res\\tasks_hc.bmp" -IDB_TASKSPANE_TOOLBAR BITMAP "Res\\taskspanetoolbar.bmp" -IDR_BORDER_TYPE BITMAP "res\\border_type.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_TOOLBAR_IMAGES TOOLBAR 16, 16 -BEGIN - BUTTON ID_APP_ABOUT - BUTTON ID_FILE_PRINT - BUTTON ID_HELP_INDEX - BUTTON ID_FORMAT_FONT - BUTTON ID_VIEW_FULL_SCREEN -END - -IDR_FORMATBAR TOOLBAR 16, 16 -BEGIN - BUTTON IDC_FONTNAME - SEPARATOR - BUTTON IDC_FONTSIZE - SEPARATOR - BUTTON ID_CHAR_BOLD - BUTTON ID_CHAR_ITALIC - BUTTON ID_CHAR_UNDERLINE - BUTTON ID_CHAR_COLOR - SEPARATOR - BUTTON ID_PARA_LEFT - BUTTON ID_PARA_CENTER - BUTTON ID_PARA_RIGHT - SEPARATOR - BUTTON ID_INSERT_BULLET - SEPARATOR - BUTTON ID_BORDER_1 -END - -IDR_MAINFRAME TOOLBAR 16, 16 -BEGIN - BUTTON ID_FILE_NEW - BUTTON ID_FILE_OPEN - BUTTON ID_FILE_SAVE - SEPARATOR - BUTTON ID_FILE_PRINT - BUTTON ID_FILE_PRINT_PREVIEW - SEPARATOR - BUTTON ID_EDIT_FIND - SEPARATOR - BUTTON ID_EDIT_CUT - BUTTON ID_EDIT_COPY - BUTTON ID_EDIT_PASTE - SEPARATOR - BUTTON ID_EDIT_UNDO - SEPARATOR - BUTTON ID_INSERT_DATE_TIME -END - -IDR_BORDER_TYPE TOOLBAR 16, 16 -BEGIN - BUTTON ID_BORDER_1 - BUTTON ID_BORDER_2 - BUTTON ID_BORDER_3 - BUTTON ID_BORDER_4 - BUTTON ID_BORDER_5 - BUTTON ID_BORDER_6 - BUTTON ID_BORDER_7 - BUTTON ID_BORDER_8 - BUTTON ID_BORDER_9 - BUTTON ID_BORDER_10 - BUTTON ID_BORDER_11 - BUTTON ID_BORDER_12 - BUTTON ID_BORDER_13 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_APP_LOOK, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 285 - VERTGUIDE, 17 - VERTGUIDE, 50 - TOPMARGIN, 7 - BOTTOMMARGIN, 207 - HORZGUIDE, 193 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_APP_LOOK DLGINIT -BEGIN - IDC_STYLE2007, 0x403, 12, 0 -0x754c, 0x616e, 0x2d20, 0x6220, 0x756c, 0x0065, - IDC_STYLE2007, 0x403, 17, 0 -0x624f, 0x6973, 0x6964, 0x6e61, 0x2d20, 0x6220, 0x616c, 0x6b63, "\000" - IDC_STYLE2007, 0x403, 5, 0 -0x7141, 0x6175, "\000" - IDC_STYLE2007, 0x403, 7, 0 -0x6953, 0x766c, 0x7265, "\000" - 0 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDP_OLE_INIT_FAILED "OLE initialization failed. WordPad can not continue." - IDP_FAILED_TO_CREATE "Failed to create object. Make sure the object is entered in the system registry." - IDS_INVALID_MEASUREMENT "This is not a valid measurement." - IDS_PLEASE_WAIT "%d%% complete Formatting ... please wait" - IDS_COMPLETE "%d%% complete" - IDS_SAVE_UNSUPPORTED "Can not save this file in its current format. Do you wish to save this file in a different format?" - IDS_CLOSE_TEXT "Cl&ose" - IDS_RICHED_LOAD_FAIL "Could not load the RichEdit control DLL. The file RICHED32.DLL may be missing or corrupt." - IDS_DEFAULTFONT "Times New Roman" - IDS_TF_BUTTONS "&Word 6.0 Document\n&Rich Text Document\n&Text Document\nCancel" - IDS_DEFAULTTEXTFONT "Courier New" -END - -STRINGTABLE -BEGIN - IDR_MAINFRAME "WordPad\nDocument\nWordPad Document\nWord for Windows 6.0 (*.doc)\n.DOC\nWordPad.Document.1\nWordPad Document" - IDS_TEXT_DOC "Text Document\nText Documents (*.txt)\n*.txt\nText Document" - IDS_RICHTEXT_DOC "Rich Text Format (RTF)\nRich Text Format (*.rtf)\n*.rtf\nRich Text Document" - IDS_WRITE_DOC "Windows Write\nWindows Write (*.wri)\n*.wri\nWrite Document" - IDS_ALL_DOC "All\nAll Documents (*.*)\n*.*" - IDS_WINWORD6_DOC "Word for Windows 6.0\nWord for Windows 6.0 (*.doc)\n*.doc\nWord Document" - IDS_WINWORD2_DOC "Word for Windows 2.0\nWord for Windows 2.0 (*.doc)\n*.doc" - IDS_EXE_DOC "Executable\nExecutable (*.exe)\n*.exe" - IDS_FILE_EXISTS "%1 already exists.\nDo you want to replace it?" - IDS_OEMTEXT_DOC "Text Document - MS-DOS Format\nText Documents - MS-DOS Format (*.txt)\n*.txt\nMS-DOS Text Document" - IDS_CLIP_TEXT "Unformatted Text\ntext without any formatting" -END - -STRINGTABLE -BEGIN - AFX_IDS_APP_TITLE "WordPad" - AFX_IDS_IDLEMESSAGE "For Help, press F1" - AFX_IDS_HELPMODEMESSAGE "Select an object you want to get Help on." -END - -STRINGTABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END - -STRINGTABLE -BEGIN - ID_FILE_NEW "Creates a new document\nNew" - ID_FILE_OPEN "Opens an existing document\nOpen" - ID_FILE_CLOSE "Closes the active document\nClose" - ID_FILE_SAVE "Saves the active document\nSave" - ID_FILE_SAVE_AS "Saves the active document with a new name\nSave As" - ID_FILE_PAGE_SETUP "Changes the printing options\nPage Setup" - ID_FILE_PRINT_SETUP "Changes the printer and printing options\nPrint Setup" - ID_FILE_PRINT "Prints the active document\nPrint" - ID_FILE_PRINT_DIRECT "Prints the active document\nPrint" - ID_FILE_PRINT_PREVIEW "Displays full pages\nPrint Preview" - ID_FILE_UPDATE "Updates the container to show any changes\nUpdate" - ID_FILE_SAVE_COPY_AS "Saves a copy of the active document with a new name\nSave Copy" - ID_FILE_SEND_MAIL "Sends the document through electronic mail\nSend" -END - -STRINGTABLE -BEGIN - ID_APP_ABOUT "Displays program information, version number, and copyright\nAbout" - ID_APP_EXIT "Quits the application; prompts you to save documents\nExit" - ID_HELP_INDEX "Lists Help topics\nHelp Index" - ID_HELP_USING "Displays instructions about how to use help\nHelp" - ID_CONTEXT_HELP "Displays Help for the button, menu, or window you click\nHelp" - ID_HELP "Displays Help for current task or command\nHelp" -END - -STRINGTABLE -BEGIN - ID_FILE_MRU_FILE1 "Opens this document" - ID_FILE_MRU_FILE2 "Opens this document" - ID_FILE_MRU_FILE3 "Opens this document" - ID_FILE_MRU_FILE4 "Opens this document" -END - -STRINGTABLE -BEGIN - ID_NEXT_PANE "Switches to the next window pane\nNext Pane" - ID_PREV_PANE "Switches back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE -BEGIN - ID_WINDOW_SPLIT "Splits the active window into panes\nSplit" -END - -STRINGTABLE -BEGIN - ID_EDIT_CLEAR "Erases the selection\nErase" - ID_EDIT_CLEAR_ALL "Erases everything\nErase All" - ID_EDIT_COPY "Copies the selection and puts it on the Clipboard\nCopy" - ID_EDIT_CUT "Cuts the selection and puts it on the Clipboard\nCut" - ID_EDIT_FIND "Finds the specified text\nFind" - ID_EDIT_PASTE "Inserts Clipboard contents\nPaste" - ID_EDIT_PASTE_LINK "Inserts Clipboard contents and a link to its source\nPaste Link" - ID_EDIT_PASTE_SPECIAL "Inserts Clipboard contents with options\nPaste Special" - ID_EDIT_REPEAT "Repeats the last find\nFind Next" - ID_EDIT_REPLACE "Replaces specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Selects the entire document\nSelect All" - ID_EDIT_UNDO "Reverses the last action\nUndo" - ID_EDIT_REDO "Carries out the previously undone action\nRedo" -END - -STRINGTABLE -BEGIN - ID_VIEW_TOOLBAR "Shows or hides the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Shows or hides the status bar\nToggle StatusBar" - ID_VIEW_FORMATBAR "Shows or hides the format bar\nToggle Format Bar" - ID_VIEW_RULER "Shows or hides the ruler\nToggle Ruler" - ID_DUMMY "Add your handler here." -END - -STRINGTABLE -BEGIN - ID_OLE_INSERT_NEW "Inserts new embedded object\nInsert Object" - ID_OLE_EDIT_LINKS "Edits linked objects\nEdit Links" - ID_OLE_EDIT_CONVERT "Converts object to different type\nConvert Object" - ID_OLE_EDIT_PROPERTIES "Changes selected object's properties\nProperties" -END - -STRINGTABLE -BEGIN - ID_OLE_VERB_FIRST "Activates embedded or linked object\nObject" - 57873 "Activates embedded or linked object" - 57874 "Activates embedded or linked object" - 57875 "Activates embedded or linked object" - ID_COLOR_AUTOMATIC "Select a color automatically\nAutomatic" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCSIZE "Changes the window size" - AFX_IDS_SCMOVE "Changes the window position" - AFX_IDS_SCMINIMIZE "Reduces the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarges the window to full size" - AFX_IDS_SCNEXTWINDOW "Switches to the next document window" - AFX_IDS_SCPREVWINDOW "Switches to the previous document window" - AFX_IDS_SCCLOSE "Closes the active window and prompts to save the documents" -END - -STRINGTABLE -BEGIN - AFX_IDS_SCRESTORE "Restores the window to normal size" - AFX_IDS_SCTASKLIST "Activates Task List" -END - -STRINGTABLE -BEGIN - AFX_IDS_PREVIEW_CLOSE "Closes print preview mode\nCancel Preview" -END - -STRINGTABLE -BEGIN - ID_PAGE_SETUP "Changes page layout settings\nPage Setup" - ID_COLOR_TEAROFF "" - ID_FREE_TEAROFF1 "" - ID_FREE_TEAROFF2 "" - ID_BORDER_TEAROFF "" - ID_VIEW_OPTIONS "Sets Options\nOptions" - ID_INSERT_BULLET "Inserts a bullet on this line\nBullets" - ID_INSERT_DATE_TIME "Inserts today's date and/or time\nDate/Time" - ID_FORMAT_PARAGRAPH "Formats current or selected paragraph(s)" - ID_FORMAT_TABS "Sets Tabs" -END - -STRINGTABLE -BEGIN - ID_FORMAT_FONT "Selects font for current selection\nFont" -END - -STRINGTABLE -BEGIN - ID_CHAR_BOLD "Makes the selection bold (toggle).\nBold" -END - -STRINGTABLE -BEGIN - ID_CHAR_ITALIC "Makes the selection italic (toggle)\nItalic" - ID_CHAR_COLOR "Formats the selection with a color\nColor" - ID_CHAR_UNDERLINE "Formats the selection with a continuous underline (toggle)\nUnderline" - ID_PARA_LEFT "Left-justifies paragraph\nAlign Left" - ID_PARA_CENTER "Center-justifies paragraph\nCenter" - ID_PARA_RIGHT "Right-justifies paragraph\nAlign Right" - ID_PEN_PERIOD "Inserts a period\nPeriod" - ID_PEN_SPACE "Inserts a space\nSpace" - ID_PEN_BACKSPACE "Deletes the previous character\nBackspace" - ID_PEN_NEWLINE "Inserts a new line\nNew Line" - ID_OLE_VERB_POPUP "Activates embedded or linked object\nObject" - ID_PEN_TOGGLE "Pen\nPen" - ID_PEN_LENS "Edit text\nEdit Text" - ID_PEN_TAB "Inserts a tab\nTab" -END - -STRINGTABLE -BEGIN - IDS_SAVE_FORMAT_TEXT "You are about to save the document in Text-Only format, which will remove all formatting. Save %1 as" - IDS_SAVING "Saving File. Please Wait." - IDS_CLIP_RTF "Formatted Text (RTF)\ntext with formatting" - IDS_FORMATTING "Formatting... Please Wait." - IDS_LEFT "Left" - IDS_CENTER "Center" - IDS_RIGHT "Right" - IDS_MEASUREMENT_RANGE "The measurement must be between %1 and %2." - IDS_INVALID_NUMBER "This is not a valid number." - IDS_INVALID_FONTSIZE "The number must be between 1 and 1638." - IDS_INCHES "Inches" - IDS_CENTIMETERS "Centimeters" - IDS_POINTS "Points" - IDS_PICAS "Picas" - IDS_WORD6_WARNING "This document was created by Word 6.0. WordPad does not support all of the features provided by Word 6.0. Therefore, you may lose information by saving this file as a Word file with the same name." - IDS_WORD6_WARNING_BUTTONS "&Save\nSave &As...\nCancel" -END - -STRINGTABLE -BEGIN - IDS_FINISHED_SEARCH "WordPad has finished searching the document." - IDC_FONTNAME "Changes the font of the selection\nFont" - IDC_FONTSIZE "Changes the font size of the selection\nFont Size" - IDS_TITLE_FORMATBAR "Formatting" - IDS_TITLE_TOOLBAR "Standard" - IDS_INCH1_ABBREV """" - IDS_INCH2_ABBREV "in" - IDS_INCH3_ABBREV "inch" - IDS_INCH4_ABBREV "inches" - IDS_CM_ABBREV "cm" - IDS_POINT_ABBREV "pt" - IDS_PICA_ABBREV "pi" -END - -STRINGTABLE -BEGIN - IDS_NOMORETABS "There are too many tab stops set in this paragraph." - IDS_MAPI_FAIL "An error occurred while sending the document." - IDS_ERRSPACE "There is not enough memory. Quit one or more programs and then try again." - IDS_CANT_LOAD "Can not load %1 files." - IDS_TOOMANYFILES "Unable to open %1. There are too many files already open." - IDS_DIRFULL "Unable to create %1. This folder is full. Use another folder or delete some files from this folder." - IDS_SHAREVIOLATION "The document %1 is in use by another application and cannot be accessed." - IDS_TEXT_OPTIONS "Text" - IDS_RTF_OPTIONS "Rich Text" - IDS_WORD6_OPTIONS "Word 6" - IDS_OPTIONS "Options" - IDS_WRITE_OPTIONS "Write" - IDS_EMBEDDED_OPTIONS "Embedded" - IDS_TEXT_DOCUMENT "Text Document" - IDS_RTF_DOCUMENT "Rich Text Document" - IDS_WORD6_DOCUMENT "Word 6 Document" -END - -STRINGTABLE -BEGIN - IDS_WRITEPROTECT "Unable to write to %1.\nThe disk is write-protected.\nA file cannot be saved on a write-protected disk." - IDS_TITLE_MENUBAR "Menu Bar" - IDS_ABOUT_INFO "Copyright 1992-2008 Microsoft Corporation. All rights reserved." -END - -STRINGTABLE -BEGIN - ID_VIEW_CUSTOMIZE "Customizes the menus and toolbars\nCustomize" - ID_VIEW_USER_TOOLBAR1 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR2 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR3 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR4 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR5 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR6 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR7 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR8 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR9 "Show or hide the user toolbar\nToggle User ToolBar" - ID_VIEW_USER_TOOLBAR10 "Show or hide the user toolbar\nToggle User ToolBar" -END - -STRINGTABLE -BEGIN - ID_VIEW_FULLSCREEN "Show application in the full screen mode\nFull Screen" - ID_VIEW_TASK_PANE "Shows or hides the tasks pane\nToggle Tasks Pane" -END - -STRINGTABLE -BEGIN - ID_VIEW_APP_LOOK "Modifies the application general look\nApplication Look" - ID_BORDER_1 "Outside Border\nOutside Border" - ID_BORDER_2 "All Borders\nAll Borders" - ID_BORDER_3 "Top Border\nTop Border" - ID_BORDER_4 "Left Border\nLeft Border" - ID_BORDER_5 "Inside Horizontal Line\nInside Horizontal Line" - ID_BORDER_6 "Descending Diagonal\nDescending Diagonal" - ID_BORDER_7 "Inside Horizontal Border\nInside Horizontal Border" - ID_BORDER_8 "Inside Border\nInside Border" -END - -STRINGTABLE -BEGIN - ID_BORDER_9 "No Border\nNo Border" - ID_BORDER_10 "Bottom Border\nBottom Border" - ID_BORDER_11 "Right Border\nRight Border" - ID_BORDER_12 "Inside Vertical Border\nInside Vertical Border" - ID_BORDER_13 "Ascending Diagonal\nAscending Diagonal" - ID_VIEW_FULL_SCREEN "Toggles full screen mode\nFull Screen" - ID_HELP_FIND "Ask a question\nAsk a Question" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#include "res\wordpad.rc2" // non-App Studio edited resources - -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#include "afxolecl.rc" // OLE container resources -#include "afxolesv.rc" // OLE server resources -#ifndef _AFXDLL -#include "afxribbon.rc" // ribbon and control bar resources -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.vcxproj deleted file mode 100644 index 5a087738d6e12..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpad.vcxproj +++ /dev/null @@ -1,242 +0,0 @@ - - - - - Debug - Win32 - - - Debug - Win32 - - - Debug - x64 - - - Debug - x64 - - - - {66F9A117-DACA-4D34-8CB8-4FC1D4211C5C} - WordPad - MFCProj - - - - Application - Dynamic - MultiByte - v110 - - - Application - - - Application - Dynamic - MultiByte - v110 - - - - - - - - - - - - - $(Configuration)\ - $(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(ProjectName) - .exe - true - false - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - false - false - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - true - Windows - false - - - MachineX86 - - - - - _DEBUG;%(PreprocessorDefinitions) - false - X64 - - - Disabled - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - $(IntDir);%(AdditionalIncludeDirectories) - - - true - Windows - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpdoc.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpdoc.cpp deleted file mode 100644 index adb6931656785..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpdoc.cpp +++ /dev/null @@ -1,657 +0,0 @@ -// -// wordpdoc.cpp : implementation of the CWordPadDoc class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" - -#include "wordpad.h" -#include "wordpdoc.h" -#include "wordpvw.h" -#include "cntritem.h" -#include "srvritem.h" -#include "formatba.h" - -#include "mainfrm.h" -#include "ipframe.h" -#include "buttondi.h" -#include "helpids.h" -#include "strings.h" -#include "unitspag.h" -#include "docopt.h" -#include "optionsh.h" - -#include "multconv.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -extern BOOL AFXAPI AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn); -extern UINT AFXAPI AfxGetFileTitle(LPCTSTR lpszPathName, LPTSTR lpszTitle, UINT nMax); - -#ifndef OFN_EXPLORER -#define OFN_EXPLORER 0x00080000L -#endif -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc -IMPLEMENT_DYNCREATE(CWordPadDoc, CRichEditDoc) - -BEGIN_MESSAGE_MAP(CWordPadDoc, CRichEditDoc) - //{{AFX_MSG_MAP(CWordPadDoc) - ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions) - ON_UPDATE_COMMAND_UI(ID_OLE_VERB_POPUP, OnUpdateOleVerbPopup) - ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail) - ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateIfEmbedded) - ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateIfEmbedded) - ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateIfEmbedded) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateIfEmbedded) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_DIRECT, OnUpdateIfEmbedded) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_PREVIEW, OnUpdateIfEmbedded) - //}}AFX_MSG_MAP - ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL, OnUpdateFileSendMail) - ON_COMMAND(ID_OLE_EDIT_LINKS, CRichEditDoc::OnEditLinks) - ON_UPDATE_COMMAND_UI(ID_OLE_VERB_FIRST, OnUpdateObjectVerbMenu) - ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_CONVERT, CRichEditDoc::OnUpdateObjectVerbMenu) - ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_LINKS, CRichEditDoc::OnUpdateEditLinksMenu) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc construction/destruction - -CWordPadDoc::CWordPadDoc() -{ - m_nDocType = -1; - m_nNewDocType = -1; -} - -BOOL CWordPadDoc::OnNewDocument() -{ - if (!CRichEditDoc::OnNewDocument()) - return FALSE; - - //correct type already set in theApp.m_nNewDocType; - int nDocType = (IsEmbedded()) ? RD_EMBEDDED : theApp.m_nNewDocType; - - GetView()->SetDefaultFont(IsTextType(nDocType)); - SetDocType(nDocType); - - return TRUE; -} - -void CWordPadDoc::ReportSaveLoadException(LPCTSTR lpszPathName, - CException* e, BOOL bSaving, UINT nIDP) -{ - if (!m_bDeferErrors && e != NULL) - { - ASSERT_VALID(e); - if (e->IsKindOf(RUNTIME_CLASS(CFileException))) - { - switch (((CFileException*)e)->m_cause) - { - case CFileException::fileNotFound: - case CFileException::badPath: - nIDP = AFX_IDP_FAILED_INVALID_PATH; - break; - case CFileException::diskFull: - nIDP = AFX_IDP_FAILED_DISK_FULL; - break; - case CFileException::accessDenied: - nIDP = bSaving ? AFX_IDP_FAILED_ACCESS_WRITE : - AFX_IDP_FAILED_ACCESS_READ; - if (((CFileException*)e)->m_lOsError == ERROR_WRITE_PROTECT) - nIDP = IDS_WRITEPROTECT; - break; - case CFileException::tooManyOpenFiles: - nIDP = IDS_TOOMANYFILES; - break; - case CFileException::directoryFull: - nIDP = IDS_DIRFULL; - break; - case CFileException::sharingViolation: - nIDP = IDS_SHAREVIOLATION; - break; - case CFileException::lockViolation: - case CFileException::badSeek: - case CFileException::genericException: - case CFileException::invalidFile: - case CFileException::hardIO: - nIDP = bSaving ? AFX_IDP_FAILED_IO_ERROR_WRITE : - AFX_IDP_FAILED_IO_ERROR_READ; - break; - default: - break; - } - CString prompt; - AfxFormatString1(prompt, nIDP, lpszPathName); - AfxMessageBox(prompt, MB_ICONEXCLAMATION, nIDP); - return; - } - } - CRichEditDoc::ReportSaveLoadException(lpszPathName, e, bSaving, nIDP); - return; -} - -BOOL CWordPadDoc::OnOpenDocument(LPCTSTR lpszPathName) -{ - if (m_lpRootStg != NULL) // we are embedded - { - // we really want to use the converter on this storage - m_nNewDocType = RD_EMBEDDED; - } - else - { - if (theApp.cmdInfo.m_bForceTextMode) - m_nNewDocType = RD_TEXT; - else - { - CFileException fe; - m_nNewDocType = GetDocTypeFromName(lpszPathName, fe); - if (m_nNewDocType == -1) - { - ReportSaveLoadException(lpszPathName, &fe, FALSE, - AFX_IDP_FAILED_TO_OPEN_DOC); - return FALSE; - } - if (m_nNewDocType == RD_TEXT && theApp.m_bForceOEM) - m_nNewDocType = RD_OEMTEXT; - } - ScanForConverters(); - if (!doctypes[m_nNewDocType].bRead) - { - CString str; - CString strName = doctypes[m_nNewDocType].GetString(DOCTYPE_DOCTYPE); - AfxFormatString1(str, IDS_CANT_LOAD, strName); - AfxMessageBox(str, MB_OK|MB_ICONINFORMATION); - return FALSE; - } - } - -// SetDocType(nNewDocType); - if (!CRichEditDoc::OnOpenDocument(lpszPathName)) - return FALSE; - return TRUE; -} - -void CWordPadDoc::Serialize(CArchive& ar) -{ - COleMessageFilter* pFilter = AfxOleGetMessageFilter(); - ASSERT(pFilter != NULL); - pFilter->EnableBusyDialog(FALSE); - if (ar.IsLoading()) - SetDocType(m_nNewDocType); - CRichEditDoc::Serialize(ar); - pFilter->EnableBusyDialog(TRUE); -} - -BOOL CWordPadDoc::DoSave(LPCTSTR pszPathName, BOOL bReplace /*=TRUE*/) - // Save the document data to a file - // pszPathName = path name where to save document file - // if pszPathName is NULL then the user will be prompted (SaveAs) - // note: pszPathName can be different than 'm_strPathName' - // if 'bReplace' is TRUE will change file name if successful (SaveAs) - // if 'bReplace' is FALSE will not change path name (SaveCopyAs) -{ - CString newName = pszPathName; - int nOrigDocType = m_nDocType; //saved in case of SaveCopyAs or failure - - // newName bWrite type result - // empty TRUE - SaveAs dialog - // empty FALSE - SaveAs dialog - // notempty TRUE - nothing - // notempty FALSE W6 warn (change to wordpad, save as, cancel) - // notempty FALSE other warn (save as, cancel) - - BOOL bModified = IsModified(); - - ScanForConverters(); - - BOOL bSaveAs = FALSE; - if (newName.IsEmpty()) - bSaveAs = TRUE; - else if (!doctypes[m_nDocType].bWrite) - { - if (m_nDocType == RD_WINWORD6) - { - // DWORD nHelpIDs[] = - // { - // 0, 0 - // }; - int nRes = CButtonDialog::DisplayMessageBox( - MAKEINTRESOURCE(IDS_WORD6_WARNING), AfxGetAppName(), - MAKEINTRESOURCE(IDS_WORD6_WARNING_BUTTONS), - MB_ICONQUESTION, 1, 2); - if (nRes == 0) // Save - SetDocType(RD_WORDPAD, TRUE); - else if (nRes == 2) // Cancel - return FALSE; - else - bSaveAs = TRUE; - // else save as - } - else // - { - if (AfxMessageBox(IDS_SAVE_UNSUPPORTED, - MB_YESNO | MB_ICONQUESTION) != IDYES) - { - return FALSE; - } - else - bSaveAs = TRUE; - } - } - - if (m_lpRootStg == NULL && IsTextType(m_nDocType) && - !GetView()->IsFormatText()) - { - // formatting changed in plain old text file - DWORD nHelpIDs[] = - { - 0, IDH_WORDPAD_WORD6FILE, - 0, IDH_WORDPAD_FORMATTED, - 0, IDH_WORDPAD_TEXTFILE, - 0, 0 - }; - CString str; - AfxFormatString1(str, IDS_SAVE_FORMAT_TEXT, GetTitle()); - int nRes = CButtonDialog::DisplayMessageBox(str, - MAKEINTRESOURCE(AFX_IDS_APP_TITLE), - MAKEINTRESOURCE(IDS_TF_BUTTONS), MB_ICONQUESTION, 0, 3, nHelpIDs); - if (nRes == 3) - return FALSE; - int nDocType = (nRes == 0) ? RD_DEFAULT: //Word 6 - (nRes == 1) ? RD_RICHTEXT : //RTF - RD_TEXT; //text - if (IsTextType(m_nDocType) && nDocType != RD_TEXT) - SetDocType(nDocType, TRUE); - if (nDocType != RD_TEXT) - bSaveAs = TRUE; - } - - GetView()->GetParentFrame()->RecalcLayout(); - if (bSaveAs) - { - newName = m_strPathName; - if (bReplace && newName.IsEmpty()) - { - newName = m_strTitle; - int iBad = newName.FindOneOf(_T(" #%;/\\")); // dubious filename - if (iBad != -1) - newName.ReleaseBuffer(iBad); - - // append the default suffix if there is one - newName += GetExtFromType(m_nDocType); - } - - int nDocType = m_nDocType; - if (!theApp.PromptForFileName(newName, - bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY, - OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, &nDocType)) - { - SetDocType(nOrigDocType, TRUE); - return FALSE; // don't even try to save - } - SetDocType(nDocType, TRUE); - } - - BeginWaitCursor(); - if (!OnSaveDocument(newName)) - { - if (pszPathName == NULL) - { - // be sure to delete the file - TRY - { - CFile::Remove(newName); - } - CATCH_ALL(e) - { - TRACE0("Warning: failed to delete file after failed SaveAs\n"); - } - END_CATCH_ALL - } - // restore orginal document type - SetDocType(nOrigDocType, TRUE); - EndWaitCursor(); - return FALSE; - } - - EndWaitCursor(); - if (bReplace) - { - int nType = m_nDocType; - SetDocType(nOrigDocType, TRUE); - SetDocType(nType); - // Reset the title and change the document name - SetPathName(newName, TRUE); - ASSERT(m_strPathName == newName); // must be set - } - else // SaveCopyAs - { - SetDocType(nOrigDocType, TRUE); - SetModifiedFlag(bModified); - } - return TRUE; // success -} - -class COIPF : public COleIPFrameWnd -{ -public: - CFrameWnd* GetMainFrame() { return m_pMainFrame;} - CFrameWnd* GetDocFrame() { return m_pDocFrame;} -}; - -void CWordPadDoc::OnDeactivateUI(BOOL bUndoable) -{ - if (GetView()->m_bDelayUpdateItems) - UpdateAllItems(NULL); - SaveState(m_nDocType); - CRichEditDoc::OnDeactivateUI(bUndoable); - COIPF* pFrame = (COIPF*)m_pInPlaceFrame; - if (pFrame != NULL) - { - if (pFrame->GetMainFrame() != NULL) - ForceDelayed(pFrame->GetMainFrame()); - if (pFrame->GetDocFrame() != NULL) - ForceDelayed(pFrame->GetDocFrame()); - } -} - -void CWordPadDoc::ForceDelayed(CFrameWnd* /*pFrameWnd*/) -{ -/* ASSERT_VALID(this); - ASSERT_VALID(pFrameWnd); - - POSITION pos = pFrameWnd->m_listControlBars.GetHeadPosition(); - while (pos != NULL) - { - // show/hide the next control bar - CControlBar* pBar = - (CControlBar*)pFrameWnd->m_listControlBars.GetNext(pos); - - BOOL bVis = pBar->GetStyle() & WS_VISIBLE; - UINT swpFlags = 0; - if ((pBar->m_nStateFlags & CControlBar::delayHide) && bVis) - swpFlags = SWP_HIDEWINDOW; - else if ((pBar->m_nStateFlags & CControlBar::delayShow) && !bVis) - swpFlags = SWP_SHOWWINDOW; - pBar->m_nStateFlags &= ~(CControlBar::delayShow|CControlBar::delayHide); - if (swpFlags != 0) - { - pBar->SetWindowPos(NULL, 0, 0, 0, 0, swpFlags| - SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); - } - }*/ -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc Attributes -CLSID CWordPadDoc::GetClassID() -{ - return (m_pFactory == NULL) ? CLSID_NULL : m_pFactory->GetClassID(); -} - -void CWordPadDoc::SetDocType(int nNewDocType, BOOL bNoOptionChange) -{ - ASSERT(nNewDocType != -1); - if (nNewDocType == m_nDocType) - return; - - m_bRTF = !IsTextType(nNewDocType); - if (bNoOptionChange) - m_nDocType = nNewDocType; - else - { - SaveState(m_nDocType); - m_nDocType = nNewDocType; - RestoreState(m_nDocType); - } -} - -CWordPadView* CWordPadDoc::GetView() -{ - POSITION pos = GetFirstViewPosition(); - return (CWordPadView* )GetNextView( pos ); -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc Operations - -CFile* CWordPadDoc::GetFile(LPCTSTR pszPathName, UINT nOpenFlags, CFileException* pException) -{ - CTrackFile* pFile = NULL; - CFrameWnd* pWnd = GetView()->GetParentFrame(); -#ifdef CONVERTERS - ScanForConverters(); - - // if writing use current doc type otherwise use new doc type - int nType = (nOpenFlags & CFile::modeReadWrite) ? m_nDocType : m_nNewDocType; - // m_nNewDocType will be same as m_nDocType except when opening a new file - if (doctypes[nType].pszConverterName != NULL) - pFile = new CConverter(doctypes[nType].pszConverterName, pWnd); - else -#endif - if (nType == RD_OEMTEXT) - pFile = new COEMFile(pWnd); - else - pFile = new CTrackFile(pWnd); - if (!pFile->Open(pszPathName, nOpenFlags, pException)) - { - delete pFile; - return NULL; - } - if (nOpenFlags & (CFile::modeWrite | CFile::modeReadWrite)) - pFile->m_dwLength = 0; // can't estimate this - else - pFile->m_dwLength = pFile->GetLength(); - return pFile; -} - -CRichEditCntrItem* CWordPadDoc::CreateClientItem(REOBJECT* preo) const -{ - // cast away constness of this - return new CWordPadCntrItem(preo, (CWordPadDoc*)this); -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc server implementation - -COleServerItem* CWordPadDoc::OnGetEmbeddedItem() -{ - // OnGetEmbeddedItem is called by the framework to get the COleServerItem - // that is associated with the document. It is only called when necessary. - - CEmbeddedItem* pItem = new CEmbeddedItem(this); - ASSERT_VALID(pItem); - return pItem; -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc serialization - -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc diagnostics - -#ifdef _DEBUG -void CWordPadDoc::AssertValid() const -{ - CRichEditDoc::AssertValid(); -} - -void CWordPadDoc::Dump(CDumpContext& dc) const -{ - CRichEditDoc::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CWordPadDoc commands - -int CWordPadDoc::MapType(int nType) -{ - if (nType == RD_OEMTEXT) - nType = RD_TEXT; - else if (!IsInPlaceActive() && nType == RD_EMBEDDED) - nType = RD_RICHTEXT; - return nType; -} - -void CWordPadDoc::OnViewOptions() -{ - int nType = MapType(m_nDocType); - int nFirstPage = 3; - if (nType == RD_TEXT) - nFirstPage = 1; - else if (nType == RD_RICHTEXT) - nFirstPage = 2; - else if (nType == RD_WRITE) - nFirstPage = 4; - else if (nType == RD_EMBEDDED) - nFirstPage = 5; - - SaveState(nType); - - COptionSheet sheet(IDS_OPTIONS, NULL, nFirstPage); - - if (sheet.DoModal() == IDOK) - { - CWordPadView* pView = GetView(); - if (theApp.m_bWordSel) - pView->GetRichEditCtrl().SetOptions(ECOOP_OR, ECO_AUTOWORDSELECTION); - else - { - pView->GetRichEditCtrl().SetOptions(ECOOP_AND, - ~(DWORD)ECO_AUTOWORDSELECTION); - } - RestoreState(nType); - } -} - -void CWordPadDoc::OnUpdateOleVerbPopup(CCmdUI* pCmdUI) -{ - pCmdUI->m_pParentMenu = pCmdUI->m_pMenu; - CRichEditDoc::OnUpdateObjectVerbMenu(pCmdUI); -} - -BOOL CWordPadDoc::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) -{ - if (nCode == CN_COMMAND && nID == ID_OLE_VERB_POPUP) - nID = ID_OLE_VERB_FIRST; - return CRichEditDoc::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); -} - -void CWordPadDoc::SaveState(int nType) -{ - if (nType == -1) - return; - nType = MapType(nType); - CWordPadView* pView = GetView(); - if (pView != NULL) - { - CFrameWnd* pFrame = pView->GetParentFrame(); - ASSERT(pFrame != NULL); - // save current state - pFrame->SendMessage(WPM_BARSTATE, 0, nType); - theApp.GetDocOptions(nType).m_nWordWrap = pView->m_nWordWrap; - } -} - -void CWordPadDoc::RestoreState(int nType) -{ - if (nType == -1) - return; - nType = MapType(nType); - CWordPadView* pView = GetView(); - if (pView != NULL) - { - CFrameWnd* pFrame = pView->GetParentFrame(); - ASSERT(pFrame != NULL); - // set new state - pFrame->SendMessage(WPM_BARSTATE, 1, nType); - int nWrapNew = theApp.GetDocOptions(nType).m_nWordWrap; - if (pView->m_nWordWrap != nWrapNew) - { - pView->m_nWordWrap = nWrapNew; - pView->WrapChanged(); - } - } -} - -void CWordPadDoc::OnCloseDocument() -{ - SaveState(m_nDocType); - CRichEditDoc::OnCloseDocument(); -} - -void CWordPadDoc::PreCloseFrame(CFrameWnd* pFrameArg) -{ - CRichEditDoc::PreCloseFrame(pFrameArg); - SaveState(m_nDocType); -} - -void CWordPadDoc::OnFileSendMail() -{ - if (m_strTitle.Find('.') == -1) - { - // add the extension because the default extension will be wrong - CString strOldTitle = m_strTitle; - m_strTitle += GetExtFromType(m_nDocType); - CRichEditDoc::OnFileSendMail(); - m_strTitle = strOldTitle; - } - else - CRichEditDoc::OnFileSendMail(); -} - -void CWordPadDoc::OnUpdateIfEmbedded(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!IsEmbedded()); -} - -void CWordPadDoc::OnUpdateObjectVerbMenu(CCmdUI* pCmdUI) -{ -// if (pCmdUI->m_pMenu == NULL/* || pCmdUI->m_pParentMenu == NULL !!!Commented by Stas */) - if (pCmdUI->m_pMenu == NULL || pCmdUI->m_pParentMenu == NULL) - { - // not a menu or is on sub-menu (don't recurse) - pCmdUI->ContinueRouting(); - return; - } - - // check for single selection - COleClientItem* pItem = GetPrimarySelectedItem(GetRoutingView_()); - GetPrimarySelectedItem (GetRoutingView_()); - - if (pItem == NULL || pItem->GetType() == OT_STATIC) - { - // no selection, or is 'static' item - pCmdUI->Enable(FALSE); - } - - // only include Convert... if there is a handler for ID_OLE_EDIT_CONVERT - UINT nConvertID = ID_OLE_EDIT_CONVERT; - AFX_CMDHANDLERINFO info; - if (!OnCmdMsg(ID_OLE_EDIT_CONVERT, CN_COMMAND, NULL, &info)) - nConvertID = 0; - - // update the menu - AfxOleSetEditMenu(GetPrimarySelectedItem(GetRoutingView_()), - pCmdUI->m_pMenu, pCmdUI->m_nIndex, - ID_OLE_VERB_FIRST, ID_OLE_VERB_LAST, nConvertID); -} - -void CWordPadDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU) -{ - CRichEditDoc::SetPathName(lpszPathName, bAddToMRU); - - ((CMainFrame*) AfxGetMainWnd ())->UpdateMRUFilesList (); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpdoc.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpdoc.h deleted file mode 100644 index eeb310a11b6f9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpdoc.h +++ /dev/null @@ -1,81 +0,0 @@ -// -// wordpdoc.h : interface of the CWordPadDoc class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CFormatBar; -class CWordPadSrvrItem; -class CWordPadView; - -class CWordPadDoc : public CRichEditDoc -{ -protected: // create from serialization only - CWordPadDoc(); - DECLARE_DYNCREATE(CWordPadDoc) - -// Attributes -public: - int m_nDocType; - int m_nNewDocType; - void SetDocType(int nDocType, BOOL bNoOptionChange = FALSE); - CWordPadView* GetView(); - CLSID GetClassID(); - LPCTSTR GetSection(); - -// Operations -public: - void SaveState(int nType); - void RestoreState(int nType); - virtual CFile* GetFile(LPCTSTR pszPathName, UINT nOpenFlags, - CFileException* pException); - virtual BOOL DoSave(LPCTSTR pszPathName, BOOL bReplace = TRUE); - int MapType(int nType); - void ForceDelayed(CFrameWnd* pFrameWnd); - -// Overrides - virtual CRichEditCntrItem* CreateClientItem(REOBJECT* preo) const; - virtual void OnDeactivateUI(BOOL bUndoable); - virtual void Serialize(CArchive& ar); - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CWordPadDoc) - public: - virtual BOOL OnNewDocument(); - virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); - virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); - virtual void OnCloseDocument(); - virtual void ReportSaveLoadException(LPCTSTR lpszPathName, CException* e, BOOL bSaving, UINT nIDPDefault); - virtual void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU = TRUE); - protected: - virtual COleServerItem* OnGetEmbeddedItem(); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual void PreCloseFrame(CFrameWnd* pFrameArg); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -// Generated message map functions -protected: - //{{AFX_MSG(CWordPadDoc) - afx_msg void OnViewOptions(); - afx_msg void OnUpdateOleVerbPopup(CCmdUI* pCmdUI); - afx_msg void OnFileSendMail(); - afx_msg void OnUpdateIfEmbedded(CCmdUI* pCmdUI); - //}}AFX_MSG - afx_msg void OnUpdateObjectVerbMenu(CCmdUI* pCmdUI); - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpvw.cpp b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpvw.cpp deleted file mode 100644 index c6aaffb488853..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpvw.cpp +++ /dev/null @@ -1,1043 +0,0 @@ -// -// wordpvw.cpp : implementation of the CWordPadView class -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "wordpad.h" -#include "cntritem.h" -#include "srvritem.h" - -#include "wordpdoc.h" -#include "wordpvw.h" -#include "formatta.h" -#include "datedial.h" -#include "formatpa.h" -#include "ruler.h" -#include "strings.h" -#include "pageset.h" - -extern CLIPFORMAT cfEmbeddedObject; -extern CLIPFORMAT cfRTO; - -#ifdef _DEBUG -#undef THIS_FILE -static char BASED_CODE THIS_FILE[] = __FILE__; -#endif - -BOOL CCharFormat::operator==(CCharFormat& cf) -{ - return - dwMask == cf.dwMask - && dwEffects == cf.dwEffects - && yHeight == cf.yHeight - && yOffset == cf.yOffset - && crTextColor == cf.crTextColor - && bPitchAndFamily == cf.bPitchAndFamily - && (lstrcmp(szFaceName, cf.szFaceName) == 0); -} - -BOOL CParaFormat::operator==(WPD_PARAFORMAT& pf) -{ - if( - dwMask != pf.dwMask - || wNumbering != pf.wNumbering -#if _MSC_VER < 1500 - || wReserved != pf.wReserved -#endif - || dxStartIndent != pf.dxStartIndent - || dxRightIndent != pf.dxRightIndent - || dxOffset != pf.dxOffset - || cTabCount != pf.cTabCount - ) - { - return FALSE; - } - for (int i=0;iSetMessageText(IDS_FORMATTING); - CWnd* pBarWnd = pFrameWnd->GetMessageBar(); - if (pBarWnd != NULL) - pBarWnd->UpdateWindow(); - - CRichEditView::WrapChanged(); - - pFrameWnd->SetMessageText(AFX_IDS_IDLEMESSAGE); - if (pBarWnd != NULL) - pBarWnd->UpdateWindow(); -} - -void CWordPadView::SetUpdateTimer() -{ - if (m_uTimerID != 0) // if outstanding timer kill it - KillTimer(m_uTimerID); - m_uTimerID = SetTimer(1, 1000, NULL); //set a timer for 1000 milliseconds - if (m_uTimerID == 0) // no timer available so force update now - GetDocument()->UpdateAllItems(NULL); - else - m_bDelayUpdateItems = TRUE; -} - -void CWordPadView::DeleteContents() -{ - ASSERT_VALID(this); - ASSERT(m_hWnd != NULL); - CRichEditView::DeleteContents(); - SetDefaultFont(IsTextType(GetDocument()->m_nNewDocType)); -} - -void CWordPadView::SetDefaultFont(BOOL bText) -{ - ASSERT_VALID(this); - ASSERT(m_hWnd != NULL); - m_bSyncCharFormat = m_bSyncParaFormat = TRUE; - WPD_CHARFORMAT* pCharFormat = bText ? &m_defTextCharFormat : &m_defCharFormat; - // set the default character format -- the FALSE makes it the default - GetRichEditCtrl().SetSel(0,-1); - GetRichEditCtrl().SetDefaultCharFormat(*pCharFormat); - GetRichEditCtrl().SetSelectionCharFormat(*pCharFormat); - - GetRichEditCtrl().SetParaFormat(m_defParaFormat); - - GetRichEditCtrl().SetSel(0,0); - GetRichEditCtrl().EmptyUndoBuffer(); - GetRichEditCtrl().SetModify(FALSE); - ASSERT_VALID(this); -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadView drawing - -///////////////////////////////////////////////////////////////////////////// -// CWordPadView printing - -void CWordPadView::OnPrint(CDC* pDC, CPrintInfo* pInfo) -{ - CRichEditView::OnPrint(pDC, pInfo); - if (pInfo != NULL && pInfo->m_bPreview) - DrawMargins(pDC); -} - -void CWordPadView::DrawMargins(CDC* pDC) -{ - if (pDC->m_hAttribDC != NULL) - { - CRect rect; - rect.left = m_rectMargin.left; - rect.right = m_sizePaper.cx - m_rectMargin.right; - rect.top = m_rectMargin.top; - rect.bottom = m_sizePaper.cy - m_rectMargin.bottom; - //rect in twips - int logx = ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSX); - int logy = ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY); - rect.left = MulDiv(rect.left, logx, 1440); - rect.right = MulDiv(rect.right, logx, 1440); - rect.top = MulDiv(rect.top, logy, 1440); - rect.bottom = MulDiv(rect.bottom, logy, 1440); - CPen pen(PS_DOT, 0, pDC->GetTextColor()); - CPen* ppen = pDC->SelectObject(&pen); - pDC->MoveTo(0, rect.top); - pDC->LineTo(10000, rect.top); - pDC->MoveTo(rect.left, 0); - pDC->LineTo(rect.left, 10000); - pDC->MoveTo(0, rect.bottom); - pDC->LineTo(10000, rect.bottom); - pDC->MoveTo(rect.right, 0); - pDC->LineTo(rect.right, 10000); - pDC->SelectObject(ppen); - } -} - -BOOL CWordPadView::OnPreparePrinting(CPrintInfo* pInfo) -{ - return DoPreparePrinting(pInfo); -} - -///////////////////////////////////////////////////////////////////////////// -// OLE Client support and commands - -inline int roundleast(int n) -{ - int mod = n%10; - n -= mod; - if (mod >= 5) - n += 10; - else if (mod <= -5) - n -= 10; - return n; -} - -static void RoundRect(LPRECT r1) -{ - r1->left = roundleast(r1->left); - r1->right = roundleast(r1->right); - r1->top = roundleast(r1->top); - r1->bottom = roundleast(r1->bottom); -} - -static void MulDivRect(LPRECT r1, LPRECT r2, int num, int div) -{ - r1->left = MulDiv(r2->left, num, div); - r1->top = MulDiv(r2->top, num, div); - r1->right = MulDiv(r2->right, num, div); - r1->bottom = MulDiv(r2->bottom, num, div); -} - -void CWordPadView::OnPageSetup() -{ - CPageSetupDialog dlg; - PAGESETUPDLG& psd = dlg.m_psd; - BOOL bMetric = theApp.GetUnits() == 1; //centimeters - psd.Flags |= PSD_MARGINS | (bMetric ? PSD_INHUNDREDTHSOFMILLIMETERS : - PSD_INTHOUSANDTHSOFINCHES); - int nUnitsPerInch = bMetric ? 2540 : 1000; - MulDivRect(&psd.rtMargin, m_rectMargin, nUnitsPerInch, 1440); - RoundRect(&psd.rtMargin); - // get the current device from the app - PRINTDLG pd; - pd.hDevNames = NULL; - pd.hDevMode = NULL; - theApp.GetPrinterDeviceDefaults(&pd); - psd.hDevNames = pd.hDevNames; - psd.hDevMode = pd.hDevMode; - if (dlg.DoModal() == IDOK) - { - RoundRect(&psd.rtMargin); - MulDivRect(m_rectMargin, &psd.rtMargin, 1440, nUnitsPerInch); - theApp.m_rectPageMargin = m_rectMargin; - theApp.SelectPrinter(psd.hDevNames, psd.hDevMode); - theApp.NotifyPrinterChanged(); - } - // PageSetupDlg failed - if (CommDlgExtendedError() != 0) - { - CPageSetupDlg dlg; - dlg.m_nBottomMargin = m_rectMargin.bottom; - dlg.m_nLeftMargin = m_rectMargin.left; - dlg.m_nRightMargin = m_rectMargin.right; - dlg.m_nTopMargin = m_rectMargin.top; - if (dlg.DoModal() == IDOK) - { - m_rectMargin.SetRect(dlg.m_nLeftMargin, dlg.m_nTopMargin, - dlg.m_nRightMargin, dlg.m_nBottomMargin); - // m_page will be changed at this point - theApp.m_rectPageMargin = m_rectMargin; - theApp.NotifyPrinterChanged(); - } - } -} - -///////////////////////////////////////////////////////////////////////////// -// OLE Server support - -// The following command handler provides the standard keyboard -// user interface to cancel an in-place editing session. Here, -// the server (not the container) causes the deactivation. -void CWordPadView::OnCancelEditSrvr() -{ - GetDocument()->OnDeactivateUI(FALSE); -} - -///////////////////////////////////////////////////////////////////////////// -// CWordPadView diagnostics - -#ifdef _DEBUG -void CWordPadView::AssertValid() const -{ - CRichEditView::AssertValid(); -} - -void CWordPadView::Dump(CDumpContext& dc) const -{ - CRichEditView::Dump(dc); -} - -CWordPadDoc* CWordPadView::GetDocument() // non-debug version is inline -{ - return (CWordPadDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CWordPadView message helpers - -///////////////////////////////////////////////////////////////////////////// -// CWordPadView message handlers - -int CWordPadView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CRichEditView::OnCreate(lpCreateStruct) == -1) - return -1; - theApp.m_listPrinterNotify.AddTail(m_hWnd); - - if (theApp.m_bWordSel) - GetRichEditCtrl().SetOptions(ECOOP_OR, ECO_AUTOWORDSELECTION); - else - GetRichEditCtrl().SetOptions(ECOOP_AND, ~(DWORD)ECO_AUTOWORDSELECTION); -// GetRichEditCtrl().SetOptions(ECOOP_OR, ECO_SELECTIONBAR); - - GetDefaultFont(m_defTextCharFormat, IDS_DEFAULTTEXTFONT); - GetDefaultFont(m_defCharFormat, IDS_DEFAULTFONT); - - GetRichEditCtrl().GetParaFormat(m_defParaFormat); - m_defParaFormat.cTabCount = 0; - - SetTextColor ((COLORREF) -1); // Automatic - return 0; -} - -void CWordPadView::GetDefaultFont(CCharFormat& cf, UINT nFontNameID) -{ - USES_CONVERSION; - CString strDefFont; - VERIFY(strDefFont.LoadString(nFontNameID)); - ASSERT(cf.cbSize == sizeof(WPD_CHARFORMAT)); - cf.dwMask = CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_SIZE| - CFM_COLOR|CFM_OFFSET|CFM_PROTECTED; - cf.dwEffects = CFE_AUTOCOLOR; - cf.yHeight = 200; //10pt - cf.yOffset = 0; - cf.crTextColor = RGB(0, 0, 0); - cf.bCharSet = 0; - cf.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - ASSERT(strDefFont.GetLength() < LF_FACESIZE); - lstrcpyn(cf.szFaceName, strDefFont, LF_FACESIZE); - cf.dwMask |= CFM_FACE; -} - -void CWordPadView::OnInsertDateTime() -{ - CDateDialog dlg; - if (dlg.DoModal() == IDOK) - GetRichEditCtrl().ReplaceSel(dlg.m_strSel);; -} - -void CWordPadView::OnFormatParagraph() -{ - CFormatParaDlg dlg(GetParaFormatSelection()); - dlg.m_nWordWrap = m_nWordWrap; - if (dlg.DoModal() == IDOK) - SetParaFormat(dlg.m_pf); -} - -void CWordPadView::OnFormatTabs() -{ - CFormatTabDlg dlg(GetParaFormatSelection()); - if (dlg.DoModal() == IDOK) - SetParaFormat(dlg.m_pf); -} - -void CWordPadView::OnTextNotFound(LPCTSTR lpStr) -{ - ASSERT_VALID(this); - MessageBeep(0); - AfxMessageBox(IDS_FINISHED_SEARCH,MB_OK|MB_ICONINFORMATION); - CRichEditView::OnTextNotFound(lpStr); -} - -void CWordPadView::OnTimer(UINT_PTR nIDEvent) -{ - if (m_uTimerID != nIDEvent) // not our timer - CRichEditView::OnTimer(nIDEvent); - else - { - KillTimer(m_uTimerID); // kill one-shot timer - m_uTimerID = 0; - if (m_bDelayUpdateItems) - GetDocument()->UpdateAllItems(NULL); - m_bDelayUpdateItems = FALSE; - - // Update document colors: - CFrameWndEx* pFrameEx = (CFrameWndEx*) GetTopLevelFrame (); - CMFCColorBar* pColorBar = DYNAMIC_DOWNCAST (CMFCColorBar, - pFrameEx->GetPane (ID_COLOR_TEAROFF)); - - if (pColorBar != NULL) - { - CList lstDocColors; - GetDocumentColors (lstDocColors); - - pColorBar->SetDocumentColors (_T("Document's Colors"), lstDocColors); - } - } -} - -void CWordPadView::OnEditChange() -{ - SetUpdateTimer(); -} - -void CWordPadView::OnDestroy() -{ - POSITION pos = theApp.m_listPrinterNotify.Find(m_hWnd); - ASSERT(pos != NULL); - theApp.m_listPrinterNotify.RemoveAt(pos); - - CRichEditView::OnDestroy(); - - if (m_uTimerID != 0) // if outstanding timer kill it - OnTimer(m_uTimerID); - ASSERT(m_uTimerID == 0); -} - -void CWordPadView::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType) -{ - CRichEditView::CalcWindowRect(lpClientRect, nAdjustType); - - if (theApp.m_bWin4 && nAdjustType != 0 && (GetStyle() & WS_VSCROLL)) - lpClientRect->right--; - - // if the ruler is visible then slide the view up under the ruler to avoid - // showing the top border of the view - if (GetExStyle() & WS_EX_CLIENTEDGE) - { - CFrameWndEx* pFrame = DYNAMIC_DOWNCAST (CFrameWndEx, GetParentFrame()); - if (pFrame != NULL) - { - CRulerBar* pBar = (CRulerBar*)pFrame->GetPane(ID_VIEW_RULER); - if (pBar != NULL) - { - BOOL bVis = pBar->IsVisible(); - if (pBar->m_bDeferInProgress) - bVis = !bVis; - if (bVis) - lpClientRect->top -= 2; - } - } - } -} - -void CWordPadView::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMIS) -{ - lpMIS->itemID = (UINT)(WORD)lpMIS->itemID; - CRichEditView::OnMeasureItem(nIDCtl, lpMIS); -} - -void CWordPadView::OnPenBackspace() -{ - SendMessage(WM_KEYDOWN, VK_BACK, 0); - SendMessage(WM_KEYUP, VK_BACK, 0); -} - -void CWordPadView::OnPenNewline() -{ - SendMessage(WM_CHAR, '\n', 0); -} - -void CWordPadView::OnPenPeriod() -{ - SendMessage(WM_CHAR, '.', 0); -} - -void CWordPadView::OnPenSpace() -{ - SendMessage(WM_CHAR, ' ', 0); -} - -void CWordPadView::OnPenTab() -{ - SendMessage(WM_CHAR, VK_TAB, 0); -} - -void CWordPadView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) -{ - if (nChar == VK_F10 && GetKeyState(VK_SHIFT) < 0) - { - long nStart, nEnd; - GetRichEditCtrl().GetSel(nStart, nEnd); - CPoint pt = GetRichEditCtrl().GetCharPos(nEnd); - SendMessage(WM_CONTEXTMENU, (WPARAM)m_hWnd, MAKELPARAM(pt.x, pt.y)); - } - - CRichEditView::OnKeyDown(nChar, nRepCnt, nFlags); -} - -HRESULT CWordPadView::GetClipboardData(CHARRANGE* lpchrg, DWORD /*reco*/, - LPDATAOBJECT lpRichDataObj, LPDATAOBJECT* lplpdataobj) -{ - CHARRANGE& cr = *lpchrg; - - if ((cr.cpMax - cr.cpMin == 1) && - GetRichEditCtrl().GetSelectionType() == SEL_OBJECT) - { - return E_NOTIMPL; - } - - BeginWaitCursor(); - //create the data source - COleDataSource* pDataSource = new COleDataSource; - - // put the formats into the data source - LPENUMFORMATETC lpEnumFormatEtc; - lpRichDataObj->EnumFormatEtc(DATADIR_SET, &lpEnumFormatEtc); - if (lpEnumFormatEtc != NULL) - { - FORMATETC etc; - while (lpEnumFormatEtc->Next(1, &etc, NULL) == S_OK) - { - STGMEDIUM stgMedium; - lpRichDataObj->GetData(&etc, &stgMedium); - pDataSource->CacheData(etc.cfFormat, &stgMedium, &etc); - } - lpEnumFormatEtc->Release(); - } - - CEmbeddedItem item(GetDocument(), cr.cpMin, cr.cpMax); - item.m_lpRichDataObj = lpRichDataObj; - // get wordpad formats - item.GetClipboardData(pDataSource); - - // get the IDataObject from the data source - *lplpdataobj = (LPDATAOBJECT)pDataSource->GetInterface(&IID_IDataObject); - - EndWaitCursor(); - return S_OK; -} - -HRESULT CWordPadView::QueryAcceptData(LPDATAOBJECT lpdataobj, - CLIPFORMAT* lpcfFormat, DWORD reco, BOOL bReally, - HGLOBAL hMetaPict) -{ - if (bReally && *lpcfFormat == 0 && (m_nPasteType == 0)) - { - COleDataObject dataobj; - dataobj.Attach(lpdataobj, FALSE); - if (!dataobj.IsDataAvailable(cfRTO)) // native avail, let richedit do as it wants - { - if (dataobj.IsDataAvailable(cfEmbeddedObject)) - { - if (PasteNative(lpdataobj)) - return S_FALSE; - } - } - } - return CRichEditView::QueryAcceptData(lpdataobj, lpcfFormat, reco, bReally, - hMetaPict); -} - -BOOL CWordPadView::PasteNative(LPDATAOBJECT lpdataobj) -{ - // check data object for wordpad object - // if true, suck out RTF directly - FORMATETC etc = {NULL, NULL, DVASPECT_CONTENT, -1, TYMED_ISTORAGE}; - etc.cfFormat = (CLIPFORMAT)cfEmbeddedObject; - STGMEDIUM stgMedium = {TYMED_ISTORAGE, 0, NULL}; - - // create an IStorage to transfer the data in - LPLOCKBYTES lpLockBytes; - if (FAILED(::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes))) - return FALSE; - ASSERT(lpLockBytes != NULL); - - HRESULT hr = ::StgCreateDocfileOnILockBytes(lpLockBytes, - STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &stgMedium.pstg); - lpLockBytes->Release(); //storage addref'd - if (FAILED(hr)) - return FALSE; - - ASSERT(stgMedium.pstg != NULL); - CLSID clsid; - BOOL bRes = FALSE; //let richedit do what it wants - if (SUCCEEDED(lpdataobj->GetDataHere(&etc, &stgMedium)) && - SUCCEEDED(ReadClassStg(stgMedium.pstg, &clsid)) && - clsid == GetDocument()->GetClassID()) - { - //suck out RTF now - // open Contents stream - COleStreamFile file; - CFileException fe; - if (file.OpenStream(stgMedium.pstg, szContents, - CFile::modeReadWrite|CFile::shareExclusive, &fe)) - { - - // load it with CArchive (loads from Contents stream) - CArchive loadArchive(&file, CArchive::load | - CArchive::bNoFlushOnDelete); - Stream(loadArchive, TRUE); //stream in selection - hr = TRUE; // don't let richedit do anything - } - } - ::ReleaseStgMedium(&stgMedium); - return bRes; -} - -// things to fix -// if format==0 we are doing a straight EM_PASTE -// look for native formats -// richedit specific -- allow richedit to handle (these will be first) -// look for RTF, CF_TEXT. If there paste special as these -// Do standard OLE scenario - -// if pasting a particular format (format != 0) -// if richedit specific, allow through -// if RTF, CF_TEXT. paste special -// if OLE format, do standard OLE scenario - - -void CWordPadView::OnFilePrint() -{ - // don't allow winini changes to occur while printing - m_bInPrint = TRUE; - CRichEditView::OnFilePrint(); - // printer may have changed - theApp.NotifyPrinterChanged(); // this will cause a GetDocument()->PrinterChanged(); - m_bInPrint = FALSE; -} - -int CWordPadView::OnMouseActivate(CWnd* pWnd, UINT nHitTest, UINT message) -{ - if (m_bOnBar) - { - SetFocus(); - return MA_ACTIVATEANDEAT; - } - else - return CRichEditView::OnMouseActivate(pWnd, nHitTest, message); -} - -typedef BOOL (WINAPI *PCWPROC)(HWND, LPSTR, UINT, LPVOID, DWORD, DWORD); -void CWordPadView::OnPenLens() -{ - USES_CONVERSION; - HINSTANCE hLib = LoadLibrary(_T("PENWIN32.DLL")); - if (hLib == NULL) - return; - PCWPROC pCorrectWriting = (PCWPROC)GetProcAddress(hLib, "CorrectWriting"); - ASSERT(pCorrectWriting != NULL); - if (pCorrectWriting != NULL) - { - CHARRANGE cr; - GetRichEditCtrl().GetSel(cr); - int nCnt = 2*(cr.cpMax-cr.cpMin); - BOOL bSel = (nCnt != 0); - nCnt = max(1024, nCnt); - char* pBuf = new char[nCnt]; - pBuf[0] = NULL; - if (bSel) - GetRichEditCtrl().GetSelText(pBuf); - delete [] pBuf; - } - FreeLibrary(hLib); -} - -LONG CWordPadView::OnPrinterChangedMsg(UINT, LONG) -{ - CDC dc; - AfxGetApp()->CreatePrinterDC(dc); - OnPrinterChanged(dc); - return 0; -} - -static void ForwardPaletteChanged(HWND hWndParent, HWND hWndFocus) -{ - // this is a quick and dirty hack to send the WM_QUERYNEWPALETTE to a window that is interested - HWND hWnd = NULL; - for (hWnd = ::GetWindow(hWndParent, GW_CHILD); hWnd != NULL; hWnd = ::GetWindow(hWnd, GW_HWNDNEXT)) - { - if (hWnd != hWndFocus) - { - ::SendMessage(hWnd, WM_PALETTECHANGED, (WPARAM)hWndFocus, 0L); - ForwardPaletteChanged(hWnd, hWndFocus); - } - } -} - -void CWordPadView::OnPaletteChanged(CWnd* pFocusWnd) -{ - ForwardPaletteChanged(m_hWnd, pFocusWnd->GetSafeHwnd()); - // allow the richedit control to realize its palette - // remove this if richedit fixes their code so that - // they don't realize their palette into foreground - if (::GetWindow(m_hWnd, GW_CHILD) == NULL) - CRichEditView::OnPaletteChanged(pFocusWnd); -} - -static BOOL FindQueryPalette(HWND hWndParent) -{ - // this is a quick and dirty hack to send the WM_QUERYNEWPALETTE to a window that is interested - HWND hWnd = NULL; - for (hWnd = ::GetWindow(hWndParent, GW_CHILD); hWnd != NULL; hWnd = ::GetWindow(hWnd, GW_HWNDNEXT)) - { - if (::SendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0L)) - return TRUE; - else if (FindQueryPalette(hWnd)) - return TRUE; - } - return FALSE; -} - -BOOL CWordPadView::OnQueryNewPalette() -{ - if(FindQueryPalette(m_hWnd)) - return TRUE; - return CRichEditView::OnQueryNewPalette(); -} - -void CWordPadView::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) -{ - CRichEditView::OnSettingChange(uFlags, lpszSection); - //printer might have changed - if (!m_bInPrint) - { - if (lstrcmpi(lpszSection, _T("windows")) == 0) - theApp.NotifyPrinterChanged(TRUE); // force update to defaults - } -} - -void CWordPadView::OnSize(UINT nType, int cx, int cy) -{ - CRichEditView::OnSize(nType, cx, cy); - CRect rect(HORZ_TEXTOFFSET, VERT_TEXTOFFSET, cx, cy); - GetRichEditCtrl().SetRect(rect); -} - -void CWordPadView::OnBarSetFocus(UINT, NMHDR*, LRESULT*) -{ - m_bOnBar = TRUE; -} - -void CWordPadView::OnBarKillFocus(UINT, NMHDR*, LRESULT*) -{ - m_bOnBar = FALSE; -} - -void CWordPadView::OnBarReturn(UINT, NMHDR*, LRESULT* ) -{ - SetFocus(); -} - -void CWordPadView::OnContextMenu(CWnd* /*pWnd*/, CPoint point) -{ - if (!ShowContextMenu (point)) - { - Default (); - } -} - -void CWordPadView::OnRButtonUp(UINT nFlags, CPoint point) -{ - long nStartChar, nEndChar; - GetRichEditCtrl().GetSel(nStartChar, nEndChar); - if (nEndChar - nStartChar <= 1) - { - SendMessage (WM_LBUTTONDOWN, nFlags, MAKELPARAM (point.x, point.y)); - ReleaseCapture (); - } - - CPoint ptScreen = point; - ClientToScreen (&ptScreen); - - if (!ShowContextMenu (ptScreen)) - { - Default (); - } -} - -BOOL CWordPadView::ShowContextMenu (CPoint point) -{ - if (DYNAMIC_DOWNCAST (CFrameWndEx, GetParentFrame ()) == NULL) - { - // Maybe, server mode, show the regular menu! - return FALSE; - } - - CRichEditCntrItem* pItem = GetSelectedItem(); - if (pItem == NULL || !pItem->IsInPlaceActive()) - { - theApp.ShowPopupMenu (IDR_TEXT_POPUP, point, this); - return TRUE; - } - - return FALSE; -} - -void CWordPadView::SetTextColor (COLORREF color) -{ - CRichEditView::OnColorPick (color == -1 ? ::GetSysColor (COLOR_WINDOWTEXT) : color); -} - -void CWordPadView::OnCharColor() -{ - COLORREF color = CMFCColorMenuButton::GetColorByCmdID (ID_CHAR_COLOR); - CRichEditView::OnColorPick (color == -1 ? ::GetSysColor (COLOR_WINDOWTEXT) : color); -} - -void CWordPadView::OnFilePrintPreview() -{ - CRichEditCntrItem* pItem = GetSelectedItem(); - if (pItem != NULL && pItem->IsInPlaceActive()) - { - pItem->Deactivate (); - } - - AFXPrintPreview (this); -} - -void CWordPadView::GetDocumentColors (CList& lstColors) -{ - CRichEditCtrl& wndRichEdit = GetRichEditCtrl(); - - // Save current selection: - CHARRANGE cr; - wndRichEdit.GetSel(cr); - - wndRichEdit.HideSelection (TRUE, FALSE); - - int nTextLen = min (500, wndRichEdit.GetTextLength ()); - // For demonstration purposes only! - - for (long iSel = 0; iSel < nTextLen; iSel += 2) - { - wndRichEdit.SetSel (iSel, iSel); - if (!(wndRichEdit.GetSelectionType() & (SEL_OBJECT|SEL_MULTIOBJECT))) - { - CCharFormat cf; - wndRichEdit.GetSelectionCharFormat (cf); - - COLORREF color = cf.crTextColor; - if (lstColors.Find (color) == NULL) - { - lstColors.AddTail (color); - - if (lstColors.GetCount () == 10) - { - break; - } - } - } - } - - // Restore selection: - wndRichEdit.SetSel (cr); - wndRichEdit.HideSelection (FALSE, FALSE); -} - -void CWordPadView::OnFontname() -{ - USES_CONVERSION; - - CMFCToolBarFontComboBox* pSrcCombo = - (CMFCToolBarFontComboBox*) CMFCToolBarComboBoxButton::GetByCmd (IDC_FONTNAME, TRUE); - if (pSrcCombo == NULL) - { - CRichEditView::OnFormatFont (); - return; - } - - CCharFormat cf; - cf.szFaceName[0] = NULL; - cf.dwMask = CFM_FACE | CFM_CHARSET; - - const CMFCFontInfo* pDesc = pSrcCombo->GetFontDesc (); - ASSERT_VALID (pDesc); - ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE); - - lstrcpyn(cf.szFaceName, pDesc->m_strName, LF_FACESIZE); - - cf.bCharSet = pDesc->m_nCharSet; - cf.bPitchAndFamily = pDesc->m_nPitchAndFamily; - - // - CMFCToolBarFontSizeComboBox* pSizeCombo = - DYNAMIC_DOWNCAST (CMFCToolBarFontSizeComboBox, CMFCToolBarFontSizeComboBox::GetByCmd (IDC_FONTSIZE)); - if (pSizeCombo != NULL) - { - int nSize = pSizeCombo->GetTwipSize(); - // CMFCFontInfo* pDesc - pSizeCombo->RebuildFontSizes (pDesc->m_strName); - pSizeCombo->SetTwipSize (nSize); - } - // - - SetCharFormat (cf); - SetFocus (); -} -//**************************************************************************************** -void CWordPadView::OnFontsize() -{ - CMFCToolBarFontSizeComboBox* pSrcCombo = - (CMFCToolBarFontSizeComboBox*) CMFCToolBarComboBoxButton::GetByCmd (IDC_FONTSIZE, TRUE); - if (pSrcCombo == NULL) - { - CRichEditView::OnFormatFont (); - return; - } - - int nSize = pSrcCombo->GetTwipSize(); - if (nSize == -2) - { - AfxMessageBox(IDS_INVALID_NUMBER, MB_OK|MB_ICONINFORMATION); - } - else if ((nSize >= 0 && nSize < 20) || nSize > 32760) - { - AfxMessageBox(IDS_INVALID_FONTSIZE, MB_OK|MB_ICONINFORMATION); - } - else if (nSize > 0) - { - CCharFormat cf; - cf.dwMask = CFM_SIZE; - cf.yHeight = nSize; - - SetCharFormat (cf); - SetFocus (); - } -} -//********************************************************************************* -void CWordPadView::OnBorderType (UINT id) -{ - m_nBorderType = id; - - MessageBox (_T("Add your code here...")); -} -//******************************************************************************** -void CWordPadView::OnUpdateBorderType (CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck (pCmdUI->m_nID == m_nBorderType); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpvw.h b/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpvw.h deleted file mode 100644 index 90d9afcfd5350..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_WordPad/cpp/wordpvw.h +++ /dev/null @@ -1,128 +0,0 @@ -// -// wordpvw.h : interface of the CWordPadView class -// -// -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -class CWordPadView : public CRichEditView -{ -protected: // create from serialization only - CWordPadView(); - DECLARE_DYNCREATE(CWordPadView) - -// Attributes -public: - UINT_PTR m_uTimerID; - BOOL m_bDelayUpdateItems; - BOOL m_bInPrint; - CParaFormat m_defParaFormat; - CCharFormat m_defCharFormat; - CCharFormat m_defTextCharFormat; - - CWordPadDoc* GetDocument(); - BOOL IsFormatText(); - - virtual HMENU GetContextMenu(WORD seltype, LPOLEOBJECT lpoleobj, - CHARRANGE* lpchrg); - -// Operations -public: - BOOL PasteNative(LPDATAOBJECT lpdataobj); - void SetDefaultFont(BOOL bText); - void SetUpdateTimer(); - void GetDefaultFont(CCharFormat& cf, UINT nFontNameID); - void DrawMargins(CDC* pDC); - BOOL SelectPalette(); - BOOL ShowContextMenu (CPoint pt); - void SetTextColor (COLORREF color); - - void GetDocumentColors (CList& lstColors); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CWordPadView) - protected: - virtual void CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType = adjustBorder); - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); - //}}AFX_VIRTUAL - BOOL OnPreparePrinting(CPrintInfo* pInfo); - virtual HRESULT GetClipboardData(CHARRANGE* lpchrg, DWORD reco, - LPDATAOBJECT lpRichDataObj, LPDATAOBJECT* lplpdataobj); - virtual HRESULT QueryAcceptData(LPDATAOBJECT, CLIPFORMAT*, DWORD, - BOOL, HGLOBAL); -public: - virtual void WrapChanged(); - -// Implementation -public: -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - BOOL m_bOnBar; - UINT m_nBorderType; - - // OLE Container support - - virtual void DeleteContents(); - virtual void OnTextNotFound(LPCTSTR); - -// Generated message map functions -protected: - afx_msg void OnCancelEditSrvr(); - //{{AFX_MSG(CWordPadView) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnPageSetup(); - afx_msg void OnInsertDateTime(); - afx_msg void OnFormatParagraph(); - afx_msg void OnFormatTabs(); - afx_msg void OnTimer(UINT_PTR nIDEvent); - afx_msg void OnDestroy(); - afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); - afx_msg void OnPenBackspace(); - afx_msg void OnPenNewline(); - afx_msg void OnPenPeriod(); - afx_msg void OnPenSpace(); - afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); - afx_msg void OnFilePrint(); - afx_msg void OnPenLens(); - afx_msg void OnPenTab(); - afx_msg void OnPaletteChanged(CWnd* pFocusWnd); - afx_msg BOOL OnQueryNewPalette(); - afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnRButtonUp(UINT nFlags, CPoint point); - afx_msg void OnCharColor(); - afx_msg void OnFilePrintPreview(); - afx_msg void OnFontname(); - afx_msg void OnFontsize(); - //}}AFX_MSG - afx_msg void OnEditChange(); - afx_msg int OnMouseActivate(CWnd* pWnd, UINT nHitTest, UINT message); - afx_msg LONG OnPrinterChangedMsg(UINT, LONG); - afx_msg void OnBarSetFocus(UINT, NMHDR*, LRESULT*); - afx_msg void OnBarKillFocus(UINT, NMHDR*, LRESULT*); - afx_msg void OnBarReturn(UINT, NMHDR*, LRESULT* ); - afx_msg void OnBorderType (UINT id); - afx_msg void OnUpdateBorderType (CCmdUI* pCmdUI); - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in wordpvw.cpp -inline CWordPadDoc* CWordPadView::GetDocument() - { return (CWordPadDoc*)m_pDocument; } -#endif - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/astoria custom feeds.sln b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/astoria custom feeds.sln deleted file mode 100644 index 1f936fb8a7c7b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/astoria custom feeds.sln +++ /dev/null @@ -1,32 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Astoria Custom Feeds", "CS\Astoria Custom Feeds.csproj", "{71409BBB-9710-483C-A297-34C1946841ED}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Custom Feed Client", "Custom Feed Client\Custom Feed Client.csproj", "{6673812E-CA91-4FFB-9247-9D58F4A68305}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Astoria Custom Feeds VB", "VB\Astoria Custom Feeds VB.vbproj", "{3B883B5E-9F81-41F7-A313-DCDA4D77F1E0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {71409BBB-9710-483C-A297-34C1946841ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {71409BBB-9710-483C-A297-34C1946841ED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {71409BBB-9710-483C-A297-34C1946841ED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {71409BBB-9710-483C-A297-34C1946841ED}.Release|Any CPU.Build.0 = Release|Any CPU - {6673812E-CA91-4FFB-9247-9D58F4A68305}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6673812E-CA91-4FFB-9247-9D58F4A68305}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6673812E-CA91-4FFB-9247-9D58F4A68305}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6673812E-CA91-4FFB-9247-9D58F4A68305}.Release|Any CPU.Build.0 = Release|Any CPU - {3B883B5E-9F81-41F7-A313-DCDA4D77F1E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B883B5E-9F81-41F7-A313-DCDA4D77F1E0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B883B5E-9F81-41F7-A313-DCDA4D77F1E0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B883B5E-9F81-41F7-A313-DCDA4D77F1E0}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/app.config b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/app.config deleted file mode 100644 index 2f7cce784b99e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/custom feed client.csproj b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/custom feed client.csproj deleted file mode 100644 index ef55aff404bed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/custom feed client.csproj +++ /dev/null @@ -1,144 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {6673812E-CA91-4FFB-9247-9D58F4A68305} - Exe - Properties - Custom_Feed_Client - Custom Feed Client - v4.0 - 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - Client - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - - - - 3.0 - - - 3.0 - - - - 3.5 - - - False - ..\..\..\..\..\..\..\Program Files (x86)\ADO.NET Data Services V1.5 CTP2\bin\System.Data.Services.Client.dll - 3.5 - - - 3.0 - - - 3.0 - - - 3.5 - - - 3.5 - - - - - 3.0 - - - 3.0 - - - - - - - True - True - Reference.datasvcmap - - - - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - datasvcmap - - - - - DataServiceClientGenerator - Reference.cs - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/program.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/program.cs deleted file mode 100644 index f13fd96a2ded2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/program.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Custom_Feed_Client.Northwind; - -namespace Custom_Feed_Client -{ - class Program - { - static void Main(string[] args) - { - try - { - //NorthwindEntities context = new NorthwindEntities(new Uri("http://localhost:12345/Northwind.svc")); - NorthwindEntities context = new NorthwindEntities(new Uri("http://localhost:54321/Northwind.svc")); - - var cust = from customers in context.Customers - where customers.CustomerID == "ALFKI" - select customers; - - foreach (Customer c in cust) - { - Console.WriteLine(c.CompanyName.ToString()); - } - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/properties/assemblyinfo.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/properties/assemblyinfo.cs deleted file mode 100644 index d9fa46f494f41..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/properties/assemblyinfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Custom Feed Client")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("Custom Feed Client")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("903886d4-0f5f-44ff-b428-41cf8668ad74")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/reference.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/reference.cs deleted file mode 100644 index ab3f08a571325..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/reference.cs +++ /dev/null @@ -1,1299 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.235 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Original file name: -// Generation date: 8/9/2011 12:17:07 AM -namespace Custom_Feed_Client.Northwind -{ - - /// - /// There are no comments for NorthwindEntities in the schema. - /// - public partial class NorthwindEntities : global::System.Data.Services.Client.DataServiceContext - { - /// - /// Initialize a new NorthwindEntities object. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public NorthwindEntities(global::System.Uri serviceRoot) : - base(serviceRoot) - { - this.ResolveName = new global::System.Func(this.ResolveNameFromType); - this.ResolveType = new global::System.Func(this.ResolveTypeFromName); - this.OnContextCreated(); - } - partial void OnContextCreated(); - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected global::System.Type ResolveTypeFromName(string typeName) - { - if (typeName.StartsWith("NorthwindModel", global::System.StringComparison.Ordinal)) - { - return this.GetType().Assembly.GetType(string.Concat("Custom_Feed_Client.Northwind", typeName.Substring(14)), false); - } - return null; - } - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected string ResolveNameFromType(global::System.Type clientType) - { - if (clientType.Namespace.Equals("Custom_Feed_Client.Northwind", global::System.StringComparison.Ordinal)) - { - return string.Concat("NorthwindModel.", clientType.Name); - } - return null; - } - /// - /// There are no comments for Customers in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Customers - { - get - { - if ((this._Customers == null)) - { - this._Customers = base.CreateQuery("Customers"); - } - return this._Customers; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Customers; - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Order_Details - { - get - { - if ((this._Order_Details == null)) - { - this._Order_Details = base.CreateQuery("Order_Details"); - } - return this._Order_Details; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Order_Details; - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Orders - { - get - { - if ((this._Orders == null)) - { - this._Orders = base.CreateQuery("Orders"); - } - return this._Orders; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Orders; - /// - /// There are no comments for Products in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Products - { - get - { - if ((this._Products == null)) - { - this._Products = base.CreateQuery("Products"); - } - return this._Products; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Products; - /// - /// There are no comments for Customers in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToCustomers(Customer customer) - { - base.AddObject("Customers", customer); - } - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToOrder_Details(Order_Detail order_Detail) - { - base.AddObject("Order_Details", order_Detail); - } - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToOrders(Order order) - { - base.AddObject("Orders", order); - } - /// - /// There are no comments for Products in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToProducts(Product product) - { - base.AddObject("Products", product); - } - } - /// - /// There are no comments for NorthwindModel.Customer in the schema. - /// - /// - /// CustomerID - /// - [global::System.Data.Services.Common.EntitySetAttribute("Customers")] - [global::System.Data.Services.Common.EntityPropertyMappingAttribute("CustomerID", System.Data.Services.Common.SyndicationItemProperty.Title, System.Data.Services.Common.SyndicationTextContentKind.Plaintext, true)] - [global::System.Data.Services.Common.EntityPropertyMappingAttribute("ContactName", System.Data.Services.Common.SyndicationItemProperty.AuthorName, System.Data.Services.Common.SyndicationTextContentKind.Plaintext, true)] - [global::System.Data.Services.Common.EntityPropertyMappingAttribute("CompanyName", "CompanyName", "Northwind", "http://schemas.examples.microsoft.com/dataservices", true)] - [global::System.Data.Services.Common.DataServiceKeyAttribute("CustomerID")] - public partial class Customer : global::System.ComponentModel.INotifyPropertyChanged - { - /// - /// Create a new Customer object. - /// - /// Initial value of CustomerID. - /// Initial value of CompanyName. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Customer CreateCustomer(string customerID, string companyName) - { - Customer customer = new Customer(); - customer.CustomerID = customerID; - customer.CompanyName = companyName; - return customer; - } - /// - /// There are no comments for Property CustomerID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string CustomerID - { - get - { - return this._CustomerID; - } - set - { - this.OnCustomerIDChanging(value); - this._CustomerID = value; - this.OnCustomerIDChanged(); - this.OnPropertyChanged("CustomerID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _CustomerID; - partial void OnCustomerIDChanging(string value); - partial void OnCustomerIDChanged(); - /// - /// There are no comments for Property ContactName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ContactName - { - get - { - return this._ContactName; - } - set - { - this.OnContactNameChanging(value); - this._ContactName = value; - this.OnContactNameChanged(); - this.OnPropertyChanged("ContactName"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ContactName; - partial void OnContactNameChanging(string value); - partial void OnContactNameChanged(); - /// - /// There are no comments for Property CompanyName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string CompanyName - { - get - { - return this._CompanyName; - } - set - { - this.OnCompanyNameChanging(value); - this._CompanyName = value; - this.OnCompanyNameChanged(); - this.OnPropertyChanged("CompanyName"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _CompanyName; - partial void OnCompanyNameChanging(string value); - partial void OnCompanyNameChanged(); - /// - /// There are no comments for Property ContactTitle in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ContactTitle - { - get - { - return this._ContactTitle; - } - set - { - this.OnContactTitleChanging(value); - this._ContactTitle = value; - this.OnContactTitleChanged(); - this.OnPropertyChanged("ContactTitle"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ContactTitle; - partial void OnContactTitleChanging(string value); - partial void OnContactTitleChanged(); - /// - /// There are no comments for Property Address in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Address - { - get - { - return this._Address; - } - set - { - this.OnAddressChanging(value); - this._Address = value; - this.OnAddressChanged(); - this.OnPropertyChanged("Address"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Address; - partial void OnAddressChanging(string value); - partial void OnAddressChanged(); - /// - /// There are no comments for Property City in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string City - { - get - { - return this._City; - } - set - { - this.OnCityChanging(value); - this._City = value; - this.OnCityChanged(); - this.OnPropertyChanged("City"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _City; - partial void OnCityChanging(string value); - partial void OnCityChanged(); - /// - /// There are no comments for Property Region in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Region - { - get - { - return this._Region; - } - set - { - this.OnRegionChanging(value); - this._Region = value; - this.OnRegionChanged(); - this.OnPropertyChanged("Region"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Region; - partial void OnRegionChanging(string value); - partial void OnRegionChanged(); - /// - /// There are no comments for Property PostalCode in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string PostalCode - { - get - { - return this._PostalCode; - } - set - { - this.OnPostalCodeChanging(value); - this._PostalCode = value; - this.OnPostalCodeChanged(); - this.OnPropertyChanged("PostalCode"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _PostalCode; - partial void OnPostalCodeChanging(string value); - partial void OnPostalCodeChanged(); - /// - /// There are no comments for Property Country in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Country - { - get - { - return this._Country; - } - set - { - this.OnCountryChanging(value); - this._Country = value; - this.OnCountryChanged(); - this.OnPropertyChanged("Country"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Country; - partial void OnCountryChanging(string value); - partial void OnCountryChanged(); - /// - /// There are no comments for Property Phone in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Phone - { - get - { - return this._Phone; - } - set - { - this.OnPhoneChanging(value); - this._Phone = value; - this.OnPhoneChanged(); - this.OnPropertyChanged("Phone"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Phone; - partial void OnPhoneChanging(string value); - partial void OnPhoneChanged(); - /// - /// There are no comments for Property Fax in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Fax - { - get - { - return this._Fax; - } - set - { - this.OnFaxChanging(value); - this._Fax = value; - this.OnFaxChanged(); - this.OnPropertyChanged("Fax"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Fax; - partial void OnFaxChanging(string value); - partial void OnFaxChanged(); - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceCollection Orders - { - get - { - return this._Orders; - } - set - { - this._Orders = value; - this.OnPropertyChanged("Orders"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceCollection _Orders = new global::System.Data.Services.Client.DataServiceCollection(null, System.Data.Services.Client.TrackingMode.None); - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected virtual void OnPropertyChanged(string property) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); - } - } - } - /// - /// There are no comments for NorthwindModel.Order_Detail in the schema. - /// - /// - /// OrderID - /// ProductID - /// - [global::System.Data.Services.Common.EntitySetAttribute("Order_Details")] - [global::System.Data.Services.Common.DataServiceKeyAttribute("OrderID", "ProductID")] - public partial class Order_Detail : global::System.ComponentModel.INotifyPropertyChanged - { - /// - /// Create a new Order_Detail object. - /// - /// Initial value of OrderID. - /// Initial value of ProductID. - /// Initial value of UnitPrice. - /// Initial value of Quantity. - /// Initial value of Discount. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Order_Detail CreateOrder_Detail(int orderID, int productID, decimal unitPrice, short quantity, float discount) - { - Order_Detail order_Detail = new Order_Detail(); - order_Detail.OrderID = orderID; - order_Detail.ProductID = productID; - order_Detail.UnitPrice = unitPrice; - order_Detail.Quantity = quantity; - order_Detail.Discount = discount; - return order_Detail; - } - /// - /// There are no comments for Property OrderID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int OrderID - { - get - { - return this._OrderID; - } - set - { - this.OnOrderIDChanging(value); - this._OrderID = value; - this.OnOrderIDChanged(); - this.OnPropertyChanged("OrderID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _OrderID; - partial void OnOrderIDChanging(int value); - partial void OnOrderIDChanged(); - /// - /// There are no comments for Property ProductID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int ProductID - { - get - { - return this._ProductID; - } - set - { - this.OnProductIDChanging(value); - this._ProductID = value; - this.OnProductIDChanged(); - this.OnPropertyChanged("ProductID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _ProductID; - partial void OnProductIDChanging(int value); - partial void OnProductIDChanged(); - /// - /// There are no comments for Property UnitPrice in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public decimal UnitPrice - { - get - { - return this._UnitPrice; - } - set - { - this.OnUnitPriceChanging(value); - this._UnitPrice = value; - this.OnUnitPriceChanged(); - this.OnPropertyChanged("UnitPrice"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private decimal _UnitPrice; - partial void OnUnitPriceChanging(decimal value); - partial void OnUnitPriceChanged(); - /// - /// There are no comments for Property Quantity in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public short Quantity - { - get - { - return this._Quantity; - } - set - { - this.OnQuantityChanging(value); - this._Quantity = value; - this.OnQuantityChanged(); - this.OnPropertyChanged("Quantity"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private short _Quantity; - partial void OnQuantityChanging(short value); - partial void OnQuantityChanged(); - /// - /// There are no comments for Property Discount in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public float Discount - { - get - { - return this._Discount; - } - set - { - this.OnDiscountChanging(value); - this._Discount = value; - this.OnDiscountChanged(); - this.OnPropertyChanged("Discount"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private float _Discount; - partial void OnDiscountChanging(float value); - partial void OnDiscountChanged(); - /// - /// There are no comments for Order in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public Order Order - { - get - { - return this._Order; - } - set - { - this._Order = value; - this.OnPropertyChanged("Order"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private Order _Order; - /// - /// There are no comments for Product in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public Product Product - { - get - { - return this._Product; - } - set - { - this._Product = value; - this.OnPropertyChanged("Product"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private Product _Product; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected virtual void OnPropertyChanged(string property) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); - } - } - } - /// - /// There are no comments for NorthwindModel.Order in the schema. - /// - /// - /// OrderID - /// - [global::System.Data.Services.Common.EntitySetAttribute("Orders")] - [global::System.Data.Services.Common.DataServiceKeyAttribute("OrderID")] - public partial class Order : global::System.ComponentModel.INotifyPropertyChanged - { - /// - /// Create a new Order object. - /// - /// Initial value of OrderID. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Order CreateOrder(int orderID) - { - Order order = new Order(); - order.OrderID = orderID; - return order; - } - /// - /// There are no comments for Property OrderID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int OrderID - { - get - { - return this._OrderID; - } - set - { - this.OnOrderIDChanging(value); - this._OrderID = value; - this.OnOrderIDChanged(); - this.OnPropertyChanged("OrderID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _OrderID; - partial void OnOrderIDChanging(int value); - partial void OnOrderIDChanged(); - /// - /// There are no comments for Property CustomerID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string CustomerID - { - get - { - return this._CustomerID; - } - set - { - this.OnCustomerIDChanging(value); - this._CustomerID = value; - this.OnCustomerIDChanged(); - this.OnPropertyChanged("CustomerID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _CustomerID; - partial void OnCustomerIDChanging(string value); - partial void OnCustomerIDChanged(); - /// - /// There are no comments for Property EmployeeID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable EmployeeID - { - get - { - return this._EmployeeID; - } - set - { - this.OnEmployeeIDChanging(value); - this._EmployeeID = value; - this.OnEmployeeIDChanged(); - this.OnPropertyChanged("EmployeeID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _EmployeeID; - partial void OnEmployeeIDChanging(global::System.Nullable value); - partial void OnEmployeeIDChanged(); - /// - /// There are no comments for Property OrderDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable OrderDate - { - get - { - return this._OrderDate; - } - set - { - this.OnOrderDateChanging(value); - this._OrderDate = value; - this.OnOrderDateChanged(); - this.OnPropertyChanged("OrderDate"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _OrderDate; - partial void OnOrderDateChanging(global::System.Nullable value); - partial void OnOrderDateChanged(); - /// - /// There are no comments for Property RequiredDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable RequiredDate - { - get - { - return this._RequiredDate; - } - set - { - this.OnRequiredDateChanging(value); - this._RequiredDate = value; - this.OnRequiredDateChanged(); - this.OnPropertyChanged("RequiredDate"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _RequiredDate; - partial void OnRequiredDateChanging(global::System.Nullable value); - partial void OnRequiredDateChanged(); - /// - /// There are no comments for Property ShippedDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable ShippedDate - { - get - { - return this._ShippedDate; - } - set - { - this.OnShippedDateChanging(value); - this._ShippedDate = value; - this.OnShippedDateChanged(); - this.OnPropertyChanged("ShippedDate"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _ShippedDate; - partial void OnShippedDateChanging(global::System.Nullable value); - partial void OnShippedDateChanged(); - /// - /// There are no comments for Property ShipVia in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable ShipVia - { - get - { - return this._ShipVia; - } - set - { - this.OnShipViaChanging(value); - this._ShipVia = value; - this.OnShipViaChanged(); - this.OnPropertyChanged("ShipVia"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _ShipVia; - partial void OnShipViaChanging(global::System.Nullable value); - partial void OnShipViaChanged(); - /// - /// There are no comments for Property Freight in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable Freight - { - get - { - return this._Freight; - } - set - { - this.OnFreightChanging(value); - this._Freight = value; - this.OnFreightChanged(); - this.OnPropertyChanged("Freight"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _Freight; - partial void OnFreightChanging(global::System.Nullable value); - partial void OnFreightChanged(); - /// - /// There are no comments for Property ShipName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipName - { - get - { - return this._ShipName; - } - set - { - this.OnShipNameChanging(value); - this._ShipName = value; - this.OnShipNameChanged(); - this.OnPropertyChanged("ShipName"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipName; - partial void OnShipNameChanging(string value); - partial void OnShipNameChanged(); - /// - /// There are no comments for Property ShipAddress in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipAddress - { - get - { - return this._ShipAddress; - } - set - { - this.OnShipAddressChanging(value); - this._ShipAddress = value; - this.OnShipAddressChanged(); - this.OnPropertyChanged("ShipAddress"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipAddress; - partial void OnShipAddressChanging(string value); - partial void OnShipAddressChanged(); - /// - /// There are no comments for Property ShipCity in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipCity - { - get - { - return this._ShipCity; - } - set - { - this.OnShipCityChanging(value); - this._ShipCity = value; - this.OnShipCityChanged(); - this.OnPropertyChanged("ShipCity"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipCity; - partial void OnShipCityChanging(string value); - partial void OnShipCityChanged(); - /// - /// There are no comments for Property ShipRegion in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipRegion - { - get - { - return this._ShipRegion; - } - set - { - this.OnShipRegionChanging(value); - this._ShipRegion = value; - this.OnShipRegionChanged(); - this.OnPropertyChanged("ShipRegion"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipRegion; - partial void OnShipRegionChanging(string value); - partial void OnShipRegionChanged(); - /// - /// There are no comments for Property ShipPostalCode in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipPostalCode - { - get - { - return this._ShipPostalCode; - } - set - { - this.OnShipPostalCodeChanging(value); - this._ShipPostalCode = value; - this.OnShipPostalCodeChanged(); - this.OnPropertyChanged("ShipPostalCode"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipPostalCode; - partial void OnShipPostalCodeChanging(string value); - partial void OnShipPostalCodeChanged(); - /// - /// There are no comments for Property ShipCountry in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipCountry - { - get - { - return this._ShipCountry; - } - set - { - this.OnShipCountryChanging(value); - this._ShipCountry = value; - this.OnShipCountryChanged(); - this.OnPropertyChanged("ShipCountry"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipCountry; - partial void OnShipCountryChanging(string value); - partial void OnShipCountryChanged(); - /// - /// There are no comments for Customer in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public Customer Customer - { - get - { - return this._Customer; - } - set - { - this._Customer = value; - this.OnPropertyChanged("Customer"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private Customer _Customer; - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceCollection Order_Details - { - get - { - return this._Order_Details; - } - set - { - this._Order_Details = value; - this.OnPropertyChanged("Order_Details"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceCollection _Order_Details = new global::System.Data.Services.Client.DataServiceCollection(null, System.Data.Services.Client.TrackingMode.None); - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected virtual void OnPropertyChanged(string property) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); - } - } - } - /// - /// There are no comments for NorthwindModel.Product in the schema. - /// - /// - /// ProductID - /// - [global::System.Data.Services.Common.EntitySetAttribute("Products")] - [global::System.Data.Services.Common.EntityPropertyMappingAttribute("ProductName", System.Data.Services.Common.SyndicationItemProperty.AuthorName, System.Data.Services.Common.SyndicationTextContentKind.Plaintext, true)] - [global::System.Data.Services.Common.EntityPropertyMappingAttribute("UnitsInStock", "UnitsInStock", "Northwind", "http://schemas.examples.microsoft.com/dataservices", true)] - [global::System.Data.Services.Common.EntityPropertyMappingAttribute("ReorderLevel", "UnitsInStock/@ReorderLevel", "Northwind", "http://schemas.examples.microsoft.com/dataservices", false)] - [global::System.Data.Services.Common.DataServiceKeyAttribute("ProductID")] - public partial class Product : global::System.ComponentModel.INotifyPropertyChanged - { - /// - /// Create a new Product object. - /// - /// Initial value of ProductID. - /// Initial value of ProductName. - /// Initial value of Discontinued. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Product CreateProduct(int productID, string productName, bool discontinued) - { - Product product = new Product(); - product.ProductID = productID; - product.ProductName = productName; - product.Discontinued = discontinued; - return product; - } - /// - /// There are no comments for Property ProductID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int ProductID - { - get - { - return this._ProductID; - } - set - { - this.OnProductIDChanging(value); - this._ProductID = value; - this.OnProductIDChanged(); - this.OnPropertyChanged("ProductID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _ProductID; - partial void OnProductIDChanging(int value); - partial void OnProductIDChanged(); - /// - /// There are no comments for Property ProductName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ProductName - { - get - { - return this._ProductName; - } - set - { - this.OnProductNameChanging(value); - this._ProductName = value; - this.OnProductNameChanged(); - this.OnPropertyChanged("ProductName"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ProductName; - partial void OnProductNameChanging(string value); - partial void OnProductNameChanged(); - /// - /// There are no comments for Property UnitsInStock in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable UnitsInStock - { - get - { - return this._UnitsInStock; - } - set - { - this.OnUnitsInStockChanging(value); - this._UnitsInStock = value; - this.OnUnitsInStockChanged(); - this.OnPropertyChanged("UnitsInStock"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _UnitsInStock; - partial void OnUnitsInStockChanging(global::System.Nullable value); - partial void OnUnitsInStockChanged(); - /// - /// There are no comments for Property ReorderLevel in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable ReorderLevel - { - get - { - return this._ReorderLevel; - } - set - { - this.OnReorderLevelChanging(value); - this._ReorderLevel = value; - this.OnReorderLevelChanged(); - this.OnPropertyChanged("ReorderLevel"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _ReorderLevel; - partial void OnReorderLevelChanging(global::System.Nullable value); - partial void OnReorderLevelChanged(); - /// - /// There are no comments for Property SupplierID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable SupplierID - { - get - { - return this._SupplierID; - } - set - { - this.OnSupplierIDChanging(value); - this._SupplierID = value; - this.OnSupplierIDChanged(); - this.OnPropertyChanged("SupplierID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _SupplierID; - partial void OnSupplierIDChanging(global::System.Nullable value); - partial void OnSupplierIDChanged(); - /// - /// There are no comments for Property CategoryID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable CategoryID - { - get - { - return this._CategoryID; - } - set - { - this.OnCategoryIDChanging(value); - this._CategoryID = value; - this.OnCategoryIDChanged(); - this.OnPropertyChanged("CategoryID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _CategoryID; - partial void OnCategoryIDChanging(global::System.Nullable value); - partial void OnCategoryIDChanged(); - /// - /// There are no comments for Property QuantityPerUnit in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string QuantityPerUnit - { - get - { - return this._QuantityPerUnit; - } - set - { - this.OnQuantityPerUnitChanging(value); - this._QuantityPerUnit = value; - this.OnQuantityPerUnitChanged(); - this.OnPropertyChanged("QuantityPerUnit"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _QuantityPerUnit; - partial void OnQuantityPerUnitChanging(string value); - partial void OnQuantityPerUnitChanged(); - /// - /// There are no comments for Property UnitPrice in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable UnitPrice - { - get - { - return this._UnitPrice; - } - set - { - this.OnUnitPriceChanging(value); - this._UnitPrice = value; - this.OnUnitPriceChanged(); - this.OnPropertyChanged("UnitPrice"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _UnitPrice; - partial void OnUnitPriceChanging(global::System.Nullable value); - partial void OnUnitPriceChanged(); - /// - /// There are no comments for Property UnitsOnOrder in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable UnitsOnOrder - { - get - { - return this._UnitsOnOrder; - } - set - { - this.OnUnitsOnOrderChanging(value); - this._UnitsOnOrder = value; - this.OnUnitsOnOrderChanged(); - this.OnPropertyChanged("UnitsOnOrder"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _UnitsOnOrder; - partial void OnUnitsOnOrderChanging(global::System.Nullable value); - partial void OnUnitsOnOrderChanged(); - /// - /// There are no comments for Property Discontinued in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public bool Discontinued - { - get - { - return this._Discontinued; - } - set - { - this.OnDiscontinuedChanging(value); - this._Discontinued = value; - this.OnDiscontinuedChanged(); - this.OnPropertyChanged("Discontinued"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private bool _Discontinued; - partial void OnDiscontinuedChanging(bool value); - partial void OnDiscontinuedChanged(); - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceCollection Order_Details - { - get - { - return this._Order_Details; - } - set - { - this._Order_Details = value; - this.OnPropertyChanged("Order_Details"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceCollection _Order_Details = new global::System.Data.Services.Client.DataServiceCollection(null, System.Data.Services.Client.TrackingMode.None); - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected virtual void OnPropertyChanged(string property) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); - } - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/reference.datasvcmap b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/reference.datasvcmap deleted file mode 100644 index bd0c336b09159..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/reference.datasvcmap +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/service.edmx b/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/service.edmx deleted file mode 100644 index 59d69684a5250..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria custom feeds/custom feed client/service references/northwind/service.edmx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/astoria linq provider.sln b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/astoria linq provider.sln deleted file mode 100644 index 6eecfb625142d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/astoria linq provider.sln +++ /dev/null @@ -1,54 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinqProviderCS", "CS\LinqProviderCS.csproj", "{D52F0C68-0D94-4438-8E2D-400194CB8A97}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinqProviderClientCS", "LinqProviderClientCS\LinqProviderClientCS.csproj", "{81BFBEDE-5DCD-4D51-8DD0-9114739A1562}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LinqProviderVB", "VB\LinqProviderVB.vbproj", "{ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Debug|x86.ActiveCfg = Debug|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Release|Any CPU.Build.0 = Release|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {D52F0C68-0D94-4438-8E2D-400194CB8A97}.Release|x86.ActiveCfg = Release|Any CPU - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Debug|Any CPU.ActiveCfg = Debug|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Debug|x86.ActiveCfg = Debug|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Debug|x86.Build.0 = Debug|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Release|Any CPU.ActiveCfg = Release|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Release|Mixed Platforms.Build.0 = Release|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Release|x86.ActiveCfg = Release|x86 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562}.Release|x86.Build.0 = Release|x86 - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Debug|x86.ActiveCfg = Debug|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Release|Any CPU.Build.0 = Release|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {ECEB64FC-6F96-4BEB-A89A-3D18283DD2B4}.Release|x86.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/linqproviderclientcs.csproj b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/linqproviderclientcs.csproj deleted file mode 100644 index 8ed689cc8536e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/linqproviderclientcs.csproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - Debug - x86 - 9.0.30729 - 2.0 - {81BFBEDE-5DCD-4D51-8DD0-9114739A1562} - Exe - Properties - NorthwindClient - LinqProviderClient - v4.0 - 512 - x86 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - - - - - 3.5 - - - False - ..\..\..\..\..\..\..\Program Files (x86)\ADO.NET Data Services V1.5 CTP2\bin\System.Data.Services.Client.dll - 3.5 - - - - - 3.5 - - - 3.5 - - - - - - - - - True - True - Reference.datasvcmap - - - - - - - - datasvcmap - - - - - - - - DataServiceClientGenerator - Reference.cs - - - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/program.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/program.cs deleted file mode 100644 index 390ff549bb653..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/program.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NorthwindClient.Northwind; - -namespace NorthwindClient -{ - class Program - { - static void Main(string[] args) - { - //NorthwindDataContext context = new NorthwindDataContext(new Uri("http://localhost:12345/Northwind.svc")); - NorthwindDataContext context = new NorthwindDataContext(new Uri("http://localhost:54321/Northwind.svc")); - - var order = (from o in context.Orders.Expand("Order_Details") - where o.OrderID == 10248 - select o).FirstOrDefault(); - - var item = order.Order_Details.FirstOrDefault(); - - item.Quantity += 1; - context.UpdateObject(item); - context.SaveChanges(); - - context.DeleteObject(item); - context.SaveChanges(); - - context.AddRelatedObject(order, "Order_Details", item); - context.SaveChanges(); - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/properties/assemblyinfo.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/properties/assemblyinfo.cs deleted file mode 100644 index 9d285e54de03b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/properties/assemblyinfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("LinqProviderClientCS")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("LinqProviderClientCS")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1e384ffe-9968-4ce5-aeda-4806b44d8862")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/reference.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/reference.cs deleted file mode 100644 index 1729e9a8e1998..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/reference.cs +++ /dev/null @@ -1,1208 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.21030.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Original file name: -// Generation date: 11/20/2009 1:43:51 PM -namespace NorthwindClient.Northwind -{ - - /// - /// There are no comments for NorthwindDataContext in the schema. - /// - public partial class NorthwindDataContext : global::System.Data.Services.Client.DataServiceContext - { - /// - /// Initialize a new NorthwindDataContext object. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public NorthwindDataContext(global::System.Uri serviceRoot) : - base(serviceRoot) - { - this.ResolveName = new global::System.Func(this.ResolveNameFromType); - this.ResolveType = new global::System.Func(this.ResolveTypeFromName); - this.OnContextCreated(); - } - partial void OnContextCreated(); - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected global::System.Type ResolveTypeFromName(string typeName) - { - if (typeName.StartsWith("NorthwindService", global::System.StringComparison.Ordinal)) - { - return this.GetType().Assembly.GetType(string.Concat("NorthwindClient.Northwind", typeName.Substring(16)), false); - } - return null; - } - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected string ResolveNameFromType(global::System.Type clientType) - { - if (clientType.Namespace.Equals("NorthwindClient.Northwind", global::System.StringComparison.Ordinal)) - { - return string.Concat("NorthwindService.", clientType.Name); - } - return null; - } - /// - /// There are no comments for Customers in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Customers - { - get - { - if ((this._Customers == null)) - { - this._Customers = base.CreateQuery("Customers"); - } - return this._Customers; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Customers; - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Orders - { - get - { - if ((this._Orders == null)) - { - this._Orders = base.CreateQuery("Orders"); - } - return this._Orders; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Orders; - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Order_Details - { - get - { - if ((this._Order_Details == null)) - { - this._Order_Details = base.CreateQuery("Order_Details"); - } - return this._Order_Details; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Order_Details; - /// - /// There are no comments for Products in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Products - { - get - { - if ((this._Products == null)) - { - this._Products = base.CreateQuery("Products"); - } - return this._Products; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Products; - /// - /// There are no comments for Customers in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToCustomers(Customer customer) - { - base.AddObject("Customers", customer); - } - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToOrders(Order order) - { - base.AddObject("Orders", order); - } - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToOrder_Details(Order_Detail order_Detail) - { - base.AddObject("Order_Details", order_Detail); - } - /// - /// There are no comments for Products in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToProducts(Product product) - { - base.AddObject("Products", product); - } - } - /// - /// There are no comments for NorthwindService.Customer in the schema. - /// - /// - /// CustomerID - /// - [global::System.Data.Services.Common.DataServiceKeyAttribute("CustomerID")] - public partial class Customer - { - /// - /// Create a new Customer object. - /// - /// Initial value of CustomerID. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Customer CreateCustomer(string customerID) - { - Customer customer = new Customer(); - customer.CustomerID = customerID; - return customer; - } - /// - /// There are no comments for Property CustomerID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string CustomerID - { - get - { - return this._CustomerID; - } - set - { - this.OnCustomerIDChanging(value); - this._CustomerID = value; - this.OnCustomerIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _CustomerID; - partial void OnCustomerIDChanging(string value); - partial void OnCustomerIDChanged(); - /// - /// There are no comments for Property CompanyName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string CompanyName - { - get - { - return this._CompanyName; - } - set - { - this.OnCompanyNameChanging(value); - this._CompanyName = value; - this.OnCompanyNameChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _CompanyName; - partial void OnCompanyNameChanging(string value); - partial void OnCompanyNameChanged(); - /// - /// There are no comments for Property ContactName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ContactName - { - get - { - return this._ContactName; - } - set - { - this.OnContactNameChanging(value); - this._ContactName = value; - this.OnContactNameChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ContactName; - partial void OnContactNameChanging(string value); - partial void OnContactNameChanged(); - /// - /// There are no comments for Property ContactTitle in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ContactTitle - { - get - { - return this._ContactTitle; - } - set - { - this.OnContactTitleChanging(value); - this._ContactTitle = value; - this.OnContactTitleChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ContactTitle; - partial void OnContactTitleChanging(string value); - partial void OnContactTitleChanged(); - /// - /// There are no comments for Property Address in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Address - { - get - { - return this._Address; - } - set - { - this.OnAddressChanging(value); - this._Address = value; - this.OnAddressChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Address; - partial void OnAddressChanging(string value); - partial void OnAddressChanged(); - /// - /// There are no comments for Property City in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string City - { - get - { - return this._City; - } - set - { - this.OnCityChanging(value); - this._City = value; - this.OnCityChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _City; - partial void OnCityChanging(string value); - partial void OnCityChanged(); - /// - /// There are no comments for Property Region in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Region - { - get - { - return this._Region; - } - set - { - this.OnRegionChanging(value); - this._Region = value; - this.OnRegionChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Region; - partial void OnRegionChanging(string value); - partial void OnRegionChanged(); - /// - /// There are no comments for Property PostalCode in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string PostalCode - { - get - { - return this._PostalCode; - } - set - { - this.OnPostalCodeChanging(value); - this._PostalCode = value; - this.OnPostalCodeChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _PostalCode; - partial void OnPostalCodeChanging(string value); - partial void OnPostalCodeChanged(); - /// - /// There are no comments for Property Country in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Country - { - get - { - return this._Country; - } - set - { - this.OnCountryChanging(value); - this._Country = value; - this.OnCountryChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Country; - partial void OnCountryChanging(string value); - partial void OnCountryChanged(); - /// - /// There are no comments for Property Phone in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Phone - { - get - { - return this._Phone; - } - set - { - this.OnPhoneChanging(value); - this._Phone = value; - this.OnPhoneChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Phone; - partial void OnPhoneChanging(string value); - partial void OnPhoneChanged(); - /// - /// There are no comments for Property Fax in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Fax - { - get - { - return this._Fax; - } - set - { - this.OnFaxChanging(value); - this._Fax = value; - this.OnFaxChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Fax; - partial void OnFaxChanging(string value); - partial void OnFaxChanged(); - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Collections.ObjectModel.Collection Orders - { - get - { - return this._Orders; - } - set - { - if ((value != null)) - { - this._Orders = value; - } - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Collections.ObjectModel.Collection _Orders = new global::System.Collections.ObjectModel.Collection(); - } - /// - /// There are no comments for NorthwindService.Order in the schema. - /// - /// - /// OrderID - /// - [global::System.Data.Services.Common.DataServiceKeyAttribute("OrderID")] - public partial class Order - { - /// - /// Create a new Order object. - /// - /// Initial value of OrderID. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Order CreateOrder(int orderID) - { - Order order = new Order(); - order.OrderID = orderID; - return order; - } - /// - /// There are no comments for Property OrderID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int OrderID - { - get - { - return this._OrderID; - } - set - { - this.OnOrderIDChanging(value); - this._OrderID = value; - this.OnOrderIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _OrderID; - partial void OnOrderIDChanging(int value); - partial void OnOrderIDChanged(); - /// - /// There are no comments for Property CustomerID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string CustomerID - { - get - { - return this._CustomerID; - } - set - { - this.OnCustomerIDChanging(value); - this._CustomerID = value; - this.OnCustomerIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _CustomerID; - partial void OnCustomerIDChanging(string value); - partial void OnCustomerIDChanged(); - /// - /// There are no comments for Property EmployeeID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable EmployeeID - { - get - { - return this._EmployeeID; - } - set - { - this.OnEmployeeIDChanging(value); - this._EmployeeID = value; - this.OnEmployeeIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _EmployeeID; - partial void OnEmployeeIDChanging(global::System.Nullable value); - partial void OnEmployeeIDChanged(); - /// - /// There are no comments for Property OrderDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable OrderDate - { - get - { - return this._OrderDate; - } - set - { - this.OnOrderDateChanging(value); - this._OrderDate = value; - this.OnOrderDateChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _OrderDate; - partial void OnOrderDateChanging(global::System.Nullable value); - partial void OnOrderDateChanged(); - /// - /// There are no comments for Property RequiredDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable RequiredDate - { - get - { - return this._RequiredDate; - } - set - { - this.OnRequiredDateChanging(value); - this._RequiredDate = value; - this.OnRequiredDateChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _RequiredDate; - partial void OnRequiredDateChanging(global::System.Nullable value); - partial void OnRequiredDateChanged(); - /// - /// There are no comments for Property ShippedDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable ShippedDate - { - get - { - return this._ShippedDate; - } - set - { - this.OnShippedDateChanging(value); - this._ShippedDate = value; - this.OnShippedDateChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _ShippedDate; - partial void OnShippedDateChanging(global::System.Nullable value); - partial void OnShippedDateChanged(); - /// - /// There are no comments for Property ShipVia in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable ShipVia - { - get - { - return this._ShipVia; - } - set - { - this.OnShipViaChanging(value); - this._ShipVia = value; - this.OnShipViaChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _ShipVia; - partial void OnShipViaChanging(global::System.Nullable value); - partial void OnShipViaChanged(); - /// - /// There are no comments for Property Freight in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable Freight - { - get - { - return this._Freight; - } - set - { - this.OnFreightChanging(value); - this._Freight = value; - this.OnFreightChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _Freight; - partial void OnFreightChanging(global::System.Nullable value); - partial void OnFreightChanged(); - /// - /// There are no comments for Property ShipName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipName - { - get - { - return this._ShipName; - } - set - { - this.OnShipNameChanging(value); - this._ShipName = value; - this.OnShipNameChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipName; - partial void OnShipNameChanging(string value); - partial void OnShipNameChanged(); - /// - /// There are no comments for Property ShipAddress in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipAddress - { - get - { - return this._ShipAddress; - } - set - { - this.OnShipAddressChanging(value); - this._ShipAddress = value; - this.OnShipAddressChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipAddress; - partial void OnShipAddressChanging(string value); - partial void OnShipAddressChanged(); - /// - /// There are no comments for Property ShipCity in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipCity - { - get - { - return this._ShipCity; - } - set - { - this.OnShipCityChanging(value); - this._ShipCity = value; - this.OnShipCityChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipCity; - partial void OnShipCityChanging(string value); - partial void OnShipCityChanged(); - /// - /// There are no comments for Property ShipRegion in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipRegion - { - get - { - return this._ShipRegion; - } - set - { - this.OnShipRegionChanging(value); - this._ShipRegion = value; - this.OnShipRegionChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipRegion; - partial void OnShipRegionChanging(string value); - partial void OnShipRegionChanged(); - /// - /// There are no comments for Property ShipPostalCode in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipPostalCode - { - get - { - return this._ShipPostalCode; - } - set - { - this.OnShipPostalCodeChanging(value); - this._ShipPostalCode = value; - this.OnShipPostalCodeChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipPostalCode; - partial void OnShipPostalCodeChanging(string value); - partial void OnShipPostalCodeChanged(); - /// - /// There are no comments for Property ShipCountry in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ShipCountry - { - get - { - return this._ShipCountry; - } - set - { - this.OnShipCountryChanging(value); - this._ShipCountry = value; - this.OnShipCountryChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ShipCountry; - partial void OnShipCountryChanging(string value); - partial void OnShipCountryChanged(); - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Collections.ObjectModel.Collection Order_Details - { - get - { - return this._Order_Details; - } - set - { - if ((value != null)) - { - this._Order_Details = value; - } - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Collections.ObjectModel.Collection _Order_Details = new global::System.Collections.ObjectModel.Collection(); - /// - /// There are no comments for Customer in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public Customer Customer - { - get - { - return this._Customer; - } - set - { - this._Customer = value; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private Customer _Customer; - } - /// - /// There are no comments for NorthwindService.Order_Detail in the schema. - /// - /// - /// OrderID - /// ProductID - /// - [global::System.Data.Services.Common.DataServiceKeyAttribute("OrderID", "ProductID")] - public partial class Order_Detail - { - /// - /// Create a new Order_Detail object. - /// - /// Initial value of OrderID. - /// Initial value of ProductID. - /// Initial value of UnitPrice. - /// Initial value of Quantity. - /// Initial value of Discount. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Order_Detail CreateOrder_Detail(int orderID, int productID, decimal unitPrice, short quantity, float discount) - { - Order_Detail order_Detail = new Order_Detail(); - order_Detail.OrderID = orderID; - order_Detail.ProductID = productID; - order_Detail.UnitPrice = unitPrice; - order_Detail.Quantity = quantity; - order_Detail.Discount = discount; - return order_Detail; - } - /// - /// There are no comments for Property OrderID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int OrderID - { - get - { - return this._OrderID; - } - set - { - this.OnOrderIDChanging(value); - this._OrderID = value; - this.OnOrderIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _OrderID; - partial void OnOrderIDChanging(int value); - partial void OnOrderIDChanged(); - /// - /// There are no comments for Property ProductID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int ProductID - { - get - { - return this._ProductID; - } - set - { - this.OnProductIDChanging(value); - this._ProductID = value; - this.OnProductIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _ProductID; - partial void OnProductIDChanging(int value); - partial void OnProductIDChanged(); - /// - /// There are no comments for Property UnitPrice in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public decimal UnitPrice - { - get - { - return this._UnitPrice; - } - set - { - this.OnUnitPriceChanging(value); - this._UnitPrice = value; - this.OnUnitPriceChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private decimal _UnitPrice; - partial void OnUnitPriceChanging(decimal value); - partial void OnUnitPriceChanged(); - /// - /// There are no comments for Property Quantity in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public short Quantity - { - get - { - return this._Quantity; - } - set - { - this.OnQuantityChanging(value); - this._Quantity = value; - this.OnQuantityChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private short _Quantity; - partial void OnQuantityChanging(short value); - partial void OnQuantityChanged(); - /// - /// There are no comments for Property Discount in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public float Discount - { - get - { - return this._Discount; - } - set - { - this.OnDiscountChanging(value); - this._Discount = value; - this.OnDiscountChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private float _Discount; - partial void OnDiscountChanging(float value); - partial void OnDiscountChanged(); - /// - /// There are no comments for Order in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public Order Order - { - get - { - return this._Order; - } - set - { - this._Order = value; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private Order _Order; - /// - /// There are no comments for Product in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public Product Product - { - get - { - return this._Product; - } - set - { - this._Product = value; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private Product _Product; - } - /// - /// There are no comments for NorthwindService.Product in the schema. - /// - /// - /// ProductID - /// - [global::System.Data.Services.Common.DataServiceKeyAttribute("ProductID")] - public partial class Product - { - /// - /// Create a new Product object. - /// - /// Initial value of ProductID. - /// Initial value of Discontinued. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Product CreateProduct(int productID, bool discontinued) - { - Product product = new Product(); - product.ProductID = productID; - product.Discontinued = discontinued; - return product; - } - /// - /// There are no comments for Property ProductID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int ProductID - { - get - { - return this._ProductID; - } - set - { - this.OnProductIDChanging(value); - this._ProductID = value; - this.OnProductIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _ProductID; - partial void OnProductIDChanging(int value); - partial void OnProductIDChanged(); - /// - /// There are no comments for Property ProductName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string ProductName - { - get - { - return this._ProductName; - } - set - { - this.OnProductNameChanging(value); - this._ProductName = value; - this.OnProductNameChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _ProductName; - partial void OnProductNameChanging(string value); - partial void OnProductNameChanged(); - /// - /// There are no comments for Property SupplierID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable SupplierID - { - get - { - return this._SupplierID; - } - set - { - this.OnSupplierIDChanging(value); - this._SupplierID = value; - this.OnSupplierIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _SupplierID; - partial void OnSupplierIDChanging(global::System.Nullable value); - partial void OnSupplierIDChanged(); - /// - /// There are no comments for Property CategoryID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable CategoryID - { - get - { - return this._CategoryID; - } - set - { - this.OnCategoryIDChanging(value); - this._CategoryID = value; - this.OnCategoryIDChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _CategoryID; - partial void OnCategoryIDChanging(global::System.Nullable value); - partial void OnCategoryIDChanged(); - /// - /// There are no comments for Property QuantityPerUnit in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string QuantityPerUnit - { - get - { - return this._QuantityPerUnit; - } - set - { - this.OnQuantityPerUnitChanging(value); - this._QuantityPerUnit = value; - this.OnQuantityPerUnitChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _QuantityPerUnit; - partial void OnQuantityPerUnitChanging(string value); - partial void OnQuantityPerUnitChanged(); - /// - /// There are no comments for Property UnitPrice in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable UnitPrice - { - get - { - return this._UnitPrice; - } - set - { - this.OnUnitPriceChanging(value); - this._UnitPrice = value; - this.OnUnitPriceChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _UnitPrice; - partial void OnUnitPriceChanging(global::System.Nullable value); - partial void OnUnitPriceChanged(); - /// - /// There are no comments for Property UnitsInStock in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable UnitsInStock - { - get - { - return this._UnitsInStock; - } - set - { - this.OnUnitsInStockChanging(value); - this._UnitsInStock = value; - this.OnUnitsInStockChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _UnitsInStock; - partial void OnUnitsInStockChanging(global::System.Nullable value); - partial void OnUnitsInStockChanged(); - /// - /// There are no comments for Property UnitsOnOrder in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable UnitsOnOrder - { - get - { - return this._UnitsOnOrder; - } - set - { - this.OnUnitsOnOrderChanging(value); - this._UnitsOnOrder = value; - this.OnUnitsOnOrderChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _UnitsOnOrder; - partial void OnUnitsOnOrderChanging(global::System.Nullable value); - partial void OnUnitsOnOrderChanged(); - /// - /// There are no comments for Property ReorderLevel in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable ReorderLevel - { - get - { - return this._ReorderLevel; - } - set - { - this.OnReorderLevelChanging(value); - this._ReorderLevel = value; - this.OnReorderLevelChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _ReorderLevel; - partial void OnReorderLevelChanging(global::System.Nullable value); - partial void OnReorderLevelChanged(); - /// - /// There are no comments for Property Discontinued in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public bool Discontinued - { - get - { - return this._Discontinued; - } - set - { - this.OnDiscontinuedChanging(value); - this._Discontinued = value; - this.OnDiscontinuedChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private bool _Discontinued; - partial void OnDiscontinuedChanging(bool value); - partial void OnDiscontinuedChanged(); - /// - /// There are no comments for Order_Details in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Collections.ObjectModel.Collection Order_Details - { - get - { - return this._Order_Details; - } - set - { - if ((value != null)) - { - this._Order_Details = value; - } - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Collections.ObjectModel.Collection _Order_Details = new global::System.Collections.ObjectModel.Collection(); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/reference.datasvcmap b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/reference.datasvcmap deleted file mode 100644 index 4d94eef25dc83..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/reference.datasvcmap +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/service.edmx b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/service.edmx deleted file mode 100644 index 0c6dbce600df9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/linqproviderclientcs/service references/northwind/service.edmx +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/upgradelog.xml b/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/upgradelog.xml deleted file mode 100644 index 04b68921c8014..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria linq provider/upgradelog.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind client/codegenclasses.bat b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind client/codegenclasses.bat deleted file mode 100644 index 7b55fae890b9b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind client/codegenclasses.bat +++ /dev/null @@ -1,4 +0,0 @@ -"C:\Program Files (x86)\ADO.NET Data Services V1.5 CTP2\bin\DataSvcUtil.exe" /language:CSharp /out:northwind.cs /dataservicecollection /version:2.0 /uri:http://localhost:12345/northwind.svc -rem "%windir%\Microsoft.NET\Framework\v4.0.20604\DataSvcUtil.exe" /language:CSharp /out:northwind.cs /dataservicecollection /version:2.0 /uri:http://localhost:12345/northwind.svc -rem "%windir%\Microsoft.NET\Framework\v4.0.20604\DataSvcUtil.exe" /? -pause diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria.sln b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria.sln deleted file mode 100644 index 115b1d85b3378..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria.sln +++ /dev/null @@ -1,99 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3D659CEE-C162-4A7C-ABC6-EED556E9B741}" - ProjectSection(SolutionItems) = preProject - Astoria1.vsmdi = Astoria1.vsmdi - LocalTestRun.testrunconfig = LocalTestRun.testrunconfig - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthwindDataServiceCS", "CS\NorthwindDataServiceCS.csproj", "{98D3AD65-3885-4104-B856-B481EDCA1E0F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthwindClientCS", "..\Astoria Northwind Client\CS\NorthwindClientCS.csproj", "{E12CD45C-7CA8-4130-9309-B1A465FC16CF}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NorthwindDataServiceVB", "VB\NorthwindDataServiceVB.vbproj", "{F4B76D1A-0917-4237-B267-878A10DB1325}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NorthwindClientVB", "..\Astoria Northwind Client\VB\NorthwindClientVB.vbproj", "{9FB79FAA-1BB3-426F-82F0-074D45E67B21}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AstoriaSnippetsVB", "AstoriaSnippetsVB\AstoriaSnippetsVB.csproj", "{16FFFE3E-F660-415A-A7C0-BAA65580B2DD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AstoriaSnippetsCS", "AstoriaSnippetsCS\AstoriaSnippetsCS.csproj", "{738FF72F-820D-41D8-A3CB-8B178E676009}" -EndProject -Global - GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = Astoria1.vsmdi - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Debug|x86.ActiveCfg = Debug|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Release|Any CPU.Build.0 = Release|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {98D3AD65-3885-4104-B856-B481EDCA1E0F}.Release|x86.ActiveCfg = Release|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Debug|x86.ActiveCfg = Debug|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Release|Any CPU.Build.0 = Release|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {E12CD45C-7CA8-4130-9309-B1A465FC16CF}.Release|x86.ActiveCfg = Release|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Debug|x86.ActiveCfg = Debug|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Release|Any CPU.Build.0 = Release|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F4B76D1A-0917-4237-B267-878A10DB1325}.Release|x86.ActiveCfg = Release|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Debug|x86.ActiveCfg = Debug|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Release|Any CPU.Build.0 = Release|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {9FB79FAA-1BB3-426F-82F0-074D45E67B21}.Release|x86.ActiveCfg = Release|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Debug|x86.ActiveCfg = Debug|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Release|Any CPU.Build.0 = Release|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {16FFFE3E-F660-415A-A7C0-BAA65580B2DD}.Release|x86.ActiveCfg = Release|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Debug|Any CPU.Build.0 = Debug|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Debug|x86.ActiveCfg = Debug|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Release|Any CPU.ActiveCfg = Release|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Release|Any CPU.Build.0 = Release|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {738FF72F-820D-41D8-A3CB-8B178E676009}.Release|x86.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria.vsmdi b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria.vsmdi deleted file mode 100644 index 2ba718a094dd0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria.vsmdi +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria1.vsmdi b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria1.vsmdi deleted file mode 100644 index 9199c24f49b1c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/astoria1.vsmdi +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/localtestrun.testrunconfig b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/localtestrun.testrunconfig deleted file mode 100644 index e18b69b3b8031..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/localtestrun.testrunconfig +++ /dev/null @@ -1,5 +0,0 @@ - - - This is a default test run configuration for a local test run. - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog.xml b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog.xml deleted file mode 100644 index baf4a7596bdd8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog2.xml b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog2.xml deleted file mode 100644 index 387c0db6c95f1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog2.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog3.xml b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog3.xml deleted file mode 100644 index f9eb13642e8d6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog3.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog4.xml b/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog4.xml deleted file mode 100644 index 9b557df972f91..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria northwind service/upgradelog4.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria photo streaming service/photoservice.sln b/samples/snippets/cpp/VS_Snippets_Misc/astoria photo streaming service/photoservice.sln deleted file mode 100644 index 33867bb2283d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria photo streaming service/photoservice.sln +++ /dev/null @@ -1,65 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoService", "CS\PhotoService.csproj", "{318E25FC-1DE8-4E26-A6F9-EA61237A562B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhotoStreamingClient", "..\Astoria Photo Streaming Client\CS\PhotoStreamingClient.csproj", "{455EE0A5-63D5-4380-8B85-8F5BF505BEF0}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PhotoServiceVB", "VB\PhotoServiceVB.vbproj", "{0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PhotoStreamingClientVB", "..\Astoria Photo Streaming Client\VB\PhotoStreamingClientVB.vbproj", "{C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Debug|x86.ActiveCfg = Debug|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Release|Any CPU.Build.0 = Release|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {318E25FC-1DE8-4E26-A6F9-EA61237A562B}.Release|x86.ActiveCfg = Release|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Debug|x86.ActiveCfg = Debug|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Release|Any CPU.Build.0 = Release|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0}.Release|x86.ActiveCfg = Release|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Debug|x86.ActiveCfg = Debug|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Release|Any CPU.Build.0 = Release|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {0BA53D10-0B84-4735-AF58-9D0C3DFADBFF}.Release|x86.ActiveCfg = Release|Any CPU - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Debug|Any CPU.ActiveCfg = Debug|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Debug|x86.ActiveCfg = Debug|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Debug|x86.Build.0 = Debug|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Release|Any CPU.ActiveCfg = Release|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Release|Mixed Platforms.Build.0 = Release|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Release|x86.ActiveCfg = Release|x86 - {C32BFAEA-1BAB-4038-904D-E8E79E4D33AE}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria quickstart service/astoria quickstart.sln b/samples/snippets/cpp/VS_Snippets_Misc/astoria quickstart service/astoria quickstart.sln deleted file mode 100644 index f709753009ae2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria quickstart service/astoria quickstart.sln +++ /dev/null @@ -1,66 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthwindService", "CS\NorthwindService.csproj", "{66054490-20CD-4CDB-97F2-DBD59D679827}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthwindClient", "..\Astoria Quickstart Client\CS\NorthwindClient.csproj", "{77E6890D-9FD2-48AF-8564-90DBAAD03E0B}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NorthwindServiceVB", "VB\NorthwindServiceVB.vbproj", "{ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}" -EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NorthwindClientVB", "..\Astoria Quickstart Client\VB\NorthwindClientVB.vbproj", "{A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {66054490-20CD-4CDB-97F2-DBD59D679827}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Debug|x86.ActiveCfg = Debug|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Release|Any CPU.Build.0 = Release|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {66054490-20CD-4CDB-97F2-DBD59D679827}.Release|x86.ActiveCfg = Release|Any CPU - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Debug|Any CPU.ActiveCfg = Debug|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Debug|x86.ActiveCfg = Debug|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Debug|x86.Build.0 = Debug|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Release|Any CPU.ActiveCfg = Release|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Release|Mixed Platforms.Build.0 = Release|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Release|x86.ActiveCfg = Release|x86 - {77E6890D-9FD2-48AF-8564-90DBAAD03E0B}.Release|x86.Build.0 = Release|x86 - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Debug|x86.ActiveCfg = Debug|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Release|Any CPU.Build.0 = Release|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {ED2542F6-3E1A-4AFD-BF35-59B8209B3ADC}.Release|x86.ActiveCfg = Release|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Debug|x86.ActiveCfg = Debug|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Release|Any CPU.Build.0 = Release|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A5EF00B6-C5BF-4AE7-BD77-1625B30178A3}.Release|x86.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/customdataserviceclient.csproj b/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/customdataserviceclient.csproj deleted file mode 100644 index 3757b69785cb6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/customdataserviceclient.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - - Exe - net48 - CustomDataServiceClient - CustomDataServiceClient - - false - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - True - True - Reference.datasvcmap - - - - - - - - - - datasvcmap - - - - - - - - - - DataServiceClientGenerator - Reference.cs - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/program.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/program.cs deleted file mode 100644 index 425d6631cd9d7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/program.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using CustomDataServiceClient.OrderItems; - -namespace CustomDataServiceClient -{ - class Program - { - static void Main(string[] args) - { - - //OrderItemData context = new OrderItemData(new Uri("http://localhost:12345/OrderItems.svc/")); - OrderItemData context = new OrderItemData(new Uri("http://localhost:54321/OrderItems.svc/")); - - Order selectedOrder = GetOrderWithItems(context); - - PrintItems(selectedOrder); - - Item selectedItem = selectedOrder.Items.FirstOrDefault(); - selectedItem.Quantity += 1; - context.UpdateObject(selectedItem); - - PrintItems(selectedOrder); - - Item newItem = new Item() { Product = "Grandma's Boysenberry Spread", Quantity = 30 }; - //context.AddToItems(newItem); - selectedOrder.Items.Add(newItem); - context.AddRelatedObject(selectedOrder, "Items", newItem); - - selectedOrder = GetOrderWithItems(context); - - PrintItems(selectedOrder); - - context.DeleteObject(newItem); - - selectedOrder = GetOrderWithItems(context); - - PrintItems(selectedOrder); - } - static Order GetOrderWithItems(OrderItemData context) - { - var selectedOrder = (from orders in context.Orders.Expand("Items") - select orders).FirstOrDefault(); - return selectedOrder; - } - static void PrintItems(Order selectedOrder) - { - Console.WriteLine("Order: {0}", selectedOrder.Customer); - foreach (Item i in selectedOrder.Items) - { - Console.WriteLine("Product: {0} ({1})", i.Product, i.Quantity); - } - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/reference.cs b/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/reference.cs deleted file mode 100644 index b1b3248305db1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/reference.cs +++ /dev/null @@ -1,260 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.21030.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Original file name: -// Generation date: 11/20/2009 1:47:48 PM -namespace CustomDataServiceClient.OrderItems -{ - - /// - /// There are no comments for OrderItemData in the schema. - /// - public partial class OrderItemData : global::System.Data.Services.Client.DataServiceContext - { - /// - /// Initialize a new OrderItemData object. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public OrderItemData(global::System.Uri serviceRoot) : - base(serviceRoot) - { - this.ResolveName = new global::System.Func(this.ResolveNameFromType); - this.ResolveType = new global::System.Func(this.ResolveTypeFromName); - this.OnContextCreated(); - } - partial void OnContextCreated(); - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected global::System.Type ResolveTypeFromName(string typeName) - { - if (typeName.StartsWith("CustomDataServiceClient", global::System.StringComparison.Ordinal)) - { - return this.GetType().Assembly.GetType(string.Concat("CustomDataServiceClient.OrderItems", typeName.Substring(23)), false); - } - return null; - } - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected string ResolveNameFromType(global::System.Type clientType) - { - if (clientType.Namespace.Equals("CustomDataServiceClient.OrderItems", global::System.StringComparison.Ordinal)) - { - return string.Concat("CustomDataServiceClient.", clientType.Name); - } - return null; - } - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Orders - { - get - { - if ((this._Orders == null)) - { - this._Orders = base.CreateQuery("Orders"); - } - return this._Orders; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Orders; - /// - /// There are no comments for Items in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Items - { - get - { - if ((this._Items == null)) - { - this._Items = base.CreateQuery("Items"); - } - return this._Items; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Items; - /// - /// There are no comments for Orders in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToOrders(Order order) - { - base.AddObject("Orders", order); - } - /// - /// There are no comments for Items in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToItems(Item item) - { - base.AddObject("Items", item); - } - } - /// - /// There are no comments for CustomDataServiceClient.Order in the schema. - /// - /// - /// OrderId - /// - [global::System.Data.Services.Common.DataServiceKeyAttribute("OrderId")] - public partial class Order - { - /// - /// Create a new Order object. - /// - /// Initial value of OrderId. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Order CreateOrder(int orderId) - { - Order order = new Order(); - order.OrderId = orderId; - return order; - } - /// - /// There are no comments for Property OrderId in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int OrderId - { - get - { - return this._OrderId; - } - set - { - this.OnOrderIdChanging(value); - this._OrderId = value; - this.OnOrderIdChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _OrderId; - partial void OnOrderIdChanging(int value); - partial void OnOrderIdChanged(); - /// - /// There are no comments for Property Customer in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Customer - { - get - { - return this._Customer; - } - set - { - this.OnCustomerChanging(value); - this._Customer = value; - this.OnCustomerChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Customer; - partial void OnCustomerChanging(string value); - partial void OnCustomerChanged(); - /// - /// There are no comments for Items in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Collections.ObjectModel.Collection Items - { - get - { - return this._Items; - } - set - { - if ((value != null)) - { - this._Items = value; - } - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Collections.ObjectModel.Collection _Items = new global::System.Collections.ObjectModel.Collection(); - } - /// - /// There are no comments for CustomDataServiceClient.Item in the schema. - /// - /// - /// Product - /// - [global::System.Data.Services.Common.DataServiceKeyAttribute("Product")] - public partial class Item - { - /// - /// Create a new Item object. - /// - /// Initial value of Product. - /// Initial value of Quantity. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Item CreateItem(string product, int quantity) - { - Item item = new Item(); - item.Product = product; - item.Quantity = quantity; - return item; - } - /// - /// There are no comments for Property Product in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Product - { - get - { - return this._Product; - } - set - { - this.OnProductChanging(value); - this._Product = value; - this.OnProductChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Product; - partial void OnProductChanging(string value); - partial void OnProductChanged(); - /// - /// There are no comments for Property Quantity in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int Quantity - { - get - { - return this._Quantity; - } - set - { - this.OnQuantityChanging(value); - this._Quantity = value; - this.OnQuantityChanged(); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _Quantity; - partial void OnQuantityChanging(int value); - partial void OnQuantityChanged(); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/reference.datasvcmap b/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/reference.datasvcmap deleted file mode 100644 index 1608d2ebfd111..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/reference.datasvcmap +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/service.edmx b/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/service.edmx deleted file mode 100644 index 0679fc10c9f07..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/astoria reflection provider/customdataserviceclient/service references/orderitems/service.edmx +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/class1.cpp deleted file mode 100644 index 97ae69c542e84..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/class1.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" -#include -#include - - - -using namespace JS_Array; - - -// 05 at the top because we need the includes and usings -// -#include -#include -using namespace Platform; -using namespace std; -using namespace Platform::Collections; - -void ArrayConversions(const Array^ arr) -{ - // Construct an Array from another Array. - Platform::Array^ newArr = ref new Platform::Array(arr); - - // Construct a Vector from an Array - auto v = ref new Platform::Collections::Vector(arr); - - // Construct a std::vector. Two options. - vector v1(begin(arr), end(arr)); - vector v2(arr->begin(), arr->end()); - - // Initialize a vector one element at a time. - // using a range for loop. Not as efficient as using begin/end. - vector v3; - for(int i : arr) - { - v3.push_back(i); - } -} -// - -Class1::Class1() -{ -} - -void Class1::ConversionDemo(const Array^ arr) -{ - ArrayConversions(arr); -} - -// -double Class1::PassArrayForReading(const Array^ arr) -{ - double sum = 0; - for(unsigned int i = 0 ; i < arr->Length; i++) - { - sum += arr[i]; - } - return sum; -} -// - -// - -// Return array as out parameter... -void Class1::CalleeAllocatedDemo(Array^* arr) -{ - auto temp = ref new Array(10); - for(unsigned int i = 0; i < temp->Length; i++) - { - temp[i] = i; - } - - *arr = temp; -} - -// ...or return array as return value: -Array^ Class1::CalleeAllocatedDemo2() -{ - auto temp = ref new Array(10); - for(unsigned int i = 0; i < temp->Length; i++) - { - temp[i] = i; - } - - return temp; -} -// - -//not used -Array^ Class1::CalleeAllocatedDemo3() -{ - std::vector vec; - for(int i = 0; i < 10; i++) - { - vec.push_back(i); - } - - return ref new Array(10/*vec*/); //compiler error -} - - -// -void Class1::CallerAllocatedDemo(Platform::WriteOnlyArray^ arr) -{ - // You can write to the elements directly. - for(unsigned int i = 0; i < arr->Length; i++) - { - arr[i] = i; - } -} -// - - - -// -void Class1::InvokeIterators(Platform::WriteOnlyArray^ arr) -{ - int k = 0; - // You can write to the elements directly. - for (unsigned int i = 9; i > 0; i--) - { - arr->set(k++, i); - } - - std::sort(arr->begin(), arr->end()); -} -// - - -using namespace Windows::Foundation::Collections; -using namespace Platform; -using namespace Platform::Collections; - -Person::Person(String^ name): m_name(name) { } -void Person::AddPhoneNumber(String^ type, String^ number) -{ - m_numbers[type] = number; -} -IMapView^ Person::PhoneNumbers::get() -{ - return ref new MapView(m_numbers); -} - - -ref class DateTracker sealed -{ -public: - property Windows::Foundation::Uri^ uri; - // ... -}; - - -void DoSomething() -{ - Windows::Foundation::Uri msdn("http://www.msdn.microsoft.com"); - Windows::Foundation::Uri^ devCenter = msdn.CombineUri("/windows/"); - // ... -} // both variables cleaned up here. - -#include -#include -#include -using namespace Platform::Collections; -using namespace Windows::Foundation::Collections; -using namespace std; -IVector^ GetInts() -{ - vector vec; - for(int i = 0; i < 10; i++) - { - vec.push_back(i); - } - //Implicit conversion to IVector - return ref new Vector(std::move(vec)); -} - -// -Array^ GetNums() -{ - int nums[] = {0,1,2,3,4}; - //Use nums internally.... - - // Convert to Platform::Array and return to caller. - return ref new Array(nums, 5); -} -// - - - - -//Array^ GetNums2() -//{ -// vector vec; -// for(int i = 0; i < 10; i++) -// { -// vec.push_back(i); -// } -// //Implicit conversion to IVector -// return ref new Array(begin(vec), end(vec)); -//} -using namespace Windows::Storage; -using namespace Windows::Storage::Streams; -using namespace concurrency; - -void Class1::TestDataReader() -{ - //String^ Filename = "test.data"; - // Windows::Storage::StorageFile^ sampleFile; - // create_task(KnownFolders::DocumentsLibrary->GetFileAsync(Filename)).then([this](task getFileTask) - //{ - // try - // { - // sampleFile = getFileTask.get(); - // } - // catch (Platform::Exception^) - // { - // // sample file doesn't exist so scenario one must be run first. - // } - //}); - - // IInputStream^ str = - // DataReader^ dataReader = ref new DataReader(sampleFile); - - // uint8 data[1024]; - // dataReader->ReadBytes( ArrayReference(data, 1024) ); - -} - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/class1.h deleted file mode 100644 index 8cb4281538c8b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/class1.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once -#include -#include -namespace WFC = Windows::Foundation::Collections; - -namespace JS_Array -{ - public ref class Class1 sealed - { - public: - Class1(); - double PassArrayForReading(const Platform::Array^ arr); - void CalleeAllocatedDemo(Platform::Array^* arr); - Platform::Array^ CalleeAllocatedDemo2(); - Platform::Array^ CalleeAllocatedDemo3(); - property Platform::Array^ Arr; - void CallerAllocatedDemo(Platform::WriteOnlyArray^ arr); - void ConversionDemo(const Platform::Array^ arr); - void InvokeIterators(Platform::WriteOnlyArray^ arr); - void TestDataReader(); - }; - - - ref class Person sealed - { - Person(Platform::String^ name); - void AddPhoneNumber(Platform::String^ type, Platform::String^ number); - property WFC::IMapView^ PhoneNumbers - { - WFC::IMapView^ get(); - } - private: - Platform::String^ m_name; - std::map m_numbers; - }; - - // - public ref class TestReferenceArray sealed - { - public: - - // Assume dr is already initialized with a stream - void GetArray(Windows::Storage::Streams::DataReader^ dr, int numBytesRemaining) - { - // Copy into Platform::Array - auto bytes = ref new Platform::Array(numBytesRemaining); - - // Fill an Array. - dr->ReadBytes(bytes); - - // Fill a C-style array - uint8 data[1024]; - dr->ReadBytes( Platform::ArrayReference(data, 1024) ); - } - }; - // - -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/js-array.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/js-array.vcxproj deleted file mode 100644 index 414bf6257ca2b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/js-array.vcxproj +++ /dev/null @@ -1,224 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {f4998ba3-0191-4972-84b5-05212e814cb8} - Win32Proj - JS-Array - JS_Array - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/js-array.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/js-array.vcxproj.filters deleted file mode 100644 index 3bb08767a7461..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/js-array.vcxproj.filters +++ /dev/null @@ -1,20 +0,0 @@ - - - - - c1e1a3f5-dc40-4a8c-b870-b2647b894c4d - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_arrays/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/class1.cpp deleted file mode 100644 index 2d470fb2804de..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/class1.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace cx_attributes; -using namespace Platform; - -Class1::Class1() -{ -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/class1.h deleted file mode 100644 index 8e1641ae536ad..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/class1.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -namespace cx_attributes -{ - - // - [Windows::Foundation::Metadata::WebHostHidden] - public ref class MyClass : Windows::UI::Xaml::DependencyObject {}; - // - - // - [Windows::Foundation::Metadata::WebHostHiddenAttribute] - public ref class MyCustomAttribute sealed : Platform::Metadata::Attribute { - public: - int Num; - Platform::String^ Msg; - }; - - [MyCustomAttribute(Num=5, Msg="Hello")] - public ref class Class1 sealed - { - public: - Class1(); - }; - // - -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/cx_attributes.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/cx_attributes.vcxproj deleted file mode 100644 index 4ab8db67efedb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/cx_attributes.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {223c5d97-3200-4a3e-85a2-480415f24aba} - Win32Proj - cx_attributes - cx_attributes - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/cx_attributes.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/cx_attributes.vcxproj.filters deleted file mode 100644 index 879f5ff815afa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/cx_attributes.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 5c145889-00bb-46c0-b5f2-6a3c79eb517c - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_attributes/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/class1.cpp deleted file mode 100644 index 25813107b0690..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/class1.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace cx_boxing; -using namespace Platform; - -Class1::Class1() -{ - // - Object^ obj = 5; //scalar value is implicitly boxed - int i = safe_cast(obj); //unboxed with explicit cast. - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/class1.h deleted file mode 100644 index 993922d430610..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/class1.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -namespace cx_boxing -{ - public ref class Class1 sealed - { - public: - Class1(); - }; - // - // A WinRT Component DLL - namespace BoxingDemo - { - public ref class Class1 sealed - { - public: - Class1(){} - Platform::IBox^ Multiply(Platform::IBox^ a, Platform::IBox^ b) - { - if(a == nullptr || b == nullptr) - return nullptr; - else - return ref new Platform::Box(a->Value * b->Value); - } - }; - // - } - - -} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/cx_boxing.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/cx_boxing.vcxproj deleted file mode 100644 index 64ec30e0f497f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/cx_boxing.vcxproj +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - - {35cee771-3e93-461f-a17a-eed5de3fdabd} - Win32Proj - cx_boxing - cx_boxing - en-US - 11.0 - true - - - - - - DynamicLibrary - true - v110 - - - DynamicLibrary - true - v110 - - - DynamicLibrary - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - false - - - - false - - - - false - - - - false - - - - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/cx_boxing.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/cx_boxing.vcxproj.filters deleted file mode 100644 index 6d2cc62021c4e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/cx_boxing.vcxproj.filters +++ /dev/null @@ -1,9 +0,0 @@ - - - - - 7be5100b-ece5-4b24-84c8-f1908a2a48cf - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_boxing/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/class1.cpp deleted file mode 100644 index 8543a6fa71001..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/class1.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace ClassesStructs; -using namespace Platform; -using namespace DummyNS; - -Class1::Class1() -{ -} - -// -#include -using namespace Windows::Foundation::Collections; -using namespace Platform; -using namespace Platform::Collections; - -Person::Person(String^ name): m_name(name) { } -void Person::AddPhoneNumber(String^ type, String^ number) -{ - m_numbers[type] = number; -} -IMapView< String^, String^>^ Person::PhoneNumbers::get() -{ - // Simple implementation. - return ref new MapView< String^, String^>(m_numbers); -} -// - -void UsePerson() -{ - // - using namespace Platform; - - Person^ p = ref new Person("Clark Kent"); - p->AddPhoneNumber("Home", "425-555-4567"); - p->AddPhoneNumber("Work", "206-555-9999"); - String^ workphone = p->PhoneNumbers->Lookup("Work"); - // -} - -// -void DoSomething() -{ - Windows::Foundation::Uri msdn("http://www.msdn.microsoft.com"); - Windows::Foundation::Uri^ devCenter = msdn.CombineUri("/windows /"); - // ... -} // both variables cleaned up here. -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/class1.h deleted file mode 100644 index 7b072335f65af..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/class1.h +++ /dev/null @@ -1,115 +0,0 @@ -#pragma once -#include - -namespace ClassesStructs -{ - public ref class MyRefClass sealed{}; - - public ref class Class1 sealed - { - public: - Class1(); - void Dummy() - { - // - MyRefClass^ myClass = ref new MyRefClass(); - // - } - - void Dummy2() - { - // - MyRefClass^ myClass = ref new MyRefClass(); - MyRefClass^ myClass2 = myClass; - // - } - - - }; - // - public enum class Continent - { - Africa, - Asia, - Australia, - Europe, - NorthAmerica, - SouthAmerica, - Antarctica - }; - - value struct GeoCoordinates - { - double Latitude; //or float64 if you prefer - double Longitude; - }; - - value struct City - { - Platform::String^ Name; - int Population; - double AverageTemperature; - GeoCoordinates Coordinates; - Continent continent; - }; - // - /* - // - ref class C{}; - public ref class D : private C //Error C3628 - {}; - // - */ - -} - -namespace DummyNS -{ - // - // #include - namespace WFC = Windows::Foundation::Collections; - namespace WFM = Windows::Foundation::Metadata; - - [WFM::WebHostHidden] - ref class Person sealed - { - public: - Person(Platform::String^ name); - void AddPhoneNumber(Platform::String^ type, Platform::String^ number); - property WFC::IMapView^ PhoneNumbers - { - WFC::IMapView^ get(); - } - private: - Platform::String^ m_name; - std::map m_numbers; - }; - // -} - -// -namespace InheritanceTest2 -{ - namespace WFM = Windows::Foundation::Metadata; - - // Base class. No public constructor. - [WFM::WebHostHidden] - public ref class Base : Windows::UI::Xaml::DependencyObject - { - internal: - Base(){} - protected: - virtual void DoSomething (){} - property Windows::UI::Xaml::DependencyProperty^ WidthProperty; - }; - - // Class intended for use by client code across ABI. - // Declared as sealed with public constructor. - public ref class MyPublicClass sealed : Base - { - public: - MyPublicClass(){} - //... - }; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/classesstructs.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/classesstructs.vcxproj deleted file mode 100644 index e542825ce9344..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/classesstructs.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {5291ff8e-fecd-42b2-bdc0-275cd7c9a671} - Win32Proj - ClassesStructs - ClassesStructs - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/classesstructs.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/classesstructs.vcxproj.filters deleted file mode 100644 index f220739e2ddd0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/classesstructs.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 14af54cb-4b1c-4b38-94b8-b253ba5a8369 - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_classes/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/class1.cpp deleted file mode 100644 index 83cd1069abcf9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/class1.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace CX_Collections; //local project namespace -using namespace std; -#include -#include //for std::move - -// -#include -#include -using namespace Platform; -using namespace Platform::Collections; -using namespace Windows::Foundation::Collections; - - -void Class1::Test() -{ - Vector^ vec = ref new Vector(); - vec->Append(1); - vec->Append(2); - vec->Append(3); - vec->Append(4); - vec->Append(5); - - - auto it = - std::find(begin(vec), end(vec), 3); - - int j = *it; //j = 3 - int k = *(it + 1); //or it[1] - - // Find a specified value. - unsigned int n; - bool found = vec->IndexOf(4, &n); //n = 3 - - // Get the value at the specified index. - n = vec->GetAt(4); // n = 3 - - // Insert an item. - // vec = 0, 1, 2, 3, 4, 5 - vec->InsertAt(0, 0); - - // Modify an item. - // vec = 0, 1, 2, 12, 4, 5, - vec->SetAt(3, 12); - - // Remove an item. - //vec = 1, 2, 12, 4, 5 - vec->RemoveAt(0); - - // vec = 1, 2, 12, 4 - vec->RemoveAtEnd(); - - // Get a read-only view into the vector. - IVectorView^ view = vec->GetView(); -} -// - -// -//#include -//#include -//#include //for std::move -//using namespace Platform::Collections; -//using namespace Windows::Foundation::Collections; -//using namespace std; -IVector^ Class1::GetInts() -{ - vector vec; - for(int i = 0; i < 10; i++) - { - vec.push_back(i); - } - // Implicit conversion to IVector - return ref new Vector(std::move(vec)); -} -// - -// -//#include -//using namespace Platform::Collections; -//using namespace Windows::Foundation::Collections; -IMapView^ Class1::MapTest() -{ - Map^ m = ref new Map(); - m->Insert("Mike", 0); - m->Insert("Dave", 1); - m->Insert("Doug", 2); - m->Insert("Nikki", 3); - m->Insert("Kayley", 4); - m->Insert("Alex", 5); - m->Insert("Spencer", 6); - - // PC::Map does not support [] operator - int i = m->Lookup("Doug"); - - return m->GetView(); - -} -// - -Class1::Class1() -{ -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/class1.h deleted file mode 100644 index 014b0b01d04bf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/class1.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace CX_Collections -{ - public ref class Class1 sealed - { - public: - Class1(); - void Test(); - Windows::Foundation::Collections::IVector^ GetInts(); - Windows::Foundation::Collections::IMapView^ Class1::MapTest(); - }; - -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/collections.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/collections.vcxproj deleted file mode 100644 index a0bef5ddaba36..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/collections.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {6238b1d3-5b72-458a-a2bd-32a227abec6d} - Win32Proj - Collections - Collections - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/collections.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/collections.vcxproj.filters deleted file mode 100644 index 98035a5d6a215..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/collections.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 0dba3cd1-1840-4148-a779-2afa76a34a6a - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_collections/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/class1.cpp deleted file mode 100644 index 399e7d1c13a9e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/class1.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace PublicEnumTest; -using namespace Platform; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/class1.h deleted file mode 100644 index a26d0b79f18bd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/class1.h +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -namespace PublicEnumTest -{ - - // - // Define the enum - public enum class TrafficLight : int { Red, Yellow, Green }; - //… - // - - public ref class Class1 sealed - { - public: - Class1() - { - // - // Consume the enum: - TrafficLight myLight = TrafficLight::Red; - if (myLight == TrafficLight::Green) - { - //... - } - // - - } - - }; - - // - // Underlying type is int32 - public enum class Enum1 - { - Zero, - One, - Two, - Three - }; - - public enum class Enum2 - { - None = 0, - First, // First == 1 - Some = 5, - Many = 10 - }; - - // Underlying type is unsigned int - // for Flags. Must be explicitly specified - using namespace Platform::Metadata; - [Flags] - public enum class BitField : unsigned int - { - Mask0 = 0x0, - Mask2 = 0x2, - Mask4 = 0x4, - Mask8 = 0x8 - }; - - Enum1 e1 = Enum1::One; - int v1 = static_cast(e1); - int v2 = static_cast(Enum2::First); - // - - - ref class PrivateClass - { - void DoSomething() - { - // - if (e1 == Enum1::One) { /* ... */ } - //if (e1 == Enum2::First) { /* ... */ } // yields compile error C3063 - - static_assert(sizeof(Enum1) == 4, "sizeof(Enum1) should be 4"); - - BitField x = BitField::Mask0 | BitField::Mask2 | BitField::Mask4; - if ((x & BitField::Mask2) == BitField::Mask2) { /* */ } - // - } - }; -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/cpp.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/cpp.vcxproj deleted file mode 100644 index 9191f3fc81dd0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/cpp.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {740d006a-1bd8-485f-80fe-11a59b1beae4} - Win32Proj - cpp - cpp - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/cpp.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/cpp.vcxproj.filters deleted file mode 100644 index 7549f230caede..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/cpp.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 5b34e4ba-39bc-4e6e-ab57-c14a12830d39 - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_enums/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/class1.cpp deleted file mode 100644 index 3ee3e0e941b6a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/class1.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace cx_Events; -using namespace Platform; - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/class1.h deleted file mode 100644 index d570af3cc9c5d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/class1.h +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - - -namespace cx_Events -{ - // - namespace EventTest - { - ref class Class1; - public delegate void SomethingHappenedEventHandler(Class1^ sender, Platform::String^ s); - - public ref class Class1 sealed - { - public: - Class1(){} - event SomethingHappenedEventHandler^ SomethingHappened; - void DoSomething() - { - //Do something.... - - // ...then fire the event: - SomethingHappened(this, L"Something happened."); - } - }; - } - // - - - - // - namespace EventTest2 - { - ref class Class1; - public delegate void SomethingHappenedEventHandler(Class1^ sender, Platform::String^ msg); - - public ref class Class1 sealed - { - public: - Class1(){} - event SomethingHappenedEventHandler^ SomethingHappened; - void DoSomething(){/*...*/} - void MethodThatFires() - { - // Fire before doing something... - BeforeSomethingHappens(this, "Something's going to happen."); - - DoSomething(); - - // ...then fire after doing something... - SomethingHappened(this, L"Something happened."); - } - - event SomethingHappenedEventHandler^ _InternalHandler; - - event SomethingHappenedEventHandler^ BeforeSomethingHappens - { - Windows::Foundation::EventRegistrationToken add(SomethingHappenedEventHandler^ handler) - { - // Add custom logic here: - //.... - return _InternalHandler += handler; - } - - void remove(Windows::Foundation::EventRegistrationToken token) - { - // Add custom logic here: - //.... - _InternalHandler -= token; - } - - void raise(Class1^ sender, Platform::String^ str) - { - - // Add custom logic here: - //.... - return _InternalHandler(sender, str); - } - } - }; - } - // - -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/cx_events.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/cx_events.vcxproj deleted file mode 100644 index d626258ca729d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/cx_events.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {0cecd6e4-8303-48e8-b568-81647ff86f80} - Win32Proj - cx_Events - cx_Events - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/cx_events.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/cx_events.vcxproj.filters deleted file mode 100644 index 2f39cf842a6c6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/cx_events.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 6181e8f2-9cc9-4f8a-86ca-db6d1769e793 - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/cx_events/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs.sln b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs.sln deleted file mode 100644 index edfe5483e479c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs.sln +++ /dev/null @@ -1,52 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 11 Express for Windows 8 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EventSupportinVS", "EventSupportinVS\EventSupportinVS.vcxproj", "{F162C48F-D05D-4E98-9D1A-3DB0098F8015}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cx_Events", "cx_Events\cx_Events.vcxproj", "{0CECD6E4-8303-48E8-B568-81647FF86F80}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|ARM = Release|ARM - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|ARM.ActiveCfg = Debug|ARM - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|ARM.Build.0 = Debug|ARM - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|ARM.Deploy.0 = Debug|ARM - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|Win32.ActiveCfg = Debug|Win32 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|Win32.Build.0 = Debug|Win32 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|Win32.Deploy.0 = Debug|Win32 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|x64.ActiveCfg = Debug|x64 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|x64.Build.0 = Debug|x64 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Debug|x64.Deploy.0 = Debug|x64 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|ARM.ActiveCfg = Release|ARM - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|ARM.Build.0 = Release|ARM - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|ARM.Deploy.0 = Release|ARM - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|Win32.ActiveCfg = Release|Win32 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|Win32.Build.0 = Release|Win32 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|Win32.Deploy.0 = Release|Win32 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|x64.ActiveCfg = Release|x64 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|x64.Build.0 = Release|x64 - {F162C48F-D05D-4E98-9D1A-3DB0098F8015}.Release|x64.Deploy.0 = Release|x64 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Debug|ARM.ActiveCfg = Debug|ARM - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Debug|ARM.Build.0 = Debug|ARM - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Debug|Win32.ActiveCfg = Debug|Win32 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Debug|Win32.Build.0 = Debug|Win32 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Debug|x64.ActiveCfg = Debug|x64 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Debug|x64.Build.0 = Debug|x64 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Release|ARM.ActiveCfg = Release|ARM - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Release|ARM.Build.0 = Release|ARM - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Release|Win32.ActiveCfg = Release|Win32 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Release|Win32.Build.0 = Release|Win32 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Release|x64.ActiveCfg = Release|x64 - {0CECD6E4-8303-48E8-B568-81647FF86F80}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml deleted file mode 100644 index 1570595419495..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml.cpp deleted file mode 100644 index c10cb6620d385..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -// App.xaml.cpp -// Implementation of the App class. -// - -#include "pch.h" -#include "MainPage.xaml.h" - -using namespace EventSupportinVS; - -using namespace Platform; -using namespace Windows::ApplicationModel; -using namespace Windows::ApplicationModel::Activation; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Interop; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 - -/// -/// Initializes the singleton application object. This is the first line of authored code -/// executed, and as such is the logical equivalent of main() or WinMain(). -/// -App::App() -{ - InitializeComponent(); - Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); -} - -/// -/// Invoked when the application is launched normally by the end user. Other entry points -/// will be used when the application is launched to open a specific file, to display -/// search results, and so forth. -/// -/// Details about the launch request and process. -void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ args) -{ - // Do not repeat app initialization when already running, just ensure that - // the window is active - if (args->PreviousExecutionState == ApplicationExecutionState::Running) - { - Window::Current->Activate(); - return; - } - - if (args->PreviousExecutionState == ApplicationExecutionState::Terminated) - { - //TODO: Load state from previously suspended application - } - - // Create a Frame to act navigation context and navigate to the first page - auto rootFrame = ref new Frame(); - if (!rootFrame->Navigate(TypeName(MainPage::typeid))) - { - throw ref new FailureException("Failed to create initial page"); - } - - // Place the frame in the current Window and ensure that it is active - Window::Current->Content = rootFrame; - Window::Current->Activate(); -} - -/// -/// Invoked when application execution is being suspended. Application state is saved -/// without knowing whether the application will be terminated or resumed with the contents -/// of memory still intact. -/// -/// The source of the suspend request. -/// Details about the suspend request. -void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e) -{ - (void) sender; // Unused parameter - (void) e; // Unused parameter - - //TODO: Save application state and stop any background activity -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml.h deleted file mode 100644 index 147c38f16d219..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/app.xaml.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// App.xaml.h -// Declaration of the App class. -// - -#pragma once - -#include "App.g.h" - -namespace EventSupportinVS -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - ref class App sealed - { - public: - App(); - virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ args) override; - - private: - void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/logo.png b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/logo.png deleted file mode 100644 index e26771cb33a49..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/logo.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/smalllogo.png b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/smalllogo.png deleted file mode 100644 index 1eb0d9d528c42..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/smalllogo.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/splashscreen.png b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/splashscreen.png deleted file mode 100644 index c951e031bdfa0..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/splashscreen.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/storelogo.png b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/storelogo.png deleted file mode 100644 index dcb672712c682..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/assets/storelogo.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/common/standardstyles.xaml b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/common/standardstyles.xaml deleted file mode 100644 index 81fb398ea2078..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/common/standardstyles.xaml +++ /dev/null @@ -1,1007 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mouse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventclientclass.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventclientclass.cpp deleted file mode 100644 index ef3ef62f58628..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventclientclass.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "pch.h" -#include "EventClientClass.h" - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventclientclass.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventclientclass.h deleted file mode 100644 index 61dfcab33de83..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventclientclass.h +++ /dev/null @@ -1,99 +0,0 @@ -namespace EventTest = cx_Events::EventTest; -#include - -// -namespace EventClient -{ - using namespace EventTest; - namespace PC = Platform::Collections; //#include - - public ref class Subscriber sealed - { - public: - Subscriber() : eventCount(0) - { - // Instantiate the class that publishes the event. - publisher= ref new EventTest::Class1(); - - // Subscribe to the event and provide a handler function. - publisher->SomethingHappened += - ref new EventTest::SomethingHappenedEventHandler( - this, - &Subscriber::MyEventHandler); - eventLog = ref new PC::Map(); - } - void SomeMethod() - { - publisher->DoSomething(); - } - - void MyEventHandler(EventTest::Class1^ mc, Platform::String^ msg) - { - // Our custom action: log the event. - eventLog->Insert(eventCount, msg); - eventCount++; - } - - private: - PC::Map^ eventLog; - int eventCount; - EventTest::Class1^ publisher; - }; -} -// - -namespace EventTest2 = cx_Events::EventTest2; - -// -namespace EventClient2 -{ - using namespace EventTest2; - - ref class Subscriber2 sealed - { - private: - bool handlerIsActive; - Platform::String^ lastMessage; - - void TestMethod() - { - Class1^ c1 = ref new Class1(); - handlerIsActive = true; - Windows::Foundation::EventRegistrationToken cookie = - c1->SomethingHappened += - ref new EventTest2::SomethingHappenedEventHandler(this, &Subscriber2::MyEventHandler); - c1->DoSomething(); - - // Do some other work..then remove the event handler and set the flag. - handlerIsActive = false; - c1->SomethingHappened -= cookie; - } - - void MyEventHandler(Class1^ mc, Platform::String^ msg) - { - if (!handlerIsActive) - return; - lastMessage = msg; - } - }; -} -// - - -namespace NotUsed -{ - public ref class T : Platform::Object - { - internal: - T(){} - protected: - virtual void Test(){} - }; - - public ref class U sealed : T - { - public: - U () : T() {} - virtual void Test() override {} - }; -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventsupportinvs.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventsupportinvs.vcxproj deleted file mode 100644 index de5fadbfa92bc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventsupportinvs.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {f162c48f-d05d-4e98-9d1a-3db0098f8015} - EventSupportinVS - en-US - 12.0 - true - Windows Store - 8.1 - - - - Application - true - v120 - - - Application - true - v120 - - - Application - true - v120 - - - Application - false - true - v120 - - - Application - false - true - v120 - - - Application - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - - EventSupportinVS_TemporaryKey.pfx - - - - /bigobj %(AdditionalOptions) - - - - - /bigobj %(AdditionalOptions) - - - - - /bigobj %(AdditionalOptions) - - - - - /bigobj %(AdditionalOptions) - - - - - /bigobj %(AdditionalOptions) - - - - - /bigobj %(AdditionalOptions) - - - - - - - App.xaml - - - MainPage.xaml - - - - - Designer - - - Designer - - - Designer - - - - - Designer - - - - - - - - - - - - App.xaml - - - MainPage.xaml - - - Create - Create - Create - Create - Create - Create - - - - - {0cecd6e4-8303-48e8-b568-81647ff86f80} - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventsupportinvs.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventsupportinvs.vcxproj.filters deleted file mode 100644 index 30c7c38c2b9c7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/eventsupportinvs.vcxproj.filters +++ /dev/null @@ -1,49 +0,0 @@ - - - - - f162c48f-d05d-4e98-9d1a-3db0098f8015 - - - 9d4c90b0-98ef-46b3-a60e-3dee2d5819eb - - - Common - - - Assets - - - Assets - - - Assets - - - Assets - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml deleted file mode 100644 index 1180d5a5444aa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml.cpp deleted file mode 100644 index 1b1d384499274..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// MainPage.xaml.cpp -// Implementation of the MainPage class. -// - -#include "pch.h" -#include "MainPage.xaml.h" - -using namespace EventSupportinVS; - -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 - -MainPage::MainPage() -{ - InitializeComponent(); -} - -/// -/// Invoked when this page is about to be displayed in a Frame. -/// -/// Event data that describes how this page was reached. The Parameter -/// property is typically used to configure the page. -void MainPage::OnNavigatedTo(NavigationEventArgs^ e) -{ - (void) e; // Unused parameter -} - - -void EventSupportinVS::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml.h deleted file mode 100644 index a90a315a8cf3b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/mainpage.xaml.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// MainPage.xaml.h -// Declaration of the MainPage class. -// - -#pragma once - -#include "MainPage.g.h" - -namespace EventSupportinVS -{ - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - [Windows::Foundation::Metadata::WebHostHidden] - public ref class MainPage sealed - { - public: - MainPage(); - - protected: - virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; - private: - void Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/package.appxmanifest b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/package.appxmanifest deleted file mode 100644 index 40f2ed43875a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/package.appxmanifest +++ /dev/null @@ -1,31 +0,0 @@ - - - - - EventSupportinVS - mblome - Assets\StoreLogo.png - - - 6.3 - 6.3 - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/pch.h deleted file mode 100644 index fadf910de32e4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_events/cpp/eventsupportinvs/pch.h +++ /dev/null @@ -1,9 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once - -#include -#include "App.xaml.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/class1.cpp deleted file mode 100644 index 31ae6111fd63e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/class1.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" -#include - -using namespace ExceptionTest; -using namespace Platform; -using namespace Windows::Storage; -using namespace concurrency; - -Class1::Class1() -{ -} - -// -String^ Class1::MyMethod(String^ argument) -{ - - if (argument->Length() == 0) - { - auto e = ref new Exception(-1, "I'm Zork bringing you this message from across the ABI."); - //throw ref new InvalidArgumentException(); - throw e; - } - - return MyMethodInternal(argument); -} -// - -// -void Class2::ProcessString(String^ input) -{ - String^ result = nullptr; - auto obj = ref new Class1(); - - try - { - result = obj->MyMethod(input); - } - - catch (/*InvalidArgument*/Exception^ e) - { - // Handle the exception in a way that's appropriate - // for your particular scenario. Assume - // here that this string enables graceful - // recover-and-continue. Why not? - result = ref new String(L"forty two"); - - // You can use Exception data for logging purposes. - Windows::Globalization::Calendar calendar; - LogMyErrors(calendar.GetDateTime(), e->HResult, e->Message); - } - - // Execution continues here in both cases. - //#include - std::wstring ws(result->Data()); - //... -} -// - -void Class2::LogMyErrors(Windows::Foundation::DateTime dt, HRESULT hr, Platform::String^ message) -{ - auto storageFolder = KnownFolders::DocumentsLibrary; - auto str = dt.ToString(); - create_task(storageFolder->CreateFileAsync("UnhandledException.txt")).then([message](StorageFile^ file) - { - FileIO::WriteTextAsync(file, message); - }); -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/class1.h deleted file mode 100644 index 9189eba34ac54..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/class1.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include - -namespace ExceptionTest -{ - public ref class Class1 sealed - { - public: - Class1(); - Platform::String^ MyMethod(Platform::String^ argument); - Platform::String^ MyMethodInternal(Platform::String^ argument) {return ref new Platform::String();} - }; - - public ref class Class2 sealed - { - public: - void ProcessString(Platform::String^ input); - private: - void LogMyErrors(Windows::Foundation::DateTime dt, HRESULT hr, Platform::String^ message); - }; -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/exceptiontest.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/exceptiontest.vcxproj deleted file mode 100644 index 983d072f2a4aa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/exceptiontest.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {dde14f76-9981-4f6d-9373-475d6be548d8} - Win32Proj - ExceptionTest - ExceptionTest - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/exceptiontest.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/exceptiontest.vcxproj.filters deleted file mode 100644 index 0bef1f8f5fe38..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/exceptiontest.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - b9d31ded-c02b-4a4c-802c-53ca76a5c12b - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/pch.h deleted file mode 100644 index 0f9a04f134f6d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_exceptions/cpp/pch.h +++ /dev/null @@ -1,7 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once -#include \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/class1.cpp deleted file mode 100644 index 574b84882b061..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/class1.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace InterfacesTest; -using namespace Platform; - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/class1.h deleted file mode 100644 index 04a63a87f1698..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/class1.h +++ /dev/null @@ -1,233 +0,0 @@ -#pragma once - -// -namespace InterfacesTest -{ - public enum class PlayState {Playing, Paused, Stopped, Forward, Reverse}; - - public ref struct MediaPlayerEventArgs sealed - { - property PlayState oldState; - property PlayState newState; - }; - - public delegate void OnStateChanged(Platform::Object^ sender, MediaPlayerEventArgs^ a); - public interface class IMediaPlayer // or public interface struct IMediaPlayer - { - event OnStateChanged^ StateChanged; - property Platform::String^ CurrentTitle; - property PlayState CurrentState; - void Play(); - void Pause(); - void Stop(); - void Back(float speed); - void Forward(float speed); - }; -} -// - -namespace InterfacesTest -{ - // - public ref class MyMediaPlayer sealed : public IMediaPlayer - { - public: - //IMediaPlayer - virtual event OnStateChanged^ StateChanged; - virtual property Platform::String^ CurrentTitle; - virtual property PlayState CurrentState; - virtual void Play() - { - // … - auto args = ref new MediaPlayerEventArgs(); - args->newState = PlayState::Playing; - args->oldState = PlayState::Stopped; - StateChanged(this, args); - } - virtual void Pause(){/*...*/} - virtual void Stop(){/*...*/} - virtual void Forward(float speed){/*...*/} - virtual void Back(float speed){/*...*/} - private: - //... - }; - // - - // - public interface struct A { void DoSomething(); }; - public interface struct B : A { void DoSomethingMore();}; - - public ref struct C sealed : B - { - virtual void DoSomething(){} - virtual void DoSomethingMore(){} - }; - - - // - - - ref class Test - { - public: - // - //Alternate implementation in MediaPlayer class of IMediaPlayer::CurrentTitle - virtual property Platform::String^ CurrentTitle - { - Platform::String^ get() {return "Now playing: " + _title;} - void set(Platform::String^ t) {_title = t; } - } - // - private: - Platform::String^ _title; - }; - - - namespace embedded - { - // - public interface class IMediaPlayer - { - //... - property Platform::String^ CurrentTitle - { - Platform::String^ get(); - } - }; - - public ref class MyMediaPlayer3 sealed : public IMediaPlayer - { - public: - //... - virtual property Platform::String^ CurrentTitle - { - Platform::String^ get() {return "Now playing: " + _title;} - } - private: - Platform::String^ _title; - }; - // - } - // - public interface class IArtist - { - Platform::String^ Draw(); - }; - - public interface class ICowboy - { - Platform::String^ Draw(); - }; - - public ref class MyClass sealed : public IArtist, ICowboy - { - public: - MyClass(){} - virtual Platform::String^ ArtistDraw() = IArtist::Draw {return L"Artist";} - virtual Platform::String^ CowboyDraw() = ICowboy::Draw {return L"Cowboy";} - }; - // - - // - public ref class MediaFile sealed {}; - - generic - private interface class IFileCollection - { - property Windows::Foundation::Collections::IVector^ Files; - Platform::String^ GetFileInfoAsString(T file); - }; - - private ref class MediaFileCollection : IFileCollection - { - public: - virtual property Windows::Foundation::Collections::IVector^ Files; - virtual Platform::String^ GetFileInfoAsString(MediaFile^ file){return "";} - }; - - public interface class ILibraryClient - { - bool FindTitle(Platform::String^ title); - //... - }; - - public ref class MediaPlayer sealed : public IMediaPlayer, public ILibraryClient - { - public: - //IMediaPlayer - virtual event OnStateChanged^ StateChanged; - virtual property Platform::String^ CurrentTitle; - virtual property PlayState CurrentState; - virtual void Play() - { - auto args = ref new MediaPlayerEventArgs(); - args->newState = PlayState::Playing; - args->oldState = PlayState::Stopped; - StateChanged(this, args); - } - virtual void Pause(){/*...*/} - virtual void Stop(){/*...*/} - virtual void Forward(float speed){/*...*/} - virtual void Back(float speed){/*...*/} - - //ILibraryClient - virtual bool FindTitle(Platform::String^ title){/*...*/ return true;} - - private: - MediaFileCollection^ fileCollection; - - }; - // - - - - namespace Example3 - { - public interface class IMediaPlayer - { - //... - property Platform::String^ CurrentTitle - { - Platform::String^ get(); - } - }; - - public ref class MyMediaPlayer3 sealed : public IMediaPlayer - { - public: - //... - virtual property Platform::String^ CurrentTitle - { - Platform::String^ get() {return "Now playing: " + _title;} - } - private: - Platform::String^ _title; - }; - - } - - - - - - //Generic Interface t-> test - generic - interface class TestIFace - { - property T data; - }; - - template - ref class TestClass : public TestIFace - { - public: - virtual property T data; - bool IsNull() - { - // No compile error!!!! - return data->Foo(nullptr); - } - }; - - -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/header2.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/header2.h deleted file mode 100644 index 7cb3239573981..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/header2.h +++ /dev/null @@ -1,25 +0,0 @@ -namespace InterfaceDemo -{ -public ref class MyMediaPlayer sealed : public IMediaPlayer - { - public: - //IMediaPlayer - virtual event OnStateChanged^ StateChanged; - virtual property Platform::String^ CurrentTitle; - virtual property PlayState CurrentState; - virtual void Play() - { - // - auto args = ref new MediaPlayerEventArgs(); - args->newState = PlayState::Playing; - args->oldState = PlayState::Stopped; - StateChanged(this, args); - } - virtual void Pause(){/*...*/} - virtual void Stop(){/*...*/} - virtual void Forward(float speed){/*...*/} - virtual void Back(float speed){/*...*/} - private: - //... - }; -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/interfacestest.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/interfacestest.vcxproj deleted file mode 100644 index eff5133e627f3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/interfacestest.vcxproj +++ /dev/null @@ -1,222 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {3b1131b5-ead9-4f69-be70-4b97a89fd675} - Win32Proj - InterfacesTest - InterfacesTest - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/interfacestest.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/interfacestest.vcxproj.filters deleted file mode 100644 index 1a3515389d3fe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/interfacestest.vcxproj.filters +++ /dev/null @@ -1,18 +0,0 @@ - - - - - 6efe2b30-9de9-4ab5-a718-9932d4fa1fd7 - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_interfaces/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/address.details.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/address.details.h deleted file mode 100644 index 95dafe2e246e9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/address.details.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// Address.Details.h -partial ref class Address -{ -private: - Platform::String^ street_; - Platform::String^ city_; - Platform::String^ state_; - Platform::String^ zip_; - Platform::String^ country_; - void ValidateAddress(bool normalize = true); -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/address.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/address.h deleted file mode 100644 index ccc3f7bd4a3fe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/address.h +++ /dev/null @@ -1,16 +0,0 @@ - -// -// Address.h -#include "Address.details.h" -ref class Address -{ -public: - Address(Platform::String^ street, Platform::String^ city, Platform::String^ state, - Platform::String^ zip, Platform::String^ country); - property Platform::String^ Street { Platform::String^ get(); } - property Platform::String^ City { Platform::String^ get(); } - property Platform::String^ State { Platform::String^ get(); } - property Platform::String^ Zip { Platform::String^ get(); } - property Platform::String^ Country { Platform::String^ get(); } -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/class1.cpp deleted file mode 100644 index c6def63bf2d5c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/class1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace PartialClassExample; -using namespace Platform; - - -int Inner::Base1::GetNumBase(){return 1;} - -int Inner::N::GetNum() {return 2;} - -int Inner::N::GetNum2() {return 2;} - -int Inner::InnerInner::N::GetNum(){return 5;} - -int Inner::InnerInner::N::GetNum2() {return 2;} - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/class1.h deleted file mode 100644 index bd2bfb6f7e6ce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/class1.h +++ /dev/null @@ -1,114 +0,0 @@ -#pragma once - -namespace PartialClassExample -{ - // - partial ref class MyClass {/* ... */}; - // - - // - partial ref class N - { - public: - int Method1(); // Method1 is public. - - }; - ref class N - { - void Method2(); // Method2 is private. - }; - // - - /* - // This is commented out because it causes - // a compile error in Delcaration #6 due to mc already being defined. - // the error is understood. The example is most effective showing - // the various declaration rules all in one example like this. - // - // Declaration #1 - partial ref class MyClass {}; - - // Declaration #2 - partial ref class MyClass; - - // Declaration #3 - MyClass^ pMc; // OK, forward declaration. - - // Declaration #4 - MyClass mc; // Error, MyClass is not defined. - - // Declaration #5 - ref class MyClass { }; - - // Declaration #6 - MyClass mc; // OK, now MyClass is defined. - // - */ - - namespace Inner - { - /* - // Commented out for same reason as previous example - // - ref class MyClass; // OK - partial ref class MyClass{}; //OK - partial ref class MyClass{}; // OK - partial ref class MyClass{}; // OK - ref class MyClass{}; // OK - partial ref class MyClass{}; // C3971, partial definition cannot appear after full definition. - // - */ - - // - ref class Base1 { public: property int m_num; int GetNumBase();}; - interface class Base2 { int GetNum(); }; - interface class Base3{ int GetNum2();}; - - partial ref class N : public Base1 - { - public: - /*...*/ - - }; - - partial ref class N : public Base2 - { - public: - virtual int GetNum(); - // OK, as long as OtherClass is - //declared before the full definition of N - void Method2( OtherClass^ oc ); - }; - - ref class OtherClass; - - ref class N : public Base3 - { - public: - virtual int GetNum2(); - }; - // - - namespace InnerInner - { - ref class Base1 { public: property int m_num; int GetNumBase();}; - interface class Base2 { int GetNum(); }; - interface class Base3{ int GetNum2();}; - - // - ref class OtherClass; - ref class N : public Base1, public Base2, public Base3 - { - public: - virtual int GetNum(); - virtual int GetNum2(); - private: - void Method2(OtherClass^ oc); - - }; - - - // - } - } -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/partialclassexample.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/partialclassexample.vcxproj deleted file mode 100644 index 58802ec6f0f30..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/partialclassexample.vcxproj +++ /dev/null @@ -1,223 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {c1c7999c-98c3-4240-8841-835d12df01bb} - Win32Proj - PartialClassExample - PartialClassExample - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/partialclassexample.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/partialclassexample.vcxproj.filters deleted file mode 100644 index cc08cf53d8960..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/partialclassexample.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - 170cf292-704c-4304-b11d-78e8d64e1837 - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_partial/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/class1.cpp deleted file mode 100644 index 41045b712f4a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/class1.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - -using namespace cx_properties; -using namespace Platform; - -Class1::Class1() -{ -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/class1.h deleted file mode 100644 index 284cd1ea7870d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/class1.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -#include - -namespace cx_properties -{ - - public ref class Class1 sealed - { - public: - Class1(); - }; - - // - public ref class Prescription sealed - { - private: - Platform::String^ m_doctor; - int quantity; - public: - Prescription(Platform::String^ name, Platform::String^ d) : m_doctor(d) - { - // Trivial properties can't be initialized in member list. - Name = name; - } - - // Trivial property - property Platform::String^ Name; - - // Read-only property - property Platform::String^ Doctor - { - Platform::String^ get() { return m_doctor; } - } - - // Read-write property - property int Quantity - { - int get() { return quantity; } - void set(int value) - { - if (value <= 0) - { - throw ref new Platform::InvalidArgumentException(); - } - quantity = value; - } - } - }; - - public ref class PropertyConsumer sealed - { - private: - void GetPrescriptions() - { - Prescription^ p = ref new Prescription("Louis", "Dr. Who"); - p->Quantity = 5; - Platform::String^ s = p->Doctor; - int32 i = p->Quantity; - - Prescription p2("JR", "Dr. Dat"); - p2.Quantity = 10; - } - }; - // -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/cx_properties.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/cx_properties.vcxproj deleted file mode 100644 index 4eb61e3f5d5f0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/cx_properties.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {ce19d451-8b2b-45bd-b74b-f512f4f3c88c} - Win32Proj - cx_properties - cx_properties - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/cx_properties.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/cx_properties.vcxproj.filters deleted file mode 100644 index b121a49fbd2a9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/cx_properties.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 30247847-fb10-4e2b-97d1-cd44e28e92fe - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_properties/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/class1.cpp deleted file mode 100644 index 37e53be92bfba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/class1.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" -#include - -using namespace Strings; - -// -using namespace Platform; -String^ str = L"hello"; -void main(){} -// - - -Class1::Class1() -{ - // - // Initializing a String^ by using string literals - String^ str1 = "Test"; // ok for ANSI text only. uses current code page - String^ str2("Test"); - String^ str3 = L"Test"; - String^ str4(L"Test"); - - - //Initialize a String^ by using another String^ - String^ str6(str1); - auto str7 = str2; - - // Initialize a String from wchar_t* and wstring - wchar_t msg[] = L"Test"; - String^ str8 = ref new String(msg); - std::wstring wstr1(L"Test"); - String^ str9 = ref new String(wstr1.c_str()); - String^ str10 = ref new String(wstr1.c_str(), wstr1.length()); - // - - - - - - - -} - -void Test1() -{ - // - - // Concatenation - auto str1 = "Hello" + " World"; - auto str2 = str1 + " from C++/CX!"; - auto str3 = String::Concat(str2, " and the String class"); - - // Comparison - if (str1 == str2) { /* ... */ } - if (str1->Equals(str2)) { /* ... */ } - if (str1 != str2) { /* ... */ } - if (str1 < str2 || str1 > str2) { /* ... */}; - int result = String::CompareOrdinal(str1, str2); - - if(str1 == nullptr) { /* ...*/}; - if(str1->IsEmpty()) { /* ...*/}; - - // Accessing individual characters in a String^ - auto it = str1->Begin(); - char16 ch = it[0]; - // -} - -void Test2() -{ - // - // Create a String^ variable statically or dynamically from a literal string. - String^ str1 = "AAAAAAAA"; - - // Use the value of str1 to create the ws1 wstring variable. - std::wstring ws1( str1->Data() ); - // The value of ws1 is L"AAAAAAAA". - - // Manipulate the wstring value. - std::wstring replacement( L"BBB" ); - ws1 = ws1.replace ( 1, 3, replacement ); - // The value of ws1 is L"ABBBAAAA". - - // Assign the modified wstring back to str1. - str1 = ref new String( ws1.c_str() ); - - // - -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/class1.h deleted file mode 100644 index d6d5c564611ba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/class1.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace Strings -{ - - - public ref class Class1 sealed - { - public: - Class1(); - }; -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/cppcx_strings.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/cppcx_strings.vcxproj deleted file mode 100644 index dba63c8df147e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/cppcx_strings.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {61c7b54d-d78a-4970-9e15-3fe6b9249873} - Win32Proj - CX_Strings - CPPCX_Strings - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/cppcx_strings.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/cppcx_strings.vcxproj.filters deleted file mode 100644 index 64d731553f1e3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/cppcx_strings.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 19ea9cd4-4b43-4f43-aae1-c2586f28d2b7 - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_strings/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/class1.cpp deleted file mode 100644 index be79985dc0994..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/class1.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Class1.cpp -#include "pch.h" -#include "Class1.h" - - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/class1.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/class1.h deleted file mode 100644 index 8c8cda2f5024f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/class1.h +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once - -namespace cx_templates -{ - public ref class Class1 sealed - { - public: - Class1(){} - }; - - // - namespace TemplateDemo - { - // A private ref class template - template - ref class MyRefTemplate - { - internal: - MyRefTemplate(T d) : data(d){} - public: - T Get(){ return data; } - private: - T data; - }; - - // Specialization of ref class template - template<> - ref class MyRefTemplate - { - internal: - //... - }; - - // A private derived ref class that inherits - // from a ref class template specialization - ref class MyDerivedSpecialized sealed : public MyRefTemplate - { - internal: - MyDerivedSpecialized() : MyRefTemplate(5){} - }; - - // A private derived template ref class - // that inherits from a ref class template - template - ref class MyDerived : public MyRefTemplate - { - internal: - MyDerived(){} - }; - - // A standard C++ template - template - class MyStandardTemplate - { - public: - MyStandardTemplate(){} - T Get() { return data; } - private: - T data; - - }; - - // A public ref class with private - // members that are specializations of - // ref class templates and standard C++ templates. - public ref class MySpecializeBoth sealed - { - public: - MySpecializeBoth(){} - private: - MyDerivedSpecialized^ g; - MyStandardTemplate* n; - }; - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/pch.h deleted file mode 100644 index f815ac97bb22e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/templatedemo.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/templatedemo.vcxproj deleted file mode 100644 index de11f5b4ae96b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/templatedemo.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {246d0852-8bf8-4d20-adb5-6e885c616f12} - Win32Proj - TemplateDemo - TemplateDemo - en-US - 12.0 - true - Windows Store - 8.1 - - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - Use - _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj %(AdditionalOptions) - - - Console - runtimeobject.lib;%(AdditionalDependencies) - false - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/templatedemo.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/templatedemo.vcxproj.filters deleted file mode 100644 index 6994e214608ea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/cx_templates/cpp/templatedemo.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - cd08e6c9-c7f8-41f5-8b54-8fd663172fdb - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/beta2_native.cpp b/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/beta2_native.cpp deleted file mode 100644 index f3e3a8af030e5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/beta2_native.cpp +++ /dev/null @@ -1,317 +0,0 @@ - -// -#include "stdafx.h" -#include -#include -#include -#include -#include -#include -#include - -CRITICAL_SECTION cs; - -using namespace ::std; -using namespace ::std::tr1; -using namespace ::Concurrency; -task_group task4; -task_group task3; -task_group task2; - -volatile long aa = 0; -volatile long bb = 0; -volatile long cc = 0; -static bool waitFor1 = true; -static bool waitFor5 = true; - -#pragma optimize("", off) -void Spin() -{ - for(int i=0;i<50*50000;++i); -} -#pragma optimize("",on) - -template -class RunFunc -{ - Func& m_Func; - int m_o; -public: - RunFunc(Func func,int o):m_Func(func),m_o(o){ - - }; - void operator()()const{ - m_Func(m_o); - }; -}; - -void T(int o) -{ - cout << "Scheduled run \n"; - -}; - -void R(int o) -{ - if (o == 2) - { - while (waitFor5) { ;} - Spin(); - - //use up all processors but 4 by scheduling 4 non-terminating tasks. - int numProcsToBurn = GetProcessorCount() - 4; - int i; - vector*> tasks; - for (i = 0; i < numProcsToBurn; i++) - { - tasks.push_back(new call([](int i){while(true)Spin();})); - asend(tasks[i],1); - cout << "Started task \n"; - } - - task_handle> t6(RunFunc(T,i + 1 + 5)); - task_handle> t7(RunFunc(T,i + 2 + 5)); - task_handle> t8(RunFunc(T,i + 3 + 5)); - task_handle> t9(RunFunc(T,i + 4 + 5)); - task_handle> t10(RunFunc(T,i + 5 + 5)); - task2.run(t6); - task2.run(t7); - task2.run(t8); - task2.run(t9); - task2.run(t10); - - //BP4 - 1 in M, 2 in R, 3 in J, 4 in R, 5 died - DebugBreak(); - } - else - { - if (o!=4) - throw; - - task3.wait(); - } -}; - -void Q() -{ - // breaks here at the same time as N and M - InterlockedIncrement(& cc); - while (cc < 4) - { - ; - } - // task 5 dies here freeing task 4 (its parent) - cout << "t5 dies\n"; - waitFor5 = false; -}; - -void P() -{ - cout << "t5 runs\n"; - Q(); -}; - -void O(int o) -{ - task_group t5; - t5.run(&P); - t5.wait(); - R(o); -}; - -void N(int o) -{ - // breaks here at the same time as M and Q - InterlockedIncrement(&cc); - while (cc < 4) - { - ; - } - R(o); -}; - -void M(int o) -{ - // breaks here at the same time as N and Q - InterlockedIncrement(&cc); - while (cc < 3) - { - ; - } - //BP3 - 1 in M, 2 in N, 3 still in J, 4 in O, 5 in Q - DebugBreak(); - InterlockedIncrement(&cc); - while (true) - Sleep(500); // for ever -}; - -void L(int oo) -{ - int temp3 = oo; - - switch (temp3) - { - case 1: - M(oo); - break; - case 2: - N(oo); - break; - case 4: - O(oo); - break; - default: - throw; //fool3 - break; - } -} -void K(int o) -{ - // break here at the same time as E and H - InterlockedIncrement(&bb); - EnterCriticalSection(&cs); - while (bb < 3) - { - ; - } - LeaveCriticalSection(&cs); - Spin(); - - //after - L(o); -} -void J(int o) -{ - int temp2 = o; - - switch (temp2) - { - case 3: - task4.wait(); - break; - case 4: - K(o); - break; - default: - throw; //fool2 - break; - } -} -static void I(int o) -{ - J(o); -} -static void H(int o) -{ - // break here at the same time as E and K - InterlockedIncrement(&bb); - EnterCriticalSection(&cs); - while (bb < 3) - { - ; - } - LeaveCriticalSection(&cs); - Spin(); - - //after - L(o); -} -static void G(int o) -{ - H(o); -} -static void F(int o) -{ - G(o); -} - -static void E(int o) -{ - // break here at the same time as H and K - while (bb < 2) - { - ; - } - //BP2 - 1 in E, 2 in H, 3 in J, 4 in K - Spin(); // for native case only - DebugBreak(); - InterlockedIncrement(&bb); - - //after - L(o); - -} - -static void D(int o) -{ - E(o); -} - -static void C(int o) -{ - int temp = o; - - InterlockedIncrement(&aa); - while (aa < 4) - { - ; - } - - if (temp == 1) - { - // BP1 - all tasks in C - DebugBreak(); - waitFor1 = false; - } - else - { - while (waitFor1) - { - ; - } - } - switch (temp) - { - case 1: - D(o); - break; - case 2: - F(o); - break; - case 3: - case 4: - I(o); - break; - default: - throw; //fool - break; - } -} -static void B(int o) -{ - C(o); -} - -void A(int o) -{ - B(o); -} -int main() -{ - InitializeCriticalSection(&cs); - - task_group tasks; - task_handle> t1(RunFunc(A,1)); - tasks.run(t1); - task_handle> t2(RunFunc(A,2)); - task2.run(t2); - task_handle> t3(RunFunc(A,3)); - task3.run(t3); - task_handle> t4(RunFunc(A,4)); - task4.run(t4); - - getchar(); - return 1; -} -// - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/makefile deleted file mode 100644 index 815710645f0d5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -beta2_native.exe : beta2_native.cpp - cl.exe /EHsc beta2_native.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/stdafx.h deleted file mode 100644 index b005a839def24..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/targetver.h deleted file mode 100644 index 6b58e4965500d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/debugger/cpp/targetver.h +++ /dev/null @@ -1,18 +0,0 @@ - -#pragma once - -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features -// to run your application. The macros work by enabling all features available on platform -// versions up to and including the version specified. - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. - -#include - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT _WIN32_WINNT_MAXVER // Change this to the appropriate value to target other versions of Windows. -#endif - -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp b/samples/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp deleted file mode 100644 index 27900a2f4ebc3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*System::Net::HttpWebRequest->AddRange(int, int) -This program demonstrates 'AddRange(int, int)' method of 'HttpWebRequest class. -A new 'HttpWebRequest' Object* is created.The number of characters of the response to be received can be -restricted by the 'AddRange' method.By calling 'AddRange(50, 150)' on the 'HttpWebRequest' Object* the content -of the response page is restricted from the 50th character to 150th charater.The response of the request is -obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a New 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest1 = - (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest1->AddRange( 1000); - Console::WriteLine("Call AddRange(1000)"); - Console::Write("Resulting Headers: "); - Console::WriteLine(myHttpWebRequest1->Headers); - - HttpWebRequest^ myHttpWebRequest2 = - (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest2->AddRange(-1000); - Console::WriteLine("Call AddRange(-1000)"); - Console::Write("Resulting Headers: "); - Console::WriteLine(myHttpWebRequest2->Headers); - -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp b/samples/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp deleted file mode 100644 index aec1e43561697..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*System::Net::HttpWebRequest->AddRange(int, int) -This program demonstrates 'AddRange(int, int)' method of 'HttpWebRequest class. -A new 'HttpWebRequest' Object* is created.The number of characters of the response to be received can be -restricted by the 'AddRange' method.By calling 'AddRange(50, 150)' on the 'HttpWebRequest' Object* the content -of the response page is restricted from the 50th character to 150th charater.The response of the request is -obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a New 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest->AddRange( 50, 150 ); - Console::WriteLine("Call AddRange(50, 150)"); - Console::Write("Resulting Request Headers: "); - Console::WriteLine(myHttpWebRequest->Headers); - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - - // Displays the headers in the response received - Console::Write("Resulting Response Headers: "); - Console::WriteLine(myHttpWebResponse->Headers); - - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe HTML contents of the page from 50th to 150 charaters are :\n " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue..........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.cpp deleted file mode 100644 index 9a85518fcef53..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// -#include "stdafx.h" - -#include "..\CalculatorComponent\CalculatorComponent_h.h" - -const IID IID_ICalculatorComponent = {0x0DBABB94,0xCE99,0x42F7,0xAC,0xBD,0xE6,0x98,0xB2,0x33,0x2C,0x60}; -const CLSID CLSID_CalculatorComponent = {0xE68F5EDD,0x6257,0x4E72,0xA1,0x0B,0x40,0x67,0xED,0x8E,0x85,0xF2}; - -// Prints an error string for the provided source code line and HRESULT -// value and returns the HRESULT value as an int. -int PrintError(unsigned int line, HRESULT hr) -{ - wprintf_s(L"ERROR: Line:%d HRESULT: 0x%X\n", line, hr); - return hr; -} - -int wmain() -{ - HRESULT hr; - - // Initialize the COM library. - hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - - ICalculatorComponent* calc = nullptr; // Interface to COM component. - - // Create the CalculatorComponent object. - hr = CoCreateInstance(CLSID_CalculatorComponent, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&calc)); - if (SUCCEEDED(hr)) - { - // Test the component by adding two numbers. - int result; - hr = calc->Add(4, 5, &result); - if (FAILED(hr)) - { - PrintError(__LINE__, hr); - } - else - { - wprintf_s(L"result = %d\n", result); - } - - // Free the CalculatorComponent object. - calc->Release(); - } - else - { - // Object creation failed. Print a message. - PrintError(__LINE__, hr); - } - - // Free the COM library. - CoUninitialize(); - - return hr; -} -/* Output: -result = 9 -*/ -// -/* -// -#include "stdafx.h" -#include - -#include "..\CalculatorComponent\CalculatorComponent_h.h" - -using namespace Microsoft::WRL; - -const IID IID_ICalculatorComponent = {0x0DBABB94,0xCE99,0x42F7,0xAC,0xBD,0xE6,0x98,0xB2,0x33,0x2C,0x60}; -const CLSID CLSID_CalculatorComponent = {0xE68F5EDD,0x6257,0x4E72,0xA1,0x0B,0x40,0x67,0xED,0x8E,0x85,0xF2}; - -// Prints an error string for the provided source code line and HRESULT -// value and returns the HRESULT value as an int. -int PrintError(unsigned int line, HRESULT hr) -{ - wprintf_s(L"ERROR: Line:%d HRESULT: 0x%X\n", line, hr); - return hr; -} - -int wmain() -{ - HRESULT hr; - - // RAII wrapper for managing the lifetime of the COM library. - class CoInitializeWrapper - { - HRESULT _hr; - public: - CoInitializeWrapper(DWORD flags) - { - _hr = CoInitializeEx(nullptr, flags); - } - ~CoInitializeWrapper() - { - if (SUCCEEDED(_hr)) - { - CoUninitialize(); - } - } - operator HRESULT() - { - return _hr; - } - - }; - - // Initialize the COM library. - CoInitializeWrapper initialize(COINIT_APARTMENTTHREADED); - if (FAILED(initialize)) - { - return PrintError(__LINE__, initialize); - } - - ComPtr calc; // Interface to COM component. - - // Create the CalculatorComponent object. - hr = CoCreateInstance(CLSID_CalculatorComponent, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(calc.GetAddressOf())); - if (SUCCEEDED(hr)) - { - // Test the component by adding two numbers. - int result; - hr = calc->Add(4, 5, &result); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - wprintf_s(L"result = %d\n", result); - } - else - { - // Object creation failed. Print a message. - return PrintError(__LINE__, hr); - } - - return 0; -} -// -*/ \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.vcxproj deleted file mode 100644 index ef668cace1fa5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.vcxproj +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {E5C03450-2BE9-4210-A2AD-864D16E979AB} - Win32Proj - Calculator - - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - Create - Create - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.vcxproj.filters deleted file mode 100644 index a494cda1cb741..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/calculator.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/readme.txt b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/readme.txt deleted file mode 100644 index 789aa90b56d19..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/readme.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : Calculator Project Overview -======================================================================== - -AppWizard has created this Calculator application for you. - -This file contains a summary of what you will find in each of the files that -make up your Calculator application. - - -Calculator.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -Calculator.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -Calculator.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named Calculator.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/stdafx.cpp deleted file mode 100644 index a65750aa16875..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// Calculator.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/stdafx.h deleted file mode 100644 index b005a839def24..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/targetver.h deleted file mode 100644 index 87c0086de751b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculator/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.cpp deleted file mode 100644 index 6579522a5cdac..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -#include "stdafx.h" - -#include "CalculatorComponent_h.h" -#include - -using namespace Microsoft::WRL; - -class CalculatorComponent: public RuntimeClass, ICalculatorComponent> -{ -public: - CalculatorComponent() - { - } - - STDMETHODIMP Add(_In_ int a, _In_ int b, _Out_ int* value) - { - *value = a + b; - return S_OK; - } -}; - -CoCreatableClass(CalculatorComponent); -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.def b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.def deleted file mode 100644 index 125b4fb8a56a3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.def +++ /dev/null @@ -1,6 +0,0 @@ -LIBRARY - -EXPORTS - DllGetActivationFactory PRIVATE - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.idl b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.idl deleted file mode 100644 index 476bf42be3d8d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.idl +++ /dev/null @@ -1,19 +0,0 @@ -// -import "ocidl.idl"; - -[uuid(0DBABB94-CE99-42F7-ACBD-E698B2332C60), version(1.0)] -interface ICalculatorComponent : IUnknown -{ - HRESULT Add([in] int a, [in] int b, [out, retval] int* value); -} - -[uuid(9D3E6826-CB8E-4D86-8B14-89F0D7EFCD01), version(1.0)] -library CalculatorComponentLib -{ - [uuid(E68F5EDD-6257-4E72-A10B-4067ED8E85F2), version(1.0)] - coclass CalculatorComponent - { - [default] interface ICalculatorComponent; - } -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.vcxproj deleted file mode 100644 index 1659b3c066407..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.vcxproj +++ /dev/null @@ -1,114 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {E36383E4-A913-4FC0-A6FA-7CE339694343} - Win32Proj - CalculatorComponent - - - - DynamicLibrary - true - v110 - Unicode - - - DynamicLibrary - false - v110 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;CALCULATORCOMPONENT_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - CalculatorComponent.def - runtimeobject.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;CALCULATORCOMPONENT_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - CalculatorComponent.def - runtimeobject.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - false - - - false - - - - - Create - Create - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.vcxproj.filters deleted file mode 100644 index 13c5eb333de61..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/calculatorcomponent.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Source Files - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/dllmain.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/dllmain.cpp deleted file mode 100644 index e8af5dac0d1d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/dllmain.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -#include "stdafx.h" -#include - -using namespace Microsoft::WRL; - -#if !defined(__WRL_CLASSIC_COM__) -STDAPI DllGetActivationFactory(_In_ HSTRING activatibleClassId, _COM_Outptr_ IActivationFactory** factory) -{ - return Module::GetModule().GetActivationFactory(activatibleClassId, factory); -} -#endif - -#if !defined(__WRL_WINRT_STRICT__) -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv) -{ - return Module::GetModule().GetClassObject(rclsid, riid, ppv); -} -#endif - -STDAPI DllCanUnloadNow() -{ - return Module::GetModule().Terminate() ? S_OK : S_FALSE; -} - -STDAPI_(BOOL) DllMain(_In_opt_ HINSTANCE hinst, DWORD reason, _In_opt_ void*) -{ - if (reason == DLL_PROCESS_ATTACH) - { - DisableThreadLibraryCalls(hinst); - } - return TRUE; -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/readme.txt b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/readme.txt deleted file mode 100644 index 1786cdd4540dc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/readme.txt +++ /dev/null @@ -1,48 +0,0 @@ -======================================================================== - DYNAMIC LINK LIBRARY : CalculatorComponent Project Overview -======================================================================== - -AppWizard has created this CalculatorComponent DLL for you. - -This file contains a summary of what you will find in each of the files that -make up your CalculatorComponent application. - - -CalculatorComponent.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -CalculatorComponent.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -CalculatorComponent.cpp - This is the main DLL source file. - - When created, this DLL does not export any symbols. As a result, it - will not produce a .lib file when it is built. If you wish this project - to be a project dependency of some other project, you will either need to - add code to export some symbols from the DLL so that an export library - will be produced, or you can set the Ignore Input Library property to Yes - on the General propert page of the Linker folder in the project's Property - Pages dialog box. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named CalculatorComponent.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/regscript.reg b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/regscript.reg deleted file mode 100644 index c8611f6b53080..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/regscript.reg +++ /dev/null @@ -1,16 +0,0 @@ -Windows Registry Editor Version 5.00 - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}] -@="CalculatorComponent Class" - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\InprocServer32] -@="E:\\SD\\UE\\Samples\\Dev11\\WRL\\wrl-classic-com-component\\cpp\\WRLClassicCOM\\Debug\\CalculatorComponent.dll" -"ThreadingModel"="Apartment" - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\Programmable] - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\TypeLib] -@="{9D3E6826-CB8E-4D86-8B14-89F0D7EFCD01}" - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\Version] -@="1.0" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/stdafx.cpp deleted file mode 100644 index 2e3b158e5d281..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// CalculatorComponent.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/stdafx.h deleted file mode 100644 index f3a07375c7662..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/stdafx.h +++ /dev/null @@ -1,16 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - - -// TODO: reference additional headers your program requires here diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/targetver.h deleted file mode 100644 index 87c0086de751b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/calculatorcomponent/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/wrlclassiccom.sln b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/wrlclassiccom.sln deleted file mode 100644 index 98ef49a96305a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/cpp/wrlclassiccom/wrlclassiccom.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalculatorComponent", "CalculatorComponent\CalculatorComponent.vcxproj", "{E36383E4-A913-4FC0-A6FA-7CE339694343}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Calculator", "Calculator\Calculator.vcxproj", "{E5C03450-2BE9-4210-A2AD-864D16E979AB}" - ProjectSection(ProjectDependencies) = postProject - {E36383E4-A913-4FC0-A6FA-7CE339694343} = {E36383E4-A913-4FC0-A6FA-7CE339694343} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E36383E4-A913-4FC0-A6FA-7CE339694343}.Debug|Win32.ActiveCfg = Debug|Win32 - {E36383E4-A913-4FC0-A6FA-7CE339694343}.Debug|Win32.Build.0 = Debug|Win32 - {E36383E4-A913-4FC0-A6FA-7CE339694343}.Release|Win32.ActiveCfg = Release|Win32 - {E36383E4-A913-4FC0-A6FA-7CE339694343}.Release|Win32.Build.0 = Release|Win32 - {E5C03450-2BE9-4210-A2AD-864D16E979AB}.Debug|Win32.ActiveCfg = Debug|Win32 - {E5C03450-2BE9-4210-A2AD-864D16E979AB}.Debug|Win32.Build.0 = Debug|Win32 - {E5C03450-2BE9-4210-A2AD-864D16E979AB}.Release|Win32.ActiveCfg = Release|Win32 - {E5C03450-2BE9-4210-A2AD-864D16E979AB}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/def/calculatorcomponent.def b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/def/calculatorcomponent.def deleted file mode 100644 index ce7bbbdaed25a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/def/calculatorcomponent.def +++ /dev/null @@ -1,8 +0,0 @@ -// -LIBRARY - -EXPORTS - DllGetActivationFactory PRIVATE - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/reg/regscript.reg b/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/reg/regscript.reg deleted file mode 100644 index e90ff7cdb5317..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-classic-com-component/reg/regscript.reg +++ /dev/null @@ -1,18 +0,0 @@ -// -Windows Registry Editor Version 5.00 - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}] -@="CalculatorComponent Class" - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\InprocServer32] -@="" -"ThreadingModel"="Apartment" - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\Programmable] - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\TypeLib] -@="{9D3E6826-CB8E-4D86-8B14-89F0D7EFCD01}" - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E68F5EDD-6257-4E72-A10B-4067ED8E85F2}\Version] -@="1.0" -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-async/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-async/cpp/makefile deleted file mode 100644 index f2881240d4284..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-async/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -wrl-consume-async.exe: wrl-consume-async.cpp - cl.exe wrl-consume-async.cpp /W4 /WX runtimeobject.lib \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-async/cpp/wrl-consume-async.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-async/cpp/wrl-consume-async.cpp deleted file mode 100644 index 4512c8230099d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-async/cpp/wrl-consume-async.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -// wrl-consume-async.cpp -// compile with: runtimeobject.lib -// -#include -#include -#include -#include -#include - -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::System::Threading; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -// - -// Prints an error string for the provided source code line and HRESULT -// value and returns the HRESULT value as an int. -int PrintError(unsigned int line, HRESULT hr) -{ - wprintf_s(L"ERROR: Line:%d HRESULT: 0x%X\n", line, hr); - return hr; -} - -int wmain() -{ - // - // Initialize the Windows Runtime. - RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); - if (FAILED(initialize)) - { - return PrintError(__LINE__, initialize); - } - // - - // - // Get the activation factory for the IThreadPoolTimer interface. - ComPtr timerFactory; - HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), &timerFactory); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Create an event that is set after the timer callback completes. We later use this event to wait for the timer to complete. - // This event is for demonstration only in a console app. In most apps, you typically don't wait for async operations to complete. - Event timerCompleted(CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, WRITE_OWNER | EVENT_ALL_ACCESS)); - hr = timerCompleted.IsValid() ? S_OK : HRESULT_FROM_WIN32(GetLastError()); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Create a timer that prints a message after 2 seconds. - - TimeSpan delay; - delay.Duration = 20000000; // 2 seconds. - - auto callback = Callback([&timerCompleted](IThreadPoolTimer* timer) -> HRESULT - { - wprintf_s(L"Timer fired.\n"); - - TimeSpan delay; - HRESULT hr = timer->get_Delay(&delay); - if (SUCCEEDED(hr)) - { - wprintf_s(L"Timer duration: %2.2f seconds.\n", delay.Duration / 10000000.0); - } - - // Set the completion event and return. - SetEvent(timerCompleted.Get()); - return hr; - }); - hr = callback ? S_OK : E_OUTOFMEMORY; - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - - ComPtr timer; - hr = timerFactory->CreateTimer(callback.Get(), delay, &timer); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Print a message and wait for the timer callback to complete. - wprintf_s(L"Timer started.\nWaiting for timer...\n"); - - // Wait for the timer to complete. - WaitForSingleObjectEx(timerCompleted.Get(), INFINITE, FALSE); - // All smart pointers and RAII objects go out of scope here. - // -} -/* -Output: -Timer started. -Waiting for timer... -Timer fired. -Timer duration: 2.00 seconds. -*/ -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-asyncop/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-asyncop/cpp/makefile deleted file mode 100644 index b2876aafe19cf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-asyncop/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -wrl-consume-asyncOp.exe: wrl-consume-asyncOp.cpp - cl.exe wrl-consume-asyncOp.cpp runtimeobject.lib \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-asyncop/cpp/wrl-consume-asyncop.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-asyncop/cpp/wrl-consume-asyncop.cpp deleted file mode 100644 index 51ce4eef54d96..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-asyncop/cpp/wrl-consume-asyncop.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// -// wrl-consume-asyncOp.cpp -// compile with: runtimeobject.lib -// -#include -#include -#include -#include -#include - -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::System::Threading; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -// - -// Prints an error string for the provided source code line and HRESULT -// value and returns the HRESULT value as an int. -int PrintError(unsigned int line, HRESULT hr) -{ - wprintf_s(L"ERROR: Line:%d HRESULT: 0x%X\n", line, hr); - return hr; -} - -// Determines whether the input value is prime. -bool IsPrime(int n) -{ - if (n < 2) - { - return false; - } - for (int i = 2; i < n; ++i) - { - if ((n % i) == 0) - { - return false; - } - } - return true; -} - -int wmain() -{ - // - // Initialize the Windows Runtime. - RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); - if (FAILED(initialize)) - { - return PrintError(__LINE__, initialize); - } - // - - // - // Get the activation factory for the IThreadPoolStatics interface. - ComPtr threadPool; - HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(), &threadPool); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Create an event that is set after the timer callback completes. We later use this event to wait for the timer to complete. - // This event is for demonstration only in a console app. In most apps, you typically don't wait for async operations to complete. - Event threadCompleted(CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, WRITE_OWNER | EVENT_ALL_ACCESS)); - hr = threadCompleted.IsValid() ? S_OK : HRESULT_FROM_WIN32(GetLastError()); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - - // - - // - wprintf_s(L"Starting thread...\n"); - - // Create a thread that computes prime numbers. - ComPtr asyncAction; - hr = threadPool->RunAsync(Callback([&threadCompleted](IAsyncAction* asyncAction) -> HRESULT - { - // Print a message. - const unsigned int start = 0; - const unsigned int end = 100000; - unsigned int primeCount = 0; - for (int n = start; n < end; n++) - { - if (IsPrime(n)) - { - primeCount++; - } - } - - wprintf_s(L"There are %u prime numbers from %u to %u.\n", primeCount, start, end); - - // Set the completion event and return. - SetEvent(threadCompleted.Get()); - return S_OK; - - }).Get(), &asyncAction); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Print a message and wait for the thread to complete. - wprintf_s(L"Waiting for thread...\n"); - - // Wait for the thread to complete. - WaitForSingleObjectEx(threadCompleted.Get(), INFINITE, FALSE); - - wprintf_s(L"Finished.\n"); - - // All smart pointers and RAII objects go out of scope here. - // -} -/* -Output: -Starting thread... -Waiting for thread... -There are 9592 prime numbers from 0 to 100000. -Finished. -*/ -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-component/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-component/cpp/makefile deleted file mode 100644 index af6bf1fd3144e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-component/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -wrl-consume-component.exe: wrl-consume-component.cpp - cl.exe wrl-consume-component.cpp /W4 /WX runtimeobject.lib \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-component/cpp/wrl-consume-component.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-component/cpp/wrl-consume-component.cpp deleted file mode 100644 index 14d7ca87cf67f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-component/cpp/wrl-consume-component.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -// wrl-consume-component.cpp -// compile with: runtimeobject.lib -// -#include -#include -#include -#include - -using namespace ABI::Windows::Foundation; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -// - -// Prints an error string for the provided source code line and HRESULT -// value and returns the HRESULT value as an int. -int PrintError(unsigned int line, HRESULT hr) -{ - wprintf_s(L"ERROR: Line:%d HRESULT: 0x%X\n", line, hr); - return hr; -} - -int wmain() -{ - // - // Initialize the Windows Runtime. - RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); - if (FAILED(initialize)) - { - return PrintError(__LINE__, initialize); - } - // - - // - // Get the activation factory for the IUriRuntimeClass interface. - ComPtr uriFactory; - HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_Uri).Get(), &uriFactory); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Create a string that represents a URI. - HString uriHString; - hr = uriHString.Set(L"http://www.microsoft.com"); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Create the IUriRuntimeClass object. - ComPtr uri; - hr = uriFactory->CreateUri(uriHString.Get(), &uri); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Get the domain part of the URI. - HString domainName; - hr = uri->get_Domain(domainName.GetAddressOf()); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Print the domain name and return. - wprintf_s(L"Domain name: %s\n", domainName.GetRawBuffer(nullptr)); - - // All smart pointers and RAII objects go out of scope here. - // -} -/* -Output: -Domain name: microsoft.com -*/ -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-event/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-event/cpp/makefile deleted file mode 100644 index d25885eb75358..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-event/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -wrl-consume-event.exe: wrl-consume-event.cpp - cl.exe wrl-consume-event.cpp /W4 /WX runtimeobject.lib \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-event/cpp/wrl-consume-event.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-event/cpp/wrl-consume-event.cpp deleted file mode 100644 index 10b3de4ad0dc5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-consume-event/cpp/wrl-consume-event.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// -// wrl-consume-events.cpp -// compile with: runtimeobject.lib -// -#include -#include -#include - -using namespace ABI::Windows::Devices::Enumeration; -using namespace ABI::Windows::Foundation; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -// - -// Prints an error string for the provided source code line and HRESULT -// value and returns the HRESULT value as an int. -int PrintError(unsigned int line, HRESULT hr) -{ - wprintf_s(L"ERROR: Line:%d HRESULT: 0x%X\n", line, hr); - return hr; -} - -int wmain() -{ - // Type define the event handler types to make the code more readable. - typedef __FITypedEventHandler_2_Windows__CDevices__CEnumeration__CDeviceWatcher_Windows__CDevices__CEnumeration__CDeviceInformation AddedHandler; - typedef __FITypedEventHandler_2_Windows__CDevices__CEnumeration__CDeviceWatcher_IInspectable EnumerationCompletedHandler; - typedef __FITypedEventHandler_2_Windows__CDevices__CEnumeration__CDeviceWatcher_IInspectable StoppedHandler; - - // - // Counts the number of enumerated devices. - unsigned int deviceCount = 0; - - // Event registration tokens that enable us to later unsubscribe from events. - EventRegistrationToken addedToken; - EventRegistrationToken stoppedToken; - EventRegistrationToken enumCompletedToken; - // - - // - // Initialize the Windows Runtime. - RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); - if (FAILED(initialize)) - { - return PrintError(__LINE__, initialize); - } - // - - // - // Create an event that is set after device enumeration completes. We later use this event to wait for the timer to complete. - // This event is for demonstration only in a console app. In most apps, you typically don't wait for async operations to complete. - Event enumerationCompleted(CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, WRITE_OWNER | EVENT_ALL_ACCESS)); - HRESULT hr = enumerationCompleted.IsValid() ? S_OK : HRESULT_FROM_WIN32(GetLastError()); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Get the activation factory for the IDeviceWatcher interface. - ComPtr watcherFactory; - hr = ABI::Windows::Foundation::GetActivationFactory(HStringReference(RuntimeClass_Windows_Devices_Enumeration_DeviceInformation).Get(), &watcherFactory); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Create a IDeviceWatcher object from the factory. - ComPtr watcher; - hr = watcherFactory->CreateWatcher(&watcher); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Subscribe to the Added event. - hr = watcher->add_Added(Callback([&deviceCount](IDeviceWatcher* watcher, IDeviceInformation*) -> HRESULT - { - // Print a message and increment the device count. - // When we reach 10 devices, stop enumerating devices. - wprintf_s(L"Added device...\n"); - deviceCount++; - if (deviceCount == 10) - { - return watcher->Stop(); - } - return S_OK; - - }).Get(), &addedToken); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - - hr = watcher->add_Stopped(Callback([=, &enumerationCompleted](IDeviceWatcher* watcher, IInspectable*) -> HRESULT - { - wprintf_s(L"Device enumeration stopped.\nRemoving event handlers..."); - - // Unsubscribe from the events. This is shown for demonstration. - // The need to remove event handlers depends on the requirements of - // your app. For instance, if you only need to handle an event for - // a short period of time, you might remove the event handler when you - // no longer need it. If you handle an event for the duration of the app, - // you might not need to explicitly remove it. - HRESULT hr1 = watcher->remove_Added(addedToken); - HRESULT hr2 = watcher->remove_Stopped(stoppedToken); - HRESULT hr3 = watcher->remove_EnumerationCompleted(enumCompletedToken); - - // Set the completion event and return. - SetEvent(enumerationCompleted.Get()); - - return FAILED(hr1) ? hr1 : FAILED(hr2) ? hr2 : hr3; - - }).Get(), &stoppedToken); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - - // Subscribe to the EnumerationCompleted event. - hr = watcher->add_EnumerationCompleted(Callback([](IDeviceWatcher* watcher, IInspectable*) -> HRESULT - { - wprintf_s(L"Enumeration completed.\n"); - - return watcher->Stop(); - - }).Get(), &enumCompletedToken); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - wprintf_s(L"Starting device enumeration...\n"); - hr = watcher->Start(); - if (FAILED(hr)) - { - return PrintError(__LINE__, hr); - } - // - - // - // Wait for the operation to complete. - WaitForSingleObjectEx(enumerationCompleted.Get(), INFINITE, FALSE); - - wprintf_s(L"Enumerated %u devices.\n", deviceCount); - - // All smart pointers and RAII objects go out of scope here. - // -} -/* -Sample output: -Starting device enumeration... -Added device... -Added device... -Added device... -Added device... -Added device... -Added device... -Added device... -Added device... -Added device... -Added device... -Device enumeration stopped. -Removing event handlers... -Enumerated 10 devices. -*/ -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/ilogger.idl b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/ilogger.idl deleted file mode 100644 index 7046e3b365acd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/ilogger.idl +++ /dev/null @@ -1,10 +0,0 @@ -// -import "ocidl.idl"; - -// Prints text to the console. -[uuid(AFDB9683-F18A-4B85-90D1-B6158DAFA46C)] -interface ILogger : IUnknown -{ - HRESULT Log([in] LPCWSTR text); -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/readme.txt b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/readme.txt deleted file mode 100644 index 8fc281714c9ac..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/readme.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : WRLMake Project Overview -======================================================================== - -AppWizard has created this WRLMake application for you. - -This file contains a summary of what you will find in each of the files that -make up your WRLMake application. - - -WRLMake.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -WRLMake.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -WRLMake.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named WRLMake.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/stdafx.cpp deleted file mode 100644 index ca3ca665fdb3a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// WRLMake.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/stdafx.h deleted file mode 100644 index b005a839def24..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/targetver.h deleted file mode 100644 index 87c0086de751b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.cpp deleted file mode 100644 index 63e2244d160cd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// WRLMake.cpp : Defines the entry point for the console application. -// -// -#include "stdafx.h" -#include -#include - -#include "ILogger_h.h" - -using namespace Microsoft::WRL; - -// Writes logging messages to the console. -class CConsoleWriter : public RuntimeClass, ILogger> -{ -public: - STDMETHODIMP Log(_In_ PCWSTR text) - { - wprintf_s(L"%s\n", text); - return S_OK; - } - -private: - // Make destroyable only through Release. - ~CConsoleWriter() - { - } -}; - -int wmain() -{ - ComPtr writer = Make(); - HRESULT hr = writer->Log(L"Logger ready."); - return hr; -} - -/* Output: -Logger ready. -*/ -// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.vcxproj deleted file mode 100644 index dc892d0409ed6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.vcxproj +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {15D490A3-C4E9-4429-9831-C4478787B808} - Win32Proj - WRLMake - - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - Create - Create - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.vcxproj.filters deleted file mode 100644 index 3cd5959203d16..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-make/cpp/wrlmake/wrlmake.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/ilogger.idl b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/ilogger.idl deleted file mode 100644 index f54224cbdf695..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/ilogger.idl +++ /dev/null @@ -1,8 +0,0 @@ -import "ocidl.idl"; - -// Prints text to the console. -[uuid(AFDB9683-F18A-4B85-90D1-B6158DAFA46C)] -interface ILogger : IUnknown -{ - HRESULT Log([in] LPCWSTR text); -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/readme.txt b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/readme.txt deleted file mode 100644 index f600b4e563008..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/readme.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : WRLMakeAndInitialize Project Overview -======================================================================== - -AppWizard has created this WRLMakeAndInitialize application for you. - -This file contains a summary of what you will find in each of the files that -make up your WRLMakeAndInitialize application. - - -WRLMakeAndInitialize.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -WRLMakeAndInitialize.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -WRLMakeAndInitialize.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named WRLMakeAndInitialize.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/stdafx.cpp deleted file mode 100644 index 9564794931df2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// WRLMakeAndInitialize.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/stdafx.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/stdafx.h deleted file mode 100644 index b005a839def24..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/targetver.h deleted file mode 100644 index 87c0086de751b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.cpp deleted file mode 100644 index 27618b46fbb04..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// WRLMakeAndInitialize.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include -#include -#include - -#include "ILogger_h.h" - -using namespace Microsoft::WRL; - -// -// Writes logging messages to the console. -class CConsoleWriter : public RuntimeClass, ILogger> -{ -public: - // Initializes the CConsoleWriter object. - // Failure here causes your object to fail construction with the HRESULT you choose. - HRESULT RuntimeClassInitialize(_In_ PCWSTR category) - { - return SHStrDup(category, &m_category); - } - - STDMETHODIMP Log(_In_ PCWSTR text) - { - wprintf_s(L"%s: %s\n", m_category, text); - return S_OK; - } - -private: - PWSTR m_category; - - // Make destroyable only through Release. - ~CConsoleWriter() - { - CoTaskMemFree(m_category); - } -}; -// - -// -int wmain() -{ - ComPtr writer; - HRESULT hr = MakeAndInitialize(&writer, L"INFO"); - if (FAILED(hr)) - { - wprintf_s(L"Object creation failed. Result = 0x%x", hr); - return hr; - } - hr = writer->Log(L"Logger ready."); - return hr; -} - -/* Output: -INFO: Logger ready. -*/ -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.vcxproj deleted file mode 100644 index fb7e9b717c85c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.vcxproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {575A7846-2F27-4DC2-B4F7-D2AB329DD1D7} - Win32Proj - WRLMakeAndInitialize - - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - Use - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - Shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - Shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - Create - Create - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.vcxproj.filters deleted file mode 100644 index 50fce758fd0a5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-logger-makeandinitialize/cpp/wrlmakeandinitialize/wrlmakeandinitialize.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/bufferlock.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/bufferlock.h deleted file mode 100644 index d8eb8efedf8d6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/bufferlock.h +++ /dev/null @@ -1,91 +0,0 @@ -// -#pragma once - -// Locks a video buffer that might or might not support IMF2DBuffer. - -class VideoBufferLock -{ -public: - VideoBufferLock(IMFMediaBuffer *pBuffer) : m_p2DBuffer(nullptr) - { - m_pBuffer = pBuffer; - m_pBuffer->AddRef(); - - // Query for the 2-D buffer interface. OK if this fails. - m_pBuffer->QueryInterface(IID_PPV_ARGS(&m_p2DBuffer)); - } - - ~VideoBufferLock() - { - UnlockBuffer(); - m_pBuffer->Release(); - if (m_p2DBuffer) - { - m_p2DBuffer->Release(); - } - } - - // LockBuffer: - // Locks the buffer. Returns a pointer to scan line 0 and returns the stride. - - // The caller must provide the default stride as an input parameter, in case - // the buffer does not expose IMF2DBuffer. You can calculate the default stride - // from the media type. - - HRESULT LockBuffer( - LONG lDefaultStride, // Minimum stride (with no padding). - DWORD dwHeightInPixels, // Height of the image, in pixels. - BYTE **ppbScanLine0, // Receives a pointer to the start of scan line 0. - LONG *plStride // Receives the actual stride. - ) - { - HRESULT hr = S_OK; - - // Use the 2-D version if available. - if (m_p2DBuffer) - { - hr = m_p2DBuffer->Lock2D(ppbScanLine0, plStride); - } - else - { - // Use non-2D version. - BYTE *pData = nullptr; - - hr = m_pBuffer->Lock(&pData, nullptr, nullptr); - if (SUCCEEDED(hr)) - { - *plStride = lDefaultStride; - if (lDefaultStride < 0) - { - // Bottom-up orientation. Return a pointer to the start of the - // last row *in memory* which is the top row of the image. - *ppbScanLine0 = pData + abs(lDefaultStride) * (dwHeightInPixels - 1); - } - else - { - // Top-down orientation. Return a pointer to the start of the - // buffer. - *ppbScanLine0 = pData; - } - } - } - return hr; - } - - HRESULT UnlockBuffer() - { - if (m_p2DBuffer) - { - return m_p2DBuffer->Unlock2D(); - } - else - { - return m_pBuffer->Unlock(); - } - } - -private: - IMFMediaBuffer *m_pBuffer; - IMF2DBuffer *m_p2DBuffer; -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/dllmain.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/dllmain.cpp deleted file mode 100644 index 8fcd8906a59ad..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/dllmain.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -#include "pch.h" -#include -#include - -using namespace Microsoft::WRL; - -STDAPI_(BOOL) DllMain(_In_ HINSTANCE hInstance, _In_ DWORD reason, _In_opt_ void *reserved) -{ - if (DLL_PROCESS_ATTACH == reason) - { - DisableThreadLibraryCalls(hInstance); - } - return TRUE; -} - -STDAPI DllGetActivationFactory(_In_ HSTRING activatibleClassId, _COM_Outptr_ IActivationFactory **factory) -{ - return Module::GetModule().GetActivationFactory(activatibleClassId, factory); -} - -STDAPI DllCanUnloadNow() -{ - return Module::GetModule().Terminate() ? S_OK : S_FALSE; -} - -STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _COM_Outptr_ void **ppv) -{ - return Module::GetModule().GetClassObject(rclsid, riid, ppv); -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.cpp deleted file mode 100644 index cac3d86ceeb75..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.cpp +++ /dev/null @@ -1,1882 +0,0 @@ -// -#include "pch.h" - -#include "GrayscaleTransform_h.h" -#include "BufferLock.h" - -using namespace Microsoft::WRL; - -// -// * IMPORTANT: If you implement your own MFT, create a new GUID for the CLSID. * -// - -// Configuration attributes - -// {7BBBB051-133B-41F5-B6AA-5AFF9B33A2CB} -GUID const MFT_GRAYSCALE_DESTINATION_RECT = {0x7bbbb051, 0x133b, 0x41f5, 0xb6, 0xaa, 0x5a, 0xff, 0x9b, 0x33, 0xa2, 0xcb}; - -// {14782342-93E8-4565-872C-D9A2973D5CBF} -GUID const MFT_GRAYSCALE_SATURATION = {0x14782342, 0x93e8, 0x4565, 0x87, 0x2c, 0xd9, 0xa2, 0x97, 0x3d, 0x5c, 0xbf}; - -// {E0BADE5D-E4B9-4689-9DBA-E2F00D9CED0E} -GUID const MFT_GRAYSCALE_CHROMA_ROTATION = {0xe0bade5d, 0xe4b9, 0x4689, 0x9d, 0xba, 0xe2, 0xf0, 0xd, 0x9c, 0xed, 0xe}; - -template void SafeRelease(T **ppT) -{ - if (*ppT) - { - (*ppT)->Release(); - *ppT = nullptr; - } -} - -// Function pointer for the function that transforms the image. -typedef void (*IMAGE_TRANSFORM_FN)( - const D2D1::Matrix3x2F& mat, // Chroma transform matrix. - const D2D_RECT_U& rcDest, // Destination rectangle for the transformation. - BYTE* pDest, // Destination buffer. - LONG lDestStride, // Destination stride. - const BYTE* pSrc, // Source buffer. - LONG lSrcStride, // Source stride. - DWORD dwWidthInPixels, // Image width in pixels. - DWORD dwHeightInPixels // Image height in pixels. - ); - -// Implements a grayscale video effect. -class CGrayscale - : public RuntimeClass< - RuntimeClassFlags, - ABI::Windows::Media::IMediaExtension, - IMFTransform> -{ - InspectableClass(RuntimeClass_GrayscaleTransform_GrayscaleEffect, BaseTrust) - -public: - CGrayscale(); - - STDMETHOD(RuntimeClassInitialize)(); - - // IMediaExtension - STDMETHODIMP SetProperties(ABI::Windows::Foundation::Collections::IPropertySet *pConfiguration); - - // IMFTransform - STDMETHODIMP GetStreamLimits( - DWORD *pdwInputMinimum, - DWORD *pdwInputMaximum, - DWORD *pdwOutputMinimum, - DWORD *pdwOutputMaximum - ); - - STDMETHODIMP GetStreamCount( - DWORD *pcInputStreams, - DWORD *pcOutputStreams - ); - - STDMETHODIMP GetStreamIDs( - DWORD dwInputIDArraySize, - DWORD *pdwInputIDs, - DWORD dwOutputIDArraySize, - DWORD *pdwOutputIDs - ); - - STDMETHODIMP GetInputStreamInfo( - DWORD dwInputStreamID, - MFT_INPUT_STREAM_INFO * pStreamInfo - ); - - STDMETHODIMP GetOutputStreamInfo( - DWORD dwOutputStreamID, - MFT_OUTPUT_STREAM_INFO * pStreamInfo - ); - - STDMETHODIMP GetAttributes(IMFAttributes** pAttributes); - - STDMETHODIMP GetInputStreamAttributes( - DWORD dwInputStreamID, - IMFAttributes **ppAttributes - ); - - STDMETHODIMP GetOutputStreamAttributes( - DWORD dwOutputStreamID, - IMFAttributes **ppAttributes - ); - - STDMETHODIMP DeleteInputStream(DWORD dwStreamID); - - STDMETHODIMP AddInputStreams( - DWORD cStreams, - DWORD *adwStreamIDs - ); - - STDMETHODIMP GetInputAvailableType( - DWORD dwInputStreamID, - DWORD dwTypeIndex, // 0-based - IMFMediaType **ppType - ); - - STDMETHODIMP GetOutputAvailableType( - DWORD dwOutputStreamID, - DWORD dwTypeIndex, // 0-based - IMFMediaType **ppType - ); - - STDMETHODIMP SetInputType( - DWORD dwInputStreamID, - IMFMediaType *pType, - DWORD dwFlags - ); - - STDMETHODIMP SetOutputType( - DWORD dwOutputStreamID, - IMFMediaType *pType, - DWORD dwFlags - ); - - STDMETHODIMP GetInputCurrentType( - DWORD dwInputStreamID, - IMFMediaType **ppType - ); - - STDMETHODIMP GetOutputCurrentType( - DWORD dwOutputStreamID, - IMFMediaType **ppType - ); - - STDMETHODIMP GetInputStatus( - DWORD dwInputStreamID, - DWORD *pdwFlags - ); - - STDMETHODIMP GetOutputStatus(DWORD *pdwFlags); - - STDMETHODIMP SetOutputBounds( - LONGLONG hnsLowerBound, - LONGLONG hnsUpperBound - ); - - STDMETHODIMP ProcessEvent( - DWORD dwInputStreamID, - IMFMediaEvent *pEvent - ); - - STDMETHODIMP ProcessMessage( - MFT_MESSAGE_TYPE eMessage, - ULONG_PTR ulParam - ); - - STDMETHODIMP ProcessInput( - DWORD dwInputStreamID, - IMFSample *pSample, - DWORD dwFlags - ); - - STDMETHODIMP ProcessOutput( - DWORD dwFlags, - DWORD cOutputBufferCount, - MFT_OUTPUT_DATA_BUFFER *pOutputSamples, // one per stream - DWORD *pdwStatus - ); - -private: - ~CGrayscale(); - - // HasPendingOutput: Returns TRUE if the MFT is holding an input sample. - BOOL HasPendingOutput() const { return m_pSample != nullptr; } - - // IsValidInputStream: Returns TRUE if dwInputStreamID is a valid input stream identifier. - BOOL IsValidInputStream(DWORD dwInputStreamID) const - { - return dwInputStreamID == 0; - } - - // IsValidOutputStream: Returns TRUE if dwOutputStreamID is a valid output stream identifier. - BOOL IsValidOutputStream(DWORD dwOutputStreamID) const - { - return dwOutputStreamID == 0; - } - - HRESULT OnGetPartialType(DWORD dwTypeIndex, IMFMediaType **ppmt); - HRESULT OnCheckInputType(IMFMediaType *pmt); - HRESULT OnCheckOutputType(IMFMediaType *pmt); - HRESULT OnCheckMediaType(IMFMediaType *pmt); - void OnSetInputType(IMFMediaType *pmt); - void OnSetOutputType(IMFMediaType *pmt); - HRESULT BeginStreaming(); - HRESULT EndStreaming(); - HRESULT OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuffer *pOut); - HRESULT OnFlush(); - HRESULT UpdateFormatInfo(); - - CRITICAL_SECTION m_critSec; - - // Transformation parameters - D2D1::Matrix3x2F m_transform; // Chroma transform matrix. - D2D_RECT_U m_rcDest; // Destination rectangle for the effect. - - // Streaming - bool m_bStreamingInitialized; - IMFSample *m_pSample; // Input sample. - IMFMediaType *m_pInputType; // Input media type. - IMFMediaType *m_pOutputType; // Output media type. - - // Fomat information - UINT32 m_imageWidthInPixels; - UINT32 m_imageHeightInPixels; - DWORD m_cbImageSize; // Image size, in bytes. - - IMFAttributes *m_pAttributes; - - // Image transform function. (Changes based on the media type.) - IMAGE_TRANSFORM_FN m_pTransformFn; -}; -ActivatableClass(CGrayscale); - -#pragma comment(lib, "d2d1") - -/* - -This sample implements a video effect as a Media Foundation transform (MFT). - -The video effect manipulates chroma values in a YUV image. In the default setting, -the entire image is converted to grayscale. Optionally, the application may set any -of the following attributes: - -MFT_GRAYSCALE_DESTINATION_RECT (type = blob, UINT32[4] array) - - Sets the destination rectangle for the effect. Pixels outside the destination - rectangle are not altered. - -MFT_GRAYSCALE_SATURATION (type = double) - - Sets the saturation level. The nominal range is [0...1]. Values beyond 1.0f - result in supersaturated colors. Values below 0.0f create inverted colors. - -MFT_GRAYSCALE_CHROMA_ROTATION (type = double) - - Rotates the chroma values of each pixel. The attribue value is the angle of - rotation in degrees. The result is a shift in hue. - -The effect is implemented by treating the chroma value of each pixel as a vector [u,v], -and applying a transformation matrix to the vector. The saturation parameter is applied -as a scaling transform. - - -NOTES ON THE MFT IMPLEMENTATION - -1. The MFT has fixed streams: One input stream and one output stream. - -2. The MFT supports the following formats: UYVY, YUY2, NV12. - -3. If the MFT is holding an input sample, SetInputType and SetOutputType both fail. - -4. The input and output types must be identical. - -5. If both types are set, no type can be set until the current type is cleared. - -6. Preferred input types: - - (a) If the output type is set, that's the preferred type. - (b) Otherwise, the preferred types are partial types, constructed from the - list of supported subtypes. - -7. Preferred output types: As above. - -8. Streaming: - - The private BeingStreaming() method is called in response to the - MFT_MESSAGE_NOTIFY_BEGIN_STREAMING message. - - If the client does not send MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, the MFT calls - BeginStreaming inside the first call to ProcessInput or ProcessOutput. - - This is a good approach for allocating resources that your MFT requires for - streaming. - -9. The configuration attributes are applied in the BeginStreaming method. If the - client changes the attributes during streaming, the change is ignored until - streaming is stopped (either by changing the media types or by sending the - MFT_MESSAGE_NOTIFY_END_STREAMING message) and then restarted. - -*/ - - -// Video FOURCC codes. -const DWORD FOURCC_YUY2 = '2YUY'; -const DWORD FOURCC_UYVY = 'YVYU'; -const DWORD FOURCC_NV12 = '21VN'; - -// Static array of media types (preferred and accepted). -const GUID g_MediaSubtypes[] = -{ - MFVideoFormat_NV12, - MFVideoFormat_YUY2, - MFVideoFormat_UYVY -}; - -HRESULT GetImageSize(DWORD fcc, UINT32 width, UINT32 height, DWORD* pcbImage); -HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride); -bool ValidateRect(const RECT& rc); - -template -inline T clamp(const T& val, const T& minVal, const T& maxVal) -{ - return (val < minVal ? minVal : (val > maxVal ? maxVal : val)); -} - - -// TransformChroma: -// Apply the transforms to calculate the output chroma values. - -void TransformChroma(const D2D1::Matrix3x2F& mat, BYTE *pu, BYTE *pv) -{ - // Normalize the chroma values to [-112, 112] range - - D2D1_POINT_2F pt = { static_cast(*pu) - 128, static_cast(*pv) - 128 }; - - pt = mat.TransformPoint(pt); - - // Clamp to valid range. - clamp(pt.x, -112.0f, 112.0f); - clamp(pt.y, -112.0f, 112.0f); - - // Map back to [16...240] range. - *pu = static_cast(pt.x + 128.0f); - *pv = static_cast(pt.y + 128.0f); -} - -//------------------------------------------------------------------- -// Functions to convert a YUV images to grayscale. -// -// In all cases, the same transformation is applied to the 8-bit -// chroma values, but the pixel layout in memory differs. -// -// The image conversion functions take the following parameters: -// -// mat Transfomation matrix for chroma values. -// rcDest Destination rectangle. -// pDest Pointer to the destination buffer. -// lDestStride Stride of the destination buffer, in bytes. -// pSrc Pointer to the source buffer. -// lSrcStride Stride of the source buffer, in bytes. -// dwWidthInPixels Frame width in pixels. -// dwHeightInPixels Frame height, in pixels. -//------------------------------------------------------------------- - -// Convert UYVY image. - -void TransformImage_UYVY( - const D2D1::Matrix3x2F& mat, - const D2D_RECT_U& rcDest, - _Inout_updates_(_Inexpressible_(lDestStride * dwHeightInPixels)) BYTE *pDest, - _In_ LONG lDestStride, - _In_reads_(_Inexpressible_(lSrcStride * dwHeightInPixels)) const BYTE* pSrc, - _In_ LONG lSrcStride, - _In_ DWORD dwWidthInPixels, - _In_ DWORD dwHeightInPixels) -{ - DWORD y = 0; - const DWORD y0 = min(rcDest.bottom, dwHeightInPixels); - - // Lines above the destination rectangle. - for ( ; y < rcDest.top; y++) - { - memcpy(pDest, pSrc, dwWidthInPixels * 2); - pSrc += lSrcStride; - pDest += lDestStride; - } - - // Lines within the destination rectangle. - for ( ; y < y0; y++) - { - WORD *pSrc_Pixel = (WORD*)pSrc; - WORD *pDest_Pixel = (WORD*)pDest; - - for (DWORD x = 0; (x + 1) < dwWidthInPixels; x += 2) - { - // Byte order is U0 Y0 V0 Y1 - // Each WORD is a byte pair (U/V, Y) - // Windows is little-endian so the order appears reversed. - - if (x >= rcDest.left && x < rcDest.right) - { - BYTE u = pSrc_Pixel[x] & 0x00FF; - BYTE v = pSrc_Pixel[x+1] & 0x00FF; - - TransformChroma(mat, &u, &v); - - pDest_Pixel[x] = (pSrc_Pixel[x] & 0xFF00) | u; - pDest_Pixel[x+1] = (pSrc_Pixel[x+1] & 0xFF00) | v; - } - else - { -#pragma warning(push) -#pragma warning(disable: 6385) -#pragma warning(disable: 6386) - pDest_Pixel[x] = pSrc_Pixel[x]; - pDest_Pixel[x+1] = pSrc_Pixel[x+1]; -#pragma warning(pop) - } - } - - pDest += lDestStride; - pSrc += lSrcStride; - } - - // Lines below the destination rectangle. - for ( ; y < dwHeightInPixels; y++) - { - memcpy(pDest, pSrc, dwWidthInPixels * 2); - pSrc += lSrcStride; - pDest += lDestStride; - } -} - - -// Convert YUY2 image. - -void TransformImage_YUY2( - const D2D1::Matrix3x2F& mat, - const D2D_RECT_U& rcDest, - _Inout_updates_(_Inexpressible_(lDestStride * dwHeightInPixels)) BYTE *pDest, - _In_ LONG lDestStride, - _In_reads_(_Inexpressible_(lSrcStride * dwHeightInPixels)) const BYTE* pSrc, - _In_ LONG lSrcStride, - _In_ DWORD dwWidthInPixels, - _In_ DWORD dwHeightInPixels) -{ - DWORD y = 0; - const DWORD y0 = min(rcDest.bottom, dwHeightInPixels); - - // Lines above the destination rectangle. - for ( ; y < rcDest.top; y++) - { - memcpy(pDest, pSrc, dwWidthInPixels * 2); - pSrc += lSrcStride; - pDest += lDestStride; - } - - // Lines within the destination rectangle. - for ( ; y < y0; y++) - { - WORD *pSrc_Pixel = (WORD*)pSrc; - WORD *pDest_Pixel = (WORD*)pDest; - - for (DWORD x = 0; (x + 1) < dwWidthInPixels; x += 2) - { - // Byte order is Y0 U0 Y1 V0 - // Each WORD is a byte pair (Y, U/V) - // Windows is little-endian so the order appears reversed. - - if (x >= rcDest.left && x < rcDest.right) - { - BYTE u = pSrc_Pixel[x] >> 8; - BYTE v = pSrc_Pixel[x+1] >> 8; - - TransformChroma(mat, &u, &v); - - pDest_Pixel[x] = (pSrc_Pixel[x] & 0x00FF) | (u<<8); - pDest_Pixel[x+1] = (pSrc_Pixel[x+1] & 0x00FF) | (v<<8); - } - else - { -#pragma warning(push) -#pragma warning(disable: 6385) -#pragma warning(disable: 6386) - pDest_Pixel[x] = pSrc_Pixel[x]; - pDest_Pixel[x+1] = pSrc_Pixel[x+1]; -#pragma warning(pop) - } - } - pDest += lDestStride; - pSrc += lSrcStride; - } - - // Lines below the destination rectangle. - for ( ; y < dwHeightInPixels; y++) - { - memcpy(pDest, pSrc, dwWidthInPixels * 2); - pSrc += lSrcStride; - pDest += lDestStride; - } -} - -// Convert NV12 image - -void TransformImage_NV12( - const D2D1::Matrix3x2F& mat, - const D2D_RECT_U& rcDest, - _Inout_updates_(_Inexpressible_(2 * lDestStride * dwHeightInPixels)) BYTE *pDest, - _In_ LONG lDestStride, - _In_reads_(_Inexpressible_(2 * lSrcStride * dwHeightInPixels)) const BYTE* pSrc, - _In_ LONG lSrcStride, - _In_ DWORD dwWidthInPixels, - _In_ DWORD dwHeightInPixels) -{ - // NV12 is planar: Y plane, followed by packed U-V plane. - - // Y plane - for (DWORD y = 0; y < dwHeightInPixels; y++) - { - CopyMemory(pDest, pSrc, dwWidthInPixels); - pDest += lDestStride; - pSrc += lSrcStride; - } - - // U-V plane - - // NOTE: The U-V plane has 1/2 the number of lines as the Y plane. - - // Lines above the destination rectangle. - DWORD y = 0; - const DWORD y0 = min(rcDest.bottom, dwHeightInPixels); - - for ( ; y < rcDest.top/2; y++) - { - memcpy(pDest, pSrc, dwWidthInPixels); - pSrc += lSrcStride; - pDest += lDestStride; - } - - // Lines within the destination rectangle. - for ( ; y < y0/2; y++) - { - for (DWORD x = 0; (x + 1) < dwWidthInPixels; x += 2) - { - if (x >= rcDest.left && x < rcDest.right) - { - BYTE u = pSrc[x]; - BYTE v = pSrc[x+1]; - - TransformChroma(mat, &u, &v); - - pDest[x] = u; - pDest[x+1] = v; - } - else - { - pDest[x] = pSrc[x]; - pDest[x+1] = pSrc[x+1]; - } - } - pDest += lDestStride; - pSrc += lSrcStride; - } - - // Lines below the destination rectangle. - for ( ; y < dwHeightInPixels/2; y++) - { - memcpy(pDest, pSrc, dwWidthInPixels); - pSrc += lSrcStride; - pDest += lDestStride; - } -} - -CGrayscale::CGrayscale() : - m_pSample(nullptr), m_pInputType(nullptr), m_pOutputType(nullptr), m_pTransformFn(nullptr), - m_imageWidthInPixels(0), m_imageHeightInPixels(0), m_cbImageSize(0), - m_transform(D2D1::Matrix3x2F::Identity()), m_rcDest(D2D1::RectU()), m_bStreamingInitialized(false), - m_pAttributes(nullptr) -{ - InitializeCriticalSectionEx(&m_critSec, 3000, 0); -} - -CGrayscale::~CGrayscale() -{ - SafeRelease(&m_pInputType); - SafeRelease(&m_pOutputType); - SafeRelease(&m_pSample); - SafeRelease(&m_pAttributes); - DeleteCriticalSection(&m_critSec); -} - -// Initialize the instance. -STDMETHODIMP CGrayscale::RuntimeClassInitialize() -{ - // Create the attribute store. - return MFCreateAttributes(&m_pAttributes, 3); -} - -// IMediaExtension methods - -//------------------------------------------------------------------- -// SetProperties -// Sets the configuration of the effect -//------------------------------------------------------------------- -HRESULT CGrayscale::SetProperties(ABI::Windows::Foundation::Collections::IPropertySet *pConfiguration) -{ - return S_OK; -} - -// IMFTransform methods. Refer to the Media Foundation SDK documentation for details. - -//------------------------------------------------------------------- -// GetStreamLimits -// Returns the minimum and maximum number of streams. -//------------------------------------------------------------------- - -HRESULT CGrayscale::GetStreamLimits( - DWORD *pdwInputMinimum, - DWORD *pdwInputMaximum, - DWORD *pdwOutputMinimum, - DWORD *pdwOutputMaximum -) -{ - // This MFT has a fixed number of streams. - *pdwInputMinimum = 1; - *pdwInputMaximum = 1; - *pdwOutputMinimum = 1; - *pdwOutputMaximum = 1; - return S_OK; -} - -// Returns the actual number of streams. - -HRESULT CGrayscale::GetStreamCount( - DWORD *pcInputStreams, - DWORD *pcOutputStreams -) -{ - // This MFT has a fixed number of streams. - *pcInputStreams = 1; - *pcOutputStreams = 1; - return S_OK; -} - - - -//------------------------------------------------------------------- -// GetStreamIDs -// Returns stream IDs for the input and output streams. -//------------------------------------------------------------------- - -HRESULT CGrayscale::GetStreamIDs( - DWORD dwInputIDArraySize, - DWORD *pdwInputIDs, - DWORD dwOutputIDArraySize, - DWORD *pdwOutputIDs -) -{ - // It is not required to implement this method if the MFT has a fixed number of - // streams AND the stream IDs are numbered sequentially from zero (that is, the - // stream IDs match the stream indexes). - - // In that case, it is OK to return E_NOTIMPL. - return E_NOTIMPL; -} - - -//------------------------------------------------------------------- -// GetInputStreamInfo -// Returns information about an input stream. -//------------------------------------------------------------------- - -HRESULT CGrayscale::GetInputStreamInfo( - DWORD dwInputStreamID, - MFT_INPUT_STREAM_INFO * pStreamInfo -) -{ - EnterCriticalSection(&m_critSec); - - if (!IsValidInputStream(dwInputStreamID)) - { - LeaveCriticalSection(&m_critSec); - return MF_E_INVALIDSTREAMNUMBER; - } - - // NOTE: This method should succeed even when there is no media type on the - // stream. If there is no media type, we only need to fill in the dwFlags - // member of MFT_INPUT_STREAM_INFO. The other members depend on having a - // a valid media type. - - pStreamInfo->hnsMaxLatency = 0; - pStreamInfo->dwFlags = MFT_INPUT_STREAM_WHOLE_SAMPLES | MFT_INPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER; - - if (m_pInputType == nullptr) - { - pStreamInfo->cbSize = 0; - } - else - { - pStreamInfo->cbSize = m_cbImageSize; - } - - pStreamInfo->cbMaxLookahead = 0; - pStreamInfo->cbAlignment = 0; - - LeaveCriticalSection(&m_critSec); - return S_OK; -} - -//------------------------------------------------------------------- -// GetOutputStreamInfo -// Returns information about an output stream. -//------------------------------------------------------------------- - -HRESULT CGrayscale::GetOutputStreamInfo( - DWORD dwOutputStreamID, - MFT_OUTPUT_STREAM_INFO * pStreamInfo -) -{ - EnterCriticalSection(&m_critSec); - - if (!IsValidOutputStream(dwOutputStreamID)) - { - LeaveCriticalSection(&m_critSec); - return MF_E_INVALIDSTREAMNUMBER; - } - - // NOTE: This method should succeed even when there is no media type on the - // stream. If there is no media type, we only need to fill in the dwFlags - // member of MFT_OUTPUT_STREAM_INFO. The other members depend on having a - // a valid media type. - - pStreamInfo->dwFlags = - MFT_OUTPUT_STREAM_WHOLE_SAMPLES | - MFT_OUTPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER | - MFT_OUTPUT_STREAM_FIXED_SAMPLE_SIZE ; - - if (m_pOutputType == nullptr) - { - pStreamInfo->cbSize = 0; - } - else - { - pStreamInfo->cbSize = m_cbImageSize; - } - - pStreamInfo->cbAlignment = 0; - - LeaveCriticalSection(&m_critSec); - return S_OK; -} - -// Returns the attributes for the MFT. -HRESULT CGrayscale::GetAttributes(IMFAttributes** ppAttributes) -{ - EnterCriticalSection(&m_critSec); - - *ppAttributes = m_pAttributes; - (*ppAttributes)->AddRef(); - - LeaveCriticalSection(&m_critSec); - return S_OK; -} - -// Returns stream-level attributes for an input stream. - -HRESULT CGrayscale::GetInputStreamAttributes( - DWORD dwInputStreamID, - IMFAttributes **ppAttributes -) -{ - // This MFT does not support any stream-level attributes, so the method is not implemented. - return E_NOTIMPL; -} - - -//------------------------------------------------------------------- -// GetOutputStreamAttributes -// Returns stream-level attributes for an output stream. -//------------------------------------------------------------------- - -HRESULT CGrayscale::GetOutputStreamAttributes( - DWORD dwOutputStreamID, - IMFAttributes **ppAttributes -) -{ - // This MFT does not support any stream-level attributes, so the method is not implemented. - return E_NOTIMPL; -} - - -//------------------------------------------------------------------- -// DeleteInputStream -//------------------------------------------------------------------- - -HRESULT CGrayscale::DeleteInputStream(DWORD dwStreamID) -{ - // This MFT has a fixed number of input streams, so the method is not supported. - return E_NOTIMPL; -} - - -//------------------------------------------------------------------- -// AddInputStreams -//------------------------------------------------------------------- - -HRESULT CGrayscale::AddInputStreams( - DWORD cStreams, - DWORD *adwStreamIDs -) -{ - // This MFT has a fixed number of output streams, so the method is not supported. - return E_NOTIMPL; -} - - -//------------------------------------------------------------------- -// GetInputAvailableType -// Returns a preferred input type. -//------------------------------------------------------------------- - -HRESULT CGrayscale::GetInputAvailableType( - DWORD dwInputStreamID, - DWORD dwTypeIndex, // 0-based - IMFMediaType **ppType -) -{ - EnterCriticalSection(&m_critSec); - - if (!IsValidInputStream(dwInputStreamID)) - { - LeaveCriticalSection(&m_critSec); - return MF_E_INVALIDSTREAMNUMBER; - } - - HRESULT hr = S_OK; - - // If the output type is set, return that type as our preferred input type. - if (m_pOutputType == nullptr) - { - // The output type is not set. Create a partial media type. - hr = OnGetPartialType(dwTypeIndex, ppType); - } - else if (dwTypeIndex > 0) - { - hr = MF_E_NO_MORE_TYPES; - } - else - { - *ppType = m_pOutputType; - (*ppType)->AddRef(); - } - - LeaveCriticalSection(&m_critSec); - return hr; -} - -// Returns a preferred output type. - -HRESULT CGrayscale::GetOutputAvailableType( - DWORD dwOutputStreamID, - DWORD dwTypeIndex, // 0-based - IMFMediaType **ppType -) -{ - EnterCriticalSection(&m_critSec); - - if (!IsValidOutputStream(dwOutputStreamID)) - { - LeaveCriticalSection(&m_critSec); - return MF_E_INVALIDSTREAMNUMBER; - } - - HRESULT hr = S_OK; - - if (m_pInputType == nullptr) - { - // The input type is not set. Create a partial media type. - hr = OnGetPartialType(dwTypeIndex, ppType); - } - else if (dwTypeIndex > 0) - { - hr = MF_E_NO_MORE_TYPES; - } - else - { - *ppType = m_pInputType; - (*ppType)->AddRef(); - } - - LeaveCriticalSection(&m_critSec); - return hr; -} - -HRESULT CGrayscale::SetInputType( - DWORD dwInputStreamID, - IMFMediaType *pType, // Can be nullptr to clear the input type. - DWORD dwFlags -) -{ - // Validate flags. - if (dwFlags & ~MFT_SET_TYPE_TEST_ONLY) - { - return E_INVALIDARG; - } - - EnterCriticalSection(&m_critSec); - - if (!IsValidInputStream(dwInputStreamID)) - { - LeaveCriticalSection(&m_critSec); - return MF_E_INVALIDSTREAMNUMBER; - } - - HRESULT hr = S_OK; - - // Does the caller want us to set the type, or just test it? - BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0); - - // If we have an input sample, the client cannot change the type now. - if (HasPendingOutput()) - { - hr = MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING; - goto done; - } - - // Validate the type, if non-nullptr. - if (pType) - { - hr = OnCheckInputType(pType); - if (FAILED(hr)) - { - goto done; - } - } - - // The type is OK. Set the type, unless the caller was just testing. - if (bReallySet) - { - OnSetInputType(pType); - - // When the type changes, end streaming. - hr = EndStreaming(); - } - -done: - LeaveCriticalSection(&m_critSec); - return hr; -} - -HRESULT CGrayscale::SetOutputType( - DWORD dwOutputStreamID, - IMFMediaType *pType, // Can be nullptr to clear the output type. - DWORD dwFlags -) -{ - // Validate flags. - if (dwFlags & ~MFT_SET_TYPE_TEST_ONLY) - { - return E_INVALIDARG; - } - - EnterCriticalSection(&m_critSec); - - if (!IsValidOutputStream(dwOutputStreamID)) - { - LeaveCriticalSection(&m_critSec); - return MF_E_INVALIDSTREAMNUMBER; - } - - HRESULT hr = S_OK; - - // Does the caller want us to set the type, or just test it? - BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0); - - // If we have an input sample, the client cannot change the type now. - if (HasPendingOutput()) - { - hr = MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING; - goto done; - } - - // Validate the type, if non-nullptr. - if (pType) - { - hr = OnCheckOutputType(pType); - if (FAILED(hr)) - { - goto done; - } - } - - // The type is OK. Set the type, unless the caller was just testing. - if (bReallySet) - { - OnSetOutputType(pType); - - // When the type changes, end streaming. - hr = EndStreaming(); - } - -done: - LeaveCriticalSection(&m_critSec); - return hr; -} - -// Returns the current input type. - -HRESULT CGrayscale::GetInputCurrentType( - DWORD dwInputStreamID, - IMFMediaType **ppType -) -{ - HRESULT hr = S_OK; - - EnterCriticalSection(&m_critSec); - - if (!IsValidInputStream(dwInputStreamID)) - { - hr = MF_E_INVALIDSTREAMNUMBER; - } - else if (!m_pInputType) - { - hr = MF_E_TRANSFORM_TYPE_NOT_SET; - } - else - { - *ppType = m_pInputType; - (*ppType)->AddRef(); - } - LeaveCriticalSection(&m_critSec); - return hr; -} - -// Returns the current output type. - -HRESULT CGrayscale::GetOutputCurrentType( - DWORD dwOutputStreamID, - IMFMediaType **ppType -) -{ - HRESULT hr = S_OK; - - EnterCriticalSection(&m_critSec); - - if (!IsValidOutputStream(dwOutputStreamID)) - { - hr = MF_E_INVALIDSTREAMNUMBER; - } - else if (!m_pOutputType) - { - hr = MF_E_TRANSFORM_TYPE_NOT_SET; - } - else - { - *ppType = m_pOutputType; - (*ppType)->AddRef(); - } - - LeaveCriticalSection(&m_critSec); - return hr; -} - -// Query if the MFT is accepting more input. - -HRESULT CGrayscale::GetInputStatus( - DWORD dwInputStreamID, - DWORD *pdwFlags -) -{ - EnterCriticalSection(&m_critSec); - - if (!IsValidInputStream(dwInputStreamID)) - { - LeaveCriticalSection(&m_critSec); - return MF_E_INVALIDSTREAMNUMBER; - } - - // If an input sample is already queued, do not accept another sample until the - // client calls ProcessOutput or Flush. - - // NOTE: It is possible for an MFT to accept more than one input sample. For - // example, this might be required in a video decoder if the frames do not - // arrive in temporal order. In the case, the decoder must hold a queue of - // samples. For the video effect, each sample is transformed independently, so - // there is no reason to queue multiple input samples. - - if (m_pSample == nullptr) - { - *pdwFlags = MFT_INPUT_STATUS_ACCEPT_DATA; - } - else - { - *pdwFlags = 0; - } - - LeaveCriticalSection(&m_critSec); - return S_OK; -} - -// Query if the MFT can produce output. - -HRESULT CGrayscale::GetOutputStatus(DWORD *pdwFlags) -{ - EnterCriticalSection(&m_critSec); - - // The MFT can produce an output sample if (and only if) there an input sample. - if (m_pSample != nullptr) - { - *pdwFlags = MFT_OUTPUT_STATUS_SAMPLE_READY; - } - else - { - *pdwFlags = 0; - } - - LeaveCriticalSection(&m_critSec); - return S_OK; -} - - -//------------------------------------------------------------------- -// SetOutputBounds -// Sets the range of time stamps that the MFT will output. -//------------------------------------------------------------------- - -HRESULT CGrayscale::SetOutputBounds( - LONGLONG hnsLowerBound, - LONGLONG hnsUpperBound -) -{ - // Implementation of this method is optional. - return E_NOTIMPL; -} - - -//------------------------------------------------------------------- -// ProcessEvent -// Sends an event to an input stream. -//------------------------------------------------------------------- - -HRESULT CGrayscale::ProcessEvent( - DWORD dwInputStreamID, - IMFMediaEvent *pEvent -) -{ - // This MFT does not handle any stream events, so the method can - // return E_NOTIMPL. This tells the pipeline that it can stop - // sending any more events to this MFT. - return E_NOTIMPL; -} - - -//------------------------------------------------------------------- -// ProcessMessage -//------------------------------------------------------------------- - -HRESULT CGrayscale::ProcessMessage( - MFT_MESSAGE_TYPE eMessage, - ULONG_PTR ulParam -) -{ - EnterCriticalSection(&m_critSec); - - HRESULT hr = S_OK; - - switch (eMessage) - { - case MFT_MESSAGE_COMMAND_FLUSH: - // Flush the MFT. - hr = OnFlush(); - break; - - case MFT_MESSAGE_COMMAND_DRAIN: - // Drain: Tells the MFT to reject further input until all pending samples are - // processed. That is our default behavior already, so there is nothing to do. - // - // For a decoder that accepts a queue of samples, the MFT might need to drain - // the queue in response to this command. - break; - - case MFT_MESSAGE_SET_D3D_MANAGER: - // Sets a pointer to the IDirect3DDeviceManager9 interface. - - // The pipeline should never send this message unless the MFT sets the MF_SA_D3D_AWARE - // attribute set to TRUE. Because this MFT does not set MF_SA_D3D_AWARE, it is an error - // to send the MFT_MESSAGE_SET_D3D_MANAGER message to the MFT. Return an error code in - // this case. - - // NOTE: If this MFT were D3D-enabled, it would cache the IDirect3DDeviceManager9 - // pointer for use during streaming. - - hr = E_NOTIMPL; - break; - - case MFT_MESSAGE_NOTIFY_BEGIN_STREAMING: - hr = BeginStreaming(); - break; - - case MFT_MESSAGE_NOTIFY_END_STREAMING: - hr = EndStreaming(); - break; - - // The next two messages do not require any action from this MFT. - - case MFT_MESSAGE_NOTIFY_END_OF_STREAM: - break; - - case MFT_MESSAGE_NOTIFY_START_OF_STREAM: - break; - } - - LeaveCriticalSection(&m_critSec); - return hr; -} - -// Process an input sample. - -HRESULT CGrayscale::ProcessInput( - DWORD dwInputStreamID, - IMFSample *pSample, - DWORD dwFlags -) -{ - if (dwFlags != 0) - { - return E_INVALIDARG; // dwFlags is reserved and must be zero. - } - - HRESULT hr = S_OK; - - EnterCriticalSection(&m_critSec); - - // Validate the input stream number. - if (!IsValidInputStream(dwInputStreamID)) - { - hr = MF_E_INVALIDSTREAMNUMBER; - goto done; - } - - // Check for valid media types. - // The client must set input and output types before calling ProcessInput. - if (!m_pInputType || !m_pOutputType) - { - hr = MF_E_NOTACCEPTING; - goto done; - } - - // Check if an input sample is already queued. - if (m_pSample != nullptr) - { - hr = MF_E_NOTACCEPTING; // We already have an input sample. - goto done; - } - - // Initialize streaming. - hr = BeginStreaming(); - if (FAILED(hr)) - { - goto done; - } - - // Cache the sample. We do the actual work in ProcessOutput. - m_pSample = pSample; - pSample->AddRef(); // Hold a reference count on the sample. - -done: - LeaveCriticalSection(&m_critSec); - return hr; -} - - -//------------------------------------------------------------------- -// ProcessOutput -// Process an output sample. -//------------------------------------------------------------------- - -HRESULT CGrayscale::ProcessOutput( - DWORD dwFlags, - DWORD cOutputBufferCount, - MFT_OUTPUT_DATA_BUFFER *pOutputSamples, // one per stream - DWORD *pdwStatus -) -{ - // Check input parameters... - - // This MFT does not accept any flags for the dwFlags parameter. - - // The only defined flag is MFT_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER. This flag - // applies only when the MFT marks an output stream as lazy or optional. But this - // MFT has no lazy or optional streams, so the flag is not valid. - - if (dwFlags != 0) - { - return E_INVALIDARG; - } - - // There must be exactly one output buffer. - if (cOutputBufferCount != 1) - { - return E_INVALIDARG; - } - - // It must contain a sample. - if (pOutputSamples[0].pSample == nullptr) - { - return E_INVALIDARG; - } - - HRESULT hr = S_OK; - - IMFMediaBuffer *pInput = nullptr; - IMFMediaBuffer *pOutput = nullptr; - - EnterCriticalSection(&m_critSec); - - // There must be an input sample available for processing. - if (m_pSample == nullptr) - { - hr = MF_E_TRANSFORM_NEED_MORE_INPUT; - goto done; - } - - // Initialize streaming. - - hr = BeginStreaming(); - if (FAILED(hr)) - { - goto done; - } - - // Get the input buffer. - hr = m_pSample->ConvertToContiguousBuffer(&pInput); - if (FAILED(hr)) - { - goto done; - } - - // Get the output buffer. - hr = pOutputSamples[0].pSample->ConvertToContiguousBuffer(&pOutput); - if (FAILED(hr)) - { - goto done; - } - - hr = OnProcessOutput(pInput, pOutput); - if (FAILED(hr)) - { - goto done; - } - - // Set status flags. - pOutputSamples[0].dwStatus = 0; - *pdwStatus = 0; - - - // Copy the duration and time stamp from the input sample, if present. - - LONGLONG hnsDuration = 0; - LONGLONG hnsTime = 0; - - if (SUCCEEDED(m_pSample->GetSampleDuration(&hnsDuration))) - { - hr = pOutputSamples[0].pSample->SetSampleDuration(hnsDuration); - if (FAILED(hr)) - { - goto done; - } - } - - if (SUCCEEDED(m_pSample->GetSampleTime(&hnsTime))) - { - hr = pOutputSamples[0].pSample->SetSampleTime(hnsTime); - } - -done: - SafeRelease(&m_pSample); // Release our input sample. - SafeRelease(&pInput); - SafeRelease(&pOutput); - LeaveCriticalSection(&m_critSec); - return hr; -} - -// PRIVATE METHODS - -// All methods that follow are private to this MFT and are not part of the IMFTransform interface. - -// Create a partial media type from our list. -// -// dwTypeIndex: Index into the list of peferred media types. -// ppmt: Receives a pointer to the media type. - -HRESULT CGrayscale::OnGetPartialType(DWORD dwTypeIndex, IMFMediaType **ppmt) -{ - if (dwTypeIndex >= ARRAYSIZE(g_MediaSubtypes)) - { - return MF_E_NO_MORE_TYPES; - } - - IMFMediaType *pmt = nullptr; - - HRESULT hr = MFCreateMediaType(&pmt); - if (FAILED(hr)) - { - goto done; - } - - hr = pmt->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); - if (FAILED(hr)) - { - goto done; - } - - hr = pmt->SetGUID(MF_MT_SUBTYPE, g_MediaSubtypes[dwTypeIndex]); - if (FAILED(hr)) - { - goto done; - } - - *ppmt = pmt; - (*ppmt)->AddRef(); - -done: - SafeRelease(&pmt); - return hr; -} - -// Validate an input media type. - -HRESULT CGrayscale::OnCheckInputType(IMFMediaType *pmt) -{ - assert(pmt != nullptr); - - HRESULT hr = S_OK; - - // If the output type is set, see if they match. - if (m_pOutputType != nullptr) - { - DWORD flags = 0; - hr = pmt->IsEqual(m_pOutputType, &flags); - - // IsEqual can return S_FALSE. Treat this as failure. - if (hr != S_OK) - { - hr = MF_E_INVALIDMEDIATYPE; - } - } - else - { - // Output type is not set. Just check this type. - hr = OnCheckMediaType(pmt); - } - return hr; -} - -// Validate an output media type. - -HRESULT CGrayscale::OnCheckOutputType(IMFMediaType *pmt) -{ - assert(pmt != nullptr); - - HRESULT hr = S_OK; - - // If the input type is set, see if they match. - if (m_pInputType != nullptr) - { - DWORD flags = 0; - hr = pmt->IsEqual(m_pInputType, &flags); - - // IsEqual can return S_FALSE. Treat this as failure. - if (hr != S_OK) - { - hr = MF_E_INVALIDMEDIATYPE; - } - - } - else - { - // Input type is not set. Just check this type. - hr = OnCheckMediaType(pmt); - } - return hr; -} - - -// Validate a media type (input or output) - -HRESULT CGrayscale::OnCheckMediaType(IMFMediaType *pmt) -{ - BOOL bFoundMatchingSubtype = FALSE; - - // Major type must be video. - GUID major_type; - HRESULT hr = pmt->GetGUID(MF_MT_MAJOR_TYPE, &major_type); - if (FAILED(hr)) - { - goto done; - } - - if (major_type != MFMediaType_Video) - { - hr = MF_E_INVALIDMEDIATYPE; - goto done; - } - - // Subtype must be one of the subtypes in our global list. - - // Get the subtype GUID. - GUID subtype; - hr = pmt->GetGUID(MF_MT_SUBTYPE, &subtype); - if (FAILED(hr)) - { - goto done; - } - - // Look for the subtype in our list of accepted types. - for (DWORD i = 0; i < ARRAYSIZE(g_MediaSubtypes); i++) - { - if (subtype == g_MediaSubtypes[i]) - { - bFoundMatchingSubtype = TRUE; - break; - } - } - - if (!bFoundMatchingSubtype) - { - hr = MF_E_INVALIDMEDIATYPE; // The MFT does not support this subtype. - goto done; - } - - // Reject single-field media types. - UINT32 interlace = MFGetAttributeUINT32(pmt, MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive); - if (interlace == MFVideoInterlace_FieldSingleUpper || interlace == MFVideoInterlace_FieldSingleLower) - { - hr = MF_E_INVALIDMEDIATYPE; - } - -done: - return hr; -} - - -// Set or clear the input media type. -// -// Prerequisite: The input type was already validated. - -void CGrayscale::OnSetInputType(IMFMediaType *pmt) -{ - // if pmt is nullptr, clear the type. - // if pmt is non-nullptr, set the type. - - SafeRelease(&m_pInputType); - m_pInputType = pmt; - if (m_pInputType) - { - m_pInputType->AddRef(); - } - - // Update the format information. - UpdateFormatInfo(); -} - - -// Set or clears the output media type. -// -// Prerequisite: The output type was already validated. - -void CGrayscale::OnSetOutputType(IMFMediaType *pmt) -{ - // If pmt is nullptr, clear the type. Otherwise, set the type. - - SafeRelease(&m_pOutputType); - m_pOutputType = pmt; - if (m_pOutputType) - { - m_pOutputType->AddRef(); - } -} - - -// Initialize streaming parameters. -// -// This method is called if the client sends the MFT_MESSAGE_NOTIFY_BEGIN_STREAMING -// message, or when the client processes a sample, whichever happens first. - -HRESULT CGrayscale::BeginStreaming() -{ - HRESULT hr = S_OK; - - if (!m_bStreamingInitialized) - { - // Get the configuration attributes. - - // Get the destination rectangle. - - RECT rcDest; - hr = m_pAttributes->GetBlob(MFT_GRAYSCALE_DESTINATION_RECT, (UINT8*)&rcDest, sizeof(rcDest), nullptr); - if (hr == MF_E_ATTRIBUTENOTFOUND || !ValidateRect(rcDest)) - { - // The client did not set this attribute, or the client provided an invalid rectangle. - // Default to the entire image. - - m_rcDest = D2D1::RectU(0, 0, m_imageWidthInPixels, m_imageHeightInPixels); - hr = S_OK; - } - else if (SUCCEEDED(hr)) - { - m_rcDest = D2D1::RectU(rcDest.left, rcDest.top, rcDest.right, rcDest.bottom); - } - else - { - goto done; - } - - // Get the chroma transformations. - - float scale = (float)MFGetAttributeDouble(m_pAttributes, MFT_GRAYSCALE_SATURATION, 0.0f); - float angle = (float)MFGetAttributeDouble(m_pAttributes, MFT_GRAYSCALE_CHROMA_ROTATION, 0.0f); - - m_transform = D2D1::Matrix3x2F::Scale(scale, scale) * D2D1::Matrix3x2F::Rotation(angle); - - m_bStreamingInitialized = true; - } - -done: - return hr; -} - - -// End streaming. - -// This method is called if the client sends an MFT_MESSAGE_NOTIFY_END_STREAMING -// message, or when the media type changes. In general, it should be called whenever -// the streaming parameters need to be reset. - -HRESULT CGrayscale::EndStreaming() -{ - m_bStreamingInitialized = false; - return S_OK; -} - - - -// Generate output data. - -HRESULT CGrayscale::OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuffer *pOut) -{ - BYTE *pDest = nullptr; // Destination buffer. - LONG lDestStride = 0; // Destination stride. - - BYTE *pSrc = nullptr; // Source buffer. - LONG lSrcStride = 0; // Source stride. - - // Helper objects to lock the buffers. - VideoBufferLock inputLock(pIn); - VideoBufferLock outputLock(pOut); - - // Stride if the buffer does not support IMF2DBuffer - LONG lDefaultStride = 0; - - HRESULT hr = GetDefaultStride(m_pInputType, &lDefaultStride); - if (FAILED(hr)) - { - goto done; - } - - // Lock the input buffer. - hr = inputLock.LockBuffer(lDefaultStride, m_imageHeightInPixels, &pSrc, &lSrcStride); - if (FAILED(hr)) - { - goto done; - } - - // Lock the output buffer. - hr = outputLock.LockBuffer(lDefaultStride, m_imageHeightInPixels, &pDest, &lDestStride); - if (FAILED(hr)) - { - goto done; - } - - // Invoke the image transform function. - assert (m_pTransformFn != nullptr); - if (m_pTransformFn) - { - (*m_pTransformFn)(m_transform, m_rcDest, pDest, lDestStride, pSrc, lSrcStride, - m_imageWidthInPixels, m_imageHeightInPixels); - } - else - { - hr = E_UNEXPECTED; - goto done; - } - - - // Set the data size on the output buffer. - hr = pOut->SetCurrentLength(m_cbImageSize); - - // The VideoBufferLock class automatically unlocks the buffers. -done: - return hr; -} - - -// Flush the MFT. - -HRESULT CGrayscale::OnFlush() -{ - // For this MFT, flushing just means releasing the input sample. - SafeRelease(&m_pSample); - return S_OK; -} - -// Update the format information. This method is called whenever the -// input type is set. - -HRESULT CGrayscale::UpdateFormatInfo() -{ - HRESULT hr = S_OK; - - GUID subtype = GUID_NULL; - - m_imageWidthInPixels = 0; - m_imageHeightInPixels = 0; - m_cbImageSize = 0; - - m_pTransformFn = nullptr; - - if (m_pInputType != nullptr) - { - hr = m_pInputType->GetGUID(MF_MT_SUBTYPE, &subtype); - if (FAILED(hr)) - { - goto done; - } - if (subtype == MFVideoFormat_YUY2) - { - m_pTransformFn = TransformImage_YUY2; - } - else if (subtype == MFVideoFormat_UYVY) - { - m_pTransformFn = TransformImage_UYVY; - } - else if (subtype == MFVideoFormat_NV12) - { - m_pTransformFn = TransformImage_NV12; - } - else - { - hr = E_UNEXPECTED; - goto done; - } - - hr = MFGetAttributeSize(m_pInputType, MF_MT_FRAME_SIZE, &m_imageWidthInPixels, &m_imageHeightInPixels); - if (FAILED(hr)) - { - goto done; - } - - // Calculate the image size (not including padding) - hr = GetImageSize(subtype.Data1, m_imageWidthInPixels, m_imageHeightInPixels, &m_cbImageSize); - } - -done: - return hr; -} - - -// Calculate the size of the buffer needed to store the image. - -// fcc: The FOURCC code of the video format. - -HRESULT GetImageSize(DWORD fcc, UINT32 width, UINT32 height, DWORD* pcbImage) -{ - HRESULT hr = S_OK; - - switch (fcc) - { - case FOURCC_YUY2: - case FOURCC_UYVY: - // check overflow - if ((width > MAXDWORD / 2) || (width * 2 > MAXDWORD / height)) - { - hr = E_INVALIDARG; - } - else - { - // 16 bpp - *pcbImage = width * height * 2; - } - break; - - case FOURCC_NV12: - // check overflow - if ((height/2 > MAXDWORD - height) || ((height + height/2) > MAXDWORD / width)) - { - hr = E_INVALIDARG; - } - else - { - // 12 bpp - *pcbImage = width * (height + (height/2)); - } - break; - - default: - hr = E_FAIL; // Unsupported type. - } - return hr; -} - -// Get the default stride for a video format. -HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride) -{ - LONG lStride = 0; - - // Try to get the default stride from the media type. - HRESULT hr = pType->GetUINT32(MF_MT_DEFAULT_STRIDE, (UINT32*)&lStride); - if (FAILED(hr)) - { - // Attribute not set. Try to calculate the default stride. - GUID subtype = GUID_NULL; - - UINT32 width = 0; - UINT32 height = 0; - - // Get the subtype and the image size. - hr = pType->GetGUID(MF_MT_SUBTYPE, &subtype); - if (SUCCEEDED(hr)) - { - hr = MFGetAttributeSize(pType, MF_MT_FRAME_SIZE, &width, &height); - } - if (SUCCEEDED(hr)) - { - if (subtype == MFVideoFormat_NV12) - { - lStride = width; - } - else if (subtype == MFVideoFormat_YUY2 || subtype == MFVideoFormat_UYVY) - { - lStride = ((width * 2) + 3) & ~3; - } - else - { - hr = E_INVALIDARG; - } - } - - // Set the attribute for later reference. - if (SUCCEEDED(hr)) - { - (void)pType->SetUINT32(MF_MT_DEFAULT_STRIDE, UINT32(lStride)); - } - } - if (SUCCEEDED(hr)) - { - *plStride = lStride; - } - return hr; -} - - -// Validate that a rectangle meets the following criteria: -// -// - All coordinates are non-negative. -// - The rectangle is not flipped (top > bottom, left > right) -// -// These are the requirements for the destination rectangle. - -bool ValidateRect(const RECT& rc) -{ - if (rc.left < 0 || rc.top < 0) - { - return false; - } - if (rc.left > rc.right || rc.top > rc.bottom) - { - return false; - } - return true; -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.def b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.def deleted file mode 100644 index 1699fdb071688..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.def +++ /dev/null @@ -1,6 +0,0 @@ -;// -EXPORTS - DllCanUnloadNow PRIVATE - DllGetActivationFactory PRIVATE - DllGetClassObject PRIVATE -;// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.h deleted file mode 100644 index 7c6c88c00df1a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.idl b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.idl deleted file mode 100644 index 62bf0c710cb63..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.idl +++ /dev/null @@ -1,14 +0,0 @@ -// -import "Windows.Media.idl"; - -#include - -namespace GrayscaleTransform -{ - [version(NTDDI_WIN8), activatable(NTDDI_WIN8)] - runtimeclass GrayscaleEffect - { - [default] interface Windows.Media.IMediaExtension; - } -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.vcxproj deleted file mode 100644 index 9e62cf670f119..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {bc0c14a0-37c8-49c7-848f-954cf4985230} - Win32Proj - GrayscaleTransform - GrayscaleTransform - en-US - 11.0 - true - - - - DynamicLibrary - true - v110 - - - DynamicLibrary - true - v110 - - - DynamicLibrary - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - - - - - - - - - - - - - - - - - - - - - - false - false - - - false - false - - - false - false - - - false - false - - - false - false - - - false - false - - - - Use - false - - - Console - false - true - runtimeobject.lib;mfuuid.lib;mfplat.lib;kernel32.lib;%(AdditionalDependencies) - GrayscaleTransform.def - - - - - Use - false - - - Console - false - false - - - - - Use - false - - - Console - false - false - - - - - Use - false - - - Console - false - false - - - - - Use - false - - - Console - false - false - - - - - Use - false - - - Console - false - false - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.vcxproj.filters deleted file mode 100644 index 4c05be36dd71d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform.vcxproj.filters +++ /dev/null @@ -1,26 +0,0 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform_h.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform_h.h deleted file mode 100644 index 654bd5892c45b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/grayscaletransform_h.h +++ /dev/null @@ -1,101 +0,0 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 8.00.0595 */ -/* at Wed Dec 26 09:45:19 2012 - */ -/* Compiler settings for C:\Users\thompet\AppData\Local\Temp\GrayscaleTransform.idl-24dcae0f: - Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595 - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -/* @@MIDL_FILE_HEADING( ) */ - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - - -#ifndef __GrayscaleTransform_h_h__ -#define __GrayscaleTransform_h_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -#if defined(__cplusplus) -#if defined(__MIDL_USE_C_ENUM) -#define MIDL_ENUM enum -#else -#define MIDL_ENUM enum class -#endif -#endif - - -/* Forward Declarations */ - -/* header files for imported files */ -#include "Windows.Media.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -/* interface __MIDL_itf_GrayscaleTransform_0000_0000 */ -/* [local] */ - -#pragma warning(push) -#pragma warning(disable:4001) -#pragma once -#pragma warning(pop) -#ifdef __cplusplus -namespace ABI { -namespace GrayscaleTransform { -class GrayscaleEffect; -} /*GrayscaleTransform*/ -} -#endif - -#ifndef RUNTIMECLASS_GrayscaleTransform_GrayscaleEffect_DEFINED -#define RUNTIMECLASS_GrayscaleTransform_GrayscaleEffect_DEFINED -extern const __declspec(selectany) WCHAR RuntimeClass_GrayscaleTransform_GrayscaleEffect[] = L"GrayscaleTransform.GrayscaleEffect"; -#endif - - -/* interface __MIDL_itf_GrayscaleTransform_0000_0000 */ -/* [local] */ - - - - -extern RPC_IF_HANDLE __MIDL_itf_GrayscaleTransform_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_GrayscaleTransform_0000_0000_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/pch.h deleted file mode 100644 index 469abe46f0024..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/pch.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// -// -#pragma once - -#include "targetver.h" - -#include -#include -#include -#include -#include -#include -#include - -// Note: The Direct2D helper library is included for its 2D matrix operations. -#include - -#include -#include -#include -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/targetver.h deleted file mode 100644 index a66ecb00f1531..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/cpp/grayscaletransform/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/mediacapture.sln b/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/mediacapture.sln deleted file mode 100644 index eb02c2c82812d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-media-capture/mediacapture.sln +++ /dev/null @@ -1,86 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GrayscaleTransform", "cpp\GrayscaleTransform\GrayscaleTransform.vcxproj", "{BC0C14A0-37C8-49C7-848F-954CF4985230}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaCapture", "cs\MediaCapture\MediaCapture.csproj", "{34F490F1-3F87-4760-B0F2-D235616EC53D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|ARM.ActiveCfg = Debug|ARM - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|ARM.Build.0 = Debug|ARM - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|Win32.Build.0 = Debug|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|x64.ActiveCfg = Debug|x64 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|x64.Build.0 = Debug|x64 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|x86.ActiveCfg = Debug|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Debug|x86.Build.0 = Debug|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|Any CPU.ActiveCfg = Release|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|ARM.ActiveCfg = Release|ARM - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|ARM.Build.0 = Release|ARM - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|Mixed Platforms.Build.0 = Release|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|Win32.ActiveCfg = Release|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|Win32.Build.0 = Release|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|x64.ActiveCfg = Release|x64 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|x64.Build.0 = Release|x64 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|x86.ActiveCfg = Release|Win32 - {BC0C14A0-37C8-49C7-848F-954CF4985230}.Release|x86.Build.0 = Release|Win32 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|ARM.ActiveCfg = Debug|ARM - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|ARM.Build.0 = Debug|ARM - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|ARM.Deploy.0 = Debug|ARM - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Mixed Platforms.Deploy.0 = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Win32.ActiveCfg = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Win32.Build.0 = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|Win32.Deploy.0 = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|x64.ActiveCfg = Debug|x64 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|x64.Build.0 = Debug|x64 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|x64.Deploy.0 = Debug|x64 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|x86.ActiveCfg = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|x86.Build.0 = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Debug|x86.Deploy.0 = Debug|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Any CPU.Build.0 = Release|Any CPU - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Any CPU.Deploy.0 = Release|Any CPU - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|ARM.ActiveCfg = Release|ARM - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|ARM.Build.0 = Release|ARM - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|ARM.Deploy.0 = Release|ARM - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Mixed Platforms.Build.0 = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Mixed Platforms.Deploy.0 = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Win32.ActiveCfg = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Win32.Build.0 = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|Win32.Deploy.0 = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|x64.ActiveCfg = Release|x64 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|x64.Build.0 = Release|x64 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|x64.Deploy.0 = Release|x64 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|x86.ActiveCfg = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|x86.Build.0 = Release|x86 - {34F490F1-3F87-4760-B0F2-D235616EC53D}.Release|x86.Deploy.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-microsoft__wrl__activationfactory/cpp/activationfactory.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-microsoft__wrl__activationfactory/cpp/activationfactory.cpp deleted file mode 100644 index 646f0b61365f7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-microsoft__wrl__activationfactory/cpp/activationfactory.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// activationfactory.cpp -// compile with: /c -#include - -using namespace Microsoft::WRL; - -namespace ABI -{ - namespace MyClassLibrary - { - [uuid({3B631C7A-B226-4F9A-8279-17D4CBAABA93})] - interface IMyClass : IWeakReference - { - virtual HRESULT STDMETHODCALLTYPE Resolve( - /* [in] */ __RPC__in REFIID riid, - /* [iid_is][out] */ __RPC__deref_out IInspectable **objectReference) - { - return S_OK; - } - }; - - [uuid({3B631C7A-B226-4F9A-8279-17D4CBAABA93})] - interface IMyAdditionalInterfaceOnFactory: IWeakReference - { - virtual HRESULT STDMETHODCALLTYPE Resolve( - /* [in] */ __RPC__in REFIID riid, - /* [iid_is][out] */ __RPC__deref_out IInspectable **objectReference) - { - return S_OK; - } - }; - - class MyClass: public RuntimeClass - { - InspectableClass(L"MyClassLibrary.MyClass", BaseTrust) - - public: - MyClass() - { - } - }; - - //ActivatableClass(MyClass); - - // - struct MyClassFactory : public ActivationFactory - { - STDMETHOD(ActivateInstance) (_Outptr_result_nullonfailure_ IInspectable** ppvObject) - { - // my custom implementation - - return S_OK; - } - }; - - ActivatableClassWithFactory(MyClass, MyClassFactory); - // or if a default factory is used: - //ActivatableClassWithFactory(MyClass, SimpleActivationFactory); - // - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-microsoft__wrl__activationfactory/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Misc/wrl-microsoft__wrl__activationfactory/cpp/makefile deleted file mode 100644 index 52911eda31713..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-microsoft__wrl__activationfactory/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -activationfactory.exe: activationfactory.cpp - cl.exe /c activationfactory.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/module.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/module.cpp deleted file mode 100644 index 3a0036d9147b6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/module.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// module.cpp : Defines the module that contains the com classes -// -#include "pch.h" - -#include - -extern "C" BOOL WINAPI DllMain(_In_opt_ HINSTANCE, DWORD, _In_opt_ LPVOID); -extern "C" HRESULT WINAPI DllCanUnloadNow(); - -#if !defined(__WRL_CLASSIC_COM__) -extern "C" HRESULT WINAPI DllGetActivationFactory(_In_ HSTRING, _Deref_out_ IActivationFactory**); - -extern "C" HRESULT WINAPI DllGetActivationFactory(_In_ HSTRING activatibleClassId, _Deref_out_ IActivationFactory** factory) -{ - auto &module = Microsoft::WRL::Module::GetModule(); - return module.GetActivationFactory(activatibleClassId, factory); -} -#endif - -#if !defined(__WRL_WINRT_STRICT__) -extern "C" HRESULT WINAPI DllGetClassObject(REFCLSID, REFIID, _Deref_out_ LPVOID*); - -extern "C" HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _Deref_out_ LPVOID *ppv) -{ - auto &module = Microsoft::WRL::Module::GetModule(); - return module.GetClassObject(rclsid, riid, ppv); -} -#endif - -extern "C" BOOL WINAPI DllMain(_In_opt_ HINSTANCE, DWORD, _In_opt_ LPVOID) -{ - return TRUE; -} - -extern "C" HRESULT WINAPI DllCanUnloadNow() -{ - const auto &module = Microsoft::WRL::Module::GetModule(); - return module.GetObjectCount() == 0 ? S_OK : S_FALSE; -} - -#if defined(_M_IX86) -#if !defined(__WRL_CLASSIC_COM__) -#pragma comment(linker, "/EXPORT:DllGetActivationFactory=_DllGetActivationFactory@8,PRIVATE") -#endif -#if !defined(__WRL_WINRT_STRICT__) -#pragma comment(linker, "/EXPORT:DllGetClassObject=_DllGetClassObject@12,PRIVATE") -#endif -#pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE") -#elif defined(_M_ARM) || defined(_M_AMD64) -#if !defined(__WRL_CLASSIC_COM__) -#pragma comment(linker, "/EXPORT:DllGetActivationFactory,PRIVATE") -#endif -#if !defined(__WRL_WINRT_STRICT__) -#pragma comment(linker, "/EXPORT:DllGetClassObject,PRIVATE") -#endif -#pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE") -#endif \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/pch.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/pch.cpp deleted file mode 100644 index 01484ff5aa454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/pch.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/pch.h deleted file mode 100644 index 9785b875951e3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/pch.h +++ /dev/null @@ -1,11 +0,0 @@ -// -// pch.h -// Header for standard system include files. -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/targetver.h b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/targetver.h deleted file mode 100644 index a66ecb00f1531..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.cpp b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.cpp deleted file mode 100644 index 56d825a040712..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -#include "pch.h" - -#include "WRLClassLibrary_h.h" -#include - -using namespace Microsoft::WRL; -using namespace Windows::Foundation; - -namespace ABI -{ - namespace WRLClassLibrary - { - class WinRTClass: public RuntimeClass - { - InspectableClass(L"WRLClassLibrary.WinRTClass", BaseTrust) - - public: - WinRTClass() - { - } - }; - - ActivatableClass(WinRTClass); - } -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.idl b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.idl deleted file mode 100644 index 51e7b8cff463c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.idl +++ /dev/null @@ -1,23 +0,0 @@ -// -import "inspectable.idl"; -import "Windows.Foundation.idl"; - -#define COMPONENT_VERSION 1.0 - -namespace WRLClassLibrary -{ - interface IWinRTClass; - runtimeclass WinRTClass; - - [uuid(89656677-8679-477c-aff1-f724c64b70f3), version(COMPONENT_VERSION), exclusiveto(WinRTClass)] - interface IWinRTClass : IInspectable - { - } - - [version(COMPONENT_VERSION), activatable(COMPONENT_VERSION)] - runtimeclass WinRTClass - { - [default] interface IWinRTClass; - } -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.vcxproj b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.vcxproj deleted file mode 100644 index 8d916cc1a9746..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.vcxproj +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - - $(VCTargetsPath11) - {89656677-8679-477c-aff1-f724c64b70f3} - WRLProj - Win32Proj - WRLClassLibrary - WRLClassLibrary - en-US - 11.0 - true - - - - - - DynamicLibrary - true - v110 - - - DynamicLibrary - true - v110 - - - DynamicLibrary - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - false - - - - false - - - - false - - - - false - - - - false - - - - - Use - WINAPI_FAMILY=WINAPI_PARTITION_APP;_USRDLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - false - - - Console - false - false - runtimeobject.lib;user32.lib;kernel32.lib - - - mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(SolutionDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial - $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd - - - - - - Use - WINAPI_FAMILY=WINAPI_PARTITION_APP;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - false - - - Console - false - false - runtimeobject.lib;user32.lib;kernel32.lib - - - mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(SolutionDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial - $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd - - - - - - Use - WINAPI_FAMILY=WINAPI_PARTITION_APP;_USRDLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - false - - - Console - false - false - runtimeobject.lib;user32.lib;kernel32.lib - - - mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(ProjectDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial - $(ProjectDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd - - - - - - Use - WINAPI_FAMILY=WINAPI_PARTITION_APP;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - false - - - Console - false - false - runtimeobject.lib;user32.lib;kernel32.lib - - - mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(ProjectDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial - $(ProjectDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd - - - - - - Use - WINAPI_FAMILY=WINAPI_PARTITION_APP;_USRDLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - false - - - Console - false - false - runtimeobject.lib;user32.lib;kernel32.lib - - - mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(ProjectDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial - $(ProjectDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd - - - - - - Use - WINAPI_FAMILY=WINAPI_PARTITION_APP;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - false - - - Console - false - false - runtimeobject.lib;user32.lib;kernel32.lib - - - mdmerge -metadata_dir "$(WindowsSDK_MetadataPath)" -o "$(ProjectDir)$(Configuration)\$(MSBuildProjectName)" -i "$(MSBuildProjectDirectory)" -v -partial - $(ProjectDir)$(Configuration)\$(MSBuildProjectName)\$(ProjectName).winmd - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - - $(WindowsSDK_MetadataPath) - $(WindowsSDK_MetadataPath) - $(WindowsSDK_MetadataPath) - $(WindowsSDK_MetadataPath) - $(WindowsSDK_MetadataPath) - $(WindowsSDK_MetadataPath) - true - true - true - true - true - true - /ns_prefix %(AdditionalOptions) - /ns_prefix %(AdditionalOptions) - /ns_prefix %(AdditionalOptions) - /ns_prefix %(AdditionalOptions) - /ns_prefix %(AdditionalOptions) - /ns_prefix %(AdditionalOptions) - - - - - - - - - true - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.vcxproj.filters deleted file mode 100644 index d56ba3ca9a0e6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Misc/wrl-project-template/cpp/wrlclasslibrary/wrlclasslibrary.vcxproj.filters +++ /dev/null @@ -1,9 +0,0 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/ActivatedServiceTypeEntry_ObjectType_Client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/ActivatedServiceTypeEntry_ObjectType_Client.cpp deleted file mode 100644 index 0a5cdc65a367a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/ActivatedServiceTypeEntry_ObjectType_Client.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -void main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel ); - ActivatedClientTypeEntry^ activatedClientTypeEntry = gcnew ActivatedClientTypeEntry( HelloServer::typeid,"tcp://localhost:8082" ); - - // Register 'HelloServer' Type on the client end so that it can be - // activated on the server. - RemotingConfiguration::RegisterActivatedClientType( activatedClientTypeEntry ); - - // Obtain a proxy object for the remote object. - HelloServer^ helloServer = gcnew HelloServer( "ParameterString" ); - if ( !helloServer ) - { - Console::WriteLine( "Could not locate server" ); - } - else - { - Console::WriteLine( "Calling remote object" ); - Console::WriteLine( helloServer->HelloMethod( "Bill" ) ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/ActivatedServiceTypeEntry_ObjectType_Share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/ActivatedServiceTypeEntry_ObjectType_Share.cpp deleted file mode 100644 index 3dd42ed0c120a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/ActivatedServiceTypeEntry_ObjectType_Share.cpp +++ /dev/null @@ -1,17 +0,0 @@ -using namespace System; - -public ref class HelloServer: public MarshalByRefObject -{ -public: - HelloServer( String^ passedString ) - { - Console::WriteLine( "HelloServer activated" ); - Console::WriteLine( "Paramater passed to the constructor is {0}", passedString ); - } - - String^ HelloMethod( String^ name ) - { - Console::WriteLine( "HelloMethod : {0}", name ); - return String::Format( "Hi there {0}", name ); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/activatedservicetypeentry_objecttype_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/activatedservicetypeentry_objecttype_server.cpp deleted file mode 100644 index 188aacb6278b5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/activatedservicetypeentry_objecttype_server.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System.Runtime.Remoting.ActivatedServiceTypeEntry -// System.Runtime.Remoting.ActivatedServiceTypeEntry.ObjectType -// System.Runtime.Remoting.ActivatedServiceTypeEntry.ToString - -/* -The following example demonstrates the 'ActivatedServiceTypeEntry' class and -the 'ObjectType' property ,'ToString' method of 'ActivatedServiceTypeEntry' class. -It registers a 'TcpChannel' object with the channel services. Then registers the 'HelloServer' -object at the service end that can be activated on request from a client.By using the -'GetRegisteredActivatedServiceTypes' method it gets the registered activated service types -and displays it's information to the console:: -*/ - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -void main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) ); - - // Create an instance of 'ActivatedServiceTypeEntry' class - // which holds the values for 'HelloServer' type. - ActivatedServiceTypeEntry^ myActivatedServiceTypeEntry = - gcnew ActivatedServiceTypeEntry( HelloServer::typeid ); - - // Register an object Type on the service end so that - // it can be activated on request from a client. - RemotingConfiguration::RegisterActivatedServiceType( - myActivatedServiceTypeEntry ); - -// -// - // Get the registered activated service types. - array^ activatedServiceEntries = - RemotingConfiguration::GetRegisteredActivatedServiceTypes(); - Console::WriteLine( "Information of first registered activated" + - " service type :" ); - Console::WriteLine( "Object type: {0}", - activatedServiceEntries[ 0 ]->ObjectType->ToString() ); - Console::WriteLine( "Description: {0}", - activatedServiceEntries[ 0 ]->ToString() ); -// -// - - Console::WriteLine( "Press enter to stop this process" ); - Console::ReadLine(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/makefile deleted file mode 100644 index 88ff0f64259a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ActivatedServiceTypeEntry_ObjectType_Client/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: ActivatedServiceTypeEntry_ObjectType_Server.exe ActivatedServiceTypeEntry_ObjectType_Client.exe - -ActivatedServiceTypeEntry_ObjectType_Server.exe: ActivatedServiceTypeEntry_ObjectType_Server.cpp ActivatedServiceTypeEntry_ObjectType_Share.dll - cl /clr:pure ActivatedServiceTypeEntry_ObjectType_Server.cpp - -ActivatedServiceTypeEntry_ObjectType_Client.exe: ActivatedServiceTypeEntry_ObjectType_Client.cpp ActivatedServiceTypeEntry_ObjectType_Share.dll - cl /clr:pure ActivatedServiceTypeEntry_ObjectType_Client.cpp - -ActivatedServiceTypeEntry_ObjectType_Share.dll: ActivatedServiceTypeEntry_ObjectType_Share.cpp - cl /LD /clr:pure ActivatedServiceTypeEntry_ObjectType_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp deleted file mode 100644 index eaec1a8cfc9a6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System.Net.AuthenticationManager.UnRegister(String). -// System.Net.AuthenticationManager.Register. -// Grouping Clause : 1,3 AND 2,3. - -/*This program demonstrates the 'UnRegister(String)' and 'Register' methods of -'AuthenticationManager' class. It gets all the authentication modules registered with the system into an -IEnumerator instance ,unregisters the first authentication module and displays to show that it was -unregistered. Then registers the same module back again and displays all the modules again.*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -void DisplayAllModules() -{ - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - Console::WriteLine( "\n\tThe following modules are now registered with the system:" ); - while ( registeredModules->MoveNext() ) - { - Console::WriteLine( "\n\t\tModule : {0}", registeredModules->Current ); - IAuthenticationModule^ currentAuthenticationModule = dynamic_cast(registeredModules->Current); - Console::WriteLine( "\t\t\t CanPreAuthenticate : {0}", currentAuthenticationModule->CanPreAuthenticate ); - } -} -// - -int main() -{ - try - { -// -// - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - // Display all the modules that are already registered with the system. - DisplayAllModules(); - registeredModules->Reset(); - registeredModules->MoveNext(); - // Get the first Authentication module registered with the system. - IAuthenticationModule^ authenticationModule1 = dynamic_cast(registeredModules->Current); - // Call the UnRegister() method to unregister the first authentication module from the system. - String^ authenticationScheme = authenticationModule1->AuthenticationType; - AuthenticationManager::Unregister( authenticationScheme ); - Console::WriteLine( "\nSuccessfully unregistered '{0}'.", authenticationModule1 ); - // Display all modules to see that the module was unregistered. - DisplayAllModules(); -// - // Calling 'Register()' method to register 'authenticationModule1' module back again. - AuthenticationManager::Register( authenticationModule1 ); - Console::WriteLine( "\nSuccessfully re-registered '{0}'.", authenticationModule1 ); - // Display the modules to verify that 'authenticationModule1' has been registered back again. - DisplayAllModules(); -// - Console::WriteLine( "Press any key to continue" ); - Console::ReadLine(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n The following Exception was raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp deleted file mode 100644 index 9d25d5c5604b7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp +++ /dev/null @@ -1,104 +0,0 @@ - - -// System::Net::Authorization::Authorization(String*, bool, String*) -/* This program demonstrates the contructor 'Authorization(String*, bool, String*)' of the authorization -* class. -* -* We implement the interface S"IAuthenticationModule*" to make CloneBasic which is a custom authentication module. -* The custom authentication module encodes username and password as base64 strings and then returns -* back an authorization instance. This authorization is internally used by the HttpWebRequest for -* authentication. -* * -* Please Note : This program has to be compiled as a dll. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -namespace CloneBasicAuthentication -{ - public ref class CloneBasic: public IAuthenticationModule - { - private: - String^ m_authenticationType; - bool m_canPreAuthenticate; - - public: - CloneBasic() - { - m_authenticationType = "CloneBasic"; - m_canPreAuthenticate = false; - } - - property String^ AuthenticationType - { - virtual String^ get() - { - return m_authenticationType; - } - } - - property bool CanPreAuthenticate - { - virtual bool get() - { - return m_canPreAuthenticate; - } - } - - // - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - try - { - String^ message; - - // Check if Challenge String* was raised by a site which requires CloneBasic authentication. - if ( (challenge == nullptr) || ( !challenge->StartsWith( "CloneBasic" )) ) - return nullptr; - NetworkCredential^ myCredentials; - if ( dynamic_cast(credentials) == nullptr ) - { - myCredentials = credentials->GetCredential( request->RequestUri, "CloneBasic" ); - if ( myCredentials == nullptr ) - return nullptr; - } - else - myCredentials = dynamic_cast(credentials); - - // Message encryption scheme : - // a)Concatenate username and password seperated by space; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain our encoded authorization message. - message = String::Concat( myCredentials->UserName, " ", myCredentials->Password ); - - // Apply AsciiEncoding to our user name and password to obtain it as an array of bytes. - Encoding^ asciiEncoding = Encoding::ASCII; - array^byteArray = gcnew array(asciiEncoding->GetByteCount( message )); - byteArray = asciiEncoding->GetBytes( message ); - - // Perform Base64 transform. - message = Convert::ToBase64String( byteArray ); - - // The following overloaded contructor sets the 'Message' property of authorization to the base64 String*; - // that we just formed and it also sets the 'Complete' property to true and the connection group id; - // to the domain of the NetworkCredential Object*. - Authorization^ myAuthorization = gcnew Authorization( String::Concat( "CloneBasic ", message, true, request->ConnectionGroupName ) ); - return myAuthorization; - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Raised ...: {0}", e->Message ); - return nullptr; - } - } - // - - virtual Authorization^ PreAuthenticate( WebRequest^ request, ICredentials^ credentials ) - { - return nullptr; - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/clientclonebasic.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/clientclonebasic.cpp deleted file mode 100644 index 2b7b7b551bde8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/clientclonebasic.cpp +++ /dev/null @@ -1,146 +0,0 @@ - - -/* This is a client program to test the S"CloneBasic" class of IAuthenticationModule*_Methods_Props.dll. -* -* To demonstrate the functionality of CloneBasic, Client class has been made which makes -* the webrequest for the protected: -resource. A site for such a protected: -resource -(http://gopik/clonebasicsite/WebForm1::aspx), which would use CloneBasic authentication, has been developed. -Pl. see the guidelines.txt file for more information in setting up the site at your environment. While -running this program make sure to refer the 'Authroization_Constructor3.dll' -*/ -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::IO; -using namespace System::Collections; - -// To test our authentication module, we write a client class. -public ref class Client -{ -public: - int main() - { - array^args = Environment::GetCommandLineArgs(); - try - { - String^ url; - String^ userName; - String^ passwd; - String^ domain; - if ( args->Length < 4 ) - { - - // Proceed with defaults. - Client::PrintUsage(); - Console::WriteLine( "\nTo proceed with defaults values press 'y' , press any other character to exit:" ); - String^ option = Console::ReadLine(); - if ( (String::Compare( option, "Y" ) == 0) || (String::Compare( option, "y" ) == 0) ) - { - url = "http://gopik/clonebasicsite/WebForm1::aspx"; - userName = "user1"; - passwd = "passwd1"; - domain = "gopik"; - } - else - return 0; - } - else - { - url = args[ 0 ]; - userName = args[ 1 ]; - passwd = args[ 2 ]; - domain = args[ 3 ]; - } - Console::WriteLine(); - CloneBasicAuthentication::CloneBasic ^ authenticationModule = gcnew CloneBasicAuthentication::CloneBasic; - - // Register CloneBasic authentication module with the system. - AuthenticationManager::Register( authenticationModule ); - Console::WriteLine( "\nSuccessfully registered our custom authentication module \"CloneBasic\"" ); - - // The AuthenticationManager calls all authentication modules sequentially until one of them responds with; - // an authorization instance. We have to unregister S"Basic" here as it almost always returns an authorization; - // thereby defeating our purpose to test CloneBasic. - AuthenticationManager::Unregister( "Basic" ); - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - Console::WriteLine( "\r\nThe following authentication modules are now registered with the system" ); - while ( registeredModules->MoveNext() ) - { - Console::WriteLine( "\r \n Module : {0}", registeredModules->Current ); - IAuthenticationModule^ currentAuthenticationModule = dynamic_cast(registeredModules->Current); - Console::WriteLine( "\t CanPreAuthenticate : {0}", currentAuthenticationModule->CanPreAuthenticate ); - } - GetPage( url, userName, passwd, domain ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n The following exception was raised : {0}", e->Message ); - } - - } - -public: - static void PrintUsage() - { - Console::WriteLine( "\r\nUsage: Try a site which requires CloneBasic(custom made) authentication as below" ); - Console::WriteLine( " ClientCloneBasic URLname username password domainname" ); - Console::WriteLine( "\nExample:" ); - Console::WriteLine( "\n ClientCloneBasic http://dotnet.microsoft.com/ george george123 microsoft" ); - } - - static void GetPage( String^ url, String^ username, String^ passwd, String^ domain ) - { - try - { - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - NetworkCredential^ credentials = gcnew NetworkCredential( username,passwd,domain ); - myHttpWebRequest->Credentials = credentials; - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - Console::WriteLine( "\nRequest for protected resource {0} sent", url ); - Stream^ receiveStream = myHttpWebResponse->GetResponseStream(); - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - Console::WriteLine( "\r\nResponse stream received" ); - array^read = gcnew array(256); - - // Read 256 characters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "Contents of the response received follows...\r\n" ); - while ( count > 0 ) - { - // Dump the 256 characters on a String* and display the String* onto the console. - Console::Write( read ); - count = readStream->Read( read, 0, 256 ); - } - Console::WriteLine( "" ); - - // Release the resources of stream Object*. - readStream->Close(); - - // Release the resources of response Object*. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - if ( e->Response != nullptr ) - Console::WriteLine( "\r\n Exception Raised. The following error occurred : {0}", (dynamic_cast(e->Response))->StatusDescription ); - else - Console::WriteLine( "\r\n Exception Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n The following exception was raised : {0}", e->Message ); - } - } -}; - -int main() -{ - Client^ c = gcnew Client(); - c->main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/makefile deleted file mode 100644 index f4bed7a3d656a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all : ClientCloneBasic.exe -ClientCloneBasic.exe: ClientCloneBasic.cpp Authorization_Constructor3.cpp - cl /clr:pure /LD Authorization_Constructor3.cpp - cl /clr:pure ClientCloneBasic.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp deleted file mode 100644 index 3eabd24b023dd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp +++ /dev/null @@ -1,192 +0,0 @@ - - -// System::Net::Authorization::Authorization(String*, bool);System::Net::Authorization::ProtectionRealm -/* This program demonstrates the 'ProtectionRealm' property and 'Authorization(String*, bool)' constructor of -the S"Authorization" class. The S"IAuthenticationModule*" interface is implemented in 'CloneBasic' to make -it a custom authentication module. The custom authentication module encodes username and password as -base64 strings and then returns back an 'Authorization' instance. The 'Authorization' instance encapsulates -a list of Uri's for which it is applicable using the S"ProtectionRealm" property. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -void GetPage( String^ url, String^ username, String^ passwd ) -{ - try - { - String^ challenge = nullptr; - HttpWebRequest^ myHttpWebRequest = nullptr; - try - { - // Create a 'HttpWebRequest' Object* for the above 'url'. - myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - - // The following method call throws the 'WebException'. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Release resources of response Object*. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - for ( int i = 0; i < e->Response->Headers->Count; ++i ) - - // Retrieve the challenge String* from the header S"WWW-Authenticate". - if ( (String::Compare( e->Response->Headers->Keys[ i ], "WWW-Authenticate", true ) == 0) ) - challenge = e->Response->Headers[ i ]; - } - - if ( challenge != nullptr ) - { - // Challenge was raised by the client.Declare your credentials. - NetworkCredential^ myCredentials = gcnew NetworkCredential( username,passwd ); - - // Pass the challenge , 'NetworkCredential' Object* and the 'HttpWebRequest' Object* to the - // 'Authenticate' method of the S"AuthenticationManager" to retrieve an S"Authorization" ; - // instance. - Authorization^ urlAuthorization = AuthenticationManager::Authenticate( challenge, myHttpWebRequest, myCredentials ); - if ( urlAuthorization != nullptr ) - { - Console::WriteLine( "\nSuccessfully Created 'Authorization' object with authorization Message:\n \" {0}\"", urlAuthorization->Message ); - Console::WriteLine( "\n\nThis authorization is valid for the following Uri's:" ); - int count = 0; - System::Collections::IEnumerator^ myEnum = urlAuthorization->ProtectionRealm->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ uri = safe_cast(myEnum->Current); - ++count; - Console::WriteLine( "\nUri->Item[ {0}]: {1}", count, uri ); - } - } - else - Console::WriteLine( "\nAuthorization Object* was returned as 0. Please check if site accepts 'CloneBasic' authentication" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n The following exception was raised : {0}", e->Message ); - } -} - -void PrintUsage() -{ - Console::WriteLine( "\r\nUsage: Try a site which requires CloneBasic(custom made) authentication as below" ); - Console::WriteLine( " Authorization_ProtectionRealm URLname username password" ); - Console::WriteLine( "\nExample:" ); - Console::WriteLine( "\n Authorization_ProtectionRealm http://dotnet.microsoft.com/ george george123" ); -} - -// The 'CloneBasic' authentication module class implements 'IAuthenticationModule*'. -public ref class CloneBasic: public IAuthenticationModule -{ -private: - String^ m_authenticationType; - bool m_canPreAuthenticate; - -public: - CloneBasic() - { - m_authenticationType = "CloneBasic"; - m_canPreAuthenticate = false; - } - - property String^ AuthenticationType - { - virtual String^ get() - { - return m_authenticationType; - } - } - - property bool CanPreAuthenticate - { - virtual bool get() - { - return m_canPreAuthenticate; - } - } - - // - // - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - try - { - String^ message; - - // Check if Challenge String* was raised by a site which requires 'CloneBasic' authentication. - if ( (challenge == nullptr) || ( !challenge->StartsWith( "CloneBasic" )) ) - return nullptr; - NetworkCredential^ myCredentials; - if ( dynamic_cast(credentials) == nullptr ) - { - myCredentials = credentials->GetCredential( request->RequestUri, "CloneBasic" ); - if ( myCredentials == nullptr ) - return nullptr; - } - else - myCredentials = dynamic_cast(credentials); - - // Message encryption scheme : - // a)Concatenate username and password seperated by space; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain our encoded authorization message. - message = String::Concat( myCredentials->UserName, " ", myCredentials->Password ); - - // Apply AsciiEncoding to 'message' String* to obtain it as an array of bytes. - Encoding^ ascii = Encoding::ASCII; - array^byteArray = gcnew array(ascii->GetByteCount( message )); - byteArray = ascii->GetBytes( message ); - - // Performing Base64 transformation. - message = Convert::ToBase64String( byteArray ); - Authorization^ myAuthorization = gcnew Authorization( String::Concat( "CloneBasic ", message, true ) ); - array^protectionRealm = gcnew array(1); - protectionRealm[ 0 ] = request->RequestUri->AbsolutePath; - myAuthorization->ProtectionRealm = protectionRealm; - return myAuthorization; - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised in Authenticate method: {0}", e->Message ); - return nullptr; - } - } - // - // - - virtual Authorization^ PreAuthenticate( WebRequest^ request, ICredentials^ credentials ) - { - return nullptr; - } -}; - -// The 'Client' class is defined here to test the above custom authentication module. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ url; - String^ userName; - String^ passwd; - if ( args->Length < 3 ) - { - PrintUsage(); - return 0; - } - else - { - url = args[ 0 ]; - userName = args[ 1 ]; - passwd = args[ 2 ]; - } - - Console::WriteLine(); - CloneBasic^ authenticationModule = gcnew CloneBasic; - AuthenticationManager::Register( authenticationModule ); - AuthenticationManager::Unregister( "Basic" ); - - // Get response from Uri. - GetPage( url, userName, passwd ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/BinaryFormatterClass Example/CPP/binaryformatter.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/BinaryFormatterClass Example/CPP/binaryformatter.cpp deleted file mode 100644 index 8721c96f86ea8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/BinaryFormatterClass Example/CPP/binaryformatter.cpp +++ /dev/null @@ -1,90 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Runtime::Serialization::Formatters::Binary; -using namespace System::Runtime::Serialization; -ref class App -{ -public: - static void Serialize() - { - - // Create a hashtable of values that will eventually be serialized. - Hashtable^ addresses = gcnew Hashtable; - addresses->Add( "Jeff", "123 Main Street, Redmond, WA 98052" ); - addresses->Add( "Fred", "987 Pine Road, Phila., PA 19116" ); - addresses->Add( "Mary", "PO Box 112233, Palo Alto, CA 94301" ); - - // To serialize the hashtable (and its keys/values), - // you must first open a stream for writing. - // In this case we will use a file stream. - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Create ); - - // Construct a BinaryFormatter and use it to serialize the data to the stream. - BinaryFormatter^ formatter = gcnew BinaryFormatter; - try - { - formatter->Serialize( fs, addresses ); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to serialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - - } - - static void Deserialize() - { - - // Declare the hashtable reference. - Hashtable^ addresses = nullptr; - - // Open the file containing the data that we want to deserialize. - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Open ); - try - { - BinaryFormatter^ formatter = gcnew BinaryFormatter; - - // Deserialize the hashtable from the file and - // assign the reference to our local variable. - addresses = dynamic_cast(formatter->Deserialize( fs )); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to deserialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - - - // To prove that the table deserialized correctly, display the keys/values. - IEnumerator^ myEnum = addresses->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry ^ de = safe_cast(myEnum->Current); - Console::WriteLine( " {0} lives at {1}.", de->Key, de->Value ); - } - } - -}; - - -[STAThread] -int main() -{ - App::Serialize(); - App::Deserialize(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionSample2/CPP/bindingcollectionsample2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionSample2/CPP/bindingcollectionsample2.cpp deleted file mode 100644 index 0f79f9a52a7dc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionSample2/CPP/bindingcollectionsample2.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// System.Web.Services.Description.Binding.Binding();System.Web.Services.Description.Binding.Name; -// System.Web.Services.Description.Binding.Type;System.Web.Services.Description.Binding.Extensions;System.Web.Services.Description.Binding.Operations; -// System.Web.Services.Description.BindingCollection.Insert; -// System.Web.Services.Description.Binding.ServiceDescription; - -// Grouping Clause : Snippet5 and Snippet8 go together. - -/* The following example demonstrates the constructor 'Binding()' and properties 'Extensions','Name','Operations', - 'ServiceDescription' and 'Type' property of 'Binding' class AND method 'Insert' of 'BindingCollection' class. - The input to the program is a WSDL file 'MathService_input.wsdl' with all information related to SOAP protocol - removed from it.In a way it tries to simulate a scenario wherein a service initially did not support a protocol, however later - on happen to support it. - IN this example the WSDL file is modified to insert a new Binding for SOAP. The binding is populated based on - WSDL document structure defined in WSDL specification. The ServiceDescription instance is loaded with values - for 'Messages', 'PortTypes','Bindings' and 'Port'.The instance is then written to an external file 'MathService_new.wsdl'. - * */ - -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -ref class MyClass -{ -public: - // Creates a Message with name ="messageName" having one MessagePart with name = "partName". - static Message^ CreateMessage( String^ messageName, String^ partName, String^ element, String^ targetNamespace ) - { - Message^ myMessage = gcnew Message; - myMessage->Name = messageName; - MessagePart^ myMessagePart = gcnew MessagePart; - myMessagePart->Name = partName; - myMessagePart->Element = gcnew XmlQualifiedName( element,targetNamespace ); - myMessage->Parts->Add( myMessagePart ); - return myMessage; - } - - // Used to create Operations under PortType. - static Operation^ CreateOperation( String^ operationName, String^ inputMessage, String^ outputMessage, String^ targetNamespace ) - { - Operation^ myOperation = gcnew Operation; - myOperation->Name = operationName; - OperationMessage^ input = (OperationMessage^)( gcnew OperationInput ); - input->Message = gcnew XmlQualifiedName( inputMessage,targetNamespace ); - OperationMessage^ output = (OperationMessage^)( gcnew OperationOutput ); - output->Message = gcnew XmlQualifiedName( outputMessage,targetNamespace ); - myOperation->Messages->Add( input ); - myOperation->Messages->Add( output ); - return myOperation; - } - -// - // Used to create OperationBinding instances within 'Binding'. -public: - static OperationBinding^ CreateOperationBinding( String^ operation, String^ targetNamespace ) - { - // Create OperationBinding instance for operation. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = operation; - // Create InputBinding for operation. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - // Create OutputBinding for operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - // Create extensibility element for 'SoapOperationBinding'. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = String::Concat( targetNamespace, operation ); - // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - return myOperationBinding; - } -// - - static void Main() - { - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input.wsdl" ); - // Create SOAP Messages. - myServiceDescription->Messages->Add( CreateMessage( "AddSoapIn", "parameters", "Add", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "AddSoapOut", "parameters", "AddResponse", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "SubtractSoapIn", "parameters", "Subtract", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "SubtractSoapOut", "parameters", "SubtractResponse", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "MultiplySoapIn", "parameters", "Multiply", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "MultiplySoapOut", "parameters", "MultiplyResponse", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "DivideSoapIn", "parameters", "Divide", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "DivideSoapOut", "parameters", "DivideResponse", myServiceDescription->TargetNamespace ) ); - - // Create a new PortType. - PortType^ soapPortType = gcnew PortType; - soapPortType->Name = "MathServiceSoap"; - soapPortType->Operations->Add( CreateOperation( "Add", "AddSoapIn", "AddSoapOut", myServiceDescription->TargetNamespace ) ); - soapPortType->Operations->Add( CreateOperation( "Subtract", "SubtractSoapIn", "SubtractSoapOut", myServiceDescription->TargetNamespace ) ); - soapPortType->Operations->Add( CreateOperation( "Multiply", "MultiplySoapIn", "MultiplySoapOut", myServiceDescription->TargetNamespace ) ); - soapPortType->Operations->Add( CreateOperation( "Divide", "DivideSoapIn", "DivideSoapOut", myServiceDescription->TargetNamespace ) ); - myServiceDescription->PortTypes->Add( soapPortType ); - -// -// -// - // Create a new Binding for SOAP Protocol. - Binding^ myBinding = gcnew Binding; - myBinding->Name = String::Concat( myServiceDescription->Services->default[ 0 ]->Name, "Soap" ); -// - -// - // Pass the name of the existing porttype 'MathServiceSoap' and the Xml targetNamespace attribute of the Descriptions tag. - myBinding->Type = gcnew XmlQualifiedName( "MathServiceSoap",myServiceDescription->TargetNamespace ); -// - -// - // Create SOAP Extensibility element. - SoapBinding^ mySoapBinding = gcnew SoapBinding; - // SOAP over HTTP. - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - // Add tag soap:binding as an extensibility element. - myBinding->Extensions->Add( mySoapBinding ); -// - -// - // Create OperationBindings for each of the operations defined in asmx file. - OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( addOperationBinding ); - OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( subtractOperationBinding ); - OperationBinding^ multiplyOperationBinding = CreateOperationBinding( "Multiply", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( multiplyOperationBinding ); - OperationBinding^ divideOperationBinding = CreateOperationBinding( "Divide", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( divideOperationBinding ); -// - - myServiceDescription->Bindings->Insert( 0, myBinding ); -// -// - -// - Console::WriteLine( "\nTarget Namespace of the Service Description to which the binding was added is:{0}", myServiceDescription->Bindings->default[ 0 ]->ServiceDescription->TargetNamespace ); -// - - // Create Port. - Port^ soapPort = gcnew Port; - soapPort->Name = "MathServiceSoap"; - soapPort->Binding = gcnew XmlQualifiedName( myBinding->Name,myServiceDescription->TargetNamespace ); - // Create SoapAddress extensibility element to add to port. - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/BindingCollectionSample/MathService.asmx"; - soapPort->Extensions->Add( mySoapAddressBinding ); - // Add port to the MathService which is the first service in the Service Collection. - myServiceDescription->Services->default[ 0 ]->Ports->Add( soapPort ); - // Save the ServiceDescripition instance to an external file. - myServiceDescription->Write( "MathService_new.wsdl" ); - Console::WriteLine( "\nSuccessfully added bindings for SOAP protocol and saved results in file MathService_new.wsdl" ); - Console::WriteLine( "\n This file should be passed to wsdl tool as input to generate proxy" ); - } -}; - -int main() -{ - MyClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionsample1/CPP/bindingcollectionsample1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionsample1/CPP/bindingcollectionsample1.cpp deleted file mode 100644 index 1e66ce14ccb62..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionsample1/CPP/bindingcollectionsample1.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// System::Web::Services::Description.BindingCollection;System::Web::Services::Description.BindingCollection::Item->Item[Int32]; -// System::Web::Services::Description.BindingCollection::Item->Item[String];System::Web::Services::Description.BindingCollection::CopyTo -/* The program reads a wsdl document S"MathService::wsdl" and instantiates a -// ServiceDescription instance from the WSDL document.A BindingCollection instance -// is then retrieved from this ServiceDescription instance and it's members are demonstrated. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - Binding^ myBinding; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input.wsdl" ); - Console::WriteLine( "Total Number of bindings : {0}", myServiceDescription->Bindings->Count ); - - // - for ( int i = 0; i < myServiceDescription->Bindings->Count; ++i ) - { - Console::WriteLine( "\nBinding {0}", i ); - - // Get Binding at index i. - myBinding = myServiceDescription->Bindings[ i ]; - Console::WriteLine( "\t Name : {0}", myBinding->Name ); - Console::WriteLine( "\t Type : {0}", myBinding->Type ); - } - // - - // - array^myBindings = gcnew array(myServiceDescription->Bindings->Count); - - // Copy BindingCollection to an Array. - myServiceDescription->Bindings->CopyTo( myBindings, 0 ); - Console::WriteLine( "\n\n Displaying array copied from BindingCollection" ); - for ( int i = 0; i < myServiceDescription->Bindings->Count; ++i ) - { - Console::WriteLine( "\nBinding {0}", i ); - Console::WriteLine( "\t Name : {0}", myBindings[ i ]->Name ); - Console::WriteLine( "\t Type : {0}", myBindings[ i ]->Type ); - } - // - - // - // Get Binding Name = S"MathServiceSoap". - myBinding = myServiceDescription->Bindings[ "MathServiceHttpGet" ]; - if ( myBinding != nullptr ) - { - Console::WriteLine( "\n\nName : {0}", myBinding->Name ); - Console::WriteLine( "Type : {0}", myBinding->Type ); - } - // - - myServiceDescription = nullptr; - myBinding = nullptr; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionsample3/CPP/bindingcollectionsample3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionsample3/CPP/bindingcollectionsample3.cpp deleted file mode 100644 index 3be2280b84de5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/BindingCollectionsample3/CPP/bindingcollectionsample3.cpp +++ /dev/null @@ -1,51 +0,0 @@ - - -// System::Web::Services::Description.BindingCollection;System::Web::Services::Description.Remove;System::Web::Services::Description.Add; -// System::Web::Services::Description.Contains;System::Web::Services::Description.IndexOf -/*The following example reads the contents of a file 'MathService::wsdl' into a ServiceDescription instance. -Removes first binding in the BindingCollection of the ServiceDescription instance and writes the current -'ServiceDescription' instance into a temporary file. -Adds the same binding back again into the instance and writes to another temporary file. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - Binding^ myBinding; - - // - // - // - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input.wsdl" ); - Console::WriteLine( "Total Number of bindings defined are: {0}", myServiceDescription->Bindings->Count ); - myBinding = myServiceDescription->Bindings[ 0 ]; - - // Remove the first binding in the collection. - myServiceDescription->Bindings->Remove( myBinding ); - Console::WriteLine( "Successfully removed binding {0}", myBinding->Name ); - Console::WriteLine( "Total Number of bindings defined now are: {0}", myServiceDescription->Bindings->Count ); - myServiceDescription->Write( "MathService_temp.wsdl" ); - // - - // Add binding to the ServiceDescription instance. - myServiceDescription->Bindings->Add( myBinding ); - // - - if ( myServiceDescription->Bindings->Contains( myBinding ) ) - Console::WriteLine( "Successfully added binding {0}", myBinding->Name ); - // - - Console::WriteLine( "Binding was added at index {0}", myServiceDescription->Bindings->IndexOf( myBinding ) ); - Console::WriteLine( "Total Number of bindings defined now are: {0}", myServiceDescription->Bindings->Count ); - myServiceDescription->Write( "MathService_temp1.wsdl" ); - //
- * myServiceDescription = 0; - - myBinding = nullptr; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/client.cpp deleted file mode 100644 index e138ddb4a2ff4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/client.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Principal; -int main() -{ - GenericIdentity^ ident = gcnew GenericIdentity( "Bob" ); - array^id = gcnew array(1); - id[ 0 ] = "Level1"; - GenericPrincipal^ prpal = gcnew GenericPrincipal( ident,id ); - LogicalCallContextData ^ data = gcnew LogicalCallContextData( prpal ); - - //Enter data into the CallContext - CallContext::SetData( "test data", data ); - Console::WriteLine( data->numOfAccesses ); - ChannelServices::RegisterChannel( gcnew TcpChannel ); - RemotingConfiguration::RegisterActivatedClientType( HelloServiceClass::typeid, "tcp://localhost:8082" ); - HelloServiceClass ^ service = gcnew HelloServiceClass; - if ( service == nullptr ) - { - Console::WriteLine( "Could not locate server." ); - return 0; - } - - // call remote method - Console::WriteLine(); - Console::WriteLine( "Calling remote Object*" ); - Console::WriteLine( service->HelloMethod( "Caveman" ) ); - Console::WriteLine( service->HelloMethod( "Spaceman" ) ); - Console::WriteLine( service->HelloMethod( "Bob" ) ); - Console::WriteLine( "Finished remote Object* call" ); - Console::WriteLine(); - - //Extract the returned data from the call context - LogicalCallContextData ^ returnedData = static_cast(CallContext::GetData( "test data" )); - Console::WriteLine( data->numOfAccesses ); - Console::WriteLine( returnedData->numOfAccesses ); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/makefile deleted file mode 100644 index 6eb42d41f53f5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/makefile +++ /dev/null @@ -1,8 +0,0 @@ -all : Client.exe - - -Client.exe : Client.cpp Service.dll - cl /clr:pure Client.cpp - -Service.dll : Service.cpp - cl /clr:pure /LD Service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/service.cpp deleted file mode 100644 index 62c2799b868c2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext/CPP/service.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -using namespace System; -using namespace System::Text; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Principal; - -// -[Serializable] -public ref class LogicalCallContextData: public ILogicalThreadAffinative -{ -private: - int _nAccesses; - IPrincipal^ _principal; - -public: - - property String^ numOfAccesses - { - String^ get() - { - return String::Format( "The identity of {0} has been accessed {1} times.", _principal->Identity->Name, _nAccesses ); - } - } - - property IPrincipal^ Principal - { - IPrincipal^ get() - { - _nAccesses++; - return _principal; - } - } - - LogicalCallContextData( IPrincipal^ p ) - { - _nAccesses = 0; - _principal = p; - } - -}; -// - -// -using namespace System; -using namespace System::Text; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Principal; -using namespace System::Security::Permissions; - -ref class LogicalCallContextData; - -public ref class HelloServiceClass: public MarshalByRefObject -{ -private: - static int n_instances; - int instanceNum; - -public: - HelloServiceClass() - { - n_instances++; - instanceNum = n_instances; - Console::WriteLine( "{0} has been created. Instance # = {1}", this->GetType()->Name, instanceNum ); - } - - ~HelloServiceClass() - { - Console::WriteLine( "Destroyed instance {0} of HelloServiceClass.", instanceNum ); - } - - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - String^ HelloMethod( String^ name ) - { - //Extract the call context data - LogicalCallContextData^ data = dynamic_cast(CallContext::GetData( "test data" )); - IPrincipal^ myPrincipal = data->Principal; - - //Check the user identity - if ( myPrincipal->Identity->Name == "Bob" ) - { - Console::WriteLine( "\nHello {0}, you are identified!", myPrincipal->Identity->Name ); - Console::WriteLine( data->numOfAccesses ); - } - else - { - Console::WriteLine( "Go away! You are not identified!" ); - return String::Empty; - } - - // calculate and return result to client - return String::Format( "Hi there {0}.", name ); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/CallContext_Server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/CallContext_Server.cpp deleted file mode 100644 index 259f7d0d74ffd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/CallContext_Server.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -namespace RemotingSamples -{ - ref class HelloServer - { - public: - static void Main() - { - TcpChannel^ myChannel = gcnew TcpChannel( 8082 ); - ChannelServices::RegisterChannel( myChannel ); - RemotingConfiguration::RegisterActivatedServiceType( HelloService::typeid ); - Console::WriteLine( "Server started." ); - Console::WriteLine( "Hit enter to terminate..." ); - Console::Read(); - } - }; -} - -int main() -{ - RemotingSamples::HelloServer::Main(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/callcontext_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/callcontext_client.cpp deleted file mode 100644 index f5539f7655bcf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/callcontext_client.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// System::Runtime::Remoting::CallContext.FreeNamedDataSlot(String*) -// System::Runtime::Remoting::CallContext.GetHeaders() -// System::Runtime::Remoting::CallContext.SetHeaders(Header->Item[]) - -/* The following example demonstrates 'FreeNamedDataSlot', 'GetHeaders', -and 'SetHeaders' methods of 'CallContext' class. - -In the example 'SetData' method is used to set dataSlot. The 'DataSlot' is freed using -'FreeNamedDataSlot' method by passing the Name parameter. -For Setting header an array of type 'Messaging::Header' is passed with method call. -Headers are set in 'HeaderMethod' of remote Object* using 'SetHeaders' method. -Finally the 'GetHeaders' method is used to get all headers. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Contexts; -using namespace System::Security; -using namespace System::Security::Principal; -using namespace System::Collections; - -int main() -{ -// - // Register the channel. - TcpChannel^ myChannel = gcnew TcpChannel; - ChannelServices::RegisterChannel( myChannel ); - RemotingConfiguration::RegisterActivatedClientType( HelloService::typeid, "Tcp://localhost:8082" ); - - GenericIdentity^ myIdentity = gcnew GenericIdentity( "Bob" ); - array^ idStr = gcnew array(1); - idStr[ 0 ] = "Level1"; - GenericPrincipal^ myPrincipal = gcnew GenericPrincipal( myIdentity, idStr ); - MyLogicalCallContextData ^ myData = gcnew MyLogicalCallContextData( myPrincipal ); - - // Set DataSlot with name parameter. - CallContext::SetData( "test data", myData ); - - // Create a remote Object*. - HelloService ^ myService = gcnew HelloService; - if ( myService == nullptr ) - { - Console::WriteLine( "Cannot locate server." ); - return -1; - } - - // Call the Remote methods. - Console::WriteLine( "Remote method output is {0}", myService->HelloMethod( "Microsoft" ) ); - - MyLogicalCallContextData ^ myReturnData = - (MyLogicalCallContextData^)( CallContext::GetData( "test data" ) ); - if ( myReturnData == nullptr ) - { - Console::WriteLine( "Data is 0." ); - } - else - { - Console::WriteLine( "Data is ' {0}'", myReturnData->numOfAccesses ); - } - - // DataSlot with same Name Parameter which was Set is Freed. - CallContext::FreeNamedDataSlot( "test data" ); - MyLogicalCallContextData ^ myReturnData1 = - (MyLogicalCallContextData^)( CallContext::GetData( "test data" ) ); - if ( myReturnData1 == nullptr ) - { - Console::WriteLine( "FreeNamedDataSlot Successful for test data" ); - } - else - { - Console::WriteLine( "FreeNamedDataSlot Failed for test data" ); - } -// - -// - // Array of Headers with name and values initialized. - array^ myArrSetHeader = { gcnew Header( "Header0","CallContextHeader0" ), - gcnew Header( "Header1","CallContextHeader1" ) }; - - // Pass the Header Array with method call. - // Header will be set in the method by'CallContext::SetHeaders' method in remote Object*. - Console::WriteLine( "Remote HeaderMethod output is {0}", - myService->HeaderMethod( "CallContextHeader", myArrSetHeader ) ); - - array^ myArrGetHeader; - // Get Header Array. - myArrGetHeader = CallContext::GetHeaders(); - if ( nullptr == myArrGetHeader ) - { - Console::WriteLine( "CallContext::GetHeaders Failed" ); - } - else - { - Console::WriteLine( "Headers:" ); - } - - for each ( Header^ myHeader in myArrGetHeader ) - { - Console::WriteLine( "Value in Header '{0}' is '{1}'.", - myHeader->Name, myHeader->Value ); - } -// -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/callcontext_share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/callcontext_share.cpp deleted file mode 100644 index 0881c0e9ab0d1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/callcontext_share.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// System::Runtime::Remoting::CallContext.SetHeaders(Header->Item[]) - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Contexts; -using namespace System::Security; -using namespace System::Security::Principal; -using namespace System::Security::Permissions; - -// -public ref class HelloService: public MarshalByRefObject -{ -public: - String^ HelloMethod( String^ name ) - { - Console::WriteLine( "Hello {0}", name ); - return "Hello {0}",name; - } - - - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - String^ HeaderMethod( String^ name, array^arrHeader ) - { - Console::WriteLine( "HeaderMethod {0}", name ); - - //Header Set with the header array passed - CallContext::SetHeaders( arrHeader ); - return "HeaderMethod {0}",name; - } -}; -// - -// 'CallContext' and 'ILogicalThreadAffinative*' is needed to pass information between threads -// on either end of a call across an application domain boundary or context boundary. - -[Serializable] -public ref class MyLogicalCallContextData: public ILogicalThreadAffinative -{ -private: - int noOfAccesses; - IPrincipal^ myIprincipal; - -public: - property String^ numOfAccesses - { - String^ get() - { - return String::Format( "The identity of {0} has been accessed {1} times.", - myIprincipal->Identity->Name, noOfAccesses ); - } - } - - property IPrincipal^ Principal - { - IPrincipal^ get() - { - noOfAccesses++; - return myIprincipal; - } - } - - MyLogicalCallContextData( IPrincipal^ p ) - { - noOfAccesses = 0; - myIprincipal = p; - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/makefile deleted file mode 100644 index 8ec88e5d193ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CallContext_GetHeaders/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: callcontext_Server.exe callcontext_Client.exe - -callcontext_Server.exe: callcontext_Server.cpp callcontext_Share.dll - cl /clr:pure callcontext_Server.cpp - -callcontext_Client.exe: callcontext_Client.cpp callcontext_Share.dll - cl /clr:pure callcontext_Client.cpp - -callcontext_Share.dll: callcontext_Share.cpp - cl /LD /clr:pure callcontext_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/ChannelServices_GetChannel_Share.cs b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/ChannelServices_GetChannel_Share.cs deleted file mode 100644 index c589c19b77da7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/ChannelServices_GetChannel_Share.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* - This program implments the remote method which will be called by the - client. -*/ -using System; -namespace RemotingSamples -{ - public class HelloServer : MarshalByRefObject - { - public HelloServer() - { - Console.WriteLine("HelloServer activated"); - } - public String HelloMethod(String name) - { - Console.WriteLine("Hello.HelloMethod : {0}", name); - return "Hi there " + name; - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/channelservices_getchannel_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/channelservices_getchannel_client.cpp deleted file mode 100644 index 9bd8438fc367a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/channelservices_getchannel_client.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// System.Runtime.Remoting.Channels.ChannelServices.GetChannel -// System.Runtime.Remoting.Channels.ChannelServices.GetChannelSinkProperties -/* -This example demonstrates the usage of the properties 'GetChannel' and -'GetChannelSinkProperties' of the 'ChannelServices' class. It displays -the registered channel name, priority and channelsinkproperties -for a given proxy and executes a remote method 'HelloMethod'. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Collections; -using namespace System::Collections::Specialized; -int main() -{ - ListDictionary^ myProperties = gcnew ListDictionary; - myProperties->Add( "port", 8085 ); - myProperties->Add( "name", "MyHttpChannel" ); - - // - HttpChannel^ myClientChannel = gcnew HttpChannel( myProperties,gcnew SoapClientFormatterSinkProvider,gcnew SoapServerFormatterSinkProvider ); - ChannelServices::RegisterChannel( myClientChannel, false ); - - // Get the registered channel. - Console::WriteLine( "Channel Name : {0}", ChannelServices::GetChannel( myClientChannel->ChannelName )->ChannelName ); - Console::WriteLine( "Channel Priorty : {0}", ChannelServices::GetChannel( myClientChannel->ChannelName )->ChannelPriority ); - - // - RemotingSamples::HelloServer^ myProxy = dynamic_cast(Activator::GetObject( RemotingSamples::HelloServer::typeid, "http://localhost:8086/SayHello" )); - - // - // Get an IDictionary of properties for a given proxy. - IDictionary^ myDictionary = ChannelServices::GetChannelSinkProperties( myProxy ); - ICollection^ myKeysCollection = myDictionary->Keys; - array^myKeysArray = gcnew array(myKeysCollection->Count); - ICollection^ myValuesCollection = myDictionary->Values; - array^myValuesArray = gcnew array(myValuesCollection->Count); - myKeysCollection->CopyTo( myKeysArray, 0 ); - myValuesCollection->CopyTo( myValuesArray, 0 ); - for ( int iIndex = 0; iIndex < myKeysArray->Length; iIndex++ ) - { - Console::WriteLine( "Property Name : {0} value : {1}", myKeysArray[ iIndex ], myValuesArray[ iIndex ] ); - - } - // - if ( myProxy == nullptr ) - System::Console::WriteLine( "Could not locate server" ); - else - Console::WriteLine( myProxy->HelloMethod( "Caveman" ) ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/makefile deleted file mode 100644 index 75029c096ecd6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_GetChannel/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: ChannelServices_GetChannel_Share.dll channelservices_getchannel_client.exe - -ChannelServices_GetChannel_Share.dll: ChannelServices_GetChannel_Share.cs - csc /t:library ChannelServices_GetChannel_Share.cs - -channelservices_getchannel_client.exe : channelservices_getchannel_client.cpp ChannelServices_GetChannel_Share.dll - cl /clr channelservices_getchannel_client.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/ChannelServices_RegisteredChannels_Share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/ChannelServices_RegisteredChannels_Share.cpp deleted file mode 100644 index 26a3250564c2f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/ChannelServices_RegisteredChannels_Share.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - The class 'HelloServer' is derived from 'MarshalByRefObject' to - make it remotable. -*/ -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; - -namespace RemotingSamples -{ - public ref class HelloServer : public MarshalByRefObject - { -public: - HelloServer() - { - Console::WriteLine("HelloServer activated"); - } - -public: - String^ HelloMethod(String^ myName) - { - Console::WriteLine("Hello.HelloMethod : {0}", myName); - return "Hi there " + myName; - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/channelservices_registeredchannels_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/channelservices_registeredchannels_client.cpp deleted file mode 100644 index 21547e27699b8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/channelservices_registeredchannels_client.cpp +++ /dev/null @@ -1,50 +0,0 @@ - - -// System.Runtime.Remoting.Channels.ChannelServices.GetUrlsForObject(MarshalByRefObject) -/* -The following example demonstrates the method 'GetUrlsForObject' -of the class 'ChannelServices'. The example is just a client, it -locates and connects to the server, retrieves a proxy for the remote -object, and calls the 'HelloMethod' on the remote object, passing the -string 'Caveman' as a parameter. The server returns the string -'Hi there Caveman'. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; - -int main() -{ - try - { - TcpChannel^ myTcpChannel = gcnew TcpChannel( 8084 ); - ChannelServices::RegisterChannel( myTcpChannel ); - RemotingSamples::HelloServer ^ myHelloServer = dynamic_cast(Activator::GetObject( RemotingSamples::HelloServer::typeid, "tcp://localhost:8080/SayHello" )); - if ( myHelloServer == nullptr ) - System::Console::WriteLine( "Could not locate server" ); - else - { - - // - array^myURLArray = ChannelServices::GetUrlsForObject( myHelloServer ); - Console::WriteLine( "Number of URLs for the specified Object: {0}", myURLArray->Length ); - for ( int iIndex = 0; iIndex < myURLArray->Length; iIndex++ ) - Console::WriteLine( "URL: {0}", myURLArray[ iIndex ] ); - // - - Console::WriteLine( myHelloServer->HelloMethod( "Caveman" ) ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "The source of exception: {0}", e->Source ); - Console::WriteLine( "The Message of exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/channelservices_registeredchannels_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/channelservices_registeredchannels_server.cpp deleted file mode 100644 index 66308d4472337..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/channelservices_registeredchannels_server.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -// System.Runtime.Remoting.Channels.ChannelServices -// System.Runtime.Remoting.Channels.ChannelServices.RegisteredChannels -// System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(IChannel[]) -/* -The following example demonstrates the property 'RegisteredChannels' -of the class 'ChannelServices', its method 'UnregisterChannel', -and usage of the class 'ChannelServices'. The example demonstrates -the remoting version of a server. When a client calls the -'HelloMethod' on the 'HelloServer' class, the server object appends the -string passed from the client to the string "Hi There" and returns the -resulting string back to the client. -*/ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; - -int main() -{ - try - { - // - // Create and register 'HttpChannel'. - HttpChannel^ myHttpChannel = gcnew HttpChannel( 8085 ); - ChannelServices::RegisterChannel( myHttpChannel ); - - // Create and register 'TcpChannel'. - TcpChannel^ myTcpChannel = gcnew TcpChannel( 8080 ); - ChannelServices::RegisterChannel( myTcpChannel ); - - // - // Retrieve and print information about the registered channels. - array^myIChannelArray = ChannelServices::RegisteredChannels; - for ( int i = 0; i < myIChannelArray->Length; i++ ) - { - Console::WriteLine( "Name of Channel: {0}", myIChannelArray[ i ]->ChannelName ); - Console::WriteLine( "Priority of Channel: {0}", myIChannelArray[ i ]->ChannelPriority ); - - } - // - RemotingConfiguration::RegisterWellKnownServiceType( Type::GetType( "RemotingSamples.HelloServer,ChannelServices_RegisteredChannels_Share" ), "SayHello", WellKnownObjectMode::SingleCall ); - - // - System::Console::WriteLine( "Hit to unregister the channels..." ); - System::Console::ReadLine(); - - // Unregister the 'HttpChannel' and 'TcpChannel' channels. - ChannelServices::UnregisterChannel( myTcpChannel ); - ChannelServices::UnregisterChannel( myHttpChannel ); - Console::WriteLine( "Unregistered the channels." ); - - // - System::Console::WriteLine( "Hit to exit..." ); - System::Console::ReadLine(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "The source of exception: {0}", e->Source ); - Console::WriteLine( "The Message of exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/makefile deleted file mode 100644 index 94358d96538c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_RegisteredChannels/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: server.exe client.exe - -server.exe: ChannelServices_registeredchannels_Server.cpp ChannelServices_registeredchannels_Share.dll - cl /clr:pure ChannelServices_registeredchannels_Server.cpp - -client.exe: channelservices_registeredchannels_client.cpp ChannelServices_registeredchannels_Share.dll - cl /clr:pure ChannelServices_registeredchannels_client.cpp - -ChannelServices_RegisteredChannels_Share.dll: ChannelServices_RegisteredChannels_Share.cpp - cl /clr:pure /LD ChannelServices_RegisteredChannels_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/ChannelServices_SyncDispatchMessage_share.cs b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/ChannelServices_SyncDispatchMessage_share.cs deleted file mode 100644 index 997024604bf93..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/ChannelServices_SyncDispatchMessage_share.cs +++ /dev/null @@ -1,15 +0,0 @@ -/* - The class 'PrintServer' is derived from 'MarshalByRefObject' to - make it remotable. -*/ -using System; -using System.Runtime.Remoting; -public class PrintServer : MarshalByRefObject -{ - public int MyPrintMethod(String myString, double fValue, int iValue) - { - Console.WriteLine("PrintServer.MyPrintMethod {0} {1} {2}", - myString, fValue, iValue); - return iValue; - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/channelservices_syncdispatchmessage_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/channelservices_syncdispatchmessage_client.cpp deleted file mode 100644 index 9c540f3858aca..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/channelservices_syncdispatchmessage_client.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// System.Runtime.Remoting.Channels.ChannelServices.SyncDispatchMessage(IMessage) -/* - The following example demonstrates 'SyncDispatchMessage' method of - 'ChannelServices' class. In the example, 'MyProxy' extends 'RealProxy' - class and overrides its constructor and 'Invoke' messages. In the 'Main' - method, the 'MyProxy' class is instantiated and 'MyPrintMethod' method - is called on it. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Messaging; - -// -// Create a custom 'RealProxy'. -public ref class MyProxy: public RealProxy -{ -private: - String^ myURIString; - MarshalByRefObject^ myMarshalByRefObject; - -public: - MyProxy( Type^ myType ) - : RealProxy( myType ) - { - - // RealProxy uses the Type to generate a transparent proxy. - myMarshalByRefObject = dynamic_cast(Activator::CreateInstance(myType)); - - // Get 'ObjRef', for transmission serialization between application domains. - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - - // Get the 'URI' property of 'ObjRef' and store it. - myURIString = myObjRef->URI; - Console::WriteLine( "URI :{0}", myObjRef->URI ); - } - - virtual IMessage^ Invoke ( IMessage^ myIMessage ) override - { - Console::WriteLine( "MyProxy.Invoke Start" ); - Console::WriteLine( "" ); - if ( dynamic_cast(myIMessage) ) - Console::WriteLine( "IMethodCallMessage" ); - - if ( dynamic_cast(myIMessage) ) - Console::WriteLine( "IMethodReturnMessage" ); - - Type^ msgType = myIMessage->GetType(); - Console::WriteLine( "Message Type: {0}", msgType ); - Console::WriteLine( "Message Properties" ); - IDictionary^ myIDictionary = myIMessage->Properties; - - // Set the '__Uri' property of 'IMessage' to 'URI' property of 'ObjRef'. - myIDictionary->default[ "__Uri" ] = myURIString; - IDictionaryEnumerator^ myIDictionaryEnumerator = dynamic_cast(myIDictionary->GetEnumerator()); - while ( myIDictionaryEnumerator->MoveNext() ) - { - Object^ myKey = myIDictionaryEnumerator->Key; - String^ myKeyName = myKey->ToString(); - Object^ myValue = myIDictionaryEnumerator->Value; - Console::WriteLine( "\t{0} : {1}", myKeyName, myIDictionaryEnumerator->Value ); - if ( myKeyName->Equals( "__Args" ) ) - { - array^myObjectArray = (array^)myValue; - for ( int aIndex = 0; aIndex < myObjectArray->Length; aIndex++ ) - Console::WriteLine( "\t\targ: {0} myValue: {1}", aIndex, myObjectArray[ aIndex ] ); - } - - if ( (myKeyName->Equals( "__MethodSignature" )) && (nullptr != myValue) ) - { - array^myObjectArray = (array^)myValue; - for ( int aIndex = 0; aIndex < myObjectArray->Length; aIndex++ ) - Console::WriteLine( "\t\targ: {0} myValue: {1}", aIndex, myObjectArray[ aIndex ] ); - } - } - - IMessage^ myReturnMessage; - myIDictionary->default[ "__Uri" ] = myURIString; - Console::WriteLine( "__Uri {0}", myIDictionary->default[ "__Uri" ] ); - Console::WriteLine( "ChannelServices.SyncDispatchMessage" ); - myReturnMessage = ChannelServices::SyncDispatchMessage( myIMessage ); - - // Push return value and OUT parameters back onto stack. - IMethodReturnMessage^ myMethodReturnMessage = dynamic_cast(myReturnMessage); - Console::WriteLine( "IMethodReturnMessage.ReturnValue: {0}", myMethodReturnMessage->ReturnValue ); - Console::WriteLine( "MyProxy.Invoke - Finish" ); - return myReturnMessage; - } -}; -// - -int main() -{ - try - { - TcpChannel^ myTcpChannel = gcnew TcpChannel( 8086 ); - ChannelServices::RegisterChannel( myTcpChannel, false ); - MyProxy^ myProxyObject = gcnew MyProxy( PrintServer::typeid); - PrintServer^ myPrintServer = dynamic_cast(myProxyObject->GetTransparentProxy()); - if ( myPrintServer == nullptr ) - Console::WriteLine( "Could not locate server" ); - else - Console::WriteLine( myPrintServer->MyPrintMethod( "String1", 1.2, 6 ) ); - Console::WriteLine( "Calling the Proxy" ); - int kValue = myPrintServer->MyPrintMethod( "String1", 1.2, 6 ); - Console::WriteLine( "Checking result" ); - if ( kValue == 6 ) - { - Console::WriteLine( "PrintServer.MyPrintMethod PASSED : returned {0}", kValue ); - } - else - { - Console::WriteLine( "PrintServer.MyPrintMethod FAILED : returned {0}", kValue ); - } - Console::WriteLine( "Sample Done" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "The source of exception: {0}", e->Source ); - Console::WriteLine( "The Message of exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/makefile deleted file mode 100644 index 177cf1738ee9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ChannelServices_SyncDispatchMessage/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: ChannelServices_syncdispatchmessage_Share.dll channelservices_syncdispatchMessage_client.exe - -ChannelServices_syncdispatchmessage_Share.dll: ChannelServices_syncdispatchmessage_Share.cs - csc /t:library ChannelServices_syncdispatchmessage_Share.cs - -channelservices_syncdispatchMessage_client.exe: channelservices_syncdispatchmessage_client.cpp ChannelServices_syncdispatchmessage_Share.dll - cl /clr channelservices_syncdispatchmessage_client.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp deleted file mode 100644 index eb8a5c280ac8c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -public ref class Class -{ -private: - void Method1() - { - String^ UserName = Console::ReadLine(); - String^ SecurelyStoredPassword = Console::ReadLine(); - String^ Domain = Console::ReadLine(); - - WebRequest^ wReq = WebRequest::Create( "http://www.contoso.com" ); - - // - CredentialCache^ myCache = gcnew CredentialCache; - - myCache->Add( gcnew Uri( "http://www.contoso.com/" ), "Basic", gcnew NetworkCredential( UserName,SecurelyStoredPassword ) ); - myCache->Add( gcnew Uri( "http://www.contoso.com/" ), "Digest", gcnew NetworkCredential( UserName,SecurelyStoredPassword,Domain ) ); - - wReq->Credentials = myCache; - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp deleted file mode 100644 index 1902e81255b95..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Net; -using namespace System::Windows::Forms; -public ref class Form1: public Form - -{ -protected: - void Method() - { - // - IPHostEntry^ hostInfo = Dns::GetHostEntry( "www.contoso.com" ); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp deleted file mode 100644 index 56d68e22b91c2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -#using - -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Net; -using namespace System; - -// -//Uses the DnsPermissionAttribute to restrict access only to those who have permission. - -[DnsPermission(SecurityAction::Demand,Unrestricted=true)] -public ref class MyClass -{ -public: - static IPAddress^ GetIPAddress() - { - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - return ipAddress; - } - -}; - -int main() -{ - try - { - - //Grants Access. - Console::WriteLine( " Access granted\n The local host IP Address is :{0}", MyClass::GetIPAddress() ); - } - // Denies Access. - catch ( SecurityException^ securityException ) - { - Console::WriteLine( "Access denied" ); - Console::WriteLine( securityException->ToString() ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp deleted file mode 100644 index e4aa5aedcd2f6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - Uri^ proxyURI = gcnew Uri( "http://webproxy:80" ); - GlobalProxySelection::Select = gcnew WebProxy( proxyURI ); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpGetClientProtocol Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpGetClientProtocol Example/CPP/source.cpp deleted file mode 100644 index 4d4eebf4ef862..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpGetClientProtocol Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -public ref class MyMath: public System::Web::Services::Protocols::HttpGetClientProtocol -{ -public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MyMath() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid, - System::Web::Services::Protocols::UrlParameterWriter::typeid)] - [returnvalue:System::Xml::Serialization::XmlRootAttribute("snippet1>",Namespace="http://www.contoso.com/",IsNullable=false)] - int Add( String^ num1, String^ num2 ) - { - array^temp0 = {num1,num2}; - return *dynamic_cast(this->Invoke( "Add", (String::Concat( this->Url, "/Add" )), temp0 )); - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( String^ num1, String^ num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {num1,num2}; - return this->BeginInvoke( "Add", (String::Concat( this->Url, "/Add" )), temp1, callback, asyncState ); - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - return *dynamic_cast(this->EndInvoke( asyncResult )); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpMethodAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpMethodAttribute Example/CPP/source.cpp deleted file mode 100644 index 984c156653d0d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpMethodAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Web; -using namespace System::Web::UI; - -// -[System::Xml::Serialization::XmlRootAttribute(Namespace="http://tempuri.org/",IsNullable=true)] -public ref class UserName -{ -public: - String^ Name; - String^ Domain; -}; - -public ref class MyUser: public System::Web::Services::Protocols::HttpPostClientProtocol -{ -public: - MyUser() - { - this->Url = "http://www.contoso.com/username.asmx"; - } - - [System::Web::Services::Protocols::HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid,System::Web::Services::Protocols::HtmlFormParameterWriter::typeid)] - UserName^ GetUserName() - { - return (dynamic_cast(this->Invoke( "GetUserName", (String::Concat( this->Url, "/GetUserName" )), gcnew array(0) ))); - } - - System::IAsyncResult^ BeginGetUserName( System::AsyncCallback^ callback, Object^ asyncState ) - { - return this->BeginInvoke( "GetUserName", (String::Concat( this->Url, "/GetUserName" )), gcnew array(0), callback, asyncState ); - } - - UserName^ EndGetUserName( System::IAsyncResult^ asyncResult ) - { - return (dynamic_cast(this->EndInvoke( asyncResult ))); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpMethodAttribute.ReturnFormatter Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpMethodAttribute.ReturnFormatter Example/CPP/source.cpp deleted file mode 100644 index 3d8283f1fa73b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpMethodAttribute.ReturnFormatter Example/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Web; -using namespace System::Web::UI; - -// -[System::Xml::Serialization::XmlRootAttribute(Namespace="http://tempuri.org/",IsNullable=true)] -public ref class UserName -{ -public: - String^ Name; - String^ Domain; -}; - -public ref class MyUser: public System::Web::Services::Protocols::HttpGetClientProtocol -{ -public: - MyUser() - { - this->Url = "http://www.contoso.com/username.asmx"; - } - - [System::Web::Services::Protocols::HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid,System::Web::Services::Protocols::UrlParameterWriter::typeid)] - UserName^ GetUserName() - { - return (dynamic_cast(this->Invoke( "GetUserName", (String::Concat( this->Url, "/GetUserName" )), gcnew array(0) ))); - } - - System::IAsyncResult^ BeginGetUserName( System::AsyncCallback^ callback, Object^ asyncState ) - { - return this->BeginInvoke( "GetUserName", (String::Concat( this->Url, "/GetUserName" )), gcnew array(0), callback, asyncState ); - } - - UserName^ EndGetUserName( System::IAsyncResult^ asyncResult ) - { - return (dynamic_cast(this->EndInvoke( asyncResult ))); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpPostClientProtocol Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpPostClientProtocol Example/CPP/source.cpp deleted file mode 100644 index 57e073dd49c0a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpPostClientProtocol Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -public ref class MyMath: public System::Web::Services::Protocols::HttpPostClientProtocol -{ -public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MyMath() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid, - System::Web::Services::Protocols::HtmlFormParameterWriter::typeid)] - [returnvalue:System::Xml::Serialization::XmlRootAttribute("snippet1>",Namespace="http://www.contoso.com/",IsNullable=false)] - int Add( String^ num1, String^ num2 ) - { - array^temp2 = {num1,num2}; - return *dynamic_cast(this->Invoke( "Add", (String::Concat( this->Url, "/Add" )), temp2 )); - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( String^ num1, String^ num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp3 = {num1,num2}; - return this->BeginInvoke( "Add", (this->Url + "/Add" ), temp3, callback, asyncState ); - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - return *dynamic_cast(this->EndInvoke( asyncResult )); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpSimpleClientProtocol Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpSimpleClientProtocol Example/CPP/source.cpp deleted file mode 100644 index 4c25623d8ecb4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpSimpleClientProtocol Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using -#using - -using namespace System::Web::Services; -using namespace System; -public ref class Math -{ -public: - - [WebMethod] - int Add( int num1, int num2 ) - { - return num1 + num2; - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpSimpleClientProtocol.EndInvoke Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpSimpleClientProtocol.EndInvoke Example/CPP/source.cpp deleted file mode 100644 index 87d6b7f28b35b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpSimpleClientProtocol.EndInvoke Example/CPP/source.cpp +++ /dev/null @@ -1,43 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Xml::Serialization; -using namespace System::Web::Services::Protocols; - -// -namespace MyMath -{ - [XmlRootAttribute("snippet1>",Namespace="http://MyMath/",IsNullable=false)] - public ref class Math: public HttpGetClientProtocol - { - public: - Math() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - [HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid, - System::Web::Services::Protocols::UrlParameterWriter::typeid)] - int Add( String^ num1, String^ num2 ) - { - array^temp0 = {num1,num2}; - return *dynamic_cast(this->Invoke( "Add", String::Concat( this->Url, "/Add" ), temp0 )); - } - - IAsyncResult^ BeginAdd( String^ num1, String^ num2, AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {num1,num2}; - return this->BeginInvoke( "Add", String::Concat( this->Url, "/Add" ), temp1, callback, asyncState ); - } - - int EndAdd( IAsyncResult^ asyncResult ) - { - return *dynamic_cast(this->EndInvoke( asyncResult )); - } - }; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpStatusCode Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpStatusCode Example/CPP/source.cpp deleted file mode 100644 index 99fcc00b893b6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpStatusCode Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web; -using namespace System::Web::UI; - -public ref class Page1: public Page -{ -private: - void Page_Load( Object^ /*sender*/, EventArgs^ /*e*/ ) - { - // - HttpWebRequest^ httpReq = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - httpReq->AllowAutoRedirect = false; - HttpWebResponse^ httpRes = dynamic_cast(httpReq->GetResponse()); - if ( httpRes->StatusCode == HttpStatusCode::Moved ) - { - // Code for moved resources goes here. - } - - // Close the response. - httpRes->Close(); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebClientProtocol.Proxy Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebClientProtocol.Proxy Example/CPP/source.cpp deleted file mode 100644 index b705fba6e3b3a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebClientProtocol.Proxy Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Web; -using namespace System::Web::UI; -using namespace System::Net; - -namespace MyMath -{ -using namespace System::Xml::Serialization; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - public ref class Math: public SoapHttpClientProtocol - { - public: - int Add( int num1, int num2 ) - { - return num1 + num2; - } - }; -} - -public ref class Page1: public Page -{ -private: - void Page_Load( Object^ /*sender*/, EventArgs^ /*e*/ ) - { - // - MyMath::Math^ math = gcnew MyMath::Math; - - // Set the proxy server to proxyserver, set the port to 80, and specify to bypass the proxy server - // for local addresses. - IWebProxy^ proxyObject = gcnew WebProxy( "http://proxyserver:80",true ); - math->Proxy = proxyObject; - - // Call the Add XML Web service method. - int total = math->Add( 8, 5 ); - - // - } -}; - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp deleted file mode 100644 index 16cbdf361c8ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp +++ /dev/null @@ -1,16 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -public ref class Sample -{ -public: - void Method() - { - // - HttpWebRequest^ myReq = dynamic_cast(WebRequest::Create( "http://www.contoso.com/" )); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.ConnectionGroupName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.ConnectionGroupName Example/CPP/source.cpp deleted file mode 100644 index 47df278d8ec99..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.ConnectionGroupName Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web; -using namespace System::Web::UI; -using namespace System::Security::Cryptography; -using namespace System::Text; -int main() -{ - // - // Create a secure group name. - SHA1Managed^ Sha1 = gcnew SHA1Managed; - array^updHash = Sha1->ComputeHash( Encoding::UTF8->GetBytes( "usernamepassworddomain" ) ); - String^ secureGroupName = Encoding::Default->GetString( updHash ); - - // Create a request for a specific URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Set the authentication credentials for the request. - myWebRequest->Credentials = gcnew NetworkCredential( "username","password","domain" ); - myWebRequest->ConnectionGroupName = secureGroupName; - - // Get the response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Insert the code that uses myWebResponse here. - // Close the response. - myWebResponse->Close(); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp deleted file mode 100644 index 352469e1bea12..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web; -using namespace System::Web::UI; - -public ref class Page1: public Page -{ -private: - void Page_Load( Object^, EventArgs^ ) - { - HttpWebRequest^ req = dynamic_cast(WebRequest::Create( "http://www.contoso.com/" )); - - // - bool hasChanged = req->RequestUri->Equals( req->Address ); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp deleted file mode 100644 index 945bd743eee48..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web; -using namespace System::Web::UI; - -public ref class Page1: public Page -{ -private: - void Page_Load( Object^, EventArgs^ ) - { - // - HttpWebRequest^ HttpWReq = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - HttpWebResponse^ HttpWResp = dynamic_cast(HttpWReq->GetResponse()); - - // Insert code that uses the response object. - HttpWResp->Close(); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic ICertificatePolicy Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic ICertificatePolicy Example/CPP/source.cpp deleted file mode 100644 index 8d014c2ed724f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic ICertificatePolicy Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security::Cryptography::X509Certificates; - -// -public enum class CertificateProblem : UInt32 -{ - CertEXPIRED = 0x800B0101, - CertVALIDITYPERIODNESTING = 0x800B0102, - CertROLE = 0x800B0103, - CertPATHLENCONST = 0x800B0104, - CertCRITICAL = 0x800B0105, - CertPURPOSE = 0x800B0106, - CertISSUERCHAINING = 0x800B0107, - CertMALFORMED = 0x800B0108, - CertUNTRUSTEDROOT = 0x800B0109, - CertCHAINING = 0x800B010A, - CertREVOKED = 0x800B010C, - CertUNTRUSTEDTESTROOT = 0x800B010D, - CertREVOCATION_FAILURE = 0x800B010E, - CertCN_NO_MATCH = 0x800B010F, - CertWRONG_USAGE = 0x800B0110, - CertUNTRUSTEDCA = 0x800B0112 -}; - -public ref class MyCertificateValidation: public ICertificatePolicy -{ -public: - - // Default policy for certificate validation. - static bool DefaultValidate = false; - virtual bool CheckValidationResult( ServicePoint^ /*sp*/, X509Certificate^ /*cert*/, WebRequest^ request, int problem ) - { - bool ValidationResult = false; - Console::WriteLine( "Certificate Problem with accessing {0}", request->RequestUri ); - Console::Write( "Problem code 0x{0:X8},", (int)problem ); - Console::WriteLine( GetProblemMessage( (CertificateProblem)problem ) ); - ValidationResult = DefaultValidate; - return ValidationResult; - } - -private: - String^ GetProblemMessage( CertificateProblem Problem ) - { - String^ ProblemMessage = ""; - CertificateProblem problemList = CertificateProblem( ); - String^ ProblemCodeName = Enum::GetName( problemList.GetType(), Problem ); - if ( ProblemCodeName != nullptr ) - ProblemMessage = String::Concat( ProblemMessage, "-Certificateproblem:", ProblemCodeName ); - else - ProblemMessage = "Unknown Certificate Problem"; - - return ProblemMessage; - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp deleted file mode 100644 index ef840b46dcf6f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class Sample -{ -protected: - void Method( Socket^ mySocket ) - { - // - LingerOption^ myOpts = gcnew LingerOption( true,1 ); - mySocket->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Linger, myOpts ); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp deleted file mode 100644 index 925df3ee81f1a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - String^ SecurelyStoredUserName = ""; - String^ SecurelyStoredPassword = ""; - String^ SecurelyStoredDomain = ""; - - // - NetworkCredential^ myCred = gcnew NetworkCredential( - SecurelyStoredUserName,SecurelyStoredPassword,SecurelyStoredDomain ); - - CredentialCache^ myCache = gcnew CredentialCache; - - myCache->Add( gcnew Uri( "www.contoso.com" ), "Basic", myCred ); - myCache->Add( gcnew Uri( "app.contoso.com" ), "Basic", myCred ); - - WebRequest^ wr = WebRequest::Create( "www.contoso.com" ); - wr->Credentials = myCache; - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp deleted file mode 100644 index 4613eef823668..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -using namespace System; -using namespace System::Runtime::Serialization; - -// Class added so sample will compile -ref class Node -{ -public: - Node( int /*i*/ ){} -}; - -// -// A serializable LinkedList example. For the full LinkedList implementation -// see the Serialization sample. -[Serializable] -ref class LinkedList: public ISerializable -{ -private: - Node^ m_head; - Node^ m_tail; - - // Serializes the object. -public: - virtual void GetObjectData( SerializationInfo^ info, StreamingContext /*context*/ ) - { - // Stores the m_head and m_tail references in the SerializationInfo info. - info->AddValue( "head", m_head, m_head->GetType() ); - info->AddValue( "tail", m_tail, m_tail->GetType() ); - } - - // Constructor that is called automatically during deserialization. -private: - // Reconstructs the object from the information in SerializationInfo info - LinkedList( SerializationInfo^ info, StreamingContext /*context*/ ) - { - Node^ temp = gcnew Node( 0 ); - // Retrieves the values of Type temp.GetType() from SerializationInfo info - m_head = dynamic_cast(info->GetValue( "head", temp->GetType() )); - m_tail = dynamic_cast(info->GetValue( "tail", temp->GetType() )); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp deleted file mode 100644 index 1a04a196a241d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - Uri^ myUri = gcnew Uri( "http://www.contoso.com/" ); - ServicePoint^ mySP = ServicePointManager::FindServicePoint( myUri ); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp deleted file mode 100644 index 7a9fdb446393e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Windows::Forms; -using namespace System::Web; -using namespace System::Web::Services; - -// Class added so sample will compile -public ref class MyCertificatePolicy: public ICertificatePolicy -{ -public: - virtual bool CheckValidationResult( System::Net::ServicePoint^, System::Security::Cryptography::X509Certificates::X509Certificate^, System::Net::WebRequest^, int ) - { - return true; - } -}; - -public ref class Form1: public Form -{ -public: - void Method( Uri^ myUri ) - { - // - ServicePointManager::CertificatePolicy = gcnew MyCertificatePolicy; - - // Create the request and receive the response - try - { - WebRequest^ myRequest = WebRequest::Create( myUri ); - WebResponse^ myResponse = myRequest->GetResponse(); - ProcessResponse( myResponse ); - myResponse->Close(); - } - // Catch any exceptions - catch ( WebException^ e ) - { - if ( e->Status == WebExceptionStatus::TrustFailure ) - { - // Code for handling security certificate problems goes here. - } - // Other exception handling goes here - } - // - } - - // Method added so sample will compile - void ProcessResponse( WebResponse^ ){} -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension Example/CPP/source.cpp deleted file mode 100644 index 40bea86464b32..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension Example/CPP/source.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; -using namespace System::IO; -using namespace System::Net; - -ref class TraceExtension; - -// Create a SoapExtensionAttribute for the SOAP Extension that can be -// applied to an XML Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class TraceExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ filename; - int priority; - -public: - TraceExtensionAttribute() - : filename( "c:\\log.txt" ) - {} - - property Type^ ExtensionType - { - virtual Type^ get() override - { - return TraceExtension::typeid; - } - } - - property int Priority - { - virtual int get() override - { - return priority; - } - virtual void set( int value ) override - { - priority = value; - } - } - - property String^ Filename - { - String^ get() - { - return filename; - } - void set( String^ value ) - { - filename = value; - } - } -}; - -// Define a SOAP Extension that traces the SOAP request and SOAP -// response for the XML Web service method the SOAP extension is -// applied to. -public ref class TraceExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // Save the Stream representing the SOAP request or SOAP response into - // a local memory buffer. - virtual Stream^ ChainStream( Stream^ stream ) override - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - // When the SOAP extension is accessed for the first time, the XML Web - // service method it is applied to is accessed to store the file - // name passed in, using the corresponding SoapExtensionAttribute. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) override - { - return (dynamic_cast(attribute))->Filename; - } - - // The SOAP extension was configured to run using a configuration file - // instead of an attribute applied to a specific XML Web service - // method. - virtual Object^ GetInitializer( Type^ WebServiceType ) override - { - // Return a file name to log the trace information to, based on the - // type. - return String::Format( "C:\\{0}.log", WebServiceType->FullName ); - } - - // Receive the file name stored by GetInitializer and store it in a - // member variable for this specific instance. - virtual void Initialize( Object^ initializer ) override - { - filename = dynamic_cast(initializer); - } - - // If the SoapMessageStage is such that the SoapRequest or - // SoapResponse is still in the SOAP format to be sent or received, - // save it out to a file. - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - case SoapMessageStage::AfterDeserialize: - break; - } - } - - void WriteOutput( SoapMessage^ message ) - { - newStream->Position = 0; - FileStream^ fs = gcnew FileStream( filename, FileMode::Append, - FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - - String^ soapString = ( (SoapServerMessage^)( message ) ) ? - (String^)"SoapResponse" : "SoapRequest"; - w->WriteLine( "-----{0} at {1}", soapString, DateTime::Now ); - w->Flush(); - Copy( newStream, fs ); - w->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - void WriteInput( SoapMessage^ message ) - { - Copy( oldStream, newStream ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - String^ soapString = (dynamic_cast(message)) ? (String^)"SoapRequest" : "SoapResponse"; - w->WriteLine( "-----{0} at {1}", soapString, DateTime::Now ); - w->Flush(); - newStream->Position = 0; - Copy( newStream, fs ); - w->Close(); - newStream->Position = 0; - } - - void Copy( Stream^ from, Stream^ to ) - { - TextReader^ reader = gcnew StreamReader( from ); - TextWriter^ writer = gcnew StreamWriter( to ); - writer->WriteLine( reader->ReadToEnd() ); - writer->Flush(); - } -}; -// - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.ChainStream Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.ChainStream Example/CPP/source.cpp deleted file mode 100644 index dfe63fe65f339..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.ChainStream Example/CPP/source.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; -using namespace System::IO; - -ref class TraceExtension; - -// Create a SoapExtensionAttribute for our SOAP Extension that can be -// applied to an XML Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class TraceExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ filename; - int priority; - -public: - TraceExtensionAttribute() - : filename( "c:\\log.txt" ) - {} - - property Type^ ExtensionType - { - virtual Type^ get() override - { - return TraceExtension::typeid; - } - } - - property int Priority - { - virtual int get() override - { - return priority; - } - virtual void set( int value ) override - { - priority = value; - } - } - - property String^ Filename - { - String^ get() - { - return filename; - } - void set( String^ value ) - { - filename = value; - } - } -}; - - -// Define a SOAP Extension that traces the SOAP request and SOAP response -// for the XML Web service method, the SOAP extension is applied to. -public ref class TraceExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // When the SOAP extension is accessed for the first time the XML Web service method it is applied - // is accessed store the filename passed in using the corresponding SoapExtensionAttribute. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) override - { - return (dynamic_cast(attribute))->Filename; - } - - // The extension was configured to run using a configuration file instead of an attribute applied to a - // specific XML Web service method. Return a file name based on the class implementing the XML Web service's type. - virtual Object^ GetInitializer( Type^ WebServiceType ) override - { - // Return a file name to log the trace information to based on the passed in type. - return String::Format( "C:\\{0}.log", WebServiceType->FullName ); - } - - // Receive the filename stored by GetInitializer and store it in a member variable - // for this specific instance. - virtual void Initialize( Object^ initializer ) override - { - filename = dynamic_cast(initializer); - } - - // If the SoapMessageStage is such that the SoapRequest or SoapResponse is still in the SOAP - // format to be sent or received over the wire, save it out to filename passed in using the SoapExtensionAttribute - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - case SoapMessageStage::AfterDeserialize: - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Save the Stream representing the SOAP request or SOAP response into a local memory buffer - // -public: - virtual Stream^ ChainStream( Stream^ stream ) override - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - // - - void WriteOutput( SoapMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "---------------------------------- Response at {0}", DateTime::Now ); - w->Flush(); - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - void WriteInput( SoapMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "================================== Request at {0}", DateTime::Now ); - w->Flush(); - newStream->Position = 0; - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - } - - void Copy( Stream^ from, Stream^ to ) - { - TextReader^ reader = gcnew StreamReader( from ); - TextWriter^ writer = gcnew StreamWriter( to ); - writer->WriteLine( reader->ReadToEnd() ); - writer->Flush(); - } -}; - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.GetInitializer Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.GetInitializer Example/CPP/source.cpp deleted file mode 100644 index 98113ace5c674..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.GetInitializer Example/CPP/source.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; -using namespace System::IO; - -ref class TraceExtension; - -// Create a SoapExtensionAttribute for our SOAP Extension that can be -// applied to an XML Web service method. - -[AttributeUsage(AttributeTargets::Method)] -public ref class TraceExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ filename; - int priority; - -public: - TraceExtensionAttribute() - : filename( "c:\\log.txt" ) - {} - - property Type^ ExtensionType - { - virtual Type^ get() override - { - return TraceExtension::typeid; - } - } - - property int Priority - { - virtual int get() override - { - return priority; - } - virtual void set( int value ) override - { - priority = value; - } - } - - property String^ Filename - { - String^ get() - { - return filename; - } - void set( String^ value ) - { - filename = value; - } - } -}; - -// Define a SOAP Extension that traces the SOAP request and SOAP response -// for the XML Web service method, the SOAP extension is applied to. -public ref class TraceExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - - // -public: - // When the SOAP extension is accessed for the first time, cache the - // file name passed in by the SoapExtensionAttribute. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) override - { - return (dynamic_cast(attribute))->Filename; - } - // - - // The extension was configured to run using a configuration file instead of an attribute applied to a - // specific XML Web service method. Return a file name based on the class implementing the XML Web service's type. - virtual Object^ GetInitializer( Type^ WebServiceType ) override - { - // Return a file name to log the trace information to based on the passed in type. - return String::Format( "C:\\{0}.log", WebServiceType->FullName ); - } - - // Receive the filename stored by GetInitializer and store it in a member variable - // for this specific instance. - virtual void Initialize( Object^ initializer ) override - { - filename = dynamic_cast(initializer); - } - - // If the SoapMessageStage is such that the SoapRequest or SoapResponse is still in the SOAP - // format to be sent or received over the wire, save it out to filename passed in using the SoapExtensionAttribute - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - case SoapMessageStage::AfterDeserialize: - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Save the Stream representing the SOAP request or SOAP response into a local memory buffer - virtual Stream^ ChainStream( Stream^ stream ) override - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - void WriteOutput( SoapMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "---------------------------------- Response at {0}", DateTime::Now ); - w->Flush(); - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - void WriteInput( SoapMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "================================== Request at {0}", DateTime::Now ); - w->Flush(); - newStream->Position = 0; - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - } - - void Copy( Stream^ from, Stream^ to ) - { - TextReader^ reader = gcnew StreamReader( from ); - TextWriter^ writer = gcnew StreamWriter( to ); - writer->WriteLine( reader->ReadToEnd() ); - writer->Flush(); - } -}; - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.Initialize Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.Initialize Example/CPP/source.cpp deleted file mode 100644 index 8fdb714ad46d0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.Initialize Example/CPP/source.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; -using namespace System::IO; - -ref class TraceExtension; - -// Create a SoapExtensionAttribute for our SOAP Extension that can be -// applied to an XML Web service method. - -[AttributeUsage(AttributeTargets::Method)] -public ref class TraceExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ filename; - int priority; - -public: - TraceExtensionAttribute() - : filename( "c:\\log.txt" ) - {} - - property Type^ ExtensionType - { - virtual Type^ get() override - { - return TraceExtension::typeid; - } - } - - property int Priority - { - virtual int get() override - { - return priority; - } - virtual void set( int value ) override - { - priority = value; - } - } - - property String^ Filename - { - String^ get() - { - return filename; - } - void set( String^ value ) - { - filename = value; - } - } -}; - -// Define a SOAP Extension that traces the SOAP request and SOAP response -// for the XML Web service method, the SOAP extension is applied to. -public ref class TraceExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // When the SOAP extension is accessed for the first time the XML Web service method it is applied - // is accessed store the filename passed in using the corresponding SoapExtensionAttribute. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) override - { - return (dynamic_cast(attribute))->Filename; - } - - virtual Object^ GetInitializer( Type^ filename ) override - { - return dynamic_cast(filename); - } - - // - // Receive the file name stored by GetInitializer and store it in - // a member variable for this specific instance. -public: - virtual void Initialize( Object^ initializer ) override - { - filename = dynamic_cast(initializer); - } - // - - // If the SoapMessageStage is such that the SoapRequest or SoapResponse is still in the SOAP - // format to be sent or received over the wire, save it out to filename passed in using the SoapExtensionAttribute - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - case SoapMessageStage::AfterDeserialize: - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Save the Stream representing the SOAP request or SOAP response into a local memory buffer - virtual Stream^ ChainStream( Stream^ stream ) override - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - void WriteOutput( SoapMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "---------------------------------- Response at {0}", DateTime::Now ); - w->Flush(); - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - void WriteInput( SoapMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "================================== Request at {0}", DateTime::Now ); - w->Flush(); - newStream->Position = 0; - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - } - - void Copy( Stream^ from, Stream^ to ) - { - TextReader^ reader = gcnew StreamReader( from ); - TextWriter^ writer = gcnew StreamWriter( to ); - writer->WriteLine( reader->ReadToEnd() ); - writer->Flush(); - } -}; - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.ProcessMessage Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.ProcessMessage Example/CPP/source.cpp deleted file mode 100644 index b15566f7beabc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtension.ProcessMessage Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Web; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; - -public ref class Sample: public SoapExtension -{ - // -public: - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - - case SoapMessageStage::AfterDeserialize: - break; - - - } - } - // - - virtual Object^ GetInitializer( LogicalMethodInfo^ /*lmi*/, SoapExtensionAttribute^ /*sea*/ ) override - { - // method added so sample will compile - Object^ myobject = gcnew Object; - return myobject; - } - - virtual void Initialize( Object^ /*o*/ ) override - { - - // method added so sample will compile - } - - void WriteOutput( SoapMessage^ /*message*/ ) - { - - // method added so sample will compile - } - - void WriteInput( SoapMessage^ /*message*/ ) - { - - // method added so sample will compile - } - - virtual Object^ GetInitializer( Type^ filename ) override - { - return dynamic_cast(filename); - } - -}; - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtensionAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtensionAttribute Example/CPP/source.cpp deleted file mode 100644 index f1845cb9d2db5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapExtensionAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; -using namespace System::IO; - -// Class added so sample will compile -public ref class TraceExtension{}; - -// -// Create a SoapExtensionAttribute for a SOAP extension that can be -// applied to an XML Web service method. - -[AttributeUsage(AttributeTargets::Method)] -public ref class TraceExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - - // Set the name of the log file were SOAP messages will be stored. - TraceExtensionAttribute() - : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - property Type^ ExtensionType - { - // Return the type of 'TraceExtension' class. - virtual Type^ get() override - { - return TraceExtension::typeid; - } - } - - property int Priority - { - // User can set priority of the 'SoapExtension'. - virtual int get() override - { - return myPriority; - } - - virtual void set( int value ) override - { - myPriority = value; - } - } - - property String^ Filename - { - String^ get() - { - return myFilename; - } - - void set( String^ value ) - { - myFilename = value; - } - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeader.Actor Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeader.Actor Example/CPP/source.cpp deleted file mode 100644 index 789a774b3b2af..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeader.Actor Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Web::Services::Protocols; - -// Following was added to make the sample compile. -public ref class MyHeader: public SoapHeader -{ -public: - String^ MyValue; -}; - -public ref class MyWebService -{ -public: - MyHeader^ myHeader; - int MyWebMethod( int num1, int num2 ) - { - return num1 + num2; - } - -}; - - -// -int main() -{ - MyWebService^ ws = gcnew MyWebService; - try - { - MyHeader^ customHeader = gcnew MyHeader; - customHeader->MyValue = "Header Value for MyValue"; - customHeader->Actor = "http://www.contoso.com/MySoapHeaderHandler"; - ws->myHeader = customHeader; - int results = ws->MyWebMethod( 3, 5 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeader.MustUnderstand Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeader.MustUnderstand Example/CPP/source.cpp deleted file mode 100644 index 20b8623788405..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeader.MustUnderstand Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -#using -#using - -using namespace System::Web::Services::Protocols; -using namespace System; - -// Following was added to make the sample compile. -public ref class MyHeader: public SoapHeader -{ -public: - String^ MyValue; -}; - -public ref class MyWebService -{ -public: - MyHeader^ myHeader; - int MyWebMethod( int num1, int num2 ) - { - return num1 + num2; - } - -}; - - -// -int main() -{ - MyWebService^ ws = gcnew MyWebService; - try - { - MyHeader^ customHeader = gcnew MyHeader; - customHeader->MyValue = "Header Value for MyValue"; - customHeader->MustUnderstand = true; - ws->myHeader = customHeader; - int results = ws->MyWebMethod( 3, 5 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeaderAttribute.MemberName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeaderAttribute.MemberName Example/CPP/source.cpp deleted file mode 100644 index eb179a86c8866..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeaderAttribute.MemberName Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; - -// Define a SOAP header by deriving from the SoapHeader base class. -// The header contains just one string value. -public ref class MyHeader: public SoapHeader -{ -public: - String^ MyValue; -}; - -public ref class MyWebService -{ -public: - - // Member variable to receive the contents of the MyHeader SOAP header. - MyHeader^ myHeader; - - [WebMethod] - [SoapHeader("myHeader",Direction=SoapHeaderDirection::InOut)] - void Hello(){} - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeaderDirection Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeaderDirection Example/CPP/source.cpp deleted file mode 100644 index 2c181c54c3b33..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHeaderDirection Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Web; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; - -// -public ref class MyHeader: public SoapHeader -{ -public: - String^ MyValue; -}; - -public ref class MyWebService -{ -public: - MyHeader^ myHeader; - - [WebMethod] - [SoapHeader("myHeader", - Direction=SoapHeaderDirection::InOut|SoapHeaderDirection::Fault)] - void MySoapHeaderReceivingMethod() - { - - // Set myHeader->MyValue to some value. - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol Example/CPP/source.cpp deleted file mode 100644 index b46a3f5ba8681..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -namespace MyMath -{ - - [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap",Namespace="http://www.contoso.com/")] - public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MyMath() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://www.contoso.com/Add", - RequestNamespace="http://www.contoso.com/",ResponseNamespace="http://www.contoso.com/", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int num1, int num2 ) - { - array^temp0 = {num1,num2}; - array^results = this->Invoke( "Add", temp0 ); - return *dynamic_cast(results[ 0 ]); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {num1,num2}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } - - }; - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.BeginInvoke Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.BeginInvoke Example/CPP/source.cpp deleted file mode 100644 index 1a106c1b0b7db..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.BeginInvoke Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -namespace MyMath -{ - - [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap",Namespace="http://www.contoso.com/")] - public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MyMath() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://www.contoso.com/Add", - RequestNamespace="http://www.contoso.com/",ResponseNamespace="http://www.contoso.com/", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int num1, int num2 ) - { - array^temp1 = {num1,num2}; - array^results = this->Invoke( "Add", temp1 ); - return *dynamic_cast(results[ 0 ]); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp2 = {num1,num2}; - return this->BeginInvoke( "Add", temp2, callback, asyncState ); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } - - }; - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.EndInvoke Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.EndInvoke Example/CPP/source.cpp deleted file mode 100644 index 9cdfc4f439da0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.EndInvoke Example/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -namespace MyMath -{ - - [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap",Namespace="http://www.contoso.com/")] - public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MyMath() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://www.contoso.com/Add",RequestNamespace="http://www.contoso.com/",ResponseNamespace="http://www.contoso.com/",Use=System::Web::Services::Description::SoapBindingUse::Literal,ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int num1, int num2 ) - { - array^temp0 = {num1,num2}; - array^results = this->Invoke( "Add", temp0 ); - return *dynamic_cast(results[ 0 ]); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {num1,num2}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } - - }; - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.Invoke Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.Invoke Example/CPP/source.cpp deleted file mode 100644 index b46a3f5ba8681..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapHttpClientProtocol.Invoke Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -namespace MyMath -{ - - [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap",Namespace="http://www.contoso.com/")] - public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MyMath() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://www.contoso.com/Add", - RequestNamespace="http://www.contoso.com/",ResponseNamespace="http://www.contoso.com/", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int num1, int num2 ) - { - array^temp0 = {num1,num2}; - array^results = this->Invoke( "Add", temp0 ); - return *dynamic_cast(results[ 0 ]); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {num1,num2}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } - - }; - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapMessage.EnsureStage Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapMessage.EnsureStage Example/CPP/source.cpp deleted file mode 100644 index 12e7ead33321a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SoapMessage.EnsureStage Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -namespace EnsureStageExample -{ - public enum class SoapMessageStage - { - BeforeSerialize = 1, - BeforeDeserialize = 2 - }; - - ref class Class1 - { - public: - static void main() - { - // - EnsureStage( (SoapMessageStage)( SoapMessageStage::BeforeSerialize | - SoapMessageStage::BeforeDeserialize ) ); - // - } - - private: - //This method is a standin for the real method so that the example will compile - static void EnsureStage( SoapMessageStage /*sms*/ ){} - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp deleted file mode 100644 index e1e657e660b0b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class Sample -{ - // -protected: - void AcceptMethod( Socket^ listeningSocket ) - { - Socket^ mySocket = listeningSocket->Accept(); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp deleted file mode 100644 index 6c46b3b92d775..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class Sample -{ -protected: - void Method( Socket^ aSocket, EndPoint^ anEndPoint ) - { - // - try - { - aSocket->Bind( anEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Winsock error: {0}", e ); - } - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp deleted file mode 100644 index 2e51128de6396..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Security::Permissions; - -public ref class Sample -{ -protected: - [SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)] - void Method( Socket^ aSocket ) - { - // - try - { - aSocket->Shutdown(SocketShutdown::Both); - aSocket->Close(); - } - catch (...) - { - aSocket->Close(); - throw; - } - - if ( aSocket->Connected ) - { - Console::WriteLine( "Winsock error: {0}", Convert::ToString( - System::Runtime::InteropServices::Marshal::GetLastWin32Error() ) ); - } - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp deleted file mode 100644 index 6693a8bdfcc7f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -static void ConnectAndCheck( Socket^ client, EndPoint^ anEndPoint ) -{ - // - client->Connect( anEndPoint ); - if ( !client->Connected ) - { - Console::WriteLine( "Winsock error: {0}", Convert::ToString( - System::Runtime::InteropServices::Marshal::GetLastWin32Error() ) ); - } - - // This is how you can determine whether a socket is still connected. - bool blockingState = client->Blocking; - try - { - array^tmp = gcnew array(1); - client->Blocking = false; - client->Send( tmp, 0, static_cast(0) ); - Console::WriteLine( L"Connected!" ); - } - catch ( SocketException^ e ) - { - // 10035 == WSAEWOULDBLOCK - if ( e->NativeErrorCode.Equals( 10035 ) ) - { - Console::WriteLine( "Connected from an exception!" ); - } - else - { - Console::WriteLine( "Disconnected: {0}!", e->NativeErrorCode ); - } - } - finally - { - client->Blocking = blockingState; - } - - Console::WriteLine( "Connected: {0}", client->Connected ); - // -} - -[STAThread] -int main() -{ - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - - String^ host = "localhost"; - int port = 80; - - IPHostEntry^ hostEntry = Dns::Resolve( host ); - IPEndPoint^ EPHost = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],port ); - - ConnectAndCheck( s, EPHost ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp deleted file mode 100644 index 66f68944d8625..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -void CreateAndListen( int port, int backlog ) -{ - // - // create the socket - Socket^ listenSocket = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - - // bind the listening socket to the port - IPAddress^ hostIP = ( Dns::Resolve( IPAddress::Any->ToString() ) )->AddressList[ 0 ]; - IPEndPoint^ ep = gcnew IPEndPoint( hostIP,port ); - listenSocket->Bind( ep ); - - // start listening - listenSocket->Listen( backlog ); - // -} - -[STAThread] -int main() -{ - CreateAndListen( 10042, 10 ); - Console::WriteLine( "enter to exit" ); - Console::Read(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp deleted file mode 100644 index 27d0003bd8bde..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -void MySerializeIPEndPointClassMethod() -{ - // - //Creates an IpEndPoint. - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - //Serializes the IPEndPoint. - SocketAddress^ socketAddress = ipLocalEndPoint->Serialize(); - - //Verifies that ipLocalEndPoint is now serialized by printing its contents. - Console::WriteLine( "Contents of the socketAddress are: {0}", socketAddress ); - //Checks the Family property. - Console::WriteLine( "The address family of the socketAddress is: {0}", socketAddress->Family ); - //Checks the underlying buffer size. - Console::WriteLine( "The size of the underlying buffer is: {0}", socketAddress->Size ); - // -} - -int main() -{ - MySerializeIPEndPointClassMethod(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index 719fbbc6521ae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length == 1 ) - { - Console::WriteLine( "Enter a selection" ); - return 0; - } - - if ( args[ 1 ] == "endpointExample" ) - { - // - //Creates an instance of the TcpListener class by providing a local endpoint. - - IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - try - { - TcpListener^ tcpListener = gcnew TcpListener( ipLocalEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - if ( args[ 1 ] == "ipAddressExample" ) - { - // - //Creates an instance of the TcpListener class by providing a local IP address and port number. - - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - - try - { - TcpListener^ tcpListener = gcnew TcpListener( ipAddress,13 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - if ( args[ 1 ] == "portNumberExample" ) - { - // - //Creates an instance of the TcpListener class by providing a local port number. - - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - - try - { - TcpListener^ tcpListener = gcnew TcpListener( ipAddress,13 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - { - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - TcpListener^ tcpListener = gcnew TcpListener( ipAddress,13 ); - tcpListener->Start(); - Console::WriteLine( "Waiting for a connection...." ); - - try - { - // - // Accepts the pending client connection and returns a socket for communciation. - Socket^ socket = tcpListener->AcceptSocket(); - Console::WriteLine( "Connection accepted." ); - - String^ responseString = "You have successfully connected to me"; - - //Forms and sends a response string to the connected client. - array^sendBytes = Encoding::ASCII->GetBytes( responseString ); - int i = socket->Send( sendBytes ); - Console::WriteLine( "Message Sent /> : {0}", responseString ); - // - - //Any communication with the remote client using the socket can go here. - - //Closes the tcpListener and the socket. - socket->Shutdown( SocketShutdown::Both ); - socket->Close(); - tcpListener->Stop(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp deleted file mode 100644 index c216c7fe3f72e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -/** -* This program shows how to use the TcpListener class. -* It creates a TcpListener that listens on the specified port (13000). -* To run this program at the command line you enter: -* cs_tcpserver -* Any TcpClient that wants to use this server -* has to explicitly connect to an address obtained by the combination of -* the server on which this TcpServer is running and the port 13000. -* This TcpServer simply echoes back the message sent by the TcpClient, after -* translating it into uppercase. -**/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -int main() -{ - try - { - - // Set the TcpListener on port 13000. - Int32 port = 13000; - TcpListener^ server = gcnew TcpListener(IPAddress::Any, port); - - // Start listening for client requests. - server->Start(); - - // Buffer for reading data - array^bytes = gcnew array(256); - String^ data = nullptr; - - // Enter the listening loop. - while ( true ) - { - Console::Write( "Waiting for a connection... " ); - - // Perform a blocking call to accept requests. - // You could also use server.AcceptSocket() here. - TcpClient^ client = server->AcceptTcpClient(); - Console::WriteLine( "Connected!" ); - data = nullptr; - - // Get a stream object for reading and writing - NetworkStream^ stream = client->GetStream(); - Int32 i; - - // Loop to receive all the data sent by the client. - while ( (i = stream->Read( bytes, 0, bytes->Length )) != 0 ) - { - - // Translate data bytes to a ASCII string. - data = System::Text::Encoding::ASCII->GetString( bytes, 0, i ); - Console::WriteLine( String::Format( "Received: {0}", data ) ); - - // Process the data sent by the client. - data = data->ToUpper(); - array^msg = System::Text::Encoding::ASCII->GetBytes( data ); - - // Send back a response. - stream->Write( msg, 0, msg->Length ); - Console::WriteLine( String::Format( "Sent: {0}", data ) ); - } - - // Shutdown and end connection - client->Close(); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException: {0}", e ); - } - - Console::WriteLine( "\nHit enter to continue..." ); - Console::Read(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index 8c3fe28953809..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -// -// This derived class demonstrate the use of three protected methods belonging to the UdpClient class. -public ref class MyUdpClientDerivedClass: public UdpClient -{ -public: - MyUdpClientDerivedClass() - : UdpClient() - {} - - void UsingProtectedMethods() - { - //Uses the protected Active property belonging to the UdpClient base class to determine if a connection is established. - if ( this->Active ) - { - //Calls the protected Client property belonging to the UdpClient base class. - Socket^ s = this->Client; - - //Uses the Socket returned by Client to set an option that is not available using UdpClient. - s->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Broadcast, 1 ); - } - } -}; -// - -int main() -{ - MyUdpClientDerivedClass^ myUdpClientDerivedClass = gcnew MyUdpClientDerivedClass; - myUdpClientDerivedClass->UsingProtectedMethods(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index b18e50746069f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class MyUdpClientExample -{ -public: - // MyUdpClientConstructor is just used to illustrate the different constructors available in the UdpClient class. - static void MyUdpClientConstructor( String^ myConstructorType ) - { - if ( myConstructorType->Equals( "PortNumberExample" ) ) - { - // - //Creates an instance of the UdpClient class to listen on - // the default interface using a particular port. - try - { - UdpClient^ udpClient = gcnew UdpClient( 11000 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConstructorType->Equals( "LocalEndPointExample" ) ) - { - // - //Creates an instance of the UdpClient class using a local endpoint. - IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - try - { - UdpClient^ udpClient = gcnew UdpClient( ipLocalEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConstructorType->Equals( "HostNameAndPortNumExample" ) ) - { - // - //Creates an instance of the UdpClient class with a remote host name and a port number. - try - { - UdpClient^ udpClient = gcnew UdpClient( "www.contoso.com",11000 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConstructorType->Equals( "DefaultExample" ) ) - { - // - //Creates an instance of the UdpClient class using the default constructor. - UdpClient^ udpClient = gcnew UdpClient; - // - } - else - { - // Do nothing. - } - } - - // MyUdpClientConnection method is just used to illustrate the different connection methods of UdpClient class. - static void MyUdpClientConnection( String^ myConnectionType ) - { - if ( myConnectionType->Equals( "HostnameAndPortNumExample" ) ) - { - // - //Uses a host name and port number to establish a socket connection. - UdpClient^ udpClient = gcnew UdpClient; - try - { - udpClient->Connect( "www.contoso.com", 11002 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConnectionType == "IPAddressAndPortNumExample" ) - { - // - //Uses the IP address and port number to establish a socket connection. - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - try - { - udpClient->Connect( ipAddress, 11003 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConnectionType == "RemoteEndPointExample" ) - { - // - //Uses a remote endpoint to establish a socket connection. - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddress,11004 ); - try - { - udpClient->Connect( ipEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - { - // Do nothing. - } - } - - // This class demonstrates sending and receiving using a Udp socket. - static void MyUdpClientCommunicator( String^ mySendType ) - { - if ( mySendType == "EndPointExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddress,11004 ); - - array^ sendBytes = Encoding::ASCII->GetBytes( "Is anybody there?" ); - try - { - udpClient->Send( sendBytes, sendBytes->Length, ipEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( mySendType == "HostNameAndPortNumberExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - - array^ sendBytes = Encoding::ASCII->GetBytes( "Is anybody there" ); - try - { - udpClient->Send( sendBytes, sendBytes->Length, "www.contoso.com", 11000 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( mySendType == "StraightSendExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient( "www.contoso.com",11000 ); - array^ sendBytes = Encoding::ASCII->GetBytes( "Is anybody there" ); - try - { - udpClient->Send( sendBytes, sendBytes->Length ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - { - // Do nothing. - } - - // - //Creates a UdpClient for reading incoming data. - UdpClient^ receivingUdpClient = gcnew UdpClient( 11000 ); - - //Creates an IPEndPoint to record the IP Address and port number of the sender. - // The IPEndPoint will allow you to read datagrams sent from any source. - IPEndPoint^ RemoteIpEndPoint = gcnew IPEndPoint( IPAddress::Any,0 ); - try - { - // Blocks until a message returns on this socket from a remote host. - array^receiveBytes = receivingUdpClient->Receive( RemoteIpEndPoint ); - - String^ returnData = Encoding::ASCII->GetString( receiveBytes ); - - Console::WriteLine( "This is the message you received {0}", returnData ); - Console::WriteLine( "This message was sent from {0} on their port number {1}", - RemoteIpEndPoint->Address, RemoteIpEndPoint->Port ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - - // This example class demonstrates methods used to join and drop multicast groups. - static void MyUdpClientMulticastConfiguration( String^ myAction ) - { - if ( myAction == "JoinMultiCastExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ multicastIpAddress = Dns::Resolve( "MulticastGroupName" )->AddressList[ 0 ]; - try - { - udpClient->JoinMulticastGroup( multicastIpAddress ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myAction == "JoinMultiCastWithTimeToLiveExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - // Creates an IPAddress to use to join and drop the multicast group. - IPAddress^ multicastIpAddress = IPAddress::Parse( "239.255.255.255" ); - - try - { - // The packet dies after 50 router hops. - udpClient->JoinMulticastGroup( multicastIpAddress, 50 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - - // - // Informs the server that you want to remove yourself from the multicast client list. - try - { - udpClient->DropMulticastGroup( multicastIpAddress ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - - // - // Closes the UDP client by calling the public method Close(). - udpClient->Close(); - // - } - else - { - // Do nothing. - } - } -}; -//end class - -int main() -{ - // For our example, we will use the default constructor. - MyUdpClientExample::MyUdpClientConstructor( "defaultExample" ); - MyUdpClientExample::MyUdpClientConnection( "HostNameAndPortNumExample" ); - MyUdpClientExample::MyUdpClientCommunicator( "EndPointExample" ); - MyUdpClientExample::MyUdpClientMulticastConfiguration( "JoinMultiCastExample" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp deleted file mode 100644 index 12a033e105eee..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -int main() -{ - // - // With this constructor the local port number is arbitrarily assigned. - UdpClient^ udpClient = gcnew UdpClient; - try - { - udpClient->Connect( "host.contoso.com", 11000 ); - - // Send message to the host to which you have connected. - array^sendBytes = Encoding::ASCII->GetBytes( "Is anybody there?" ); - udpClient->Send( sendBytes, sendBytes->Length ); - - // Send message to a different host using optional hostname and port parameters. - UdpClient^ udpClientB = gcnew UdpClient; - udpClientB->Send( sendBytes, sendBytes->Length, "AlternateHostMachineName", 11000 ); - - //IPEndPoint object will allow us to read datagrams sent from any source. - IPEndPoint^ RemoteIpEndPoint = gcnew IPEndPoint( IPAddress::Any,0 ); - - // Block until a message returns on this socket from a remote host. - array^receiveBytes = udpClient->Receive( RemoteIpEndPoint ); - String^ returnData = Encoding::ASCII->GetString( receiveBytes ); - - // Use the IPEndPoint object to determine which of these two hosts responded. - Console::WriteLine( String::Concat( "This is the message you received ", returnData->ToString() ) ); - Console::WriteLine( String::Concat( "This message was sent from ", RemoteIpEndPoint->Address->ToString(), " on their port number ", RemoteIpEndPoint->Port.ToString() ) ); - udpClient->Close(); - udpClientB->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp deleted file mode 100644 index 50ec230906cf7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Net; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - void Method() - { - // - Uri^ siteUri = gcnew Uri( "http://www.contoso.com/" ); - WebRequest^ wr = WebRequest::Create( siteUri ); - // - } -}; - -void main() -{ - Form1^ f = gcnew Form1; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsolutePath Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsolutePath Example/CPP/source.cpp deleted file mode 100644 index 1d511f22f6b4b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsolutePath Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - void Method() - { - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->AbsolutePath ); - // - } -}; - -void main() -{ - Form1^ f = gcnew Form1; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsoluteUri Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsoluteUri Example/CPP/source.cpp deleted file mode 100644 index f5adb1e6dc0ce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsoluteUri Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->AbsoluteUri ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Authority Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Authority Example/CPP/source.cpp deleted file mode 100644 index 2cb8990b9d084..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Authority Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com:8080/" ); - Uri^ myUri = gcnew Uri( baseUri,"shownew.htm?date=today" ); - Console::WriteLine( myUri->Authority ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.CheckHostName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.CheckHostName Example/CPP/source.cpp deleted file mode 100644 index 0d5b9b878972b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.CheckHostName Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Console::WriteLine( Uri::CheckHostName( "www.contoso.com" ) ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Host Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Host Example/CPP/source.cpp deleted file mode 100644 index db24745352e4f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Host Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com:8080/" ); - Uri^ myUri = gcnew Uri( baseUri,"shownew.htm?date=today" ); - Console::WriteLine( myUri->Host ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.PathAndQuery Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.PathAndQuery Example/CPP/source.cpp deleted file mode 100644 index 77b48ab3d8296..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.PathAndQuery Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri, "catalog/shownew.htm?date=today" ); - - Console::WriteLine( myUri->PathAndQuery ); - // -} - -void Method2() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri, "catalog/shownew.htm?date=today" ); - - Console::WriteLine( myUri->Query ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Port Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Port Example/CPP/source.cpp deleted file mode 100644 index 2298149c10295..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Port Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->Port ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Scheme Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Scheme Example/CPP/source.cpp deleted file mode 100644 index 2a79562ae4cfc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Scheme Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->Scheme ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp deleted file mode 100644 index 1977347df49ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp deleted file mode 100644 index 74ea933f0d169..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ myUri = gcnew Uri( "http://www.contoso.com/Hello%20World.htm",true ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp deleted file mode 100644 index aa310799d843c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com" ); - Uri^ myUri = gcnew Uri( baseUri, "catalog/shownew.htm" ); - Console::WriteLine( myUri->ToString() ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri4 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri4 Example/CPP/source.cpp deleted file mode 100644 index 1cd0cad631055..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri4 Example/CPP/source.cpp +++ /dev/null @@ -1,12 +0,0 @@ - - -#using - -using namespace System; -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"Hello%20World.htm",false ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp deleted file mode 100644 index 7d57c1f31fb35..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ uBuild = gcnew UriBuilder( "http://www.contoso.com/" ); - uBuild->Path = "index.htm"; - uBuild->Fragment = "main"; - Uri^ myUri = uBuild->Uri; - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp deleted file mode 100644 index 8ed7f68ec92ca..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http", "www.contoso.com" ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp deleted file mode 100644 index af69e8f961a84..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http", "www.contoso.com",8080 ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp deleted file mode 100644 index 6c6a09487e188..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http","www.contoso.com",8080,"index.htm" ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp deleted file mode 100644 index 3e0bf14858e68..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http","www.contoso.com",8080,"index.htm","#top" ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebClientProtocol.Timeout Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebClientProtocol.Timeout Example/CPP/source.cpp deleted file mode 100644 index cecb1ef607214..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebClientProtocol.Timeout Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -using namespace System; - -// Struct added so sample will compile -public value struct myMath -{ -public: - int Timeout; -}; - -public ref class Sample -{ -public: - void sampleFunction() - { - myMath math = myMath( ); - - // - math.Timeout = 15000; - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebClientProtocol.Url Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebClientProtocol.Url Example/CPP/source.cpp deleted file mode 100644 index 3e503131573d1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebClientProtocol.Url Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ -using namespace System; - -// Class added so sample will compile -public ref class myMath -{ -public: - String^ Url; - int Add( int /*a*/, int /*b*/ ) - { - return 0; - } -}; - -// Structure added so sample will compile -public value struct myNum -{ -public: - String^ Text; -}; - -public ref class Sample -{ -public: - void sampleFunction() - { - myMath^ math = gcnew myMath; - myNum Num1 = myNum( ); - myNum Num2 = myNum( ); - - // - // Set the URL property to a different Web server than that described in the - // service description. - math->Url = "http://www.contoso.com/math.asmx"; - int total = math->Add( Convert::ToInt32( Num1.Text ), Convert::ToInt32( Num2.Text ) ); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp deleted file mode 100644 index 166f9d97f7f41..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; - -public ref class Sample -{ -private: - void sampleFunction() - { - // - WebProxy^ proxyObject = gcnew WebProxy( "http://proxyserver:80/",true ); - WebRequest^ req = WebRequest::Create( "http://www.contoso.com" ); - req->Proxy = proxyObject; - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp deleted file mode 100644 index 2a706abc691ab..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; - -public ref class Sample -{ -private: - void sampleFunction() - { - // - // Initialize the WebRequest. - WebRequest^ myRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Return the response. - WebResponse^ myResponse = myRequest->GetResponse(); - - // Code to use the WebResponse goes here. - - // Close the response to free resources. - myResponse->Close(); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp deleted file mode 100644 index ef3028f80a50f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; - -public ref class Sample -{ -private: - void sampleFunction() - { - // - WebRequest^ myRequest = WebRequest::Create( "http://www.contoso.com" ); - // - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp deleted file mode 100644 index 557ea7d00c843..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class XClass -{ -public: - - /* Apply the XmlAnyElementAttribute to a field returning an array - of XmlElement objects. */ - - [XmlAnyElement] - array^AllElements; -}; - -public ref class Test -{ -public: - void DeserializeObject( String^ filename ) - { - // Create an XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( XClass::typeid ); - - // To read a file, a FileStream is needed. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Deserialize the class. - XClass^ x = dynamic_cast(mySerializer->Deserialize( fs )); - - // Read the element names and values. - System::Collections::IEnumerator^ myEnum = x->AllElements->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlElement^ xel = safe_cast(myEnum->Current); - Console::WriteLine( "{0}: {1}", xel->LocalName, xel->Value ); - } - } -}; - -int main() -{ - Test^ t = gcnew Test; - t->DeserializeObject( "XFile.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp deleted file mode 100644 index 7824f3ba5cbe5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Item -{ -public: - - [XmlElement(ElementName="OrderItem")] - String^ ItemName; - String^ ItemCode; - Decimal ItemPrice; - int ItemQuantity; -}; - -public ref class BookItem: public Item -{ -public: - String^ Title; - String^ Author; - String^ ISBN; -}; - -// This is the class that will be serialized. -public ref class MyRootClass -{ -private: - array^items; - -public: - - /* Here is a simple way to serialize the array as XML. Using the - XmlArrayAttribute, assign an element name and namespace. The - IsNullable property determines whether the element will be - generated if the field is set to a null value. If set to true, - the default, setting it to a null value will cause the XML - xsi:null attribute to be generated. */ - - [XmlArray(ElementName="MyStrings", - Namespace="http://www.cpandl.com",IsNullable=true)] - array^MyStringArray; - - /* Here is a more complex example of applying an - XmlArrayAttribute. The Items property can contain both Item - and BookItem objects. Use the XmlArrayItemAttribute to specify - that both types can be inserted into the array. */ - [XmlArrayItem(ElementName="Item", - IsNullable=true, - Type=Item::typeid, - Namespace="http://www.cpandl.com"), - XmlArrayItem(ElementName="BookItem", - IsNullable=true, - Type=BookItem::typeid, - Namespace="http://www.cohowinery.com")] - [XmlArray] - property array^ Items - { - array^ get() - { - return items; - } - - void set( array^value ) - { - items = value; - } - } -}; - -public ref class Run -{ -public: - void SerializeDocument( String^ filename ) - { - // Creates a new XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( MyRootClass::typeid ); - - // Writing the file requires a StreamWriter. - TextWriter^ myWriter = gcnew StreamWriter( filename ); - - // Creates an instance of the class to serialize. - MyRootClass^ myRootClass = gcnew MyRootClass; - - /* Uses a basic method of creating an XML array: Create and - populate a string array, and assign it to the - MyStringArray property. */ - array^myString = {"Hello","world","!"}; - myRootClass->MyStringArray = myString; - - /* Uses a more advanced method of creating an array: - create instances of the Item and BookItem, where BookItem - is derived from Item. */ - Item^ item1 = gcnew Item; - BookItem^ item2 = gcnew BookItem; - - // Sets the objects' properties. - item1->ItemName = "Widget1"; - item1->ItemCode = "w1"; - item1->ItemPrice = 231; - item1->ItemQuantity = 3; - item2->ItemCode = "w2"; - item2->ItemPrice = 123; - item2->ItemQuantity = 7; - item2->ISBN = "34982333"; - item2->Title = "Book of Widgets"; - item2->Author = "John Smith"; - - // Fills the array with the items. - array^myItems = {item1,item2}; - - // Sets the class's Items property to the array. - myRootClass->Items = myItems; - - /* Serializes the class, writes it to disk, and closes - the TextWriter. */ - s->Serialize( myWriter, myRootClass ); - myWriter->Close(); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeDocument( "books.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index dc6cfc478abf9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Book -{ -public: - String^ Title; - String^ Author; - String^ ISBN; -}; - -public ref class Library -{ -private: - array^books; - -public: - - [XmlArray(ElementName="My_Books")] - property array^ Books - { - array^ get() - { - return books; - } - - void set( array^value ) - { - books = value; - } - } -}; - -int main() -{ - String^ filename = "ArrayExample.xml"; - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - TextWriter^ t = gcnew StreamWriter( filename ); - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "bk", "http://wwww.contoso.com" ); - Book^ b1 = gcnew Book; - b1->Title = "MyBook Title"; - b1->Author = "An Author"; - b1->ISBN = "00000000"; - Book^ b2 = gcnew Book; - b2->Title = "Another Title"; - b2->Author = "Another Author"; - b2->ISBN = "0000000"; - Library^ myLibrary = gcnew Library; - array^myBooks = {b1,b2}; - myLibrary->Books = myBooks; - mySerializer->Serialize( t, myLibrary, ns ); - t->Close(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 84965bcbf7ad7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,111 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; -public ref class Winery -{ -public: - String^ Name; -}; - -public ref class VacationCompany -{ -public: - String^ Name; -}; - -public ref class Enterprises -{ -private: - array^wineries; - array^companies; - -public: - - // Sets the Form property to qualified, and specifies the namespace. - [XmlArray(Form=XmlSchemaForm::Qualified,ElementName="Company", - Namespace="http://www.cohowinery.com")] - property array^ Wineries - { - array^ get() - { - return wineries; - } - void set( array^value ) - { - wineries = value; - } - } - - [XmlArray(Form=XmlSchemaForm::Qualified,ElementName="Company", - Namespace="http://www.treyresearch.com")] - property array^ Companies - { - array^ get() - { - return companies; - } - void set( array^value ) - { - companies = value; - } - } -}; - -int main() -{ - String^ filename = "MyEnterprises.xml"; - - // Creates an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Enterprises::typeid ); - - // Writing file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Creates an instance of the XmlSerializerNamespaces class. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Adds namespaces and prefixes for the XML document instance. - ns->Add( "winery", "http://www.cohowinery.com" ); - ns->Add( "vacationCompany", "http://www.treyresearch.com" ); - - // Creates an instance of the class that will be serialized. - Enterprises^ myEnterprises = gcnew Enterprises; - - // Creates objects and adds to the array. - Winery^ w1 = gcnew Winery; - w1->Name = "cohowinery"; - array^myWinery = {w1}; - myEnterprises->Wineries = myWinery; - VacationCompany^ com1 = gcnew VacationCompany; - com1->Name = "adventure-works"; - array^myCompany = {com1}; - myEnterprises->Companies = myCompany; - - // Serializes the class, and closes the TextWriter. - mySerializer->Serialize( writer, myEnterprises, ns ); - writer->Close(); -} - -void ReadEnterprises( String^ filename ) -{ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Enterprises::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Enterprises^ myEnterprises = dynamic_cast(mySerializer->Deserialize( fs )); - for ( int i = 0; i < myEnterprises->Wineries->Length; i++ ) - { - Console::WriteLine( myEnterprises->Wineries[ i ]->Name ); - } - for ( int i = 0; i < myEnterprises->Companies->Length; i++ ) - { - Console::WriteLine( myEnterprises->Companies[ i ]->Name ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index b04f9de845eef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlArray(IsNullable=true)] - array^IsNullableIsTrueArray; - - [XmlArray(IsNullable=false)] - array^IsNullableIsFalseArray; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index ffc20656b48d2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,162 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Book -{ -public: - String^ Title; - String^ Author; - String^ ISBN; - - [XmlAttributeAttribute] - String^ Publisher; -}; - -public ref class Periodical -{ -private: - String^ title; - -public: - - property String^ Title - { - String^ get() - { - return title; - } - void set( String^ value ) - { - title = value; - } - } -}; - -public ref class Library -{ -private: - array^books; - array^periodicals; - -public: - - /* This element will be qualified with the prefix - that is associated with the namespace http://wwww.cpandl.com. */ - [XmlArray(ElementName="Titles", - Namespace="http://wwww.cpandl.com")] - property array^ Books - { - array^ get() - { - return books; - } - void set( array^value ) - { - books = value; - } - } - - /* This element will be qualified with the prefix that is - associated with the namespace http://www.proseware.com. */ - [XmlArray(ElementName="Titles",Namespace= - "http://www.proseware.com")] - property array^ Periodicals - { - array^ get() - { - return periodicals; - } - void set( array^value ) - { - periodicals = value; - } - } -}; - -void WriteBook( String^ filename ) -{ - // Creates a new XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - - // Writing the file requires a StreamWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - /* Creates an XmlSerializerNamespaces and adds prefixes and - namespaces to be used. */ - XmlSerializerNamespaces^ myNamespaces = gcnew XmlSerializerNamespaces; - myNamespaces->Add( "books", "http://wwww.cpandl.com" ); - myNamespaces->Add( "magazines", "http://www.proseware.com" ); - - // Creates an instance of the class to be serialized. - Library^ myLibrary = gcnew Library; - - // Creates two book objects. - Book^ b1 = gcnew Book; - b1->Title = "My Book Title"; - b1->Author = "An Author"; - b1->ISBN = "000000000"; - b1->Publisher = "Microsoft Press"; - Book^ b2 = gcnew Book; - b2->Title = "Another Book Title"; - b2->Author = "Another Author"; - b2->ISBN = "00000001"; - b2->Publisher = "Another Press"; - - /* Creates an array using the objects, and sets the Books property - to the array. */ - array^myBooks = {b1,b2}; - myLibrary->Books = myBooks; - - // Creates two Periodical objects. - Periodical^ per1 = gcnew Periodical; - per1->Title = "My Magazine Title"; - Periodical^ per2 = gcnew Periodical; - per2->Title = "Another Magazine Title"; - - // Sets the Periodicals property to the array. - array^myPeridocials = {per1,per2}; - myLibrary->Periodicals = myPeridocials; - - // Serializes the myLibrary object. - mySerializer->Serialize( myStreamWriter, myLibrary, myNamespaces ); - myStreamWriter->Close(); -} - -void ReadBook( String^ filename ) -{ - /* Creates an instance of an XmlSerializer - with the class used to read the document. */ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - - // A FileStream is needed to read the file. - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Library^ myLibrary = dynamic_cast(mySerializer->Deserialize( myFileStream )); - - // Reads each book in the array returned by the Books property. - for ( int i = 0; i < myLibrary->Books->Length; i++ ) - { - Console::WriteLine( myLibrary->Books[ i ]->Title ); - Console::WriteLine( myLibrary->Books[ i ]->Author ); - Console::WriteLine( myLibrary->Books[ i ]->ISBN ); - Console::WriteLine( myLibrary->Books[ i ]->Publisher ); - Console::WriteLine(); - } - for ( int i = 0; i < myLibrary->Periodicals->Length; i++ ) - { - Console::WriteLine( myLibrary->Periodicals[ i ]->Title ); - } -} - -int main() -{ - WriteBook( "MyLibrary.xml" ); - ReadBook( "MyLibrary.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp deleted file mode 100644 index 78a6040f3fa5d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlArrayAttribute] - array^MyStringArray; - - [XmlArrayAttribute] - array^MyIntegerArray; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp deleted file mode 100644 index 9b68919eff81a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class MyClass -{ -public: - - [XmlArrayAttribute("MyStrings")] - array^MyStringArray; - - [XmlArrayAttribute(ElementName="MyIntegers")] - array^MyIntegerArray; -}; - -int main() -{ - String^ filename = "MyClass.xml"; - - // Creates a new instance of the XmlSerializer class. - XmlSerializer^ s = gcnew XmlSerializer( MyClass::typeid ); - - // Needs a StreamWriter to write the file. - TextWriter^ myWriter = gcnew StreamWriter( filename ); - MyClass^ myClass = gcnew MyClass; - - // Creates and populates a string array, then assigns - // it to the MyStringArray property. - array^myStrings = {"Hello","World","!"}; - myClass->MyStringArray = myStrings; - - /* Creates and populates an integer array, and assigns - it to the MyIntegerArray property. */ - array^myIntegers = {1,2,3}; - myClass->MyIntegerArray = myIntegers; - - // Serializes the class, and writes it to disk. - s->Serialize( myWriter, myClass ); - myWriter->Close(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp deleted file mode 100644 index 7504aad63a35a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,93 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - /* The XmlArrayItemAttribute allows the XmlSerializer to insert - both the base type (Employee) and derived type (Manager) - into serialized arrays. */ - - [XmlArrayItem(Manager::typeid), - XmlArrayItem(Employee::typeid)] - array^Employees; - - /* Use the XmlArrayItemAttribute to specify types allowed - in an array of Object items. */ - - [XmlArray] - [XmlArrayItem(Int32::typeid, - ElementName="MyNumber"), - XmlArrayItem(String::typeid, - ElementName="MyString"), - XmlArrayItem(Manager::typeid)] - array^ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Creates a new XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ group = gcnew Group; - Manager^ manager = gcnew Manager; - Employee^ emp1 = gcnew Employee; - Employee^ emp2 = gcnew Employee; - manager->Name = "Consuela"; - manager->Level = 3; - emp1->Name = "Seiko"; - emp2->Name = "Martina"; - array^emps = {manager,emp1,emp2}; - group->Employees = emps; - - // Creates an int and a string and assigns to ExtraInfo. - array^temp = {43,"Extra",manager}; - group->ExtraInfo = temp; - - // Serializes the object, and closes the StreamWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::WriteLine( "Members:" ); - System::Collections::IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}", e->Name ); - } -} - -int main() -{ - SerializeObject( "TypeDoc.xml" ); - DeserializeObject( "TypeDoc.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index 1ad1f494f358b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// By default, this class results in XML elements named "Vehicle". -public ref class Vehicle -{ -public: - String^ id; -}; - -// By default, this class results in XML elements named "Car". -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - /* Specifies acceptable types and the ElementName generated - for each object type. */ - - [XmlArray("Vehicles")] - [XmlArrayItem(Vehicle::typeid,ElementName="Transport"), - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 6f0101ea001e2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - // Specifies the Form property value. - - [XmlArray("Vehicles")] - [XmlArrayItem(Vehicle::typeid, - Form=XmlSchemaForm::Unqualified), - XmlArrayItem(Car::typeid, - Form=XmlSchemaForm::Qualified)] - array^MyVehicles; -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 10b3c35b2f145..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - [XmlArray(IsNullable=true)] - [XmlArrayItem(Manager::typeid,IsNullable=false), - XmlArrayItem(Employee::typeid,IsNullable=false)] - array^Employees; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Creates the object to serialize. - Group^ group = gcnew Group; - - // Creates a null Manager object. - Manager^ mgr = nullptr; - - // Creates a null Employee object. - Employee^ y = nullptr; - array^temp = {mgr,y}; - group->Employees = temp; - - // Serializes the object and closes the TextWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -int main() -{ - SerializeObject( "TypeDoc.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 41cc05bd3444c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Vehicle{}; - -public ref class Car: public Vehicle{}; - -// -public ref class Transportation -{ -public: - - // Sets the Namespace property. - - [XmlArrayItem(Car::typeid,Namespace="http://www.cpandl.com")] - array^MyVehicles; -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index b249fa9707cba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Person -{ -public: - String^ Name; -}; - -public ref class Manager: public Person -{ -public: - int Rank; -}; - -public ref class Group -{ -public: - - /* The Type property instructs the XmlSerializer to accept both - the Person and Manager types in the array. */ - - [XmlArrayItem(Type=Manager::typeid), - XmlArrayItem(Type=Person::typeid)] - array^Staff; -}; - -void SerializeOrder( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid ); - - // Creates the Group object, and two array items. - Group^ myGroup = gcnew Group; - Person^ p1 = gcnew Person; - p1->Name = "Jacki"; - Manager^ p2 = gcnew Manager; - p2->Name = "Megan"; - p2->Rank = 2; - array^myStaff = {p1,p2}; - myGroup->Staff = myStaff; - - // Serializes the object, and closes the StreamWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); -} - -int main() -{ - SerializeOrder( "TypeEx.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp deleted file mode 100644 index 153e7b6e3d2c2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem, - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - - // Creates the object to serialize. - Transportation^ myTransportation = gcnew Transportation; - - // Creates objects to add to the array. - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^temp = {myVehicle,myCar}; - myTransportation->MyVehicles = temp; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates an XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem1.xml" ); - DeserializeObject( "XmlArrayItem1.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp deleted file mode 100644 index 27560a1275850..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem(ElementName="Transportation"), - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates the serializer with the type to deserialize. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem2.xml" ); - DeserializeObject( "XmlArrayItem2.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp deleted file mode 100644 index 8809b40c0afc1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem(Vehicle::typeid), - XmlArrayItem(Car::typeid)] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates the serializer with the type to deserialize. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem3.xml" ); - DeserializeObject( "XmlArrayItem3.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp deleted file mode 100644 index 6886a80fe910d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArray] - [XmlArrayItem("Transport",Vehicle::typeid), - XmlArrayItem("Automobile",Car::typeid)] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem4.xml" ); - DeserializeObject( "XmlArrayItem4.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp deleted file mode 100644 index ded3d3f240a14..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - - [XmlAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [XmlAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [XmlAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; -}; - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2001,1,10); - myGroup->Today = myDate; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "Attributes.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp deleted file mode 100644 index bf8889f67722d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - - // Change the XML attribute name. - - [XmlAttributeAttribute(AttributeName="MgrName")] - String^ Name; - /* Use the AttributeName to collect all the XML attributes - in the XML-document instance. */ -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Serializing" ); - - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - /* Set the Name property, which will be generated - as an XML attribute. */ - myGroup->Name = "Wallace"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Deserializing" ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->Name ); -} - -int main() -{ - /* To use the AttributeName to collect all the - XML attributes. Call SerializeObject to generate - an XML document and alter the document by adding - new XML attributes to it. Then comment out the SerializeObject - method, and call DeserializeObject. */ - SerializeObject( "MyAtts.xml" ); - DeserializeObject( "MyAtts.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp deleted file mode 100644 index dbc9a73c48ff8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Group -{ -public: - - [XmlAttributeAttribute(DataType="string")] - String^ Name; - - [XmlAttributeAttribute(DataType="base64Binary")] - array^Hex64Code; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 37de504e9b71c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle -{ -public: - - [XmlAttributeAttribute(Form=XmlSchemaForm::Qualified)] - String^ Maker; - - [XmlAttributeAttribute(Form=XmlSchemaForm::Unqualified)] - String^ ModelID; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 8cd4fd710f3c1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Car -{ -public: - - [XmlAttributeAttribute(Namespace="Make")] - String^ MakerName; - - [XmlAttributeAttribute(Namespace="Model")] - String^ ModelName; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp deleted file mode 100644 index 4dc40d33dd299..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownAttribute( Object^ /*sender*/, XmlAttributeEventArgs^ e ) - { - System::Xml::XmlAttribute^ attr = e->Attr; - Console::WriteLine( "Unknown Attribute Name and Value: {0} = '{1}'", - attr->Name, attr->Value ); - Object^ x = e->ObjectBeingDeserialized; - Console::WriteLine( "ObjectBeingDeserialized: {0}", x ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp deleted file mode 100644 index 5d23724e8ea4f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp +++ /dev/null @@ -1,113 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - /* Each overridden field, property, or type requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Create an XmlElementAttribute to override the - field that returns Instrument objects. The overridden field - returns Brass objects instead. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - - // Create the XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - /* Add the type of the class that contains the overridden - member and the XmlAttributes to override it with to the - XmlAttributeOverrides object. */ - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object that will be serialized. - Orchestra^ band = gcnew Orchestra; - - // Create an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlElementAttribute to override the Instrument. - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the XmlElementAttribute to the collection of objects. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* The difference between deserializing the overridden - XML document and serializing it is this: To read the derived - object values, you must declare an object of the derived type - (Brass), and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp deleted file mode 100644 index e474a5694c3ba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp +++ /dev/null @@ -1,102 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -ref class Band; -ref class Instrument; - -/* This is the class that will be overridden. The XmlIncludeAttribute -tells the XmlSerializer that the overriding type exists. */ - -[XmlInclude(Band::typeid)] -public ref class Orchestra -{ -public: - array^Instruments; -}; - -// This is the overriding class. -public ref class Band: public Orchestra -{ -public: - String^ BandName; -}; - -public ref class Instrument -{ -public: - String^ Name; -}; - -void SerializeObject( String^ filename ) -{ - /* Each object that is being overridden requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - // An XmlRootAttribute allows overriding the Orchestra class. - XmlRootAttribute^ xmlRoot = gcnew XmlRootAttribute; - - // Set the object to the XmlAttribute.XmlRoot property. - attrs->XmlRoot = xmlRoot; - - // Create an XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes to the XmlAttributeOverrrides. - attrOverrides->Add( Orchestra::typeid, attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object using the derived class. - Band^ band = gcnew Band; - band->BandName = "NewBand"; - - // Create an Instrument. - Instrument^ i = gcnew Instrument; - i->Name = "Trumpet"; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlRootAttribute^ attr = gcnew XmlRootAttribute; - attrs->XmlRoot = attr; - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Deserialize the Band object. - Band^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - Console::WriteLine( i->Name ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp deleted file mode 100644 index ae9b594d0f2f8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributeOverrides object. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlAttributeAttribute to override the base class - object's XmlAttributeAttribute object. Give the overriding object - a new attribute name ("Code"). */ - XmlAttributeAttribute^ xAtt = gcnew XmlAttributeAttribute; - xAtt->AttributeName = "Code"; - - /* Create an instance of the XmlAttributes class and set the - XmlAttribute property to the XmlAttributeAttribute object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - attrs->XmlAttribute = xAtt; - - /* Add the XmlAttributes object to the XmlAttributeOverrides - and specify the type and member name to override. */ - xOver->Add( Group::typeid, "GroupCode", attrs ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp deleted file mode 100644 index d9d43cdf6b353..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlSerializer with overriding attributes. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - - // Set a new Namespace and ElementName for the root element. - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->ElementName = "NewGroup"; - attrs->XmlRoot = xRoot; - xOver->Add( Group::typeid, attrs ); - - // Get the XmlAttributes object, based on the type. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[ Group::typeid ]; - - // Print the Namespace and ElementName of the root. - Console::WriteLine( tempAttrs->XmlRoot->Namespace ); - Console::WriteLine( tempAttrs->XmlRoot->ElementName ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp deleted file mode 100644 index 099c81b666442..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlSerializer with overriding attributes. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlAttributeAttribute object and set the - AttributeName property. */ - XmlAttributeAttribute^ xAtt = gcnew XmlAttributeAttribute; - xAtt->AttributeName = "Code"; - - /* Create a new XmlAttributes object and set the - XmlAttributeAttribute object to the XmlAttribute property. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - attrs->XmlAttribute = xAtt; - - /* Add the XmlAttributes to the XmlAttributeOverrides object. The - name of the overridden attribute must be specified. */ - xOver->Add( Group::typeid, "GroupCode", attrs ); - - // Get the XmlAttributes object for the type and member. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[Group::typeid, "GroupCode"]; - Console::WriteLine( tempAttrs->XmlAttribute->AttributeName ); - - // Create the XmlSerializer instance and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp deleted file mode 100644 index c0960e934fc9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp +++ /dev/null @@ -1,85 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Member -{ -public: - String^ MemberName; -}; - - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // This field will be overridden. - array^Members; -}; - - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Creating XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the XmlArray. - XmlArrayAttribute^ xArray = gcnew XmlArrayAttribute( "Staff" ); - xArray->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArray = xArray; - xOver->Add( Group::typeid, "Members", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - Member^ m = gcnew Member; - m->MemberName = "Paul"; - array^temp = {m}; - myGroup->Members = temp; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - System::Collections::IEnumerator^ myEnum = myGroup->Members->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Member^ m = safe_cast(myEnum->Current); - Console::WriteLine( m->MemberName ); - } -} - -int main() -{ - SerializeObject( "OverrideArray.xml" ); - DeserializeObject( "OverrideArray.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp deleted file mode 100644 index d2aff93a0cec3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Member -{ -public: - String^ MemberName; -}; - -// This is the class that will be serialized. -public ref class Group -{ -public: - array^Members; -}; - -public ref class NewMember: public Member -{ -public: - int MemberID; -}; - -public ref class RetiredMember: public NewMember -{ -public: - DateTime RetireDate; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the XmlArrayItem. - XmlArrayItemAttribute^ xArrayItem = gcnew XmlArrayItemAttribute( NewMember::typeid ); - xArrayItem->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArrayItems->Add( xArrayItem ); - - // Add a second override. - XmlArrayItemAttribute^ xArrayItem2 = gcnew XmlArrayItemAttribute( RetiredMember::typeid ); - xArrayItem2->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArrayItems->Add( xArrayItem2 ); - - // Add all overrides to XmlAttribueOverrides object. - xOver->Add( Group::typeid, "Members", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - NewMember^ m = gcnew NewMember; - m->MemberName = "Paul"; - m->MemberID = 2; - - // Create a second member. - RetiredMember^ m2 = gcnew RetiredMember; - m2->MemberName = "Renaldo"; - m2->MemberID = 23; - m2->RetireDate = DateTime(2000,10,10); - array^temp = {m,m2}; - myGroup->Members = temp; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - System::Collections::IEnumerator^ myEnum = myGroup->Members->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Member^ m = safe_cast(myEnum->Current); - Console::WriteLine( m->MemberName ); - } -} - -int main() -{ - SerializeObject( "OverrideArrayItem.xml" ); - DeserializeObject( "OverrideArrayItem.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp deleted file mode 100644 index 080d02f704e2e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // This is the attribute that will be overridden. - - [XmlAttributeAttribute] - String^ GroupName; - int GroupNumber; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - /* Create an overriding XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ xAttribute = gcnew XmlAttributeAttribute( "SplinterName" ); - xAttrs->XmlAttribute = xAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - xOver->Add( Group::typeid, "GroupName", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - /* Set the Name property, which will be generated - as an XML attribute. */ - myGroup->GroupName = ".NET"; - myGroup->GroupNumber = 1; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->GroupNumber ); -} - -int main() -{ - SerializeObject( "OverrideAttribute.xml" ); - DeserializeObject( "OverrideAttribute.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp deleted file mode 100644 index 79e6e3011778d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,112 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - /* Each overridden field, property, or type requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Create an XmlElementAttribute to override the - field that returns Instrument objects. The overridden field - returns Brass objects instead. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - - // Create the XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - /* Add the type of the class that contains the overridden - member and the XmlAttributes to override it with to the - XmlAttributeOverrides object. */ - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object that will be serialized. - Orchestra^ band = gcnew Orchestra; - - // Create an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlElementAttribute to override the Instrument. - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* The difference between deserializing the overridden - XML document and serializing it is this: To read the derived - object values, you must declare an object of the derived type - (Brass), and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp deleted file mode 100644 index 40f6a96deb728..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp +++ /dev/null @@ -1,88 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::ComponentModel; - -// This is the class that will be serialized. -public ref class Pet -{ -public: - - // The default value for the Animal field is "Dog". - - [DefaultValueAttribute("Dog")] - String^ Animal; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the default value of the GroupName. - Object^ defaultAnimal = "Cat"; - xAttrs->XmlDefaultValue = defaultAnimal; - - // Add all the XmlAttributes to the XmlAttributeOverrides object. - xOver->Add( Pet::typeid, "Animal", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Pet::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Pet^ myPet = gcnew Pet; - - /* Set the Animal property. If you set it to the default value, - which is "Cat" (the value assigned to the XmlDefaultValue - of the XmlAttributes object), no value will be serialized. - If you change the value to any other value (including "Dog"), - the value will be serialized. - */ - // The default value "Cat" will be assigned (nothing serialized). - myPet->Animal = ""; - - // Uncommenting the next line also results in the default - // value because Cat is the default value (not serialized). - // myPet.Animal = "Cat"; - // Uncomment the next line to see the value serialized: - // myPet.Animal = "fish"; - // This will also be serialized because Dog is not the - // default anymore. - // myPet.Animal = "Dog"; - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myPet ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Pet^ myPet = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myPet->Animal ); -} - -int main() -{ - SerializeObject( "OverrideDefaultValue.xml" ); - DeserializeObject( "OverrideDefaultValue.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp deleted file mode 100644 index dc3a90e6177b0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp +++ /dev/null @@ -1,101 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; - -public ref class Car -{ -public: - String^ Name; -}; - -public ref class Plane -{ -public: - String^ Name; -}; - -public ref class Truck -{ -public: - String^ Name; -}; - -public ref class Train -{ -public: - String^ Name; -}; - -public ref class Transportation -{ -public: - - // Subsequent code overrides these two XmlElementAttributes. - - [XmlElement(Car::typeid), - XmlElement(Plane::typeid)] - ArrayList^ Vehicles; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttribute to override - the Vehicles property. */ - XmlElementAttribute^ xElement1 = gcnew XmlElementAttribute( Truck::typeid ); - - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute, and - add it to the collection. */ - XmlElementAttribute^ xElement2 = gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object and serialize it. - Transportation^ myTransportation = gcnew Transportation; - - /* Create two new override objects that can be - inserted into the array. */ - myTransportation->Vehicles = gcnew ArrayList; - Truck^ myTruck = gcnew Truck; - myTruck->Name = "MyTruck"; - Train^ myTrain = gcnew Train; - myTrain->Name = "MyTrain"; - myTransportation->Vehicles->Add( myTruck ); - myTransportation->Vehicles->Add( myTrain ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "OverrideElement.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp deleted file mode 100644 index 9b65599120b76..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class FoodType -{ - // Subsequent code overrides these enumerations. - Low, High -}; - -// This is the class that will be serialized. -public ref class Food -{ -public: - FoodType Type; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an XmlEnumAttribute for the FoodType.Low enumeration. - XmlEnumAttribute^ xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Cold"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "Low", xAttrs ); - - // Add an XmlEnumAttribute for the FoodType.High enumeration. - xAttrs = gcnew XmlAttributes; - xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Hot"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "High", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Food::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Food^ myFood = gcnew Food; - - // Set the object properties. - myFood->Type = FoodType::High; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myFood ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Food^ myFood = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myFood->Type ); -} - -int main() -{ - SerializeObject( "OverrideEnum.xml" ); - DeserializeObject( "OverrideEnum.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp deleted file mode 100644 index 1f586f8054745..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // The GroupName value will be serialized--unless it's overridden. - String^ GroupName; - - /* This field will be ignored when serialized-- - unless it's overridden. */ - - [XmlIgnoreAttribute] - String^ Comment; -}; - - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Setting XmlIgnore to false overrides the XmlIgnoreAttribute - applied to the Comment field. Thus it will be serialized.*/ - attrs->XmlIgnore = false; - xOver->Add( Group::typeid, "Comment", attrs ); - - /* Use the XmlIgnore to instruct the XmlSerializer to ignore - the GroupName instead. */ - attrs = gcnew XmlAttributes; - attrs->XmlIgnore = true; - xOver->Add( Group::typeid, "GroupName", attrs ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object to serialize and set its properties. - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->Comment = "My Comment..."; - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object and close the TextWriter. - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "IgnoreXml.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp deleted file mode 100644 index 42c1f3a350371..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -// Return an XmlSerializer for overriding attributes. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - - // Set a new Namespace and ElementName for the root element. - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->ElementName = "NewGroup"; - attrs->XmlRoot = xRoot; - - /* Add the XmlAttributes object to the XmlAttributeOverrides. - No member name is needed because the whole class is - overridden. */ - xOver->Add( Group::typeid, attrs ); - - // Get the XmlAttributes object, based on the type. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[ Group::typeid ]; - - // Print the Namespace and ElementName of the root. - Console::WriteLine( tempAttrs->XmlRoot->Namespace ); - Console::WriteLine( tempAttrs->XmlRoot->ElementName ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create the XmlSerializer using the CreateOverrider method. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object to serialize. - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->GroupCode = 123; - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object and close the TextWriter. - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "OverrideRoot.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp deleted file mode 100644 index e2732ed2c5711..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - // This field will be serialized as XML text. - String^ Comment; -}; - -// Return an XmlSerializer to be used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - /* Create an XmlTextAttribute and assign it to the XmlText - property. This instructs the XmlSerializer to treat the - Comment field as XML text. */ - XmlTextAttribute^ xText = gcnew XmlTextAttribute; - xAttrs->XmlText = xText; - xOver->Add( Group::typeid, "Comment", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - myGroup->Comment = "Great Stuff!"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->Comment ); -} - -int main() -{ - SerializeObject( "OverrideText.xml" ); - DeserializeObject( "OverrideText.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp deleted file mode 100644 index d2cccc13596c1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Car -{ -public: - int ID; -}; - -public ref class Transportation -{ -public: - array^Cars; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlTypeAttribute and change the name of the - XML type. */ - XmlTypeAttribute^ xType = gcnew XmlTypeAttribute; - xType->TypeName = "Autos"; - - // Set the XmlTypeAttribute to the XmlType property. - attrs->XmlType = xType; - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Car::typeid, attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create object and serialize it. - Transportation^ myTransportation = gcnew Transportation; - Car^ c1 = gcnew Car; - c1->ID = 12; - Car^ c2 = gcnew Car; - c2->ID = 44; - array^temp0 = {c1,c2}; - myTransportation->Cars = temp0; - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "XmlType.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp deleted file mode 100644 index eea4fa29c6d53..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - /* Set the element name and namespace of the XML element. - By applying an XmlElementAttribute to an array, you instruct - the XmlSerializer to serialize the array as a series of XML - elements, instead of a nested set of elements. */ - - [XmlElement( - ElementName="Members", - Namespace="http://www.cpandl.com")] - array^Employees; - - [XmlElement(DataType="snippet1>", - ElementName="Building")] - double GroupID; - - [XmlElement(DataType="hexBinary")] - array^HexBytes; - - [XmlElement(DataType="boolean")] - bool IsActive; - - [XmlElement(Type=::Manager::typeid)] - Employee^ Manager; - - [XmlElement(Int32::typeid, - ElementName="ObjectNumber"), - XmlElement(String::typeid, - ElementName="ObjectString")] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Create the XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - /* Create an instance of the group to serialize, and set - its properties. */ - Group^ group = gcnew Group; - group->GroupID = 10.089f; - group->IsActive = false; - array^temp0 = {Convert::ToByte( 100 )}; - group->HexBytes = temp0; - Employee^ x = gcnew Employee; - Employee^ y = gcnew Employee; - x->Name = "Jack"; - y->Name = "Jill"; - array^temp1 = {x,y}; - group->Employees = temp1; - Manager^ mgr = gcnew Manager; - mgr->Name = "Sara"; - mgr->Level = 4; - group->Manager = mgr; - - /* Add a number and a string to the - ArrayList returned by the ExtraInfo property. */ - group->ExtraInfo = gcnew ArrayList; - group->ExtraInfo->Add( 42 ); - group->ExtraInfo->Add( "Answer" ); - - // Serialize the object, and close the TextWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::WriteLine( g->Manager->Name ); - Console::WriteLine( g->GroupID ); - Console::WriteLine( g->HexBytes[ 0 ] ); - IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( e->Name ); - } -} - -int main() -{ - SerializeObject( "FirstDoc.xml" ); - DeserializeObject( "FirstDoc.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp deleted file mode 100644 index dac3339b9d7a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Group -{ -public: - - /* Apply two XmlElementAttributes to the field. Set the DataType - to string an int to allow the ArrayList to accept - both types. The Namespace is also set to different values - for each type. */ - - [XmlElement(DataType="string", - Type=String::typeid, - Namespace="http://www.cpandl.com"), - XmlElement(DataType="snippet1>", - Namespace="http://www.cohowinery.com", - Type=Int32::typeid)] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // A TextWriter is needed to write the file. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Create the object to serialize. - Group^ myGroup = gcnew Group; - - /* Add a string and an integer to the ArrayList returned - by the ExtraInfo field. */ - myGroup->ExtraInfo = gcnew ArrayList; - myGroup->ExtraInfo->Add( "hello" ); - myGroup->ExtraInfo->Add( 100 ); - - // Serialize the object and close the TextWriter. - s->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "ElementTypes.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index c73eab60f3bab..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class XClass -{ -public: - /* The XML element name will be XName - instead of the default ClassName. */ - [XmlElement(ElementName="XName")] - String^ ClassName; -}; -// - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 323a5e3febfc6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement(Form=XmlSchemaForm::Unqualified)] - String^ ClassName; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 496244672dfe9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement(IsNullable=false)] - String^ Group; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index 217959b7fad28..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - [XmlElement(Manager::typeid)] - array^Staff; - - [XmlElement(Int32::typeid), - XmlElement(String::typeid), - XmlElement(DateTime::typeid)] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid ); - - // Create object and serialize it. - Group^ myGroup = gcnew Group; - Manager^ e1 = gcnew Manager; - e1->Name = "Manager1"; - Manager^ m1 = gcnew Manager; - m1->Name = "Manager2"; - m1->Level = 4; - array^emps = {e1,m1}; - myGroup->Staff = emps; - myGroup->ExtraInfo = gcnew ArrayList; - myGroup->ExtraInfo->Add( ".NET" ); - myGroup->ExtraInfo->Add( 42 ); - myGroup->ExtraInfo->Add( DateTime(2001,1,1) ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "TypeEx.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp deleted file mode 100644 index f06647e1954f3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement] - String^ TeacherName; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp deleted file mode 100644 index a92464e29dcf9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Transportation -{ -public: - - [XmlElement("Cars")] - String^ Vehicles; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp deleted file mode 100644 index 701b642c4906d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp +++ /dev/null @@ -1,96 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Creates an XmlElementAttribute that overrides the Instrument type. - XmlElementAttribute^ attr = gcnew XmlElementAttribute( Brass::typeid ); - attr->ElementName = "Brass"; - - // Adds the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Creates the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Creates the object to serialize. - Orchestra^ band = gcnew Orchestra; - - // Creates an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Creates an XmlElementAttribute that override the Instrument type. - XmlElementAttribute^ attr = gcnew XmlElementAttribute( Brass::typeid ); - attr->ElementName = "Brass"; - - // Adds the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Creates the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* Deserializing differs from serializing. To read the - derived-object values, declare an object of the derived - type (Brass) and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp deleted file mode 100644 index 000e548b46f07..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; - -public ref class Car -{ -public: - String^ Name; -}; - -public ref class Plane -{ -public: - String^ Name; -}; - -public ref class Truck -{ -public: - String^ Name; -}; - -public ref class Train -{ -public: - String^ Name; -}; - -public ref class Transportation -{ -public: - - // Override these two XmlElementAttributes. - - [XmlElement(Car::typeid), - XmlElement(Plane::typeid)] - ArrayList^ Vehicles; -}; - -XmlSerializer^ CreateOverrider() -{ - // Create XmlAtrributes and XmlAttributeOverrides instances. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttributes object to override - one of the attributes applied to the Vehicles property. */ - XmlElementAttribute^ xElement1 = gcnew XmlElementAttribute( Truck::typeid ); - - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute and - add it to the collection. */ - XmlElementAttribute^ xElement2 = gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object. - Transportation^ myTransportation = gcnew Transportation; - - /* Create two new, overriding objects that can be - inserted into the Vehicles array. */ - myTransportation->Vehicles = gcnew ArrayList; - Truck^ myTruck = gcnew Truck; - myTruck->Name = "MyTruck"; - Train^ myTrain = gcnew Train; - myTrain->Name = "MyTrain"; - myTransportation->Vehicles->Add( myTruck ); - myTransportation->Vehicles->Add( myTrain ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "OverrideElement.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp deleted file mode 100644 index 3933ca7d495f6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Truck{ - // Class added so sample will compile -}; - -public ref class Train{ - // Class added so sample will compile -}; - -public ref class Transportation{ - // Class added so sample will compile -}; - -public ref class Sample -{ - // -public: - XmlSerializer^ CreateOverrider() - { - // Create XmlAttributes and XmlAttributeOverrides instances. - - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = - gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttributes to override - the Vehicles property. */ - XmlElementAttribute^ xElement1 = - gcnew XmlElementAttribute( Truck::typeid ); - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute, and - add to the collection. */ - XmlElementAttribute^ xElement2 = - gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( - Transportation::typeid,xOver ); - return xSer; - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp deleted file mode 100644 index b82f373dbe0aa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public enum class EmployeeStatus -{ - [XmlEnum(Name = "Single")] - One, - [XmlEnum(Name = "Double")] - Two, - [XmlEnum(Name = "Triple")] - Three -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp deleted file mode 100644 index d494e993e3e74..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public enum class EmployeeStatus -{ - [XmlEnum("Single")] - One, - [XmlEnum("Double")] - Two, - [XmlEnum("Triple")] - Three -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp deleted file mode 100644 index d7f0debeaeca4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class FoodType -{ - // Subsequent code overrides these enumerations. - Low, High -}; - -// This is the class that will be serialized. -public ref class Food -{ -public: - FoodType Type; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an XmlEnumAttribute for the FoodType.Low enumeration. - XmlEnumAttribute^ xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Cold"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "Low", xAttrs ); - - // Add an XmlEnumAttribute for the FoodType.High enumeration. - xAttrs = gcnew XmlAttributes; - xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Hot"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "High", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Food::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Food^ myFood = gcnew Food; - - // Set the object properties. - myFood->Type = FoodType::High; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myFood ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Food^ myFood = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myFood->Type ); -} - -int main() -{ - SerializeObject( "OverrideEnum.xml" ); - DeserializeObject( "OverrideEnum.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp deleted file mode 100644 index 7298f812c7a4d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Group -{ -public: - - // The XmlSerializer ignores this field. - - [XmlIgnore] - String^ Comment; - - // The XmlSerializer serializes this field. - String^ GroupName; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index cbfdda004f2c5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -ref class Employee; - -ref class Manager; - -ref class Group -{ -public: - array^Employees; -}; - -// Instruct the XmlSerializer to accept Manager types as well. -[XmlInclude(Manager::typeid)] -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ group = gcnew Group; - Manager^ manager = gcnew Manager; - Employee^ emp1 = gcnew Employee; - Employee^ emp2 = gcnew Employee; - manager->Name = "Zeus"; - manager->Level = 2; - emp1->Name = "Ares"; - emp2->Name = "Artemis"; - array^emps = {manager,emp1,emp2}; - group->Employees = emps; - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::Write( "Members:" ); - System::Collections::IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}", e->Name ); - } -} - -int main() -{ - SerializeObject( "IncludeExample.xml" ); - DeserializeObject( "IncludeExample.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp deleted file mode 100644 index 8ba6ec67f1524..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle{}; - -public ref class Car: public Vehicle{}; - -public ref class Truck: public Vehicle{}; - -public ref class Sample -{ -public: - - [WebMethodAttribute] - [XmlInclude(Car::typeid)] - [XmlInclude(Truck::typeid)] - Vehicle^ ReturnVehicle( int i ) - { - if ( i == 0 ) - return gcnew Car; - else - return gcnew Truck; - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source.cpp deleted file mode 100644 index 1945e706e46b1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source.cpp +++ /dev/null @@ -1,43 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// placeholder; see complete definition elsewhere in this section -public ref class Order -{ -public: - void ShipItems(){} - -}; - - -// Creates the queue if it does not already exist. -void EnsureQueueExists( String^ path ) -{ - if ( !MessageQueue::Exists( path ) ) - { - MessageQueue::Create( path ); - } -} - -int main() -{ - Console::WriteLine( "Processing Orders" ); - String^ queuePath = ".\\orders"; - EnsureQueueExists( queuePath ); - MessageQueue^ queue = gcnew MessageQueue( queuePath ); - array^temp0 = {"Order"}; - (dynamic_cast(queue->Formatter))->TargetTypeNames = temp0; - while ( true ) - { - Order^ newOrder = dynamic_cast(queue->Receive()->Body); - newOrder->ShipItems(); - } -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source2.cpp deleted file mode 100644 index 057b230d28d69..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source2.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -using namespace System; -public ref class Order -{ -public: - int itemId; - int quantity; - String^ address; - void ShipItems() - { - Console::WriteLine( "Order Placed:" ); - Console::WriteLine( "\tItem ID : {0}", itemId ); - Console::WriteLine( "\tQuantity : {0}", quantity ); - Console::WriteLine( "\tShip To : {0}", address ); - - // Add order to the database. - /* Insert code here. */ - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source3.cpp deleted file mode 100644 index 44d1d0daa090e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlMessageFormatter Example/CPP/source3.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// placeholder; see complete definition elsewhere in this section -public ref class Order -{ -public: - int itemId; - int quantity; - String^ address; - void ShipItems(){} - -}; - - -// Creates the queue if it does not already exist. -void EnsureQueueExists( String^ path ) -{ - if ( !MessageQueue::Exists( path ) ) - { - MessageQueue::Create( path ); - } -} - -int main() -{ - String^ queuePath = ".\\orders"; - EnsureQueueExists( queuePath ); - MessageQueue^ queue = gcnew MessageQueue( queuePath ); - Order^ orderRequest = gcnew Order; - orderRequest->itemId = 1025; - orderRequest->quantity = 5; - orderRequest->address = "One Microsoft Way"; - queue->Send( orderRequest ); - - // This line uses a new method you define on the Order class: - // orderRequest.PrintReceipt(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp deleted file mode 100644 index 78b7ac99698a5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp deleted file mode 100644 index de9d0304ae411..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ -private: - // - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp deleted file mode 100644 index 6898547406979..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp deleted file mode 100644 index bd6a1e29d7207..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( myNodeType ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp deleted file mode 100644 index 88a67fdab41aa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Object^ o = e->ObjectBeingDeserialized; - Console::WriteLine( "Object being deserialized: {0}", o ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp deleted file mode 100644 index a4734b7e0126a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp deleted file mode 100644 index b4318feda2a00..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void DeserializeItem( String^ filename ) - { - XmlSerializer^ mySerializer = gcnew XmlSerializer( ObjectToDeserialize::typeid ); - - // Add an instance of the delegate to the event. - mySerializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Class1::Serializer_UnknownNode ); - - // A FileStream is needed to read the file to deserialize. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - ObjectToDeserialize^ o = dynamic_cast(mySerializer->Deserialize( fs )); - } - - void Serializer_UnknownNode( Object^ sender, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - Object^ o = e->ObjectBeingDeserialized; - Console::WriteLine( "Object being deserialized {0}", o ); - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( myNodeType ); - } - // - -public: - - ref class ObjectToDeserialize{}; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp deleted file mode 100644 index 705ea6b12448f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -[XmlRoot(Namespace="www.contoso.com", -ElementName="MyGroupName", -DataType="string", -IsNullable=true)] -public ref class Group -{ -private: - String^ groupNameValue; - -public: - - // Insert code for the Group class. - Group(){} - - Group( String^ groupNameVal ) - { - groupNameValue = groupNameVal; - } - - property String^ GroupName - { - String^ get() - { - return groupNameValue; - } - void set( String^ value ) - { - groupNameValue = value; - } - - } - -}; - -void SerializeGroup() -{ - // Create an instance of the Group class, and an - // instance of the XmlSerializer to serialize it. - Group^ myGroup = gcnew Group( "Redmond" ); - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // A FileStream is used to write the file. - FileStream^ fs = gcnew FileStream( "group.xml",FileMode::Create ); - ser->Serialize( fs, myGroup ); - fs->Close(); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( "Done" ); - Console::ReadLine(); -} - -int main() -{ - SerializeGroup(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 9780f3bb00398..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; - -// Apply the XmlRootAttribute and set the IsNullable property to false. - -[XmlRoot(IsNullable=false)] -public ref class Group -{ -public: - String^ Name; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object to serialize. - Group^ mygroup = nullptr; - - // Serialize the object, and close the TextWriter. - s->Serialize( writer, mygroup ); - writer->Close(); -} - -int main() -{ - Console::WriteLine( "Running" ); - SerializeObject( "NullDoc.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 4d0cd2a4a6156..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlRoot(Namespace="http://www.cpandl.com")] -public ref class Group{}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp deleted file mode 100644 index ee176b3d4b413..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class MyClass -{ -public: - String^ Name; -}; - -XmlSerializer^ CreateOverrider(); -void SerializeOrder( String^ filename ) -{ - // Create an XmlSerializer instance using the method below. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object, and set its Name property. - MyClass^ myClass = gcnew MyClass; - myClass->Name = "New Class Name"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myClass ); - writer->Close(); -} - -// Return an XmlSerializer to override the root serialization. -XmlSerializer^ CreateOverrider() -{ - // Create an XmlAttributes to override the default root element. - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlRootAttribute and set its element name and namespace. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "OverriddenRootElementName"; - xRoot->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - attrs->XmlRoot = xRoot; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Add the XmlAttributes object to the - XmlAttributeOverrides object. */ - xOver->Add( MyClass::typeid, attrs ); - - // Create the Serializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( MyClass::typeid,xOver ); - return xSer; -} - -int main() -{ - SerializeOrder( "OverrideAttribute.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp deleted file mode 100644 index 0bfeccd401c6e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp +++ /dev/null @@ -1,216 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; -ref class Address; -ref class OrderedItem; - -/* The XmlRootAttribute allows you to set an alternate name - (PurchaseOrder) of the XML element, the element namespace; by - default, the XmlSerializer uses the class name. The attribute - also allows you to set the XML namespace for the element. Lastly, - the attribute sets the IsNullable property, which specifies whether - the xsi:null attribute appears if the class instance is set to - a null reference. */ - -[XmlRootAttribute("PurchaseOrder",Namespace="http://www.cpandl.com", -IsNullable=false)] -public ref class PurchaseOrder -{ -public: - Address^ ShipTo; - String^ OrderDate; - - /* The XmlArrayAttribute changes the XML element name - from the default of "OrderedItems" to "Items". */ - - [XmlArrayAttribute("Items")] - array^OrderedItems; - Decimal SubTotal; - Decimal ShipCost; - Decimal TotalCost; -}; - -public ref class Address -{ -public: - - /* The XmlAttribute instructs the XmlSerializer to serialize the Name - field as an XML attribute instead of an XML element (the default - behavior). */ - - [XmlAttributeAttribute] - String^ Name; - String^ Line1; - - /* Setting the IsNullable property to false instructs the - XmlSerializer that the XML attribute will not appear if - the City field is set to a null reference. */ - - [XmlElementAttribute(IsNullable=false)] - String^ City; - String^ State; - String^ Zip; -}; - -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - /* Calculate is a custom method that calculates the price per item, - and stores the value in a field. */ - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } - -}; - -public ref class Test -{ -public: - static void main() - { - // Read and write purchase orders. - Test^ t = gcnew Test; - t->CreatePO( "po.xml" ); - t->ReadPO( "po.xml" ); - } - -private: - void CreatePO( String^ filename ) - { - // Create an instance of the XmlSerializer class; - // specify the type of object to serialize. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - PurchaseOrder^ po = gcnew PurchaseOrder; - - // Create an address to ship and bill to. - Address^ billAddress = gcnew Address; - billAddress->Name = "Teresa Atkinson"; - billAddress->Line1 = "1 Main St."; - billAddress->City = "AnyTown"; - billAddress->State = "WA"; - billAddress->Zip = "00000"; - - // Set ShipTo and BillTo to the same addressee. - po->ShipTo = billAddress; - po->OrderDate = System::DateTime::Now.ToLongDateString(); - - // Create an OrderedItem object. - OrderedItem^ i1 = gcnew OrderedItem; - i1->ItemName = "Widget S"; - i1->Description = "Small widget"; - i1->UnitPrice = (Decimal)5.23; - i1->Quantity = 3; - i1->Calculate(); - - // Insert the item into the array. - array^items = {i1}; - po->OrderedItems = items; - - // Calculate the total cost. - Decimal subTotal = Decimal(0); - System::Collections::IEnumerator^ myEnum = items->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - OrderedItem^ oi = safe_cast(myEnum->Current); - subTotal = subTotal + oi->LineTotal; - } - - po->SubTotal = subTotal; - po->ShipCost = (Decimal)12.51; - po->TotalCost = po->SubTotal + po->ShipCost; - - // Serialize the purchase order, and close the TextWriter. - serializer->Serialize( writer, po ); - writer->Close(); - } - -protected: - void ReadPO( String^ filename ) - { - // Create an instance of the XmlSerializer class; - // specify the type of object to be deserialized. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - - /* If the XML document has been altered with unknown - nodes or attributes, handle them with the - UnknownNode and UnknownAttribute events.*/ - serializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Test::serializer_UnknownNode ); - serializer->UnknownAttribute += gcnew XmlAttributeEventHandler( this, &Test::serializer_UnknownAttribute ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - PurchaseOrder^ po; - - /* Use the Deserialize method to restore the object's state with - data from the XML document. */ - po = dynamic_cast(serializer->Deserialize( fs )); - - // Read the order date. - Console::WriteLine( "OrderDate: {0}", po->OrderDate ); - - // Read the shipping address. - Address^ shipTo = po->ShipTo; - ReadAddress( shipTo, "Ship To:" ); - - // Read the list of ordered items. - array^items = po->OrderedItems; - Console::WriteLine( "Items to be shipped:" ); - System::Collections::IEnumerator^ myEnum1 = items->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - OrderedItem^ oi = safe_cast(myEnum1->Current); - Console::WriteLine( "\t{0}\t{1}\t{2}\t{3}\t{4}", oi->ItemName, oi->Description, oi->UnitPrice, oi->Quantity, oi->LineTotal ); - } - - Console::WriteLine( "\t\t\t\t\t Subtotal\t{0}", po->SubTotal ); - Console::WriteLine( "\t\t\t\t\t Shipping\t{0}", po->ShipCost ); - Console::WriteLine( "\t\t\t\t\t Total\t\t{0}", po->TotalCost ); - } - - void ReadAddress( Address^ a, String^ label ) - { - // Read the fields of the Address object. - Console::WriteLine( label ); - Console::WriteLine( "\t{0}", a->Name ); - Console::WriteLine( "\t{0}", a->Line1 ); - Console::WriteLine( "\t{0}", a->City ); - Console::WriteLine( "\t{0}", a->State ); - Console::WriteLine( "\t{0}", a->Zip ); - Console::WriteLine(); - } - -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "Unknown Node:{0}\t{1}", e->Name, e->Text ); - } - - void serializer_UnknownAttribute( Object^ /*sender*/, XmlAttributeEventArgs^ e ) - { - System::Xml::XmlAttribute^ attr = e->Attr; - Console::WriteLine( "Unknown attribute {0}='{1}'", attr->Name, attr->Value ); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp deleted file mode 100644 index b488c27b932ef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void TestDocument( String^ filename, Type^ objType ) - { - // Using a FileStream, create an XmlTextReader. - Stream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlReader^ reader = gcnew XmlTextReader( fs ); - XmlSerializer^ serializer = gcnew XmlSerializer( objType ); - if ( serializer->CanDeserialize( reader ) ) - { - Object^ o = serializer->Deserialize( reader ); - } - fs->Close(); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp deleted file mode 100644 index 542444fb61ae5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject(String^ filename) -{ - Console::WriteLine("Reading with Stream"); - - // Create an instance of the XmlSerializer. - XmlSerializer^ serializer = gcnew XmlSerializer(OrderedItem::typeid); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Reading the XML document requires a FileStream. - Stream^ reader = gcnew FileStream(filename, FileMode::Open); - - try - { - // Call the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize(reader)); - } - finally - { - delete reader; - } - - // Write out the properties of the object. - Console::Write("{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp deleted file mode 100644 index b803c3b61af20..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with TextReader" ); - - // Create an instance of the XmlSerializer specifying type. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - /* Create a TextReader to read the file. Specify an - Encoding to use. */ - TextReader^ reader = gcnew StreamReader( filename,Encoding::Unicode ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Use the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp deleted file mode 100644 index 3b2738346ee16..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with XmlReader" ); - - // Create an instance of the XmlSerializer specifying type and namespace. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlReader^ reader = gcnew XmlTextReader( fs ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Use the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp deleted file mode 100644 index a9b0d0bf54ed3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -/* Three classes are included here. Each one will -be used to create three XmlSerializer objects. */ -public ref class Instrument -{ -public: - String^ InstrumentName; -}; - -public ref class Player -{ -public: - String^ PlayerName; -}; - -public ref class Piece -{ -public: - String^ PieceName; -}; - -void GetSerializers() -{ - // Create an array of types. - array^types = gcnew array(3); - types[ 0 ] = Instrument::typeid; - types[ 1 ] = Player::typeid; - types[ 2 ] = Piece::typeid; - - // Create an array for XmlSerializer objects. - array^serializers = gcnew array(3); - serializers = XmlSerializer::FromTypes( types ); - - // Create one Instrument and serialize it. - Instrument^ i = gcnew Instrument; - i->InstrumentName = "Piano"; - - // Create a TextWriter to write with. - TextWriter^ writer = gcnew StreamWriter( "Inst.xml" ); - serializers[ 0 ]->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - GetSerializers(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp deleted file mode 100644 index deb65e2782ed4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With TextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - /* Create a StreamWriter to write with. First create a FileStream - object, and create the StreamWriter specifying an Encoding to use. */ - FileStream^ fs = gcnew FileStream( filename,FileMode::Create ); - TextWriter^ writer = gcnew StreamWriter( fs,gcnew UTF8Encoding ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp deleted file mode 100644 index c635e5664684b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With TextWriter" ); - - // Create an XmlSerializer instance using the type. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two namespaces with prefixes. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a StreamWriter to write with. - TextWriter^ writer = gcnew StreamWriter( filename ); - - /* Serialize using the object using the TextWriter - and namespaces. */ - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp deleted file mode 100644 index 053d871e78a07..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With Stream" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create a FileStream to write with. - Stream^ writer = gcnew FileStream( filename,FileMode::Create ); - - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp deleted file mode 100644 index baf2cd1b7c894..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With Stream" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two prefix-namespace pairs. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a FileStream to write with. - Stream^ writer = gcnew FileStream( filename,FileMode::Create ); - - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with Stream" ); - - // Create an instance of the XmlSerializer. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - // Writing the file requires a Stream. - Stream^ reader = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - /* Use the Deserialize method to restore the object's state - using data from the XML document. */ - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); - DeserializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp deleted file mode 100644 index 1774c451ee458..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With XmlTextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlTextWriter using a FileStream. - Stream^ fs = gcnew FileStream( filename,FileMode::Create ); - XmlWriter^ writer = gcnew XmlTextWriter( fs,Encoding::Unicode ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp deleted file mode 100644 index 8a82ba5a382ee..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With XmlTextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two namespaces with prefixes. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create an XmlTextWriter using a FileStream. - Stream^ fs = gcnew FileStream( filename,FileMode::Create ); - XmlWriter^ writer = gcnew XmlTextWriter( fs,gcnew UTF8Encoding ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp deleted file mode 100644 index cef506f6c438c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - - // Deserialize the file containing unknown elements. - t->DeserializeObject( "UnknownAttributes.xml" ); - } - -private: - void Serializer_UnknownAttribute( Object^ sender, XmlAttributeEventArgs^ e ) - { - Console::WriteLine( "Unknown Attribute" ); - Console::WriteLine( "\t{0} {1}", e->Attr->Name, e->Attr->InnerXml ); - Console::WriteLine( "\t LineNumber: {0}", e->LineNumber ); - Console::WriteLine( "\t LinePosition: {0}", e->LinePosition ); - Group^ x = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( x->GroupName ); - Console::WriteLine( sender ); - } - - void DeserializeObject( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Add a delegate to handle unknown element events. - ser->UnknownAttribute += gcnew XmlAttributeEventHandler( this, &Test::Serializer_UnknownAttribute ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = dynamic_cast(ser->Deserialize( fs )); - fs->Close(); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp deleted file mode 100644 index 57d80144134cb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - - // Only the GroupName field will be known. - String^ GroupName; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->DeserializeObject( "UnknownNodes.xml" ); - } - -private: - void DeserializeObject( String^ filename ) - { - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - mySerializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Test::serializer_UnknownNode ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - fs->Close(); - } - -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( "NodeType: {0}", myNodeType ); - Group^ myGroup = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( "GroupName: {0}", myGroup->GroupName ); - Console::WriteLine(); - } -}; - -int main() -{ - Test::main(); -} - -/* Paste this XML into a file named UnknownNodes: - - - MyGroup - Large - 444 - West - - 1 - Thing1 - - element - - - -*/ -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp deleted file mode 100644 index 1df7c03435e65..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp +++ /dev/null @@ -1,181 +0,0 @@ - - -// -// Beginning of the HighSchool.dll -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -namespace HighSchool -{ - public ref class Student - { - public: - String^ Name; - int ID; - }; - - public ref class MyClass - { - public: - array^Students; - }; -} - -namespace College -{ - -using namespace HighSchool; - public ref class Graduate: public HighSchool::Student - { - public: - Graduate(){} - - // Add a new field named University. - String^ University; - - // Use extra types to use this field. - array^Info; - }; - - public ref class Address - { - public: - String^ City; - }; - - public ref class Phone - { - public: - String^ Number; - }; - - public ref class Run - { - public: - static void main() - { - Run^ test = gcnew Run; - test->WriteOverriddenAttributes( "College.xml" ); - test->ReadOverriddenAttributes( "College.xml" ); - } - - private: - void WriteOverriddenAttributes( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create an XMLAttributeOverrides class. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Create the XmlAttributes class. - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Override the Student class. "Alumni" is the name - of the overriding element in the XML output. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - - /* Add the XmlElementAttribute to the collection of - elements in the XmlAttributes object. */ - attrs->XmlElements->Add( attr ); - - /* Add the XmlAttributes to the XmlAttributeOverrides. - "Students" is the name being overridden. */ - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - - // Create array of extra types. - array^extraTypes = gcnew array(2); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - - // Create an XmlRootAttribute. - XmlRootAttribute^ root = gcnew XmlRootAttribute( "Graduates" ); - - /* Create the XmlSerializer with the - XmlAttributeOverrides object. */ - XmlSerializer^ mySerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides,extraTypes,root,"http://www.microsoft.com" ); - MyClass ^ myClass = gcnew MyClass; - Graduate^ g1 = gcnew Graduate; - g1->Name = "Jacki"; - g1->ID = 1; - g1->University = "Alma"; - Graduate^ g2 = gcnew Graduate; - g2->Name = "Megan"; - g2->ID = 2; - g2->University = "CM"; - array^myArray = {g1,g2}; - myClass->Students = myArray; - - // Create extra information. - Address^ a1 = gcnew Address; - a1->City = "Ionia"; - Address^ a2 = gcnew Address; - a2->City = "Stamford"; - Phone^ p1 = gcnew Phone; - p1->Number = "555-0101"; - Phone^ p2 = gcnew Phone; - p2->Number = "555-0100"; - array^o1 = {a1,p1}; - array^o2 = {a2,p2}; - g1->Info = o1; - g2->Info = o2; - mySerializer->Serialize( myStreamWriter, myClass ); - myStreamWriter->Close(); - } - - void ReadOverriddenAttributes( String^ filename ) - { - /* The majority of the code here is the same as that in the - WriteOverriddenAttributes method. Because the XML being read - doesn't conform to the schema defined by the DLL, the - XMLAttributesOverrides must be used to create an - XmlSerializer instance to read the XML document.*/ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - attrs->XmlElements->Add( attr ); - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - array^extraTypes = gcnew array(2); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - XmlRootAttribute^ root = gcnew XmlRootAttribute( "Graduates" ); - XmlSerializer^ readSerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides,extraTypes,root,"http://www.microsoft.com" ); - - // A FileStream object is required to read the file. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - MyClass ^ myClass; - myClass = dynamic_cast(readSerializer->Deserialize( fs )); - - /* Here is the difference between reading and writing an - XML document: You must declare an object of the derived - type (Graduate) and cast the Student instance to it.*/ - Graduate^ g; - Address^ a; - Phone^ p; - System::Collections::IEnumerator^ myEnum = myClass->Students->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Graduate^ grad = safe_cast(myEnum->Current); - g = dynamic_cast(grad); - Console::Write( "{0}\t", g->Name ); - Console::Write( "{0}\t", g->ID ); - Console::Write( "{0}\n", g->University ); - a = dynamic_cast(g->Info[ 0 ]); - Console::WriteLine( a->City ); - p = dynamic_cast(g->Info[ 1 ]); - Console::WriteLine( p->Number ); - } - } - }; -} - -int main() -{ - College::Run::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp deleted file mode 100644 index 173d91e6ff341..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void SerializeObject( String^ filename ) - { - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,"http://www.cpandl.com" ); - - // Create an instance of the class to be serialized. - OrderedItem^ i = gcnew OrderedItem; - - // Insert code to set property values. - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i ); - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,"http://www.cpandl.com" ); - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Deserialize the object. - i = dynamic_cast(serializer->Deserialize( fs )); - - // Insert code to use the properties and methods of the object. - } - // - -public: - ref class OrderedItem{ - // Members of OrderedItem go here - }; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp deleted file mode 100644 index 2ce08d9f7a102..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void SerializeObject( String^ filename ) - { - // Create an XmlRootAttribute, and set its properties. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "CustomRoot"; - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->IsNullable = true; - - // Construct the XmlSerializer with the XmlRootAttribute. - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,xRoot ); - - // Create an instance of the object to serialize. - OrderedItem^ i = gcnew OrderedItem; - // Insert code to set properties of the ordered item. - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - serializer->Serialize( writer, i ); - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create an XmlRootAttribute, and set its properties. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "CustomRoot"; - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->IsNullable = true; - - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,xRoot ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - // Deserialize the object. - OrderedItem^ i = dynamic_cast(serializer->Deserialize( fs )); - // Insert code to use the object's properties and methods. - } - // - -public: - ref class OrderedItem{ - // Members of OrderedItem go here - }; -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp deleted file mode 100644 index 669af6e0644df..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp +++ /dev/null @@ -1,137 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -ref class Address; -ref class Phone; - -// This defines the object that will be serialized. -public ref class Teacher -{ -public: - String^ Name; - Teacher(){} - - /* Note that the Info field returns an array of objects. - Any object can be added to the array by adding the - object type to the array passed to the extraTypes argument. */ - - [XmlArray(ElementName="ExtraInfo",IsNullable=true)] - array^Info; - Phone^ PhoneInfo; -}; - - -// This defines one of the extra types to be included. -public ref class Address -{ -public: - String^ City; - Address(){} - - Address( String^ city ) - { - City = city; - } -}; - -// Another extra type to include. -public ref class Phone -{ -public: - String^ PhoneNumber; - Phone(){} - - Phone( String^ phoneNumber ) - { - PhoneNumber = phoneNumber; - } -}; - -// Another type, derived from Phone -public ref class InternationalPhone: public Phone -{ -public: - String^ CountryCode; - InternationalPhone(){} - - InternationalPhone( String^ countryCode ) - { - CountryCode = countryCode; - } -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeObject( "Teacher.xml" ); - test->DeserializeObject( "Teacher.xml" ); - } - -private: - void SerializeObject( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create a Type array. - array^extraTypes = gcnew array(3); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - extraTypes[ 2 ] = InternationalPhone::typeid; - - // Create the XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Teacher::typeid,extraTypes ); - Teacher^ teacher = gcnew Teacher; - teacher->Name = "Mike"; - - // Add extra types to the Teacher object - array^info = gcnew array(2); - info[ 0 ] = gcnew Address( "Springville" ); - info[ 1 ] = gcnew Phone( "555-0100" ); - teacher->Info = info; - teacher->PhoneInfo = gcnew InternationalPhone( "000" ); - mySerializer->Serialize( myStreamWriter, teacher ); - myStreamWriter->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create a Type array. - array^extraTypes = gcnew array(3); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - extraTypes[ 2 ] = InternationalPhone::typeid; - - // Create the XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Teacher::typeid,extraTypes ); - - // Reading a file requires a FileStream. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Teacher^ teacher = dynamic_cast(mySerializer->Deserialize( fs )); - - // Read the extra information. - Address^ a = dynamic_cast(teacher->Info[ 0 ]); - Phone^ p = dynamic_cast(teacher->Info[ 1 ]); - InternationalPhone^ Ip = dynamic_cast(teacher->PhoneInfo); - Console::WriteLine( teacher->Name ); - Console::WriteLine( a->City ); - Console::WriteLine( p->PhoneNumber ); - Console::WriteLine( Ip->CountryCode ); - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp deleted file mode 100644 index 0050ba6a3cec2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp +++ /dev/null @@ -1,133 +0,0 @@ - - -// -// Beginning of HighSchool.dll -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -namespace HighSchool -{ - public ref class Student - { - public: - String^ Name; - int ID; - }; - - public ref class MyClass - { - public: - array^Students; - }; -} - -namespace College -{ - -using namespace HighSchool; - public ref class Graduate: public HighSchool::Student - { - public: - Graduate(){} - - // Add a new field named University. - String^ University; - }; - - public ref class Run - { - public: - static void main() - { - Run^ test = gcnew Run; - test->WriteOverriddenAttributes( "College.xml" ); - test->ReadOverriddenAttributes( "College.xml" ); - } - - private: - void WriteOverriddenAttributes( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create an XMLAttributeOverrides class. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Create the XmlAttributes class. - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Override the Student class. "Alumni" is the name - of the overriding element in the XML output. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - - /* Add the XmlElementAttribute to the collection of - elements in the XmlAttributes object. */ - attrs->XmlElements->Add( attr ); - - /* Add the XmlAttributes to the XmlAttributeOverrides. - "Students" is the name being overridden. */ - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - - // Create the XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides ); - MyClass ^ myClass = gcnew MyClass; - Graduate^ g1 = gcnew Graduate; - g1->Name = "Jackie"; - g1->ID = 1; - g1->University = "Alma Mater"; - Graduate^ g2 = gcnew Graduate; - g2->Name = "Megan"; - g2->ID = 2; - g2->University = "CM"; - array^myArray = {g1,g2}; - myClass->Students = myArray; - mySerializer->Serialize( myStreamWriter, myClass ); - myStreamWriter->Close(); - } - - void ReadOverriddenAttributes( String^ filename ) - { - /* The majority of the code here is the same as that in the - WriteOverriddenAttributes method. Because the XML being read - doesn't conform to the schema defined by the DLL, the - XMLAttributesOverrides must be used to create an - XmlSerializer instance to read the XML document.*/ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - attrs->XmlElements->Add( attr ); - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - XmlSerializer^ readSerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides ); - - // To read the file, a FileStream object is required. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - MyClass ^ myClass; - myClass = dynamic_cast(readSerializer->Deserialize( fs )); - - /* Here is the difference between reading and writing an - XML document: You must declare an object of the derived - type (Graduate) and cast the Student instance to it.*/ - Graduate^ g; - System::Collections::IEnumerator^ myEnum = myClass->Students->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Graduate^ grad = safe_cast(myEnum->Current); - g = dynamic_cast(grad); - Console::Write( "{0}\t", g->Name ); - Console::Write( "{0}\t", g->ID ); - Console::Write( "{0}\n", g->University ); - } - } - }; -} - -int main() -{ - College::Run::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp deleted file mode 100644 index 6dabc064fb44a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void SerializeObject( String^ filename ) - { - XmlSerializer^ serializer = - gcnew XmlSerializer( OrderedItem::typeid ); - - // Create an instance of the class to be serialized. - OrderedItem^ i = gcnew OrderedItem; - - // Set the public property values. - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object, and close the TextWriter. - serializer->Serialize( writer, i ); - writer->Close(); - } - -public: - // This is the class that will be serialized. - ref class OrderedItem - { - public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - }; - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp deleted file mode 100644 index 01f91598da81f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Price -{ -public: - - [XmlAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ currency; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal price; -}; - -[XmlType(Namespace="http://www.cpandl.com")] -public ref class Book -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ TITLE; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Price^ PRICE; -}; - -public ref class Books -{ -public: - - [XmlElement(Namespace="http://www.cohowinery.com")] - Book^ Book; -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeObject( "XmlNamespaces.xml" ); - } - - void SerializeObject( String^ filename ) - { - XmlSerializer^ s = gcnew XmlSerializer( Books::typeid ); - - // Writing a file requires a TextWriter. - TextWriter^ t = gcnew StreamWriter( filename ); - - /* Create an XmlSerializerNamespaces object and add two - prefix-namespace pairs. */ - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "books", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a Book instance. - Book^ b = gcnew Book; - b->TITLE = "A Book Title"; - Price^ p = gcnew Price; - p->price = (Decimal)9.95; - p->currency = "US Dollar"; - b->PRICE = p; - Books^ bks = gcnew Books; - bks->Book = b; - s->Serialize( t, bks, ns ); - t->Close(); - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp deleted file mode 100644 index 825b960ef4a57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - XmlSerializerNamespaces^ AddNamespaces() - { - XmlSerializerNamespaces^ xmlNamespaces = - gcnew XmlSerializerNamespaces; - - // Add three prefix-namespace pairs. - xmlNamespaces->Add( "money", "http://www.cpandl.com" ); - xmlNamespaces->Add( "books", "http://www.cohowinery.com" ); - xmlNamespaces->Add( "software", "http://www.microsoft.com" ); - - return xmlNamespaces; - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp deleted file mode 100644 index 89a101a18a2e1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void PrintNamespacePairs( XmlSerializerNamespaces^ namespaces ) - { - array^ qualifiedNames = namespaces->ToArray(); - for ( int i = 0; i < qualifiedNames->Length; i++ ) - { - Console::WriteLine( "{0}\t{1}", - qualifiedNames[ i ]->Name, qualifiedNames[ i ]->Namespace ); - } - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp deleted file mode 100644 index 58d5dd5564948..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - XmlSerializerNamespaces^ CreateFromQNames() - { - XmlQualifiedName^ q1 = - gcnew XmlQualifiedName( "money","http://www.cohowinery.com" ); - - XmlQualifiedName^ q2 = - gcnew XmlQualifiedName( "books","http://www.cpandl.com" ); - - array^ names = { q1, q2 }; - - return gcnew XmlSerializerNamespaces( names ); - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp deleted file mode 100644 index fadecdb274e7b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,99 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class Group1 -{ -public: - - // The XmlTextAttribute with type set to string informs the - // XmlSerializer that strings should be serialized as XML text. - - [XmlText(String::typeid)] - [XmlElement(Int32::typeid)] - [XmlElement(Double::typeid)] - array^All; - Group1() - { - array^temp = {321,"One",2,3.0,"Two"}; - All = temp; - } -}; - -public enum class GroupType -{ - Small, Medium, Large -}; - -public ref class Group2 -{ -public: - - [XmlText(Type=GroupType::typeid)] - GroupType Type; -}; - -public ref class Group3 -{ -public: - - [XmlText(Type=DateTime::typeid)] - DateTime CreationTime; - Group3() - { - CreationTime = DateTime::Now; - } -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->SerializeArray( "XmlText1.xml" ); - t->SerializeEnum( "XmlText2.xml" ); - t->SerializeDateTime( "XmlText3.xml" ); - } - -private: - void SerializeArray( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group1::typeid ); - Group1^ myGroup1 = gcnew Group1; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup1 ); - writer->Close(); - } - - void SerializeEnum( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group2::typeid ); - Group2^ myGroup = gcnew Group2; - myGroup->Type = GroupType::Medium; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeDateTime( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group3::typeid ); - Group3^ myGroup = gcnew Group3; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp deleted file mode 100644 index d6719698f718e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; - String^ Comment; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->SerializerOrder( "TextOverride.xml" ); - } - - /* Create an instance of the XmlSerializer class that overrides - the default way it serializes an object. */ - XmlSerializer^ CreateOverrider() - { - /* Create instances of the XmlAttributes and - XmlAttributeOverrides classes. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlTextAttribute to override the default - serialization process. */ - XmlTextAttribute^ xText = gcnew XmlTextAttribute; - attrs->XmlText = xText; - - // Add the XmlAttributes to the XmlAttributeOverrides. - xOver->Add( Group::typeid, "Comment", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } - - void SerializerOrder( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object and serialize it. - Group^ myGroup = gcnew Group; - myGroup->Comment = "This is a great product."; - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp deleted file mode 100644 index 0b402e1de8730..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(Namespace="http://www.cpandl.com", -TypeName="GroupMember")] -public ref class Person -{ -public: - String^ Name; -}; - - -[XmlType(Namespace="http://www.cohowinery.com", -TypeName="GroupAddress")] -public ref class Address -{ -public: - String^ Line1; - String^ Line2; - String^ City; - String^ State; - String^ Zip; -}; - -public ref class Group -{ -public: - array^Staff; - Person^ Manager; - Address^ Location; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp deleted file mode 100644 index 592b8ccb05353..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(IncludeInSchema=false)] -public ref class ExtraneousInfo{}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 04919033ae5a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(Namespace="http://www.cpandl.com")] -public ref class Book{}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp deleted file mode 100644 index 87847fcbb3ee3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -ref class Person; -ref class Job; -ref class Group -{ -public: - array^Staff; -}; - - -[XmlType(TypeName="Employee", -Namespace="http://www.cpandl.com")] -public ref class Person -{ -public: - String^ PersonName; - Job^ Position; -}; - - -[XmlType(TypeName="Occupation", -Namespace="http://www.cohowinery.com")] -public ref class Job -{ -public: - String^ JobName; -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index 3c56e569110c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,248 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; -public ref class MyTcpClientExample -{ -public: - - // - // MyTcpClientConstructor is just used to illustrate the different constructors available in the TcpClient class - static void MyTcpClientConstructor( String^ myConstructorType ) - { - if ( myConstructorType == "IPAddressExample" ) - { - - // - //Creates a TCPClient using a local end point. - IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - TcpClient^ tcpClientA = gcnew TcpClient( ipLocalEndPoint ); - - // - } - else - if ( myConstructorType == "HostNameExample" ) - { - - // - // Creates a TCPClient using hostname and port. - TcpClient^ tcpClientB = gcnew TcpClient( "www.contoso.com",11000 ); - - // - } - else - if ( myConstructorType == "DefaultExample" ) - { - - // - //Creates a TCPClient using the default constructor. - TcpClient^ tcpClientC = gcnew TcpClient; - - // - } - else - { - - // - TcpClient^ tcpClientD = gcnew TcpClient( AddressFamily::InterNetwork ); - - // - } - } - - - // MyTcpClientConnection class is just used to illustrate the different connection methods of the TcpClient class. - static void MyTcpClientConnection( String^ myConnectionType ) - { - if ( myConnectionType == "HostnameExample" ) - { - - // - //Uses a host name and port number to establish a socket connection. - TcpClient^ tcpClient = gcnew TcpClient; - tcpClient->Connect( "www.contoso.com", 11002 ); - - // - tcpClient->Close(); - } - else - if ( myConnectionType == "IPAddressExample" ) - { - - // - //Uses the IP address and port number to establish a socket connection. - TcpClient^ tcpClient = gcnew TcpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - tcpClient->Connect( ipAddress, 11003 ); - - // - tcpClient->Close(); - } - else - if ( myConnectionType == "RemoteEndPointExample" ) - { - - // - //Uses a remote end point to establish a socket connection. - TcpClient^ tcpClient = gcnew TcpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddress,11004 ); - tcpClient->Connect( ipEndPoint ); - - // - tcpClient->Close(); - } - else - { - - // Do nothing. - } - } - - - // MyTcpClientPropertySetter is just used to illustrate setting and getting various properties of the TcpClient class. - static void MyTcpClientPropertySetter() - { - TcpClient^ tcpClient = gcnew TcpClient; - - // - // sets the receive buffer size using the ReceiveBufferSize public property. - tcpClient->ReceiveBufferSize = 1024; - - // gets the receive buffer size using the ReceiveBufferSize public property. - if ( tcpClient->ReceiveBufferSize == 1024 ) - Console::WriteLine( "The receive buffer was successfully set to {0}", tcpClient->ReceiveBufferSize ); - - - // - // - //sets the send buffer size using the SendBufferSize public property. - tcpClient->SendBufferSize = 1024; - - // gets the send buffer size using the SendBufferSize public property. - if ( tcpClient->SendBufferSize == 1024 ) - Console::WriteLine( "The send buffer was successfully set to {0}", tcpClient->SendBufferSize ); - - - // - // - // Sets the receive time out using the ReceiveTimeout public property. - tcpClient->ReceiveTimeout = 5; - - // Gets the receive time out using the ReceiveTimeout public property. - if ( tcpClient->ReceiveTimeout == 5 ) - Console::WriteLine( "The receive time out limit was successfully set {0}", tcpClient->ReceiveTimeout ); - - - // - // - // sets the send time out using the SendTimeout public property. - tcpClient->SendTimeout = 5; - - // gets the send time out using the SendTimeout public property. - if ( tcpClient->SendTimeout == 5 ) - Console::WriteLine( "The send time out limit was successfully set {0}", tcpClient->SendTimeout ); - - - // - // - // sets the amount of time to linger after closing, using the LingerOption public property. - LingerOption^ lingerOption = gcnew LingerOption( true,10 ); - tcpClient->LingerState = lingerOption; - - // gets the amount of linger time set, using the LingerOption public property. - if ( tcpClient->LingerState->LingerTime == 10 ) - Console::WriteLine( "The linger state setting was successfully set to {0}", tcpClient->LingerState->LingerTime ); - - - // - // - // Sends data immediately upon calling NetworkStream.Write. - tcpClient->NoDelay = true; - - // Determines if the delay is enabled by using the NoDelay property. - if ( tcpClient->NoDelay == true ) - Console::WriteLine( "The delay was set successfully to {0}", tcpClient->NoDelay ); - - - // - tcpClient->Close(); - } - - static void MyTcpClientCommunicator() - { - - // - TcpClient^ tcpClient = gcnew TcpClient; - - // Uses the GetStream public method to return the NetworkStream. - NetworkStream^ netStream = tcpClient->GetStream(); - if ( netStream->CanWrite ) - { - array^sendBytes = Encoding::UTF8->GetBytes( "Is anybody there?" ); - netStream->Write( sendBytes, 0, sendBytes->Length ); - } - else - { - Console::WriteLine( "You cannot write data to this stream." ); - tcpClient->Close(); - - // Closing the tcpClient instance does not close the network stream. - netStream->Close(); - return; - } - - if ( netStream->CanRead ) - { - - // Reads NetworkStream into a byte buffer. - array^bytes = gcnew array(tcpClient->ReceiveBufferSize); - - // Read can return anything from 0 to numBytesToRead. - // This method blocks until at least one byte is read. - netStream->Read( bytes, 0, (int)tcpClient->ReceiveBufferSize ); - - // Returns the data received from the host to the console. - String^ returndata = Encoding::UTF8->GetString( bytes ); - Console::WriteLine( "This is what the host returned to you: {0}", returndata ); - } - else - { - Console::WriteLine( "You cannot read data from this stream." ); - tcpClient->Close(); - - // Closing the tcpClient instance does not close the network stream. - netStream->Close(); - return; - } - - - // - } - -}; - - -//end class -int main() -{ - - // Using the default constructor. - MyTcpClientExample::MyTcpClientConstructor( "DefaultExample" ); - - // Establish a connection by using the hostname and port number. - MyTcpClientExample::MyTcpClientConnection( "HostnameExample" ); - - // Set and verify all communication parameters before attempting communication. - MyTcpClientExample::MyTcpClientPropertySetter(); - - // Send and receive data using tcpClient class. - MyTcpClientExample::MyTcpClientCommunicator(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_client.cpp deleted file mode 100644 index 9338142454cc6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_client.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// System::Runtime::Remoting::Lifetime.ClientSponsor::Register(MarshalByRefObject) -// System::Runtime::Remoting::Lifetime.ClientSponsor::Unregister(MarshalByRefObject) -// System::Runtime::Remoting::Lifetime.ClientSponsor::RenewalTime -// System::Runtime::Remoting::Lifetime.ClientSponsor::InitializeLifetimeService() -// System::Runtime::Remoting::Lifetime.ClientSponsor::Renewal(ILease*) -// System::Runtime::Remoting::Lifetime.ClientSponsor::Close() -// System::Runtime::Remoting::Lifetime.ClientSponsor - -/* The following example demonstrates 'RenewalTime', 'Register', 'UnRegister' and -'Close' methods of 'ClientSponsor' class. -A remote Object* is created and registered with 'ClientSponsor' class. The renewal -time is set. Then the leased time is renewed and the method of remote Object* is invoked. -Finally the remote Object* is unregistered. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Lifetime; - -// -int main() -{ - // Register a channel. - TcpChannel^ myChannel = gcnew TcpChannel; - ChannelServices::RegisterChannel( myChannel ); - RemotingConfiguration::RegisterActivatedClientType( - RemotingSamples::HelloService::typeid, "tcp://localhost:8085/" ); - - // Get the remote Object*. - RemotingSamples::HelloService ^ myService = gcnew RemotingSamples::HelloService; - - // Get a sponsor for renewal of time. - ClientSponsor^ mySponsor = gcnew ClientSponsor; - - // Register the service with sponsor. - mySponsor->Register( myService ); - - // Set renewaltime. - mySponsor->RenewalTime = TimeSpan::FromMinutes( 2 ); - - // Renew the lease. - ILease^ myLease = dynamic_cast(mySponsor->InitializeLifetimeService()); - TimeSpan myTime = mySponsor->Renewal( myLease ); - Console::WriteLine( "Renewed time in minutes is {0}", myTime.Minutes ); - - // Call the remote method. - Console::WriteLine( myService->HelloMethod( "World" ) ); - - // Unregister the channel. - mySponsor->Unregister( myService ); - mySponsor->Close(); -} -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_server.cpp deleted file mode 100644 index c3f3966269b9c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_server.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Lifetime; - -int main() -{ - RemotingConfiguration::Configure( "Server.config" ); - Console::WriteLine( "Server started." ); - Console::WriteLine( "Hit enter to terminate..." ); - Console::Read(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_share.cpp deleted file mode 100644 index 97289d67531db..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/clientsponsor_share.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Lifetime; - -namespace RemotingSamples -{ - public ref class HelloService: public MarshalByRefObject - { - public: - String^ HelloMethod( String^ name ) - { - Console::WriteLine( "Hello {0}", name ); - return String::Format( "Hello {0}", name ); - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/makefile deleted file mode 100644 index 1ff152d3ad74e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ClientSponsor_Register/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: ClientSponsor_Server.exe ClientSponsor_Client.exe - -ClientSponsor_Server.exe: ClientSponsor_Server.cpp ClientSponsor_Share.dll - cl /clr:pure ClientSponsor_Server.cpp - -ClientSponsor_Client.exe: ClientSponsor_Client.cpp ClientSponsor_Share.dll - cl /clr:pure ClientSponsor_Client.cpp - -ClientSponsor_Share.dll: ClientSponsor_Share.cpp - cl /LD /clr:pure ClientSponsor_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CommonTransportKeys/CPP/commontransportkeys.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CommonTransportKeys/CPP/commontransportkeys.cpp deleted file mode 100644 index 92548f77799d9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CommonTransportKeys/CPP/commontransportkeys.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// System.Runtime.Remoting.Channels.CommonTransportKeys -// System.Runtime.Remoting.Channels.CommonTransportKeys.IPAddress -// System.Runtime.Remoting.Channels.CommonTransportKeys.ConnectionId -// System.Runtime.Remoting.Channels.CommonTransportKeys.RequestUri -/* -This program demonstrates 'CommonTransportKeys' class and the static members 'IPAddress', 'ConnectionId', -'RequestUri'. 'LoggingClientChannelSinkProvider' and 'LoggingServerChannelSinkProvider' classes are -created which inherits'IClientChannelSinkProvider' and 'IServerChannelSinkProvider' respectively. -'ProcessMessage' method is having 'ITransportHeaders' parameter which gives the required header values. - -Note: This snippet assumes CommonTransportKeys_Server.cs, CommonTransportKeys_Client.cs, -CommonTransportKeys_Share.cs files along with channels.config, server.exe.config, client.exe. -config config files. -*/ -#using - -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Permissions; - -namespace Logging -{ - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - private ref class LoggingClientChannelSink: public BaseChannelObjectWithProperties, public IClientChannelSink - { - private: - IClientChannelSink^ nextSink1; - - public: - LoggingClientChannelSink() - : nextSink1( nullptr ) - {} - - LoggingClientChannelSink( IClientChannelSink^ localNextSink ) - : BaseChannelObjectWithProperties() - { - nextSink1 = localNextSink; - } - - - virtual void ProcessMessage( IMessage^ msg, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) = IClientChannelSink::ProcessMessage - { - nextSink1->ProcessMessage( msg, requestHeaders, requestStream, responseHeaders, responseStream ); - } - - virtual void AsyncProcessRequest( IClientChannelSinkStack^ sinkStack, IMessage^ msg, ITransportHeaders^ headers, Stream^ stream1 ) - { - sinkStack->Push( this, nullptr ); - nextSink1->AsyncProcessRequest( sinkStack, msg, headers, stream1 ); - } - - virtual void AsyncProcessResponse( IClientResponseChannelSinkStack^ sinkStack, Object^ /*state*/, ITransportHeaders^ headers, Stream^ stream1 ) - { - sinkStack->AsyncProcessResponse( headers, stream1 ); - } - - virtual Stream^ GetRequestStream( IMessage^ /*msg*/, ITransportHeaders^ /*headers*/ ) - { - return nullptr; - } - - property IClientChannelSink^ NextChannelSink - { - virtual IClientChannelSink^ get() - { - return nextSink1; - } - } - }; - - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - public ref class LoggingClientChannelSinkProvider: public IClientChannelSinkProvider - { - private: - IClientChannelSinkProvider^ next1; - - public: - LoggingClientChannelSinkProvider() - : next1( nullptr ) - {} - - virtual IClientChannelSink^ CreateSink( IChannelSender^ channel1, String^ url1, Object^ remoteChannelData ) - { - IClientChannelSink^ localNextSink = nullptr; - if ( next1 != nullptr ) - { - localNextSink = next1->CreateSink( channel1, url1, remoteChannelData ); - if ( localNextSink == nullptr ) - return nullptr; - } - - return gcnew LoggingClientChannelSink( localNextSink ); - } - - property IClientChannelSinkProvider^ Next - { - virtual IClientChannelSinkProvider^ get() - { - return next1; - } - - virtual void set( IClientChannelSinkProvider^ value ) - { - next1 = value; - } - } - }; - - // - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - private ref class LoggingServerChannelSink: public BaseChannelObjectWithProperties, public IServerChannelSink - { - private: - IServerChannelSink^ nextSink2; - bool bEnabled2; - - public: - LoggingServerChannelSink() - : nextSink2( nullptr ), bEnabled2( true ) - {} - - LoggingServerChannelSink( IServerChannelSink^ localNextSink ) - : BaseChannelObjectWithProperties() - { - nextSink2 = localNextSink; - } - - virtual ServerProcessing ProcessMessage( IServerChannelSinkStack^ sinkStack, IMessage^ requestMsg, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]IMessage^% responseMsg, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) = IServerChannelSink::ProcessMessage - { - if ( bEnabled2 ) - { - Console::WriteLine( "----------Request Headers-----------" ); - - // - Console::WriteLine( "{0}:{1}", CommonTransportKeys::IPAddress, - requestHeaders[ CommonTransportKeys::IPAddress ] ); - // - // - Console::WriteLine( "{0}:{1}", CommonTransportKeys::ConnectionId, - requestHeaders[ CommonTransportKeys::ConnectionId ] ); - // - // - Console::WriteLine( "{0}:{1}", CommonTransportKeys::RequestUri, - requestHeaders[ CommonTransportKeys::RequestUri ] ); - // - } - - sinkStack->Push( this, nullptr ); - ServerProcessing processing = nextSink2->ProcessMessage( sinkStack, requestMsg, requestHeaders, requestStream, responseMsg, responseHeaders, responseStream ); - switch ( processing ) - { - case ServerProcessing::Complete: - sinkStack->Pop( this ); - break; - - case ServerProcessing::OneWay: - sinkStack->Pop( this ); - break; - - case ServerProcessing::Async: - sinkStack->Store( this, nullptr ); - break; - } - return processing; - } - - virtual void AsyncProcessResponse( IServerResponseChannelSinkStack^ sinkStack, Object^ /*state*/, IMessage^ msg, ITransportHeaders^ headers, Stream^ stream1 ) - { - sinkStack->AsyncProcessResponse( msg, headers, stream1 ); - } - - virtual Stream^ GetResponseStream( IServerResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, IMessage^ /*msg*/, ITransportHeaders^ /*headers*/ ) - { - return nullptr; - } - - property IServerChannelSink^ NextChannelSink - { - virtual IServerChannelSink^ get() - { - return nextSink2; - } - } - }; - - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - public ref class LoggingServerChannelSinkProvider: public IServerChannelSinkProvider - { - private: - IServerChannelSinkProvider^ next2; - - public: - LoggingServerChannelSinkProvider() - : next2( nullptr ) - {} - - LoggingServerChannelSinkProvider( IDictionary^ /*properties*/, ICollection^ /*providerData*/ ){} - - virtual void GetChannelData( IChannelDataStore^ /*channelData*/ ){} - - virtual IServerChannelSink^ CreateSink( IChannelReceiver^ channel1 ) - { - IServerChannelSink^ localNextSink = nullptr; - if ( next2 != nullptr ) - localNextSink = next2->CreateSink( channel1 ); - - return gcnew LoggingServerChannelSink( localNextSink ); - } - - property IServerChannelSinkProvider^ Next - { - virtual IServerChannelSinkProvider^ get() - { - return next2; - } - - virtual void set( IServerChannelSinkProvider^ value ) - { - next2 = value; - } - } - }; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference/CPP/contractreference.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference/CPP/contractreference.cpp deleted file mode 100644 index 393044fb2605a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference/CPP/contractreference.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// System::Web::Services::Discovery.ContractReference -/* -The following example demonstrates the 'ContractReference' class . -A new instance of 'ContractReference' class is obtained. The -Contract reference Object* is added to the list of references -contained within the discovery document and a '.disco' file is -generated for the Webservice where the reference tags of -ContractReference are reflected. -*/ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -int main() -{ - try - { - - // Get a DiscoveryDocument. - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - - // Get a ContractReference. - ContractReference^ myContractReference = gcnew ContractReference; - - // Set the URL to the referenced service description. - myContractReference->Ref = "http://localhost/service1.asmx?wsdl"; - - // Set the URL for an XML Web service implementing the service - // description. - myContractReference->DocRef = "http://localhost/service1.asmx"; - SoapBinding^ myBinding = gcnew SoapBinding; - myBinding->Binding = gcnew XmlQualifiedName( "q1:Service1Soap" ); - myBinding->Address = "http://localhost/service1.asmx"; - - // Add myContractReference to the list of references contained - // in the discovery document. - myDiscoveryDocument->References->Add( myContractReference ); - - // Add Binding to the references collection. - myDiscoveryDocument->References->Add( myBinding ); - - // Open or create a file for writing. - FileStream^ myFileStream = gcnew FileStream( "Service1.disco",FileMode::OpenOrCreate,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - - // Write myDiscoveryDocument into the passed stream. - myDiscoveryDocument->Write( myStreamWriter ); - Console::WriteLine( "The Service1.disco is generated." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error is {0}", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_Contract/CPP/contractreference_contract.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_Contract/CPP/contractreference_contract.cpp deleted file mode 100644 index e4861522f0f37..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_Contract/CPP/contractreference_contract.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System.Web.Services.Discovery.ContractReference.Contract -/* -The following example demonstrates the 'Contract' property of the 'ContractReference' -class. -It creates an instance of 'DiscoveryDocument' class by reading from a disco file -and gets the first reference to a service description in a 'ContractReference' instance. -Using the 'Contract' property of the 'ContractReference' instance it creates a wsdl -file which works as a service description file. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Net; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Web::Services::Description; - -// -int main() -{ - try - { - // Create the file stream. - FileStream^ discoStream = gcnew FileStream( "Service1_CS.disco",FileMode::Open ); - - // Create the discovery document. - DiscoveryDocument^ myDiscoveryDocument = DiscoveryDocument::Read( discoStream ); - - // Get the first ContractReference in the collection. - ContractReference^ myContractReference = dynamic_cast(myDiscoveryDocument->References[ 0 ]); - - // Set the client protocol. - myContractReference->ClientProtocol = gcnew DiscoveryClientProtocol; - myContractReference->ClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // Get the service description. - ServiceDescription^ myContract = myContractReference->Contract; - - // Create the service description file. - myContract->Write( "MyService1.wsdl" ); - Console::WriteLine( "The WSDL file created is MyService1.wsdl" ); - discoStream->Close(); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Exception: {0}", ex->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_DefaultFileName/CPP/contractreference_defaultfilename.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_DefaultFileName/CPP/contractreference_defaultfilename.cpp deleted file mode 100644 index e61ce94cb751d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_DefaultFileName/CPP/contractreference_defaultfilename.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// System.Web.Services.Discovery.ContractReference.DefaultFileName -// System.Web.Services.Discovery.ContractReference.Url -/* -The following example demonstrates the 'DefaultFilename' and 'Url' properties of -'ContractReference' class. It gets the 'DiscoveryDocument' object using the -'Discover' method of 'DiscoveryClientProtocol' class. It gets the 'ContractReference' -object by using the 'References' property of 'DiscoveryDocument' object.Then it displays the -'DefaultFileName' and 'Url' properties of 'ContractReference'. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::Xml::Schema; -using namespace System::Collections; - -int main() -{ - // - // - DiscoveryClientProtocol^ myProtocol = gcnew DiscoveryClientProtocol; - - // Get the DiscoveryDocument. - DiscoveryDocument^ myDiscoveryDocument = myProtocol->Discover( "http://localhost/ContractReference/test_cs.disco" ); - ArrayList^ myArrayList = dynamic_cast(myDiscoveryDocument->References); - - // Get the ContractReference. - ContractReference^ myContractRefrence = dynamic_cast(myArrayList[ 0 ]); - - // Get the DefaultFileName associated with the .disco file. - String^ myFileName = myContractRefrence->DefaultFilename; - - // Get the URL associated with the .disco file. - String^ myUrl = myContractRefrence->Url; - Console::WriteLine( "The DefaulFilename is: {0}", myUrl ); - Console::WriteLine( "The URL is: {0}", myUrl ); - // - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ReadDocument/CPP/MyService1_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ReadDocument/CPP/MyService1_cpp.wsdl deleted file mode 100644 index 8bc5dacacfc57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ReadDocument/CPP/MyService1_cpp.wsdl +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ReadDocument/CPP/contractreference_readdocument.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ReadDocument/CPP/contractreference_readdocument.cpp deleted file mode 100644 index b1f994d465480..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ReadDocument/CPP/contractreference_readdocument.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// System::Web::Services::Discovery.ContractReference::ReadDocument -/* -* The following example demonstrates the 'ReadDocument' method of the -* 'ContractReference' class. -* It creates an instance of 'ContractReference' class and calls the -* 'ReadDocument' method passing a service description stream and get a -* 'ServiceDescription' instance. -*/ -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Web::Services::Description; - -// -int main() -{ - try - { - // Create the file stream. - FileStream^ wsdlStream = gcnew FileStream( "MyService1_cpp.wsdl",FileMode::Open ); - ContractReference^ myContractReference = gcnew ContractReference; - - // Read the service description from the passed stream. - ServiceDescription^ myServiceDescription = dynamic_cast(myContractReference->ReadDocument( wsdlStream )); - Console::Write( "Target Namespace for the service description is: {0}", myServiceDescription->TargetNamespace ); - wsdlStream->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_Reference/CPP/contractreference_ref.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_Reference/CPP/contractreference_ref.cpp deleted file mode 100644 index a906da5b7585a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_Reference/CPP/contractreference_ref.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -System::Web::Services::Discovery.ContractReference::ctor -System::Web::Services::Discovery.ContractReference::Ref -System::Web::Services::Discovery.ContractReference::DocRef -System::Web::Services::Discovery.ContractReference::Namespace - -The following example demonstrates the constructor, the -properties 'Ref', 'DocRef' and 'Namespace'. A sample discovery -document is read and 'Ref', 'DocRef' and 'Namespace' properties -are displayed. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -using namespace System::Web::Services::Discovery; - -int main() -{ - - // - // - // - // - // Call the Constructor of ContractReference. - ContractReference^ myContractReference = gcnew ContractReference; - // - XmlDocument^ myXmlDocument = gcnew XmlDocument; - - // Read the discovery document for the 'contractRef' tag. - myXmlDocument->Load( "http://localhost/Discoverydoc.disco" ); - XmlNode^ myXmlRoot = myXmlDocument->FirstChild; - XmlNode^ myXmlNode = myXmlRoot[ "scl:contractRef" ]; - XmlAttributeCollection^ myAttributeCollection = myXmlNode->Attributes; - myContractReference->Ref = myAttributeCollection[ 0 ]->Value; - Console::WriteLine( "The URL to the referenced service description is : {0}", myContractReference->Ref ); - // - myContractReference->DocRef = myAttributeCollection[ 1 ]->Value; - Console::WriteLine( "The URL implementing the referenced service description is : {0}", myContractReference->DocRef ); - // - Console::WriteLine( "Namespace for the referenced service description is : {0}", ContractReference::Namespace ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/TestInput_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/TestInput_cpp.wsdl deleted file mode 100644 index e0c5e90b8c55a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/TestInput_cpp.wsdl +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/TestOutput_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/TestOutput_cpp.wsdl deleted file mode 100644 index e0c5e90b8c55a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/TestOutput_cpp.wsdl +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/contractreference_writedocument.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/contractreference_writedocument.cpp deleted file mode 100644 index e2220cc74c037..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_WriteDocument/CPP/contractreference_writedocument.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -The following example demonstrates the 'WriteDocument' method of -'ContractReference' class. It creates a 'ContactReference' and a 'FileStream' Object*. -Then it gets the 'ServiceDescription' Object* corresponding to the 'test.wsdl' file. -Using the 'WriteDocument' method, the 'ServiceDescription' Object* is written into the -file stream. -Note: The 'TestInput_cpp::wsdl' file should exist in the same folder. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::IO; -using namespace System::Web::Services::Description; - -int main() -{ - try - { -// - ContractReference^ myContractReference = gcnew ContractReference; - FileStream^ myFileStream = gcnew FileStream( "TestOutput_cpp.wsdl", - FileMode::OpenOrCreate,FileAccess::Write ); - - // Get the ServiceDescription for the test .wsdl file. - ServiceDescription^ myServiceDescription = - ServiceDescription::Read( "TestInput_cpp.wsdl" ); - - // Write the ServiceDescription into the file stream. - myContractReference->WriteDocument( myServiceDescription, myFileStream ); - Console::WriteLine( "ServiceDescription is written " - + "into the file stream successfully." ); - Console::WriteLine( "The number of bytes written into the file stream: {0}", - myFileStream->Length ); - myFileStream->Close(); -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ctor1/CPP/contractreference_ctor1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ctor1/CPP/contractreference_ctor1.cpp deleted file mode 100644 index a188fe4e240cd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ctor1/CPP/contractreference_ctor1.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Web::Services::Discovery.ContractReference::ContractReference(String*) - -/* -The following example demonstrates the constructor 'ContractReference(String*)' -of 'ContractReference' class. A 'DiscoveryDocument' Object* is created .The -constructor initializes a new instance of 'ContractReference' using the supplied -reference to a Service Description::The Contract reference Object* is added to the list -of references contained within the discovery document. A '.disco' file is generated -for the webservice, where the reference tags of ContractReference are reflected. -*/ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Web::Services::Discovery; - -int main() -{ - try - { - // Create a DiscoveryDocument. - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - -// - // Create a ContractReference using a reference to a service description. - ContractReference^ myContractReference = gcnew ContractReference( - "http://localhost/Service1::asmx?wsdl" ); -// - - // Set the URL for an XML Web service implementing the service description. - myContractReference->DocRef = "http://localhost/service1.asmx"; - SoapBinding^ myBinding = gcnew SoapBinding; - myBinding->Binding = gcnew XmlQualifiedName( "q1:Service1Soap" ); - myBinding->Address = "http://localhost/service1.asmx"; - - // Add myContractReference to the list of references contained - // in the discovery document. - myDiscoveryDocument->References->Add( myContractReference ); - myDiscoveryDocument->References->Add( myBinding ); - - // Open or create a file for writing. - FileStream^ myFileStream = gcnew FileStream( "Service1.disco",FileMode::OpenOrCreate,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - - // Write myDiscoveryDocument into the passed stream. - myDiscoveryDocument->Write( myStreamWriter ); - Console::WriteLine( "The Service1.disco is generated." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error is {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ctor2/CPP/contractreference_ctor2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ctor2/CPP/contractreference_ctor2.cpp deleted file mode 100644 index ce3f7b776af1d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ContractReference_ctor2/CPP/contractreference_ctor2.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// System::Web::Services::Discovery.ContractReference::ContractReference(String*, String*) - -/* -The following example demonstrates the constructor 'ContractReference(String*, String*)' -of 'ContractReference' class. In this example the 'ContractReference' class constructor -initializes a new instance of the 'ContractReference' class using the supplied references -to a service description and a XML Web service implementing the service description.The -Contract reference Object* is added to the list of references contained within the -discovery document and a '.disco' file is generated for the webservice where the -reference tags of ContractReference are reflected. -*/ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Web::Services::Discovery; - -int main() -{ - try - { - // Get a DiscoveryDocument. - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - -// - // Create a ContractReference using a service description and - // an XML Web service. - ContractReference^ myContractReference = gcnew ContractReference( - "http://localhost/Service1::asmx?wsdl","http://localhost/Service1::asmx" ); -// - - SoapBinding^ myBinding = gcnew SoapBinding; - myBinding->Binding = gcnew XmlQualifiedName( "q1:Service1Soap" ); - myBinding->Address = "http://localhost/service1.asmx"; - - // Add myContractReference to the list of references contained - // in the discovery document. - myDiscoveryDocument->References->Add( myContractReference ); - myDiscoveryDocument->References->Add( myBinding ); - - // Open or create a file for writing. - FileStream^ myFileStream = gcnew FileStream( "Service1.disco", - FileMode::OpenOrCreate,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - - // Write myDiscoveryDocument into the passed stream. - myDiscoveryDocument->Write( myStreamWriter ); - Console::WriteLine( "The Service1.disco is generated." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error is {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp deleted file mode 100644 index 14edae829803b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp +++ /dev/null @@ -1,147 +0,0 @@ - - -/* -This program demonstrates 'Item(string)' and 'Count' properties of 'CookieCollection' class. - -This program uses an internal site called "CookiesServer.aspx". The program creates a 'HttpWebRequest' -object with the 'URL' taken from command line argument. When no cookies are initially sent to -the server, it responds with a specific page querying the client for information. The client queries -this information from the user and sends it to the server in the second request. This information is -used by the server to not only structure the page sent subsequently but also construct some cookies to be -set by the client, for future requests. The response and the cookies that are sent from the server are -displayed to the console. - -Note: This program requires the "CookiesServer.aspx" server to be running before the execution of this -program.Please refer the "ReadmeCookiesServer.txt" file for setting up the server. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Text::RegularExpressions; -void DisplayCookies( CookieCollection^ cookies ) -{ - // - // - // Get the cookies in the 'CookieCollection' object using the 'Item' property. - // The 'Item' property in C++ is implemented through Indexers. - // The class that implements indexers is usually a collection of other objects. - // This class provides access to those objects with the '[i]' syntax. - try - { - if ( cookies->Count == 0 ) - { - Console::WriteLine( "No cookies to display" ); - return; - } - - Console::WriteLine( "{0}", cookies[ "UserName" ] ); - Console::WriteLine( "{0}", cookies[ "DateOfBirth" ] ); - Console::WriteLine( "{0}", cookies[ "PlaceOfBirth" ] ); - Console::WriteLine( "" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - // - // -} - -void printUsage() -{ - Console::WriteLine( "Usage : " ); - Console::WriteLine( "CookieCollection_Item_1 " ); - Console::WriteLine( " is the name of the CookiesServer.aspx site installed locally" ); - Console::WriteLine( "\nExample : CookieCollection_Item_1 http://www.MyServer.com/CookiesServer.aspx" ); -} - -void GetPage( Uri^ requestUri ) -{ - try - { - array^output = gcnew array(120); - Stream^ myStream; - Encoding^ asciiEncoding = gcnew ASCIIEncoding; - - // Create the request. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - - // Get the response without any cookies sent to the server. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - String^ usrName; - String^ dateBirth; - String^ placeBirth; - - // Get the information from the user as requested by the server and send it over to the server. - myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - myHttpWebRequest->Method = "POST"; - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - Console::WriteLine( "\nEnter the values to be sent to the server :\n" ); - Console::Write( "UserName : " ); - usrName = Console::ReadLine(); - Console::Write( "\nDateOfBirth [dd/mm/yyyy]: " ); - dateBirth = Console::ReadLine(); - Regex^ regex = gcnew Regex( "/" ); - String^ convertDate = regex->Replace( dateBirth, "%2F" ); - Console::Write( "\nPlaceOfBirth : " ); - placeBirth = Console::ReadLine(); - Console::WriteLine( "" ); - output = asciiEncoding->GetBytes( String::Format( "UserName={0}&DateOfBirth={1}&PlaceOfBirth={2}&__EVENTTARGET=PlaceOfBirth&__EVENTARGUMENT=", usrName, convertDate, placeBirth ) ); - myHttpWebRequest->ContentLength = output->Length; - myStream = myHttpWebRequest->GetRequestStream(); - myStream->Write( output, 0, output->Length ); - myStream->Close(); - myHttpWebResponse->Close(); - - // Get the response. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Output the response to the console. - myStream = myHttpWebResponse->GetResponseStream(); - Console::WriteLine( "Displaying the contents of the page of '{0}' site:", requestUri ); - Console::WriteLine( "" ); - int bytesRead = 0; - while ( (bytesRead = myStream->Read( output, 0, output->Length )) != 0 ) - Console::Write( asciiEncoding->GetString( output, 0, bytesRead ) ); - Console::WriteLine( "" ); - Console::WriteLine( "\nDisplaying the cookies in the response : " ); - Console::WriteLine( "" ); - DisplayCookies( myHttpWebResponse->Cookies ); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - printUsage(); - return 0; - } - GetPage( gcnew Uri( args[ 1 ] ) ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp deleted file mode 100644 index 5f84293fef803..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp +++ /dev/null @@ -1,143 +0,0 @@ - - -/* -This program demonstrates 'Item(int)' properties of 'CookieCollection' class. - -This program uses an internal site called "CookiesServer.aspx". The program creates a 'HttpWebRequest' -object with the 'URL' taken from command line argument. When no cookies are initially sent to -the server, it responds with a specific page querying the client for information. The client queries -this information from the user and sends it to the server in the second request. This information is -used by the server to not only structure the page sent subsequently but also construct some cookies to be -set by the client, for future requests. The response and the cookies that are sent from the server are -displayed to the console. - -Note: This program requires the "CookiesServer.aspx" server to be running before the execution of this -program.Please refer the "ReadmeCookiesServer.txt" file for setting up the server. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Text::RegularExpressions; -void DisplayCookies( CookieCollection^ cookies ) -{ - // - // Get the cookies in the 'CookieCollection' object using the 'Item' property. - // The 'Item' property in C++ is implemented through Indexers. - // The class that implements indexers is usually a collection of other objects. - // This class provides access to those objects with the '[i]' syntax. - try - { - if ( cookies->Count == 0 ) - { - Console::WriteLine( "No cookies to display" ); - return; - } - - for ( int j = 0; j < cookies->Count; j++ ) - Console::WriteLine( "{0}", cookies[ j ] ); - Console::WriteLine( "" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - // -} - -void GetPage( Uri^ requestUri ) -{ - try - { - array^output = gcnew array(120); - Stream^ myStream; - Encoding^ asciiEncoding = gcnew ASCIIEncoding; - - // Create the request. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - - // Get the response without any cookies sent to the server. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - String^ usrName; - String^ dateBirth; - String^ placeBirth; - - // Get the information from the user as requested by the server and send it over to the server. - myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - myHttpWebRequest->Method = "POST"; - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - Console::WriteLine( "\nEnter the values to be sent to the server :\n" ); - Console::Write( "UserName : " ); - usrName = Console::ReadLine(); - Console::Write( "\nDateOfBirth [dd/mm/yyyy]: " ); - dateBirth = Console::ReadLine(); - Regex^ regex = gcnew Regex( "/" ); - String^ convertDate = regex->Replace( dateBirth, "%2F" ); - Console::Write( "\nPlaceOfBirth : " ); - placeBirth = Console::ReadLine(); - Console::WriteLine( "" ); - output = asciiEncoding->GetBytes( String::Format( "UserName={0}&DateOfBirth={1}&PlaceOfBirth={2}&__EVENTTARGET=PlaceOfBirth&__EVENTARGUMENT=", usrName, convertDate, placeBirth ) ); - myHttpWebRequest->ContentLength = output->Length; - myStream = myHttpWebRequest->GetRequestStream(); - myStream->Write( output, 0, output->Length ); - myStream->Close(); - myHttpWebResponse->Close(); - - // Get the response. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Output the response to the console. - myStream = myHttpWebResponse->GetResponseStream(); - Console::WriteLine( "Displaying the contents of the page of '{0}' site:", requestUri ); - Console::WriteLine( "" ); - int bytesRead = 0; - while ( (bytesRead = myStream->Read( output, 0, output->Length )) != 0 ) - Console::Write( asciiEncoding->GetString( output, 0, bytesRead ) ); - Console::WriteLine( "" ); - Console::WriteLine( "\nDisplaying the cookies in the response : " ); - Console::WriteLine( "" ); - DisplayCookies( myHttpWebResponse->Cookies ); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - -} - -void printUsage() -{ - Console::WriteLine( "Usage : " ); - Console::WriteLine( "CookieCollection_Item_2 " ); - Console::WriteLine( " is the name of the CookiesServer.aspx site installed locally" ); - Console::WriteLine( "\nExample : CookieCollection_Item_2 http://www.MyServer.com/CookiesServer.aspx" ); -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - printUsage(); - return 0; - } - GetPage( gcnew Uri( args[ 1 ] ) ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CreateObjRef/CPP/example.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CreateObjRef/CPP/example.cpp deleted file mode 100644 index 2426daf471f1f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CreateObjRef/CPP/example.cpp +++ /dev/null @@ -1,141 +0,0 @@ - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Serialization; - -// -// a custom ObjRef class that outputs its status -[System::Security::Permissions::SecurityPermissionAttribute( - System::Security::Permissions::SecurityAction::Demand, - Flags=System::Security::Permissions::SecurityPermissionFlag::SerializationFormatter)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::Demand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::InheritanceDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - -public ref class MyObjRef: public ObjRef -{ -private: - - // only instantiate via marshaling or deserialization - MyObjRef(){} - -public: - MyObjRef( MarshalByRefObject^ o, Type^ t ) - : ObjRef( o, t ) - { - Console::WriteLine( "Created MyObjRef." ); - ORDump(); - } - - MyObjRef( SerializationInfo^ i, StreamingContext c ) - : ObjRef( i, c ) - { - Console::WriteLine( "Deserialized MyObjRef." ); - } - - virtual void GetObjectData( SerializationInfo^ s, StreamingContext c ) override - { - - // After calling the base method, change the type from ObjRef to MyObjRef - ObjRef::GetObjectData( s, c ); - s->SetType( GetType() ); - Console::WriteLine( "Serialized MyObjRef." ); - } - - virtual Object^ GetRealObject( StreamingContext context ) override - { - if ( IsFromThisAppDomain() || IsFromThisProcess() ) - { - Console::WriteLine( "Returning actual Object* referenced by MyObjRef." ); - return ObjRef::GetRealObject( context ); - } - else - { - Console::WriteLine( "Returning proxy to remote Object*." ); - return RemotingServices::Unmarshal( this ); - } - } - - void ORDump() - { - Console::WriteLine( " --- Reporting MyObjRef Info --- " ); - Console::WriteLine( "Reference to {0}.", TypeInfo->TypeName ); - Console::WriteLine( "URI is {0}.", URI ); - Console::WriteLine( "\nWriting EnvoyInfo: " ); - if ( EnvoyInfo != nullptr ) - { - IMessageSink^ EISinks = EnvoyInfo->EnvoySinks; - while ( EISinks != nullptr ) - { - Console::WriteLine( "\tSink: {0}", EISinks ); - EISinks = EISinks->NextSink; - } - } - else - Console::WriteLine( "\t {no sinks}" ); - - Console::WriteLine( "\nWriting ChannelInfo: " ); - for ( int i = 0; i < ChannelInfo->ChannelData->Length; i++ ) - Console::WriteLine( "\tChannel: {0}", ChannelInfo->ChannelData[ i ] ); - Console::WriteLine( " ----------------------------- " ); - } -}; - -// a class that uses MyObjRef -public ref class LocalObject: public MarshalByRefObject -{ -public: - - // overriding CreateObjRef will allow us to return a custom ObjRef - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual ObjRef^ CreateObjRef( Type^ t ) override - { - return gcnew MyObjRef( this,t ); - } -}; -// - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Serialization; - -public ref class RemoteObject: public MarshalByRefObject -{ -public: - void Method1( LocalObject^ param ) - { - Console::WriteLine( "Invoked: Method1( {0})", param ); - } - -}; - -int main() -{ - ChannelServices::RegisterChannel( gcnew HttpChannel( 8090 ) ); - RemotingConfiguration::RegisterWellKnownServiceType( RemoteObject::typeid, "RemoteObject", WellKnownObjectMode::Singleton ); - RemoteObject^ RObj = dynamic_cast(Activator::GetObject( RemoteObject::typeid, "http://localhost:8090/RemoteObject" )); - LocalObject^ LObj = gcnew LocalObject; - RObj->Method1( LObj ); - Console::WriteLine( "Press Return to exit..." ); - Console::ReadLine(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CreateObjRef2/CPP/example.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CreateObjRef2/CPP/example.cpp deleted file mode 100644 index 3f4dc5fd57157..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CreateObjRef2/CPP/example.cpp +++ /dev/null @@ -1,139 +0,0 @@ - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Serialization; - -// -// a custom ObjRef class that outputs its status -[System::Security::Permissions::SecurityPermissionAttribute( - System::Security::Permissions::SecurityAction::Demand, - Flags=System::Security::Permissions::SecurityPermissionFlag::SerializationFormatter)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::Demand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::InheritanceDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -public ref class MyObjRef: public ObjRef -{ -private: - - // only instantiate using marshaling or deserialization - MyObjRef(){} - -public: - MyObjRef( MarshalByRefObject^ o, Type^ t ) - : ObjRef( o, t ) - { - Console::WriteLine( "Created MyObjRef." ); - ORDump(); - } - - MyObjRef( SerializationInfo^ i, StreamingContext c ) - : ObjRef( i, c ) - { - Console::WriteLine( "Deserialized MyObjRef." ); - } - - virtual void GetObjectData( SerializationInfo^ s, StreamingContext c ) override - { - // After calling the base method, change the type from ObjRef to MyObjRef - ObjRef::GetObjectData( s, c ); - s->SetType( GetType() ); - Console::WriteLine( "Serialized MyObjRef." ); - } - - virtual Object^ GetRealObject( StreamingContext context ) override - { - if ( IsFromThisAppDomain() || IsFromThisProcess() ) - { - Console::WriteLine( "Returning actual Object^ referenced by MyObjRef." ); - return ObjRef::GetRealObject( context ); - } - else - { - Console::WriteLine( "Returning proxy to remote Object^." ); - return RemotingServices::Unmarshal( this ); - } - } - - void ORDump() - { - Console::WriteLine( " --- Reporting MyObjRef Info --- " ); - Console::WriteLine( "Reference to {0}.", TypeInfo->TypeName ); - Console::WriteLine( "URI is {0}.", URI ); - Console::WriteLine( "\nWriting EnvoyInfo: " ); - if ( EnvoyInfo != nullptr ) - { - IMessageSink^ EISinks = EnvoyInfo->EnvoySinks; - while ( EISinks != nullptr ) - { - Console::WriteLine( "\tSink: {0}", EISinks ); - EISinks = EISinks->NextSink; - } - } - else - Console::WriteLine( "\t {no sinks}" ); - - Console::WriteLine( "\nWriting ChannelInfo: " ); - for ( int i = 0; i < ChannelInfo->ChannelData->Length; i++ ) - Console::WriteLine( "\tChannel: {0}", ChannelInfo->ChannelData[ i ] ); - Console::WriteLine( " ----------------------------- " ); - } - -}; - -// a class that uses MyObjRef -public ref class LocalObject: public MarshalByRefObject -{ -public: - - // overriding CreateObjRef will allow us to return a custom ObjRef - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual ObjRef^ CreateObjRef( Type^ t ) override - { - return gcnew MyObjRef( this,t ); - } -}; -// - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Serialization; - -public ref class RemoteObject: public MarshalByRefObject -{ -public: - void Method1( LocalObject^ param ) - { - Console::WriteLine( "Invoked: Method1( {0})", param ); - } -}; - -int main() -{ - ChannelServices::RegisterChannel( gcnew HttpChannel( 8090 ) ); - WellKnownServiceTypeEntry^ wkste = gcnew WellKnownServiceTypeEntry( RemoteObject::typeid,"RemoteObject",WellKnownObjectMode::Singleton ); - RemotingConfiguration::RegisterWellKnownServiceType( wkste ); - RemoteObject^ RObj = dynamic_cast(Activator::GetObject( RemoteObject::typeid, "http://localhost:8090/RemoteObject" )); - LocalObject^ LObj = gcnew LocalObject; - RObj->Method1( LObj ); - Console::WriteLine( "Press Return to exit..." ); - Console::ReadLine(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp deleted file mode 100644 index 292bea040314d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// System::Net::CredentialCache->Add;System::Net::CredentialCache::CredentialCache(); -// System::Net::CredentialCache::Remove;System::Net::CredentialCache. - -/*This program demontrates the 'Remove' method, 'Add' method and 'CredentialCache' -constructor of the 'CredentialCache' class.It takes an URL creates a 'WebRequest' Object* for the Url. -The program stores a known set of credentials in a credential cache and removes a credential when it -is no longer needed. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url, String^ userName, String^ password, String^ domainName ) -{ - try - { -// -// - CredentialCache^ myCredentialCache = gcnew CredentialCache; - // Used Dummy names as credentials. They are to be replaced by credentials applicable locally. - myCredentialCache->Add( gcnew Uri( "http://www.microsoft.com/" ), "Basic", gcnew NetworkCredential( "user1","passwd1","domain1" ) ); - myCredentialCache->Add( gcnew Uri( "http://www.msdn.com/" ), "Basic", gcnew NetworkCredential( "user2","passwd2","domain2" ) ); - myCredentialCache->Add( gcnew Uri( url ), "Basic", gcnew NetworkCredential( userName,password,domainName ) ); - Console::WriteLine( "\nAdded your credentials to the program's CredentialCache" ); -// -// - // Create a webrequest with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentialCache; - Console::WriteLine( "\nLinked CredentialCache to your request." ); - // Send the request and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// - - // Process response here. - - Console::Write( "Response received successfully." ); - - // Call 'Remove' method to dispose credentials for current Uri as not required further. - myCredentialCache->Remove( myWebRequest->RequestUri, "Basic" ); - Console::WriteLine( "\nYour credentials have now been removed from the program's CredentialCache" ); - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - if ( e->Response != nullptr ) - { - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", (dynamic_cast(e->Response))->StatusDescription ); - } - else - { - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", e->Status ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } - -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\n Usage:" ); - Console::WriteLine( "\n CredentialCache_Add_Remove " ); - Console::WriteLine( "\n Example: CredentialCache_Add_Remove http://www.microsoft.com Catherine cath$ microsoft" ); - } - else if ( args->Length == 4 ) - GetPage( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ] ); - else - { - Console::WriteLine( "\nInvalid arguments." ); - return 0; - } - - Console::WriteLine( " Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp deleted file mode 100644 index 778e10ae046a1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp +++ /dev/null @@ -1,82 +0,0 @@ - - -// System::Net::CredentialCache::DefaultCredentials. -/* This program demonstrates the 'DefaultCredentials' property of the 'CredentialCache' -class. -Creates an 'HttpWebRequest' Object* to access the local Uri S"http://localhost"(IIS documentation start page) -Assigns the static property 'DefaultCredentials' of 'CredentialCache' as 'Credentials' for the 'HttpWebRequest' -Object*. DefaultCredentials returns the system credentials for the current security context in which -the application is running. For a client-side application, these are usually the Windows credentials -(user name, password, and domain) of the user running the application. -These credentials are used internally to authenticate the request. -The html contents of the start page are displayed to the console. - -Note: Make sure that S"Windows Authentication" has been set as Directory Security settings -for default web site in IIS -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - try - { - // - // Ensure Directory Security settings for default web site in IIS is "Windows Authentication". - String^ url = "http://localhost"; - - // Create a 'HttpWebRequest' object with the specified url. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - - // Assign the credentials of the logged in user or the user being impersonated. - myHttpWebRequest->Credentials = CredentialCache::DefaultCredentials; - - // Send the 'HttpWebRequest' and wait for response. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - Console::WriteLine( "Authentication successful" ); - Console::WriteLine( "Response received successfully" ); - - // - Console::WriteLine( "\nPress enter to continue" ); - Console::ReadLine(); - - // Get the stream associated with the response object. - Stream^ receiveStream = myHttpWebResponse->GetResponseStream(); - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - - // Pipe the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - Console::WriteLine( "\r\nResponse stream received" ); - array^read = gcnew array(256); - - // Read 256 characters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "HTML...\r\n" ); - while ( count > 0 ) - { - // Dump the 256 characters on a string and display the string onto the console. - String^ output = gcnew String( read,0,count ); - Console::Write( output ); - count = readStream->Read( read, 0, 256 ); - } - Console::WriteLine( "" ); - - // Release the resources of response Object*. - myHttpWebResponse->Close(); - - // Release the resources of stream Object*. - readStream->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nException Raised. The following error occurred : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp deleted file mode 100644 index 050903cb32e34..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp +++ /dev/null @@ -1,86 +0,0 @@ - - -// System::Net::CredentialCache::GetCredential -/*This program demontrates the 'GetCredential' method of the CredentialCache class.It takes an URL -creates a 'WebRequest' Object* for the Url. The program stores a known set of credentials in a credential cache. -'GetCredential' will then retrieve the credentials for the requested Uri. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -void Display( NetworkCredential^ credential ) -{ - Console::WriteLine( "\nThe credentials are:" ); - Console::WriteLine( "\nUsername : {0} , Password : {1} , Domain : {2}", credential->UserName, credential->Password, credential->Domain ); -} - -void GetPage( String^ url, String^ userName, String^ password, String^ domainName ) -{ - try - { - CredentialCache^ myCredentialCache = gcnew CredentialCache; - - // Dummy names used as credentials. - myCredentialCache->Add( gcnew Uri( "http://microsoft.com/" ), "Basic", gcnew NetworkCredential( "user1","passwd1","domain1" ) ); - myCredentialCache->Add( gcnew Uri( "http://msdn.com/" ), "Basic", gcnew NetworkCredential( "user2","passwd2","domain2" ) ); - myCredentialCache->Add( gcnew Uri( url ), "Basic", gcnew NetworkCredential( userName,password,domainName ) ); - - // Create a webrequest with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - - // Call 'GetCredential' to obtain the credentials specific to our Uri. - NetworkCredential^ myCredential = myCredentialCache->GetCredential( gcnew Uri( url ), "Basic" ); - Display( myCredential ); - - // Associating only our credentials. - myWebRequest->Credentials = myCredential; - - // Sends the request and waits for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process response here. - Console::WriteLine( "\nResponse Received." ); - myWebResponse->Close(); - } - catch ( WebException^ e ) - { - if ( e->Response != nullptr ) - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", (dynamic_cast(e->Response))->StatusDescription ); - else - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\n Usage:" ); - Console::WriteLine( "\n CredentialCache_GetCredential " ); - Console::WriteLine( "\n Example: CredentialCache_GetCredential http://www.microsoft.com Catherine cath$ microsoft" ); - } - else - if ( (args->Length == 4) ) - { - GetPage( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ] ); - } - else - { - Console::WriteLine( "\nInvalid arguments." ); - return 0; - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp deleted file mode 100644 index 86beeaa5a722e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp +++ /dev/null @@ -1,92 +0,0 @@ - - -// System::Net::CredentialCache::GetEnumerator -/*This program demontrates the 'GetEnumerator' method of the CredentialCache class. -It takes an URL, creates a 'WebRequest' Object* for the Url. The program stores a known set of credentials -in a credential cache which is then bound to the request. If the url requested has it's credentials in the cache -the response will be OK . 'GetEnumerator' method is used to enlist all the credentials stored in the -'CredentialCache' Object*. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -void Display( NetworkCredential^ credential ) -{ - Console::WriteLine( "\n\tUsername : {0} , Password : {1} , Domain : {2}", credential->UserName, credential->Password, credential->Domain ); -} - -void GetPage( String^ url, String^ userName, String^ password, String^ domainName ) -{ - try - { - CredentialCache^ myCredentialCache = gcnew CredentialCache; - - // Dummy Credentials used here. - myCredentialCache->Add( gcnew Uri( "http://microsoft.com/" ), "Basic", gcnew NetworkCredential( "user1","passwd1","domain1" ) ); - myCredentialCache->Add( gcnew Uri( "http://msdn.com/" ), "Basic", gcnew NetworkCredential( "user2","passwd2","domain2" ) ); - myCredentialCache->Add( gcnew Uri( url ), "Basic", gcnew NetworkCredential( userName,password,domainName ) ); - - // Creates a webrequest with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentialCache; - IEnumerator^ listCredentials = myCredentialCache->GetEnumerator(); - Console::WriteLine( "\nDisplaying credentials stored in CredentialCache: " ); - while ( listCredentials->MoveNext() ) - Display( dynamic_cast(listCredentials->Current) ); - Console::WriteLine( "\nNow Displaying the same using 'foreach' : " ); - - // Can use foreach with CredentialCache(Since GetEnumerator function of IEnumerable* has been implemented by 'CredentialCache' class. - IEnumerator^ myEnum = myCredentialCache->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - NetworkCredential^ credential = safe_cast(myEnum->Current); - Display( credential ); - } - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process response here. - Console::WriteLine( "\nResponse Received." ); - myWebResponse->Close(); - } - catch ( WebException^ e ) - { - if ( e->Response != nullptr ) - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", (dynamic_cast(e->Response))->StatusDescription ); - else - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\n Usage:" ); - Console::WriteLine( "\n CredentialCache_GetEnumerator " ); - Console::WriteLine( "\n Example: CredentialCache_GetEnumerator http://www.microsoft.com Catherine cath$ microsoft" ); - } - else - if ( args->Length == 4 ) - { - GetPage( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ] ); - } - else - { - Console::WriteLine( "\n Invalid arguments." ); - return 0; - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/CustomProxy_Attribute_RealProxy/CPP/customproxy_sample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/CustomProxy_Attribute_RealProxy/CPP/customproxy_sample.cpp deleted file mode 100644 index f2179104c27a3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/CustomProxy_Attribute_RealProxy/CPP/customproxy_sample.cpp +++ /dev/null @@ -1,250 +0,0 @@ - - -// System::Runtime::Remoting::Proxies.ProxyAttribute::CreateInstance; -// System::Runtime::Remoting::Proxies.ProxyAttribute::CreateProxy; -// System::Runtime::Remoting::Proxies.RealProxy::SetStubData; -// System::Runtime::Remoting::Proxies.RealProxy::Invoke; -// System::Runtime::Remoting::Proxies.RealProxy::InitializeServerObject; -// System::Runtime::Remoting::Proxies.RealProxy::CreateObjRef; -// System::Runtime::Remoting::Proxies.RealProxy::GetObjectData; -// System::Runtime::Remoting::Proxies.RealProxy::GetTransparentProxy; -// System::Runtime::Remoting::Proxies.RealProxy::GetStubData; -// System::Runtime::Remoting::Proxies.RealProxy::GetProxiedType; -// System::Runtime::Remoting::Proxies.ProxyAttribute; -// System::Runtime::Remoting::Proxies.RealProxy; - -/* The following example demonstrates implementation of methods -'CreateInstance' and 'CreateProxy' of System::Runtime::Remoting::Proxies.ProxyAttribute and methods -'SetStubData', 'Invoke', 'InitializeServerObject', 'CreateObjRef', 'GetStubData', 'GetObjectData', -'GetTransparentProxy', 'GetProxiedType' of System::Runtime::Remoting::Proxies.RealProxy. - -The following program has derived from'ProxyAttribute', 'RealProxy' classes. CustomProxy is implemented by deriving -from 'RealProxy' and overriding 'Invoke' method. The new statement for 'CustomServer' class is intercepted to -derived 'CustomProxyAttribute' by setting 'ProxyAttribute' on the CustomServer class. Implementation of -'RealProxy' and 'ProxyAttribute' methods are shown. -*/ - -// -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Activation; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Contexts; -using namespace System::Security::Permissions; - -ref class CustomServer; - -[SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] -public ref class MyProxy: public RealProxy -{ -private: - String^ myUri; - MarshalByRefObject^ myMarshalByRefObject; - -public: - MyProxy() - : RealProxy() - { - Console::WriteLine( "MyProxy Constructor Called..." ); - myMarshalByRefObject = dynamic_cast(Activator::CreateInstance( CustomServer::typeid )); - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - myUri = myObjRef->URI; - } - - MyProxy( Type^ type1 ) - : RealProxy( type1 ) - { - Console::WriteLine( "MyProxy Constructor Called..." ); - myMarshalByRefObject = dynamic_cast(Activator::CreateInstance( type1 )); - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - myUri = myObjRef->URI; - } - - MyProxy( Type^ type1, MarshalByRefObject^ targetObject ) - : RealProxy( type1 ) - { - Console::WriteLine( "MyProxy Constructor Called..." ); - myMarshalByRefObject = targetObject; - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - myUri = myObjRef->URI; - } - - // - // - virtual IMessage^ Invoke( IMessage^ myMessage ) override - { - Console::WriteLine( "MyProxy 'Invoke method' Called..." ); - if ( dynamic_cast(myMessage) ) - { - Console::WriteLine( "IMethodCallMessage*" ); - } - - if ( dynamic_cast(myMessage) ) - { - Console::WriteLine( "IMethodReturnMessage*" ); - } - - if ( dynamic_cast(myMessage) ) - { - // Initialize a new instance of remote object - IConstructionReturnMessage^ myIConstructionReturnMessage = this->InitializeServerObject( static_cast(myMessage) ); - ConstructionResponse^ constructionResponse = gcnew ConstructionResponse( nullptr,static_cast(myMessage) ); - return constructionResponse; - } - - IDictionary^ myIDictionary = myMessage->Properties; - IMessage^ returnMessage; - myIDictionary[ "__Uri" ] = myUri; - - // Synchronously dispatch messages to server. - returnMessage = ChannelServices::SyncDispatchMessage( myMessage ); - - // Pushing return value and OUT parameters back onto stack. - IMethodReturnMessage^ myMethodReturnMessage = dynamic_cast(returnMessage); - return returnMessage; - } - // - // - - // - virtual ObjRef^ CreateObjRef( Type^ ServerType ) override - { - Console::WriteLine( "CreateObjRef Method Called ..." ); - CustomObjRef ^ myObjRef = gcnew CustomObjRef( myMarshalByRefObject,ServerType ); - myObjRef->URI = myUri; - return myObjRef; - } - // - - // - [System::Security::Permissions::SecurityPermissionAttribute( - System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void GetObjectData( SerializationInfo^ info, StreamingContext context ) override - { - // Add your custom data if any here. - RealProxy::GetObjectData( info, context ); - } - // - - [System::Security::Permissions::SecurityPermissionAttribute( - System::Security::Permissions::SecurityAction::Demand, - Flags=System::Security::Permissions::SecurityPermissionFlag::SerializationFormatter)] - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::InheritanceDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - ref class CustomObjRef: public ObjRef - { - public: - CustomObjRef( MarshalByRefObject^ myMarshalByRefObject, Type^ serverType ) - : ObjRef( myMarshalByRefObject, serverType ) - { - Console::WriteLine( "ObjRef 'Constructor' called" ); - } - - // Override this method to store custom data. - virtual void GetObjectData( SerializationInfo^ info, StreamingContext context ) override - { - ObjRef::GetObjectData( info, context ); - } - }; -}; - -// -[AttributeUsageAttribute(AttributeTargets::Class)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::LinkDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::InheritanceDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -public ref class MyProxyAttribute: public ProxyAttribute -{ -public: - MyProxyAttribute(){} - - // - // Create an instance of ServicedComponentProxy - virtual MarshalByRefObject^ CreateInstance( Type^ serverType ) override - { - return ProxyAttribute::CreateInstance( serverType ); - } - // - - // - // - virtual RealProxy^ CreateProxy( ObjRef^ objRef1, Type^ serverType, Object^ serverObject, Context^ serverContext ) override - { - MyProxy^ myCustomProxy = gcnew MyProxy( serverType ); - if ( serverContext != nullptr ) - { - RealProxy::SetStubData( myCustomProxy, serverContext ); - } - - if ( ( !serverType->IsMarshalByRef) && (serverContext == nullptr) ) - { - throw gcnew RemotingException( "Bad Type for CreateProxy" ); - } - - return myCustomProxy; - } - // - // -}; - -[MyProxyAttribute] -ref class CustomServer: public ContextBoundObject -{ -public: - CustomServer() - { - Console::WriteLine( "CustomServer Base Class constructor called" ); - } - - void HelloMethod( String^ str ) - { - Console::WriteLine( "HelloMethod of Server is invoked with message : {0}", str ); - } -}; -// - -// Acts as a custom proxy user. -int main() -{ - Console::WriteLine( "" ); - Console::WriteLine( "CustomProxy Sample" ); - Console::WriteLine( "================" ); - Console::WriteLine( "" ); - - // - // - // - // Create an instance of MyProxy. - MyProxy^ myProxyInstance = gcnew MyProxy( CustomServer::typeid ); - - // Get a CustomServer proxy. - CustomServer^ myHelloServer = static_cast(myProxyInstance->GetTransparentProxy()); - // - - // Get stubdata. - Console::WriteLine( "GetStubData = {0}", RealProxy::GetStubData( myProxyInstance ) ); - // - - // Get ProxyType. - Console::WriteLine( "Type of object represented by RealProxy is : {0}", myProxyInstance->GetProxiedType() ); - // - - myHelloServer->HelloMethod( "RealProxy Sample" ); - Console::WriteLine( "" ); - - // Get a reference object from server. - Console::WriteLine( "Create an objRef object to be marshalled across Application Domains..." ); - ObjRef^ CustomObjRef = myProxyInstance->CreateObjRef( CustomServer::typeid ); - Console::WriteLine( "URI of 'ObjRef' object = {0}", CustomObjRef->URI ); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp deleted file mode 100644 index 1b5f86b7e5cb6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -This program demonstrates the 'SocketPermission(PermissionState)', -'SocketPermission(NetworkAccess, TransportType, String*, int) constructors, -'FromXml', 'Intersect', 'AddPermission' methods and 'AllPorts' field -of 'SocketPermission' class. - -This program provides a class called 'DateClient' that functions as a client -for a 'DateServer'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateClient' class -provides a method called 'GetDate' which returns the current date on the server. -The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -TransportType, String*, int)' constructor. A third 'SocketPermission' Object* is -formed from the intersection of the above two 'SocketPermission' objects with the -use of the 'Intersect' method of 'SocketPermission' class. This 'SocketPermission' -Object* is used by the 'GetDate' method to verify the permissions of the calling -method. If the calling method has the requisite permissions the 'GetDate' method -connects to the 'DateServer' and returns the current date that the 'DateServer' -sends. If any exception occurs the 'GetDate' method returns an empty String*. - -Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Collections; -using namespace System::Security; -using namespace System::Security::Permissions; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateClient_SocketPermission_Constructor" ); - Console::WriteLine( "\tDateClient_SocketPermission_Constructor " ); - Console::WriteLine( "\tThe ipaddress argument is the ip address of the Date server." ); - Console::WriteLine( "\tThe port argument is the port of the Date server." ); -} - -public ref class DateClient -{ -private: - Socket^ serverSocket; - Encoding^ asciiEncoding; - IPAddress^ serverAddress; - - int serverPort; - -public: - // The constructor takes the address and port of the remote server. - DateClient( IPAddress^ ipAddress, int port ) - { - serverAddress = ipAddress; - serverPort = port; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - asciiEncoding = Encoding::ASCII; - } - - String^ GetDate() - { -// -// -// -// -// -// - SocketPermission^ socketPermission1 = gcnew SocketPermission( PermissionState::Unrestricted ); - - // Create a 'SocketPermission' Object* for two ip addresses. - SocketPermission^ socketPermission2 = gcnew SocketPermission( PermissionState::None ); - SecurityElement^ securityElement1 = socketPermission2->ToXml(); - // 'SocketPermission' Object* for 'Connect' permission - SecurityElement^ securityElement2 = gcnew SecurityElement( "ConnectAccess" ); - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and - // for 'All'ports for the ip-address. - SecurityElement^ securityElement3 = gcnew SecurityElement( "URI","192.168.144.238#-1#3" ); - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and - // for 'All' ports for the ip-address. - SecurityElement^ securityElement4 = gcnew SecurityElement( "URI","192.168.144.240#-1#3" ); - securityElement2->AddChild( securityElement3 ); - securityElement2->AddChild( securityElement4 ); - securityElement1->AddChild( securityElement2 ); - - // Obtain a 'SocketPermission' Object* using 'FromXml' method. - socketPermission2->FromXml( securityElement1 ); - - Console::WriteLine( "\nDisplays the result of FromXml method : \n" ); - Console::WriteLine( socketPermission2 ); - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission^ socketPermission3 = - gcnew SocketPermission( NetworkAccess::Connect, - TransportType::All, - "192.168.144.238", - SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3->AddPermission( NetworkAccess::Connect, - TransportType::All, - "192.168.144.239", - SocketPermission::AllPorts ); - - Console::WriteLine( "Displays the result of AddPermission method : \n" ); - Console::WriteLine( socketPermission3 ); - - // Find the intersection between two 'SocketPermission' objects. - socketPermission1 = dynamic_cast(socketPermission2->Intersect( socketPermission3 )); - - Console::WriteLine( "Displays the result of Intersect method :\n " ); - Console::WriteLine( socketPermission1 ); - - // Demand that the calling method have the requsite socket permission. - socketPermission1->Demand(); -// -// -// -// -// -// - // Get the current date from the remote date server. - try - { - int bytesReceived; - array^getByte = gcnew array(100); - serverSocket->Connect( gcnew IPEndPoint( serverAddress,serverPort ) ); - bytesReceived = serverSocket->Receive( getByte, getByte->Length, SocketFlags::None ); - return asciiEncoding->GetString( getByte, 0, bytesReceived ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return ""; - } - } -}; - -// demonstrates the caller of the 'GetDate' method for the 'DateClient' object. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 2 ) - { - PrintUsage(); - return 0; - } - - try - { - DateClient^ myDateClient = gcnew DateClient( IPAddress::Parse( args[ 0 ] ),Int32::Parse( args[ 1 ] ) ); - String^ currentDate = myDateClient->GetDate(); - Console::WriteLine( "The current date and time is : " ); - Console::WriteLine( " {0}", currentDate ); - } - // This exception is thrown by the called method in the context of improper permissions. - catch ( SecurityException^ e ) - { - Console::WriteLine( "\nSecurityException raised : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateserver_socketpermission.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateserver_socketpermission.cpp deleted file mode 100644 index 1570a8acb54b0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateserver_socketpermission.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -This program demonstrates the 'AcceptList' property of 'SocketPermission' class. - -This program provides a class called 'DateServer' that functions as a server -for a 'DateClient'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateServer' class -provides a method called 'Create' which waits for client connections and sends -the current date on that socket connection. Within the 'Create' method of -'DateServer' class an instance of 'SocketPermission' is created with the -'SocketPermission(NetworkAccess, TransportType, String*, int)' constructor. -If the calling method has the requisite permissions the 'Create' method waits -for client connections and sends the current date on the socket connection. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Security; -using namespace System::Collections; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateServer_SocketPermission" ); - Console::WriteLine( "\tDateServer_SocketPermission " ); - Console::WriteLine( "\tport is the port on which the DateServer is listening" ); -} - -public ref class DateServer -{ -private: - - // Client connecting to the date server. - Socket^ clientSocket; - Socket^ serverSocket; - Encoding^ asciiEncoding; - -public: - const int serverBacklog; - DateServer() - : serverBacklog( 10 ) - { - asciiEncoding = Encoding::ASCII; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - } - - - // Return the current date on the client connection. - bool Create( String^ portString ) - { - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and - // for 'All' ports for the ip-address. - SocketPermission^ socketPermission = gcnew SocketPermission( NetworkAccess::Accept,TransportType::All,"192.168.144.238",SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and - // for 'All' ports for the ip-address. - socketPermission->AddPermission( NetworkAccess::Accept, TransportType::All, "192.168.144.239", SocketPermission::AllPorts ); - Console::WriteLine( "Display result of AcceptList property : " ); - IEnumerator^ enumerator = socketPermission->AcceptList; - while ( enumerator->MoveNext() ) - { - Console::WriteLine( "The hostname is : {0}", dynamic_cast(enumerator->Current)->Hostname ); - Console::WriteLine( "The port is : {0}", dynamic_cast(enumerator->Current)->Port ); - Console::WriteLine( "The Transport type is : {0}", dynamic_cast(enumerator->Current)->Transport ); - } - - - // Demand for the calling method for requisite socket permissions. - socketPermission->Demand(); - serverSocket->Bind( gcnew IPEndPoint( (Dns::Resolve( Dns::GetHostName() )->AddressList)[ 0 ],Int16::Parse( portString ) ) ); - serverSocket->Listen( serverBacklog ); - while ( true ) - { - try - { - clientSocket = serverSocket->Accept(); - array^sendByte = asciiEncoding->GetBytes( DateTime::Now.ToString() ); - clientSocket->Send( sendByte, sendByte->Length, SocketFlags::None ); - clientSocket->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return false; - } - - } - } - -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 1 ) - { - PrintUsage(); - return 0; - } - - DateServer^ server = gcnew DateServer; - try - { - server->Create( args[ 0 ] ); - } - catch ( SecurityException^ securityException ) - { - Console::WriteLine( "SecurityException caught !!!" ); - Console::WriteLine( "Message : {0}", securityException->Message ); - } - catch ( Exception^ exception ) - { - Console::WriteLine( "Exception caught !!!" ); - Console::WriteLine( "Message {0}", exception->Message ); - } - -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp deleted file mode 100644 index 028625e0176e5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -This program demonstrates the 'ToXml' and 'IsUnrestricted' method and 'ConnectList' property of -'SocketPermission' class. - -This program provides a class called 'DateClient' that functions as a client -for a 'DateServer'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateClient' class -provides a method called 'GetDate' which returns the current date on the server. -The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -TransportType, String*, int)' constructor. A third 'SocketPermission' Object* is -formed from the union of the above two 'SocketPermission' objects with the use of the -'Union' method of 'SocketPermission' class . This 'SocketPermission' Object* is used by -the 'GetDate' method to verify the permissions of the calling method. If the calling -method has the requisite permissions the 'GetDate' method connects to the 'DateServer' -and returns the current date that the 'DateServer' sends. If any exception occurs -the 'GetDate' method returns an empty String*. - -Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Collections; -using namespace System::Security; -using namespace System::Security::Permissions; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateClient_SocketPermission_ToXml" ); - Console::WriteLine( "\tDateClient_SocketPermission_ToXml " ); - Console::WriteLine( "\tThe ipaddress argument is the ip address of the Date server." ); - Console::WriteLine( "\tThe port argument is the port of the Date server." ); -} - -public ref class DateClient -{ -private: - Socket^ serverSocket; - Encoding^ asciiEncoding; - IPAddress^ serverAddress; - int serverPort; - - // The constructor takes the address and port of the remote server. -public: - DateClient( IPAddress^ serverIpAddress, int port ) - { - serverAddress = serverIpAddress; - serverPort = port; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - asciiEncoding = Encoding::ASCII; - } - -private: - - // Print a security element and all its children, in a depth-first manner. - void PrintSecurityElement( SecurityElement^ securityElementObj, int depth ) - { - Console::WriteLine( "Depth : {0}", depth ); - Console::WriteLine( "Tag : {0}", securityElementObj->Tag ); - Console::WriteLine( "Text : {0}", securityElementObj->Text ); - if ( securityElementObj->Children != nullptr ) - Console::WriteLine( "Children : {0}", securityElementObj->Children->Count ); - - if ( securityElementObj->Attributes != nullptr ) - { - IEnumerator^ attributeEnumerator = securityElementObj->Attributes->GetEnumerator(); - while ( attributeEnumerator->MoveNext() ) - Console::WriteLine( "Attribute - \" {0}\" , Value - \" {1}\"", (dynamic_cast(attributeEnumerator))->Key, (dynamic_cast(attributeEnumerator))->Value ); - } - - Console::WriteLine( "" ); - if ( securityElementObj->Children != nullptr ) - { - depth += 1; - for ( int i = 0; i < securityElementObj->Children->Count; i++ ) - PrintSecurityElement( dynamic_cast(securityElementObj->Children[ i ]), depth ); - } - } - - -public: - String^ GetDate() - { - // - // - // - SocketPermission^ socketPermission1 = gcnew SocketPermission( PermissionState::Unrestricted ); - - // Create a 'SocketPermission' Object* for two ip addresses. - SocketPermission^ socketPermission2 = gcnew SocketPermission( PermissionState::None ); - SecurityElement^ securityElement4 = socketPermission2->ToXml(); - - // 'SocketPermission' Object* for 'Connect' permission - SecurityElement^ securityElement1 = gcnew SecurityElement( "ConnectAccess" ); - - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement^ securityElement2 = gcnew SecurityElement( "URI","192.168.144.238#-1#3" ); - - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement^ securityElement3 = gcnew SecurityElement( "URI","192.168.144.240#-1#3" ); - securityElement1->AddChild( securityElement2 ); - securityElement1->AddChild( securityElement3 ); - securityElement4->AddChild( securityElement1 ); - - // Obtain a 'SocketPermission' Object* using 'FromXml' method. - socketPermission2->FromXml( securityElement4 ); - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission^ socketPermission3 = gcnew SocketPermission( NetworkAccess::Connect,TransportType::All,"192.168.144.238",SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3->AddPermission( NetworkAccess::Connect, TransportType::All, "192.168.144.239", SocketPermission::AllPorts ); - Console::WriteLine( "\nChecks the Socket permissions using IsUnrestricted method : " ); - if ( socketPermission1->IsUnrestricted() ) - Console::WriteLine( "Socket permission is unrestricted" ); - else - Console::WriteLine( "Socket permission is restricted" ); - - Console::WriteLine(); - Console::WriteLine( "Display result of ConnectList property : \n" ); - IEnumerator^ enumerator = socketPermission3->ConnectList; - while ( enumerator->MoveNext() ) - { - Console::WriteLine( "The hostname is : {0}", dynamic_cast(enumerator->Current)->Hostname ); - Console::WriteLine( "The port is : {0}", dynamic_cast(enumerator->Current)->Port ); - Console::WriteLine( "The Transport type is : {0}", dynamic_cast(enumerator->Current)->Transport ); - } - - Console::WriteLine( "" ); - Console::WriteLine( "Display Security Elements :\n " ); - PrintSecurityElement( socketPermission2->ToXml(), 0 ); - - // Get a 'SocketPermission' Object* which is a union of two other 'SocketPermission' objects. - socketPermission1 = dynamic_cast(socketPermission3->Union( socketPermission2 )); - - // Demand that the calling method have the socket permission. - socketPermission1->Demand(); - // - // - // - - // Get the current date from the remote date server. - try - { - int bytesReceived; - array^getByte = gcnew array(100); - serverSocket->Connect( gcnew IPEndPoint( serverAddress,serverPort ) ); - bytesReceived = serverSocket->Receive( getByte, getByte->Length, static_cast(0) ); - return asciiEncoding->GetString( getByte, 0, bytesReceived ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return ""; - } - } -}; - -// This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' Object*. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 2 ) - { - PrintUsage(); - return 0; - } - - try - { - DateClient^ myDateClient = gcnew DateClient( IPAddress::Parse( args[ 0 ] ),Int32::Parse( args[ 1 ] ) ); - String^ currentDate = myDateClient->GetDate(); - Console::WriteLine( "The current date and time is : " ); - Console::WriteLine( " {0}", currentDate ); - } - // This exception is thrown by the called method in the context of improper permissions. - catch ( SecurityException^ e ) - { - Console::WriteLine( "\nSecurityException raised : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateserver_socketpermission.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateserver_socketpermission.cpp deleted file mode 100644 index fd182f2936116..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateserver_socketpermission.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* -This program demonstrates the 'AcceptList' property of 'SocketPermission' class. - -This program provides a class called 'DateServer' that functions as a server -for a 'DateClient'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateServer' class -provides a method called 'Create' which waits for client connections and sends -the current date on that socket connection. Within the 'Create' method of -'DateServer' class an instance of 'SocketPermission' is created with the -'SocketPermission(NetworkAccess, TransportType, String*, int)' constructor. -If the calling method has the requisite permissions the 'Create' method waits -for client connections and sends the current date on the socket connection. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Security; -using namespace System::Collections; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateServer_SocketPermission" ); - Console::WriteLine( "\tDateServer_SocketPermission " ); - Console::WriteLine( "\tport is the port on which the DateServer is listening" ); -} - -public ref class DateServer -{ -private: - - // Client connecting to the date server. - Socket^ clientSocket; - Socket^ serverSocket; - Encoding^ asciiEncoding; - -public: - int serverBacklog; - DateServer() - { - asciiEncoding = Encoding::ASCII; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - serverBacklog = 10; - } - - - // Return the current date on the client connection. - bool Create( String^ portString ) - { - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and - // for 'All' ports for the ip-address. - SocketPermission^ socketPermission = gcnew SocketPermission( NetworkAccess::Accept,TransportType::All,"192.168.144.238",SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and - // for 'All' ports for the ip-address. - socketPermission->AddPermission( NetworkAccess::Accept, TransportType::All, "192.168.144.239", SocketPermission::AllPorts ); - Console::WriteLine( "Display result of AcceptList property : " ); - IEnumerator^ enumerator = socketPermission->AcceptList; - while ( enumerator->MoveNext() ) - { - Console::WriteLine( "The hostname is : {0}", dynamic_cast(enumerator->Current)->Hostname ); - Console::WriteLine( "The port is : {0}", dynamic_cast(enumerator->Current)->Port ); - Console::WriteLine( "The Transport type is : {0}", dynamic_cast(enumerator->Current)->Transport ); - } - - // Demand for the calling method for requisite socket permissions. - socketPermission->Demand(); - serverSocket->Bind( gcnew IPEndPoint( (Dns::Resolve( Dns::GetHostName() )->AddressList)[ 0 ],Int16::Parse( portString ) ) ); - serverSocket->Listen( serverBacklog ); - while ( true ) - { - try - { - clientSocket = serverSocket->Accept(); - array^sendByte = asciiEncoding->GetBytes( DateTime::Now.ToString() ); - clientSocket->Send( sendByte, sendByte->Length, SocketFlags::None ); - clientSocket->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return false; - } - - } - } -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 1 ) - { - PrintUsage(); - return 0; - } - - DateServer^ server = gcnew DateServer; - try - { - server->Create( args[ 0 ] ); - } - catch ( SecurityException^ securityException ) - { - Console::WriteLine( "SecurityException caught !!!" ); - Console::WriteLine( "Message : {0}", securityException->Message ); - } - catch ( Exception^ exception ) - { - Console::WriteLine( "Exception caught !!!" ); - Console::WriteLine( "Message {0}", exception->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DescriptionNamespaceSample1/CPP/MathService_input_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/DescriptionNamespaceSample1/CPP/MathService_input_cpp.wsdl deleted file mode 100644 index 556e7526dd45d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DescriptionNamespaceSample1/CPP/MathService_input_cpp.wsdl +++ /dev/null @@ -1,491 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DescriptionNamespaceSample1/CPP/descriptionnamespacesample1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DescriptionNamespaceSample1/CPP/descriptionnamespacesample1.cpp deleted file mode 100644 index 3dbecd0e92aec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DescriptionNamespaceSample1/CPP/descriptionnamespacesample1.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// System.Web.Services.Description.InputBinding.InputBinding(); -// System.Web.Services.Description.InputBinding.Extensions -// System.Web.Services.Description.InputBinding -// System.Web.Services.Description.Message.Message(); -// System.Web.Services.Description.Message.Name; -// System.Web.Services.Description.Message.Parts; -// System.Web.Services.Description.MessageCollection.Add; -// System.Web.Services.Description.MessageCollection.Insert; -// System.Web.Services.Description.MessageCollection; -// System.Web.Services.Description.MessagePart.MessagePart(); -// System.Web.Services.Description.MessagePart.Element; -// System.Web.Services.Description.MessagePart.Name; -// System.Web.Services.Description.MessagePart; -// System.Web.Services.Description.MessagePartCollection.Add; -// System.Web.Services.Description.MessagePartCollection.Insert; - -/* - The following program takes input a WSDL file 'MathService_input.wsdl' with all information related to SOAP protocol - removed from it.In a way it tries to simulate a scenario wherein a service initially did not support a protocol, however later - on happen to support it. - In this example the WSDL file is modified to insert a new Binding for SOAP. The binding is populated based on - WSDL document structure defined in WSDL specification. The ServiceDescription instance is loaded with values - for 'Messages', 'PortTypes','Bindings' and 'Port'.The instance is then written to an external file 'MathService_new.wsdl'. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -ref class MyClass1 -{ - // - // Creates a Message with name = messageName having one MessagePart - // with name = partName. -public: - static Message^ CreateMessage( String^ messageName, String^ partName, String^ element, String^ targetNamespace ) - { - // - // - Message^ myMessage = gcnew Message; - myMessage->Name = messageName; - // - // - // - // - // - MessagePart^ myMessagePart = gcnew MessagePart; - myMessagePart->Name = partName; - myMessagePart->Element = gcnew XmlQualifiedName( element,targetNamespace ); - myMessage->Parts->Add( myMessagePart ); - // - // - // - // - // - return myMessage; - } - // - - // - // Used to create OperationBinding instances within 'Binding'. - static OperationBinding^ CreateOperationBinding( String^ operation, String^ targetNamespace ) - { - // Create OperationBinding for operation. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = operation; - - // - // - // Create InputBinding for operation. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - - // - // - // Create OutputBinding for operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add InputBinding and OutputBinding to OperationBinding. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - - // Create an extensibility element for SoapOperationBinding. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = String::Concat( targetNamespace, operation ); - - // Add the extensibility element SoapOperationBinding to OperationBinding. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - return myOperationBinding; - } - // - - // Used to create Operations under PortType. - static Operation^ CreateOperation( String^ operationName, String^ inputMessage, String^ outputMessage, String^ targetNamespace ) - { - Operation^ myOperation = gcnew Operation; - myOperation->Name = operationName; - OperationMessage^ input = dynamic_cast(gcnew OperationInput); - input->Message = gcnew XmlQualifiedName( inputMessage,targetNamespace ); - OperationMessage^ output = dynamic_cast(gcnew OperationOutput); - output->Message = gcnew XmlQualifiedName( outputMessage,targetNamespace ); - myOperation->Messages->Add( input ); - myOperation->Messages->Add( output ); - return myOperation; - } - - static void main() - { - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input_cpp.wsdl" ); - // Create SOAP messages. - // - Message^ myMessage = gcnew Message; - myMessage->Name = "AddSoapOut"; - // - MessagePart^ myMessagePart = gcnew MessagePart; - myMessagePart->Name = "parameters"; - myMessagePart->Element = gcnew XmlQualifiedName( "AddResponse",myServiceDescription->TargetNamespace ); - myMessage->Parts->Add( myMessagePart ); - // - myServiceDescription->Messages->Add( myMessage ); - // - // - // - Message^ myMessage1 = gcnew Message; - myMessage1->Name = "AddSoapIn"; - // - MessagePart^ myMessagePart1 = gcnew MessagePart; - myMessagePart1->Name = "parameters"; - myMessagePart1->Element = gcnew XmlQualifiedName( "Add",myServiceDescription->TargetNamespace ); - myMessage1->Parts->Insert( 0, myMessagePart1 ); - // - myServiceDescription->Messages->Insert( 16, myMessage1 ); - // - myServiceDescription->Messages->Add( CreateMessage( "SubtractSoapIn", "parameters", "Subtract", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "SubtractSoapOut", "parameters", "SubtractResponse", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "MultiplySoapIn", "parameters", "Multiply", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "MultiplySoapOut", "parameters", "MultiplyResponse", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "DivideSoapIn", "parameters", "Divide", myServiceDescription->TargetNamespace ) ); - myServiceDescription->Messages->Add( CreateMessage( "DivideSoapOut", "parameters", "DivideResponse", myServiceDescription->TargetNamespace ) ); - - // Create a new PortType. - PortType^ soapPortType = gcnew PortType; - soapPortType->Name = "MathServiceSoap"; - soapPortType->Operations->Add( CreateOperation( "Add", "AddSoapIn", "AddSoapOut", myServiceDescription->TargetNamespace ) ); - soapPortType->Operations->Add( CreateOperation( "Subtract", "SubtractSoapIn", "SubtractSoapOut", myServiceDescription->TargetNamespace ) ); - soapPortType->Operations->Add( CreateOperation( "Multiply", "MultiplySoapIn", "MultiplySoapOut", myServiceDescription->TargetNamespace ) ); - soapPortType->Operations->Add( CreateOperation( "Divide", "DivideSoapIn", "DivideSoapOut", myServiceDescription->TargetNamespace ) ); - myServiceDescription->PortTypes->Add( soapPortType ); - - // Create a new Binding for the SOAP protocol. - Binding^ myBinding = gcnew Binding; - myBinding->Name = String::Concat( myServiceDescription->Services[ 0 ]->Name, "Soap" ); - - // Pass the name of the existing PortType MathServiceSoap and the - // Xml TargetNamespace attribute of the Descriptions tag. - myBinding->Type = gcnew XmlQualifiedName( "MathServiceSoap",myServiceDescription->TargetNamespace ); - - // Create a SOAP extensibility element. - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - - // Add tag soap:binding as an extensibility element. - myBinding->Extensions->Add( mySoapBinding ); - - // Create OperationBindings for each of the operations defined - // in the .asmx file. - OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( addOperationBinding ); - OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( subtractOperationBinding ); - OperationBinding^ multiplyOperationBinding = CreateOperationBinding( "Multiply", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( multiplyOperationBinding ); - OperationBinding^ divideOperationBinding = CreateOperationBinding( "Divide", myServiceDescription->TargetNamespace ); - myBinding->Operations->Add( divideOperationBinding ); - myServiceDescription->Bindings->Insert( 0, myBinding ); - Console::WriteLine( "\nTarget namespace of the service description to which the binding was added is: {0}", myServiceDescription->Bindings[ 0 ]->ServiceDescription->TargetNamespace ); - - // Create a Port. - Port^ soapPort = gcnew Port; - soapPort->Name = "MathServiceSoap"; - soapPort->Binding = gcnew XmlQualifiedName( myBinding->Name,myServiceDescription->TargetNamespace ); - - // Create a SoapAddress extensibility element to add to the port. - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/MathService.cs.asmx"; - soapPort->Extensions->Add( mySoapAddressBinding ); - - // Add the port to the MathService, which is the first service in - // the service collection. - myServiceDescription->Services[ 0 ]->Ports->Add( soapPort ); - - // Save the ServiceDescription to an external file. - myServiceDescription->Write( "MathService_new.wsdl" ); - Console::WriteLine( "\nSuccessfully added bindings for SOAP protocol and saved results in the file MathService_new.wsdl" ); - Console::WriteLine( "\n This file should be passed to the WSDL tool as input to generate the proxy" ); - } -}; - -int main() -{ - MyClass1::main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection2/CPP/discoveryclientdocumentcollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection2/CPP/discoveryclientdocumentcollection.cpp deleted file mode 100644 index d293d82792a48..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection2/CPP/discoveryclientdocumentcollection.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* -System::Web::Services::Discovery.DiscoveryClientDocumentCollection - -The following example demonstrates the class 'DiscoveryClientDocumentCollection'. -A sample discovery document is read and the 'Keys' and 'Values' properties -are displayed. -*/ - -// -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Web::Services::Discovery; - -int main() -{ - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // 'dataservice.disco' is a sample discovery document. - String^ myStringUrl = "http://localhost/dataservice.disco"; - - // 'Discover' method is called to populate the 'Documents' property. - DiscoveryDocument^ myDiscoveryDocument = - myDiscoveryClientProtocol->Discover( myStringUrl ); - - // An instance of the 'DiscoveryClientDocumentCollection' class is created. - DiscoveryClientDocumentCollection^ myDiscoveryClientDocumentCollection = - myDiscoveryClientProtocol->Documents; - - // 'Keys' in the collection are retrieved. - ICollection^ myCollection = myDiscoveryClientDocumentCollection->Keys; - array^myObjectCollection = - gcnew array(myDiscoveryClientDocumentCollection->Count); - myCollection->CopyTo( myObjectCollection, 0 ); - Console::WriteLine( "The discovery documents in the collection are :" ); - for ( int iIndex = 0; iIndex < myObjectCollection->Length; iIndex++ ) - { - Console::WriteLine( myObjectCollection[ iIndex ] ); - - } - Console::WriteLine( "" ); - - // 'Values' in the collection are retrieved. - ICollection^ myCollection1 = myDiscoveryClientDocumentCollection->Values; - array^myObjectCollection1 = - gcnew array(myDiscoveryClientDocumentCollection->Count); - myCollection1->CopyTo( myObjectCollection1, 0 ); - Console::WriteLine( "The objects in the collection are :" ); - for ( int iIndex = 0; iIndex < myObjectCollection1->Length; iIndex++ ) - { - Console::WriteLine( myObjectCollection1[ iIndex ] ); - - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection_Keys/CPP/discoveryclientdocumentcollection_keys.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection_Keys/CPP/discoveryclientdocumentcollection_keys.cpp deleted file mode 100644 index f41808e363c92..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection_Keys/CPP/discoveryclientdocumentcollection_keys.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* -System::Web::Services::Discovery.DiscoveryClientDocumentCollection::Keys -System::Web::Services::Discovery.DiscoveryClientDocumentCollection::Values -System::Web::Services::Discovery.DiscoveryClientDocumentCollection::Contains(String) - -The following example demonstrates the 'Keys', 'Values' properties -and the 'Contains' method. The 'Keys' property returns the names -the discoverydocuments in the 'DiscoveryClientDocumentCollection' and -the 'Values' property returns the type of objects in the -'DiscoveryClientDocumentCollection'. A sample discovery document is read -and the properties 'Keys' and 'Values' and the method 'Contains' are -displayed. -*/ - -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Web::Services::Discovery; - -int main() -{ - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // 'dataservice.disco' is a sample discovery document. - String^ myStringUrl = "http://localhost/dataservice.disco"; - - // 'Discover' method is called to populate the 'Documents' property. - myDiscoveryClientProtocol->Discover( myStringUrl ); - DiscoveryClientDocumentCollection^ myDiscoveryClientDocumentCollection = - myDiscoveryClientProtocol->Documents; - - // 'Keys' in the collection are retrieved. - // - ICollection^ myCollection = myDiscoveryClientDocumentCollection->Keys; - array^myObjectCollection = - gcnew array(myDiscoveryClientDocumentCollection->Count); - myCollection->CopyTo( myObjectCollection, 0 ); - Console::WriteLine( "The discovery documents in the collection are :" ); - for ( int iIndex = 0; iIndex < myObjectCollection->Length; iIndex++ ) - Console::WriteLine( myObjectCollection[ iIndex ] ); - // - - Console::WriteLine( "" ); - - // - // 'Values' in the collection are retrieved. - ICollection^ myCollection1 = myDiscoveryClientDocumentCollection->Values; - array^myObjectCollection1 = - gcnew array(myDiscoveryClientDocumentCollection->Count); - myCollection1->CopyTo( myObjectCollection1, 0 ); - Console::WriteLine( "The objects in the collection are :" ); - for ( int iIndex = 0; iIndex < myObjectCollection1->Length; iIndex++ ) - Console::WriteLine( myObjectCollection1[ iIndex ] ); - // - - Console::WriteLine( "" ); - - // - bool myContains = myDiscoveryClientDocumentCollection->Contains( myStringUrl ); - if ( myContains ) - Console::WriteLine( "The discovery document {0} is present in the Collection", myStringUrl ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection_ctor/CPP/discoveryclientdocumentcollection_ctor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection_ctor/CPP/discoveryclientdocumentcollection_ctor.cpp deleted file mode 100644 index e5595a2be7ad7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientDocumentCollection_ctor/CPP/discoveryclientdocumentcollection_ctor.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* -System::Web::Services::Discovery.DiscoveryClientDocumentCollection::DiscoveryClientDocumentCollection -System::Web::Services::Discovery.DiscoveryClientDocumentCollection->Add -System::Web::Services::Discovery.DiscoveryClientDocumentCollection::Remove -System::Web::Services::Discovery.DiscoveryClientDocumentCollection::Item - -The following example demonstrates the constructor, the 'Add' and -'Remove' methods and the 'Item' property. The method 'Add', adds a -discovery document Object* to the DiscoveryClientDocumentCollection. -The method 'Remove', removes a discovery document Object* from the -DiscoveryClientDocumentCollection. The Item property is used to -retrieve an Object* in the DiscoveryClientDocumentCollection. A sample -discovery document is read and the methods 'Add', 'Remove' and the -property 'Item' are applied on the sample. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Web::Services::Discovery; - -int main() -{ - // - // - // - DiscoveryClientDocumentCollection^ myDiscoveryClientDocumentCollection = gcnew DiscoveryClientDocumentCollection; - // - - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - String^ myStringUrl = "http://www.contoso.com/service.disco"; - String^ myStringUrl1 = "http://www.contoso.com/service1.disco"; - myDiscoveryClientDocumentCollection->Add( myStringUrl, myDiscoveryDocument ); - myDiscoveryClientDocumentCollection->Add( myStringUrl1, myDiscoveryDocument ); - // - - myDiscoveryClientDocumentCollection->Remove( myStringUrl1 ); - // - - // - Object^ myObject = myDiscoveryClientDocumentCollection[ myStringUrl ]; - Console::WriteLine( "Object representing the Url : {0}", myObject ); - // - - Console::WriteLine( "" ); - - // 'Keys' in the collection are retrieved. - ICollection^ myCollection = myDiscoveryClientDocumentCollection->Keys; - array^myObjectCollection = gcnew array(myDiscoveryClientDocumentCollection->Count); - myCollection->CopyTo( myObjectCollection, 0 ); - Console::WriteLine( "The discovery documents in the collection are :" ); - for ( int iIndex = 0; iIndex < myObjectCollection->Length; iIndex++ ) - { - Console::WriteLine( myObjectCollection[ iIndex ] ); - } - Console::WriteLine( "" ); - - // 'Values' in the collection are retrieved. - ICollection^ myCollection1 = myDiscoveryClientDocumentCollection->Values; - array^myObjectCollection1 = gcnew array(myDiscoveryClientDocumentCollection->Count); - myCollection1->CopyTo( myObjectCollection1, 0 ); - Console::WriteLine( "The objects in the collection are :" ); - for ( int iIndex = 0; iIndex < myObjectCollection1->Length; iIndex++ ) - Console::WriteLine( myObjectCollection1[ iIndex ] ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_AdditionalInformation/CPP/discoveryclientprotocol_additionalinformation.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_AdditionalInformation/CPP/discoveryclientprotocol_additionalinformation.cpp deleted file mode 100644 index 4f8e4cdbea9fe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_AdditionalInformation/CPP/discoveryclientprotocol_additionalinformation.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// System::Web::Services::Discovery.DiscoveryClientProtocol->AdditionalInformation - -/* The following example demonstrates 'AdditionalInformation' of DiscoveryClientProtocol -class. -In the example 'SoapBinding' informations is added to a 'DiscoveryClientProtocol' using -'AdditionalInformation' collection. The soap binding added is retrived back and SoapBinding -address is displayed. The resultant document is written back. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Xml; -using namespace System::Web::Services::Discovery; - -int main() -{ - try - { - // dataservice.disco is a sample discovery document. - String^ myStringUrl = "http://localhost/dataservice.disco"; - - // Call the Discover method to populate the Documents property. - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - myDiscoveryClientProtocol->Discover( myStringUrl ); - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Address = "http://schemas.xmlsoap.org/disco/scl/"; - mySoapBinding->Binding = gcnew XmlQualifiedName( "String*","http://www.w3.org/2001/XMLSchema" ); - myDiscoveryClientProtocol->AdditionalInformation->Add( mySoapBinding ); - - // Write the information back. - myDiscoveryClientProtocol->WriteAll( "MyDirectory", "results.discomap" ); - System::Collections::IList^ myIList = myDiscoveryClientProtocol->AdditionalInformation; - mySoapBinding = nullptr; - mySoapBinding = dynamic_cast(myIList[ 0 ]); - Console::WriteLine( "The address of the SoapBinding associated with " - "AdditionalInformation is: {0}", mySoapBinding->Address ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Download/CPP/discoveryclientprotocol_download.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Download/CPP/discoveryclientprotocol_download.cpp deleted file mode 100644 index 13d35e01f3089..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Download/CPP/discoveryclientprotocol_download.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -System::Web::Services::Discovery.DiscoveryClientProtocol::DiscoveryClientProtocol -System::Web::Services::Discovery.DiscoveryClientProtocol::Download(String)* - -The following example demonstrates the 'constructor' and the -method 'Download' of the 'DiscoveryClientProtocol' class. The -'Download' method downloads a discovery document into a stream. -A sample discovery document is read and the method 'download' -is applied on it. -*/ - -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Web::Services::Discovery; - -int main() -{ -// -// - // Call the constructor of the DiscoveryClientProtocol class. - DiscoveryClientProtocol^ myDiscoveryClientProtocol = - gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - // 'dataservice.disco' is a sample discovery document. - String^ myStringUrl = "http://localhost:80/dataservice.disco"; - - Stream^ myStream = myDiscoveryClientProtocol->Download( myStringUrl ); - - Console::WriteLine( "Size of the discovery document downloaded" ); - Console::WriteLine( "is : {0} bytes", myStream->Length ); - myStream->Close(); -// -// -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Download2/CPP/discoveryclientprotocol_download.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Download2/CPP/discoveryclientprotocol_download.cpp deleted file mode 100644 index 03531eb4e6d3d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Download2/CPP/discoveryclientprotocol_download.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// System.web.Services.Discovery.DiscoveryClientProtocol.Download(string,string) - -/* -The following example demonstrates the usage of the 'Download' method -of the class 'DiscoveryClientProtocol'. The input to the program is -a discovery file 'MathService_cs.vsdisco'. It generates a 'Stream' -instance of the discovery file 'MathService_cs.vsdisco' from the -'Download' method of 'DiscoveryClientPrototocol' and prints out -the 'contentType' and length in bytes of the discoverydocument. -*/ - -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::Collections; -using namespace System::IO; - -int main() -{ -// - String^ myDiscoFile = "http://localhost/MathService_cs.vsdisco"; - String^ myEncoding = ""; - DiscoveryClientProtocol^ myDiscoveryClientProtocol = - gcnew DiscoveryClientProtocol; - - Stream^ myStream = myDiscoveryClientProtocol->Download( - myDiscoFile, myEncoding ); - Console::WriteLine( "The length of the stream in bytes: {0}", - myStream->Length ); - Console::WriteLine( "The MIME encoding of the downloaded " + - "discovery document: {0}", myEncoding ); - myStream->Close(); -// -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Errors/CPP/discoveryclientprotocol_errors.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Errors/CPP/discoveryclientprotocol_errors.cpp deleted file mode 100644 index 8f7d7442435ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientProtocol_Errors/CPP/discoveryclientprotocol_errors.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// System.web.Services.Discovery.DiscoveryClientProtocol.Errors - -/* -The following example demonstrates the usage of the 'Errors' property -of the class 'DiscoveryClientProtocol'. The input to the program is -a discovery file 'MathService_cs.vsdisco', which holds reference -related to 'MathService_cs.asmx' web service. The program is -excecuted first time with existence of the file -'MathService_cs.asmx' in the location as specified in the discovery -file. The file 'MathService_cs.asmx' is removed from the referred -location in a way to simulate a scenario wherein the file related -to web service is missing, and the program is excecuted the second time -to show the exception occuring. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::Collections; - -int main() -{ - -// - String^ myDiscoFile = "http://localhost/MathService_cs.vsdisco"; - String^ myUrlKey = "http://localhost/MathService_cs.asmx?wsdl"; - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - - // Get the discovery document. - DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol->Discover( myDiscoFile ); - IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - { - ContractReference^ myContractReference = dynamic_cast(myEnumerator->Current); - - // Get the DiscoveryClientProtocol from the ContractReference. - myDiscoveryClientProtocol = myContractReference->ClientProtocol; - myDiscoveryClientProtocol->ResolveAll(); - DiscoveryExceptionDictionary^ myExceptionDictionary = myDiscoveryClientProtocol->Errors; - if ( myExceptionDictionary->Contains( myUrlKey ) ) - { - Console::WriteLine( "System generated exceptions." ); - - // Get the exception from the DiscoveryExceptionDictionary. - Exception^ myException = myExceptionDictionary[ myUrlKey ]; - Console::WriteLine( " Source : {0}", myException->Source ); - Console::WriteLine( " Exception : {0}", myException->Message ); - } - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection/CPP/discoveryclientreferencecollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection/CPP/discoveryclientreferencecollection.cpp deleted file mode 100644 index 256a95000a9d0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection/CPP/discoveryclientreferencecollection.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System::Web::Services::Discovery.DiscoveryClientReferenceCollection - -/* -The following example demonstrates the class -'DiscoveryClientReferenceCollection'. A sample discovery document -is read and the 'Keys' and 'Values' properties are displayed. A -String* containing the URL of a discovery document is passed as -an argument to 'Contains' method of the instance of the class. -*/ - -// -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; -using namespace System::Web::Services::Discovery; - -int main() -{ - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // 'dataservice.vsdisco' is a sample discovery document. - String^ myStringUrl = "http://localhost/dataservice.vsdisco"; - - // Call the Discover method to populate the References property. - DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol->Discover( myStringUrl ); - - // Resolve all references found in the discovery document. - myDiscoveryClientProtocol->ResolveAll(); - DiscoveryClientReferenceCollection^ myDiscoveryClientReferenceCollection = myDiscoveryClientProtocol->References; - - // Retrieve the keys from the collection. - ICollection^ myCollection = myDiscoveryClientReferenceCollection->Keys; - array^myObjectCollection = gcnew array(myDiscoveryClientReferenceCollection->Count); - myCollection->CopyTo( myObjectCollection, 0 ); - Console::WriteLine( "The discovery documents, service descriptions, and XML schema" ); - Console::WriteLine( " definitions in the collection are: " ); - for ( int i = 0; i < myObjectCollection->Length; i++ ) - { - Console::WriteLine( myObjectCollection[ i ] ); - } - Console::WriteLine( "" ); - - // Retrieve the values from the collection. - ICollection^ myCollection1 = myDiscoveryClientReferenceCollection->Values; - array^myObjectCollection1 = gcnew array(myDiscoveryClientReferenceCollection->Count); - myCollection1->CopyTo( myObjectCollection1, 0 ); - Console::WriteLine( "The objects in the collection are: " ); - for ( int i = 0; i < myObjectCollection1->Length; i++ ) - { - Console::WriteLine( myObjectCollection1[ i ] ); - } - Console::WriteLine( "" ); - String^ myStringUrl1 = "http://localhost/dataservice.vsdisco"; - if ( myDiscoveryClientReferenceCollection->Contains( myStringUrl1 ) ) - { - Console::WriteLine( "The document reference {0} is part of the collection.", myStringUrl1 ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection_Items/CPP/discoveryclientreferencecollection_items.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection_Items/CPP/discoveryclientreferencecollection_items.cpp deleted file mode 100644 index 97d6c8335c879..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection_Items/CPP/discoveryclientreferencecollection_items.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -System::Web::Services::Discovery.DiscoveryClientReferenceCollection::DiscoveryClientReferenceCollection -System::Web::Services::Discovery.DiscoveryClientReferenceCollection->Add(DiscoveryReference) -System::Web::Services::Discovery.DiscoveryClientReferenceCollection->Add(DiscoveryReference, url) -System::Web::Services::Discovery.DiscoveryClientReferenceCollection::Remove -System::Web::Services::Discovery.DiscoveryClientReferenceCollection::Item - -The following example demonstrates the 'constructor' and various members of -the class 'DiscoveryClientReferenceCollection'. The 'Add(DiscoveryReference)' -method adds a DocumentReference Object* to the DiscoveryClientDocumentCollection -collection. The Add(url, DiscoveryReference) method adds a DiscoveryReference -with the specified Url. The 'Remove' method removes a DiscoveryReference with -the specified Url from the 'DiscoveryClientReferenceCollection' collection. -The 'Item' property gets or sets a DiscoveryReference Object* from the -'DiscoveryClientReferenceCollection' with the specified Url. -*/ - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Web::Services::Discovery; - -int main() -{ - // - // - // - DiscoveryClientReferenceCollection^ myDiscoveryClientReferenceCollection = gcnew DiscoveryClientReferenceCollection; - ContractReference^ myContractReference = gcnew ContractReference; - String^ myStringUrl1 = "http://www.contoso.com/service1.disco"; - myContractReference->Ref = myStringUrl1; - myDiscoveryClientReferenceCollection->Add( myContractReference ); - // - // - - // myDiscoveryClientReferenceCollection is an instance collection. - Object^ myObject = myDiscoveryClientReferenceCollection[ myStringUrl1 ]; - Console::WriteLine( "Object representing the URL: {0}", myObject ); - // - - Console::WriteLine( "" ); - - // - // - DiscoveryDocumentReference^ myDiscoveryDocumentReference = gcnew DiscoveryDocumentReference; - String^ myStringUrl = "http://www.contoso.com/service.disco"; - myDiscoveryClientReferenceCollection->Add( myStringUrl, myDiscoveryDocumentReference ); - // - - myDiscoveryClientReferenceCollection->Remove( myStringUrl ); - // - - // Retrieve the keys in the collection. - ICollection^ myCollection = myDiscoveryClientReferenceCollection->Keys; - array^myObjectCollection = gcnew array(myDiscoveryClientReferenceCollection->Count); - myCollection->CopyTo( myObjectCollection, 0 ); - Console::WriteLine( "The discovery documents, service descriptions, and" ); - Console::WriteLine( "XML schema definitions in the collection are:" ); - for ( int iIndex = 0; iIndex < myObjectCollection->Length; iIndex++ ) - { - Console::WriteLine( myObjectCollection[ iIndex ] ); - } - Console::WriteLine( "" ); - - // Retrieve the values in the collection. - ICollection^ myCollection1 = myDiscoveryClientReferenceCollection->Values; - array^myObjectCollection1 = gcnew array(myDiscoveryClientReferenceCollection->Count); - myCollection1->CopyTo( myObjectCollection1, 0 ); - Console::WriteLine( "The objects in the collection are:" ); - for ( int iIndex = 0; iIndex < myObjectCollection1->Length; iIndex++ ) - { - Console::WriteLine( myObjectCollection1[ iIndex ] ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection_Keys/CPP/discoveryclientreferencecollection_keys.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection_Keys/CPP/discoveryclientreferencecollection_keys.cpp deleted file mode 100644 index 58015aa26dfab..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientReferenceCollection_Keys/CPP/discoveryclientreferencecollection_keys.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -System::Web::Services::Discovery.DiscoveryClientReferenceCollection::Keys -System::Web::Services::Discovery.DiscoveryClientReferenceCollection::Values -System::Web::Services::Discovery.DiscoveryClientReferenceCollection::Contains - -The following example demonstrates the 'Keys', 'Values' properties and -the method 'Contains' of the class 'DiscoveryClientReferenceCollection'. A sample -discovery document is read and the 'Keys', 'Values' and 'Contains' properties -are displayed. -*/ - -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; -using namespace System::Web::Services::Discovery; - -int main() -{ -// - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // 'dataservice.disco' is a sample discovery document. - String^ myStringUrl = "http://localhost/dataservice.disco"; - - // Call the Discover method to populate the References property. - DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol->Discover( myStringUrl ); - - // Resolve all references found in the discovery document. - myDiscoveryClientProtocol->ResolveAll(); - DiscoveryClientReferenceCollection^ myDiscoveryClientReferenceCollection = myDiscoveryClientProtocol->References; - - // Retrieve the keys in the collection. - ICollection^ myCollection = myDiscoveryClientReferenceCollection->Keys; - array^myObjectCollection = gcnew array(myDiscoveryClientReferenceCollection->Count); - myCollection->CopyTo( myObjectCollection, 0 ); - Console::WriteLine( "The discovery documents, service descriptions, and XML schema" ); - Console::WriteLine( " definitions in the collection are:" ); - for ( int iIndex = 0; iIndex < myObjectCollection->Length; iIndex++ ) - { - Console::WriteLine( myObjectCollection[ iIndex ] ); - } -// - Console::WriteLine( "" ); -// - // Retrieve the values in the collection. - ICollection^ myCollection1 = myDiscoveryClientReferenceCollection->Values; - array^myObjectCollection1 = gcnew array(myDiscoveryClientReferenceCollection->Count); - myCollection1->CopyTo( myObjectCollection1, 0 ); - Console::WriteLine( "The objects in the collection are:" ); - for ( int iIndex = 0; iIndex < myObjectCollection1->Length; iIndex++ ) - { - Console::WriteLine( myObjectCollection1[ iIndex ] ); - } -// - Console::WriteLine( "" ); -// - String^ myStringUrl1 = "http://localhost/dataservice.disco"; - if ( myDiscoveryClientReferenceCollection->Contains( myStringUrl1 ) ) - { - Console::WriteLine( "The document reference {0} is part of the collection.", myStringUrl1 ); - } -// -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult/CPP/discoveryclientresult.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult/CPP/discoveryclientresult.cpp deleted file mode 100644 index 8dc400a665b8a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult/CPP/discoveryclientresult.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// System.Web.Services.DiscoveryClientResult -/* -The following example demonstrates 'DiscoveryClientResult' class. -A 'DiscoveryClientResultCollection' object is obtained by reading a -'.discomap' file which contains the 'DiscoveryClientResult' objects, -representing the details of discovery references. The contents of this -collection are displayed.. -*/ -// -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -int main() -{ - try - { - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - - // Get the collection holding DiscoveryClientResult objects. - DiscoveryClientResultCollection^ myDiscoveryClientResultCollection = myDiscoveryClientProtocol->ReadAll( "results.discomap" ); - Console::WriteLine( "The number of DiscoveryClientResult objects: {0}", myDiscoveryClientResultCollection->Count ); - Console::WriteLine( "Displaying the items in the collection:" ); - - // Iterate through the collection and display the properties - // of each DiscoveryClientResult in it. - System::Collections::IEnumerator^ myEnum = myDiscoveryClientResultCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DiscoveryClientResult^ myDiscoveryClientResult = safe_cast(myEnum->Current); - Console::WriteLine( "Type of reference in the discovery document: {0}", myDiscoveryClientResult->ReferenceTypeName ); - Console::WriteLine( "Url for the reference: {0}", myDiscoveryClientResult->Url ); - Console::WriteLine( "File for saving the reference: {0}", myDiscoveryClientResult->Filename ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error is {0}", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResultCollection/CPP/discoveryclientresultcollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResultCollection/CPP/discoveryclientresultcollection.cpp deleted file mode 100644 index 0a3223d17da07..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResultCollection/CPP/discoveryclientresultcollection.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// System.Web.Services.Discovery.DiscoveryClientResultCollection - -/* -The following example demonstrates 'DiscoveryClientResultCollection' class. -A 'DiscoveryClientResultCollection' object is obtained by reading a '.discomap' file -which contains the 'DiscoveryClientResult' objects, representing the details of -discovery references. An element from the collection is removed and programmatically -added to 'DiscoveryClientResultCollection' class. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Xml::Schema; -using namespace System::Collections; - -int main() -{ - try - { - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - - // Get the collection of DiscoveryClientResult objects. - DiscoveryClientResultCollection^ myDiscoveryClientResultCollection = - myDiscoveryClientProtocol->ReadAll( "results.discomap" ); - Console::WriteLine( "Removing a DiscoveryClientResult from the collection..." ); - - // Remove the first DiscoveryClientResult from the collection. - myDiscoveryClientResultCollection->Remove( myDiscoveryClientResultCollection[ 0 ] ); - Console::WriteLine( "Adding a DiscoveryClientResult to the collection..." ); - DiscoveryClientResult^ myDiscoveryClientResult = gcnew DiscoveryClientResult; - - // Set the DiscoveryDocumentReference class as the type of - // reference in the discovery document. - myDiscoveryClientResult->ReferenceTypeName = - "System.Web.Services.Discovery.DiscoveryDocumentReference"; - - // Set the URL for the reference. - myDiscoveryClientResult->Url = "http://localhost/Discovery/Service1_cs.asmx?disco"; - - // Set the name of the file in which the reference is saved. - myDiscoveryClientResult->Filename = "Service1_cs.disco"; - - // Add myDiscoveryClientResult to the collection. - myDiscoveryClientResultCollection->Add( myDiscoveryClientResult ); - if ( myDiscoveryClientResultCollection->Contains( myDiscoveryClientResult ) ) - { - Console::WriteLine( "Instance of DiscoveryClientResult found in the Collection" ); - } - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Error is {0}", ex->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult_Filename/CPP/discoveryclientresult_filename.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult_Filename/CPP/discoveryclientresult_filename.cpp deleted file mode 100644 index e186c3aeca331..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult_Filename/CPP/discoveryclientresult_filename.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// System.Web.Services.Discovery.DiscoveryClientResultCollection.Remove -// System.Web.Services.Discovery.DiscoveryClientResult() -// System.Web.Services.Discovery.DiscoveryClientResult.ReferenceTypeName -// System.Web.Services.Discovery.DiscoveryClientResult.Url -// System.Web.Services.Discovery.DiscoveryClientResult.Filename -// System.Web.Services.Discovery.DiscoveryClientResultCollection.Add -// System.Web.Services.Discovery.DiscoveryClientResultCollection.Contains -// System.Web.Services.Discovery.DiscoveryClientResultCollection.Item - -/* -The following example demonstrates 'ReferenceTypeName' ,'Url','Filename' properties and the -constructor of 'DiscoveryClientResult' class and 'Remove', 'Add' 'Contains' methods and -'Item' property of 'DiscoveryClientResultCollection' class. -A 'DiscoveryClientResultCollection' object is obtained by reading a '.discomap' file -which contains the 'DiscoveryClientResult' objects, representing the details of -discovery references. An element from the collection is removed and programmatically -added to it to show the usage of methods of 'DiscoveryClientResultCollection' class . -The contents of this collection are displayed.. -*/ - -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; - -int main() -{ - try - { - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - - // Get the collection of DiscoveryClientResult objects. - DiscoveryClientResultCollection^ myDiscoveryClientResultCollection = myDiscoveryClientProtocol->ReadAll( "results.discomap" ); - Console::WriteLine( "The number of DiscoveryClientResult objects: {0}", myDiscoveryClientResultCollection->Count ); - Console::WriteLine( "Removing a DiscoveryClientResult from the collection..." ); - - // - // Remove the first DiscoveryClientResult from the collection. - myDiscoveryClientResultCollection->Remove( myDiscoveryClientResultCollection[ 0 ] ); - // - - Console::WriteLine( "Adding a DiscoveryClientResult to the collection..." ); - - // - // - // - // - // - // Initialize new instance of the DiscoveryClientResult class. - DiscoveryClientResult^ myDiscoveryClientResult = gcnew DiscoveryClientResult; - - // Set the type of reference in the discovery document as - // DiscoveryDocumentReference. - myDiscoveryClientResult->ReferenceTypeName = "System.Web.Services.Discovery.DiscoveryDocumentReference"; - - // Set the URL for the reference. - myDiscoveryClientResult->Url = "http://localhost/Discovery/Service1_cs.asmx?disco"; - - // Set the name of the file in which the reference is saved. - myDiscoveryClientResult->Filename = "Service1_cs.disco"; - - // Add the DiscoveryClientResult to the collection. - myDiscoveryClientResultCollection->Add( myDiscoveryClientResult ); - // - // - // - // - // - - // - if ( myDiscoveryClientResultCollection->Contains( myDiscoveryClientResult ) ) - { - Console::WriteLine( "The collection contains the specified " - "DiscoveryClientResult instance." ); - } - // - - Console::WriteLine( "Displaying the items in collection" ); - - // - for ( int i = 0; i < myDiscoveryClientResultCollection->Count; i++ ) - { - DiscoveryClientResult^ myClientResult = myDiscoveryClientResultCollection[ i ]; - Console::WriteLine( "DiscoveryClientResult {0}", (i + 1) ); - Console::WriteLine( "Type of reference in the discovery document: {0}", myClientResult->ReferenceTypeName ); - Console::WriteLine( "Url for reference:{0}", myClientResult->Url ); - Console::WriteLine( "File for saving the reference: {0}", myClientResult->Filename ); - } - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error is {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult_ctor/CPP/discoveryclientresult_ctor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult_ctor/CPP/discoveryclientresult_ctor.cpp deleted file mode 100644 index 40ff11fefc455..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResult_ctor/CPP/discoveryclientresult_ctor.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// System.Web.Services.Discovery.DiscoveryClientResult(Type,String,String) - -/* -The following example demonstrates the DiscoveryClientResult(Type,String,String) -constructor of 'DiscoveryClientResult' class. -A 'DiscoveryClientResultCollection' object is obtained by reading a '.discomap' file -which contains the 'DiscoveryClientResult' objects, representing the details of -discovery references. A 'DiscoveryClientProtocol' object from the collection is -removed. Then a 'DiscoveryClientProtocol' is created suppling the type of reference -in the discovery document, URL for the reference and name of the file in which the -reference is saved.and programmatically added to it. The contents of this collection -are displayed. -*/ - -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Web::Services::Discovery; - -int main() -{ - try - { - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - - // Get the collection of DiscoveryClientResult objects. - DiscoveryClientResultCollection^ myDiscoveryClientResultCollection = - myDiscoveryClientProtocol->ReadAll( "results.discomap" ); - Console::WriteLine( "The number of DiscoveryClientResult objects: {0}", myDiscoveryClientResultCollection->Count ); - Console::WriteLine( "Removing a DiscoveryClientResult " - "from the collection..." ); - - // Remove first DiscoveryClientResult from the collection. - myDiscoveryClientResultCollection->Remove( myDiscoveryClientResultCollection[ 0 ] ); - Console::WriteLine( "Adding a DiscoveryClientResult " - "to the collection..." ); - - // - // Initialize a new instance of the DiscoveryClientResult class. - DiscoveryClientResult^ myDiscoveryClientResult = - gcnew DiscoveryClientResult( System::Web::Services::Discovery::DiscoveryDocumentReference::typeid, - "http://localhost/Discovery/Service1_cs.asmx?disco","Service1_cs.disco" ); - - // Add the DiscoveryClientResult to the collection. - myDiscoveryClientResultCollection->Add( myDiscoveryClientResult ); - // - - Console::WriteLine( "Displaying the items in the collection" ); - for ( int i = 0; i < myDiscoveryClientResultCollection->Count; i++ ) - { - DiscoveryClientResult^ myClientResult = myDiscoveryClientResultCollection[ i ]; - Console::WriteLine( "DiscoveryClientResult Object {0}", (i + 1) ); - Console::WriteLine( "Type of reference in the discovery document: {0}", myClientResult->ReferenceTypeName ); - Console::WriteLine( "URL for reference: {0}", myClientResult->Url ); - Console::WriteLine( "File for saving the reference: {0}", myClientResult->Filename ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error is {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResultsFile_Results/CPP/discoveryclientresultsfile_results.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResultsFile_Results/CPP/discoveryclientresultsfile_results.cpp deleted file mode 100644 index 331ee9af57712..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryClientResultsFile_Results/CPP/discoveryclientresultsfile_results.cpp +++ /dev/null @@ -1,66 +0,0 @@ - - -// System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoveryClientResultsFile -// System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoveryClientResultsFile.ctor -// System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoveryClientResultsFile.Results -/* -The following example demonstrates the usage of 'DiscoveryClientProtocol. -DiscoveryClientResultsFile' class, constructor 'DiscoveryClientProtocol. -DiscoveryClientResultsFile()' and the property 'Results' of the class. -The input to the program is a VSDisco file 'MathService.vsdisco', which -holds reference to 'MathService' web service. The 'Results' property returns -all valid references of the discovery document 'MathService.vsdisco'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::Net; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -int main() -{ - String^ outputDirectory = "c:\\InetPub\\wwwroot"; - DiscoveryClientProtocol^ myClient = gcnew DiscoveryClientProtocol; - - // Use default credentials to access the URL being discovered. - myClient->Credentials = CredentialCache::DefaultCredentials; - try - { - DiscoveryDocument^ myDocument; - - // Discover the supplied URL to determine if it is a discovery document. - myDocument = myClient->Discover( "http://localhost/MathService_cs.vsdisco" ); - myClient->ResolveAll(); - DiscoveryClientResultCollection^ myCollection = myClient->WriteAll( outputDirectory, "MyDiscoMap.discomap" ); - - // - // - // Get the DiscoveryClientProtocol.DiscoveryClientResultsFile. - DiscoveryClientProtocol::DiscoveryClientResultsFile ^ myResultFile = gcnew DiscoveryClientProtocol::DiscoveryClientResultsFile; - XmlSerializer^ mySerializer = gcnew XmlSerializer( myResultFile->GetType() ); - XmlReader^ reader = gcnew XmlTextReader( "http://localhost/MyDiscoMap.discomap" ); - myResultFile = dynamic_cast(mySerializer->Deserialize( reader )); - - // Get a collection of DiscoveryClientResult objects. - DiscoveryClientResultCollection^ myResultcollection = myResultFile->Results; - Console::WriteLine( "Referred file(s): " ); - System::Collections::IEnumerator^ myEnum = myResultcollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DiscoveryClientResult^ myResult = safe_cast(myEnum->Current); - Console::WriteLine( myResult->Filename ); - } - // - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument/CPP/discoverydocument.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument/CPP/discoverydocument.cpp deleted file mode 100644 index 8106396f6fa55..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument/CPP/discoverydocument.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// System::Web::Services::Discovery.DiscoveryDocument -// System::Web::Services::Discovery.DiscoveryDocument::Write(TextWriter) -/* The following example deomonstrates DiscoveryDocument class and the 'Write(Stream)' method -of the 'DiscoveryDocument' class. -A XmlTextReader Object* is created with a sample discovery file and this -is passed to the Read method to create a DiscoveryDocument. The contents -of this document is displayed onto the console using the Write(TextWriter) -method. -*/ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Collections; -int main() -{ - try - { - - // Create an Object* of the 'DiscoveryDocument'. - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - - // Create an XmlTextReader with the sample file. - XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( "http://localhost/example_cs.disco" ); - - // Read the given XmlTextReader. - myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader ); - - // - // Write the DiscoveryDocument into the 'TextWriter'. - FileStream^ myFileStream = gcnew FileStream( "log.txt",FileMode::OpenOrCreate,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myDiscoveryDocument->Write( myStreamWriter ); - myStreamWriter->Flush(); - myStreamWriter->Close(); - - // - // Display the contents of the DiscoveryDocument onto the console. - FileStream^ myFileStream1 = gcnew FileStream( "log.txt",FileMode::OpenOrCreate,FileAccess::Read ); - StreamReader^ myStreamReader = gcnew StreamReader( myFileStream1 ); - - // Set the file pointer to the begin. - myStreamReader->BaseStream->Seek( 0, SeekOrigin::Begin ); - Console::WriteLine( "The contents of the DiscoveryDocument are-" ); - while ( myStreamReader->Peek() > -1 ) - { - Console::WriteLine( myStreamReader->ReadLine() ); - } - myStreamReader->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised : {0}", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_Document_ResolveAll/CPP/ddreference_document_resolveall.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_Document_ResolveAll/CPP/ddreference_document_resolveall.cpp deleted file mode 100644 index 2c15fc11a0911..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_Document_ResolveAll/CPP/ddreference_document_resolveall.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// System::Web::Services::Discovery.DiscoveryDocumentReference::Document -// System::Web::Services::Discovery.DiscoveryDocumentReference::ResolveAll() -/* -This program demonstrates the 'Document' property and 'ResolveAll()' method of -'DiscoveryDocumentReference' class. Set the 'ClientProtocol' of -'DiscoveryDocumentReference' class. The validity of the documents within the discovery -document is verified using the 'ResolveAll' method and the valid references to the -discovery documents are displayed on the console using the 'Document' property. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::Collections; -int main() -{ - try - { - // - String^ myUrl = "http://localhost/Sample_cs.vsdisco"; - DiscoveryClientProtocol^ myProtocol = gcnew DiscoveryClientProtocol; - - // Get the discovery document myDiscoveryDocument. - DiscoveryDocument^ myDiscoveryDocument = myProtocol->Discover( myUrl ); - - // Get the references of myDiscoveryDocument. - IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - { - DiscoveryDocumentReference^ myNewReference = dynamic_cast(myEnumerator->Current); - - // Set the ClientProtocol of myNewReference. - DiscoveryClientProtocol^ myNewProtocol = myNewReference->ClientProtocol; - - // Verify for all the valid references. - myNewReference->ResolveAll(); - - // Get the document of myNewReference. - DiscoveryDocument^ myNewDiscoveryDocument = myNewReference->Document; - IEnumerator^ myNewEnumerator = myNewDiscoveryDocument->References->GetEnumerator(); - Console::WriteLine( "The valid discovery document is : \n" ); - while ( myNewEnumerator->MoveNext() ) - { - // Display the references of myNewDiscoveryDocument on the console. - Console::WriteLine( (dynamic_cast(myNewEnumerator->Current))->Ref ); - } - } - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ReadDocument/CPP/discoverydocumentreference_readdocument.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ReadDocument/CPP/discoverydocumentreference_readdocument.cpp deleted file mode 100644 index 8643d9666913e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ReadDocument/CPP/discoverydocumentreference_readdocument.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// System::Web::Services::Discovery.DiscoveryDocumentReference::ReadDocument(stream) -/* -This program demonstrates the 'ReadDocument(stream)' of 'DiscoveryDocumentReference' -class. Read the contents of the discovery document from the stream and returns -discovery document reference. The references of the 'DiscoveryDocumentReference' -are printed. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::IO; -using namespace System::Collections; -int main() -{ - try - { - // - String^ myUrl = "http://localhost/Sample_cs.vsdisco"; - DiscoveryClientProtocol^ myProtocol = gcnew DiscoveryClientProtocol; - DiscoveryDocumentReference^ myReference = gcnew DiscoveryDocumentReference( myUrl ); - Stream^ myFileStream = myProtocol->Download( myUrl ); - DiscoveryDocument^ myDiscoveryDocument = dynamic_cast(myReference->ReadDocument( myFileStream )); - // - - IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator(); - Console::WriteLine( "\nThe references to the discovery document are : \n" ); - while ( myEnumerator->MoveNext() ) - { - DiscoveryDocumentReference^ myNewReference = dynamic_cast(myEnumerator->Current); - - // Print the discovery document references on the console. - Console::WriteLine( myNewReference->Url ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_Properties/CPP/discoverydocumentreference_ctor_properties.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_Properties/CPP/discoverydocumentreference_ctor_properties.cpp deleted file mode 100644 index 25a62274838f6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_Properties/CPP/discoverydocumentreference_ctor_properties.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// System::Web::Services::Discovery.DiscoveryDocumentReference::DiscoveryDocumentReference(String*) -// System::Web::Services::Discovery.DiscoveryDocumentReference::Ref -// System::Web::Services::Discovery.DiscoveryDocumentReference::Url -// System::Web::Services::Discovery.DiscoveryDocumentReference::DefaultFileName -/* -This program demonstrates the 'DiscoveryDocumentReference(String*)' Constructor, 'Ref', -'Url', and 'DefaultFileName' properties of the 'DiscoveryDocumentReference' class. -It creates an instance of 'DiscoveryDocumentReference' and displays the 'Ref', 'Url' and -'DefaultFilename' properties. -*/ -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Discovery; - -int main() -{ - try - { - -// - DiscoveryDocumentReference^ myDiscoveryDocumentReference = - gcnew DiscoveryDocumentReference( - "http://localhost/Sample_cpp.disco" ); -// - - Console::WriteLine( "The reference to the discovery document is:" ); - -// - // Display the discovery document reference. - Console::WriteLine( myDiscoveryDocumentReference->Ref ); -// - Console::WriteLine(); - Console::WriteLine( - "The URL of the referenced discovery document is:" ); - -// - // Display the URL of the referenced discovery document. - Console::WriteLine( myDiscoveryDocumentReference->Url ); -// - Console::WriteLine(); - Console::WriteLine( "The name of the default disco file is:" ); - -// - // Display the name of the default file used for reference. - Console::WriteLine( - myDiscoveryDocumentReference->DefaultFilename ); -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_Properties/CPP/sample_cpp.disco b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_Properties/CPP/sample_cpp.disco deleted file mode 100644 index fabe8ce6a2245..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_Properties/CPP/sample_cpp.disco +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_WriteDocument/CPP/discoverydocumentreference_ctor_writedocument.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_WriteDocument/CPP/discoverydocumentreference_ctor_writedocument.cpp deleted file mode 100644 index 36a4b5400c36a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocumentReference_ctor_WriteDocument/CPP/discoverydocumentreference_ctor_writedocument.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// System::Web::Services::Discovery.DiscoveryDocumentReference -// System::Web::Services::Discovery.DiscoveryDocumentReference::DiscoveryDocumentReference() -// System::Web::Services::Discovery.DiscoveryDocumentReference::WriteDocument(Object*, Stream) -/* -This program demonstrates the 'DiscoveryDocumentReference' class, default constructor and -'WriteDocument(Object*, Stream)' method of the 'DiscoveryDocumentReference' class. -Discovery file is read by using 'DiscoveryDocument' instance. Write this discovery -document into a file stream and print its contents on the console. -*/ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Discovery; -using namespace System::IO; -using namespace System::Collections; -int main() -{ - try - { - DiscoveryDocument^ myDiscoveryDocument; - XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( "http://localhost/Sample_cs::vsdisco" ); - myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader ); - - // - // Create a new instance of DiscoveryDocumentReference. - DiscoveryDocumentReference^ myDiscoveryDocumentReference = gcnew DiscoveryDocumentReference; - - // - // - FileStream^ myFileStream = gcnew FileStream( "Temp::vsdisco",FileMode::OpenOrCreate,FileAccess::Write ); - myDiscoveryDocumentReference->WriteDocument( myDiscoveryDocument, myFileStream ); - myFileStream->Close(); - - // - FileStream^ myFileStream1 = gcnew FileStream( "Temp::vsdisco",FileMode::OpenOrCreate,FileAccess::Read ); - StreamReader^ myStreamReader = gcnew StreamReader( myFileStream1 ); - - // Initialize the file pointer. - myStreamReader->BaseStream->Seek( 0, SeekOrigin::Begin ); - Console::WriteLine( "The contents of the discovery document are: \n" ); - while ( myStreamReader->Peek() > -1 ) - { - - // Display the contents of the discovery document. - Console::WriteLine( myStreamReader->ReadLine() ); - } - myStreamReader->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_DiscoveryDocument/CPP/discoverydocument_discoverydocument.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_DiscoveryDocument/CPP/discoverydocument_discoverydocument.cpp deleted file mode 100644 index c9c3ac9fdb286..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_DiscoveryDocument/CPP/discoverydocument_discoverydocument.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// System::Web::Services::Discovery.DiscoveryDocument::DiscoveryDocument -// System::Web::Services::Discovery.DiscoveryDocument::Namespace -// System::Web::Services::Discovery.DiscoveryDocument::CanRead -// System::Web::Services::Discovery.DiscoveryDocument::Read(XmlReader) -// System::Web::Services::Discovery.DiscoveryDocument::References -/* The following example deomonstrates the 'DiscoveryDocument' constructor, -'Namespace' field, 'References' property and the 'CanRead' and 'Read(XmlReader)' -methods of the 'DiscoveryDocument' class. -The namespace field is displayed onto the console. A XmlTextReader Object* is -created with a sample discovery file and this is passed to the CanRead method -to check whether it is readable. Then we read this file to create a Discovery -document and display the references in the created document. -*/ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Collections; -int main() -{ - try - { - - // Create an Object* of the 'DiscoveryDocument'. - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - - // - // Display the 'Namespace' field. - Console::WriteLine( "The namespace is : {0}", DiscoveryDocument::Namespace ); - - // - // Create an XmlTextReader with the sample file. - XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( "http://localhost/example.vsdisco" ); - - // - // - // Check whether the given XmlTextReader is readable. - if ( DiscoveryDocument::CanRead( myXmlTextReader ) == true ) - - // Read the given XmlTextReader. - myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader ); - else - Console::WriteLine( "The supplied file is not readable" ); - - // - // - // - // Enumerate the 'References' in the DiscoveryDocument. - IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator(); - Console::WriteLine( "The 'References' in the discovery document are-" ); - while ( myEnumerator->MoveNext() ) - Console::Write( (dynamic_cast(myEnumerator->Current)->Url) ); - - // - Console::WriteLine(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised : {0}", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_Write1/CPP/discoverydocument_write1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_Write1/CPP/discoverydocument_write1.cpp deleted file mode 100644 index 4354c6bd9c143..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_Write1/CPP/discoverydocument_write1.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// System::Web::Services::Discovery.DiscoveryDocument::Write(Stream) - -/* The following example deomonstrates the 'Write(Stream)' method -of the 'DiscoveryDocument' class. -A XmlTextReader Object* is created with a sample discovery file and this is -passed to the Read method to create a DiscoveryDocument. The contents of this -document are displayed onto the console using the Write(Stream) method. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Collections; - -int main() -{ - try - { - // - // Create an object of the 'DiscoveryDocument'. - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - - // Create an XmlTextReader with the sample file. - XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( - "http://localhost/example_Write1_cs.disco" ); - - // Read the given XmlTextReader. - myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader ); - - // Write the DiscoveryDocument into the stream. - FileStream^ myFileStream = gcnew FileStream( - "log.txt",FileMode::OpenOrCreate,FileAccess::Write ); - myDiscoveryDocument->Write( myFileStream ); - - myFileStream->Flush(); - myFileStream->Close(); - - // Display the contents of the DiscoveryDocument onto the console. - FileStream^ myFileStream1 = gcnew FileStream( - "log.txt",FileMode::OpenOrCreate,FileAccess::Read ); - StreamReader^ myStreamReader = gcnew StreamReader( myFileStream1 ); - - // Set the file pointer to the begin. - myStreamReader->BaseStream->Seek( 0, SeekOrigin::Begin ); - Console::WriteLine( "The contents of the DiscoveryDocument are-" ); - while ( myStreamReader->Peek() > -1 ) - { - Console::WriteLine( myStreamReader->ReadLine() ); - } - myStreamReader->Close(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_Write2/CPP/discoverydocument_write2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_Write2/CPP/discoverydocument_write2.cpp deleted file mode 100644 index 7eb75ffdfb53c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryDocument_Write2/CPP/discoverydocument_write2.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// System::Web::Services::Discovery.DiscoveryDocument::Write(XmlTextWriter) - -/* The following example deomonstrates the 'Write(XmlTextWriter)' method -of the 'DiscoveryDocument' class. -A XmlTextReader Object* is created with a sample discovery file and this is -passed to the Read method to create a DiscoveryDocument. The contents of this -document are displayed onto the console using the Write(XmlTextWriter) method. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Collections; - -int main() -{ - try - { -// - // Create a DiscoveryDocument. - DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument; - - // Create an XmlTextReader with the sample file. - XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( - "http://localhost/example_Write2_cs.disco" ); - - // Read the given XmlTextReader. - myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader ); - - FileStream^ myFileStream = gcnew FileStream( - "log.txt",FileMode::OpenOrCreate,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - - XmlTextWriter^ myXmlTextWriter = gcnew XmlTextWriter( myStreamWriter ); - myDiscoveryDocument->Write( myXmlTextWriter ); - - myXmlTextWriter->Flush(); - myXmlTextWriter->Close(); - - // Display the contents of the DiscoveryDocument on the console. - FileStream^ myFileStream1 = gcnew FileStream( - "log.txt",FileMode::OpenOrCreate,FileAccess::Read ); - StreamReader^ myStreamReader = gcnew StreamReader( myFileStream1 ); - - // Set the file pointer to the beginning. - myStreamReader->BaseStream->Seek( 0, SeekOrigin::Begin ); - Console::WriteLine( "The contents of the DiscoveryDocument are: " ); - while ( myStreamReader->Peek() > -1 ) - { - Console::WriteLine( myStreamReader->ReadLine() ); - } - myStreamReader->Close(); -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryExceptionDictionary_Property_Method/CPP/discoveryexceptiondictionary_property_method.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryExceptionDictionary_Property_Method/CPP/discoveryexceptiondictionary_property_method.cpp deleted file mode 100644 index 0fd88a3bd0ecc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryExceptionDictionary_Property_Method/CPP/discoveryexceptiondictionary_property_method.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// System.Web.Services.Discovery.DiscoveryExceptionDictionary -// System.Web.Services.Discovery.DiscoveryExceptionDictionary.Contains -// System.Web.Services.Discovery.DiscoveryExceptionDictionary.Item -// System.Web.Services.Discovery.DiscoveryExceptionDictionary.Remove -// System.Web.Services.Discovery.DiscoveryExceptionDictionary.DiscoveryExceptionDictionary -// System.Web.Services.Discovery.DiscoveryExceptionDictionary.Add -// System.Web.Services.Discovery.DiscoveryExceptionDictionary.Keys -// System.Web.Services.Discovery.DiscoveryExceptionDictionary.Values - -/* -The following example demonstrates the usage of the -'DiscoveryExceptionDictionary' class, the constructor -'DiscoveryExceptionDictionary()', the properties 'Item', 'Keys', -'Values' and the methods 'Contains', 'Add' and 'Remove' of the class. -The input to the program is a discovery file 'MathService_cs.disco' -which holds reference related to 'MathService_cs.asmx' web service. -The program is executed first with the file 'MathService_cs.asmx' in -the location as specified in the discovery file. The file -'MathService_cs.asmx' is removed from the referred location in a way to -simulate a scenario wherein the file related to web service is missing, -and the program is excecuted second time to show the exception occuring. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Discovery; -using namespace System::Xml; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Net; - -int main() -{ - String^ myDiscoFile = "http://localhost/MathService_cs.disco"; - String^ myUrlKey = "http://localhost/MathService_cs.asmx?wsdl"; - DiscoveryClientProtocol^ myDiscoveryClientProtocol1 = gcnew DiscoveryClientProtocol; - DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol1->Discover( myDiscoFile ); - IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - { - ContractReference^ myContractReference = dynamic_cast(myEnumerator->Current); - DiscoveryClientProtocol^ myDiscoveryClientProtocol2 = myContractReference->ClientProtocol; - myDiscoveryClientProtocol2->ResolveAll(); - - // - DiscoveryExceptionDictionary^ myExceptionDictionary = myDiscoveryClientProtocol2->Errors; - if ( myExceptionDictionary->Contains( myUrlKey ) == true ) - { - Console::WriteLine( "'myExceptionDictionary' contains a discovery exception for the key '{0}'", myUrlKey ); - } - else - { - Console::WriteLine( "'myExceptionDictionary' does not contain a discovery exception for the key '{0}'", myUrlKey ); - } - // - if ( myExceptionDictionary->Contains( myUrlKey ) == true ) - { - Console::WriteLine( "System generated exceptions." ); - - // - Exception^ myException = myExceptionDictionary[ myUrlKey ]; - Console::WriteLine( " Source : {0}", myException->Source ); - Console::WriteLine( " Exception : {0}", myException->Message ); - // - - Console::WriteLine(); - - // - // Remove the discovery exception.for the key 'myUrlKey'. - myExceptionDictionary->Remove( myUrlKey ); - // - - // - // - DiscoveryExceptionDictionary^ myNewExceptionDictionary = gcnew DiscoveryExceptionDictionary; - - // Add an exception with the custom error message. - Exception^ myNewException = gcnew Exception( "The requested service is not available." ); - myNewExceptionDictionary->Add( myUrlKey, myNewException ); - myExceptionDictionary = myNewExceptionDictionary; - // - // - - Console::WriteLine( "Added exceptions." ); - - // - array^myArray = gcnew array(myExceptionDictionary->Count); - myExceptionDictionary->Keys->CopyTo( (Array^)myArray, 0 ); - Console::WriteLine( " Keys are :" ); - - for each(Object^ myObj in myArray) - { - Console::WriteLine(" " + myObj->ToString()); - } - // - - Console::WriteLine(); - - // - array^myCollectionArray = gcnew array(myExceptionDictionary->Count); - myExceptionDictionary->Values->CopyTo( (Array^)myCollectionArray, 0 ); - Console::WriteLine( " Values are :" ); - for each(Object^ myObj in myCollectionArray) - { - Console::WriteLine(" " + myObj->ToString()); - } - // - } - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReference/CPP/discoveryreference.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReference/CPP/discoveryreference.cpp deleted file mode 100644 index f9a87f28eac1a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReference/CPP/discoveryreference.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// System::Web::Services::Discovery.DiscoveryReference::ClientProtocol -// System::Web::Services::Discovery.DiscoveryReference::DefaultFilename -// System::Web::Services::Discovery.DiscoveryReference::WriteDocument(Object*, Stream) -// System::Web::Services::Discovery.DiscoveryReference::ReadDocument(Stream) -// System::Web::Services::Discovery.DiscoveryReference::Url -// System::Web::Services::Discovery.DiscoveryReference::Resolve() -// This program demonstrates 'ClientProtocol', 'WriteDocumant', 'Url' properties -// and 'DefaultFilename', 'readDocument', 'Resolve' methods of 'DiscoveryReference' -// class. DiscoveryReference class is derived in 'MyDiscoveryReferenceClass'. A -// variable of type 'MyDiscoveryReferenceClass' class is taken to demonstrate these -// members. -// Note : The dataservice.disco file should be copied to Inetpub\wwwroot -// - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Net; - -// Class derived from DiscoveryReference class and overriding its members. -ref class MyDiscoveryReferenceClass: public DiscoveryReference -{ -private: - String^ myDocumentUrl; - -public: - property String^ DefaultFilename - { - virtual String^ get() override - { - return "dataservice.disco"; - } - } - - virtual Object^ ReadDocument( Stream^ stream ) override - { - return stream; - } - - void Resolve() - { - try - { - DiscoveryDocument^ myDiscoveryRefDocument; - myDiscoveryRefDocument = __super::ClientProtocol->Discover( Url ); - } - catch ( Exception^ e ) - { - throw e; - } - } - -protected: - virtual void Resolve( String^ contentType, Stream^ stream ) override {} - -public: - - property String^ Url - { - virtual String^ get() override - { - return myDocumentUrl; - } - - virtual void set( String^ value ) override - { - myDocumentUrl = value; - } - } - virtual void WriteDocument( Object^ document, System::IO::Stream^ stream ) override - { - DiscoveryDocument^ myDiscoveryDocument = dynamic_cast(document); - myDiscoveryDocument->Write( stream ); - } -}; - -int main() -{ - DiscoveryDocument^ myDiscoveryDocument; - StreamReader^ myStreamReader = gcnew StreamReader( "c:\\Inetpub\\wwwroot\\dataservice.disco" ); - FileStream^ myStream = gcnew FileStream( "C:\\MyDiscovery.disco",FileMode::OpenOrCreate ); - Console::WriteLine( "Demonstrating Discovery Reference class." ); - - // Read discovery file. - myDiscoveryDocument = DiscoveryDocument::Read( myStreamReader ); - - // Variable of type DiscoveryReference class defined. - MyDiscoveryReferenceClass^ myDiscoveryReference; - myDiscoveryReference = gcnew MyDiscoveryReferenceClass; - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // Set client protocol. - myDiscoveryReference->ClientProtocol = myDiscoveryClientProtocol; - - // Read the default file name. - Console::WriteLine( "Default file name is: {0}", myDiscoveryReference->DefaultFilename ); - - // Write the document. - myDiscoveryReference->WriteDocument( myDiscoveryDocument, myStream ); - - // Read the document. - myDiscoveryReference->ReadDocument( myStream ); - - // Set the URL. - myDiscoveryReference->Url = "http://localhost/dataservice.disco"; - Console::WriteLine( "Url is: {0}", myDiscoveryReference->Url ); - - // Resolve the URL. - myDiscoveryReference->Resolve(); - myStreamReader->Close(); - myStream->Close(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReference1/CPP/discoveryreference.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReference1/CPP/discoveryreference.cpp deleted file mode 100644 index 2476f726e9659..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReference1/CPP/discoveryreference.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// System.Web.Services.Discovery.DiscoveryReference - -/* -This program demonstrates 'DiscoveryReference' class. -DiscoveryReference class is derived in 'MyDiscoveryReferenceClass'. A -variable of type 'MyDiscoveryReferenceClass' class is taken to demonstrate -members of 'MyDiscoveryReferenceClass'. -Note : The dataservice.disco file should be copied to c:\Inetpub\wwwroot -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Discovery; -using namespace System::Net; - -// Class derived from DiscoveryReference class and overriding it members. -ref class MyDiscoveryReferenceClass: public DiscoveryReference -{ -private: - String^ myDocumentUrl; - -public: - property String^ DefaultFilename - { - virtual String^ get() override - { - return "dataservice.disco"; - } - } - - virtual Object^ ReadDocument( Stream^ stream ) override - { - return stream; - } - - void Resolve() - { - try - { - DiscoveryDocument^ myDiscoveryRefDocument; - myDiscoveryRefDocument = DiscoveryReference::ClientProtocol->Discover( Url ); - } - catch ( Exception^ e ) - { - throw e; - } - } - -protected: - virtual void Resolve( String^ /*contentType*/, Stream^ /*stream*/ ) override {} - -public: - property String^ Url - { - virtual String^ get() override - { - return myDocumentUrl; - } - - virtual void set( String^ value ) override - { - myDocumentUrl = value; - } - } - - virtual void WriteDocument( Object^ document, System::IO::Stream^ stream ) override - { - DiscoveryDocument^ myDiscoveryDocument = dynamic_cast(document); - myDiscoveryDocument->Write( stream ); - } -}; - -int main() -{ - try - { - DiscoveryDocument^ myDiscoveryDocument; - StreamReader^ myStreamReader = gcnew StreamReader( "c:\\Inetpub\\wwwroot\\dataservice.disco" ); - FileStream^ myStream = gcnew FileStream( "c:\\MyDiscovery.disco",FileMode::OpenOrCreate ); - Console::WriteLine( "Demonstrating DiscoveryReference class." ); - - // Read discovery file. - myDiscoveryDocument = DiscoveryDocument::Read( myStreamReader ); - - // Create a new instance of the DiscoveryReference class. - MyDiscoveryReferenceClass^ myDiscoveryReference; - myDiscoveryReference = gcnew MyDiscoveryReferenceClass; - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // Set the client protocol. - myDiscoveryReference->ClientProtocol = myDiscoveryClientProtocol; - - // Read the default file name. - Console::WriteLine( "Default file name is: {0}", myDiscoveryReference->DefaultFilename ); - - // Write the document. - myDiscoveryReference->WriteDocument( myDiscoveryDocument, myStream ); - - // Read the document. - myDiscoveryReference->ReadDocument( myStream ); - - // Set the URL. - myDiscoveryReference->Url = "http://localhost/dataservice.disco"; - Console::WriteLine( "Url is: {0}", myDiscoveryReference->Url ); - - // Resolve the URL. - myDiscoveryReference->Resolve(); - myStreamReader->Close(); - myStream->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught! - {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReferenceCollection/CPP/discoveryreferencecollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReferenceCollection/CPP/discoveryreferencecollection.cpp deleted file mode 100644 index d41b200102372..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DiscoveryReferenceCollection/CPP/discoveryreferencecollection.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Web::Services::Discovery.DiscoveryReferenceCollection::DiscoveryReferenceCollection -// System::Web::Services::Discovery.DiscoveryReferenceCollection->Add(DiscoveryReference) -// System::Web::Services::Discovery.DiscoveryReferenceCollection::Contains(DiscoveryReference) -// System::Web::Services::Discovery.DiscoveryReferenceCollection::Item(int) -// System::Web::Services::Discovery.DiscoveryReferenceCollection::Remove(DiscoveryReference) -// System::Web::Services::Discovery.DiscoveryReferenceCollection - -/* The following example demonstrates the usage of 'DiscoveryReferenceCollection' class, 'Add', 'Contains', -* 'Item'and 'Remove' methods and its constructor. A variable of 'DiscoveryReferenceCollection' -* class is taken. Two 'DiscoveryReference' type member is added to the collection. Using this -* various methods of 'DiscoveryReferenceCollection' class are demonstrated. -*/ - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Discovery; - -// -int main() -{ - DiscoveryDocumentReference^ myDiscoveryDocReference1 = gcnew DiscoveryDocumentReference; - DiscoveryDocumentReference^ myDiscoveryDocReference2 = gcnew DiscoveryDocumentReference; - DiscoveryReference^ myDiscoveryReference; - Console::WriteLine( "Demonstrating DiscoveryReferenceCollection class." ); - - // Create new DiscoveryReferenceCollection. - DiscoveryReferenceCollection^ myDiscoveryReferenceCollection = gcnew DiscoveryReferenceCollection; - - // Access the Count method. - Console::WriteLine( "The number of elements in the collection is: {0}", myDiscoveryReferenceCollection->Count ); - - // Add elements to the collection. - myDiscoveryReferenceCollection->Add( myDiscoveryDocReference1 ); - myDiscoveryReferenceCollection->Add( myDiscoveryDocReference2 ); - Console::WriteLine( "The number of elements in the collection after adding two elements to the collection: {0}", myDiscoveryReferenceCollection->Count ); - - // Call the Contains method. - if ( myDiscoveryReferenceCollection->Contains( myDiscoveryDocReference1 ) != true ) - { - throw gcnew Exception( "Element not found in collection." ); - } - - // Access the indexed member. - myDiscoveryReference = dynamic_cast(myDiscoveryReferenceCollection[ 0 ]); - if ( myDiscoveryReference == nullptr ) - { - throw gcnew Exception( "Element not found in collection." ); - } - - // Remove one element from collection. - myDiscoveryReferenceCollection->Remove( myDiscoveryDocReference1 ); - Console::WriteLine( "The number of elements in the collection after removing one element is: {0}", myDiscoveryReferenceCollection->Count ); -} -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Discovery_SoapBinding1/CPP/discovery_soapbinding.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Discovery_SoapBinding1/CPP/discovery_soapbinding.cpp deleted file mode 100644 index 36bc202ae4d62..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Discovery_SoapBinding1/CPP/discovery_soapbinding.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// System::Web::Services::Discovery.SoapBinding::SoapBinding -// System::Web::Services::Discovery.SoapBinding->Address -// System::Web::Services::Discovery.SoapBinding::Binding -// System::Web::Services::Discovery.SoapBinding::Namespace -// System::Web::Services::Discovery.SoapBinding -/* The following example demonstrates 'Discovery::SoapBinding' class, its -* constructor, 'Address', 'Binding' and 'Namespace' members. A variable -* of type 'SoapBinding' is created. The properties are set. -* Finally the created 'SoapBinding' is added to 'DiscoveryClientProtocol'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Xml; -using namespace System::Web::Services::Discovery; -int main() -{ - try - { - - // - // 'dataservice.disco' is a sample discovery document. - String^ myStringUrl = "http://localhost/dataservice.disco"; - - // Call the Discover method to populate the Documents property. - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol->Discover( myStringUrl ); - Console::WriteLine( "Demonstrating the Discovery::SoapBinding class." ); - - // Create a SOAP binding. - SoapBinding^ mySoapBinding = gcnew SoapBinding; - - // Assign an address to the created SOAP binding. - mySoapBinding->Address = "http://schemas.xmlsoap.org/disco/scl/"; - - // Bind the created SOAP binding with a new XmlQualifiedName. - mySoapBinding->Binding = gcnew XmlQualifiedName( "String*","http://www.w3.org/2001/XMLSchema" ); - - // Add the created SOAP binding to the DiscoveryClientProtocol. - myDiscoveryClientProtocol->AdditionalInformation->Add( mySoapBinding ); - - // Display the namespace associated with SOAP binding. - Console::WriteLine( "Namespace associated with the SOAP binding is: {0}", SoapBinding::Namespace ); - - // Write all the information of the DiscoveryClientProtocol. - myDiscoveryClientProtocol->WriteAll( ".", "results.discomap" ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp deleted file mode 100644 index cfe2812f5b9df..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -This program demonstrates the 'Constructor' of 'DnsPermission' class. -It creates an instance of 'DnsPermission' class and checks for permission.Then it -creates a 'SecurityElement' Object* and prints it's attributes which hold the XML -encoding of 'DnsPermission' instance . -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ - // -public: - void useDns() - { - // Create a DnsPermission instance. - DnsPermission^ permission = gcnew DnsPermission( PermissionState::Unrestricted ); - - // Check for permission. - permission->Demand(); - // Create a SecurityElement Object* to hold XML encoding of the DnsPermission instance. - SecurityElement^ securityElementObj = permission->ToXml(); - Console::WriteLine( "Tag, Attributes and Values of 'DnsPermission' instance :" ); - Console::WriteLine( "\n\tTag : {0}", securityElementObj->Tag ); - // Print the attributes and values. - PrintKeysAndValues( securityElementObj->Attributes ); - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\n\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp deleted file mode 100644 index 0e9c78efb3901..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -This program demonstrates the 'Copy' method of 'DnsPermission' class. -It creates an identical copy of 'DnsPermission' instance. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class DnsPermissionExample -{ - // -public: - void UseDns() - { - // Create a DnsPermission instance. - DnsPermission^ myPermission = gcnew DnsPermission( PermissionState::Unrestricted ); - // Check for permission. - myPermission->Demand(); - // Create an identical copy of the above 'DnsPermission' Object*. - DnsPermission^ myPermissionCopy = dynamic_cast(myPermission->Copy()); - Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" ); - // Print the attributes and values. - PrintKeysAndValues( myPermission->ToXml()->Attributes ); - Console::WriteLine( "Attribute and values of copied instance :" ); - PrintKeysAndValues( myPermissionCopy->ToXml()->Attributes ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample * dnsPermissionExampleObj = new DnsPermissionExample; - dnsPermissionExampleObj->UseDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp deleted file mode 100644 index 3674b00df6c9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -This program demonstrates the 'FromXml' method of 'DnsPermission' class. -It creates an instance of 'DnsPermission' class and prints the XML encoding of that instance.Then it -creates a 'SecurityElement' Object* and adds the attributes corresponding to the above 'DnsPermission' -Object*. A new 'DnsPermission' instance is reconstructed from the 'SecurityElement' instance by calling -'FromXml' method and it's XML encoding is printed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ - // -public: - void ConstructDnsPermission() - { - try - { - // Create a DnsPermission instance. - DnsPermission^ permission = gcnew DnsPermission( PermissionState::None ); - // Create a SecurityElement instance by calling the ToXml method on the - // DnsPermission instance. - // Print its attributes, which hold the XML encoding of the DnsPermission - // instance. - Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" ); - PrintKeysAndValues( permission->ToXml()->Attributes ); - - // Create a SecurityElement instance. - SecurityElement^ securityElementObj = gcnew SecurityElement( "IPermission" ); - // Add attributes and values of the SecurityElement instance corresponding to - // the permission instance. - securityElementObj->AddAttribute( "version", "1" ); - securityElementObj->AddAttribute( "Unrestricted", "true" ); - securityElementObj->AddAttribute( "class", "System.Net.DnsPermission" ); - - // Reconstruct a DnsPermission instance from an XML encoding. - DnsPermission^ permission1 = gcnew DnsPermission( PermissionState::None ); - permission1->FromXml( securityElementObj ); - - // Print the attributes and values of the constructed DnsPermission Object*. - Console::WriteLine( "After reconstruction Attributes and Values of new DnsPermission instance :" ); - PrintKeysAndValues( permission1->ToXml()->Attributes ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "NullReferenceException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->ConstructDnsPermission(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp deleted file mode 100644 index 929717f0e2e0a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -This program demonstrates the 'IsSubsetOf' method of 'DnsPermission' class. -'IsSubsetOf' method returns true, if the current DnsPermission instance allows no -more access to DNS servers than does the specified 'DnsPermission' instance. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ -private: - DnsPermission^ permission; - - // -public: - void useDns() - { - // Create a DnsPermission instance. - permission = gcnew DnsPermission( PermissionState::Unrestricted ); - DnsPermission^ dnsPermission1 = gcnew DnsPermission( PermissionState::None ); - // Check for permission. - permission->Demand(); - dnsPermission1->Demand(); - // Print the attributes and values. - Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" ); - PrintKeysAndValues( permission->ToXml()->Attributes ); - Console::WriteLine( "Attributes and Values of specified 'DnsPermission' instance :" ); - PrintKeysAndValues( dnsPermission1->ToXml()->Attributes ); - Subset( dnsPermission1 ); - } - -private: - void Subset( DnsPermission^ Permission1 ) - { - if ( permission->IsSubsetOf( Permission1 ) ) - { - Console::WriteLine( "Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance." ); - } - else - { - Console::WriteLine( "Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance." ); - } - } - - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp deleted file mode 100644 index 0c760523b0295..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -This program demonstrates the 'IsUnrestricted' method of 'DnsPermission' class. -It checks the overall permission state of the Object* and it will return true if the -'DnsPermission' instance was created with unrestricted permission state otherwise false. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ - // -public: - void useDns() - { - // Create a DnsPermission instance. - DnsPermission^ permission = gcnew DnsPermission( PermissionState::Unrestricted ); - // Check for permission. - permission->Demand(); - Console::WriteLine( "Attributes and Values of DnsPermission instance :" ); - // Print the attributes and values. - PrintKeysAndValues( permission->ToXml()->Attributes ); - // Check the permission state. - if ( permission->IsUnrestricted() ) - { - Console::WriteLine( "Overall permissions : Unrestricted" ); - } - else - { - Console::WriteLine( "Overall permissions : Restricted" ); - } - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp deleted file mode 100644 index d3f14c02e8925..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -This program demonstrates 'BeginResolve' and 'EndResolve' methods of Dns class. -It obtains the 'IPHostEntry' Object* by calling 'BeginResolve' and 'EndResolve' method -of 'Dns' class by passing a URL, a callback function and an instance of 'RequestState' -class.Then prints host name, IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Threading; - -// -// -public ref class DnsBeginGetHostByName -{ -public: - static System::Threading::ManualResetEvent^ allDone = nullptr; - ref class RequestState - { - public: - IPHostEntry^ host; - RequestState() - { - host = nullptr; - } - }; - - static void RespCallback( IAsyncResult^ ar ) - { - try - { - // Convert the IAsyncResult* Object* to a RequestState Object*. - RequestState^ tempRequestState = dynamic_cast(ar->AsyncState); - - // End the asynchronous request. - tempRequestState->host = Dns::EndResolve( ar ); - allDone->Set(); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - } -}; - -int main() -{ - DnsBeginGetHostByName::allDone = gcnew ManualResetEvent( false ); - - // Create an instance of the RequestState class. - DnsBeginGetHostByName::RequestState^ myRequestState = - gcnew DnsBeginGetHostByName::RequestState; - - // Begin an asynchronous request for information like host name, IP addresses, or - // aliases for specified the specified URI. - IAsyncResult^ asyncResult = Dns::BeginResolve( "www.contoso.com", - gcnew AsyncCallback( DnsBeginGetHostByName::RespCallback ), myRequestState ); - - // Wait until asynchronous call completes. - DnsBeginGetHostByName::allDone->WaitOne(); - Console::WriteLine( "Host name : {0}", myRequestState->host->HostName ); - Console::WriteLine( "\nIP address list : " ); - for ( int index = 0; index < myRequestState->host->AddressList->Length; index++ ) - Console::WriteLine( myRequestState->host->AddressList[ index ] ); - Console::WriteLine( "\nAliases : " ); - for ( int index = 0; index < myRequestState->host->Aliases->Length; index++ ) - Console::WriteLine( myRequestState->host->Aliases[ index ] ); -} -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp deleted file mode 100644 index 500d528483db1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -This program demonstrates 'GetHostByAddress(IPAddress)' method of 'Dns' class. -It takes an IP address String* from commandline or uses default value and creates -an instance of IPAddress for the specified IP address String*. Obtains the IPHostEntry -Object* by calling 'GetHostByAddress' method of 'Dns' class and prints host name, -IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -class DnsHostByAddress -{ -public: - void DisplayHostAddress( String^ IpAddressString ) - { - // Call 'GetHostByAddress(IPAddress)' method giving an 'IPAddress' Object* as argument. - // Obtain an 'IPHostEntry' instance, containing address information of the specified host. - // - try - { - IPAddress^ hostIPAddress = IPAddress::Parse( IpAddressString ); - IPHostEntry^ hostInfo = Dns::GetHostByAddress( hostIPAddress ); - - // Get the IP address list that resolves to the host names contained in - // the Alias property. - array^address = hostInfo->AddressList; - - // Get the alias names of the addresses in the IP address list. - array^alias = hostInfo->Aliases; - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "\nAliases :" ); - for ( int index = 0; index < alias->Length; index++ ) - Console::WriteLine( alias[ index ] ); - Console::WriteLine( "\nIP address list : " ); - for ( int index = 0; index < address->Length; index++ ) - Console::WriteLine( address[ index ] ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - // - } -}; - -int main() -{ - String^ IpAddressString = ""; - DnsHostByAddress * myDnsHostByAddress = new DnsHostByAddress; - Console::Write( "Type an IP address (press Enter for default, default is '207.46.131.199'): " ); - IpAddressString = Console::ReadLine(); - if ( IpAddressString->Length > 0 ) - myDnsHostByAddress->DisplayHostAddress( IpAddressString ); - else - myDnsHostByAddress->DisplayHostAddress( "207.46.131.199" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp deleted file mode 100644 index a65db62149f60..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -This program demonstrates 'GetHostByName' method of 'Dns' class. -It takes a URL String* from commandline or uses default value, and obtains -the 'IPHostEntry' Object* by calling 'GetHostByName' method of 'Dns' class.Then -prints host name, IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class DnsHostByName -{ -public: - void DisplayHostName( String^ hostName ) - { - // Call the GetHostByName method passing a DNS style host name(for example, - // S"www.contoso.com") as an argument. - // Obtain the IPHostEntry instance, that contains information of the specified host. - // - try - { - IPHostEntry^ hostInfo = Dns::GetHostByName( hostName ); - - // Get the IP address list that resolves to the host names contained in the - // Alias property. - array^address = hostInfo->AddressList; - - // Get the alias names of the addresses in the IP address list. - array^alias = hostInfo->Aliases; - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "\nAliases : " ); - for ( int index = 0; index < alias->Length; index++ ) - Console::WriteLine( alias[ index ] ); - Console::WriteLine( "\nIP address list : " ); - for ( int index = 0; index < address->Length; index++ ) - Console::WriteLine( address[ index ] ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - // - } -}; - -int main() -{ - String^ hostName = ""; - DnsHostByName^ myDnsHostByName = gcnew DnsHostByName; - Console::Write( "Type a URL (press Enter for default, default is 'www.microsoft.net') : " ); - hostName = Console::ReadLine(); - if ( hostName->Length > 0 ) - myDnsHostByName->DisplayHostName( hostName ); - else - myDnsHostByName->DisplayHostName( "www.microsoft.net" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp deleted file mode 100644 index 975e9204362f4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -This program demonstrates the 'GetHostName' method of 'Dns' class. -It creates a 'DnsHostName' instance and calls 'GetHostName' method to get the local host -computer name. Then prints the computer name on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class DnsHostName -{ - // -public: - void DisplayLocalHostName() - { - try - { - // Get the local computer host name. - String^ hostName = Dns::GetHostName(); - Console::WriteLine( "Computer name : {0}", hostName ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - } - // -}; - -int main() -{ - DnsHostName^ dnsHostNameObj = gcnew DnsHostName; - dnsHostNameObj->DisplayLocalHostName(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp deleted file mode 100644 index f280df4899907..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -This program demonstrates 'Resolve' method of 'Dns' class. -It takes a URL or IP address String* from commandline or uses default value and obtains the 'IPHostEntry' -Object* by calling 'Resolve' method of 'Dns' class. Then prints host name, IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -class DnsResolve -{ -public: - void DisplayHostAddress( String^ hostString ) - { - // Call the Resolve method passing a DNS style host name or an IP address in dotted-quad notation - // (for example, S"www.contoso.com" or S"207.46.131.199") to obtain an IPHostEntry instance that contains - // address information for the specified host. - // - try - { - IPHostEntry^ hostInfo = Dns::Resolve( hostString ); - - // Get the IP address list that resolves to the host names contained in the - // Alias property. - array^address = hostInfo->AddressList; - - // Get the alias names of the addresses in the IP address list. - array^alias = hostInfo->Aliases; - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "\nAliases : " ); - for ( int index = 0; index < alias->Length; index++ ) - { - Console::WriteLine( alias[ index ] ); - - } - Console::WriteLine( "\nIP Address list :" ); - for ( int index = 0; index < address->Length; index++ ) - { - Console::WriteLine( address[ index ] ); - - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "NullReferenceException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - // - } -}; - -int main() -{ - String^ hostString = ""; - DnsResolve * myDnsResolve = new DnsResolve; - Console::Write( "Type a URL or IP address (press Enter for default, default is '207.46.131.199') : " ); - hostString = Console::ReadLine(); - if ( hostString->Length > 0 ) - myDnsResolve->DisplayHostAddress( hostString ); - else - myDnsResolve->DisplayHostAddress( "207.46.131.199" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DocumentableItemsample/CPP/MathService_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/DocumentableItemsample/CPP/MathService_cpp.wsdl deleted file mode 100644 index 9aa220c7ed2ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DocumentableItemsample/CPP/MathService_cpp.wsdl +++ /dev/null @@ -1,352 +0,0 @@ - - - - - All types have been defined here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Port Type "MathServiceHttpGet" is defined here - - - - - - - - - - - - - - - - - - - - - Port Type "MathServiceHttpPost" is defined here - - - - - - - - - - - - - - - - - - - - - Port Type "MathServiceSoap" is defined here - - - - - - - - - - - - - - - - - - - - - Binding "MathServiceSoap" is defined here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binding "MathServiceHttpGet" is defined here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binding "MathServiceHttpPost" is defined here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/DocumentableItemsample/CPP/documentableitemsample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/DocumentableItemsample/CPP/documentableitemsample.cpp deleted file mode 100644 index 16ae3564724d1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/DocumentableItemsample/CPP/documentableitemsample.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -// System::Web::Services::Description.DocumentableItem::Documentation; -/* -The following program demonstrates the property 'Documentation' of abstract class 'DocumentableItem' -The program reads a wsdl document S"MathService::wsdl" and instantiates a ServiceDescription instance -from the WSDL document. -This program demonstrates a generic utility function which can accept any of Types, PortType and Binding -classes as parameters. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; -using namespace System::Collections; - -// Prints documentation associated with a wsdl element. -void PrintDocumentation( DocumentableItem^ myItem ) -{ - Console::WriteLine( "\t {0}", myItem->Documentation ); -} - -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_cpp.wsdl" ); - Console::WriteLine( "Documentation Element for type is " ); - PrintDocumentation( myServiceDescription->Types ); - IEnumerator^ myEnum = myServiceDescription->PortTypes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - PortType^ myPortType = safe_cast(myEnum->Current); - Console::WriteLine( "Documentation Element for Port Type {0} is ", myPortType->Name ); - PrintDocumentation( myPortType ); - } - - myEnum = myServiceDescription->Bindings->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Binding^ myBinding = safe_cast(myEnum->Current); - Console::WriteLine( "Documentation Element for Port Type {0} is ", myBinding->Name ); - PrintDocumentation( myBinding ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices Registration/CPP/deployservicedcomponent.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices Registration/CPP/deployservicedcomponent.cpp deleted file mode 100644 index dce62908316f9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices Registration/CPP/deployservicedcomponent.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#using - -using namespace System; -using namespace System::EnterpriseServices; - -[STAThread] -int main() -{ - // - try - { - // - String^ applicationName = "Queued Component"; - String^ typeLibraryName = nullptr; - RegistrationHelper^ helper = gcnew RegistrationHelper; - // Call the InstallAssembly method passing it the name of the assembly to - // install as a COM+ application, the COM+ application name, and - // the name of the type library file. - // Setting the application name and the type library to NULL (nothing in Visual Basic .NET - // allows you to use the COM+ application name that is given in the assembly and - // the default type library name. The application name in the assembly metadata - // takes precedence over the application name you provide to InstallAssembly. - helper->InstallAssembly( "C:..\\..\\QueuedComponent.dll", applicationName, typeLibraryName, InstallationFlags::CreateTargetApplication ); - Console::WriteLine( "Registration succeeded: Type library {0} created.", typeLibraryName ); - Console::Read(); - // - - // - // Create a RegistrationConfig object and set its attributes - // Create a RegistrationHelper object, and call the InstallAssemblyFromConfig - // method by passing the RegistrationConfiguration object to it as a - // reference object - RegistrationConfig^ registrationConfiguration = gcnew RegistrationConfig; - registrationConfiguration->AssemblyFile = "C:..\\..\\QueuedComponent.dll"; - registrationConfiguration->Application = "MyApp"; - registrationConfiguration->InstallationFlags = InstallationFlags::CreateTargetApplication; - RegistrationHelper^ helperFromConfig = gcnew RegistrationHelper; - helperFromConfig->InstallAssemblyFromConfig( registrationConfiguration ); - // - } - // - catch ( RegistrationException^ e ) - { - Console::WriteLine( e->Message ); - // - - // - // Check whether the ErrorInfo property of the RegistrationException object is null. - // If there is no extended error information about - // methods related to multiple COM+ objects ErrorInfo will be null. - if ( e->ErrorInfo != nullptr ) - { - // Gets an array of RegistrationErrorInfo objects describing registration errors - array^ registrationErrorInfos = e->ErrorInfo; - - // Iterate through the array of RegistrationErrorInfo objects and disply the - // ErrorString for each object. - System::Collections::IEnumerator^ myEnum = registrationErrorInfos->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - RegistrationErrorInfo^ registrationErrorInfo = (RegistrationErrorInfo^)( myEnum->Current ); - Console::WriteLine( registrationErrorInfo->ErrorString ); - } - } - // - Console::Read(); - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesContextUtil/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesContextUtil/CPP/class1.cpp deleted file mode 100644 index 45c9a032b730d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesContextUtil/CPP/class1.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::Reflection; - -// -[Synchronization(SynchronizationOption::Required)] -public ref class ContextUtil_ActivityId: public ServicedComponent -{ -public: - void Example() - { - // Display the ActivityID associated with the current COM+ context. - Console::WriteLine( "Activity ID: {0}", ContextUtil::ActivityId ); - } -}; -// - -// -[Synchronization(SynchronizationOption::Required)] -public ref class ContextUtil_ApplicationInstanceId: public ServicedComponent -{ -public: - void Example() - { - // Display the ApplicationInstanceId associated with the current COM+ - // context. - Console::WriteLine( "Application Instance ID: {0}", - ContextUtil::ApplicationInstanceId ); - } -}; -// - -// -[Transaction(TransactionOption::Required)] -public ref class ContextUtil_DisableCommit: public ServicedComponent -{ -public: - void Example() - { - // Set both the consistent bit and the done bit to false for the - // current COM+ context. - ContextUtil::DisableCommit(); - } -}; -// - -// -[Transaction(TransactionOption::Required)] -public ref class ContextUtil_EnableCommit: public ServicedComponent -{ -public: - void Example() - { - // Set the consistent bit to true and the done bit to false for the - // current COM+ context. - ContextUtil::EnableCommit(); - } -}; -// - -// -[Transaction(TransactionOption::Required)] -public ref class ContextUtil_IsInTransaction: public ServicedComponent -{ -public: - void Example() - { - // Display whether the current COM+ context is enlisted in a - // transaction. - Console::WriteLine( "Current context enlisted in transaction: {0}", - ContextUtil::IsInTransaction ); - } -}; -// - -// -[SecurityRole("Role1")] -public ref class ContextUtil_IsSecurityEnabled: public ServicedComponent -{ -public: - void Example() - { - // Display whether role-based security is active for the current COM+ - // context. - Console::WriteLine( "Role-based security active in current context: {0}", - ContextUtil::IsSecurityEnabled ); - } -}; -// - -// -[Transaction(TransactionOption::Required)] -public ref class ContextUtil_TransactionId: public ServicedComponent -{ -public: - void Example() - { - // Display the ID of the transaction in which the current COM+ context - // is enlisted. - Console::WriteLine( "Transaction ID: {0}", ContextUtil::TransactionId ); - } -}; -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesInterfaceQueuingAttribute/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesInterfaceQueuingAttribute/CPP/class1.cpp deleted file mode 100644 index 2924b763b8b35..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesInterfaceQueuingAttribute/CPP/class1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::Reflection; - -// References: -// System.EnterpriseServices -// -[InterfaceQueuing] -interface class IInterfaceQueuingAttribute_Ctor{}; -// - -// -[InterfaceQueuing(true)] -interface class IInterfaceQueuingAttribute_Ctor_Bool{}; -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesObjectPoolingAttribute/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesObjectPoolingAttribute/cpp/class1.cpp deleted file mode 100644 index 3fbda4b806ec1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesObjectPoolingAttribute/cpp/class1.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -using namespace System; -using namespace System::EnterpriseServices; - -// References: -// System.EnterpriseServices - -// -[ObjectPooling(true)] -public ref class ObjectPoolingAttributeCtorBool : public ServicedComponent -{ -}; -// - -// -[ObjectPooling(true, 1, 10)] -public ref class ObjectPoolingAttributeCtorBoolIntInt : - public ServicedComponent -{ -}; -// - -// -[ObjectPooling(1, 10)] -public ref class ObjectPoolingAttributeCtorIntInt : public ServicedComponent -{ -}; -// - -// -[ObjectPooling(false)] -public ref class ObjectPoolingAttributeEnabled : public ServicedComponent -{ -public: - void EnabledExample() - { - // Get the ObjectPoolingAttribute applied to the class. - ObjectPoolingAttribute^ attribute = - (ObjectPoolingAttribute^)Attribute::GetCustomAttribute( - this->GetType(), - ObjectPoolingAttribute::typeid, - false); - - // Display the current value of the attribute's Enabled property. - Console::WriteLine("ObjectPoolingAttribute.Enabled: {0}", - attribute->Enabled); - - // Set the Enabled property value of the attribute. - attribute->Enabled = true; - - // Display the new value of the attribute's Enabled property. - Console::WriteLine("ObjectPoolingAttribute.Enabled: {0}", - attribute->Enabled); - } -}; -// - -// - - -// Test client. -int main() -{ - // Create a new instance of each example class. - ObjectPoolingAttributeEnabled^ enabledExample = - gcnew ObjectPoolingAttributeEnabled(); - - // Demonstrate the ObjectPoolingAttribute properties. - enabledExample->EnabledExample(); -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesObjectPoolingAttribute/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesObjectPoolingAttribute/cpp/makefile deleted file mode 100644 index f576735c8c9a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesObjectPoolingAttribute/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -EnterpriseServicesObjectPoolingAttribute.exe : class1.cpp - cl /W4 /clr:pure /FeEnterpriseServicesObjectPoolingAttribute.exe class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesPrivateComponentAttribute/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesPrivateComponentAttribute/cpp/class1.cpp deleted file mode 100644 index 288dac0fdf8d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesPrivateComponentAttribute/cpp/class1.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -#using - -using namespace System; -using namespace System::EnterpriseServices; - -// References: -// System.EnterpriseServices - -// - -// Note: Access checks must be performed at the component level to allow access -// to private components. -[assembly: ApplicationAccessControl(false, -AccessChecksLevel=AccessChecksLevelOption::ApplicationComponent)]; - -[PrivateComponent] -public ref class PrivateComponentAttributeExample : public ServicedComponent -{ -public: - void DisplayMessage() - { - // Display some output. - Console::WriteLine("Private component called successfully."); - } -}; -// - -public ref class PrivateComponentAttributeTest : public ServicedComponent -{ -public: - static void Test() - { - // Create a new instance of the example class. - PrivateComponentAttributeExample^ example = - gcnew PrivateComponentAttributeExample(); - - // Call a method on the class. - example->DisplayMessage(); - } -}; - - -// - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesPrivateComponentAttribute/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesPrivateComponentAttribute/cpp/makefile deleted file mode 100644 index eae4d7f4ddc43..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesPrivateComponentAttribute/cpp/makefile +++ /dev/null @@ -1,4 +0,0 @@ -EnterpriseServicesPrivateComponentAttribute.dll: class1.cpp - cl /LD /FeEnterpriseServicesPrivateComponentAttribute.dll /clr:pure class1.cpp - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesSynchronizationOption/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesSynchronizationOption/cpp/class1.cpp deleted file mode 100644 index de1dd4ae5ab30..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesSynchronizationOption/cpp/class1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -#using - -using namespace System; -using namespace System::EnterpriseServices; - -// References: -// System.EnterpriseServices - -// An instance of this class will not join an activity, but can share its -// caller's context even if its caller is configured as NotSupported, -// Supported, Required, or RequiresNew. -[Synchronization(SynchronizationOption::Disabled)] -public ref class SynchronizationAttribute_SynchronizationDisabled : - public ServicedComponent -{ -}; - -// An instance of this class will not join an activity, and will share its -// caller's context only if its caller is also configured as NotSupported. -[Synchronization(SynchronizationOption::NotSupported)] -public ref class SynchronizationAttribute_SynchronizationNotSupported : - public ServicedComponent -{ -}; - -// An instance of this class will join its caller's activity if one exists. -[Synchronization(SynchronizationOption::Supported)] -public ref class SynchronizationAttribute_SynchronizationSupported : - public ServicedComponent -{ -}; - -// An instance of this class will join its caller's activity if one exists. -// If not, a new activity will be created for it. -[Synchronization(SynchronizationOption::Required)] -public ref class SynchronizationAttribute_SynchronizationRequired : - public ServicedComponent -{ -}; - -// A new activity will always be created for an instance of this class. -[Synchronization(SynchronizationOption::RequiresNew)] -public ref class SynchronizationAttribute_SynchronizationRequiresNew : - public ServicedComponent -{ -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesSynchronizationOption/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesSynchronizationOption/cpp/makefile deleted file mode 100644 index d1a0f4b635a51..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesSynchronizationOption/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -EnterpriseServicesSynchronizationOption.dll : class1.cpp - cl /clr:pure /LD /FeEnterpriseServicesSynchronizationOption.dll class1.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionIsolationLevel/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionIsolationLevel/cpp/class1.cpp deleted file mode 100644 index 95137a20bbc90..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionIsolationLevel/cpp/class1.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::Reflection; - -// References: -// System.EnterpriseServices - -// An instance of this class will inherit its caller's transaction isolation -// level if available. If not, it will use isolation level Serializable. -[Transaction(Isolation=TransactionIsolationLevel::Any)] -public ref class IsolationAny : public ServicedComponent -{ -}; - -// An instance of this class will read only committed data, but non-repeatable -// reads and phantom rows are still possible. -[Transaction(Isolation=TransactionIsolationLevel::ReadCommitted)] -public ref class IsolationReadCommitted : public ServicedComponent -{ -}; - -// An instance of this class will read committed and uncommitted data, so dirty -// reads, non-repeatable reads, and phantom rows are possible. -[Transaction(Isolation=TransactionIsolationLevel::ReadUncommitted)] -public ref class IsolationReadUncommitted : public ServicedComponent -{ -}; - -// An instance of this class will read only committed data and place shared -// locks on the data, preventing other users from modifying it, but other users -// can still insert rows into the data set, so phantom rows are still possible. -[Transaction(Isolation=TransactionIsolationLevel::RepeatableRead)] -public ref class IsolationRepeatableRead : public ServicedComponent -{ -}; - -// An instance of this class will read only committed data and place a range -// lock on the data set, preventing other users from updating or inserting rows -// into the data set until its transaction is complete. -[Transaction(Isolation=TransactionIsolationLevel::Serializable)] -public ref class IsolationSerializable : public ServicedComponent -{ -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionIsolationLevel/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionIsolationLevel/cpp/makefile deleted file mode 100644 index bb7da43195575..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionIsolationLevel/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -EnterpriseServicesTransactionIsolationLevel.dll: class1.cpp - cl /FeEnterpriseServicesTransactionIsolationLevel.dll /clr:pure class1.cpp /LD diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionOption/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionOption/cpp/class1.cpp deleted file mode 100644 index f146dfea0784b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionOption/cpp/class1.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::Reflection; - -// References: -// System.EnterpriseServices - -// An instance of this class will not participate in transactions, but can -// share its caller's context even if its caller is configured as -// NotSupported, Supported, Required, or RequiresNew. -[Transaction(TransactionOption::Disabled)] -public ref class TransactionDisabled : public ServicedComponent -{ -}; - -// An instance of this class will not participate in transactions, and will -// share its caller's context only if its caller is also configured as -// NotSupported. -[Transaction(TransactionOption::NotSupported)] -public ref class TransactionNotSupported : public ServicedComponent -{ -}; - -// An instance of this class will participate in its caller's transaction -// if one exists. -[Transaction(TransactionOption::Supported)] -public ref class TransactionSupported : public ServicedComponent -{ -}; - -// An instance of this class will participate in its caller's transaction -// if one exists. If not, a new transaction will be created for it. -[Transaction(TransactionOption::Required)] -public ref class TransactionRequired : public ServicedComponent -{ -}; - -// A new transaction will always be created for an instance of this class. -[Transaction(TransactionOption::RequiresNew)] -public ref class TransactionRequiresNew : public ServicedComponent -{ -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionOption/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionOption/cpp/makefile deleted file mode 100644 index 0c1c3eb6b2192..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServicesTransactionOption/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -EnterpriseServicesTransactionOption.dll : class1.cpp - cl /W4 /clr:pure /LD /FeEnterpriseServicesTransactionOption.dll class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Basic/CPP/calculator.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Basic/CPP/calculator.cpp deleted file mode 100644 index 17cf341fc64d2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Basic/CPP/calculator.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using - -using namespace System; -using namespace System::EnterpriseServices; - -// - -[assembly:ApplicationName("Calculator")]; -[assembly:ApplicationActivation(ActivationOption::Library)]; -[assembly:System::Reflection::AssemblyKeyFile("Calculator.snk")]; -public ref class Calculator: public ServicedComponent -{ -public: - int Add( int x, int y ) - { - return (x + y); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/crmclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/crmclient.cpp deleted file mode 100644 index c4aa994f1db8e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/crmclient.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -#using "System.EnterpriseServices.dll" - -using namespace System; - -[assembly: System::Reflection::AssemblyKeyFile("CrmServer.key")]; - -int main () -{ - - // Create a new account object. The object is created in a COM+ server application. - Account^ account = gcnew Account(); - - // Transactionally debit the account. - try - { - account->Filename = System::IO::Path::GetFullPath("JohnDoe"); - account->AllowCommit = true; - account->DebitAccount(3); - } - finally - { - delete account; - } - -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/crmserver.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/crmserver.cpp deleted file mode 100644 index 19de5456c6e7c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/crmserver.cpp +++ /dev/null @@ -1,289 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::EnterpriseServices::CompensatingResourceManager; -using namespace System::IO; -using namespace System::Diagnostics; - -// -[assembly: ApplicationActivation(ActivationOption::Server)]; -// -// -[assembly: ApplicationAccessControl(false)]; -// -// -[assembly: ApplicationCrmEnabled]; -// -// -[assembly: Description("A system for ensuring that the correct account " - "balance is stored after a transaction.")]; -// - -// Subroutines to read and write account files. -void WriteAccountBalance(String^ filename, int balance) -{ - StreamWriter^ streamWriter = gcnew StreamWriter(filename); - try - { - streamWriter->WriteLine(balance); - } - finally - { - delete streamWriter; - } -} - -int ReadAccountBalance(String^ filename) -{ - int balance = 0; - if (File::Exists(filename)) - { - StreamReader^ streamReader = gcnew StreamReader(filename); - try - { - String^ line = streamReader->ReadLine(); - balance = Int32::Parse(line); - } - finally - { - delete streamReader; - } - } - return balance; -} - -ref class AccountCompensator; - -// -// A CRM Worker -[Transaction] -public ref class Account : public ServicedComponent -{ - - // A data member for the account file name. -private: - String^ filenameValue; - -public: - property String^ Filename - { - String^ get() - { - return filenameValue; - } - void set( String^ value ) - { - filenameValue = value; - } - } - - // A boolean data member that determines whether to commit or abort the - // transaction. -private: - bool allowCommitValue; - -public: - property bool AllowCommit - { - bool get() - { - return allowCommitValue; - } - void set( bool value ) - { - allowCommitValue = value; - } - } - - // Debit the account, -public: - void DebitAccount(int amount) - { - - // - // Create a new clerk using the AccountCompensator class. - Clerk^ clerk = gcnew Clerk(AccountCompensator::typeid, - "An account transaction compensator", CompensatorOptions::AllPhases); - // - - // - // Create a record of previous account status, and deliver it to the - // clerk. - int balance = ReadAccountBalance(Filename); - - array^ record = gcnew array(2); - record[0] = Filename; - record[1] = balance; - - clerk->WriteLogRecord(record); - clerk->ForceLog(); - // - - // Perform the transaction - balance -= amount; - - Console::WriteLine("{0}: {1}", Filename, balance); - - WriteAccountBalance(Filename, balance); - - // - // Commit or abort the transaction - if (AllowCommit) - { - ContextUtil::SetComplete(); - } - else - { - ContextUtil::SetAbort(); - } - // - - } - -}; -// - -// -// A CRM Compensator -public ref class AccountCompensator : public Compensator -{ -private: - bool receivedPrepareRecord; - -public: - AccountCompensator() - { - receivedPrepareRecord = false; - } - - // -public: - virtual void BeginPrepare() override - { - // nothing to do - } - // - - // -public: - virtual bool PrepareRecord(LogRecord^ log) override - { - - // Check the validity of the record. - if (log == nullptr) - { - return false; - } - array^ record = dynamic_cast^>(log->Record); - if (record == nullptr) - { - return false; - } - if (record->Length != 2) - { - return false; - } - - // The record is valid. - receivedPrepareRecord = true; - return true; - } - // - - // -public: - virtual bool EndPrepare() override - { - // Allow the transaction to proceed onlyif we have received a prepare - // record. - if (receivedPrepareRecord) - { - return true; - } - else - { - return false; - } - } - // - - // -public: - virtual void BeginCommit(bool commit) override - { - // nothing to do - } - // - - // -public: - virtual bool CommitRecord(LogRecord^ log) override - { - // nothing to do - return(false); - } - // - - // -public: - virtual void EndCommit() override - { - // nothing to do - } - // - - // -public: - virtual void BeginAbort(bool abort) override - { - // nothing to do - } - // - - // -public: - virtual bool AbortRecord(LogRecord^ log) override - { - - // Check the validity of the record. - if (log == nullptr) - { - return true; - } - array^ record = dynamic_cast^>(log->Record); - if (record == nullptr) - { - return true; - } - if (record->Length != 2) - { - return true; - } - - // Extract old account data from the record. - String^ filename = (String^) record[0]; - int balance = (int) record[1]; - - // Restore the old state of the account. - WriteAccountBalance(filename, balance); - - return false; - } - // - - // -public: - virtual void EndAbort() override - { - // nothing to do - } - // - -}; -// - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/makefile deleted file mode 100644 index 58a304675f4f2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Crm/cpp/makefile +++ /dev/null @@ -1,22 +0,0 @@ -all: CrmServer.dll CrmClient.exe - -CrmServer.dll: CrmServer.cpp CrmServer.key -# - cl /c /FoCrmServer.obj /clr:pure CrmServer.cpp - link /DLL /KEYFILE:"CrmServer.key" CrmServer.obj -# - -CrmServer.key: -# - sn -k CrmServer.key -# - -CrmClient.exe: CrmClient.cpp CrmServer.dll -# - cl /FeCrmClient.exe /clr:pure CrmClient.cpp /FUCrmServer.dll -# - -install: -# - regsvcs CrmServer.dll -# diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Pooling/CPP/inspector.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Pooling/CPP/inspector.cpp deleted file mode 100644 index 50d9d6fefafed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Pooling/CPP/inspector.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::Windows::Forms; - -// - -[assembly:ApplicationName("ObjectInspector")]; -[assembly:ApplicationActivation(ActivationOption::Server)]; -[assembly:System::Reflection::AssemblyKeyFile("Inspector.snk")]; -[JustInTimeActivation] -[ObjectPooling(MinPoolSize=2,MaxPoolSize=100,CreationTimeout=1000)] -public ref class ObjectInspector: public ServicedComponent -{ - // -public: - String^ IdentifyObject( Object^ obj ) - { - // Return this object to the pool after use. - ContextUtil::DeactivateOnReturn = true; - - // Get the supplied object's type. - Type^ objType = obj->GetType(); - - // Return its name. - return (objType->FullName); - } - // - - // -protected: - virtual void Activate() override - { - MessageBox::Show( String::Format( "Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n", ContextUtil::ApplicationId.ToString(), ContextUtil::ApplicationInstanceId.ToString(), ContextUtil::ContextId.ToString() ) ); - } - // - - // - virtual void Deactivate() override - { - MessageBox::Show( "Bye Bye!" ); - } - // - - // - // This object can be pooled. - virtual bool CanBePooled() override - { - return (true); - } - // -}; -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Security/CPP/employeeinformation.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Security/CPP/employeeinformation.cpp deleted file mode 100644 index 8aff4f6dc9632..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Security/CPP/employeeinformation.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::EnterpriseServices; - -// -// Set component name and strong name key. -[assembly:ApplicationName("EmployeeInformation")]; -[assembly:System::Reflection::AssemblyKeyFile("EmployeeInformation.snk")]; -// - -// -// Set component access controls. -[assembly:ApplicationAccessControl(Authentication=AuthenticationOption::Privacy, -ImpersonationLevel=ImpersonationLevelOption::Identify, -AccessChecksLevel=AccessChecksLevelOption::ApplicationComponent)]; -// - -// -// Create a security role for the component. -[assembly:SecurityRole("Manager")]; -// - -// -// Accept a constructor string. - -[ConstructionEnabled] -public ref class EmployeeInformation: public ServicedComponent -{ -private: - - // The employee's user name and salary. - String^ accountName; - double salary; - -public: - - // - // Get the employee's name. All users can call this method. - String^ GetName() - { - return (accountName); - } - // - - // - // Set the employee's salary. Only managers can do this. - void SetSalary( double ammount ) - { - if ( SecurityCallContext::CurrentCall->IsCallerInRole( "Manager" ) ) - { - salary = ammount; - } - else - { - throw gcnew UnauthorizedAccessException; - } - } - // - - // - // Get the employee's salary. Only the employee and managers can do this. - double GetSalary() - { - if ( SecurityCallContext::CurrentCall->DirectCaller->AccountName == accountName || SecurityCallContext::CurrentCall->IsCallerInRole( "Manager" ) ) - { - return (salary); - } - else - { - throw gcnew UnauthorizedAccessException; - } - } - // - - // -protected: - // Use the constructor string. - // This method is called when the object is instantiated. - virtual void Construct( String^ constructorString ) override - { - accountName = constructorString; - } - // -}; - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_SharedProperties/CPP/receiptcounterclass.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_SharedProperties/CPP/receiptcounterclass.cpp deleted file mode 100644 index 17d849b6a90d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_SharedProperties/CPP/receiptcounterclass.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::Reflection; - -[assembly:AssemblyKeyFile("..\\common\\key.snk")]; -[assembly:ApplicationName("ReceiptNumberGenerator")]; -[assembly:ApplicationActivation(ActivationOption::Library)]; - -public ref class ReceiptNumberGeneratorClass -{ -public: - - // Generates a new receipt number based on the receipt number - // stored by the Shared Property Manager (SPM) - int GetNextReceiptNumber() - { - bool groupExists; - bool propertyExists; - int nextReceiptNumber = 0; - PropertyLockMode lockMode = PropertyLockMode::SetGet; - PropertyReleaseMode releaseMode = PropertyReleaseMode::Standard; - - // - // Create a shared property group manager. - SharedPropertyGroupManager^ groupManager = gcnew SharedPropertyGroupManager; - // - - // - // - // Create a shared property group. - SharedPropertyGroup^ group = - groupManager->CreatePropertyGroup( "Receipts", lockMode, releaseMode, groupExists ); - // - - // Create a shared property. - SharedProperty^ ReceiptNumber; - ReceiptNumber = group->CreateProperty( "ReceiptNumber", propertyExists ); - // - - // - // Retrieve the value from shared property, and increment the shared - // property value. - nextReceiptNumber = safe_cast(ReceiptNumber->Value); - ReceiptNumber->Value = nextReceiptNumber + 1; - // - - // Return nextReceiptNumber - return nextReceiptNumber; - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Transaction/CPP/transaction.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Transaction/CPP/transaction.cpp deleted file mode 100644 index 720671e07a367..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/EnterpriseServices_Transaction/CPP/transaction.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::EnterpriseServices; - -// - -[assembly:System::Reflection::AssemblyKeyFile("Transaction.snk")]; -[Transaction] -public ref class TransactionalComponent: public ServicedComponent -{ -public: - void TransactionalMethod( String^ data ) - { - ContextUtil::DeactivateOnReturn = true; - ContextUtil::MyTransactionVote = TransactionVote::Abort; - - // do work with data - ContextUtil::MyTransactionVote = TransactionVote::Commit; - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Add/CPP/faultbindingcollection_add.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Add/CPP/faultbindingcollection_add.cpp deleted file mode 100644 index fbcca70719e5e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Add/CPP/faultbindingcollection_add.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* The following example demonstrates the 'Add' method of the 'FaultBindingCollection' class -* and constructor and 'Extensions' property of 'FaultBinding'class and 'Documentation' -* property of 'DocumentableItem' class. -* -* This program generates a WSDL file for a service called StockQuote. The StockQuote service -* provides one method called 'GetTradePrice'. The 'GetTradePrice' method takes two arguments, -* a 'tickerSymbol' and 'time' strings. The 'tickerSymbol' is a unique representation of a -* stock and 'time' is the time for which the trading price is to be returned for the stock -* specified. The WSDL file generated for the service supports the SOAP protocol only. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -XmlSchemaElement^ CreateComplexTypeXmlElement( String^ minoccurs, String^ maxoccurs, String^ name, bool isNillable, XmlQualifiedName^ schemaTypeName ) -{ - XmlSchemaElement^ myXmlSchemaElement = gcnew XmlSchemaElement; - myXmlSchemaElement->MinOccursString = minoccurs; - myXmlSchemaElement->MaxOccursString = maxoccurs; - myXmlSchemaElement->Name = name; - myXmlSchemaElement->IsNillable = true; - myXmlSchemaElement->SchemaTypeName = schemaTypeName; - return myXmlSchemaElement; -} - -XmlSchemaElement^ CreateOtherXmlElement( String^ name, XmlQualifiedName^ SchemaTypeName ) -{ - XmlSchemaElement^ myXmlSchemaElement = gcnew XmlSchemaElement; - myXmlSchemaElement->Name = name; - myXmlSchemaElement->SchemaTypeName = SchemaTypeName; - return myXmlSchemaElement; -} - -// Creates a Message with name =S"messageName" having one MessagePart with name = S"partName". -Message^ CreateMessage( String^ messageName, String^ partName, String^ element, String^ targetNamespace ) -{ - Message^ myMessage = gcnew Message; - myMessage->Name = messageName; - MessagePart^ myMessagePart = gcnew MessagePart; - myMessagePart->Name = partName; - myMessagePart->Element = gcnew XmlQualifiedName( element,targetNamespace ); - myMessage->Parts->Add( myMessagePart ); - return myMessage; -} - -int main() -{ - ServiceDescription^ myServiceDescription = gcnew ServiceDescription; - myServiceDescription->Name = "StockQuote"; - myServiceDescription->TargetNamespace = "http://www.contoso.com/stockquote.wsdl"; - - // Generate the 'Types' element. - XmlSchema^ myXmlSchema = gcnew XmlSchema; - myXmlSchema->AttributeFormDefault = XmlSchemaForm::Qualified; - myXmlSchema->ElementFormDefault = XmlSchemaForm::Qualified; - myXmlSchema->TargetNamespace = "http://www.contoso.com/stockquote.wsdl"; - - //XmlSchemaElement myXmlSchemaElement; - XmlSchemaComplexType^ myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - myXmlSchemaComplexType->Name = "GetTradePriceInputType"; - XmlSchemaSequence^ myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "tickerSymbol", true, gcnew XmlQualifiedName( "s:string" ) ) ); - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "time", true, gcnew XmlQualifiedName( "s:string" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlSchema->Items->Add( myXmlSchemaComplexType ); - - myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - myXmlSchemaComplexType->Name = "GetTradePriceOutputType"; - myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "result", true, gcnew XmlQualifiedName( "s:string" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlSchema->Items->Add( myXmlSchemaComplexType ); - - myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - myXmlSchemaComplexType->Name = "GetTradePriceStringFaultType"; - myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "error", true, gcnew XmlQualifiedName( "s:string" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlSchema->Items->Add( myXmlSchemaComplexType ); - - myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - myXmlSchemaComplexType->Name = "GetTradePriceStringIntType"; - myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "error", true, gcnew XmlQualifiedName( "s:int" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlSchema->Items->Add( myXmlSchemaComplexType ); - - myXmlSchema->Items->Add( CreateOtherXmlElement( "GetTradePriceSoapIn", gcnew XmlQualifiedName( "s0:GetTradePriceInputType" ) ) ); - myXmlSchema->Items->Add( CreateOtherXmlElement( "GetTradePriceSoapOut", gcnew XmlQualifiedName( "s0:GetTradePriceOutputType" ) ) ); - myXmlSchema->Items->Add( CreateOtherXmlElement( "GetTradePriceSoapStringFault", gcnew XmlQualifiedName( "s0:GetTradePriceStringFaultType" ) ) ); - myXmlSchema->Items->Add( CreateOtherXmlElement( "GetTradePriceSoapIntFault", gcnew XmlQualifiedName( "s0:GetTradePriceIntFaultType" ) ) ); - - myServiceDescription->Types->Schemas->Add( myXmlSchema ); - - // Generate the 'Message' element. - MessageCollection^ myMessageCollection = myServiceDescription->Messages; - myMessageCollection->Add( CreateMessage( "GetTradePriceInput", "parameters", "GetTradePriceSoapIn", myServiceDescription->TargetNamespace ) ); - myMessageCollection->Add( CreateMessage( "GetTradePriceOutput", "parameters", "GetTradePriceSoapOut", myServiceDescription->TargetNamespace ) ); - myMessageCollection->Add( CreateMessage( "GetTradePriceStringFault", "parameters", "GetTradePriceStringSoapFault", myServiceDescription->TargetNamespace ) ); - myMessageCollection->Add( CreateMessage( "GetTradePriceIntFault", "parameters", "GetTradePriceIntSoapFault", myServiceDescription->TargetNamespace ) ); - - // Generate the 'Port Type' element. - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = gcnew PortType; - myPortType->Name = "StockQuotePortType"; - OperationCollection^ myOperationCollection = myPortType->Operations; - Operation^ myOperation = gcnew Operation; - myOperation->Name = "GetTradePrice"; - OperationMessage^ myOperationMessage; - OperationMessageCollection^ myOperationMessageCollection = myOperation->Messages; - myOperationMessage = dynamic_cast(gcnew OperationInput); - myOperationMessage->Message = gcnew XmlQualifiedName( "s0:GetTradePriceInput" ); - myOperationMessageCollection->Add( myOperationMessage ); - myOperationMessage = dynamic_cast(gcnew OperationOutput); - myOperationMessage->Message = gcnew XmlQualifiedName( "s0:GetTradePriceOutput" ); - myOperationMessageCollection->Add( myOperationMessage ); - OperationFault^ myOperationFault = gcnew OperationFault; - myOperationFault->Name = "ErrorString"; - myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceStringFault" ); - myOperation->Faults->Add( myOperationFault ); - myOperationFault = gcnew OperationFault; - myOperationFault->Name = "ErrorInt"; - myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceIntFault" ); - myOperation->Faults->Add( myOperationFault ); - myOperationCollection->Add( myOperation ); - myPortTypeCollection->Add( myPortType ); - - // Generate the 'Binding' element. - ServiceDescriptionFormatExtensionCollection^ myExtensions; - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - Binding^ myBinding = gcnew Binding; - myBinding->Name = "StockQuoteSoapBinding"; - myBinding->Type = gcnew XmlQualifiedName( "s0:StockQuotePortType" ); - myExtensions = myBinding->Extensions; - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Style = SoapBindingStyle::Document; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - myExtensions->Add( mySoapBinding ); - OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations; - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myExtensions = myOperationBinding->Extensions; - SoapOperationBinding^ mySoapBindingOperation = gcnew SoapOperationBinding; - mySoapBindingOperation->SoapAction = "http://www.contoso.com/GetTradePrice"; - myExtensions->Add( mySoapBindingOperation ); - myOperationBinding->Name = "GetTradePrice"; - myOperationBinding->Input = gcnew InputBinding; - myExtensions = myOperationBinding->Input->Extensions; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - mySoapBodyBinding->Namespace = "http://www.contoso.com/stockquote"; - myExtensions->Add( mySoapBodyBinding ); - myOperationBinding->Output = gcnew OutputBinding; - myExtensions = myOperationBinding->Output->Extensions; - mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - mySoapBodyBinding->Namespace = "http://www.contoso.com/stockquote"; - myExtensions->Add( mySoapBodyBinding ); - -// -// -// - FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults; - FaultBinding^ myFaultBinding = gcnew FaultBinding; - myFaultBinding->Name = "ErrorString"; - // Associate SOAP fault binding to the fault binding of the operation. - myExtensions = myFaultBinding->Extensions; - SoapFaultBinding^ mySoapFaultBinding = gcnew SoapFaultBinding; - mySoapFaultBinding->Use = SoapBindingUse::Literal; - mySoapFaultBinding->Namespace = "http://www.contoso.com/stockquote"; - myExtensions->Add( mySoapFaultBinding ); - myFaultBindingCollection->Add( myFaultBinding ); -// -// -// - - myFaultBinding = gcnew FaultBinding; - myFaultBinding->Name = "ErrorInt"; - // Associate SOAP fault binding to the fault binding of the operation. - myExtensions = myFaultBinding->Extensions; - mySoapFaultBinding = gcnew SoapFaultBinding; - mySoapFaultBinding->Use = SoapBindingUse::Literal; - mySoapFaultBinding->Namespace = "http://www.contoso.com/stockquote"; - myExtensions->Add( mySoapFaultBinding ); - myFaultBindingCollection->Add( myFaultBinding ); - myOperationBindingCollection->Add( myOperationBinding ); - myBindingCollection->Add( myBinding ); - - // Generate the 'Service' element. - ServiceCollection^ myServiceCollection = myServiceDescription->Services; - -// - Service^ myService = gcnew Service; - // Add a simple documentation for the service to ease the readability of the generated WSDL file. - myService->Documentation = "A Simple Stock Quote Service"; - myService->Name = "StockQuoteService"; - PortCollection^ myPortCollection = myService->Ports; - Port^ myPort = gcnew Port; - myPort->Name = "StockQuotePort"; - myPort->Binding = gcnew XmlQualifiedName( "s0:StockQuoteSoapBinding" ); - myExtensions = myPort->Extensions; - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://www.contoso.com/stockquote"; - myExtensions->Add( mySoapAddressBinding ); - myPortCollection->Add( myPort ); - // - myServiceCollection->Add( myService ); - - // Display the WSDL generated to the console. - myServiceDescription->Write( Console::Out ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Item/CPP/faultbindingcollection_item.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Item/CPP/faultbindingcollection_item.cpp deleted file mode 100644 index 5084e6fa1697e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Item/CPP/faultbindingcollection_item.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -* The following example demonstrates the 'Item[String*]' property of -FaultBindingCollection class -* The program removes a fault binding with the name 'ErrorString' -from the WSDL file. It also removes a operation fault with the name -'ErrorString' and displays the resultant WSDL file to the console. -* -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - - // Read the 'StockQuote::wsdl' file as input. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote.wsdl" ); - - // Get the operation fault collection and remove the operation fault with the name 'ErrorString'. - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = myPortTypeCollection[ 0 ]; - OperationCollection^ myOperationCollection = myPortType->Operations; - Operation^ myOperation = myOperationCollection[ 0 ]; - OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults; - if ( myOperationFaultCollection->Contains( myOperationFaultCollection[ "ErrorString" ] ) ) - myOperationFaultCollection->Remove( myOperationFaultCollection[ "ErrorString" ] ); - - - // Get the fault binding collection and remove the fault binding with the name 'ErrorString'. - // - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - Binding^ myBinding = myBindingCollection[ 0 ]; - OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations; - OperationBinding^ myOperationBinding = myOperationBindingCollection[ 0 ]; - FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults; - if ( myFaultBindingCollection->Contains( myFaultBindingCollection[ "ErrorString" ] ) ) - myFaultBindingCollection->Remove( myFaultBindingCollection[ "ErrorString" ] ); - - - // - myServiceDescription->Write( Console::Out ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Remove/CPP/faultbindingcollection_remove.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Remove/CPP/faultbindingcollection_remove.cpp deleted file mode 100644 index 5d0f962f0778f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FaultBindingCollection_Remove/CPP/faultbindingcollection_remove.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -* The following example demonstrates the 'Remove', 'CopyTo', 'Insert', -'Contains', 'IndexOf' method and 'Item[int]' property of FaultBindingCollection -class -The program reverses the fault bindings that appear in the WSDL file. -It also reverses the operation faults and displays the resultant WSDL file -to the console. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - - // Read the 'StockQuote::wsdl' file as input. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = myPortTypeCollection[ 0 ]; - OperationCollection^ myOperationCollection = myPortType->Operations; - Operation^ myOperation = myOperationCollection[ 0 ]; - OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults; - - // Reverse the operation fault order. - if ( myOperationFaultCollection->Count > 1 ) - { - array^myOperationFaultArray = gcnew array(myOperationFaultCollection->Count); - - // Copy the operation fault to a temporary array. - myOperationFaultCollection->CopyTo( myOperationFaultArray, 0 ); - - // Remove all the operation fault instances in the fault binding collection. - for ( int i = 0; i < myOperationFaultArray->Length; i++ ) - myOperationFaultCollection->Remove( myOperationFaultArray[ i ] ); - - // Insert the operation fault instance in the reverse order. - for ( int i = 0,j = (myOperationFaultArray->Length - 1); i < myOperationFaultArray->Length; i++,j-- ) - myOperationFaultCollection->Insert( i, myOperationFaultArray[ j ] ); - } - - // - // - // - // - // - // - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - Binding^ myBinding = myBindingCollection[ 0 ]; - OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations; - OperationBinding^ myOperationBinding = myOperationBindingCollection[ 0 ]; - FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults; - - // Reverse the fault bindings order. - if ( myFaultBindingCollection->Count > 1 ) - { - FaultBinding^ myFaultBinding = myFaultBindingCollection[ 0 ]; - array^myFaultBindingArray = gcnew array(myFaultBindingCollection->Count); - - // Copy the fault bindings to a temporary array. - myFaultBindingCollection->CopyTo( myFaultBindingArray, 0 ); - - // Remove all the fault binding instances in the fault binding collection. - for ( int i = 0; i < myFaultBindingArray->Length; i++ ) - myFaultBindingCollection->Remove( myFaultBindingArray[ i ] ); - - // Insert the fault binding instance in the reverse order. - for ( int i = 0,j = (myFaultBindingArray->Length - 1); i < myFaultBindingArray->Length; i++,j-- ) - myFaultBindingCollection->Insert( i, myFaultBindingArray[ j ] ); - - // Check if the first element in the collection before the reversal is now the last element. - if ( myFaultBindingCollection->Contains( myFaultBinding ) && myFaultBindingCollection->IndexOf( myFaultBinding ) == (myFaultBindingCollection->Count - 1) ) - - // Display the WSDL generated to the console. - myServiceDescription->Write( Console::Out ); - else - Console::WriteLine( "Error while reversing" ); - } - // - // - // - // - // - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp deleted file mode 100644 index ff1a5cacc7dcb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// System::Net::FileWebRequest::ContentLength;System::Net::FileWebRequest::RequestUri; - -/* -This program demonstrates 'ContentLength'and 'RequestUri' property of 'FileWebRequest' class. -The path of a file where user would like to write something is obtained from command line argument. -Then a 'WebRequest' Object* is created. The 'ContentLength' property of 'FileWebRequest' is used to -set the length of the file content that was written. -*/ - -#using - -using namespace System::Net; -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter where you want to write:" ); - Console::WriteLine( "Usage:FileWebRequest_ContentLen //\nExample:FileWebRequest_ContentLen shafeeque/shaf/hello.txt" ); - } - else - { - try - { - // Create an 'Uri' Object*. - Uri^ myUrl = gcnew Uri( String::Concat( "file://", args[ 1 ] ) ); - FileWebRequest^ myFileWebRequest = nullptr; - -// - myFileWebRequest = (FileWebRequest^)( WebRequest::Create( myUrl ) ); - - Console::WriteLine( "Enter the string you want to write into the file:" ); - String^ userInput = Console::ReadLine(); - ASCIIEncoding^ encoder = gcnew ASCIIEncoding; - array^ byteArray = encoder->GetBytes( userInput ); - - // Set the 'Method' property of 'FileWebRequest' Object* to 'POST' method. - myFileWebRequest->Method = "POST"; - - // The 'ContentLength' property is used to set the content length of the file. - myFileWebRequest->ContentLength = byteArray->Length; -// - -// - // Compare the file name and 'RequestUri' is same or not. - if ( myFileWebRequest->RequestUri->Equals( myUrl ) ) - { - // 'GetRequestStream' method returns the stream handler for writing into the file. - Stream^ readStream = myFileWebRequest->GetRequestStream(); - // Write to the stream - readStream->Write( byteArray, 0, userInput->Length ); - readStream->Close(); - } - - Console::WriteLine( "\nThe String you entered was successfully written into the file." ); - Console::WriteLine( "The content length sent to the server is {0}.", myFileWebRequest->ContentLength ); -// - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( "The ArgumentException is : {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "The UriFormatException is : {0}", e->Message ); - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp deleted file mode 100644 index 7203551b78700..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp +++ /dev/null @@ -1,118 +0,0 @@ - - -// System::Net::FileWebRequest::BeginGetRequestStream;System::Net::FileWebRequest::EndGetRequestStream; -// Snippet1 and Snippet2 go together -/* -This program demonstrates 'BeginGetRequestStream' and 'EndGetRequestStream' method of 'FileWebRequest' class -The path of the file from where content is to be read is obtained as a command line argument and a 'webRequest' -Object* is created.Using the 'BeginGetRequestStream' method and 'EndGetRequestStream' of 'FileWebRequest' class -a stream Object* is obtained which is used to write into the file. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; - -// -// -public ref class RequestDeclare -{ -public: - FileWebRequest^ myFileWebRequest; - String^ userinput; - RequestDeclare() - { - myFileWebRequest = nullptr; - } - -}; - -ref class FileWebRequest_reqbeginend -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void ReadCallback( IAsyncResult^ ar ) - { - try - { - - // State of the request is asynchronous. - RequestDeclare^ requestDeclare = dynamic_cast(ar->AsyncState); - FileWebRequest^ myFileWebRequest = requestDeclare->myFileWebRequest; - String^ sendToFile = requestDeclare->userinput; - - // End the Asynchronus request by calling the 'EndGetRequestStream()' method. - Stream^ readStream = myFileWebRequest->EndGetRequestStream( ar ); - - // Convert the String* into Byte array. - ASCIIEncoding^ encoder = gcnew ASCIIEncoding; - array^byteArray = encoder->GetBytes( sendToFile ); - - // Write to the stream. - readStream->Write( byteArray, 0, sendToFile->Length ); - readStream->Close(); - allDone->Set(); - Console::WriteLine( "\nThe String you entered was successfully written into the file." ); - Console::WriteLine( "\nPress Enter to continue." ); - } - catch ( ApplicationException^ e ) - { - Console::WriteLine( "ApplicationException is : {0}", e->Message ); - } - - } - -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebRequest_reqbeginend //\n" ); - Console::WriteLine( "Example:FileWebRequest_reqbeginend shafeeque/shaf/hello.txt" ); - } - else - { - try - { - - // Place a webrequest. - WebRequest^ myWebRequest = WebRequest::Create( String::Concat( "file://", args[ 1 ] ) ); - - // Create an instance of the 'RequestDeclare' and associate the 'myWebRequest' to it. - RequestDeclare^ requestDeclare = gcnew RequestDeclare; - requestDeclare->myFileWebRequest = dynamic_cast(myWebRequest); - - // Set the 'Method' property of 'FileWebRequest' Object* to 'POST' method. - requestDeclare->myFileWebRequest->Method = "POST"; - Console::WriteLine( "Enter the String* you want to write into the file:" ); - requestDeclare->userinput = Console::ReadLine(); - - // Begin the Asynchronous request for getting file content using 'BeginGetRequestStream()' method . - IAsyncResult^ r = dynamic_cast(requestDeclare->myFileWebRequest->BeginGetRequestStream( gcnew AsyncCallback( &FileWebRequest_reqbeginend::ReadCallback ), requestDeclare )); - FileWebRequest_reqbeginend::allDone->WaitOne(); - Console::Read(); - } - catch ( ProtocolViolationException^ e ) - { - Console::WriteLine( "ProtocolViolationException is : {0}", e->Message ); - } - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( "InvalidOperationException is : {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatExceptionException is : {0}", e->Message ); - } - - } -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp deleted file mode 100644 index 0a0ee8a55ebda..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp +++ /dev/null @@ -1,105 +0,0 @@ - - -// System::Net::FileWebRequest::BeginGetResponse;System::Net::FileWebRequest::EndGetResponse; -// Snippet1 and Snippet2 go together -/* -This program demonstrates 'BeginGetResponse' and 'EndGetResponse' methods of 'FileWebRequest' class. -The path of the file from where content is to be read is obtained as a command line argument and a -'WebRequest' Object* is created. Using the 'BeginGetResponse' method and 'EndGetResponse' of 'FileWebRequest' -class a 'FileWebResponse' Object* is obtained which is used to print the content on the file. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Threading; - -// -// -public ref class RequestDeclare -{ -public: - FileWebRequest^ myFileWebRequest; - RequestDeclare() - { - myFileWebRequest = nullptr; - } - -}; - -ref class FileWebRequest_resbeginend -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void RespCallback( IAsyncResult^ ar ) - { - - // State of request is asynchronous. - RequestDeclare^ requestDeclare = dynamic_cast(ar->AsyncState); - FileWebRequest^ myFileWebRequest = requestDeclare->myFileWebRequest; - - // End the Asynchronus request by calling the 'EndGetResponse()' method. - FileWebResponse^ myFileWebResponse = dynamic_cast(myFileWebRequest->EndGetResponse( ar )); - - // Reade the response into Stream. - StreamReader^ streamReader = gcnew StreamReader( myFileWebResponse->GetResponseStream() ); - array^readBuffer = gcnew array(256); - int count = streamReader->Read( readBuffer, 0, 256 ); - Console::WriteLine( "The contents of the file are :\n" ); - while ( count > 0 ) - { - String^ str = gcnew String( readBuffer,0,count ); - Console::WriteLine( str ); - count = streamReader->Read( readBuffer, 0, 256 ); - } - - streamReader->Close(); - - // Release the response Object* resources. - myFileWebResponse->Close(); - allDone->Set(); - Console::WriteLine( "File reading is over." ); - } - -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebRequest_resbeginend //\n" ); - Console::WriteLine( "Example:FileWebRequest_resbeginend shafeeque/shaf/hello.txt" ); - } - else - { - try - { - - // Place a 'Webrequest'. - WebRequest^ myWebRequest = WebRequest::Create( String::Concat( "file://", args[ 1 ] ) ); - - // Create an instance of the 'RequestDeclare' and associating the 'myWebRequest' to it. - RequestDeclare^ myRequestDeclare = gcnew RequestDeclare; - myRequestDeclare->myFileWebRequest = dynamic_cast(myWebRequest); - - // Begin the Asynchronous request for getting file content using 'BeginGetResponse()' method. - IAsyncResult^ asyncResult = dynamic_cast(myRequestDeclare->myFileWebRequest->BeginGetResponse( gcnew AsyncCallback( &FileWebRequest_resbeginend::RespCallback ), myRequestDeclare )); - FileWebRequest_resbeginend::allDone->WaitOne(); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException is : {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatException is : {0}", e->Message ); - } - - } -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp deleted file mode 100644 index 429fd7433ea49..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Net::FileWebResponse::Close -/*This program demontrates the 'Close' method of 'FileWebResponse' Class. -It takes an Uri from console and creates a 'FileWebRequest' Object* for the Uri::It then gets back -the response Object* from the Uri. The response Object* can be processed as desired.The program then -closes the response Object* and releases resources associated with it. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a FileWebrequest with the specified Uri. - FileWebRequest^ myFileWebRequest = dynamic_cast(WebRequest::Create( fileUrl )); - // Send the 'fileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = dynamic_cast(myFileWebRequest->GetResponse()); - // Process the response here. - Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." ); - // Release resources of response Object*. - myFileWebResponse->Close(); - Console::WriteLine( "\nResponse Stream successfully closed." ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown.The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebResponse_Close // \nExample:FileWebResponse_Close microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp deleted file mode 100644 index 76317e5d2a499..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Net::FileWebResponse::ContentLength;System::Net::FileWebResponse::ContentType. - -/* This program demonstrates the 'ContentLength' and 'ContentType' property of 'FileWebResponse' class. -It creates a web request and queries for a response.It then prints the content length -and content type of the entity body in the response onto the console */ - -#using - -using namespace System; -using namespace System::Net; - -// -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a 'FileWebrequest' Object* with the specified Uri. - FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) ); - // Send the 'fileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() ); - // Print the ContentLength and ContentType properties received as headers in the response Object*. - Console::WriteLine( "\nContent length : {0}, Content Type : {1}", myFileWebResponse->ContentLength, myFileWebResponse->ContentType ); - // Release resources of response Object*. - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown.The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebResponse_ContentLength_ContentType // \nExample:FileWebResponse_ContentLength_ContentType microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp deleted file mode 100644 index 0221b756f8987..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// System::Net::FileWebResponse::GetResponseStream. - -/* This program demonstrates the 'GetResponseStream' method of the 'FileWebResponse' class. -It creates a 'FileWebRequest' Object* and queries for a response. -The response stream obtained is piped to a higher level stream reader. The reader reads -256 characters at a time , writes them into a String* and then displays the String* onto the console*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a 'FileWebrequest' Object* with the specified Uri. - FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) ); - // Send the 'FileWebRequest' Object* and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() ); - - // Get the stream Object* associated with the response Object*. - Stream^ receiveStream = myFileWebResponse->GetResponseStream(); - - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - // Pipe the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - Console::WriteLine( "\r\nResponse stream received" ); - - array^ read = gcnew array(256); - // Read 256 characters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "File Data...\r\n" ); - while ( count > 0 ) - { - // Dump the 256 characters on a String* and display the String* onto the console. - String^ str = gcnew String( read,0,count ); - Console::Write( str ); - count = readStream->Read( read, 0, 256 ); - } - Console::WriteLine( "" ); - // Release resources of stream Object*. - readStream->Close(); - // Release resources of response Object*. - myFileWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown.The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebResponse_GetResponseStream // \nExample:FileWebResponse_GetResponseStream microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp deleted file mode 100644 index 94a12053a56e9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// System::Net::FileWebResponse::Headers - -/* This program demonstrates the 'Headers' property of the 'FileWebResponse' class. -It creates a web request and queries for a response.It then prints [Out] all* the response -headers (name -value pairs) onto the console. */ - -#using - -using namespace System; -using namespace System::Net; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a 'FileWebrequest' Object^ with the specified Uri . - FileWebRequest^ myFileWebRequest = (FileWebRequest^)(WebRequest::Create( fileUrl )); - // Send the 'FileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)(myFileWebRequest->GetResponse()); - // Display all Headers present in the response received from the Uri. - Console::WriteLine( "\r\nThe following headers were received in the response:" ); - // Display each header and the key of the response Object^. - for ( int i = 0; i < myFileWebResponse->Headers->Count; ++i ) - Console::WriteLine( "\nHeader Name: {0}, Header value : {1}", - myFileWebResponse->Headers->Keys[ i ], myFileWebResponse->Headers[ (HttpRequestHeader)i ] ); - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown. The Reason for failure is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised: {0}", e->Message ); - } - -} -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the file name as command line parameter as:" ); - Console::WriteLine( "Usage:FileWebResponse_Headers // \nExample:FileWebResponse_Headers microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp deleted file mode 100644 index 2e7e834b615f5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Net::FileWebResponse::ResponseUri - -/* This program demonstrates the 'ResponseUri' property of the 'FileWebResponse' class. -It creates a 'FileWebRequest' Object* and queries for a response.It then displays the Uri of the file -system resource that provided the response. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - - // Create a 'FileWebrequest' object with the specified Uri . - FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) ); - - // Send the 'fileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() ); - Console::WriteLine( "\nThe Uri of the file system resource that provided the response is :\n {0}\n\n", myFileWebResponse->ResponseUri ); - - // Release resources of response object. - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown.The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the file name as command line parameter as:" ); - Console::WriteLine( "Usage:FileWebResponse_ResponseUri // \nExample:FileWebResponse_ResponseUri microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/FormatterServices.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/FormatterServices.cpp deleted file mode 100644 index b9bb5895a5120..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/FormatterServices.cpp +++ /dev/null @@ -1,178 +0,0 @@ -//Types:System.Runtime.Serialization.FormatterServices -//Types:System.Runtime.Serialization.SerializationInfoEnumerator -// -using namespace System; -using namespace System::IO; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Serialization::Formatters; -using namespace System::Runtime::Serialization::Formatters::Binary; -using namespace System::Reflection; -using namespace System::Security::Permissions; - -// Person is a serializable base class. -[Serializable] -public ref class Person -{ -private: - String^ title; - -public: - Person(String^ title) - { - this->title = title; - } - -public: - virtual String^ ToString() override - { - return String::Format("{0}", title); - } -}; - -// Employee is a serializable class derived from Person. -[Serializable] -public ref class Employee : public Person -{ -private: - String^ title; - -public: - Employee(String^ title) : Person("Person") - { - this->title = title; - } - -public: - virtual String^ ToString() override - { - return String::Format("{0} -> {1}", title, Person::ToString()); - } -}; - -// Manager is a serializable and ISerializable class derived from Employee. -[Serializable] -ref class Manager : public Employee, public ISerializable -{ -private: - String^ title; - -public: - Manager() : Employee("Employee") - { - this->title = "Manager"; - } - - // -public: - [SecurityPermission(SecurityAction::Demand, SerializationFormatter = true)] - virtual void GetObjectData(SerializationInfo^ info, StreamingContext context) - { - // Serialize the desired values for this class. - info->AddValue("title", title); - - // Get the set of serializable members for the class and base classes. - Type^ thisType = this->GetType(); - array^ serializableMembers = - FormatterServices::GetSerializableMembers(thisType, context); - - // Serialize the base class's fields to the info object. - for each (MemberInfo^ serializableMember in serializableMembers) - { - // Do not serialize fields for this class. - if (serializableMember->DeclaringType != thisType) - { - // Skip this field if it is marked NonSerialized. - if (!(Attribute::IsDefined(serializableMember, - NonSerializedAttribute::typeid))) - { - // Get the value of this field and add it to the - // SerializationInfo object. - info->AddValue(serializableMember->Name, - ((FieldInfo^)serializableMember)->GetValue(this)); - } - } - } - - // Call the method below to see the contents of the - // SerializationInfo object. - DisplaySerializationInfo(info); - } - // - - // -private: - static void DisplaySerializationInfo(SerializationInfo^ info) - { - Console::WriteLine("Values in the SerializationInfo:"); - for each (SerializationEntry^ infoEntry in info) - { - Console::WriteLine("Name={0}, ObjectType={1}, Value={2}", - infoEntry->Name, infoEntry->ObjectType, infoEntry->Value); - } - } - // - -protected: - Manager(SerializationInfo^ info, - StreamingContext context) : Employee(nullptr) - { - // Get the set of serializable members for the class and base classes. - Type^ thisType = this->GetType(); - array^ serializableMembers = - FormatterServices::GetSerializableMembers(thisType, context); - - // Deserialize the base class's fields from the info object. - for each (MemberInfo^ serializableMember in serializableMembers) - { - // Do not deserialize fields for this class. - if (serializableMember->DeclaringType != thisType) - { - // For easier coding, treat the member as a FieldInfo object - FieldInfo^ fieldInformation = (FieldInfo^)serializableMember; - - // Skip this field if it is marked NonSerialized. - if (!(Attribute::IsDefined(serializableMember, - NonSerializedAttribute::typeid))) - { - // Get the value of this field from the - // SerializationInfo object. - fieldInformation->SetValue(this, - info->GetValue(fieldInformation->Name, - fieldInformation->FieldType)); - } - } - } - - // Deserialize the values that were serialized for this class. - title = info->GetString("title"); - } - -public: - virtual String^ ToString() override - { - return String::Format("{0} -> {1}", title, Employee::ToString()); - } -}; - -int main() -{ - Stream^ stream = gcnew MemoryStream(); - IFormatter^ formatter = gcnew BinaryFormatter(); - Manager^ m = gcnew Manager(); - Console::WriteLine(m->ToString()); - formatter->Serialize(stream, m); - - stream->Position = 0; - m = (Manager^) formatter->Deserialize(stream); - Console::WriteLine(m->ToString()); -} - -// This code produces the following output. -// -// Manager -> Employee -> Person -// Values in the SerializaitonInfo: -// Name=title, ObjectType=System.String, Value=Manager -// Name=Employee+title, ObjectType=System.String, Value=Employee -// Name=Person+title, ObjectType=System.String, Value=Person -// Manager -> Employee -> Person -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/makefile deleted file mode 100644 index ac459f1f7cd67..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/FormatterServices/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -FormatterServices.exe: FormatterServices.cpp - cl /clr:pure /FeFormatterServices.exe FormatterServices.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpBinding_HttpBinding/CPP/HttpBinding_ctor_Input_CPP.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/HttpBinding_HttpBinding/CPP/HttpBinding_ctor_Input_CPP.wsdl deleted file mode 100644 index 5adc74e56098d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpBinding_HttpBinding/CPP/HttpBinding_ctor_Input_CPP.wsdl +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpBinding_HttpBinding/CPP/httpbinding_ctor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpBinding_HttpBinding/CPP/httpbinding_ctor.cpp deleted file mode 100644 index 6e09ece812682..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpBinding_HttpBinding/CPP/httpbinding_ctor.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// System.Web.Services.Description.HttpBinding.HttpBinding() -// System.Web.Services.Description.HttpBinding.Namespace -// System.Web.Services.Description.HttpAddressBinding.HttpAddressBinding() - -/* The following program demonstrates the constructor, field 'Namespace' of - class 'HttpBinding' and constructor of class 'HttpAddressBinding'. This program writes all 'HttpPost' binding related information to the input wsdl file and genrates an output file which is later on compiled using wsdl tool. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myDescription = ServiceDescription::Read( "HttpBinding_ctor_Input_CPP.wsdl" ); - - // - // - // Create 'Binding' object. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "MyHttpBindingServiceHttpPost"; - XmlQualifiedName^ qualifiedName = gcnew XmlQualifiedName( "s0:MyHttpBindingServiceHttpPost" ); - myBinding->Type = qualifiedName; - - // Create 'HttpBinding' object. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - Console::WriteLine( "HttpBinding Namespace : {0}", HttpBinding::Namespace ); - // - - // Add 'HttpBinding' to 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - // - - // Create 'OperationBinding' object. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myOperation = gcnew HttpOperationBinding; - myOperation->Location = "/AddNumbers"; - - // Add 'HttpOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( myOperation ); - - // Create 'InputBinding' object. - InputBinding^ myInput = gcnew InputBinding; - MimeContentBinding^ postMimeContentbinding = gcnew MimeContentBinding; - postMimeContentbinding->Type = "application/x-www-form-urlencoded"; - myInput->Extensions->Add( postMimeContentbinding ); - - // Add 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInput; - - // Create 'OutputBinding' object. - OutputBinding^ myOutput = gcnew OutputBinding; - MimeXmlBinding^ postMimeXmlbinding = gcnew MimeXmlBinding; - postMimeXmlbinding->Part = "Body"; - myOutput->Extensions->Add( postMimeXmlbinding ); - - // Add 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; - - // Add 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myDescription->Bindings->Add( myBinding ); - - // - // Create a 'Port' object. - Port^ postPort = gcnew Port; - postPort->Name = "MyHttpBindingServiceHttpPost"; - postPort->Binding = gcnew XmlQualifiedName( "s0:MyHttpBindingServiceHttpPost" ); - - // Create 'HttpAddressBinding' object. - HttpAddressBinding^ postAddressBinding = gcnew HttpAddressBinding; - postAddressBinding->Location = "http://localhost/HttpBinding_ctor/HttpBinding_ctor_Service.cs.asmx"; - - // Add 'HttpAddressBinding' to 'Port'. - postPort->Extensions->Add( postAddressBinding ); - // - - // Add 'Port' to 'PortCollection' of 'ServiceDescription'. - myDescription->Services[ 0 ]->Ports->Add( postPort ); - - // Write 'ServiceDescription' as a WSDL file. - myDescription->Write( "HttpBinding_ctor_Output_CPP.wsdl" ); - Console::WriteLine( "WSDL file with name 'HttpBinding_ctor_Output_CPP.wsdl' file created Successfully" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.AddHookChannelUri/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.AddHookChannelUri/CPP/class1.cpp deleted file mode 100644 index a5bf4b16d1aef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.AddHookChannelUri/CPP/class1.cpp +++ /dev/null @@ -1,219 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::IO; -using namespace System::Runtime::Remoting::Messaging; - -// This snippet demonstrates HttpChannel->AddHookChannelUri. -// client code should NOT call this call directly. So, I'm -// writing a class using an implementation that mimics the behavior -// of HttpChannel -// -ref class CustomChannel: public BaseChannelWithProperties, public IChannelReceiverHook, public IChannelReceiver, public IChannel, public IChannelSender -{ -public: - virtual void AddHookChannelUri( String^ channelUri ) - { - if ( channelUri != nullptr ) - { - array^uris = dataStore->ChannelUris; - - // This implementation only allows one URI to be hooked in. - if ( uris == nullptr ) - { - array^newUris = gcnew array(1); - newUris[ 0 ] = channelUri; - dataStore->ChannelUris = newUris; - wantsToListen = false; - } - else - { - String^ msg = "This channel is already listening for data, and can't be hooked into at this stage."; - throw gcnew System::Runtime::Remoting::RemotingException( msg ); - } - } - } - - // The rest of CustomChannel's implementation. - // - ref class TransportSink: public IServerChannelSink - { - public: - - property IServerChannelSink^ NextChannelSink - { - virtual IServerChannelSink^ get() - { - return next; - } - - } - TransportSink( IServerChannelSink^ nextSink ) - { - next = nextSink; - } - - // I am not implementing these because they are - // not needed for my snippet but they must be here. - virtual void AsyncProcessResponse( IServerResponseChannelSinkStack^ sinkStack, Object^ state, IMessage^ msg, ITransportHeaders^ headers, Stream^ stream ){} - - virtual Stream^ GetResponseStream( IServerResponseChannelSinkStack^ sinkStack, Object^ state, IMessage^ msg, ITransportHeaders^ headers ) - { - return nullptr; - } - - virtual ServerProcessing ProcessMessage( IServerChannelSinkStack^ sinkStack, IMessage^ requestMsg, ITransportHeaders^ requestHeaders, Stream^ requestStream, IMessage^% msg, ITransportHeaders^% responseHeaders, Stream^% responseStream ) - { - msg = nullptr; - responseHeaders = nullptr; - responseStream = nullptr; - return ServerProcessing::Complete; - } - - - property IDictionary^ Properties - { - virtual IDictionary^ get() - { - return nullptr; - } - } - - private: - IServerChannelSink^ next; - }; - - -private: - TransportSink^ transportSink; - -public: - property IServerChannelSink^ ChannelSinkChain - { - virtual IServerChannelSink^ get() - { - return transportSink->NextChannelSink; - } - } - -public: - CustomChannel() - { - BinaryServerFormatterSink^ formatterSink = gcnew BinaryServerFormatterSink( BinaryServerFormatterSink::Protocol::Http,nullptr,this ); - transportSink = gcnew TransportSink( formatterSink ); - priority = 0; - dataStore = gcnew ChannelDataStore( nullptr ); - wantsToListen = true; - socket = ""; - } - - CustomChannel( int portNum ) - { - BinaryServerFormatterSink^ formatterSink = gcnew BinaryServerFormatterSink( BinaryServerFormatterSink::Protocol::Http,nullptr,this ); - transportSink = gcnew TransportSink( formatterSink ); - priority = 0; - dataStore = gcnew ChannelDataStore( nullptr ); - wantsToListen = false; - socket = String::Format( "http://localhost: {0}", portNum ); - } - - CustomChannel( IDictionary^ properties, IClientChannelSinkProvider^ clientSinkProvider, IServerChannelSinkProvider^ serverSinkProvider ){} - - - property String^ ChannelName - { - virtual String^ get() - { - return "custom"; - } - } - - property Object^ ChannelData - { - virtual Object^ get() - { - return dataStore; - } - } - - property bool WantsToListen - { - virtual bool get() - { - return wantsToListen; - } - } - - property int ChannelPriority - { - virtual int get() - { - return priority; - } - } - - property String^ ChannelScheme - { - virtual String^ get() - { - return "http"; - } - - } - virtual array^ GetUrlsForUri( String^ uri ) - { - array^urls = gcnew array(dataStore->ChannelUris->Length); - int i = 0; - IEnumerator^ myEnum = dataStore->ChannelUris->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ currUri = safe_cast(myEnum->Current); - urls[ i ] = String::Format( "{0} / {1}", socket, currUri ); - i++; - } - - return urls; - } - - virtual void StartListening( Object^ data ){} - - virtual void StopListening( Object^ data ){} - - virtual String^ Parse( String^ url, String^% objectURI ) - { - int lastSlash = url->LastIndexOf( "/" ); - objectURI = ""; - objectURI = url->Substring( lastSlash ); - return socket; - } - - virtual IMessageSink^ CreateMessageSink( String^ url, Object^ remoteChannelData, String^% objectURI ) - { - Parse( url, objectURI ); - return nullptr; - } - -private: - ChannelDataStore^ dataStore; - bool wantsToListen; - int priority; - String^ socket; -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - CustomChannel^ channel = gcnew CustomChannel( 8085 ); - channel->AddHookChannelUri( "TempConverter" ); - - //System::Runtime::Remoting::Channels.Http::HttpChannel* channel = new System::Runtime::Remoting::Channels.Http::HttpChannel(8085); - //System::Runtime::Remoting::Channels.Tcp::TcpChannel* channel = new System::Runtime::Remoting::Channels.Tcp::TcpChannel(8085); - System::Console::WriteLine( channel->GetUrlsForUri( "TempConverter" )[ 0 ] ); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.ChannelSinkChain/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.ChannelSinkChain/CPP/class1.cpp deleted file mode 100644 index 1520773148216..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.ChannelSinkChain/CPP/class1.cpp +++ /dev/null @@ -1,215 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::IO; -using namespace System::Runtime::Remoting::Messaging; - -// This snippet demonstrates HttpChannel::ChannelSinkChain. -// client code should NOT call this call directly. So, I'm -// writing a class that implements the member as HttpChannel -// does. That is, it returns the first sink after the transport -// sink. ie... if the sink chain is transport=>encryption=>formatter -// then this member should return encryption. - -// -ref class CustomChannel: public BaseChannelWithProperties, public IChannelReceiverHook, public IChannelReceiver, public IChannel, public IChannelSender -{ -public: - - property IServerChannelSink^ ChannelSinkChain - { - // TransportSink is a private class defined within CustomChannel. - virtual IServerChannelSink^ get() - { - return transportSink->NextChannelSink; - } - } - - // Rest of CustomChannel's implementation... - // - CustomChannel() - { - BinaryServerFormatterSink^ formatterSink = gcnew BinaryServerFormatterSink( BinaryServerFormatterSink::Protocol::Http,nullptr,this ); - transportSink = gcnew TransportSink( formatterSink ); - priority = 0; - dataStore = gcnew ChannelDataStore( nullptr ); - wantsToListen = true; - socket = ""; - } - - CustomChannel( int portNum ) - { - BinaryServerFormatterSink^ formatterSink = gcnew BinaryServerFormatterSink( BinaryServerFormatterSink::Protocol::Http,nullptr,this ); - transportSink = gcnew TransportSink( formatterSink ); - priority = 0; - dataStore = gcnew ChannelDataStore( nullptr ); - wantsToListen = false; - socket = "http://localhost: {0}",portNum; - } - - CustomChannel( IDictionary^ properties, IClientChannelSinkProvider^ clientSinkProvider, IServerChannelSinkProvider^ serverSinkProvider ){} - - property String^ ChannelName - { - virtual String^ get() - { - return "custom"; - } - - } - - property Object^ ChannelData - { - virtual Object^ get() - { - return dataStore; - } - - } - virtual void AddHookChannelUri( String^ channelUri ) - { - if ( channelUri != nullptr ) - { - array^uris = dataStore->ChannelUris; - if ( uris == nullptr ) - { - array^newUris = gcnew array(1); - newUris[ 0 ] = channelUri; - dataStore->ChannelUris = newUris; - } - else - { - String^ msg = "This channel is already listening for data, and can't be hooked into at this stage."; - throw gcnew System::Runtime::Remoting::RemotingException( msg ); - } - } - } - - property bool WantsToListen - { - virtual bool get() - { - return wantsToListen; - } - - } - - property int ChannelPriority - { - virtual int get() - { - return priority; - } - - } - - property String^ ChannelScheme - { - virtual String^ get() - { - return "http"; - } - - } - virtual array^ GetUrlsForUri( String^ uri ) - { - array^urls = gcnew array(dataStore->ChannelUris->Length); - int i = 0; - IEnumerator^ myEnum = dataStore->ChannelUris->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ currUri = safe_cast(myEnum->Current); - urls[ i ] = String::Format( "{0}/{1}", socket, currUri ); - i++; - } - - return urls; - } - - virtual void StartListening( Object^ data ){} - - virtual void StopListening( Object^ data ){} - - virtual String^ Parse( String^ url, String^% objectURI ) - { - int lastSlash = url->LastIndexOf( "/" ); - objectURI = ""; - objectURI = url->Substring( lastSlash ); - return socket; - } - - virtual IMessageSink^ CreateMessageSink( String^ url, Object^ remoteChannelData, String^% objectURI ) - { - Parse( url, objectURI ); - return nullptr; - } - - ref class TransportSink: public IServerChannelSink - { - public: - - property IServerChannelSink^ NextChannelSink - { - virtual IServerChannelSink^ get() - { - return next; - } - - } - TransportSink( IServerChannelSink^ nextSink ) - { - next = nextSink; - } - - // I am not implementing these because they are - // not needed for my snippet but they must be here. - virtual void AsyncProcessResponse( IServerResponseChannelSinkStack^ sinkStack, Object^ state, IMessage^ msg, ITransportHeaders^ headers, Stream^ stream ){} - - virtual Stream^ GetResponseStream( IServerResponseChannelSinkStack^ sinkStack, Object^ state, IMessage^ msg, ITransportHeaders^ headers ) - { - return nullptr; - } - - virtual ServerProcessing ProcessMessage( IServerChannelSinkStack^ sinkStack, IMessage^ requestMsg, ITransportHeaders^ requestHeaders, Stream^ requestStream, IMessage^% msg, ITransportHeaders^% responseHeaders, Stream^% responseStream ) - { - msg = nullptr; - responseHeaders = nullptr; - responseStream = nullptr; - return ServerProcessing::Complete; - } - - property IDictionary^ Properties - { - virtual IDictionary^ get() - { - return nullptr; - } - } - - private: - IServerChannelSink^ next; - }; - -private: - ChannelDataStore^ dataStore; - bool wantsToListen; - int priority; - String^ socket; - TransportSink^ transportSink; -}; - -int main() -{ - CustomChannel^ channel = gcnew CustomChannel( 8085 ); - channel->AddHookChannelUri( "TempConverter" ); - - //System::Runtime::Remoting::Channels.Http::HttpChannel* channel = new System::Runtime::Remoting::Channels.Http::HttpChannel(8085); - //System::Runtime::Remoting::Channels.Tcp::TcpChannel* channel = new System::Runtime::Remoting::Channels.Tcp::TcpChannel(8085); - System::Console::WriteLine( channel->ChannelSinkChain ); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.GetUrlsFromUri/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.GetUrlsFromUri/CPP/class1.cpp deleted file mode 100644 index 76d14d8aed808..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel.GetUrlsFromUri/CPP/class1.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Collections; - -public ref class HelloService: public MarshalByRefObject{}; - -int main() -{ - // Create a remotable object. - HttpChannel^ httpChannel = gcnew HttpChannel( 8085 ); - WellKnownServiceTypeEntry^ WKSTE = gcnew WellKnownServiceTypeEntry( HelloService::typeid,"Service",WellKnownObjectMode::Singleton ); - RemotingConfiguration::RegisterWellKnownServiceType( WKSTE ); - RemotingConfiguration::ApplicationName = "HelloServer"; - - // Print out the urls for HelloServer. - array^urls = httpChannel->GetUrlsForUri( "HelloServer" ); - IEnumerator^ myEnum = urls->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ url = safe_cast(myEnum->Current); - System::Console::WriteLine( "{0}", url ); - } - - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/client.cpp deleted file mode 100644 index b30b48567bc26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/client.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Security::Permissions; -using namespace SampleNamespace; - -// The following sample uses an HttpChannel constructor -// to create a new HttpChannel, allowing this client to -// hook up to an event on a server Object*. -// System::Runtime::Remoting::Channels.Http::HttpChannel.HttpChannel(int) -// -public ref class SampleClient: public MarshalByRefObject -{ -public: - [PermissionSet(SecurityAction::LinkDemand)] - SampleClient() - { - ChannelServices::RegisterChannel( gcnew HttpChannel( 0 ), false ); - SampleService ^ service = dynamic_cast(Activator::GetObject(SampleNamespace::SampleService::typeid, "http://localhost:9000/MySampleService/SampleService::soap" )); - - // Subscribe to event so that the client can receive notification from ther server. - SomethingHappenedEventHandler ^ eventHandler = gcnew SomethingHappenedEventHandler(this, &SampleClient::OnSomethingHappened ); - service->SomethingHappened += eventHandler; - - // The server will fire the SomethingHappened event in SampleMethod() - service->SampleMethod(); - service->SomethingHappened -= eventHandler; - } - - void OnSomethingHappened( Object^ source, SampleServiceEventArgs^ e ) - { - Console::WriteLine( "SomethingHappened event fired: {0}", e->Message ); - } - -}; - -int main() -{ - SampleClient^ client = gcnew SampleClient; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/client2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/client2.cpp deleted file mode 100644 index 3fa80f648699f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/client2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Lifetime; -using namespace SampleNamespace; - -// The following sample uses an HttpChannel constructor -// to create a new HttpChannel. -// NOTE: manually instantiating HttpChannel() and registering it does not seem -// necessary. This sample will work if the line of code is commented out. -// System::Runtime::Remoting::Channels.Http::HttpChannel.HttpChannel() -// -public ref class SampleClient: public MarshalByRefObject -{ -public: - void main() - { - ChannelServices::RegisterChannel( gcnew HttpChannel, false ); - RemotingConfiguration::RegisterWellKnownClientType( SampleService::typeid, "http://localhost:9000/MySampleService/SampleService::soap" ); - SampleService ^ service = gcnew SampleService; - service->SampleMethod(); - } - -}; - - -// actual entry point -int main() -{ - SampleClient^ p = gcnew SampleClient; - p->main(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/makefile deleted file mode 100644 index d4e70c2e1d14a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/makefile +++ /dev/null @@ -1,19 +0,0 @@ -all : client.exe client2.exe server.exe server2.exe - - -client.exe : client.cpp service.dll - cl /clr:pure client.cpp - -client2.exe : client2.cpp service.dll - cl /clr:pure client.cpp - -server.exe : server.cpp service.dll - cl /clr:pure server.cpp - -server2.exe : server2.cpp service.dll - cl /clr:pure server2.cpp - -service.dll : service.cpp - cl /LD /clr:pure service.cpp - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/server.cpp deleted file mode 100644 index 6e1b41e8078e2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/server.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; -using namespace SampleNamespace; - -// This assembly contains a remote service and its server host wrapped together. -int main() -{ - - // The following sample uses an HttpChannel constructor - // to create a new HttpChannel that will listen on port 9000. - // System::Runtime::Remoting::Channels.Http::HttpChannel.HttpChannel(int) - // System::Runtime::Remoting::Channels.Http::HttpChannel - // - HttpChannel^ channel = gcnew HttpChannel( 9000 ); - ChannelServices::RegisterChannel( channel, false ); - RemotingConfiguration::RegisterWellKnownServiceType( SampleNamespace::SampleService::typeid, "MySampleService/SampleService::soap", WellKnownObjectMode::Singleton ); - Console::WriteLine( "** Press enter to end the server process. **" ); - Console::ReadLine(); - // - - return 0; -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/server2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/server2.cpp deleted file mode 100644 index 596d3b490b1de..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/server2.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Collections::Specialized; -using namespace SampleNamespace; - -// This assembly contains a remote service and its server host wrapped together. -int main() -{ - - // The following sample uses an HttpChannel constructor - // to create a new HttpChannel that will listen on port 9000. - // System::Runtime::Remoting::Channels.Http::HttpChannel.HttpChannel(IDictionary*, IClientChannelSinkProvider*, IServerChannelSinkProvider*); - // - ListDictionary^ channelProperties = gcnew ListDictionary; - channelProperties->Add( "port", 9000 ); - HttpChannel^ channel = gcnew HttpChannel( channelProperties,gcnew SoapClientFormatterSinkProvider,gcnew SoapServerFormatterSinkProvider ); - ChannelServices::RegisterChannel( channel, false ); - RemotingConfiguration::RegisterWellKnownServiceType(SampleNamespace::SampleService::typeid, "MySampleService/SampleService::soap", WellKnownObjectMode::Singleton ); - Console::WriteLine( "** Press enter to end the server process. **" ); - Console::ReadLine(); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/service.cpp deleted file mode 100644 index 7625518a511b7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpChannel/CPP/service.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; - -namespace SampleNamespace -{ - // Define the event arguments - [Serializable] - public ref class SampleServiceEventArgs: public EventArgs - { - private: - String^ m_Message; - - public: - SampleServiceEventArgs( String^ message ) - { - m_Message = message; - } - - property String^ Message - { - String^ get() - { - return m_Message; - } - } - }; - - // Define the delegate for the event - public delegate void SomethingHappenedEventHandler(Object^ sender, SampleServiceEventArgs^ e ); - - // Define the remote service class - public ref class SampleService: public MarshalByRefObject - { - // The client will subscribe and unsubscribe to this event - public: - event SomethingHappenedEventHandler^ SomethingHappened; - - bool SampleMethod() - { - Console::WriteLine( "Hello, you have called SampleMethod()." ); - - // Fire Event - // Package String in TimerServiceEventArgs - SampleServiceEventArgs^ sampleEventArgs = gcnew SampleServiceEventArgs( "Something happened" ); - Console::WriteLine( "Firing SomethingHappened Event" ); - SomethingHappened( this, sampleEventArgs ); - - return true; - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpGetClientProtocol_Constructor/CPP/httpgetclientprotocol_constructor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpGetClientProtocol_Constructor/CPP/httpgetclientprotocol_constructor.cpp deleted file mode 100644 index 4b14e0f5e34a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpGetClientProtocol_Constructor/CPP/httpgetclientprotocol_constructor.cpp +++ /dev/null @@ -1,77 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -// System.Web.Services.Protocols.HttpGetClientProtocol.HttpGetClientProtocol -/* The following example demonstrates 'Constructor' of 'HttpGetClientProtocol' class -A variable of type 'HttpGetClientProtocol' is used to set proxy information , -client credentials and Url on the proxy class. -*/ -/* -// The following example is a proxy class generated by the Wsdl.exe -// utility for the Math Web service. The proxy class derives from -// HttpGetClientProtocol, which derives from the abstract -// HttpSimpleClientProtocol class. - -public class MyMath : System.Web.Services.Protocols.HttpGetClientProtocol -{ -[System.Diagnostics.DebuggerStepThroughAttribute()] -public MyMath() -{ -this.Url = "http://localhost/MyMath.Cs.asmx"; -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.Web.Services.Protocols.HttpMethodAttribute( -typeof(System.Web.Services.Protocols.XmlReturnReader), -typeof(System.Web.Services.Protocols.UrlParameterWriter))] -[return: System.Xml.Serialization.XmlRootAttribute("int", -Namespace="http://tempuri.org/", IsNullable=false)] -public int Add(string num1, string num2) -{ -return ((int)(this.Invoke("Add", (this.Url + "/Add"), new object[] { -num1, -num2}))); -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -public System.IAsyncResult BeginAdd(string num1, string num2, -System.AsyncCallback callback, object asyncState) -{ -return this.BeginInvoke("Add", (this.Url + "/Add"), new object[] { -num1, -num2}, callback, asyncState); -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -public int EndAdd(System.IAsyncResult asyncResult) -{ -return ((int)(this.EndInvoke(asyncResult))); -} -} -*/ -public ref class Math: public HttpGetClientProtocol{}; - -int main() -{ - - // - // Math is a proxy class derived from HttpGetClientProtocol. - HttpGetClientProtocol^ myHttpGetClientProtocol = gcnew ::Math; - - // Obtain password from a secure store. - String^ SecurelyStoredPassword = String::Empty; - - // Set the client-side credentials using the Credentials property. - ICredentials^ credentials = gcnew NetworkCredential( "Joe","mydomain",SecurelyStoredPassword ); - myHttpGetClientProtocol->Credentials = credentials; - Console::WriteLine( "Auto redirect is: {0}", myHttpGetClientProtocol->AllowAutoRedirect ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpPostClientProtocol_Constructor/CPP/httppostclientprotocol_constructor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpPostClientProtocol_Constructor/CPP/httppostclientprotocol_constructor.cpp deleted file mode 100644 index b09c48ea156f0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpPostClientProtocol_Constructor/CPP/httppostclientprotocol_constructor.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -// System.Web.Services.Protocols.HttpPostClientProtocol.HttpPostClientProtocol -/* The following example demonstrates 'Constructor' of 'HttpPostClientProtocol' class -A variable of type 'HttpPostClientProtocol' is used to set proxy information , -client credentials and Url on the proxy class. -*/ -/* -// The following example is a proxy class generated by the Wsdl.exe utility -// for the Math Web service. The proxy class derives from -// HttpPostClientProtocol, which derives from the abstract -// HttpSimpleClientProtocol class. - -public class MyMath : System.Web.Services.Protocols.HttpPostClientProtocol -{ -[System.Diagnostics.DebuggerStepThroughAttribute()] -public MyMath() -{ -this.Url = "http://localhost/Mymath.Cs.asmx"; -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.Web.Services.Protocols.HttpMethodAttribute( -typeof(System.Web.Services.Protocols.XmlReturnReader), -typeof(System.Web.Services.Protocols.HtmlFormParameterWriter))] -[return: System.Xml.Serialization.XmlRootAttribute("int", -Namespace="http://tempuri.org/", IsNullable=false)] -public int Add(string num1, string num2) -{ -return ((int)(this.Invoke("Add", (this.Url + "/Add"), -new object[] {num1, num2}))); -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -public System.IAsyncResult BeginAdd(string num1, string num2, -System.AsyncCallback callback, object asyncState) -{ -return this.BeginInvoke("Add", (this.Url + "/Add"), -new object[] {num1, num2}, callback, asyncState); -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -public int EndAdd(System.IAsyncResult asyncResult) -{ -return ((int)(this.EndInvoke(asyncResult))); -} -} -*/ -public ref class Math: public HttpPostClientProtocol{}; - -int main() -{ - - // - // Math is a proxy class derived from HttpPostClientProtocol. - HttpPostClientProtocol^ myHttpPostClientProtocol = gcnew ::Math; - - // Obtain password from a secure store. - String^ SecurelyStoredPassword = String::Empty; - - // Set the client-side credentials using the Credentials property. - myHttpPostClientProtocol->Credentials = System::Net::CredentialCache::DefaultCredentials; - - // Allow the server to redirect the request. - myHttpPostClientProtocol->AllowAutoRedirect = true; - Console::WriteLine( "Auto redirect is: {0}", myHttpPostClientProtocol->AllowAutoRedirect ); - - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/HttpServerChannel_Clientl_14_Share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/HttpServerChannel_Clientl_14_Share.cpp deleted file mode 100644 index 16b3761c1b635..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/HttpServerChannel_Clientl_14_Share.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* This program will define the methods to execute from the client. - */ -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; - -public ref class MyHelloServer : public MarshalByRefObject -{ -public: - MyHelloServer() - { - Console::WriteLine("HelloServer activated"); - } - -public: - String^ myHelloMethod(String^ name) - { - Console::WriteLine("Hello.HelloMethod : {0}", name); - return "Hi there " + name; - } -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/httpclientchannel_6_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/httpclientchannel_6_client.cpp deleted file mode 100644 index b891e831c59cf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/httpclientchannel_6_client.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// System.Runtime.Remoting.Channels.Http.HttpClientChannel -// System.Runtime.Remoting.Channels.Http.HttpClientChannel.ChannelName; System.Runtime.Remoting.Channels.Http.HttpClientChannel.ChannelPriority; System.Runtime.Remoting.Channels.Http.HttpClientChannel.Parse(); System.Runtime.Remoting.Channels.Http.HttpClientChannel.Keys; System.Runtime.Remoting.Channels.Http.HttpClientChannel.CreateMessageSink() -/* -The following program demonstrates the 'HttpClientChannel' class and -'ChannelName','ChannelPriority' , 'Keys', properties, and 'Parse', -CreateMessageSink methods of 'HttpClientChannel' class. This program -create and registers 'HttpClientChannel'. This will change the priority -of the 'HttpClientChannel' channel and it displays the property values -of 'HttpClientChannel'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Collections; -using namespace System::Runtime::Remoting::Messaging; - -int main() -{ - try - { - // - // Creating the 'IDictionary' to set the server object properties. - IDictionary^ myDictionary = gcnew Hashtable; - myDictionary[ "name" ] = "HttpClientChannel"; - myDictionary[ "priority" ] = 2; - - // Set the properties along with the constructor. - HttpClientChannel^ myHttpClientChannel = gcnew HttpClientChannel( myDictionary,gcnew BinaryClientFormatterSinkProvider ); - - // Register the server channel. - ChannelServices::RegisterChannel( myHttpClientChannel ); - MyHelloServer ^ myHelloServer1 = dynamic_cast(Activator::GetObject( MyHelloServer::typeid, "http://localhost:8085/SayHello" )); - if ( myHelloServer1 == nullptr ) - System::Console::WriteLine( "Could not locate server" ); - else - { - Console::WriteLine( myHelloServer1->myHelloMethod( "Client" ) ); - - // Get the name of the channel. - Console::WriteLine( "Channel Name :{0}", myHttpClientChannel->ChannelName ); - - // Get the channel priority. - Console::WriteLine( "ChannelPriority :{0}", myHttpClientChannel->ChannelPriority ); - String^ myString; - String^ myObjectURI1; - Console::WriteLine( "Parse :{0}{1}", myHttpClientChannel->Parse( "http://localhost:8085/SayHello", myString ), myString ); - - // Get the key count. - System::Console::WriteLine( "Keys->Count : {0}", myHttpClientChannel->Keys->Count ); - - // Get the channel message sink that delivers message to the specified url. - IMessageSink^ myIMessageSink = myHttpClientChannel->CreateMessageSink( "http://localhost:8085/NewEndPoint", nullptr, myObjectURI1 ); - Console::WriteLine( "The channel message sink that delivers the messages to the URL is : {0}", myIMessageSink ); - Console::WriteLine( "URI of the new channel message sink is: {0}", myObjectURI1 ); - } - // - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception is raised on client side :{0}", ex->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/httpserverchannel_9_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/httpserverchannel_9_server.cpp deleted file mode 100644 index e7549bfa2db6c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/httpserverchannel_9_server.cpp +++ /dev/null @@ -1,84 +0,0 @@ - - -// System.Runtime.Remoting.Channels.Http.HttpServerChannel -// System.Runtime.Remoting.Channels.Http.HttpServerChannel.StartListening(); System.Runtime.Remoting.Channels.Http.HttpServerChannel.ChannelName; System.Runtime.Remoting.Channels.Http.HttpServerChannel.ChannelPriority; System.Runtime.Remoting.Channels.Http.HttpServerChannel.ChannelScheme; System.Runtime.Remoting.Channels.Http.HttpServerChannel.GetChannelUri(); System.Runtime.Remoting.Channels.Http.HttpServerChannel.WantsToListen -// System.Runtime.Remoting.Channels.Http.HttpServerChannel.Parse(); System.Runtime.Remoting.Channels.Http.HttpServerChannel.StopListening() -/* The following program demonstrates the 'HttpServerChannel' class, 'ChannelName', -'ChannelPriority', 'ChannelScheme', 'WantsToListen' properties, 'GetChannelUri', -'StartListening', 'StopListening' and 'Parse' methods of 'HttpServerChannel' class. -This program creates and registers 'HttpServerChannel'. This will change the priority -of the 'HttpServerChannel' channel and displays the property values of this class. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -int main() -{ - try - { - String^ myString; - - // - int myPort = 8085; - - // Creating the 'IDictionary' to set the server object properties. - IDictionary^ myDictionary = gcnew Hashtable; - myDictionary[ "name" ] = "MyServerChannel1"; - myDictionary[ "priority" ] = 2; - myDictionary[ "port" ] = 8085; - - // Set the properties along with the constructor. - HttpServerChannel^ myHttpServerChannel = gcnew HttpServerChannel( myDictionary,gcnew BinaryServerFormatterSinkProvider ); - - // Register the server channel. - ChannelServices::RegisterChannel( myHttpServerChannel ); - RemotingConfiguration::RegisterWellKnownServiceType( MyHelloServer::typeid, "SayHello", WellKnownObjectMode::SingleCall ); - myHttpServerChannel->WantsToListen = true; - - // Start listening on a specific port. - myHttpServerChannel->StartListening( myPort ); - - // Get the name of the channel. - Console::WriteLine( "ChannelName : {0}", myHttpServerChannel->ChannelName ); - - // Get the channel priority. - Console::WriteLine( "ChannelPriority : {0}", myHttpServerChannel->ChannelPriority ); - - // Get the schema of the channel. - Console::WriteLine( "ChannelScheme : {0}", myHttpServerChannel->ChannelScheme ); - - // Get the channel URI. - Console::WriteLine( "GetChannelUri : {0}", myHttpServerChannel->GetChannelUri() ); - - // Indicates whether 'IChannelReceiverHook' wants to be hooked into the outside listener service. - Console::WriteLine( "WantsToListen : {0}", myHttpServerChannel->WantsToListen ); - // - - // - // Extract the channel URI and the remote well known object URI from the specified URL. - Console::WriteLine( "Parsed : {0}", myHttpServerChannel->Parse( String::Concat( myHttpServerChannel->GetChannelUri(), "/SayHello" ), myString ) ); - Console::WriteLine( "Remote WellKnownObject : {0}", myString ); - Console::WriteLine( "Hit to stop listening..." ); - Console::ReadLine(); - - // Stop listening to channel. - myHttpServerChannel->StopListening( myPort ); - // - - Console::WriteLine( "Hit to exit..." ); - Console::ReadLine(); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception is raised on server side : {0}", ex->Message ); - } - -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/makefile deleted file mode 100644 index 54468753cc4ba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpServerChannel_Server_Client/CPP/makefile +++ /dev/null @@ -1,11 +0,0 @@ - -all: HttpServerChannel_Client.exe HttpServerChannel_Server.exe - -HttpServerChannel_Client.exe: HttpClientChannel_6_Client.cpp HttpServerChannel_Share.dll - cl /clr:pure HttpClientChannel_6_Client.cpp - -HttpServerChannel_Server.exe: HttpServerChannel_9_Server.cpp HttpServerChannel_Share.dll - cl /clr:pure HttpServerChannel_9_Server.cpp - -HttpServerChannel_Share.dll: HttpServerChannel_Clientl_14_Share.cpp - cl /clr:pure /LD HttpServerChannel_Clientl_14_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpSimpleClientProtocol.Invoke Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpSimpleClientProtocol.Invoke Example/CPP/source.cpp deleted file mode 100644 index 6553b346e86e4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpSimpleClientProtocol.Invoke Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -namespace MyMath -{ - - [System::Web::Services::WebServiceBindingAttribute(Name="MathSoap",Namespace="http://tempuri.org/")] - public ref class Math: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - Math() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int num1, int num2 ) - { - array^temp0 = {num1,num2}; - array^results = this->Invoke( "Add", temp0 ); - return *dynamic_cast(results[ 0 ]); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {num1,num2}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } - - }; - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp deleted file mode 100644 index 234d931c473f4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/*System::Net::HttpVersion::Version10 -This program demonstrates the 'Version10' field of the 'HttpVersion' Class. -The 'ProtocolVersion' property of 'HttpWebrequest' class identifies the Version of the Protocol being used. -A new 'HttpWebRequest' Object* is created. -Then the default value of 'ProtocolVersion' property is displayed to the console. -The 'Version10' field of the 'HttpVersion' class is assigned to the 'ProtocolVersion' property of the 'HttpWebRequest' Class. -The changed Version and the 'ProtocolVersion' of the response Object* are displayed. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.microsoft.com" ) ); - Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol before assignment is : {0}", myHttpWebRequest->ProtocolVersion ); - // Assign Version10 to ProtocolVersion. - myHttpWebRequest->ProtocolVersion = HttpVersion::Version10; - // Assign the response Object* of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol after assignment is : {0}", myHttpWebRequest->ProtocolVersion ); - Console::WriteLine( "\nThe 'ProtocolVersion' of the response Object* is : {0}", myHttpWebResponse->ProtocolVersion ); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue.............." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - Console::WriteLine( "Source : {0} ", e->Source ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebClientProtocol_UserAgent/CPP/httpwebclientprotocol_useragent.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebClientProtocol_UserAgent/CPP/httpwebclientprotocol_useragent.cpp deleted file mode 100644 index 2b454542d5a13..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebClientProtocol_UserAgent/CPP/httpwebclientprotocol_useragent.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; -using namespace System::Xml; - -// System.Web.Services.Protocols.HttpWebClientProtocol.UserAgent -/* The following example demonstrates 'UserAgent' member of 'HttpWebClientProtocol' -class. First the default user agent is displayed. Then the user agent is modified -and displayed. -*/ -/* -The following example is a proxy class generated by the Wsdl.exe utility -for the Math Web service. The proxy class derives from SoapHttpClientProtocol, -which derives from the abstract HttpWebClientProtocol class. - -[System.Web.Services.WebServiceBindingAttribute(Name="MyMathSoap", -Namespace="http://tempuri.org/")] -public class MyMath : System.Web.Services.Protocols.SoapHttpClientProtocol -{ -[System.Diagnostics.DebuggerStepThroughAttribute()] -public MyMath() -{ -this.Url = "http://localhost/Mymath.Cs.asmx"; -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.Web.Services.Protocols.SoapDocumentMethodAttribute( -"http://tempuri.org/Add", -Use=System.Web.Services.Description.SoapBindingUse.Literal, -ParameterStyle= -System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] -public int Add(int num1, int num2) -{ -object[] results = this.Invoke("Add", -new object[] {num1, num2}); -return ((int)(results[0])); -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -public System.IAsyncResult BeginAdd(int num1, int num2, -System.AsyncCallback callback, object asyncState) -{ -return this.BeginInvoke("Add", new object[] {num1, num2}, -callback, asyncState); -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -public int EndAdd(System.IAsyncResult asyncResult) -{ -object[] results = this.EndInvoke(asyncResult); -return ((int)(results[0])); -} -} -*/ -namespace test -{ - public ref class MyMath: public SoapHttpClientProtocol{}; - -} - -int main() -{ - - // - // MyMath is a proxy class. - test::MyMath^ objMyMath = gcnew test::MyMath; - - // Get the default user agent. - Console::WriteLine( "Default user agent is: {0}", objMyMath->UserAgent ); - objMyMath->UserAgent = "My Agent"; - Console::WriteLine( "Modified user agent is: {0}", objMyMath->UserAgent ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp deleted file mode 100644 index a478dd3224104..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* System::Net::HttpWebRequest::Accept -This program demonstrates 'Accept' property of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created.The 'Accept' property of 'HttpWebRequest' -class is set to 'image/*' that in turn sets the 'Accept' field of HTTP Request Headers to -S"image/*". HTTP Request and Response headers are displayed to the console. -The contents of the page of the requested URI are displayed to the console. -'Accept' property is set with an aim to receive the response in a specific format. - -Note:This program requires http://localhost/CodeSnippetTest::html as Command line parameter. -If the requested page contains any content other than 'image/*' an error of 'status (406) Not Acceptable' -is returned.The functionality of 'Accept' property is supported only by servers that use HTTP 1.1 -protocol.Please refer to RFC 2616 for further information on HTTP Headers. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -void GetPage( String^ myUri ) -{ - try - { -// - // Create a 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Set the 'Accept' property to accept an image of any type. - myHttpWebRequest->Accept = "image/*"; - // The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Console::WriteLine( "\nHTTP Request Headers :\n\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nHTTP Response Headers :\n\n {0}", myHttpWebResponse->Headers ); - Console::WriteLine( "Press 'Enter' Key to Continue......." ); - Console::Read(); - // Displaying the contents of the page to the console - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML page are......." ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - Console::WriteLine( "\nPress 'Enter' Key to Continue......" ); - Console::Read(); - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter" ); - Console::WriteLine( "Usage:HttpWebRequest_Accept http://www.microsoft.com/library/homepage/images/ms-banner.gif" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp deleted file mode 100644 index f2c721bf97992..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* System::Net::HttpWebRequest::AllowAutoRedirect System::Net::HttpWebRequest->Address -This program demonstrates 'AllowAutoRedirect' and 'Address' properties of 'HttpWebRequest' Class. -A new 'HttpWebRequest' Object* is created. The 'AllowAutoredirect' property which redirects a page automatically -to the new Uri is set to true.Using the 'Address' property, the address of the 'Responding Uri' is printed to -console.The contents of the redirected page are displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// -// - // Create a new HttpWebRequest Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest->MaximumAutomaticRedirections = 1; - myHttpWebRequest->AllowAutoRedirect = true; - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of Html Page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nThe Requested Uri is {0}", myHttpWebRequest->RequestUri ); - Console::WriteLine( "\nThe Actual Uri responding to the request is \n {0}", myHttpWebRequest->Address ); -// - Console::WriteLine( "\nPress any Key to Continue.........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp deleted file mode 100644 index da5e28f5284a1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*System::Net::HttpWebRequest::AllowWriteStreamBuffering -This program demonstrates 'AllowWriteStreamBuffering' property of 'HttpWebRequestClass'. -A new 'HttpWebRequest' Object* is created. -The 'AllowWriteStreamBuffering' property value is set to false. -If the 'AllowWriteStreamBuffering' is set to false, -then 'ContentLength' property should be set to the length of data to be posted before posting the data -else the Http Status(411) Length required is returned. -Data to be posted to the Uri is requested from the user. -The 'Method' property is set to POST to be able to post data to the Uri. -The 'GetRequestStream' method of the 'HttpWebRequest' class returns a stream Object*. -This stream Object* is used to write data to the Uri. -The HTML contents of the page are displayed to the console after the posted data is accepted by the URL - -Note:This program posts data to the Uri : http://www20.brinkster.com/codesnippets/next.asp. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' object to the mentioned Uri. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com/codesnippets/next.asp" ) ); - // Set AllowWriteStreamBuffering to 'false'. - myHttpWebRequest->AllowWriteStreamBuffering = false; - Console::WriteLine( "\nPlease Enter the data to be posted to the (http://www.contoso.com/codesnippets/next.asp) uri:" ); - String^ inputData = Console::ReadLine(); - String^ postData = String::Concat( "firstone= ", inputData ); - // Set 'Method' property of 'HttpWebRequest' class to POST. - myHttpWebRequest->Method = "POST"; - ASCIIEncoding^ encodedData = gcnew ASCIIEncoding; - array^ byteArray = encodedData->GetBytes( postData ); - // Set 'ContentType' property of the 'HttpWebRequest' class to S"application/x-www-form-urlencoded". - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - // If the AllowWriteStreamBuffering property of HttpWebRequest is set to false, the contentlength has to be set to length of data to be posted else Exception(411) is raised. - myHttpWebRequest->ContentLength = byteArray->Length; - Stream^ newStream = myHttpWebRequest->GetRequestStream(); - newStream->Write( byteArray, 0, byteArray->Length ); - newStream->Close(); - Console::WriteLine( "\nData has been posted to the Uri\n\nPlease wait for the response.........." ); - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' Key to Continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - Console::WriteLine( "\n(The 'ContentLength' property of 'HttpWebRequest' is not set after 'AllowWriteStreamBuffering' is set to 'false'.)" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp deleted file mode 100644 index 36c811102e472..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* System::Net::HttpWebRequest::BeginGetRequestStream, System::Net::HttpWebRequest::EndGetRequestStream - -This program demonstrates 'BeginGetRequestStream' and 'EndGetRequestStream' methods of 'HttpWebRequest' class. -A new 'HttpWebRequest' Object is created .The 'Method' property of the 'HttpWebRequest' Object* is set to -'POST'.The 'ContentType' property is set to S"application/x-www-form-urlencoded".Then 'BeginGetRequestStream' -method of 'HttpWebRequest' class starts the Asynchronous writing to the 'HttpWebRequest' Object*. The -'EndGetRequestStream' method of 'HttpWebRequest' class ends the Asynchronous writing of data and returns a -stream Object*.The 'Stream' Object* is used to write data to the 'HttpWebRequest' Object*. - -Note: This program POSTs data to the Uri: http://www20.Brinkster::com/codesnippets/next.asp -*/ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -ref class HttpWebRequestBeginGetRequest -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void Main() - { - - // - // Create a new HttpWebRequest object. - HttpWebRequest^ request = dynamic_cast(WebRequest::Create( "http://www.contoso.com/example.aspx" )); - - // Set the ContentType property. - request->ContentType = "application/x-www-form-urlencoded"; - - // Set the Method property to 'POST' to post data to the Uri. - request->Method = "POST"; - - // Start the asynchronous operation. - AsyncCallback^ del = gcnew AsyncCallback(GetRequestStreamCallback); - request->BeginGetRequestStream( del, request ); - - // Keep the main thread from continuing while the asynchronous - // operation completes. A real world application - // could do something useful such as updating its user interface. - allDone->WaitOne(); - } - - -private: - static void GetRequestStreamCallback(IAsyncResult^ asynchronousResult) - { - HttpWebRequest^ request = dynamic_cast(asynchronousResult->AsyncState); - - // End the operation - Stream^ postStream = request->EndGetRequestStream(asynchronousResult); - - Console::WriteLine("Please enter the input data to be posted:"); - String^ postData = Console::ReadLine(); - - // Convert the string into a byte array. - array^ByteArray = Encoding::UTF8->GetBytes(postData); - - // Write to the request stream. - postStream->Write(ByteArray, 0, postData->Length); - postStream->Close(); - - // Start the asynchronous operation to get the response - AsyncCallback^ del = gcnew AsyncCallback(GetResponseCallback); - request->BeginGetResponse(del, request); - } - - static void GetResponseCallback(IAsyncResult^ asynchronousResult) - { - HttpWebRequest^ request = dynamic_cast(asynchronousResult->AsyncState); - - // End the operation - HttpWebResponse^ response = dynamic_cast(request->EndGetResponse(asynchronousResult)); - Stream^ streamResponse = response->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader(streamResponse); - String^ responseString = streamRead->ReadToEnd(); - Console::WriteLine(responseString); - // Close the stream object - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse - response->Close(); - allDone->Set(); - } - // -}; - -void main() -{ - HttpWebRequestBeginGetRequest::Main(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetResponse/CPP/httpwebrequest_begingetresponse.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetResponse/CPP/httpwebrequest_begingetresponse.cpp deleted file mode 100644 index fb120510b57de..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetResponse/CPP/httpwebrequest_begingetresponse.cpp +++ /dev/null @@ -1,158 +0,0 @@ - - -// System::Net::HttpWebRequest::BeginGetResponse System::Net::HttpWebRequest::EndGetResponse -/** -* Snippet1, Snippet2, Snippet3 go together. -* This program shows how to use BeginGetResponse and EndGetResponse methods of the -* HttpWebRequest class. -* It uses an asynchronous approach to get the response for the HTTP Web Request. -* The RequestState class is defined to chekc the state of the request. -* After a HttpWebRequest Object* is created, its BeginGetResponse method is used to start -* the asynchronous response phase. -* Finally, the EndGetResponse method is used to end the asynchronous response phase . -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -public ref class RequestState -{ -private: - - // This class stores the State of the request. - const int BUFFER_SIZE; - -public: - StringBuilder^ requestData; - array^BufferRead; - HttpWebRequest^ request; - HttpWebResponse^ response; - Stream^ streamResponse; - RequestState() - : BUFFER_SIZE( 1024 ) - { - BufferRead = gcnew array(BUFFER_SIZE); - requestData = gcnew StringBuilder( "" ); - request = nullptr; - streamResponse = nullptr; - } - -}; - -ref class HttpWebRequest_BeginGetResponse -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static int BUFFER_SIZE = 1024; - - // - // - static void RespCallback( IAsyncResult^ asynchronousResult ) - { - try - { - - // State of request is asynchronous. - RequestState^ myRequestState = dynamic_cast(asynchronousResult->AsyncState); - HttpWebRequest^ myHttpWebRequest2 = myRequestState->request; - myRequestState->response = dynamic_cast(myHttpWebRequest2->EndGetResponse( asynchronousResult )); - - // Read the response into a Stream object. - Stream^ responseStream = myRequestState->response->GetResponseStream(); - myRequestState->streamResponse = responseStream; - - // Begin the Reading of the contents of the HTML page and print it to the console. - IAsyncResult^ asynchronousInputRead = responseStream->BeginRead( myRequestState->BufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - - } - - static void ReadCallBack( IAsyncResult^ asyncResult ) - { - try - { - RequestState^ myRequestState = dynamic_cast(asyncResult->AsyncState); - Stream^ responseStream = myRequestState->streamResponse; - int read = responseStream->EndRead( asyncResult ); - - // Read the HTML page and then print it to the console. - if ( read > 0 ) - { - myRequestState->requestData->Append( Encoding::ASCII->GetString( myRequestState->BufferRead, 0, read ) ); - IAsyncResult^ asynchronousResult = responseStream->BeginRead( myRequestState->BufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - } - else - { - Console::WriteLine( "\nThe contents of the Html page are : " ); - if ( myRequestState->requestData->Length > 1 ) - { - String^ stringContent; - stringContent = myRequestState->requestData->ToString(); - Console::WriteLine( stringContent ); - } - Console::WriteLine( "Press any key to continue.........." ); - Console::ReadLine(); - responseStream->Close(); - allDone->Set(); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - - } - -}; - -int main() -{ - try - { - - // Create a HttpWebrequest object to the desired URL. - HttpWebRequest^ myHttpWebRequest1 = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - - // Create an instance of the RequestState and assign the previous myHttpWebRequest1 - // object to its request field. - RequestState^ myRequestState = gcnew RequestState; - myRequestState->request = myHttpWebRequest1; - - // Start the asynchronous request. - IAsyncResult^ result = dynamic_cast(myHttpWebRequest1->BeginGetResponse( gcnew AsyncCallback( HttpWebRequest_BeginGetResponse::RespCallback ), myRequestState )); - HttpWebRequest_BeginGetResponse::allDone->WaitOne(); - - // Release the HttpWebResponse resource. - myRequestState->response->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - Console::WriteLine( "Press any key to continue.........." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - Console::WriteLine( "Press any key to continue.........." ); - Console::Read(); - } - -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp deleted file mode 100644 index 9db4b0b725965..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp +++ /dev/null @@ -1,94 +0,0 @@ - - -// System::Net::HttpWebRequest::KeepAlive System::Net::HttpWebRequest::Connection -/** -* This program demonstrates Connection and KeepAlive properties of the -* HttpWebRequest Class. -* Two new HttpWebRequest objects are created . The KeepAlive property of one of -* the objects is set to false that in turn sets the value of Connection field of -* the HTTP request Headers to Close. -* The Connection property of the other HttpWebRequest Object* is assigned the -* value Close. This throws an ArgumentException which is caught.The HTTP request -* Headers are displayed to the console. -* The contents of the HTML page of the requested URI are displayed. -**/ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -// -int main() -{ - try - { - - // Create a new HttpWebRequest object. Make sure that - // a default proxy is set if you are behind a firewall. - HttpWebRequest^ myHttpWebRequest1 = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - myHttpWebRequest1->KeepAlive = false; - - // Assign the response object of HttpWebRequest to a HttpWebResponse variable. - HttpWebResponse^ myHttpWebResponse1 = dynamic_cast(myHttpWebRequest1->GetResponse()); - Console::WriteLine( "\nThe HTTP request Headers for the first request are: \n {0}", myHttpWebRequest1->Headers ); - Console::WriteLine( "Press Enter Key to Continue.........." ); - Console::Read(); - Stream^ streamResponse = myHttpWebResponse1->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "The contents of the Html page are.......\n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - Console::WriteLine(); - - // Close the Stream object. - streamResponse->Close(); - streamRead->Close(); - - // Release the resources held by response object. - myHttpWebResponse1->Close(); - - // - // Create a new HttpWebRequest object for the specified Uri. - HttpWebRequest^ myHttpWebRequest2 = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - myHttpWebRequest2->Connection = "Close"; - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse2 = dynamic_cast(myHttpWebRequest2->GetResponse()); - - // Release the resources held by response object. - myHttpWebResponse2->Close(); - Console::WriteLine( "\nThe Http RequestHeaders are \n {0}", myHttpWebRequest2->Headers ); - - // - Console::WriteLine( "\nPress 'Enter' Key to Continue........." ); - Console::Read(); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( "\nThe second HttpWebRequest Object* has raised an Argument Exception as 'Connection' Property is set to 'Close'" ); - Console::WriteLine( "\n {0}", e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp deleted file mode 100644 index 6aeaaef1467a3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -System::Net::HttpWebRequest::Method, System::Net::HttpWebRequest::ContentLength, System::Net::HttpWebRequest::ContentType -System::Net::HttpWebRequest::GetRequestStream -This program demonstrates 'Method', 'ContentLength' and 'ContentType' properties and 'GetRequestStream' -method of HttpWebRequest Class. -It creates a 'HttpWebRequest' Object*.The 'Method' property of 'HttpWebRequestClass' is set to 'POST'. -The 'ContentType' property is set to 'application/x-www-form-urlencoded'.The 'ContentLength' property -is set to the length of the Byte stream to be posted.A new 'Stream' Object* is obtained from the -'GetRequestStream' method of the 'HttpWebRequest' class. Data to be posted is requested from the user. -Data is posted using the stream Object*.The HTML contents of the page are then displayed to the console -after the Posted data is accepted by the URL. -Note: This program POSTs data to the Uri: http://www20.Brinkster::com/codesnippets/next.asp -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { - // Create a new WebRequest Object to the mentione Uri. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com/codesnippets/next.asp" ) ); - - Console::WriteLine( "\nThe value of 'ContentLength' property before sending the data is {0}", myHttpWebRequest->ContentLength ); - -// -// - // Set the 'Method' property of the 'Webrequest' to 'POST'. - myHttpWebRequest->Method = "POST"; - Console::WriteLine( "\nPlease enter the data to be posted to the (http://www.contoso.com/codesnippets/next.asp) Uri :" ); - - // Create a new String* Object* to POST data to the Url. - String^ inputData = Console::ReadLine(); - -// -// - String^ postData = String::Concat( "firstone= ", inputData ); - ASCIIEncoding^ encoding = gcnew ASCIIEncoding; - array^ byte1 = encoding->GetBytes( postData ); - - // Set the content type of the data being posted. - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - - // Set the content length of the String* being posted. - myHttpWebRequest->ContentLength = byte1->Length; - - Stream^ newStream = myHttpWebRequest->GetRequestStream(); - - newStream->Write( byte1, 0, byte1->Length ); - Console::WriteLine( "The value of 'ContentLength' property after sending the data is {0}", myHttpWebRequest->ContentLength ); - - // Close the Stream Object*. - newStream->Close(); -// -// -// -// - Console::WriteLine( "\nThe String* entered is successfully posted to the Uri " ); - Console::WriteLine( "Please wait for the response......." ); - - // Assign the response Object* of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - - Console::WriteLine( "\nThe contents of the HTML page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - - // Close the Stream object. - streamResponse->Close(); - streamRead->Close(); - - // Release the resources held by response Object*. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' Key to Continue............." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp deleted file mode 100644 index dbc0defcc7fbf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*System::Net::HttpWebRequest::Headers -This program demonstrates the 'Headers' property of 'HttpWebRequest' Class. -A new 'HttpWebRequest' Object* is created. -The (name, value) collection of the Http Headers are displayed to the console. -The contents of the HTML page of the requested URI are displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nThe HttpHeaders are \n\n\tName\t\tValue\n {0}", myHttpWebRequest->Headers ); - // Print the HTML contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe HTML contents of page the are : \n\n " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - Console::WriteLine( "Status : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp deleted file mode 100644 index 2ffbd73948e29..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp +++ /dev/null @@ -1,90 +0,0 @@ - - -/* -System::Net::HttpWebRequest::IfModifiedSince -This program demonstrates the 'IfModifiedSince' property of the 'HttpWebRequest' class . -A new 'HttpWebrequest' Object* is created. -A new 'DateTime' Object* is created with the value intialized to the present DateTime. -The 'IfModifiedSince' property of 'HttpWebRequest' Object* is compared with the 'DateTime' Object*. -If the requested page has been modified since the time of the DateTime Object* -then the output displays the page has been modified -else the response headers and the contents of the page of the requested Uri are printed to the Console. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -int main() -{ - try - { - - // - // Create a new 'Uri' object with the mentioned string. - Uri^ myUri = gcnew Uri( "http://www.contoso.com" ); - - // Create a new 'HttpWebRequest' object with the above 'Uri' object. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( myUri )); - - // Create a new 'DateTime' object. - DateTime targetDate = DateTime::Now; - // Set a target date of a week ago - targetDate.AddDays(-7.0); - myHttpWebRequest->IfModifiedSince = targetDate; - - try - { - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - Console::WriteLine( "Response headers \n {0}\n", myHttpWebResponse->Headers ); - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of Html Page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' key to continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - if (e->Response) - { - if ( ((HttpWebResponse ^)e->Response)->StatusCode == HttpStatusCode::NotModified) - Console::WriteLine("\nThe page has not been modified since {0}", targetDate); - else - Console::WriteLine("\nUnexpected status code = {0}", ((HttpWebResponse ^)e->Response)->StatusCode); - } - else - Console::WriteLine("\nUnexpected Web Exception {0}" + e->Message); - } -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp deleted file mode 100644 index 86bf537bd95f5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*Sytem::Net.HttpWebRequest::PipeLined -This program demonstrates 'Pipelined' property of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created.The 'Pipelined' property is displayed to the console. -HTTP Request and Response Headers are displayed to the console.The contents of the page of the -requested URI are displayed to the console. - -Note:The 'Pipelined' property is supported only by servers that allow Pipelining of requests. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -void GetPage( String^ myUri ) -{ - try - { -// - // Create a 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML page are......." ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - Console::WriteLine( "\nHTTP Request Headers :\n\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nHTTP Response Headers :\n\n {0}", myHttpWebResponse->Headers ); - streamRead->Close(); - streamResponse->Close(); - // Release the response object resources. - myHttpWebResponse->Close(); - Console::WriteLine( "\n'Pipelined' property is: {0}", myHttpWebRequest->Pipelined ); - Console::WriteLine( "\nPress 'Enter' Key to Continue......" ); - Console::Read(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter:" ); - Console::WriteLine( "->Item[ Usage:HttpWebRequest_Pipelined http://www.microsoft.com ]" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp deleted file mode 100644 index 94eeccc8582d1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* System::Net::HttpWebRequest::ProtocolVersion -This Program demonstrates the 'ProtocolVersion' property of the 'HttpWebRequest' Class. -The 'ProtocolVersion' is a property that identifies the Version of the Protocol being used. -A new 'HttpWebRequest' Object* is created.Then the default version, being used is displayed onto -the console.It is then set to another version and displayed to the Console::The HTML contents -of the page of the requested Uri are printed to the console. -Note:Here the 'ProtocolVersion' property displays the ProtocolVersion being used. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.microsoft.com" ) ); - // Use the existing 'ProtocolVersion' , and display it onto the console. - Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol used is {0}", myHttpWebRequest->ProtocolVersion ); - // Set the 'ProtocolVersion' property of the 'HttpWebRequest' to 'Version1::0' . - myHttpWebRequest->ProtocolVersion = HttpVersion::Version10; - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol changed to {0}", myHttpWebRequest->ProtocolVersion ); - Console::WriteLine( "\nThe protocol version of the response Object* is {0}", myHttpWebResponse->ProtocolVersion ); -// - Console::WriteLine( "\nPress any Key to Continue.............." ); - Console::Read(); - Console::Read(); - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the HTML Page are :" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress any Key to Continue.............." ); - Console::Read(); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised!" ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0} ", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp deleted file mode 100644 index c3349680bc95c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*System::Net::HttpWebRequest::Referer -This program demonstrates 'Referer' property of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created.The 'Referer' property is displayed to the console. -HTTP Request and Response Headers are displayed to the console.The contents of the page of the -requested URI are displayed to the console. - -Note:The 'Referer' property is used by the server to store the address of the Uri that has referred -the request to that server.Please refer to RFC 2616 for more information on HTTP Headers. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -void GetPage( String^ myUri ) -{ - try - { -// - // Create a 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Set referer property to http://www.microsoft.com . - myHttpWebRequest->Referer = "http://www.microsoft.com"; - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML page are......." ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - Console::WriteLine( "\nHTTP Request Headers :\n\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nHTTP Response Headers :\n\n {0}", myHttpWebResponse->Headers ); - streamRead->Close(); - streamResponse->Close(); - // Release the response object resources. - myHttpWebResponse->Close(); - Console::WriteLine( "Referer to the site is: {0}", myHttpWebRequest->Referer ); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue......" ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter" ); - Console::WriteLine( "->Item[ Usage:HttpWebRequest_Referer http://www.microsoft.com ]" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp deleted file mode 100644 index 9b34c1dbaf531..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -System::Net::HttpWebRequest::SendChunked -System::Net::HttpWebRequest::TransferEncoding -This program demonstrates 'TransferEncoding' and 'SendChunked' properties of 'HttpWebRequestClass'. -A new 'HttpWebRequest' Object* is created.The 'SendChunked' property value is set to 'true' and -'TransferEncoding' property is set to S"gzip".If 'TransferEncoding' property is set with 'SendChunked' -property set to 'false' then 'InvalidOperationException' is raised. Data to be posted to the Uri is -requested from the user.The HTML contents of the page are displayed to the console after the posted -data is accepted by the URL - -Note:This program requires http://localhost/CodeSnippetTest::asp as Command line parameter. -If the 'TransferEncoding' of type 'gzip' is not implemented by the server an error of status -'(501) Not implemented' is returned. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -void GetPage( String^ myUri ) -{ - try - { -// -// - // A new 'HttpWebRequest' object is created. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - myHttpWebRequest->SendChunked = true; - // 'TransferEncoding' property is set to 'gzip'. - myHttpWebRequest->TransferEncoding = "gzip"; - Console::WriteLine( "\nPlease Enter the data to be posted to the (http:///CodeSnippetTest::asp) uri:" ); - String^ inputData = Console::ReadLine(); - String^ postData = String::Concat( "testdata= ", inputData ); - // 'Method' property of 'HttpWebRequest' class is set to POST. - myHttpWebRequest->Method = "POST"; - ASCIIEncoding^ encodedData = gcnew ASCIIEncoding; - array^ byteArray = encodedData->GetBytes( postData ); - // 'ContentType' property of the 'HttpWebRequest' class is set to S"application/x-www-form-urlencoded". - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - // 'ContentLength' property is set to Length of the data to be posted. - myHttpWebRequest->ContentLength = byteArray->Length; - Stream^ newStream = myHttpWebRequest->GetRequestStream(); - newStream->Write( byteArray, 0, byteArray->Length ); - newStream->Close(); - Console::WriteLine( "\nData has been posted to the Uri\n\nPlease wait for the response.........." ); - // The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Displaying the contents of the page to the console - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the HTML page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); -// -// - Console::WriteLine( "\nPress 'Enter' Key to Continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter:" ); - Console::WriteLine( "[ Usage:HttpWebRequest_Sendchunked http:///CodeSnippetTest.asp ]" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp deleted file mode 100644 index b7c3ae94b7142..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*System::Net::HttpWebRequest::Time->Item[Out] This* program demonstrates 'Timeout' property of the HttpWebRequest Class. -A new HttpWebRequest Object is created .The default value of the 'Timeout' property is printed to the console. -It is then set to some value and displayed to the console. If the 'Timeout' property is set to a value less -than the time required to get the response an 'Exception' is raised. 'Timeout' property measures the time in -Milliseconds. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - Console::WriteLine( "\nThe timeout time of the request before setting the property is {0} milliseconds.", myHttpWebRequest->Timeout ); - // Set the 'Timeout' property of the HttpWebRequest to 10 milliseconds. - myHttpWebRequest->Timeout = 10; - // Display the 'Timeout' property of the 'HttpWebRequest' on the console. - Console::WriteLine( "\nThe timeout time of the request after setting the timeout is {0} milliseconds.", myHttpWebRequest->Timeout ); - // A HttpWebResponse object is created and is GetResponse Property of the HttpWebRequest associated with it - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the HTML page are, " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress any Key to Continue............." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised!" ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0} ", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp deleted file mode 100644 index 802ed95274d7d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*System::Net::HttpWebRequest::UserAgent -This program demonstrates 'UserAgent' property of 'HttpWebRequest' Class. -A new 'HttpWebRequest' Object* is created.The 'UserAgent' property is set to -"Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0; COM+ 1.0.2702)". -This inturn sets the 'User-Agent' field of HTTP Request headers. -The response is obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest->UserAgent = ".NET Framework Test Client"; - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML Page are :\n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); -// - Console::WriteLine( "\nHTTP Request Headers :\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nUserAgent is: {0}", myHttpWebRequest->UserAgent ); - Console::WriteLine( "\nPress 'Enter' Key to Continue..........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - Console::WriteLine( "Status : {0} ", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp deleted file mode 100644 index 4a3da3be11dfa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Net::HttpWebResponse::Close -/* This program demonstrates the 'Close' method of the 'HttpWebResponse' class. -It creates a web request and queries for a response.The response Object* can be processed as desired. -The program then closes the response Object* and releases resources associated with it. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - // Sends the HttpWebRequest and waits for a response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." ); - // Releases the resources of the response. - myHttpWebResponse->Close(); - Console::WriteLine( "\nResponse Stream successfully closed" ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_Close http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp deleted file mode 100644 index 38763c56e4167..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ -// - try - { - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - - Console::WriteLine( "The encoding method used is: {0}", myHttpWebResponse->ContentEncoding ); - Console::WriteLine( "The character set used is : {0}", myHttpWebResponse->CharacterSet ); - - char separator = '/'; - String^ contenttype = myHttpWebResponse->ContentType; - // Retrieve 'text' if the content type is of 'text/html. - String^ maintype = contenttype->Substring( 0, contenttype->IndexOf( separator ) ); - // Display only 'text' type. - if ( String::Compare( maintype, "text" ) == 0 ) - { - Console::WriteLine( "\n Content type is 'text'." ); -// - -// - Stream^ receiveStream = myHttpWebResponse->GetResponseStream(); - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - - Console::WriteLine( "\r\nResponse stream received." ); - array^ read = gcnew array(256); - - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "\nText retrieved from the URL follows:\r\n" ); - - int index = 0; - while ( index < myHttpWebResponse->ContentLength ) - { - // Dump the 256 characters on a string and display the string onto the console. - String^ str = gcnew String( read,0,count ); - Console::WriteLine( str ); - index += count; - count = readStream->Read( read, 0, 256 ); - } - receiveStream->Close(); - Console::WriteLine( "" ); - } - // Release the resources of response object. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_ContentLength_ContentType http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp deleted file mode 100644 index da0eb5ef001c4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// System::Net::HttpWebResponse::GetResponseHeader -/* This program demonstrates the 'GetResponseHeader' method of the 'HttpWebResponse' class -It creates a web request and queries for a response.If the site requires authentication it -will respond with a challenge String* which is extracted using 'GetResponse()' method. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ ourUri = gcnew Uri( url ); - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( ourUri ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nThe server did not issue any challenge. Please try again with a protected resource URL." ); - // Releases the resources of the response. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - HttpWebResponse^ response = (HttpWebResponse^)( e->Response ); - if ( response != nullptr ) - { - if ( response->StatusCode == HttpStatusCode::Unauthorized ) - { - String^ challenge = nullptr; - challenge = response->GetResponseHeader( "WWW-Authenticate" ); - if ( challenge != nullptr ) - Console::WriteLine( "\nThe following challenge was raised by the server: {0}", challenge ); - } - else - { - Console::WriteLine( "\nThe following WebException was raised : {0}", e->Message ); - } - } - else - { - Console::WriteLine( "\nResponse Received from server was 0" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter a protected resource url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_GetResponseHeader http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp deleted file mode 100644 index c489c6d0ddcc0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// System::Net::HttpWebResponse::GetResponseStream -/* This program demonstrates the 'GetResponseStream' method of the 'HttpWebResponse' class. -It creates a web request and queries for a response.It then gets the response stream . -This response stream is piped to a higher level stream reader. The reader reads 256 characters at a time , -writes them into a String* and then displays the String* in the console*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - // Creates an HttpWebRequest with the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - // Sends the HttpWebRequest and waits for the response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Gets the stream associated with the response. - Stream^ receiveStream = myHttpWebResponse->GetResponseStream(); - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - // Pipes the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - Console::WriteLine( "\r\nResponse stream received." ); - array^ read = gcnew array(256); - // Reads 256 characters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "HTML...\r\n" ); - while ( count > 0 ) - { - // Dumps the 256 characters on a String* and displays the String* to the console. - String^ str = gcnew String( read,0,count ); - Console::Write( str ); - count = readStream->Read( read, 0, 256 ); - } - Console::WriteLine( "" ); - // Releases the resources of the response. - myHttpWebResponse->Close(); - // Releases the resources of the Stream. - readStream->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_GetResponseStream http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp deleted file mode 100644 index 7432bdb865bb0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// System::Net::HttpWebResponse::Headers - -/* This program demonstrates the 'Headers' property of the 'HttpWebResponse' class -It creates a web request and queries for a response.It then displays all the response headers -onto the console. */ -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { - // - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - - // Sends the HttpWebRequest and waits for response. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Displays all the headers present in the response received from the URI. - Console::WriteLine( "\r\nThe following headers were received in the response:" ); - - // Displays each header and its key associated with the response. - for ( int i = 0; i < myHttpWebResponse->Headers->Count; ++i ) - Console::WriteLine( "\nHeader Name: {0}, Value : {1}", - myHttpWebResponse->Headers->Keys[ i ], - myHttpWebResponse->Headers[ (System::Net::HttpRequestHeader)i ] ); - - // Releases the resources of the response. - myHttpWebResponse->Close(); - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_Headers http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp deleted file mode 100644 index 333f61bc9f20a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Net::HttpWebResponse::LastModified -/* This program demonstrates the 'LastModified' property of the 'HttpWebResponse' class -It creates a web request and queries for a response.The program checks -if the entity requested was modified any time today. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ myUri = gcnew Uri( url ); - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\r\nRequest succeeded and the requested information is in the response , Description : {0}", - myHttpWebResponse->StatusDescription ); - } - DateTime today = DateTime::Now; - // Uses the LastModified property to compare with today's date. - if ( DateTime::Compare( today, myHttpWebResponse->LastModified ) == 0 ) - { - Console::WriteLine( "\nThe requested URI entity was modified today" ); - } - else if ( DateTime::Compare( today, myHttpWebResponse->LastModified ) == 1 ) - { - Console::WriteLine( "\nThe requested URI was last modified on: {0}", - myHttpWebResponse->LastModified ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_LastModified http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp deleted file mode 100644 index 17ef6d6a0ce97..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System::Net::HttpWebResponse::Method;System::Net::HttpWebResponse::Server -/* This program demonstrates the 'Method' and 'Server' properties of the 'HttpWebResponse' class. -It creates a Web request and queries for a response.It evaluates the response method used and the prints -the Web server name to the console*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ -// -// - try - { - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - String^ method; - method = myHttpWebResponse->Method; - if ( String::Compare( method, "GET" ) == 0 ) - { - Console::WriteLine( "\nThe 'GET' method was successfully invoked on the following Web Server : {0}", - myHttpWebResponse->Server ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -// -// -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_Method_Server http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp deleted file mode 100644 index 0ab44b6775d57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System::Net::HttpWebResponse::ProtocolVersion -/* This program demonstrates the 'ProtocolVersion' property of the 'HttpWebResponse' class. -It creates a web request and queries for a response.The server should respond using the same version */ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ ourUri = gcnew Uri( url ); - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( ourUri ) ); - myHttpWebRequest->ProtocolVersion = HttpVersion::Version10; - // Sends the HttpWebRequest and waits for the response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Ensures that only Http/1.0 responses are accepted. - if ( myHttpWebResponse->ProtocolVersion != HttpVersion::Version10 ) - { - Console::WriteLine( "\nThe server responded with a version other than Http/1.0" ); - } - else if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\nRequest sent using version Http/1.0. Successfully received response with version HTTP/1.0 " ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_ProtocolVersion http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp deleted file mode 100644 index 94feadb963d6f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System::Net::HttpWebResponse::ResponseUri -/*This program demonstrates the 'ResponseUri' property of the 'HttpWebResponse' class -It creates a web request and queries for a response.It checks if the original Uri -was redirected by the server. */ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ myUri = gcnew Uri( url ); - // Create a 'HttpWebRequest' object for the specified url. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Send the request and wait for response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\nRequest succeeded and the requested information is in the response , Description : {0}", - myHttpWebResponse->StatusDescription ); - } - if ( myUri->Equals( myHttpWebResponse->ResponseUri ) ) - { - Console::WriteLine( "\nThe Request Uri was not redirected by the server" ); - } - else - { - Console::WriteLine( "\nThe Request Uri was redirected to : {0}", myHttpWebResponse->ResponseUri ); - } - // Release resources of response Object*. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_ResponseUri http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp deleted file mode 100644 index a698f39492a0e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Net::HttpWebResponse::StatusCode; System::Net::HttpWebResponse::StatusDescription - -/* This program demonstrates the 'StatusCode' and 'StatusDescription' property of the 'HttpWebResponse' class. -It creates a web request and queries for a response. */ - -#using - -using namespace System; -using namespace System::Net; - -// -// -void GetPage( String^ url ) -{ - try - { - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - // Sends the HttpWebRequest and waits for a response. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\r\nResponse Status Code is OK and StatusDescription is: {0}", - myHttpWebResponse->StatusDescription ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_StatusCode_StatusDescription http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp deleted file mode 100644 index ebd4e3a01785d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp +++ /dev/null @@ -1,78 +0,0 @@ - - -/*System::Net::HttpWebRequest::HaveResponse - -This program demonstrates 'HaveResponse' property of 'HttpWebRequest' Class. -A new 'HttpWebRequest' is created. -The 'HaveResponse' property is a ReadOnly, boolean property that indicates -whether the Request Object* has received any response or not. -The default value of 'HaveResponse' property of the 'HttpWebRequest' is displayed to the console. -The HttpWebResponse variable is assigned the response Object* of 'HttpWebRequest'. -The HaveReponse property is tested for its value. -If there is a response then the HTML contents of the page of the requested Uri are displayed to the console -else a message 'The response is not received' is displayed to the console. - -*/ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; -int main() -{ - try - { - - // - // Create a new 'HttpWebRequest' Object. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - HttpWebResponse^ myHttpWebResponse; - - // Display the 'HaveResponse' property of the 'HttpWebRequest' object to the console. - Console::WriteLine( "\nThe value of 'HaveResponse' property before a response object is obtained : {0}", myHttpWebRequest->HaveResponse ); - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - if ( myHttpWebRequest->HaveResponse ) - { - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of Html Page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' key to continue.........." ); - Console::Read(); - } - else - { - Console::WriteLine( "\nThe response is not received " ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp deleted file mode 100644 index 2f56e5129b95e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/*System::Net::HttpWebRequest::Proxy -This program demonstrates the 'Proxy' property of the 'HttpWebRequest' class. -A 'HttpWebRequest' Object* and a 'Proxy' Object* is created.The Proxy Object is then assigned to -the 'Proxy' Property of the 'HttpWebRequest' Object* and printed onto the console(this is the default -Proxy setting).New Proxy address and the credentials are requested from the User::A new Proxy Object* is -then constructed from the supplied inputs.Then the 'Proxy' property of the request is associated with the new -Proxy Object*. -Note:No credentials are required if the Proxy does not require any authentication. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new request to the mentioned URL. - HttpWebRequest ^ myWebRequest = - (HttpWebRequest ^) (WebRequest::Create("http://www.microsoft.com")); - - // Obtain the 'Proxy' of the Default browser. - IWebProxy ^ proxy = myWebRequest->Proxy; - // Print the Proxy Url to the console. - if (proxy) - { - Console::WriteLine("Proxy: {0}", - proxy->GetProxy(myWebRequest->RequestUri)); - } - else - { - Console::WriteLine("Proxy is null; no proxy will be used"); - } - - WebProxy ^ myProxy = gcnew WebProxy; - - Console::WriteLine("\nPlease enter the new Proxy Address that is to be set:"); - Console::WriteLine("(Example:http://myproxy.example.com:port)"); - String ^ proxyAddress; - - try - { - proxyAddress = Console::ReadLine(); - if (proxyAddress->Length > 0) { - Console::WriteLine("\nPlease enter the Credentials "); - Console::WriteLine("Username:"); - String ^ username; - username = Console::ReadLine(); - Console::WriteLine("\nPassword:"); - String ^ password; - password = Console::ReadLine(); - // Create a new Uri object. - Uri ^ newUri = gcnew Uri(proxyAddress); - // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set. - myProxy->Address = newUri; - // Create a NetworkCredential object and associate it with the Proxy property of request object. - myProxy->Credentials = - gcnew NetworkCredential(username, password); - myWebRequest->Proxy = myProxy; - } - Console::WriteLine("\nThe Address of the new Proxy settings are {0}", - myProxy->Address); - HttpWebResponse ^ myWebResponse = - (HttpWebResponse ^) (myWebRequest->GetResponse()); -// - - // Print the HTML contents of the page to the console. - Stream ^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader ^ streamRead = gcnew StreamReader(streamResponse); - array < Char > ^readBuff = gcnew array < Char > (256); - int count = streamRead->Read(readBuff, 0, 256); - Console::WriteLine("\nThe contents of the HTML pages are :"); - while (count > 0) { - String ^ outputData = gcnew String(readBuff, 0, count); - Console::Write(outputData); - count = streamRead->Read(readBuff, 0, 256); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myWebResponse->Close(); - Console::WriteLine("\nPress any key to continue........."); - Console::Read(); - } - catch(UriFormatException ^ e) - { - Console::WriteLine("\nUriFormatException is thrown. Message: {0}", - e->Message); - Console::WriteLine("\nThe format of the Proxy address you entered is invalid"); - Console::WriteLine("\nPress any key to continue........."); - Console::Read(); - } - } - catch(WebException ^ e) - { - Console::WriteLine("\nWebException raised!"); - Console::WriteLine("\nMessage: {0} ", e->Message); - Console::WriteLine("\nStatus: {0} ", e->Status); - } - catch(Exception ^ e) - { - Console::WriteLine("\nException is raised. "); - Console::WriteLine("\nMessage: {0} ", e->Message); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelDataStore_Item/CPP/ichanneldatastore.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelDataStore_Item/CPP/ichanneldatastore.cpp deleted file mode 100644 index dc8a4fff2a665..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelDataStore_Item/CPP/ichanneldatastore.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// System.Runtime.Remoting.Channels.IChannelDataStore -// System.Runtime.Remoting.Channels.IChannelDataStore.ChannelUris -// System.Runtime.Remoting.Channels.IChannelDataStore.Item[object] - -/* The following example demonstrates 'ChannelUris', 'Item' and 'IChannelDataStore' -class. -In the example after registering the channel, the object is registered with remoting -infrastructure by calling 'RemotingServices.Marshal' method. After registering the -object the channel information is obtained. From the channel information the required -'IChannelInfo' is collected and displayed. -*/ - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Services; - -// Marshal ByRef Object class. -public ref class MyServiceClass: public MarshalByRefObject -{ -public: - String^ HelloWorld() - { - return "Hello World"; - } -}; - -int main() -{ - // - // - TcpChannel^ myChannel = gcnew TcpChannel( 8085 ); - ChannelServices::RegisterChannel( myChannel ); - MyServiceClass^ myService = gcnew MyServiceClass; - - // After the channel is registered, register the object - // with remoting infrastructure by calling Marshal method. - ObjRef^ myObjRef = RemotingServices::Marshal( myService, "TcpService" ); - - // Get the information contributed by active channel. - IChannelInfo^ myChannelInfo = myObjRef->ChannelInfo; - IChannelDataStore^ myIChannelData; - System::Collections::IEnumerator^ myEnum = myChannelInfo->ChannelData->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myChannelData = safe_cast(myEnum->Current); - if ( dynamic_cast(myChannelData) ) - { - myIChannelData = dynamic_cast(myChannelData); - System::Collections::IEnumerator^ myEnum1 = myIChannelData->ChannelUris->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - String^ myUri = safe_cast(myEnum1->Current); - Console::WriteLine( "Channel Uris are -> {0}", myUri ); - } - String^ myKey = "Key1"; - myIChannelData[ myKey ] = "My Data"; - Console::WriteLine( myIChannelData[ myKey ] ); - } - } - // - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiverHook_ChannelScheme/CPP/ichannelreceiverhook_channelscheme.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiverHook_ChannelScheme/CPP/ichannelreceiverhook_channelscheme.cpp deleted file mode 100644 index d2e8a8d8aaade..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiverHook_ChannelScheme/CPP/ichannelreceiverhook_channelscheme.cpp +++ /dev/null @@ -1,141 +0,0 @@ - - - -// System.Runtime.Remoting.Channels.IChannelReceiverHook -// System.Runtime.Remoting.Channels.IChannelReceiverHook.WantsToListen -// System.Runtime.Remoting.Channels.IChannelReceiverHook.ChannelScheme - -/* -This example demonstrates the implementation of the 'ChannelScheme' and -'WantsToListen' properties of the 'IChannelReceiverHook' interface. -It creates a customized channel 'MyCustomChannel' by implementing -'IChannelReceiverHook' interface. -*/ - - - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -// -// Implementation of 'IChannelReceiverHook' interface. -public ref class MyCustomChannel: public IChannelReceiverHook -{ -private: - bool portSet; - -public: - // Constructor for MyCustomChannel. - MyCustomChannel( int /*port*/ ) - { - MyChannelScheme = "http"; - portSet = true; - } - - // Constructor for MyCustomChannel. - MyCustomChannel() - { - MyChannelScheme = "http"; - portSet = false; - } - - property bool WantsToListen - { - // - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual bool get() - { - if ( portSet ) - { - return false; - } - else - { - return true; - } - } - } - // - - // -private: - String^ MyChannelScheme; - -public: - property String^ ChannelScheme - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual String^ get() - { - return MyChannelScheme; - } - } - // - - property IServerChannelSink^ ChannelSinkChain - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual IServerChannelSink^ get() - { - - // Null implementation. - return nullptr; - } - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void AddHookChannelUri( String^ /*channelUri*/ ) - { - // Null implementation. - } -}; -// - -int main() -{ - try - { - MyCustomChannel^ myCustomChannelWithPort = gcnew MyCustomChannel( 8085 ); - MyCustomChannel^ myCustomChannelNoPort = gcnew MyCustomChannel; - Console::WriteLine( "Channel Scheme of myCustomChannelWithPort : {0}", - myCustomChannelWithPort->ChannelScheme ); - Console::WriteLine( "Channel Scheme of myCustomChannelNoPort : {0}", - myCustomChannelNoPort->ChannelScheme ); - // 'WantsToListen' is false. It is already listening. - if ( myCustomChannelWithPort->WantsToListen ) - { - Console::WriteLine( "myCustomChannelWithPort wants to listen." ); - } - else - { - Console::WriteLine( "myCustomChannelWithPort doesn't want to listen." ); - } - if ( myCustomChannelNoPort->WantsToListen ) - { - Console::WriteLine( "myCustomChannelNoPort wants to listen." ); - } - else - { - Console::WriteLine( "myCustomChannelNoPort doesn't want to listen." ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/IChannelReceiver_ChannelData_Client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/IChannelReceiver_ChannelData_Client.cpp deleted file mode 100644 index db042ca4c2f1d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/IChannelReceiver_ChannelData_Client.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// This program acts as a client and calls the remote method 'HelloMethod'. - -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections::Specialized; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Security::Permissions; - -public ref class MyIChannelReceiverChannelDataClientClass -{ -public: - [PermissionSet(SecurityAction::Demand)] - static void Main() - { - String^ myChannelURL = "tcp://" + Dns::Resolve(Dns::GetHostName()) - ->AddressList[0] + ":8085/SayHello"; - ListDictionary^ myListDictionary = gcnew ListDictionary(); - myListDictionary->Add("port",8086); - TcpChannel^ myCustomChannel = gcnew TcpChannel(myListDictionary, - gcnew SoapClientFormatterSinkProvider(), - gcnew SoapServerFormatterSinkProvider()); - ChannelServices::RegisterChannel(myCustomChannel); - try - { - HelloServer^ myHelloServer = (HelloServer^)Activator::GetObject - (HelloServer::typeid, myChannelURL); - if (myHelloServer == nullptr) - { - Console::WriteLine("Could not locate server."); - } - else - { - Console::WriteLine(myHelloServer->HelloMethod("Caveman")); - } - } - catch(Exception^ e) - { - Console::WriteLine("Message : " + e->Message); - } - } -}; - -int main() { - MyIChannelReceiverChannelDataClientClass::Main(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/IChannelReceiver_ChannelData_Share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/IChannelReceiver_ChannelData_Share.cpp deleted file mode 100644 index 4ea674b9651d5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/IChannelReceiver_ChannelData_Share.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* The class 'HelloServer' is derived from 'MarshalByRefObject' to make - it remotable. Ihe method 'HelloMethod' can be called by the client - after creating instance of the 'HelloServer' class. -*/ -using namespace System; - -public ref class HelloServer : public MarshalByRefObject -{ - -public: - HelloServer() - { - Console::WriteLine("HelloServer activated"); - } - -public: - String^ HelloMethod(String^ name) - { - Console::WriteLine("Hello.HelloMethod : {0}", name); - return "Hi there " + name; - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/ichannelreceiver_channeldata_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/ichannelreceiver_channeldata_server.cpp deleted file mode 100644 index f89d4890e0ecf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/ichannelreceiver_channeldata_server.cpp +++ /dev/null @@ -1,174 +0,0 @@ - - -// System.Runtime.Remoting.Channels.IChannelReceiver -// System.Runtime.Remoting.Channels.IChannelReceiver.ChannelData -// System.Runtime.Remoting.Channels.IChannelReceiver.GetUrlsForUri -// System.Runtime.Remoting.Channels.IChannelReceiver.StartListening -// System.Runtime.Remoting.Channels.IChannelReceiver.StopListening -/* -This example implements the 'ChannelData' property and 'GetUrlsForUri', -'StartListening' and 'StopListening' method of 'IChannelReceiver' interface. -It creates a server by implementing 'IChannelReceiver' interface to receive -request send by the client. -*/ -#using -#using - -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Threading; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Text::RegularExpressions; - -// -ref class MyCustomChannel: public IChannelReceiver -{ -private: - ChannelDataStore^ myChannelData; - int myChannelPriority; - - // Set the 'ChannelName' to 'MyCustomChannel'. - String^ myChannelName; - - // Implement 'ChannelName' property. - TcpListener^ myTcpListener; - int myPortNo; - bool myListening; - Thread^ myThread; - -public: - MyCustomChannel() - : myChannelPriority( 25 ), myChannelName( "tcp" ), myListening( false ) - {} - - MyCustomChannel( int portNo ) - { - myPortNo = portNo; - array^myURI = gcnew array(1); - myURI[ 0 ] = String::Concat( Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ], ":", portNo ); - - // Store the 'URI' in 'myChannelDataStore'. - myChannelData = gcnew ChannelDataStore( myURI ); - - // Create 'myTcpListener' to listen at the 'myPortNo' port. - myTcpListener = gcnew TcpListener( myPortNo ); - - // Create the thread 'myThread'. - myThread = gcnew Thread( gcnew ThreadStart( myTcpListener, &TcpListener::Start ) ); - this->StartListening( nullptr ); - } - - property String^ ChannelName - { - virtual String^ get() - { - return myChannelName; - } - } - - property int ChannelPriority - { - virtual int get() - { - return myChannelPriority; - } - } - virtual String^ Parse( String^ myUrl, [Out]String^% objectURI ) - { - Regex^ myRegex = gcnew Regex( "/",RegexOptions::RightToLeft ); - - // Check for '/' in 'myUrl' from Right to left. - Match^ myMatch = myRegex->Match(myUrl); - - // Get the object URI. - objectURI = myUrl->Substring( myMatch->Index ); - - // Return the channel url. - return myUrl->Substring( 0, myMatch->Index ); - } - - // Implementation of 'IChannelReceiver' interface. - // - property Object^ ChannelData - { - virtual Object^ get() - { - return myChannelData; - } - } - // - - // - // Create and send the object URL. - virtual array^ GetUrlsForUri( String^ objectURI ) - { - array^myString = gcnew array(1); - myString[ 0 ] = String::Concat( Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ], "/", objectURI ); - return myString; - } - // - - // - // Start listening to the port. - virtual void StartListening( Object^ data ) - { - if ( myListening == false ) - { - myTcpListener->Start(); - myListening = true; - Console::WriteLine( "Server Started Listening !!!" ); - } - } - // - - // - // Stop listening to the port. - virtual void StopListening( Object^ data ) - { - if ( myListening == true ) - { - myTcpListener->Stop(); - myListening = false; - Console::WriteLine( "Server Stopped Listening !!!" ); - } - } - // -}; -// - -int main() -{ - MyCustomChannel^ myChannel = gcnew MyCustomChannel( 8085 ); - ChannelDataStore^ myChannelDataStore = (ChannelDataStore^)myChannel->ChannelData; - Console::WriteLine( "The channel URI is {0}", myChannelDataStore->ChannelUris[ 0 ] ); - array^myUrlArray = myChannel->GetUrlsForUri( "SayHello" ); - Console::WriteLine( "The URL for the objectURI is {0}", myUrlArray[ 0 ] ); - bool continueOption = true; - while ( continueOption ) - { - Console::WriteLine( "" ); - Console::WriteLine( "Select a option .." ); - Console::WriteLine( " 1 - StartListening" ); - Console::WriteLine( " 2 - StopListening" ); - Console::WriteLine( " 3 - Exit" ); - Console::Write( "Option : " ); - int myOption = Int32::Parse( Console::ReadLine() ); - switch ( myOption ) - { - case 1: - myChannel->StartListening( nullptr ); - break; - - case 2: - myChannel->StopListening( nullptr ); - break; - - case 3: - continueOption = false; - break; - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/makefile deleted file mode 100644 index f687312e51f84..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelReceiver_StartListening_ChannelData/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: Share.dll server.exe client.exe - -Share.dll: IChannelReceiver_ChannelData_Share.cpp - cl /clr:pure /LD IChannelReceiver_ChannelData_Share.cpp - -server.exe: IChannelReceiver_ChannelData_Server.cpp IChannelReceiver_ChannelData_Share.dll - cl /clr:pure IChannelReceiver_ChannelData_Server.cpp - -client.exe: IChannelReceiver_ChannelData_client.cpp IChannelReceiver_ChannelData_Share.dll - cl /clr:pure IChannelReceiver_ChannelData_client.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/IChannelSender_Share.cs b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/IChannelSender_Share.cs deleted file mode 100644 index adb3c9e61daae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/IChannelSender_Share.cs +++ /dev/null @@ -1,19 +0,0 @@ -/* This file is a support file for demonstrating the members of - IChannelSender interface on the client side. The program will - define the methods to execute from the client. */ - -using System; - -public class MyHelloServer : MarshalByRefObject -{ - public MyHelloServer() - { - Console.WriteLine("HelloServer activated"); - } - - public String myHelloMethod(String myString) - { - Console.WriteLine("Hello.HelloMethod : {0}", myString); - return "Hi there " + myString; - } -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/ichannelsender_2_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/ichannelsender_2_client.cpp deleted file mode 100644 index f75401a16a447..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/ichannelsender_2_client.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// System.Runtime.Remoting.Channels.IChannelSender -// System.Runtime.Remoting.Channels.IChannelSender.CreateMessageSink() -/* The following program demonstrates the usage of IChannelSender -interface and its 'CreateMessageSink' method in the namespace -'System.Runtime.Remoting.Channels'. This program creates and -registers an IChannelSender of type 'HttpClientChannel'. -It sets the priority of the channel and it displays the -property values of 'HttpClientChannel'. */ -// -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Channels::Http; -int main() -{ - try - { - - // Create the 'IDictionary' to set the server object properties. - IDictionary^ myDictionary = gcnew Hashtable; - myDictionary->default[ "name" ] = "HttpClientChannel"; - myDictionary->default[ "priority" ] = 2; - - // Set the properties along with the constructor. - IChannelSender^ myIChannelSender = gcnew HttpClientChannel( myDictionary,gcnew BinaryClientFormatterSinkProvider ); - - // Register the server channel. - ChannelServices::RegisterChannel( myIChannelSender, false ); - MyHelloServer ^ myHelloServer1 = dynamic_cast(Activator::GetObject( MyHelloServer::typeid, "http://localhost:8085/SayHello" )); - if ( myHelloServer1 == nullptr ) - { - Console::WriteLine( "Could not locate server" ); - } - else - { - Console::WriteLine( myHelloServer1->myHelloMethod( "Client" ) ); - - // Get the name of the channel. - Console::WriteLine( "Channel Name :{0}", myIChannelSender->ChannelName ); - - // Get the channel priority. - Console::WriteLine( "ChannelPriority :{0}", myIChannelSender->ChannelPriority ); - String^ myString; - String^ myObjectURI1; - Console::WriteLine( "Parse :{0}{1}", myIChannelSender->Parse( "http://localhost:8085/SayHello", myString ), myString ); - - // - // Get the channel message sink that delivers message to specified url. - IMessageSink^ myIMessageSink = myIChannelSender->CreateMessageSink( "http://localhost:8085/NewEndPoint", nullptr, myObjectURI1 ); - Console::WriteLine( "Channel message sink used :{0}", myIMessageSink ); - - // - Console::WriteLine( "URI of new channel message sink :{0}", myObjectURI1 ); - } - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Following exception is raised on client side : {0}", ex->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/makefile deleted file mode 100644 index 2d517fe56a83d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IChannelSender/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: IChannelSender_Share.dll ichannelsender_2_client.exe - -IChannelSender_Share.dll: IChannelSender_Share.cs - csc /t:library IChannelSender_Share.cs - -ichannelsender_2_client.exe: ichannelsender_2_client.cpp IChannelSender_Share.dll - cl /clr ichannelsender_2_client.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp deleted file mode 100644 index c5e7cd86495f2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* -This program demonstrates 'GetCredential' method of 'ICredentials*' interface. -The 'CredentialList' class implements 'ICredentials*' interface which stores credentials for multiple -internet resources.The Program takes URL, Username, Password and Domain name from commandline and adds -it to an instance of 'CredentialList' class.An instance of 'WebRequest' class is obtained and 'Credentials' -property of 'WebRequest' class is set to an instance of 'NetworkCredential' class obtained by calling -'GetCredential' method of 'CredentialList' class. Then it sends the request and obtains a response. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -ref class CredentialList: public ICredentials -{ -private: - ref class CredentialInfo - { - public: - Uri^ uriObj; - String^ authenticationType; - NetworkCredential^ networkCredentialObj; - CredentialInfo( Uri^ uriObj, String^ authenticationType, NetworkCredential^ networkCredentialObj ) - { - this->uriObj = uriObj; - this->authenticationType = authenticationType; - this->networkCredentialObj = networkCredentialObj; - } - }; - - ArrayList^ arrayListObj; - -public: - CredentialList() - { - arrayListObj = gcnew ArrayList; - } - - void Add( Uri^ uriObj, String^ authenticationType, NetworkCredential^ credential ) - { - - // Add a 'CredentialInfo' object into a list. - arrayListObj->Add( gcnew CredentialInfo( uriObj,authenticationType,credential ) ); - } - - // Remove the 'CredentialInfo' object from the list that matches to the given 'Uri' and 'AuthenticationType' - void Remove( Uri^ uriObj, String^ authenticationType ) - { - for ( int index = 0; index < arrayListObj->Count; index++ ) - { - CredentialInfo^ credentialInfo = dynamic_cast(arrayListObj[ index ]); - if ( uriObj->Equals( credentialInfo->uriObj ) && authenticationType->Equals( credentialInfo->authenticationType ) ) - arrayListObj->RemoveAt( index ); - } - } - - virtual NetworkCredential^ GetCredential( Uri^ uriObj, String^ authenticationType ) - { - for ( int index = 0; index < arrayListObj->Count; index++ ) - { - CredentialInfo^ credentialInfoObj = dynamic_cast(arrayListObj[ index ]); - if ( uriObj->Equals( credentialInfoObj->uriObj ) && authenticationType->Equals( credentialInfoObj->authenticationType ) ) - return credentialInfoObj->networkCredentialObj; - } - return nullptr; - } -}; -// - -void GetPage( String^ urlString, String^ UserName, String^ password, String^ DomainName ) -{ - try - { - CredentialList^ credentialListObj = gcnew CredentialList; - - // Dummy names used as credentials. - credentialListObj->Add( gcnew Uri( urlString ), - "Basic", gcnew NetworkCredential( UserName,password,DomainName ) ); - credentialListObj->Add( gcnew Uri( "http://www.msdn.microsoft.com" ), - "Basic", gcnew NetworkCredential( "User1","Passwd1","Domain1" ) ); - - // Create a 'WebRequest' for the specified url. - WebRequest^ myWebRequest = WebRequest::Create( urlString ); - - // Call 'GetCredential' to obtain the credentials specific to a Uri. - myWebRequest->Credentials = credentialListObj->GetCredential( gcnew Uri( urlString ), "Basic" ); - - // Send the request and get the response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // ....Process the response here. - Console::WriteLine( "\n Response Received." ); - myWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException caught !!!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught !!!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} - -int main() -{ - String^ urlString; - String^ username; - String^ password; - String^ domainname; - Console::Write( "Enter a URL(for e.g. http://www.microsoft.com : " ); - urlString = Console::ReadLine(); - Console::Write( "Enter User name : " ); - username = Console::ReadLine(); - Console::Write( "Enter Password :" ); - password = Console::ReadLine(); - Console::Write( "Enter Domain name : " ); - domainname = Console::ReadLine(); - GetPage( urlString, username, password, domainname ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IDeserializationCallback Interface Example/CPP/ideserializationcallback.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IDeserializationCallback Interface Example/CPP/ideserializationcallback.cpp deleted file mode 100644 index dada2d6208ba8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IDeserializationCallback Interface Example/CPP/ideserializationcallback.cpp +++ /dev/null @@ -1,106 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Runtime::Serialization::Formatters::Binary; -using namespace System::Runtime::Serialization; - -// This class is serializable and will have its OnDeserialization method -// called after each instance of this class is deserialized. - -[Serializable] -ref class Circle: public IDeserializationCallback -{ -private: - Double m_radius; - -public: - - // To reduce the size of the serialization stream, the field below is - // not serialized. This field is calculated when an object is constructed - // or after an instance of this class is deserialized. - - [NonSerialized] - Double m_area; - Circle( Double radius ) - { - m_radius = radius; - m_area = Math::PI * radius * radius; - } - - virtual void OnDeserialization( Object^ /*sender*/ ) - { - // After being deserialized, initialize the m_area field - // using the deserialized m_radius value. - m_area = Math::PI * m_radius * m_radius; - } - - virtual String^ ToString() override - { - return String::Format( "radius= {0}, area= {1}", m_radius, m_area ); - } -}; - -void Serialize() -{ - Circle^ c = gcnew Circle( 10 ); - Console::WriteLine( "Object being serialized: {0}", c ); - - // To serialize the Circle, you must first open a stream for - // writing. We will use a file stream here. - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Create ); - - // Construct a BinaryFormatter and use it to serialize the data to the stream. - BinaryFormatter^ formatter = gcnew BinaryFormatter; - try - { - formatter->Serialize( fs, c ); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to serialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } -} - -void Deserialize() -{ - // Declare the Circle reference. - Circle^ c = nullptr; - - // Open the file containing the data that we want to deserialize. - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Open ); - try - { - BinaryFormatter^ formatter = gcnew BinaryFormatter; - - // Deserialize the Circle from the file and - // assign the reference to our local variable. - c = dynamic_cast(formatter->Deserialize( fs )); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to deserialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - - // To prove that the Circle deserialized correctly, display its area. - Console::WriteLine( "Object being deserialized: {0}", c ); -} - -[STAThread] -int main() -{ - Serialize(); - Deserialize(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_client.cpp deleted file mode 100644 index e1b40ce138adf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_client.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -// System::Runtime::Remoting::Lifetime.ILease* -// System::Runtime::Remoting::Lifetime.ILease*.InitialLeaseTime -// System::Runtime::Remoting::Lifetime.ILease*.CurrentLeaseTime -// System::Runtime::Remoting::Lifetime.ILease*.RenewOnCallTime -// System::Runtime::Remoting::Lifetime.ILease*.SponsorshipTimeout -//System::Runtime::Remoting::Lifetime.ILease*.CurrentState -// System::Runtime::Remoting::Lifetime.ILease*.Register(ISponsor*) -// System::Runtime::Remoting::Lifetime.ILease*.Renew(TimeSpam) -// System::Runtime::Remoting::Lifetime.ILease*.Unregister(ISponsor*) -// System::Runtime::Remoting::Lifetime.ILease*.Register(ISponsor*, TimeSpam) -/* The following example demonstrates 'InitialLeaseTime', 'CurrentLeaseTime', -'RenewOnCallTime', 'SponsorshipTimeout', 'CurrentState', 'Register', 'Renew', -'Unregister' and 'Register' methods of 'ClientSponsor' class. - -In the example using 'RemotingServices::GetLifetimeService' the lease information -of the remote service is obtained. All the properties and methods 'ILease' are demonstrated -using this lease variable. The client registers itself with 'ClientSponsor' class. -After registeration the current lease time is displayed. The lease is expired -and renewed. Then the renewed lease time is displayed. Finally the client unregister itself. -The client again registers itself. This time with initial lease time mentioned at -the time of registeration. The lease time is displayed. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Lifetime; -using namespace RemotingSamples; - -// -int main() -{ - // - // Register the channel. - TcpChannel^ myChannel = gcnew TcpChannel; - ChannelServices::RegisterChannel( myChannel ); - RemotingConfiguration::RegisterActivatedClientType( HelloService::typeid, "Tcp://localhost:8085" ); - TimeSpan myTimeSpan = TimeSpan::FromMinutes( 10 ); - - // Create a remote object. - HelloService ^ myService = gcnew HelloService; - ILease^ myLease; - myLease = dynamic_cast(RemotingServices::GetLifetimeService( myService )); - if ( myLease == nullptr ) - { - Console::WriteLine( "Cannot lease." ); - return -1; - } - - Console::WriteLine( "Initial lease time is {0}", myLease->InitialLeaseTime ); - Console::WriteLine( "Current lease time is {0}", myLease->CurrentLeaseTime ); - Console::WriteLine( "Renew on call time is {0}", myLease->RenewOnCallTime ); - Console::WriteLine( "Sponsorship timeout is {0}", myLease->SponsorshipTimeout ); - Console::WriteLine( "Current lease state is {0}", myLease->CurrentState ); - // - - // Register with a sponser. - ClientSponsor^ mySponsor = gcnew ClientSponsor; - myLease->Register( mySponsor ); - Console::WriteLine( "Wait for lease to expire (approx. 15 seconds)..." ); - System::Threading::Thread::Sleep( myLease->CurrentLeaseTime ); - Console::WriteLine( "Current lease time before renewal is {0}", myLease->CurrentLeaseTime ); - - // Renew the lease time. - myLease->Renew( myTimeSpan ); - Console::WriteLine( "Current lease time after renewal is {0}", myLease->CurrentLeaseTime ); - - // Call the Remote method. - Console::WriteLine( "Remote method output is {0}", myService->HelloMethod( "Microsoft" ) ); - myLease->Unregister( mySponsor ); - GC::Collect(); - GC::WaitForPendingFinalizers(); - - // Register with lease time of 15 minutes. - myLease->Register( mySponsor, TimeSpan::FromMinutes( 15 ) ); - Console::WriteLine( "Registered client with lease time of 15 minutes." ); - Console::WriteLine( "Current lease time is {0}", myLease->CurrentLeaseTime ); - - // Call the Remote method. - Console::WriteLine( "Remote method output is {0}", myService->HelloMethod( "Microsoft" ) ); - myLease->Unregister( mySponsor ); -} -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_server.cpp deleted file mode 100644 index e25e7e5165e72..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_server.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Lifetime; -using namespace RemotingSamples; - -int main() -{ - TcpChannel^ myChannel = gcnew TcpChannel( 8085 ); - ChannelServices::RegisterChannel( myChannel ); - RemotingConfiguration::RegisterActivatedServiceType( HelloService::typeid ); - Console::WriteLine( "Server started." ); - Console::WriteLine( "Hit enter to terminate..." ); - Console::Read(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_share.cpp deleted file mode 100644 index b7ca866a01ebe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/ilease_share.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Lifetime; - -namespace RemotingSamples -{ - public ref class HelloService: public MarshalByRefObject - { - public: - String^ HelloMethod( String^ name ) - { - Console::WriteLine( "Hello {0}", name ); - return "Hello {0}",name; - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual Object^ InitializeLifetimeService() override - { - ILease^ baseLease = dynamic_cast(MarshalByRefObject::InitializeLifetimeService()); - if ( baseLease->CurrentState == LeaseState::Initial ) - { - - // For demonstration the initial time is kept small. - // in actual scenarios it will be large. - baseLease->InitialLeaseTime = TimeSpan::FromSeconds( 15 ); - baseLease->RenewOnCallTime = TimeSpan::FromSeconds( 15 ); - baseLease->SponsorshipTimeout = TimeSpan::FromMinutes( 2 ); - } - - return baseLease; - } - - }; - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/makefile deleted file mode 100644 index da35e5fd35ec1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ILease_ILease/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: ILease_Server.exe ILease_Client.exe - -ILease_Server.exe: ILease_Server.cpp ILease_Share.dll - cl /clr:pure ILease_Server.cpp - -ILease_Client.exe: ILease_Client.cpp ILease_Share.dll - cl /clr:pure ILease_Client.cpp - -ILease_Share.dll: ILease_Share.cpp - cl /clr:pure /LD ILease_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/IMessageSink_Share.cs b/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/IMessageSink_Share.cs deleted file mode 100644 index d77948550e14c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/IMessageSink_Share.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -namespace Share -{ - public class MyHelloService : MarshalByRefObject -{ - public string myFunction(string myName) - { - string myMessage = "Hi there " + myName + ", you are using .NET Remoting"; - Console.WriteLine(myMessage ); - return myMessage ; - } -} -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/imessagesink_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/imessagesink_client.cpp deleted file mode 100644 index 22fe13cf2f055..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/imessagesink_client.cpp +++ /dev/null @@ -1,149 +0,0 @@ - - -// System.Runtime.Remoting.Messaging.IMessage -// System.Runtime.Remoting.Messaging.IMessage.Properties -// System.Runtime.Remoting.Messaging.IMessageSink -// System.Runtime.Remoting.Messaging.IMessageSink.SyncProcessMessage(IMessage) -/* The following example demonstrates 'IMessage.Properties', 'IMessage' interface, -'IMessageSink.SyncProcessMessage' and 'IMessageSink' interface. -In the example the MyProxy is derived from 'RealProxy' class. In MyProxy -'MessageSink' is created using 'CreateMessageSink' method of 'IChannelSender' -interface. The 'IMessageSink' return by 'CreateMessageSink' is used to demonstrate -'IMessageSink.SyncProcessMessage' of 'IMessageSink' interface. The 'Invoke' method -is overridden in 'MyProxy' class.to demonstrate its properties. -*/ -// -// -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Threading; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Permissions; -using namespace Share; - -public ref class MyProxy: public RealProxy -{ -private: - String^ myUrl; - String^ myObjectURI; - IMessageSink^ myMessageSink; - -public: - [System::Security::Permissions::PermissionSetAttribute(System::Security::Permissions::SecurityAction::LinkDemand)] - - MyProxy( Type^ myType, String^ myUrl1 ) - : RealProxy( myType ) - { - myUrl = myUrl1; - array^myRegisteredChannels = ChannelServices::RegisteredChannels; - IEnumerator^ myEnum = myRegisteredChannels->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IChannel^ channel = safe_cast(myEnum->Current); - if ( dynamic_cast(channel) ) - { - IChannelSender^ myChannelSender = dynamic_cast(channel); - myMessageSink = myChannelSender->CreateMessageSink( myUrl, nullptr, myObjectURI ); - if ( myMessageSink != nullptr ) - break; - } - } - - if ( myMessageSink == nullptr ) - { - throw gcnew Exception( String::Format( "A supported channel could not be found for myUrl1:{0}", myUrl ) ); - } - } - - virtual IMessage^ Invoke( IMessage^ myMesg ) override - { - Console::WriteLine( "MyProxy.Invoke Start" ); - if ( dynamic_cast(myMesg) ) - Console::WriteLine( "IMethodCallMessage" ); - - if ( dynamic_cast(myMesg) ) - Console::WriteLine( "IMethodReturnMessage" ); - - - // - Console::WriteLine( "Message Properties" ); - IDictionary^ myDictionary = myMesg->Properties; - IDictionaryEnumerator^ myEnum = dynamic_cast(myDictionary->GetEnumerator()); - while ( myEnum->MoveNext() ) - { - Object^ myKey = myEnum->Key; - String^ myKeyName = myKey->ToString(); - Object^ myValue = myEnum->Value; - Console::WriteLine( "{0} : {1}", myKeyName, myEnum->Value ); - if ( myKeyName->Equals( "__Args" ) ) - { - array^myArgs = (array^)myValue; - for ( int myInt = 0; myInt < myArgs->Length; myInt++ ) - Console::WriteLine( "arg: {0} myValue: {1}", myInt, myArgs[ myInt ] ); - } - - if ( (myKeyName->Equals( "__MethodSignature" )) && (nullptr != myValue) ) - { - array^myArgs = (array^)myValue; - for ( int myInt = 0; myInt < myArgs->Length; myInt++ ) - Console::WriteLine( "arg: {0} myValue: {1}", myInt, myArgs[ myInt ] ); - } - } - - Console::WriteLine( "myUrl1 {0} object URI{1}", myUrl, myObjectURI ); - myDictionary->default[ "__Uri" ] = myUrl; - Console::WriteLine( "URI {0}", myDictionary->default[ "__URI" ] ); - - // - // - IMessage^ myRetMsg = myMessageSink->SyncProcessMessage( myMesg ); - if ( dynamic_cast(myRetMsg) ) - { - IMethodReturnMessage^ myMethodReturnMessage = dynamic_cast(myRetMsg); - } - - - // - Console::WriteLine( "MyProxy.Invoke - Finish" ); - return myRetMsg; - } - -}; - - -// -// Main function that drives the whole sample -// -int main() -{ - ChannelServices::RegisterChannel( gcnew HttpChannel, false ); - Console::WriteLine( "Remoting Sample:" ); - Console::WriteLine( "Generate a new MyProxy using the Type" ); - Type^ myType = MyHelloService::typeid; - String^ myUrl1 = "http://localhost/myServiceAccess.soap"; - MyProxy^ myProxy = gcnew MyProxy( myType,myUrl1 ); - Console::WriteLine( "Obtain the transparent proxy from myProxy" ); - MyHelloService^ myService = dynamic_cast(myProxy->GetTransparentProxy()); - Console::WriteLine( "Calling the Proxy" ); - String^ myReturnString = myService->myFunction( "bill" ); - Console::WriteLine( "Checking result : {0}", myReturnString ); - if ( myReturnString->Equals( "Hi there bill, you are using .NET Remoting" ) ) - { - Console::WriteLine( "myService.HelloMethod PASSED : returned {0}", myReturnString ); - } - else - { - Console::WriteLine( "myService.HelloMethod FAILED : returned {0}", myReturnString ); - } -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/makefile deleted file mode 100644 index 2010000a79c3b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMessageSink_Client/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: IMessageSink_Share.dll imessagesink_client.exe - -IMessageSink_Share.dll: IMessageSink_Share.cs - csc /t:library IMessageSink_Share.cs - -imessagesink_client.exe: imessagesink_client.cpp IMessageSink_Share.dll - cl /clr imessagesink_client.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodCallMessage_GetInArg/CPP/imethodcallmessage.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IMethodCallMessage_GetInArg/CPP/imethodcallmessage.cpp deleted file mode 100644 index bf01660d3c3d5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodCallMessage_GetInArg/CPP/imethodcallmessage.cpp +++ /dev/null @@ -1,108 +0,0 @@ - - -// System::Runtime::Remoting::IMethodCallMessage -// System::Runtime::Remoting::IMethodCallMessage.InArgCount -// System::Runtime::Remoting::IMethodCallMessage.InArgs -// System::Runtime::Remoting::IMethodCallMessage.GetArgName(int) -// System::Runtime::Remoting::IMethodCallMessage.GetInArg(int) -/* -The following example demonstrates 'GetInArg', 'GetArgName', 'InArgCount' and 'InArgs' -members of 'IMethodCallMessage*' interface. -In this example custom proxy is accessed by passing message to the Invoke method. -In invoke method check the type of message. If the type is IMethodCallMessage*, then -InArgCount, InArgs, GetArgName(int) and GetInArg(int) of the interface are displayed. -This example also shows how to create a custom proxy. -*/ -// -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Messaging; - -// MyProxy extends the CLR Remoting RealProxy. -// In the same class, in the Invoke method, the methods and properties of the -// IMethodCallMessage are demonstrated. - -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::LinkDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::InheritanceDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - -public ref class MyProxy: public RealProxy -{ -public: - MyProxy( Type^ myType ) - : RealProxy( myType ) - { - // This constructor forwards the call to base RealProxy. - // RealProxy uses the Type to generate a transparent proxy. - } - - // - virtual IMessage^ Invoke( IMessage^ myIMessage ) override - { - Console::WriteLine( "MyProxy::Invoke Start" ); - Console::WriteLine( "" ); - ReturnMessage^ myReturnMessage = nullptr; - if ( dynamic_cast(myIMessage) ) - { - Console::WriteLine( "Message is of type 'IMethodCallMessage*'." ); - Console::WriteLine( "" ); - IMethodCallMessage^ myIMethodCallMessage; - myIMethodCallMessage = dynamic_cast(myIMessage); - Console::WriteLine( "InArgCount is : {0}", myIMethodCallMessage->InArgCount ); - IEnumerator^ myEnum = myIMethodCallMessage->InArgs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myObj = safe_cast(myEnum->Current); - Console::WriteLine( "InArgs is : {0}", myObj ); - } - - for ( int i = 0; i < myIMethodCallMessage->InArgCount; i++ ) - { - Console::WriteLine( "GetArgName({0}) is : {1}", i, myIMethodCallMessage->GetArgName( i ) ); - Console::WriteLine( "GetInArg({0}) is : {0}", i, myIMethodCallMessage->GetInArg( i ) ); - - } - Console::WriteLine( "" ); - } - else - if ( dynamic_cast(myIMessage) ) - Console::WriteLine( "Message is of type 'IMethodReturnMessage*'." ); - - // Build Return Message - myReturnMessage = gcnew ReturnMessage( 5,nullptr,0,nullptr,dynamic_cast(myIMessage) ); - Console::WriteLine( "MyProxy::Invoke - Finish" ); - return myReturnMessage; - } -}; - -// The class used to obtain Metadata. -public ref class MyMarshalByRefClass: public MarshalByRefObject -{ -public: - int MyMethod( String^ str, double dbl, int i ) - { - Console::WriteLine( "MyMarshalByRefClass::MyMethod {0} {1} {2}", str, dbl, i ); - return 0; - } - -}; -// - -// Main routine that drives the whole sample. -int main() -{ - Console::WriteLine( "Generate a new MyProxy." ); - MyProxy^ myProxy = gcnew MyProxy( MyMarshalByRefClass::typeid ); - Console::WriteLine( "Obtain the transparent proxy from myProxy." ); - MyMarshalByRefClass^ myMarshalByRefClassObj = dynamic_cast(myProxy->GetTransparentProxy()); - Console::WriteLine( "Calling the Proxy." ); - Object^ myReturnValue = myMarshalByRefClassObj->MyMethod( "Microsoft", 1.2, 6 ); - Console::WriteLine( "Sample Done." ); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodMessage_LogicalCallContext/CPP/imethodmessage_logicalcallcontext.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IMethodMessage_LogicalCallContext/CPP/imethodmessage_logicalcallcontext.cpp deleted file mode 100644 index 2b4d9d392c794..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodMessage_LogicalCallContext/CPP/imethodmessage_logicalcallcontext.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// System::Runtime::Remoting::Messaging.IMethodMessage*.LogicalCallContext -// System::Runtime::Remoting::Messaging.IMethodMessage*.Uri - -/* -The program demonstrates the 'LogicalCallContext' and 'Uri' properties of -the IMethodMessage* interface. -In the program a remote Object* is created with a method by extending 'MarshalByRefObject'. -A custom proxy is created by extending 'RealProxy' and overriding 'Invoke' -method of 'RealProxy'. In this example custom proxy is accessed by passing message -to the Invoke method. Then the values of 'Uri' and 'LogicalCallContext' properties -are displayed to the console. -*/ - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Permissions; - -// MyProxy extends the CLR Remoting RealProxy. -// This demonstrate the RealProxy extensiblity. -// -//This sample requires full trust -[PermissionSetAttribute(SecurityAction::Demand, Name = "FullTrust")] -public ref class MyProxy: public RealProxy -{ -private: - String^ stringUri; - MarshalByRefObject^ targetObject; - -public: - MyProxy( Type^ type ) - : RealProxy( type ) - { - targetObject = dynamic_cast(Activator::CreateInstance( type )); - ObjRef^ myObject = RemotingServices::Marshal( targetObject ); - stringUri = myObject->URI; - } - - MyProxy( Type^ type, MarshalByRefObject^ targetObject ) - : RealProxy( type ) - { - this->targetObject = targetObject; - } - - // - virtual IMessage^ Invoke( IMessage^ message ) override - { - message->Properties[ "__Uri" ] = stringUri; - IMethodMessage^ myMethodMessage = dynamic_cast(ChannelServices::SyncDispatchMessage( message )); - Console::WriteLine( "---------IMethodMessage* example-------" ); - Console::WriteLine( "Method name : {0}", myMethodMessage->MethodName ); - Console::WriteLine( "LogicalCallContext has information : {0}", myMethodMessage->LogicalCallContext->HasInfo ); - Console::WriteLine( "Uri : {0}", myMethodMessage->Uri ); - return myMethodMessage; - } - // -}; -// - - -[AttributeUsage(AttributeTargets::Class)] -[PermissionSetAttribute(SecurityAction::Demand, Name = "FullTrust")] -public ref class MyProxyAttribute: public ProxyAttribute -{ -public: - MyProxyAttribute(){} - - virtual MarshalByRefObject^ CreateInstance( Type^ serverType ) override - { - if ( serverType->IsMarshalByRef ) - { - MarshalByRefObject^ targetObject = dynamic_cast(Activator::CreateInstance( serverType )); - MyProxy^ proxy = gcnew MyProxy( serverType,targetObject ); - return dynamic_cast(proxy->GetTransparentProxy()); - } - else - throw gcnew Exception( "Proxies only work on MarshalByRefObject objects and their children" ); - } -}; - -public ref class Zip: public MarshalByRefObject, public ILogicalThreadAffinative -{ -public: - Zip(){} - - int Method1( int i ) - { - return i; - } -}; - -int main() -{ - MyProxy^ proxy = gcnew MyProxy( Zip::typeid ); - Zip^ myZip = dynamic_cast(proxy->GetTransparentProxy()); - CallContext::SetData( "USER", gcnew Zip ); - myZip->Method1( 6 ); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodMessage_MethodName/CPP/imethodmessage_methodname.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IMethodMessage_MethodName/CPP/imethodmessage_methodname.cpp deleted file mode 100644 index fc6f65fff23bd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodMessage_MethodName/CPP/imethodmessage_methodname.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// System::Runtime::Remoting::Messaging.IMethodMessage* -// System::Runtime::Remoting::Messaging.IMethodMessage*.MethodName -// System::Runtime::Remoting::Messaging.IMethodMessage*.ArgCount -// System::Runtime::Remoting::Messaging.IMethodMessage*.GetArgName -// System::Runtime::Remoting::Messaging.IMethodMessage*.GetArg -// System::Runtime::Remoting::Messaging.IMethodMessage*.HasVarArgs -// System::Runtime::Remoting::Messaging.IMethodMessage*.Args - -/* -The following program demonstrates the 'MethodName', 'ArgCount', 'HasVarArgs', -'Args' properties, 'GetArgName', 'GetArg' methods of 'IMethodMessage*' interface and -'IMethodMessage*' interface. -In this example custom proxy is accessed by passing message to the Invoke method. -The Invoke method calls the methods and properties of 'IMethodMessage*' interface -and displays the result to the console. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Permissions; - -public ref class Reverser: public MarshalByRefObject -{ -private: - String^ stringReversed; - -public: - String^ GetReversedString() - { - return stringReversed; - } - - void SetString( String^ temp ) - { - DoReverse( temp ); - } - -private: - - // Exposed reverse as a method to reverse a String*. - void DoReverse( String^ argString ) - { - stringReversed = ""; - for ( int i = argString->Length - 1; i >= 0; i-- ) - { - stringReversed += argString[i]; - } - } -}; - -// -// This class requires full trust -[PermissionSetAttribute(SecurityAction::Demand, Name = "FullTrust")] -public ref class MyProxyClass: public RealProxy -{ -private: - Object^ myObjectInstance; - Type^ myType; - -public: - MyProxyClass( Type^ argType ) - : RealProxy( argType ) - { - myType = argType; - myObjectInstance = Activator::CreateInstance( argType ); - } - - // - // Overriding the Invoke method of RealProxy. - virtual IMessage^ Invoke( IMessage^ message ) override - { - IMethodMessage^ myMethodMessage = dynamic_cast(message); - Console::WriteLine( "**** Begin Invoke ****" ); - Console::WriteLine( "\tType is : {0}", myType ); - Console::WriteLine( "\tMethod name : {0}", myMethodMessage->MethodName ); - for ( int i = 0; i < myMethodMessage->ArgCount; i++ ) - { - Console::WriteLine( "\tArgName is : {0}", myMethodMessage->GetArgName( i ) ); - Console::WriteLine( "\tArgValue is: {0}", myMethodMessage->GetArg( i ) ); - - } - if ( myMethodMessage->HasVarArgs ) - Console::WriteLine( "\t The method have variable arguments!!" ); - else - Console::WriteLine( "\t The method does not have variable arguments!!" ); - - - // Dispatch the method call to the real Object*. - Object^ returnValue = myType->InvokeMember( myMethodMessage->MethodName, BindingFlags::InvokeMethod, nullptr, myObjectInstance, myMethodMessage->Args ); - Console::WriteLine( "**** End Invoke ****" ); - - // Build the return message to pass back to the transparent proxy. - ReturnMessage^ myReturnMessage = gcnew ReturnMessage( returnValue,nullptr,0,nullptr,dynamic_cast(message) ); - return myReturnMessage; - } - // -}; -// - -int main() -{ - MyProxyClass^ myProxy = gcnew MyProxyClass( Reverser::typeid ); - - // The real proxy dynamically creates a transparent proxy. - Reverser^ myReverser = dynamic_cast(myProxy->GetTransparentProxy()); - myReverser->SetString( "Hello World!" ); - Console::WriteLine( "The [Out] result is : {0}", myReverser->GetReversedString() ); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodReturnMessage_Exception/CPP/imethodreturnmessage_exception.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IMethodReturnMessage_Exception/CPP/imethodreturnmessage_exception.cpp deleted file mode 100644 index de64597d5f167..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodReturnMessage_Exception/CPP/imethodreturnmessage_exception.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// System::Runtime::Remoting::Messaging.IMethodReturnMessage*.Exception - -/* -The following example demonstrates 'Exception' property of 'IMethodReturnMessage*'interface. -A 'CustomServer' class is defined extending 'MarshalByRefObject'. A custom proxy -is created by extending 'RealProxy' and overriding 'Invoke' method of 'RealProxy'. -The Invoke method calls the methods and properties of 'IMethodMessage*' interface -and display the 'Exception' property value of 'IMethodReturnMessage*' interface to -the console. -*/ - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Messaging; - -public ref class CustomServer: public MarshalByRefObject -{ -public: - void RaiseException() - { - throw gcnew Exception( "Raising an exception." ); - } -}; - -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::LinkDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::InheritanceDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -public ref class MyProxy: public RealProxy -{ -private: - String^ _URI; - MarshalByRefObject^ myMarshalByRefObject; - -public: - MyProxy( Type^ myType ) : RealProxy( myType ) - { - myMarshalByRefObject = dynamic_cast(Activator::CreateInstance( myType )); - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - _URI = myObjRef->URI; - } - - // - virtual IMessage^ Invoke( IMessage^ myMessage ) override - { - IMethodCallMessage^ myCallMessage = dynamic_cast(myMessage); - - IMethodReturnMessage^ myIMethodReturnMessage = - RemotingServices::ExecuteMessage( myMarshalByRefObject, myCallMessage ); - if ( myIMethodReturnMessage->Exception != nullptr ) - { - Console::WriteLine( "{0} raised an exception.", - myIMethodReturnMessage->MethodName ); - } - else - { - Console::WriteLine( "{0} does not raise an exception.", - myIMethodReturnMessage->MethodName ); - } - - return myIMethodReturnMessage; - } - // -}; - -int main() -{ - // Create an instance of MyProxy. - MyProxy^ myCustomProxy = gcnew MyProxy( CustomServer::typeid ); - // Get an instance of remote class. - CustomServer^ myHelloServer = dynamic_cast(myCustomProxy->GetTransparentProxy()); - try - { - // Invoke remote method. - myHelloServer->RaiseException(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodReturnMessage_ReturnValue/CPP/imethodreturnmessage_returnvalue.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IMethodReturnMessage_ReturnValue/CPP/imethodreturnmessage_returnvalue.cpp deleted file mode 100644 index b77b076d05bd4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IMethodReturnMessage_ReturnValue/CPP/imethodreturnmessage_returnvalue.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// System::Runtime::Remoting::Messaging.IMethodReturnMessage* -// System::Runtime::Remoting::Messaging.IMethodReturnMessage*.OutArgs -// System::Runtime::Remoting::Messaging.IMethodReturnMessage*.ReturnValue -// System::Runtime::Remoting::Messaging.IMethodReturnMessage*.OutArgCount -// System::Runtime::Remoting::Messaging.IMethodReturnMessage*.GetOutArg -// System::Runtime::Remoting::Messaging.IMethodReturnMessage*.GetOutArgName - -/* -The following example demonstrates 'ReturnValue', 'OutArgCount' properties, -'GetOutArg', 'GetOutArgName' methods of 'IMethodReturnMessage*' interface -and 'IMethodReturnMessage*' interface. -A custom proxy is created by extending 'RealProxy' and overriding 'Invoke' method of -'RealProxy'. The custom proxy is accessed by passing message to the Invoke method. -The Invoke method calls properties of 'IMethodReturnMessage*' interface and -prints the values to the console. -*/ - -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::InteropServices; - -public ref class CustomServer: public MarshalByRefObject -{ -public: - String^ HelloMethod( String^ myString, interior_ptr myDoubleValue, - [Out]interior_ptr myIntValue ) - { - *myIntValue = 100; - return myString; - } -}; - -// -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::LinkDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -[System::Security::Permissions::SecurityPermissionAttribute -(System::Security::Permissions::SecurityAction::InheritanceDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -public ref class MyProxy: public RealProxy -{ -private: - String^ stringUri; - MarshalByRefObject^ myMarshalByRefObject; - -public: - MyProxy( Type^ myType ) : RealProxy( myType ) - { - myMarshalByRefObject = dynamic_cast(Activator::CreateInstance( myType )); - ObjRef^ myObject = RemotingServices::Marshal( myMarshalByRefObject ); - stringUri = myObject->URI; - } - - // - virtual IMessage^ Invoke( IMessage^ myMessage ) override - { - IMethodCallMessage^ myCallMessage = (IMethodCallMessage^)( myMessage ); - - IMethodReturnMessage^ myIMethodReturnMessage = - RemotingServices::ExecuteMessage( myMarshalByRefObject, myCallMessage ); - - Console::WriteLine( "Method name : {0}", myIMethodReturnMessage->MethodName ); - Console::WriteLine( "The return value is : {0}", myIMethodReturnMessage->ReturnValue ); - - // Get number of 'ref' and 'out' parameters. - int myArgOutCount = myIMethodReturnMessage->OutArgCount; - Console::WriteLine( "The number of 'ref', 'out' parameters are : {0}", - myIMethodReturnMessage->OutArgCount ); - // Gets name and values of 'ref' and 'out' parameters. - for ( int i = 0; i < myArgOutCount; i++ ) - { - Console::WriteLine( "Name of argument {0} is '{1}'.", - i, myIMethodReturnMessage->GetOutArgName( i ) ); - Console::WriteLine( "Value of argument {0} is '{1}'.", - i, myIMethodReturnMessage->GetOutArg( i ) ); - } - Console::WriteLine(); - array^myObjectArray = myIMethodReturnMessage->OutArgs; - for ( int i = 0; i < myObjectArray->Length; i++ ) - Console::WriteLine( "Value of argument {0} is '{1}' in OutArgs", - i, myObjectArray[ i ] ); - return myIMethodReturnMessage; - } - // -}; -// - -int main() -{ - // Create an instance of MyProxy. - MyProxy^ myCustomProxy = gcnew MyProxy( CustomServer::typeid ); - // Get an instance of remote class. - CustomServer^ myHelloServer = - (CustomServer^)( myCustomProxy->GetTransparentProxy() ); - double myDoubleValue = 10.5; - int myIntValue = 200; - // Invoke the remote method. - myHelloServer->HelloMethod( "Hello", &myDoubleValue, &myIntValue ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IObjectReference Interface Example/CPP/iobjectreference.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IObjectReference Interface Example/CPP/iobjectreference.cpp deleted file mode 100644 index e5d090d7dce0f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IObjectReference Interface Example/CPP/iobjectreference.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Runtime::Serialization::Formatters::Binary; -using namespace System::Runtime::Serialization; - -ref class SingletonSerializationHelper; - -// There should be only one instance of this type per AppDomain. - -[Serializable] -public ref class Singleton sealed: public ISerializable -{ -private: - - // This is the one instance of this type. - static Singleton^ theOneObject = gcnew Singleton; - -public: - - // Here are the instance fields. - String^ someString; - Int32 someNumber; - -private: - - // Private constructor allowing this type to construct the singleton. - Singleton() - { - // Do whatever is necessary to initialize the singleton. - someString = "This is a String* field"; - someNumber = 123; - } - -public: - - // A method returning a reference to the singleton. - static Singleton^ GetSingleton() - { - return theOneObject; - } - - // A method called when serializing a Singleton. - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::SerializationFormatter)] - virtual void GetObjectData( SerializationInfo^ info, StreamingContext context ) - { - // Instead of serializing this Object*, we will - // serialize a SingletonSerializationHelp instead. - info->SetType( SingletonSerializationHelper::typeid ); - - // No other values need to be added. - } - - // NOTE: ISerializable*'s special constructor is NOT necessary - // because it's never called -}; - -[Serializable] -private ref class SingletonSerializationHelper sealed: public IObjectReference -{ -public: - - // This Object* has no fields (although it could). - // GetRealObject is called after this Object* is deserialized - virtual Object^ GetRealObject( StreamingContext context ) - { - // When deserialiing this Object*, return a reference to - // the singleton Object* instead. - return Singleton::GetSingleton(); - } -}; - -[STAThread] -int main() -{ - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Create ); - try - { - // Construct a BinaryFormatter and use it - // to serialize the data to the stream. - BinaryFormatter^ formatter = gcnew BinaryFormatter; - - // Create an array with multiple elements refering to - // the one Singleton Object*. - array^a1 = {Singleton::GetSingleton(),Singleton::GetSingleton()}; - - // This displays S"True". - Console::WriteLine( "Do both array elements refer to the same Object? {0}", (a1[ 0 ] == a1[ 1 ]) ); - - // Serialize the array elements. - formatter->Serialize( fs, a1 ); - - // Deserialize the array elements. - fs->Position = 0; - array^a2 = (array^)formatter->Deserialize( fs ); - - // This displays S"True". - Console::WriteLine( "Do both array elements refer to the same Object? {0}", (a2[ 0 ] == a2[ 1 ]) ); - - // This displays S"True". - Console::WriteLine( "Do all array elements refer to the same Object? {0}", (a1[ 0 ] == a2[ 0 ]) ); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to serialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp deleted file mode 100644 index 252026db49226..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* -This program demonstrates the 'Loopback' and 'Broadcast' field of 'IPAddress' class. -It prints the loopback IP address 127.0.0.1 and Broadcast IP address 255.255.255.255 -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void PrintLoopbackAddress() -{ - // Gets the IP loopback address and converts it to a string. - String^ IpAddressString = IPAddress::Loopback->ToString(); - Console::WriteLine( "Loopback IP address : {0}", IpAddressString ); -} -// - -// -void PrintBroadcastAddress() -{ - // Get the IP Broadcast address and convert it to string. - String^ IpAddressString = IPAddress::Broadcast->ToString(); - Console::WriteLine( "\nBroadcast IP address : {0}", IpAddressString ); -} -// - -int main() -{ - PrintLoopbackAddress(); - PrintBroadcastAddress(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp deleted file mode 100644 index e1bb956946698..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -This program demonstrates 'NetworkToHostOrder(short)', 'NetworkToHostOrder(int)' and -'NetworkToHostOrder(long)' methods of 'IPAddress' class. -It takes a String* from commandline for each of above cases and convert it to the corresponding -primitive type(i.e. short, int, long) value. Alternatively it uses default values for each cases. -Then these values are converted from network Byte order to host Byte order by calling the -overloaded 'NetworkToHostOrder' methods of 'IPAddress' class. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void NetworkToHostOrder_Short( short networkByte ) -{ - short hostByte; - // Converts a short value from network Byte order to host Byte order. - hostByte = IPAddress::NetworkToHostOrder( networkByte ); - Console::WriteLine( "Network Byte order to Host Byte order of {0} is {1}", networkByte, hostByte ); -} -// - -// -void NetworkToHostOrder_Integer( int networkByte ) -{ - int hostByte; - // Converts an integer value from network Byte order to host Byte order. - hostByte = IPAddress::NetworkToHostOrder( networkByte ); - Console::WriteLine( "Network Byte order to Host Byte order of {0} is {1}", networkByte, hostByte ); -} -// - -// -void NetworkToHostOrder_Long( __int64 networkByte ) -{ - __int64 hostByte; - // Converts a long value from network Byte order to host Byte order. - hostByte = IPAddress::NetworkToHostOrder( networkByte ); - Console::WriteLine( "Network Byte order to Host Byte order of {0} is {1}", networkByte, hostByte ); -} -// - -int main() -{ - try - { - short networkByteShort = 4365; - int networkByteInt = 286064640; - __int64 networkByteLong = 1228638273342013440I64; - String^ networkByteString = ""; - - Console::Write( "'Program converts Network Byte order to Host Byte order for short, int and long values'" ); - Console::Write( "\nEnter a short value for Convertion(press Enter for default, default is '4365') : " ); - networkByteString = Console::ReadLine(); - if ( networkByteString->Length > 0 ) - networkByteShort = Convert::ToInt16( networkByteString ); - NetworkToHostOrder_Short( networkByteShort ); - - networkByteString = ""; - Console::Write( "\nEnter an Integer value for Convertion(press Enter for default, default is '286064640') : " ); - networkByteString = Console::ReadLine(); - if ( networkByteString->Length > 0 ) - networkByteInt = Convert::ToInt32( networkByteString ); - NetworkToHostOrder_Integer( networkByteInt ); - - networkByteString = ""; - Console::Write( "\nEnter a long value for Convertion(press Enter for default, default is '1228638273342013440') : " ); - networkByteString = Console::ReadLine(); - if ( networkByteString->Length > 0 ) - networkByteLong = Convert::ToInt64( networkByteString ); - NetworkToHostOrder_Long( networkByteLong ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp deleted file mode 100644 index c4ef78097fa02..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -/* -This program demonstrates the 'None' field of 'IPAddress' class. -Provides an IP address indicating that no network interface should be used. -*/ -#using - -using namespace System; -using namespace System::Net; - -// -int main() -{ - - // Gets the IP address indicating that no network interface should be used - // and converts it to a String*. - String^ address = IPAddress::None->ToString(); - Console::WriteLine( "IP address : {0}", address ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp deleted file mode 100644 index fdaff450fae58..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// System.Net.IPEndPoint.MaxPort; System.Net.IPEndPoint.MinPort; -// System.Net.IPEndPoint.AddressFamily; System.Net.IPEndPoint.IPEndPoint(long,int) -// System.Net.IPEndPoint.Address; System.Net.IPEndPoint.Port; - -/*This program demonstrates the properties 'MaxPort', 'MinPort','Address','Port' -and 'AddressFamily' and a constructor 'IPEndPoint(long,int)' of class 'IPEndPoint'. - -A procedure DoSocketGet is created which internally uses a socket to transmit http "Get" requests to a Web resource. -The program accepts a resource Url, Resolves it to obtain 'IPAddress',Constructs 'IPEndPoint' instance using this -'IPAddress' and port 80.Invokes DoSocketGet procedure to obtain a response and displays the response to a console. - -It then accepts another Url, Resolves it to obtain 'IPAddress'. Assigns this IPAddress and port to the 'IPEndPoint' -and again invokes DoSocketGet to obtain a response and display. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::Net::Sockets; -using namespace System::Runtime::InteropServices; - -String^ DoSocketGet( IPEndPoint^ hostIPEndPoint, String^ getString ); // forward reference - -int main() -{ - try - { - Console::Write( "\nPlease enter an INTRANET Url as shown: [e.g. www.microsoft.com]:" ); - String^ hostString1 = Console::ReadLine(); - -// -// -// -// - IPAddress^ hostIPAddress1 = (Dns::Resolve( hostString1 ))->AddressList[ 0 ]; - Console::WriteLine( hostIPAddress1 ); - IPEndPoint^ hostIPEndPoint = gcnew IPEndPoint( hostIPAddress1,80 ); - Console::WriteLine( "\nIPEndPoint information:{0}", hostIPEndPoint ); - Console::WriteLine( "\n\tMaximum allowed Port Address :{0}", IPEndPoint::MaxPort ); - Console::WriteLine( "\n\tMinimum allowed Port Address :{0}", (int^)IPEndPoint::MinPort ); - Console::WriteLine( "\n\tAddress Family :{0}", hostIPEndPoint->AddressFamily ); -// - Console::Write( "\nPress Enter to continue" ); - Console::ReadLine(); - String^ getString = String::Format( "GET / HTTP/1.1\r\nHost: {0}\r\nConnection: Close\r\n\r\n", hostString1 ); - String^ pageContent = DoSocketGet( hostIPEndPoint, getString ); - if ( pageContent != nullptr ) - { - Console::WriteLine( "Default HTML page on {0} is:\r\n{1}", hostString1, pageContent ); - } -// -// -// - - Console::Write( "\n\n\nPlease enter another INTRANET Url as shown[e.g. www.microsoft.com]: " ); - String^ hostString2 = Console::ReadLine(); - -// -// - IPAddress^ hostIPAddress2 = (Dns::Resolve( hostString2 ))->AddressList[ 0 ]; - hostIPEndPoint->Address = hostIPAddress2; - hostIPEndPoint->Port = 80; - - getString = String::Format( "GET / HTTP/1.1\r\nHost: {0}\r\nConnection: Close\r\n\r\n", hostString2 ); - pageContent = DoSocketGet( hostIPEndPoint, getString ); - if ( pageContent != nullptr ) - { - Console::WriteLine( "Default HTML page on {0} is:\r\n{1}", hostString2, pageContent ); - } - -// -// - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -String^ DoSocketGet( IPEndPoint^ hostIPEndPoint, String^ getString ) -{ - try - { - // Set up variables and String to write to the server. - Encoding^ ASCII = Encoding::ASCII; - - array^ byteGet = ASCII->GetBytes( getString ); - array^ recvBytes = gcnew array(256); - String^ strRetPage = nullptr; - // Create the Socket for sending data over TCP. - Socket^ mySocket = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream,ProtocolType::Tcp ); - // Connect to host using IPEndPoint. - mySocket->Connect( hostIPEndPoint ); - // Send the GET text to the host. - mySocket->Send( byteGet, byteGet->Length, (SocketFlags)( 0 ) ); - // Receive the page, loop until all bytes are received. - Int32 byteCount = mySocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)( 0 ) ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( recvBytes, 0, byteCount ) ); - while ( byteCount > 0 ) - { - byteCount = mySocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)( 0 ) ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( recvBytes, 0, byteCount ) ); - } - return strRetPage; - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - Console::WriteLine( "WinSock Error : {0}", Convert::ToString( Marshal::GetLastWin32Error() ) ); - return nullptr; - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp deleted file mode 100644 index f51adc5cf17f5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -This program demostrates 'AddressList' property of 'IPHostEntry' class. -It takes a URL from commandline(or uses default value) and obtains a -'IPHostEntry' Object* by calling 'GetHostByName' method of 'Dns' class and -prints the host name and IP addresses associated with the specified URL. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -// -void GetIpAddressList( String^ hostString ) -{ - try - { - // Get 'IPHostEntry' object containing information - // like host name, IP addresses, aliases for a host. - IPHostEntry^ hostInfo = Dns::GetHostByName( hostString ); - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "IP address List : " ); - for ( int index = 0; index < hostInfo->AddressList->Length; index++ ) - Console::WriteLine( hostInfo->AddressList[ index ] ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// - -int main() -{ - String^ hostString = " "; - - // Create an instance of HostInfoSample class. - Console::Write( "Type a URL(or press Enter for default, default is 'www.microsoft.net') : " ); - hostString = Console::ReadLine(); - if ( hostString->Length > 0 ) - GetIpAddressList( hostString ); - else - GetIpAddressList( "www.microsoft.net" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ISerializable Interface Example/CPP/iobjectreference.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ISerializable Interface Example/CPP/iobjectreference.cpp deleted file mode 100644 index abb2b85494bb7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ISerializable Interface Example/CPP/iobjectreference.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Runtime::Serialization::Formatters::Binary; -using namespace System::Runtime::Serialization; - -ref class SingletonSerializationHelper; - -// There should be only one instance of this type per AppDomain. - -[Serializable] -public ref class Singleton sealed: public ISerializable -{ -private: - - // This is the one instance of this type. - static Singleton^ theOneObject = gcnew Singleton; - -public: - - // Here are the instance fields. - String^ someString; - Int32 someNumber; - -private: - - // Private constructor allowing this type to construct the singleton. - Singleton() - { - - // Do whatever is necessary to initialize the singleton. - someString = "This is a String* field"; - someNumber = 123; - } - -public: - - // A method returning a reference to the singleton. - static Singleton^ GetSingleton() - { - return theOneObject; - } - - // A method called when serializing a Singleton. - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::SerializationFormatter)] - virtual void GetObjectData( SerializationInfo^ info, StreamingContext context ) - { - // Instead of serializing this Object*, we will - // serialize a SingletonSerializationHelp instead. - info->SetType( SingletonSerializationHelper::typeid ); - - // No other values need to be added. - } - - // NOTE: ISerializable*'s special constructor is NOT necessary - // because it's never called -}; - -[Serializable] -private ref class SingletonSerializationHelper sealed: public IObjectReference -{ -public: - - // This Object* has no fields (although it could). - // GetRealObject is called after this Object* is deserialized - virtual Object^ GetRealObject( StreamingContext context ) - { - // When deserialiing this Object*, return a reference to - // the singleton Object* instead. - return Singleton::GetSingleton(); - } -}; - -[STAThread] -int main() -{ - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Create ); - try - { - // Construct a BinaryFormatter and use it - // to serialize the data to the stream. - BinaryFormatter^ formatter = gcnew BinaryFormatter; - - // Create an array with multiple elements refering to - // the one Singleton Object*. - array^a1 = {Singleton::GetSingleton(),Singleton::GetSingleton()}; - - // This displays S"True". - Console::WriteLine( "Do both array elements refer to the same Object? {0}", (a1[ 0 ] == a1[ 1 ]) ); - - // Serialize the array elements. - formatter->Serialize( fs, a1 ); - - // Deserialize the array elements. - fs->Position = 0; - array^a2 = (array^)formatter->Deserialize( fs ); - - // This displays S"True". - Console::WriteLine( "Do both array elements refer to the same Object? {0}", (a2[ 0 ] == a2[ 1 ]) ); - - // This displays S"True". - Console::WriteLine( "Do all array elements refer to the same Object? {0}", (a1[ 0 ] == a2[ 0 ]) ); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to serialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IServerChannelSinkProvider_CreateSink/CPP/iserverchannelsinkprovider_3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IServerChannelSinkProvider_CreateSink/CPP/iserverchannelsinkprovider_3.cpp deleted file mode 100644 index a648e8a91ee04..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IServerChannelSinkProvider_CreateSink/CPP/iserverchannelsinkprovider_3.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// System.Runtime.Remoting.Channels.IServerChannelSinkProvider.CreateSink() -// System.Runtime.Remoting.Channels.IServerChannelSinkProvider.GetChannelData() -// System.Runtime.Remoting.Channels.IServerChannelSinkProvider.Next - -/* The following program demonstrates 'CreateSink', 'GetChannelData' - methods and 'Next' property of - 'System.Runtime.Remoting.Channels.ServerChannelSinkStack' class. - It chains together two different sink providers using the 'Next' - property. The return value of 'GetChannelData()' is displayed on - the console. -*/ - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -ref class MyServerChannelSinkStack -{ -public: - IServerChannelSinkProvider^ myIServerChannelSinkProvider; - IServerChannelSinkProvider^ myIServerChannelSinkProvider1; - IServerChannelSink^ myIServerChannelSink; - IServerChannelSink^ myIServerChannelSink1; - - void MyCreateSinkMethod() - { - Console::Write( "Press Enter to set sink providers and create sinks" ); - Console::ReadLine(); - -// -// - // Create the sink providers. - myIServerChannelSinkProvider = gcnew SoapServerFormatterSinkProvider; - myIServerChannelSinkProvider1 = gcnew BinaryServerFormatterSinkProvider; - // Create the channel sinks. - myIServerChannelSink = myIServerChannelSinkProvider->CreateSink( gcnew HttpChannel ); - myIServerChannelSinkProvider->Next = myIServerChannelSinkProvider1; - - myIServerChannelSink1 = myIServerChannelSinkProvider->Next->CreateSink( gcnew HttpChannel ); -// -// - Console::WriteLine( "Two sink providers have been set" ); - } - - void MyGetChannelDataMethod() - { -// - array^channelUri = gcnew array(5); - IChannelDataStore^ myIChannelDataStore = gcnew ChannelDataStore( channelUri ); - IChannelDataStore^ myIChannelDataStore1 = gcnew ChannelDataStore( channelUri ); - myIServerChannelSinkProvider->GetChannelData( myIChannelDataStore ); - myIServerChannelSinkProvider1->GetChannelData( myIChannelDataStore1 ); -// - - Console::WriteLine( "Number of Uris in first IChannelDataStore: {0}", - myIChannelDataStore->ChannelUris->Length ); - Console::WriteLine( "Number of Uris in second IChannelDataStore: {0}", - myIChannelDataStore1->ChannelUris->Length ); - } -}; - -int main() -{ - MyServerChannelSinkStack^ myNewServerChannelSinkStack = - gcnew MyServerChannelSinkStack; - myNewServerChannelSinkStack->MyCreateSinkMethod(); - myNewServerChannelSinkStack->MyGetChannelDataMethod(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/isponsor_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/isponsor_client.cpp deleted file mode 100644 index 950c783ff0b0f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/isponsor_client.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// System::Runtime::Remoting::Lifetime.ISponsor -// System::Runtime::Remoting::Lifetime.ISponsor.Renewal - -/* -The following program demonstrates the 'ISponsor' interface and its 'Renewal' method. -It defines 'MyClientSponsor' which implements 'ISponsor' interface. The server and -client is created. The client registers a sponsor that(after the initial lease time) -renews the lease at different time from that specified in the remote type. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Security::Permissions; - -// -// -public ref class MyClientSponsor: public MarshalByRefObject, public ISponsor -{ -private: - DateTime lastRenewal; - -public: - MyClientSponsor() - { - lastRenewal = DateTime::Now; - } - - [SecurityPermissionAttribute(SecurityAction::LinkDemand,Flags=SecurityPermissionFlag::Infrastructure)] - virtual TimeSpan Renewal( ILease^ /* lease */ ) - { - Console::WriteLine( "Request to renew the lease time." ); - Console::WriteLine( "Time since last renewal: {0}", - DateTime::Now - lastRenewal ); - - lastRenewal = DateTime::Now; - return TimeSpan::FromSeconds( 20 ); - } -}; -// -// - -int main() -{ - // Load the configuration file. - RemotingConfiguration::Configure( "ISponsor_Client.config" ); - ClientActivatedType ^ clientActivatedObject = gcnew ClientActivatedType; - - ILease^ serverLease = (ILease^)( RemotingServices::GetLifetimeService( - clientActivatedObject ) ); - MyClientSponsor^ sponsor = gcnew MyClientSponsor; - - // Note: If you don't pass an initial time, the first request will be taken - // from the LeaseTime settings specified in the ISponsor_Server.config file. - serverLease->Register( sponsor ); - - Console::WriteLine( "Client-activated Object.\n {0}", - clientActivatedObject->RemoteMethod() ); - Console::WriteLine( "Press enter to end the client application domain." ); - Console::ReadLine(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/isponsor_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/isponsor_server.cpp deleted file mode 100644 index a9a6b502a421d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/isponsor_server.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; - -int main() -{ - RemotingConfiguration::Configure( "ISponsor_Server.config" ); - - Console::WriteLine( "The server is listening. Press Enter to exit...." ); - Console::ReadLine(); - - Console::WriteLine( "Garbage Collecting." ); - GC::Collect(); - GC::WaitForPendingFinalizers(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/makefile deleted file mode 100644 index 04526f1be0c1c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: isponsor_client.exe isponsor_server.exe - -isponsor_client.exe: isponsor_client.cpp remotetype.dll - cl /clr:pure isponsor_client.cpp - -isponsor_server.exe: isponsor_server.cpp remotetype.dll - cl /clr:pure isponsor_server.cpp - -remotetype.dll: remotetype.cpp - cl /clr:pure /LD remotetype.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/remotetype.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/remotetype.cpp deleted file mode 100644 index e5ecc3d8df9fa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ISponsor_Client/CPP/remotetype.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Security::Principal; - -public ref class ClientActivatedType: public MarshalByRefObject -{ -public: - // Override the lease settings for this Object. - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual Object^ InitializeLifetimeService() override - { - ILease^ lease = (ILease^)( MarshalByRefObject::InitializeLifetimeService() ); - if ( lease->CurrentState == LeaseState::Initial ) - { - lease->InitialLeaseTime = TimeSpan::FromSeconds( 3 ); - lease->SponsorshipTimeout = TimeSpan::FromSeconds( 10 ); - lease->RenewOnCallTime = TimeSpan::FromSeconds( 2 ); - } - return lease; - } - - String^ RemoteMethod() - { - Console::WriteLine( "ClientActivatedType::RemoteMethod called." ); - - // Report our client identity name. - return "RemoteMethodCalled. User name : {0}",WindowsIdentity::GetCurrent()->Name; - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/ITransportHeaders_3_Share.cs b/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/ITransportHeaders_3_Share.cs deleted file mode 100644 index 525cb3639ef9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/ITransportHeaders_3_Share.cs +++ /dev/null @@ -1,16 +0,0 @@ -/* Supporting file for the ITransportHeaders_3_Server.cs - */ -using System; - -public class MyHelloServer : MarshalByRefObject -{ - public MyHelloServer() - { - Console.WriteLine("HelloServer activated..."); - } - public String MyHelloMethod(String name) - { - Console.WriteLine("MyHelloServer.MyHelloMethod : {0}", name); - return "Hello " + name ; - } -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/itransportheaders_3_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/itransportheaders_3_server.cpp deleted file mode 100644 index e161a956e00e6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/itransportheaders_3_server.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -// System.Runtime.Remoting.Channels.ITransportHeaders -// System.Runtime.Remoting.Channels.ITransportHeaders.Item -// System.Runtime.Remoting.Channels.ITransportHeaders.GetEnumerator() -/* The following program demonstrates the 'ITransportHeaders' interface, -its 'Item' property and 'GetEnumerator' method. It implements the 'Item' -property and 'GetEnumerator' method in a class derived from 'ITransportHeaders' -interface. It then adds a few headers to the header list and displays them. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -ref class MyITransportHeadersClass: public ITransportHeaders -{ -private: - - // - // - int myInt; - array^myDictionaryEntry; - -public: - MyITransportHeadersClass() - { - myInt = 0; - myDictionaryEntry = gcnew array(10); - } - - - property Object^ Item [Object^] - { - - // Implement the 'Item' property. - virtual Object^ get( Object^ myKey ) - { - if ( myKey != nullptr ) - { - for ( int i = 0; i <= myInt; i++ ) - if ( myDictionaryEntry[ i ].Key == myKey ) - return myDictionaryEntry[ i ].Value; - } - - return nullptr; - } - - virtual void set( Object^ myKey, Object^ value ) - { - myDictionaryEntry[ myInt ] = DictionaryEntry(myKey,value); - myInt++; - } - - } - - // Implement the 'GetEnumerator' method. - virtual IEnumerator^ GetEnumerator() - { - Hashtable^ myHashtable = gcnew Hashtable; - for ( int j = 0; j < myInt; j++ ) - myHashtable->Add( myDictionaryEntry[ j ].Key, myDictionaryEntry[ j ].Value ); - return myHashtable->GetEnumerator(); - } - - // - // -}; - -int main() -{ - try - { - - // Create and register a 'TcpChannel' object. - TcpChannel^ myTcpChannel = gcnew TcpChannel( 8085 ); - ChannelServices::RegisterChannel( myTcpChannel, false ); - RemotingConfiguration::RegisterWellKnownServiceType( MyHelloServer::typeid, "SayHello", WellKnownObjectMode::SingleCall ); - - // Create an instance of 'myITransportHeadersObj'. - MyITransportHeadersClass^ myITransportHeadersObj = gcnew MyITransportHeadersClass; - ITransportHeaders^ myITransportHeaders = dynamic_cast(myITransportHeadersObj); - - // Add items to the header list. - myITransportHeaders->default[ "Header1" ] = "TransportHeader1"; - myITransportHeaders->default[ "Header2" ] = "TransportHeader2"; - - // Get the 'ITranportHeader' item value with key 'Header2'. - Console::WriteLine( "ITransport Header item value with key 'Header2' is :{0}", myITransportHeaders->default[ "Header2" ] ); - IEnumerator^ myEnumerator = myITransportHeaders->GetEnumerator(); - Console::WriteLine( " -KEY- -VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - - // Display the 'Key' and 'Value' of the current element. - Object^ myEntry = myEnumerator->Current; - DictionaryEntry myDictionaryEntry = *dynamic_cast(myEntry); - Console::WriteLine( " {0}: {1}", myDictionaryEntry.Key, myDictionaryEntry.Value ); - } - Console::WriteLine( "Hit to exit..." ); - Console::ReadLine(); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception is raised on the server side: {0}", ex->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/makefile deleted file mode 100644 index bdb7b77d7421e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ITransportHeaders_Item/CPP/makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: ITransportHeaders_3_Share.dll itransportheaders_3_server.exe - -ITransportHeaders_3_Share.dll: ITransportHeaders_3_Share.cs - csc /t:library ITransportHeaders_3_Share.cs - -ITransportHeaders_3_server.exe: itransportheaders_3_server.cpp ITransportHeaders_3_Share.dll - cl /clr itransportheaders_3_server.cpp - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp deleted file mode 100644 index 51a46703a72dc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -This program demonstrates 'Credentials' property, 'GetProxy' and 'IsBypassed' methods of -IWebProxy* interface. -The 'WebProxy_Interface' class implements the 'IWebProxy*' interface. It provides an implementation for the -'GetProxy' and 'IsByPassed' methods and 'ICredentials*' property. The 'GetProxy' method returns the url -of the proxy server as specified in the constructor. The 'IsByPassed' method returns false indicating -that the proxy server must never be bypassed for any requested url. The 'ICredentials*' property stores -the credentials required by the proxy server to authenticate the actual user. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -// -// -public ref class WebProxy_Interface: public IWebProxy -{ -private: - // The credentials to be used with the web proxy. - ICredentials^ iCredentials; - - // Uri of the associated proxy server. - Uri^ webProxyUri; - -public: - WebProxy_Interface( Uri^ proxyUri ) - { - webProxyUri = proxyUri; - } - - property ICredentials^ Credentials - { - // Get and Set the Credentials property. - virtual ICredentials^ get() - { - return iCredentials; - } - virtual void set( ICredentials^ value ) - { - if ( iCredentials != value ) - { - iCredentials = value; - } - } - } - - // Return the web proxy for the specified destination (destUri). - virtual Uri^ GetProxy( Uri^ destUri ) - { - // Always use the same proxy. - return webProxyUri; - } - - // Return whether the web proxy should be bypassed for the specified destination (hostUri). - virtual bool IsBypassed( Uri^ hostUri ) - { - // Never bypass the proxy. - return false; - } -}; -// -// -// - -int main() -{ - // - WebProxy_Interface^ webProxy_Interface = gcnew WebProxy_Interface( gcnew Uri( "http://proxy.example.com" ) ); - - webProxy_Interface->Credentials = gcnew NetworkCredential( "myusername", "mypassword" ); - - Console::WriteLine( "The web proxy is : {0}", webProxy_Interface->GetProxy( gcnew Uri( "http://www.contoso.com" ) ) ); - - // Check if the webproxy can ne bypassed for the site "http://www.contoso.com". - if ( webProxy_Interface->IsBypassed( gcnew Uri( "http://www.contoso.com" ) ) ) - { - Console::WriteLine( "Web Proxy is by passed" ); - } - else - { - Console::WriteLine( "Web Proxy is not by passed" ); - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ImportCollection_6/CPP/StockQuoteService_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/ImportCollection_6/CPP/StockQuoteService_cpp.wsdl deleted file mode 100644 index ba2aaa247d148..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ImportCollection_6/CPP/StockQuoteService_cpp.wsdl +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - My first service - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ImportCollection_6/CPP/importcollection_6.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ImportCollection_6/CPP/importcollection_6.cpp deleted file mode 100644 index a896ff5bdcf91..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ImportCollection_6/CPP/importcollection_6.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// System::Web::Services::Description.ImportCollection -// System::Web::Services::Description.ImportCollection::Item -// System::Web::Services::Description.ImportCollection::CopyTo -// System::Web::Services::Description.ImportCollection::Contains -// System::Web::Services::Description.ImportCollection::IndexOf -// System::Web::Services::Description.ImportCollection::Remove - -/* The following program demonstrates the methods 'CopyTo', 'Contains', 'IndexOf', 'Remove' -and property 'Item' of class 'ImportCollection'. -The program reads a 'WSDL' document and gets a 'ServiceDescription' instance -An 'ImportCollection' instance is then retrieved from this 'ServiceDescription' -instance and its members have been demonstrated. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuoteService_cpp.wsdl" ); - Console::WriteLine( " ImportCollection Sample " ); - - // - // Get Import Collection. - ImportCollection^ myImportCollection = myServiceDescription->Imports; - Console::WriteLine( "Total Imports in the document = {0}", myServiceDescription->Imports->Count ); - - // Print 'Import' properties to console. - for ( int i = 0; i < myImportCollection->Count; ++i ) - Console::WriteLine( "\tImport Namespace : {0} Import Location : {1} ", - myImportCollection[ i ]->Namespace, myImportCollection[ i ]->Location ); - // - - // - array^myImports = gcnew array(myServiceDescription->Imports->Count); - - // Copy 'ImportCollection' to an array. - myServiceDescription->Imports->CopyTo( myImports, 0 ); - Console::WriteLine( "Imports that are copied to Importarray ..." ); - for ( int i = 0; i < myImports->Length; ++i ) - Console::WriteLine( "\tImport Namespace : {0} Import Location : {1} ", - myImports[ i ]->Namespace, myImports[ i ]->Location ); - // - - // - // - // - // Get Import by Index. - Import^ myImport = myServiceDescription->Imports[ myServiceDescription->Imports->Count - 1 ]; - Console::WriteLine( "Import by Index..." ); - if ( myImportCollection->Contains( myImport ) ) - { - Console::WriteLine( "Import Namespace ' {0} ' is found in 'ImportCollection'.", myImport->Namespace ); - Console::WriteLine( "Index of '{0}' in 'ImportCollection' = {1}", - myImport->Namespace, myImportCollection->IndexOf( myImport ) ); - Console::WriteLine( "Deleting Import from 'ImportCollection'..." ); - myImportCollection->Remove( myImport ); - if ( myImportCollection->IndexOf( myImport ) == -1 ) - Console::WriteLine( "Import is successfully removed from Import Collection." ); - } - // - // - // -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Importsample/CPP/importsample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Importsample/CPP/importsample.cpp deleted file mode 100644 index 84b92d63c6bfd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Importsample/CPP/importsample.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// System::Web::Services::Description.ImportCollection->Add; -// System::Web::Services::Description.ImportCollection::Insert; -// System::Web::Services::Description.Import::Import(); -// System::Web::Services::Description.Import::Location; -// System::Web::Services::Description.Import::Namespace; -// System::Web::Services::Description.Import::ServiceDescription; -// System::Web::Services::Description.Import; - -/* The following example demonstrates the constructor 'Import()' and properties 'Namespace', 'Location', 'Namespace', -'ServiceDescription' of Import Class. Methods 'Add' and 'Insert' of Class 'ImportCollection' are also demonstrated. -This example uses a sample provided in WSDL specification to explain Import and ImportCollection. -It adds import instances to ImportCollection as suggested in the specification sample and enumerates the same to the console. -Note: This is an illustrative sample using an example from WSDL specification. The real world web service has been assumed. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -// -// -// -// Creates an Import object with namespace and location. -Import^ CreateImport( String^ targetNamespace, String^ targetlocation ) -{ - Import^ myImport = gcnew Import; - myImport->Location = targetlocation; - myImport->Namespace = targetNamespace; - return myImport; -} -// -// -// - -// -void PrintImportCollection( String^ fileName_wsdl ) -{ - // Read import collection properties from generated WSDL file. - ServiceDescription^ myServiceDescription1 = ServiceDescription::Read( fileName_wsdl ); - ImportCollection^ myImportCollection = myServiceDescription1->Imports; - Console::WriteLine( "Enumerating Import Collection for file ' {0}'...", fileName_wsdl ); - - // Print Import properties to console. - for ( int i = 0; i < myImportCollection->Count; ++i ) - { - Console::WriteLine( "Namespace : {0}", myImportCollection[ i ]->Namespace ); - Console::WriteLine( "Location : {0}", myImportCollection[ i ]->Location ); - Console::WriteLine( "ServiceDescription : {0}", myImportCollection[ i ]->ServiceDescription->Name ); - } -} -// - -int main() -{ - Console::WriteLine( "Import Sample" ); - - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote_cpp.wsdl" ); - myServiceDescription->Imports->Add( CreateImport( "http://localhost/stockquote/schemas", "http://localhost/stockquote/stockquote_cpp.xsd" ) ); - // - - // Save the ServiceDescripition to an external file. - myServiceDescription->Write( "StockQuote_cpp.wsdl" ); - Console::WriteLine( "document 'StockQuote_cpp.wsdl'" ); - - // Print the import collection to the console. - PrintImportCollection( "StockQuote_cpp.wsdl" ); - - // - myServiceDescription = ServiceDescription::Read( "StockQuoteService_cpp.wsdl" ); - myServiceDescription->Imports->Insert( 0, CreateImport( "http://localhost/stockquote/definitions", "http://localhost/stockquote/stockquote_cpp.wsdl" ) ); - // - - // Save the ServiceDescripition to an external file. - myServiceDescription->Write( "StockQuoteService_cs::wsdl" ); - Console::WriteLine( "" ); - Console::WriteLine( "document 'StockQuoteService_cpp.wsdl'" ); - - //Print the import collection to the console. - PrintImportCollection( "StockQuoteService_cpp.wsdl" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_BeginInvoke/CPP/logicalmethodinfo_begininvoke.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_BeginInvoke/CPP/logicalmethodinfo_begininvoke.cpp deleted file mode 100644 index 052c76a6eb843..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_BeginInvoke/CPP/logicalmethodinfo_begininvoke.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// System.Web.Services.Protocols.LogicalMethodInfo.BeginInvoke(object,object[],AsyncCallback,object) -// System.Web.Services.Protocols.LogicalMethodInfo.EndInvoke(object,IAsyncResult) - -/* The following example demonstrates 'BeginInvoke' and 'EndInvoke' methods of -'LogicalMethodInfo' class. The 'Add' method of Math web service is called in asynchronous mode. 'BeginInvoke' -begins asynchronous invocation of method and 'EndInvoke' terminates the invocation -started by 'BeginInvoke'. The return value returned by 'Endinvoke' is displayed. - -Note: The MyMath class is a proxy class generated by the Wsdl.exe utility for -the Math Web Service. This class can also be found in SoapHttpClientProtocol Class example. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Web::Services::Protocols; -using namespace System::Security::Permissions; - -// Automatically generated proxy class for Math Web service. -// This class can also be found in the SoapHttpClientProtocol class example. -namespace MyMath -{ - using namespace System::Diagnostics; - using namespace System::Xml::Serialization; - using namespace System::Web::Services::Protocols; - using namespace System::Web::Services; - - [System::Web::Services::WebServiceBindingAttribute( - Name="MyMathSoap",Namespace="http://tempuri.org/")] - public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - MyMath() - { - this->Url = "http://localhost/Math.asmx"; - } - - [System::Web::Services::Protocols::SoapDocumentMethodAttribute( - "http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int x, int y ) - { - array^ temp2 = { x, y }; - array^ results = this->Invoke( "Add", temp2 ); - return (int)( results[ 0 ] ); - } - - System::IAsyncResult^ BeginAdd( int x, int y, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^ temp3 = {x,y}; - return this->BeginInvoke( "Add", temp3, callback, asyncState ); - } - - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^ results = this->EndInvoke( asyncResult ); - return (int)( results[ 0 ] ); - } - }; -} - -public ref class BeginInvokeClass -{ - // - // -public: - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - static void main() - { - // Get the type information. - // Note: The MyMath class is a proxy class generated by the Wsdl.exe - // utility for the Math Web service. This class can also be found in - // the SoapHttpClientProtocol class example. - Type^ myType = MyMath::MyMath::typeid; - - // Get the method info. - MethodInfo^ myBeginMethod = myType->GetMethod( "BeginAdd" ); - MethodInfo^ myEndMethod = myType->GetMethod( "EndAdd" ); - - // Create an instance of the LogicalMethodInfo class. - array^ temp0 = { myBeginMethod, myEndMethod }; - LogicalMethodInfo^ myLogicalMethodInfo = - ( LogicalMethodInfo::Create( temp0, LogicalMethodTypes::Async ) )[ 0 ]; - - // Get an instance of the proxy class. - MyMath::MyMath^ myMathService = gcnew MyMath::MyMath; - - // Call the MyEndIntimationMethod method to intimate the end of - // the asynchronous call. - AsyncCallback^ myAsyncCallback = gcnew AsyncCallback( MyEndIntimationMethod ); - - // Begin to invoke the Add method. - array^ temp1 = { 10, 10 }; - IAsyncResult^ myAsyncResult = myLogicalMethodInfo->BeginInvoke( - myMathService, temp1, myAsyncCallback, nullptr ); - - // Wait until invoke is complete. - myAsyncResult->AsyncWaitHandle->WaitOne(); - - // Get the result. - array^ myReturnValue; - myReturnValue = myLogicalMethodInfo->EndInvoke( myMathService, myAsyncResult ); - - Console::WriteLine( "Sum of 10 and 10 is {0}", myReturnValue[ 0 ] ); - } - - // This method will be called at the end of the asynchronous call. - static void MyEndIntimationMethod( IAsyncResult^ /*Result*/ ) - { - Console::WriteLine( "Asynchronous call on Add method finished." ); - } - // - // -}; - -int main() -{ - BeginInvokeClass::main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Constructor/CPP/logicalmethodinfo_constructor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Constructor/CPP/logicalmethodinfo_constructor.cpp deleted file mode 100644 index 6845810ce5a2f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Constructor/CPP/logicalmethodinfo_constructor.cpp +++ /dev/null @@ -1,66 +0,0 @@ - - -// All the following have been marked as 1 snippet : Snippet1 -// System::Web::Services::Protocols.LogicalMethodInfo::LogicalMethodInfo(MethodInfo) -// System::Web::Services::Protocols.LogicalMethodInfo::DeclaringType -// System::Web::Services::Protocols.LogicalMethodInfo::Parameters -// System::Web::Services::Protocols.LogicalMethodInfo::ReturnType -// System::Web::Services::Protocols.LogicalMethodInfo::Invoke(Object*, Object*->Item[]) -// System::Web::Services::Protocols.LogicalMethodInfo -/* -This following example demonstrates the constructor, 'DeclaringType', -'Parameters', 'ReturnType' properties and 'Invoke(Object*, Object*->Item[])', -'ToString()' methods of the 'LogicalMethodInfo' class. This example -displays the declaring type, parameters, return type of a method -named 'Add' in the class named 'MyService'. - -Note : The 'LogicalMethodInfo' class should only be used with -'SoapMessage'. 'SoapClientMessage' and 'SoapServerMessage' contain -a property named 'MethodInfo' which provides for an instance of -'LogicalMethodInfo'. If you are interested only in the reflection -of a type then use the 'System::Reflection' namespace and not this -class. This class gives information ab->Item[Out] the* method invoked for -a web service and hence should only be used as such. For example -purposes it is being showed in a more simplified scenario. -*/ -// -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Web::Services::Protocols; - -public ref class MyService -{ -public: - int Add( int xValue, int yValue ) - { - return (xValue + yValue); - } - -}; - -int main() -{ - Type^ myType = MyService::typeid; - MethodInfo^ myMethodInfo = myType->GetMethod( "Add" ); - LogicalMethodInfo^ myLogicalMethodInfo = gcnew LogicalMethodInfo( myMethodInfo ); - Console::WriteLine( "\nPrinting properties of method : {0}\n", myLogicalMethodInfo ); - Console::WriteLine( "\nThe declaring type of the method {0} is :\n", myLogicalMethodInfo->Name ); - Console::WriteLine( "\t {0}", myLogicalMethodInfo->DeclaringType ); - Console::WriteLine( "\nThe parameters of the method {0} are :\n", myLogicalMethodInfo->Name ); - array^myParameters = myLogicalMethodInfo->Parameters; - for ( int i = 0; i < myParameters->Length; i++ ) - { - Console::WriteLine( "\t {0}", String::Concat( myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) ); - } - Console::WriteLine( "\nThe return type of the method {0} is :\n", myLogicalMethodInfo->Name ); - Console::WriteLine( "\t {0}", myLogicalMethodInfo->ReturnType ); - MyService^ service = gcnew MyService; - Console::WriteLine( "\nInvoking the method {0}\n", myLogicalMethodInfo->Name ); - array^values = gcnew array(2); - values[ 0 ] = 10; - values[ 1 ] = 10; - Console::WriteLine( "\tThe sum of 10 and 10 is : {0}", myLogicalMethodInfo->Invoke( service, values ) ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Create1/CPP/logicalmethodinfo_create1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Create1/CPP/logicalmethodinfo_create1.cpp deleted file mode 100644 index 3710797439f81..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Create1/CPP/logicalmethodinfo_create1.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -// All the following have been marked as 1 snippet : Snippet1 -// System::Web::Services::Protocols.LogicalMethodInfo::Create(MethodInfo) -// System::Web::Services::Protocols.LogicalMethodInfo::Name -// System::Web::Services::Protocols.LogicalMethodInfo::InParameters -// System::Web::Services::Protocols.LogicalMethodInfo::OutParameters -// System::Web::Services::Protocols.LogicalMethodInfo::IsVoid -/* -This following example demonstrates the 'Name', -'InParameters', 'OutParameters', 'IsVoid' properties and -'Create(MethodInfo)' method of the 'LogicalMethodInfo' class. -This example displays the parameters, the in parameters and -[Out] parameters. - - -Note : The 'LogicalMethodInfo' class should only be used with -'SoapMessage'. 'SoapClientMessage' and 'SoapServerMessage' contain -a property named 'MethodInfo' which provides for an instance of -'LogicalMethodInfo'. If you are interested only in the reflection -of a type then use the 'System::Reflection' namespace and not this -class. This class gives information ab->Item[Out] the* method invoked for -a web service and hence should only be used as such. For example -purposes it is being showed in a more simplified scenario. -*/ -// -#using - -using namespace System; -using namespace System::Runtime::InteropServices; -using namespace System::Reflection; -using namespace System::Web::Services::Protocols; - -public ref class MyService -{ -public: - void MyMethod( int inParameter, [Out]interior_ptr outParameter ) - { - *outParameter = inParameter; - } -}; - -int main() -{ - Type^ myType = MyService::typeid; - MethodInfo^ myMethodInfo = myType->GetMethod( "MyMethod" ); - array^temparray = {myMethodInfo}; - LogicalMethodInfo^ myLogicalMethodInfo = (LogicalMethodInfo::Create( temparray ))[ 0 ]; - Console::WriteLine( "\nPrinting parameters for the method : {0}", myLogicalMethodInfo->Name ); - Console::WriteLine( "\nThe parameters of the method {0} are :\n", myLogicalMethodInfo->Name ); - array^myParameters = myLogicalMethodInfo->Parameters; - for ( int i = 0; i < myParameters->Length; i++ ) - { - Console::WriteLine( String::Concat( "\t ", myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) ); - - } - Console::WriteLine( "\nThe in parameters of the method {0} are :\n", myLogicalMethodInfo->Name ); - myParameters = myLogicalMethodInfo->InParameters; - for ( int i = 0; i < myParameters->Length; i++ ) - { - Console::WriteLine( String::Concat( "\t ", myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) ); - - } - Console::WriteLine( "\nThe out parameters of the method {0} are :\n", myLogicalMethodInfo->Name ); - myParameters = myLogicalMethodInfo->OutParameters; - for ( int i = 0; i < myParameters->Length; i++ ) - { - Console::WriteLine( String::Concat( "\t ", myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) ); - - } - if ( myLogicalMethodInfo->IsVoid ) - Console::WriteLine( "\nThe return type is void" ); - else - Console::WriteLine( "\nThe return type is {0}", myLogicalMethodInfo->ReturnType ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Create2/CPP/logicalmethodinfo_create2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Create2/CPP/logicalmethodinfo_create2.cpp deleted file mode 100644 index c626ad55b86ce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_Create2/CPP/logicalmethodinfo_create2.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// System::Web::Services::Protocols.LogicalMethodInfo::Create(MethodInfo->Item[], LogicalMethodTypes) -// System::Web::Services::Protocols.LogicalMethodInfo::AsyncCallbackParameter -// System::Web::Services::Protocols.LogicalMethodInfo::AsyncStateParameter -// System::Web::Services::Protocols.LogicalMethodInfo::AsyncResultParameter -// System::Web::Services::Protocols.LogicalMethodInfo::BeginMethodInfo -// System::Web::Services::Protocols.LogicalMethodInfo::EndMethodInfo -// System::Web::Services::Protocols.LogicalMethodInfo::IsAsync -// System::Web::Services::Protocols.LogicalMethodTypes::Async - -/* -This following example demonstrates the 'AsyncCallbackParameter', -'AsyncResultParameter', 'AsyncStateParameter', 'BeginMethodInfo', -'EndMethodInfo', 'IsAsync' properties and -'Create(MethodInfo->Item[], LogicalMethodTypes)' method of the -'LogicalMethodInfo' class and the 'Async' enum member of the -'LogicalMethodTypes' enumeration. This example displays the callback, -result and state parameters for asynchronous methods. It also displays -the begin and end for such asynchronous methods. - -Note : The 'LogicalMethodInfo' class should only be used with -'SoapMessage'. 'SoapClientMessage' and 'SoapServerMessage' contain -a property named 'MethodInfo' which provides for an instance of -'LogicalMethodInfo'. If you are interested only in the reflection -of a type then use the 'System::Reflection' namespace and not this -class. This class gives information ab->Item[Out] the* method invoked for -a web service and hence should only be used as such. For example -purposes it is being showed in a more simplified scenario. -*/ - -// -#using -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Web::Services::Protocols; - -public ref class MyService: public SoapHttpClientProtocol -{ -public: - IAsyncResult^ BeginAdd( int xValue, int yValue, AsyncCallback^ callback, Object^ asyncState ) - { - array^temp0 = {xValue,yValue}; - return this->BeginInvoke( "Add", temp0, callback, asyncState ); - } - - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } -}; - -int main() -{ - Type^ myType = MyService::typeid; - MethodInfo^ myBeginMethod = myType->GetMethod( "BeginAdd" ); - MethodInfo^ myEndMethod = myType->GetMethod( "EndAdd" ); - array^temp0 = {myBeginMethod,myEndMethod}; - LogicalMethodInfo^ myLogicalMethodInfo = LogicalMethodInfo::Create( temp0, LogicalMethodTypes::Async )[ 0 ]; - Console::WriteLine( "\nThe asynchronous callback parameter of method {0} is :\n", myLogicalMethodInfo->Name ); - Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncCallbackParameter->Name, myLogicalMethodInfo->AsyncCallbackParameter->ParameterType ); - Console::WriteLine( "\nThe asynchronous state parameter of method {0} is :\n", myLogicalMethodInfo->Name ); - Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncStateParameter->Name, myLogicalMethodInfo->AsyncStateParameter->ParameterType ); - Console::WriteLine( "\nThe asynchronous result parameter of method {0} is :\n", myLogicalMethodInfo->Name ); - Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncResultParameter->Name, myLogicalMethodInfo->AsyncResultParameter->ParameterType ); - Console::WriteLine( "\nThe begin method of the asynchronous method {0} is :\n", myLogicalMethodInfo->Name ); - Console::WriteLine( "\t {0}", myLogicalMethodInfo->BeginMethodInfo ); - Console::WriteLine( "\nThe end method of the asynchronous method {0} is :\n", myLogicalMethodInfo->Name ); - Console::WriteLine( "\t {0}", myLogicalMethodInfo->EndMethodInfo ); - if ( myLogicalMethodInfo->IsAsync ) - Console::WriteLine( "\n {0} is asynchronous", myLogicalMethodInfo->Name ); - else - Console::WriteLine( "\n {0} is synchronous", myLogicalMethodInfo->Name ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_GetCustomAttribute/CPP/logicalmethodinfo_getcustomattribute.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_GetCustomAttribute/CPP/logicalmethodinfo_getcustomattribute.cpp deleted file mode 100644 index ac1bdd162ab88..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_GetCustomAttribute/CPP/logicalmethodinfo_getcustomattribute.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// System::Web::Services::Protocols.LogicalMethodTypes::Sync -// System::Web::Services::Protocols.LogicalMethodTypes::LogicalMethodTypes -// System::Web::Services::Protocols.LogicalMethodInfo::MethodInfo -// All the following have been grouped as one snippet : Snippet4 -// System::Web::Services::Protocols.LogicalMethodInfo::GetCustomAttribute(Type) -// System::Web::Services::Protocols.LogicalMethodInfo::GetCustomAttributes(Type) -// System::Web::Services::Protocols.LogicalMethodInfo::ReturnTypeCustomAttributeProvider -// System::Web::Services::Protocols.LogicalMethodInfo::CustomAttributeProvider - -/* -This following example demonstrates the 'MethodInfo', -'ReturnTypeCustomAttributeProvider', 'CustomAttributeProvider', -properties and 'GetCustomAttribute(Type)', -'GetCustomAttributes(Type)' methods of the 'LogicalMethodInfo' class -and 'Sync' enum member of 'LogicalMethodTypes' enumeration. -This example demonstrates custom attributes and return attributes of the -'Add' method. - -Note : The 'LogicalMethodInfo' class should only be used with -'SoapMessage'. 'SoapClientMessage' and 'SoapServerMessage' contain -a property named 'MethodInfo' which provides for an instance of -'LogicalMethodInfo'. If you are interested only in the reflection -of a type then use the 'System::Reflection' namespace and not this -class. This class gives information ab[Out] the* method invoked for -a web service and hence should only be used as such. For example -purposes it is being showed in a more simplified scenario. -*/ - -// -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Web::Services::Protocols; - -// Define a custom attribute with one named parameter. - -[AttributeUsage(AttributeTargets::Method|AttributeTargets::ReturnValue, -AllowMultiple=true)] -public ref class MyAttribute: public Attribute -{ -private: - String^ myName; - -public: - MyAttribute( String^ name ) - { - myName = name; - } - - property String^ Name - { - String^ get() - { - return myName; - } - } -}; - -public ref class MyService -{ -public: - - [MyAttribute("This is the first sample attribute")] - [MyAttribute("This is the second sample attribute")] - [returnvalue:MyAttribute("This is the return sample attribute")] - int Add( int xValue, int yValue ) - { - return (xValue + yValue); - } -}; - -int main() -{ - // - Type^ myType = MyService::typeid; - MethodInfo^ myMethodInfo = myType->GetMethod( "Add" ); - - // - // - // Create a synchronous 'LogicalMethodInfo' instance. - array^temparray = {myMethodInfo}; - LogicalMethodInfo^ myLogicalMethodInfo = (LogicalMethodInfo::Create( temparray, LogicalMethodTypes::Sync ))[ 0 ]; - // - // - - // Display the method for which the attributes are being displayed. - Console::WriteLine( "\nDisplaying the attributes for the method : {0}\n", myLogicalMethodInfo->MethodInfo ); - // - - // Displaying a custom attribute of type 'MyAttribute' - Console::WriteLine( "\nDisplaying attribute of type 'MyAttribute'\n" ); - Object^ attribute = myLogicalMethodInfo->GetCustomAttribute( MyAttribute::typeid ); - Console::WriteLine( (dynamic_cast(attribute))->Name ); - - // Display all custom attribute of type 'MyAttribute'. - Console::WriteLine( "\nDisplaying all attributes of type 'MyAttribute'\n" ); - array^attributes = myLogicalMethodInfo->GetCustomAttributes( MyAttribute::typeid ); - for ( int i = 0; i < attributes->Length; i++ ) - Console::WriteLine( (dynamic_cast(attributes[ i ]))->Name ); - - // Display all return attributes of type 'MyAttribute'. - Console::WriteLine( "\nDisplaying all return attributes of type 'MyAttribute'\n" ); - ICustomAttributeProvider^ myCustomAttributeProvider = myLogicalMethodInfo->ReturnTypeCustomAttributeProvider; - if ( myCustomAttributeProvider->IsDefined( MyAttribute::typeid, true ) ) - { - attributes = myCustomAttributeProvider->GetCustomAttributes( true ); - for ( int i = 0; i < attributes->Length; i++ ) - if ( attributes[ i ]->GetType()->Equals( MyAttribute::typeid ) ) - Console::WriteLine( (dynamic_cast(attributes[ i ]))->Name ); - } - - // Display all the custom attributes of type 'MyAttribute'. - Console::WriteLine( "\nDisplaying all attributes of type 'MyAttribute'\n" ); - myCustomAttributeProvider = myLogicalMethodInfo->CustomAttributeProvider; - if ( myCustomAttributeProvider->IsDefined( MyAttribute::typeid, true ) ) - { - attributes = myCustomAttributeProvider->GetCustomAttributes( true ); - for ( int i = 0; i < attributes->Length; i++ ) - if ( attributes[ i ]->GetType()->Equals( MyAttribute::typeid ) ) - Console::WriteLine( (dynamic_cast(attributes[ i ]))->Name ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_IsBeginMethod/CPP/logicalmethodinfo_isbeginmethod.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_IsBeginMethod/CPP/logicalmethodinfo_isbeginmethod.cpp deleted file mode 100644 index ce69fb86dfdf0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/LogicalMethodInfo_IsBeginMethod/CPP/logicalmethodinfo_isbeginmethod.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// System.Web.Services.Protocols.LogicalMethodInfo.IsBeginMethod(MethodInfo) -// System.Web.Services.Protocols.LogicalMethodInfo.IsEndMethod(MethodInfo) -/* -The following example demonstrates 'IsBeginMethod' and 'IsEndMethod' methods of 'System.Web.Services.Protocols.LogicalMethodInfo' class. The type information of methods of Math web service is taken in a varible of type MethodInfo. Then 'IsBeginMethod' and 'IsEndMethod' is used to query on created MethodInfo variable to find whether the method is begin and end method for asynchronous invocation or not. -Note: The below MyMath class is a proxy class generated by the Wsdl.exe utility for the Math Web Service. This class can be found in SoapHttpClientProtocol Class example also. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Web::Services::Protocols; - -// Automatically generated proxy class for Math Web service. -// This class can also be found in SoapHttpClientProtocol class example. -namespace MyMath -{ -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - - [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap", - Namespace="http://tempuri.org/")] - public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - MyMath() - { - this->Url = "http://localhost/Math.asmx"; - } - - [System::Web::Services::Protocols::SoapDocumentMethodAttribute( - "http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int x, int y ) - { - array^temp0 = {x,y}; - array^results = this->Invoke( "Add", temp0 ); - return *dynamic_cast(results[ 0 ]); - } - - System::IAsyncResult^ BeginAdd( int x, int y, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {x,y}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } - - }; - -} - -int main() -{ - // - // - // Get the type for the proxy class MyMath Web service. - // Note: The MyMath class is a proxy class generated by the Wsdl.exe - // utility for the Math Web service. This class can also be found in - // the SoapHttpClientProtocol class example. - Type^ myType = MyMath::MyMath::typeid; - MethodInfo^ myBeginMethod = myType->GetMethod( "BeginAdd" ); - MethodInfo^ myEndMethod = myType->GetMethod( "EndAdd" ); - MethodInfo^ myMethod = myType->GetMethod( "Add" ); - Console::WriteLine( "Is 'BeginAdd' a Begin Method : {0}", LogicalMethodInfo::IsBeginMethod( myBeginMethod ) ); - Console::WriteLine( "Is 'Add' a Begin Method : {0}", LogicalMethodInfo::IsBeginMethod( myMethod ) ); - Console::WriteLine( "Is 'EndAdd' an End Method : {0}", LogicalMethodInfo::IsEndMethod( myEndMethod ) ); - // - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/SvcClient_MatchAttribute.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/SvcClient_MatchAttribute.cpp deleted file mode 100644 index ae08b9bd29609..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/SvcClient_MatchAttribute.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - This program is used as a client of the client proxy class. -*/ - -// System.Web.Services.Protocols.MatchAttribute -// System.Web.Services.Protocols.MatchAttribute.MatchAttribute(string) -// System.Web.Services.Protocols.MatchAttribute.IgnoreCase -// System.Web.Services.Protocols.MatchAttribute.Pattern -// System.Web.Services.Protocols.MatchAttribute.Capture -// System.Web.Services.Protocols.MatchAttribute.Group -// System.Web.Services.Protocols.MatchAttribute.MaxRepeats - -/* - The following example demonstrates the constructor and 'IgnoreCase', - 'Pattern', 'Capture', 'Group', 'MaxRepeats' properties of the - 'MatchAttribute' class. This example shows a simple proxy that - parses the contents of a .html file which has been returned in - response to a web request. The web request which is a HTTP-GET - request is done behind the scenes in the 'Invoke' method of - 'HttpGetClientProtocol'. The .html file returned in response is - parsed with the help of 'MatchAttribute' class and the contents - are available in the 'Headers' instance returned by 'GetHeaders' - method. -*/ - -// -#using -#using - -using namespace System; -using namespace System::Web::Services::Protocols; - -// -// -// -// -// -// -public ref class Example_Headers -{ -public: - - [MatchAttribute("TITLE>(.*?)<")] - String^ Title; - - [MatchAttribute("",Pattern="h1>(.*?)<",IgnoreCase=true)] - String^ H1; - - [MatchAttribute("H2>((([^<,]*),?)+)<",Group=3,Capture=4)] - String^ Element; - - [MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=0)] - array^ Elements1; - - [MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=1)] - array^ Elements2; - - [MatchAttribute("H3 ([^=]*)=([^>]*)",Group=1)] - String^ Attribute; - - [MatchAttribute("H3 ([^=]*)=([^>]*)",Group=2)] - String^ Value; -}; -// -// -// -// -// -// - -public ref class MatchAttribute_Example: public HttpGetClientProtocol -{ -public: - MatchAttribute_Example() - { - Url = "http://localhost"; - } - - [HttpMethodAttribute(TextReturnReader::typeid,UrlParameterWriter::typeid)] - Example_Headers^ GetHeaders() - { - return ((Example_Headers^)(Invoke( "GetHeaders", ( Url + "/MyHeaders.html" ), - gcnew array(0) ))); - } - - System::IAsyncResult^ BeginGetHeaders( System::AsyncCallback^ callback, - Object^ asyncState ) - { - return BeginInvoke( "GetHeaders", ( Url + "/MyHeaders.html" ), - gcnew array(0), callback, asyncState ); - } - - Example_Headers^ EndGetHeaders( System::IAsyncResult^ asyncResult ) - { - return (Example_Headers^)(EndInvoke( asyncResult )); - } -}; -// - -public ref class SvcClient -{ -public: - static void main() - { - Example_Headers^ myHeaders; - MatchAttribute_Example^ mySample = gcnew MatchAttribute_Example; - myHeaders = mySample->GetHeaders(); - - Console::WriteLine( "\nThe Title html tag content is : {0}", - myHeaders->Title ); - - Console::WriteLine( "\nThe H1 html tag content is : {0}", - myHeaders->H1 ); - - Console::WriteLine( "\nThe fifth element in H2 html tag content is : {0}", - myHeaders->Element ); - - Console::WriteLine( "\nThe elements in the H2 html tag are :" + - " (MaxRepeats = 0)" ); - for ( int i = 0; i < myHeaders->Elements1->Length; i++ ) - { - Console::WriteLine( myHeaders->Elements1[ i ] ); - } - - Console::WriteLine( "\nThe elements in the H2 html tag are :" + - " (MaxRepeats = 1)" ); - for ( int i = 0; i < myHeaders->Elements2->Length; i++ ) - { - Console::WriteLine( myHeaders->Elements2[ i ] ); - } - - Console::WriteLine( "\nThe H3 html tag has attribute : {0} = {1}", - myHeaders->Attribute, myHeaders->Value ); - } -}; - -int main() -{ - SvcClient::main(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/makefile deleted file mode 100644 index 99d1d96246779..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all : SvcClient_MatchAttribute.exe - -SvcClient_MatchAttribute.exe : SvcClient_MatchAttribute.cpp matchattribute.dll - cl /clr:pure SvcClient_MatchAttribute.cpp - -matchattribute.dll : matchattribute.cpp - cl /clr:pure /LD matchattribute.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/matchattribute.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/matchattribute.cpp deleted file mode 100644 index 93e7c98050706..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MatchAttribute/CPP/matchattribute.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#using - -using namespace System; - -public ref class NotMuchHere -{ -public: - static void Main() - { - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Message.Acknowledgment/CPP/message_acknowledgment.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Message.Acknowledgment/CPP/message_acknowledgment.cpp deleted file mode 100644 index d472ebf0ea77d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Message.Acknowledgment/CPP/message_acknowledgment.cpp +++ /dev/null @@ -1,145 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - static void CreateQueue( String^ queuePath ) - { - try - { - if ( !MessageQueue::Exists( queuePath ) ) - { - MessageQueue::Create( queuePath ); - } - else - { - Console::WriteLine( "{0} already exists.", queuePath ); - } - } - catch ( MessageQueueException^ e ) - { - Console::WriteLine( e->Message ); - } - - } - - void SendMessage() - { - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Create a new message. - Message^ myMessage = gcnew Message( "Original Message" ); - myMessage->AdministrationQueue = gcnew MessageQueue( ".\\myAdministrationQueue" ); - myMessage->AcknowledgeType = (AcknowledgeTypes)(AcknowledgeTypes::PositiveReceive | AcknowledgeTypes::PositiveArrival); - - // Send the Order to the queue. - myQueue->Send( myMessage ); - return; - } - - String^ ReceiveMessage() - { - // Connect to the a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - myQueue->MessageReadPropertyFilter->CorrelationId = true; - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - String^ returnString = nullptr; - try - { - // Receive and format the message. - Message^ myMessage = myQueue->Receive(); - - // Display message information. - Console::WriteLine( "____________________________________________" ); - Console::WriteLine( "Original message information--" ); - Console::WriteLine( "Body: {0}", myMessage->Body ); - Console::WriteLine( "Id: {0}", myMessage->Id ); - Console::WriteLine( "____________________________________________" ); - returnString = myMessage->Id; - } - catch ( MessageQueueException^ ) - { - // Handle Message Queuing exceptions. - } - // Handle invalid serialization format. - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( e->Message ); - } - - // Catch other exceptions as necessary. - return returnString; - } - - void ReceiveAcknowledgment( String^ messageId, String^ queuePath ) - { - bool found = false; - MessageQueue^ queue = gcnew MessageQueue( queuePath ); - queue->MessageReadPropertyFilter->CorrelationId = true; - queue->MessageReadPropertyFilter->Acknowledgment = true; - try - { - while ( queue->PeekByCorrelationId( messageId ) != nullptr ) - { - Message^ myAcknowledgmentMessage = queue->ReceiveByCorrelationId( messageId ); - - // Output acknowledgment message information. The correlation Id is identical - // to the id of the original message. - Console::WriteLine( "Acknowledgment Message Information--" ); - Console::WriteLine( "Correlation Id: {0}", myAcknowledgmentMessage->CorrelationId ); - Console::WriteLine( "Id: {0}", myAcknowledgmentMessage->Id ); - Console::WriteLine( "Acknowledgment Type: {0}", myAcknowledgmentMessage->Acknowledgment ); - Console::WriteLine( "____________________________________________" ); - found = true; - } - } - catch ( InvalidOperationException^ e ) - { - // This exception would be thrown if there is no (further) acknowledgment message - // with the specified correlation Id. Only output a message if there are no messages; - // not if the loop has found at least one. - if ( found == false ) - { - Console::WriteLine( e->Message ); - } - - // Handle other causes of invalid operation exception. - } - - } - -}; - -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Create new queues. - MyNewQueue::CreateQueue( ".\\myQueue" ); - MyNewQueue::CreateQueue( ".\\myAdministrationQueue" ); - - // Send messages to a queue. - myNewQueue->SendMessage(); - - // Receive messages from a queue. - String^ messageId = myNewQueue->ReceiveMessage(); - - // Receive acknowledgment message. - if ( messageId != nullptr ) - { - myNewQueue->ReceiveAcknowledgment( messageId, ".\\myAdministrationQueue" ); - } - - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Message.Body/CPP/message_sendreceive.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Message.Body/CPP/message_sendreceive.cpp deleted file mode 100644 index 1d933075840d7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Message.Body/CPP/message_sendreceive.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Messaging; -using namespace System::Drawing; -using namespace System::IO; -ref class Order -{ -public: - int orderId; - DateTime orderTime; -}; - -ref class MyNewQueue -{ -public: - static void CreateQueue( String^ queuePath ) - { - try - { - if ( !MessageQueue::Exists( queuePath ) ) - { - MessageQueue::Create( queuePath ); - } - else - { - Console::WriteLine( "{0} already exists.", queuePath ); - } - } - catch ( MessageQueueException^ e ) - { - Console::WriteLine( e->Message ); - } - - } - - void SendMessage() - { - try - { - // Create a new order and set values. - Order^ sentOrder = gcnew Order; - sentOrder->orderId = 3; - sentOrder->orderTime = DateTime::Now; - - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Create the new order. - Message^ myMessage = gcnew Message( sentOrder ); - - // Send the order to the queue. - myQueue->Send( myMessage ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - - return; - } - - void ReceiveMessage() - { - // Connect to the a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Set the formatter to indicate body contains an Order. - array^p = gcnew array(1); - p[ 0 ] = Order::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - try - { - // Receive and format the message. - Message^ myMessage = myQueue->Receive(); - Order^ myOrder = dynamic_cast(myMessage->Body); - - // Display message information. - Console::WriteLine( "Order ID: {0}", myOrder->orderId ); - Console::WriteLine( "Sent: {0}", myOrder->orderTime ); - } - catch ( MessageQueueException^ ) - { - // Handle Message Queuing exceptions. - } - // Handle invalid serialization format. - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( e->Message ); - } - - // Catch other exceptions as necessary. - return; - } -}; - -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Create a queue on the local computer. - MyNewQueue::CreateQueue( ".\\myQueue" ); - - // Send a message to a queue. - myNewQueue->SendMessage(); - - // Receive a message from a queue. - myNewQueue->ReceiveMessage(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Message.DefaultPropertiesToSend/CPP/message_defaultandpriority.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Message.DefaultPropertiesToSend/CPP/message_defaultandpriority.cpp deleted file mode 100644 index 9bf2333fbd8d1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Message.DefaultPropertiesToSend/CPP/message_defaultandpriority.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// - -#using -#using - -using namespace System; -using namespace System::Messaging; - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ - //************************************************** - // Sends a string message to a queue. - //************************************************** -public: - void SendMessage( MessagePriority priority, String^ messageBody ) - { - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Create a new message. - Message^ myMessage = gcnew Message; - if ( priority > MessagePriority::Normal ) - { - myMessage->Body = "High Priority: {0}",messageBody; - } - else - { - myMessage->Body = messageBody; - } - - // Set the priority of the message. - myMessage->Priority = priority; - - // Send the Order to the queue. - myQueue->Send( myMessage ); - - return; - } - - //************************************************** - // Receives a message. - //************************************************** - void ReceiveMessage() - { - // Connect to the a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Set the queue to read the priority. By default, it - // is not read. - myQueue->MessageReadPropertyFilter->Priority = true; - - // Set the formatter to indicate body contains a String^. - array^ p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - try - { - // Receive and format the message. - Message^ myMessage = myQueue->Receive(); - - // Display message information. - Console::WriteLine( "Priority: {0}", - myMessage->Priority ); - Console::WriteLine( "Body: {0}", - myMessage->Body ); - } - catch ( MessageQueueException^ ) - { - // Handle Message Queuing exceptions. - } - // Handle invalid serialization format. - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( e->Message ); - } - - // Catch other exceptions as necessary. - - return; - } -}; - -//************************************************** -// Provides an entry point into the application. -// -// This example sends and receives a message from -// a queue. -//************************************************** -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send messages to a queue. - myNewQueue->SendMessage( MessagePriority::Normal, "First Message Body." ); - myNewQueue->SendMessage( MessagePriority::Highest, "Second Message Body." ); - - // Receive messages from a queue. - myNewQueue->ReceiveMessage(); - myNewQueue->ReceiveMessage(); - - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageBinding_sample/CPP/messagebinding_sample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageBinding_sample/CPP/messagebinding_sample.cpp deleted file mode 100644 index 5210e7417e565..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageBinding_sample/CPP/messagebinding_sample.cpp +++ /dev/null @@ -1,85 +0,0 @@ - - -// System::Web::Services::Description.MessageBinding::MessageBinding(); -// System::Web::Services::Description.MessageBinding::Extensions; -// System::Web::Services::Description.MessageBinding::Name; -/* The following program demonstrates the abstract class 'MessageBinding', it's constructor MessageBinding() -and properties 'Extensions' and 'Name'. -'MessageBinding' is an abstract class from which 'InputBinding' , 'OutputBinding' are derived. -The program contains a utility function which could be used to create either an InputBinding or OutputBinding. -This generic nature is achieved by returning an instance of 'MessageBinding'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -MessageBinding^ CreateInputOutputBinding( String^ myBindName, bool isInputBinding ) -{ - - // - // Value isInputBinding = true ---> return type = InputBinding. - // Value isInputBinding = false --> return type = OutputBinding. - // - // - MessageBinding^ myMessageBinding = nullptr; - switch ( isInputBinding ) - { - case true: - myMessageBinding = gcnew InputBinding; - Console::WriteLine( "Added an InputBinding" ); - break; - - case false: - myMessageBinding = gcnew OutputBinding; - Console::WriteLine( "Added an OutputBinding" ); - break; - } - // - myMessageBinding->Name = myBindName; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myMessageBinding->Extensions->Add( mySoapBodyBinding ); - Console::WriteLine( "Added extensibility element of type : {0}", mySoapBodyBinding->GetType() ); - // - // - - return myMessageBinding; -} - - -// Used to create OperationBinding instances within Binding. -OperationBinding^ CreateOperationBinding( String^ myOperation, String^ targetNamespace ) -{ - // Create OperationBinding for Operation. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = myOperation; - - // Create InputBinding for operation. - InputBinding^ myInputBinding = dynamic_cast(CreateInputOutputBinding( nullptr, true )); - - // Create OutputBinding for operation. - OutputBinding^ myOutputBinding = dynamic_cast(CreateInputOutputBinding( nullptr, false )); - - // Add InputBinding and OutputBinding to OperationBinding. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - - // Create an extensibility element for SoapOperationBinding. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = String::Concat( targetNamespace, myOperation ); - - // Add the extensibility element SoapOperationBinding to OperationBinding. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - return myOperationBinding; -} - -int main() -{ - /* OperationBinding* addOperationBinding = */ - CreateOperationBinding( "Add", "http://tempuri.org/" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageCollection/CPP/messagecollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageCollection/CPP/messagecollection.cpp deleted file mode 100644 index 078f4450a480b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageCollection/CPP/messagecollection.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// System::Web::Services::Description.MessageCollection::CopyTo; -// System::Web::Services::Description.MessageCollection::Item Property(Int32); -// System::Web::Services::Description.MessageCollection::Item Property (String); -// System::Web::Services::Description.MessageCollection::Contains; -// System::Web::Services::Description.MessageCollection::IndexOf; -// System::Web::Services::Description.MessageCollection::Remove; - -/* The program reads a WSDL document S"MathService::wsdl" and gets a ServiceDescription instance. -A MessageCollection instance is then retrieved from this ServiceDescription instance and it's -members are demonstrated. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_1.wsdl" ); - Console::WriteLine( "" ); - Console::WriteLine( "MessageCollection Sample" ); - Console::WriteLine( "========================" ); - Console::WriteLine( "" ); - - // - // Get Message Collection. - MessageCollection^ myMessageCollection = myServiceDescription->Messages; - Console::WriteLine( "Total Messages in the document = {0}", myServiceDescription->Messages->Count ); - Console::WriteLine( "" ); - Console::WriteLine( "Enumerating Messages..." ); - Console::WriteLine( "" ); - - // Print messages to console. - for ( int i = 0; i < myMessageCollection->Count; ++i ) - Console::WriteLine( "Message Name : {0}", myMessageCollection[ i ]->Name ); - // - - // - // Create a Message Array. - array^myMessages = gcnew array(myServiceDescription->Messages->Count); - - // Copy MessageCollection to an array. - myServiceDescription->Messages->CopyTo( myMessages, 0 ); - Console::WriteLine( "" ); - Console::WriteLine( "Displaying Messages that were copied to Messagearray ..." ); - Console::WriteLine( "" ); - for ( int i = 0; i < myServiceDescription->Messages->Count; ++i ) - Console::WriteLine( "Message Name : {0}", myMessages[ i ]->Name ); - // - - // - // - // - // - // Get Message by Name = S"AddSoapIn". - Message^ myMessage = myServiceDescription->Messages[ "AddSoapIn" ]; - Console::WriteLine( "" ); - Console::WriteLine( "Getting Message = 'AddSoapIn' {by Name}" ); - if ( myMessageCollection->Contains( myMessage ) ) - { - Console::WriteLine( "" ); - - // Get Message Name = S"AddSoapIn" Index. - Console::WriteLine( "Message 'AddSoapIn' was found in Message Collection." ); - Console::WriteLine( "Index of 'AddSoapIn' in Message Collection = {0}", myMessageCollection->IndexOf( myMessage ) ); - Console::WriteLine( "Deleting Message from Message Collection..." ); - myMessageCollection->Remove( myMessage ); - if ( myMessageCollection->IndexOf( myMessage ) == -1 ) - Console::WriteLine( "Message 'AddSoapIn' was successfully removed from Message Collection." ); - } - // - // - // - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessagePartCollection/CPP/messagepartcollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessagePartCollection/CPP/messagepartcollection.cpp deleted file mode 100644 index 1b626e5d6ee7c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessagePartCollection/CPP/messagepartcollection.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// System::Web::Services::Description.MessagePartCollection::Item Property(Int32); -// System::Web::Services::Description.MessagePart::Message; -// System::Web::Services::Description.MessagePartCollection::CopyTo; -// System::Web::Services::Description.MessagePartCollection::Item Property (String); -// System::Web::Services::Description.MessagePartCollection::Contains; -// System::Web::Services::Description.MessagePartCollection::IndexOf; -// System::Web::Services::Description.MessagePartCollection::Remove; -// System::Web::Services::Description.MessagePartCollection; - -/* The program reads a wsdl document S"MathService::wsdl" and gets ServiceDescription instance. -A MessagePartCollection instance is then retrieved from each Message and it's members are demonstrated. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - Console::WriteLine( "" ); - Console::WriteLine( "MessagePartCollection Sample" ); - Console::WriteLine( "============================" ); - Console::WriteLine( "" ); - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService.wsdl" ); - - // Get the message collection. - MessageCollection^ myMessageCollection = myServiceDescription->Messages; - Console::WriteLine( "Total Messages in the document = {0}", myServiceDescription->Messages->Count ); - Console::WriteLine( "" ); - Console::WriteLine( "Enumerating PartCollection for each message..." ); - Console::WriteLine( "" ); - - // - // - // Get the message part collection for each message. - for ( int i = 0; i < myMessageCollection->Count; ++i ) - { - Console::WriteLine( "Message : {0}", myMessageCollection[ i ]->Name ); - - // Get the message part collection. - MessagePartCollection^ myMessagePartCollection = myMessageCollection[ i ]->Parts; - - // Display the part collection. - for ( int k = 0; k < myMessagePartCollection->Count; k++ ) - { - Console::WriteLine( "\t Part Name : {0}", myMessagePartCollection[ k ]->Name ); - Console::WriteLine( "\t Message Name : {0}", myMessagePartCollection[ k ]->Message->Name ); - } - Console::WriteLine( "" ); - } - // - // - - Console::WriteLine( "MessagePartCollection for the message AddHttpGetIn." ); - // - // - Message^ myLocalMessage = myServiceDescription->Messages[ "AddHttpPostOut" ]; - if ( myMessageCollection->Contains( myLocalMessage ) ) - { - Console::WriteLine( "Message : {0}", myLocalMessage->Name ); - - // Get the message part collection. - MessagePartCollection^ myMessagePartCollection = myLocalMessage->Parts; - array^myMessagePart = gcnew array(myMessagePartCollection->Count); - - // Copy the MessagePartCollection to an array. - myMessagePartCollection->CopyTo( myMessagePart, 0 ); - for ( int k = 0; k < myMessagePart->Length; k++ ) - Console::WriteLine( "\t Part Name : {0}", myMessagePartCollection[ k ]->Name ); - Console::WriteLine( "" ); - } - // - // - - // - // - // - Console::WriteLine( "Checking if message is AddHttpPostOut..." ); - Message^ myMessage = myServiceDescription->Messages[ "AddHttpPostOut" ]; - if ( myMessageCollection->Contains( myMessage ) ) - { - // Get the mssage part collection. - MessagePartCollection^ myMessagePartCollection = myMessage->Parts; - - // Get the part named Body. - MessagePart^ myMessagePart = myMessage->Parts[ "Body" ]; - if ( myMessagePartCollection->Contains( myMessagePart ) ) - { - // Get the part named Body. - Console::WriteLine( "Index of Body in MessagePart collection = {0}", myMessagePartCollection->IndexOf( myMessagePart ) ); - Console::WriteLine( "Deleting Body from MessagePart collection..." ); - myMessagePartCollection->Remove( myMessagePart ); - if ( myMessagePartCollection->IndexOf( myMessagePart ) == -1 ) - Console::WriteLine( "from the message AddHttpPostOut." ); - } - } - // - // - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessagePropertyFilter/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessagePropertyFilter/CPP/class1.cpp deleted file mode 100644 index 6f8df31e358ae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessagePropertyFilter/CPP/class1.cpp +++ /dev/null @@ -1,930 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -namespace MessagePropertyFilterExample -{ - public ref class Order - { - private: - int orderIdValue; - DateTime orderTimeValue; - - public: - - property int OrderId - { - int get() - { - return orderIdValue; - } - - void set(int value) - { - orderIdValue = value; - } - } - - property DateTime OrderTime - { - DateTime get() - { - return orderTimeValue; - } - - void set(DateTime value) - { - orderTimeValue = value; - } - - } - }; - - public ref class OrderProcessor - { - public: - - // Creates a new queue-> - static void CreateQueue(String^ queuePath, - bool transactional) - { - if (!MessageQueue::Exists(queuePath)) - { - MessageQueue::Create(queuePath, transactional); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } - } - - // Sends an Order to a queue-> - void SendMessage() - { - // Create a new order and set values. - Order^ sentOrder = gcnew Order; - sentOrder->OrderId = 3; - sentOrder->OrderTime = DateTime::Now; - - // Connect to a queue on the local computer. - MessageQueue^ queue = - gcnew MessageQueue(".\\orderQueue"); - - // Create the new order. - Message^ orderMessage = gcnew Message(sentOrder); - - // Label the message. - orderMessage->Label = "Order Message"; - - // Send the order to the queue-> - queue->Send(orderMessage); - } - - // Receives a message containing an order. - void ReceiveMessage() - { - // Connect to the a queue on the local computer. - MessageQueue^ queue = - gcnew MessageQueue(".\\orderQueue"); - - // Set the formatter to indicate - // the message body contains an order. - array ^targetTypes = gcnew array(1); - targetTypes[0] = Order::typeid; - queue->Formatter = - gcnew XmlMessageFormatter(targetTypes); - - // Declare the message. - Message^ orderMessage; - - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's AcknowledgeType property. - queue->MessageReadPropertyFilter-> - AcknowledgeType = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // AcknowledgeType property. - Console::WriteLine("Message.AcknowledgeType: {0}", - orderMessage->AcknowledgeType); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's AdministrationQueue property. - queue->MessageReadPropertyFilter-> - AdministrationQueue = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // AdministrationQueue property. - Console::WriteLine("Message.AdministrationQueue: {0}", - orderMessage->AdministrationQueue); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's AppSpecific property. - queue->MessageReadPropertyFilter->AppSpecific = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // AppSpecific property. - Console::WriteLine("Message.AppSpecific: {0}", - orderMessage->AppSpecific); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's ArrivedTime property. - queue->MessageReadPropertyFilter->ArrivedTime = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // ArrivedTime property. - Console::WriteLine("Message.ArrivedTime: {0}", - orderMessage->ArrivedTime); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's AttachSenderId property. - queue->MessageReadPropertyFilter->AttachSenderId = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // AttachSenderId property. - Console::WriteLine("Message.AttachSenderId: {0}", - orderMessage->AttachSenderId); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's Authenticated property. - queue->MessageReadPropertyFilter->Authenticated = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // Authenticated property. - Console::WriteLine("Message.Authenticated: {0}", - orderMessage->Authenticated); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's - // AuthenticationProviderName property. - queue->MessageReadPropertyFilter-> - AuthenticationProviderName = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // AuthenticationProviderName property. - Console::WriteLine( - "Message.AuthenticationProviderName: {0}", - orderMessage->AuthenticationProviderName); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's - // AuthenticationProviderType property. - queue->MessageReadPropertyFilter-> - AuthenticationProviderType = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // AuthenticationProviderType property. - Console::WriteLine( - "Message.AuthenticationProviderType: {0}", - orderMessage->AuthenticationProviderType); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's Body property. - queue->MessageReadPropertyFilter->Body = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's Body property. - Console::WriteLine("Message.Body: {0}", - orderMessage->Body); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's ConnectorType property. - queue->MessageReadPropertyFilter->ConnectorType = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // ConnectorType property. - Console::WriteLine("Message.ConnectorType: {0}", - orderMessage->ConnectorType); - - // - // - // Set the filter's DefaultBodySize - // property to 2048 bytes. - queue->MessageReadPropertyFilter-> - DefaultBodySize = 2048; - - // Display the new value of the filter's - // DefaultBodySize property. - Console::WriteLine( - "MessageReadPropertyFilter.DefaultBodySize: {0}", - queue->MessageReadPropertyFilter->DefaultBodySize); - - // - // - // Set the filter's DefaultExtensionSize - // property to 1024 bytes. - queue->MessageReadPropertyFilter-> - DefaultExtensionSize = 1024; - - // Display the new value of the filter's - // DefaultExtensionSize property. - Console::WriteLine( - "MessageReadPropertyFilter." - "DefaultExtensionSize: {0}", - queue->MessageReadPropertyFilter-> - DefaultExtensionSize); - - // - // - // Set the filter's DefaultLabelSize - // property to 1024 bytes. - queue->MessageReadPropertyFilter-> - DefaultLabelSize = 1024; - - // Display the new value of the filter's - // DefaultLabelSize property. - Console::WriteLine( - "MessageReadPropertyFilter.DefaultLabelSize: {0}", - queue->MessageReadPropertyFilter->DefaultLabelSize); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's DestinationQueue property. - queue->MessageReadPropertyFilter-> - DestinationQueue = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // Destinationqueue->QueueName property. - Console::WriteLine( - "Message.Destinationqueue->QueueName: {0}", - orderMessage->DestinationQueue->QueueName); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's - // DestinationSymmetricKey property. - queue->MessageReadPropertyFilter-> - DestinationSymmetricKey = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // DestinationSymmetricKey property. - Console::WriteLine( - "Message.DestinationSymmetricKey: {0}", - orderMessage->DestinationSymmetricKey); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's DigitalSignature property. - queue->MessageReadPropertyFilter-> - DigitalSignature = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // DigitalSignature property. - Console::WriteLine("Message.DigitalSignature: {0}", - orderMessage->DigitalSignature); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's EncryptionAlgorithm property. - queue->MessageReadPropertyFilter-> - EncryptionAlgorithm = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // EncryptionAlgorithm property. - Console::WriteLine("Message.EncryptionAlgorithm: {0}", - orderMessage->EncryptionAlgorithm); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's Extension property. - queue->MessageReadPropertyFilter->Extension = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's Extension property. - Console::WriteLine("Message.Extension: {0}", - orderMessage->Extension); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's HashAlgorithm property. - queue->MessageReadPropertyFilter->HashAlgorithm = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // HashAlgorithm property. - Console::WriteLine("Message.HashAlgorithm: {0}", - orderMessage->HashAlgorithm); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's Id property. - queue->MessageReadPropertyFilter->Id = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's Id property. - Console::WriteLine("Message.Id: {0}", orderMessage->Id); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's Label property. - queue->MessageReadPropertyFilter->Label = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's Label property. - Console::WriteLine("Message.Label: {0}", - orderMessage->Label); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's MessageType property. - queue->MessageReadPropertyFilter->MessageType = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // MessageType property. - Console::WriteLine("Message.MessageType: {0}", - orderMessage->MessageType); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's Recoverable property. - queue->MessageReadPropertyFilter->Recoverable = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // Recoverable property. - Console::WriteLine("Message.Recoverable: {0}", - orderMessage->Recoverable); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's ResponseQueue property. - queue->MessageReadPropertyFilter->ResponseQueue = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // Responsequeue->QueueName property. - if (orderMessage->ResponseQueue != nullptr) - { - Console::WriteLine( - "Message.Responsequeue->QueueName: {0}", - orderMessage->ResponseQueue->QueueName); - } - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's SenderCertificate property. - queue->MessageReadPropertyFilter-> - SenderCertificate = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // SenderCertificate property. - Console::WriteLine("Message.SenderCertificate: {0}", - orderMessage->SenderCertificate); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's SenderId property. - queue->MessageReadPropertyFilter->SenderId = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's SenderId property. - Console::WriteLine("Message.SenderId: {0}", - orderMessage->SenderId); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's SenderVersion property. - queue->MessageReadPropertyFilter->SenderVersion = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // SenderVersion property. - Console::WriteLine("Message.SenderVersion: {0}", - orderMessage->SenderVersion); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's SentTime property. - queue->MessageReadPropertyFilter->SentTime = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's SentTime property. - Console::WriteLine("Message.SentTime: {0}", - orderMessage->SentTime); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's SourceMachine property. - queue->MessageReadPropertyFilter->SourceMachine = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // SourceMachine property. - Console::WriteLine("Message.SourceMachine: {0}", - orderMessage->SourceMachine); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's TimeToBeReceived property. - queue->MessageReadPropertyFilter-> - TimeToBeReceived = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // TimeToBeReceived property. - Console::WriteLine("Message.TimeToBeReceived: {0}", - orderMessage->TimeToBeReceived); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's TimeToReachQueue property. - queue->MessageReadPropertyFilter-> - TimeToReachQueue = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // TimeToReachQueue property. - Console::WriteLine("Message.TimeToReachQueue: {0}", - orderMessage->TimeToReachQueue); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's UseAuthentication property. - queue->MessageReadPropertyFilter-> - UseAuthentication = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // UseAuthentication property. - Console::WriteLine("Message.UseAuthentication: {0}", - orderMessage->UseAuthentication); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's UseDeadLetterQueue property. - queue->MessageReadPropertyFilter-> - UseDeadLetterQueue = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // UseDeadLetterQueue property. - Console::WriteLine("Message.UseDeadLetterQueue: {0}", - orderMessage->UseDeadLetterQueue); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's UseEncryption property. - queue->MessageReadPropertyFilter->UseEncryption = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // UseEncryption property. - Console::WriteLine("Message.UseEncryption: {0}", - orderMessage->UseEncryption); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's UseJournalQueue property. - queue->MessageReadPropertyFilter-> - UseJournalQueue = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // UseJournalQueue property. - Console::WriteLine("Message.UseJournalQueue: {0}", - orderMessage->UseJournalQueue); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's UseTracing property. - queue->MessageReadPropertyFilter->UseTracing = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // UseTracing property. - Console::WriteLine("Message.UseTracing: {0}", - orderMessage->UseTracing); - - // - // - // Set all of the queue's MessageReadPropertyFilter - // Boolean properties to false. - queue->MessageReadPropertyFilter->ClearAll(); - - // - // - // Set all of the queue's MessageReadPropertyFilter - // properties to their defaults. - queue->MessageReadPropertyFilter->SetDefaults(); - - // - // - // Set all of the queue's MessageReadPropertyFilter - // Boolean properties to true. - queue->MessageReadPropertyFilter->SetAll(); - - // - // - // Assign the queue a new MessageReadPropertyFilter. - queue->MessageReadPropertyFilter = - gcnew MessagePropertyFilter; - - // - // Receive the message. This will remove the message - // from the queue-> - orderMessage = - queue->Receive(TimeSpan::FromSeconds(10.0)); - } - - // Sends an order to a transactional queue-> - void SendMessageToTransQueue() - { - // Create a new order and set values. - Order^ sentOrder = gcnew Order; - sentOrder->OrderId = 3; - sentOrder->OrderTime = DateTime::Now; - - // Connect to a queue on the local computer. - MessageQueue^ queue = - gcnew MessageQueue(".\\orderTransQueue"); - - // Create the new order. - Message^ orderMessage = gcnew Message(sentOrder); - - // Create a message queuing transaction-> - MessageQueueTransaction^ transaction = - gcnew MessageQueueTransaction; - - try - { - // Begin a transaction-> - transaction->Begin(); - - // Send the order to the queue-> - queue->Send(orderMessage, transaction); - - // Commit the transaction-> - transaction->Commit(); - } - catch (MessageQueueException^ ex) - { - // Abort the transaction-> - transaction->Abort(); - - // Propagate the exception. - throw; - } - finally - { - // Delete the transaction object. - delete transaction; - } - } - - // Receives a message containing an order. - void ReceiveMessageFromTransQueue() - { - // Connect to the a queue on the local computer. - MessageQueue^ queue = - gcnew MessageQueue(".\\orderTransQueue"); - - // Set the formatter to indicate the - // message body contains an order. - array ^targetTypes = gcnew array(1); - targetTypes[0] = Order::typeid; - queue->Formatter = - gcnew XmlMessageFormatter(targetTypes); - - // Declare the message. - Message^ orderMessage; - - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's IsFirstInTransaction property. - queue->MessageReadPropertyFilter-> - IsFirstInTransaction = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // IsFirstInTransaction property. - Console::WriteLine("Message.IsFirstInTransaction: {0}", - orderMessage->IsFirstInTransaction); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's IsLastInTransaction property. - queue->MessageReadPropertyFilter-> - IsLastInTransaction = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // IsLastInTransaction property. - Console::WriteLine("Message.IsLastInTransaction: {0}", - orderMessage->IsLastInTransaction); - - // - // - // Set the queue's MessageReadPropertyFilter property - // to enable the message's TransactionId property. - queue->MessageReadPropertyFilter->TransactionId = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // TransactionId property. - Console::WriteLine("Message.TransactionId: {0}", - orderMessage->TransactionId); - - // - // - // Set the queue's MessageReadPropertyFilter property to - // enable the message's TransactionStatusQueue property. - queue->MessageReadPropertyFilter-> - TransactionStatusQueue = true; - - // Peek at the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Peek(TimeSpan::FromSeconds(10.0)); - - // Display the value of the message's - // TransactionStatusqueue->QueueName property. - Console::WriteLine( - "Message.TransactionStatusqueue->QueueName: {0}", - orderMessage->TransactionStatusQueue->QueueName); - - // - // Create a message queuing transaction-> - MessageQueueTransaction^ transaction = - gcnew MessageQueueTransaction; - - try - { - // Begin a transaction-> - transaction->Begin(); - - // Receive the message. Time out after ten seconds - // in case the message was not delivered. - orderMessage = queue->Receive( - TimeSpan::FromSeconds(10.0), transaction); - - // Commit the transaction-> - transaction->Commit(); - } - catch (MessageQueueException^ ex) - { - // Abort the transaction-> - transaction->Abort(); - - // Propagate the exception. - throw; - } - finally - { - // Delete the transaction object. - delete transaction; - } - } - }; -} - -int main() -{ - // Create a new instance of the class. - MessagePropertyFilterExample::OrderProcessor^ processor = - gcnew MessagePropertyFilterExample::OrderProcessor; - - try - { - // Create a non-transactional queue on the local computer. - // Note that the queue might not be immediately accessible, - //and therefore this example might throw an exception of type - // System.Messaging.MessageQueueException when trying to send - // a message to the newly created queue-> - MessagePropertyFilterExample:: - OrderProcessor::CreateQueue(".\\orderQueue", false); - - // Send a message to a queue-> - processor->SendMessage(); - - // Receive a message from a queue-> - processor->ReceiveMessage(); - - // Create a transactional queue on the local computer. - MessagePropertyFilterExample:: - OrderProcessor::CreateQueue(".\\orderTransQueue", true); - - // Send a message to a transactional queue-> - processor->SendMessageToTransQueue(); - - // Receive a message from a transactional queue-> - processor->ReceiveMessageFromTransQueue(); - } - catch (MessageQueueException^ ex) - { - // Write the exception information to the console. - Console::WriteLine(ex); - } -} - -// - -//output: -// -//.\orderQueue already exists. -//Message.AcknowledgeType: None -//Message.AdministrationQueue: -//Message.AppSpecific: 0 -//Message.ArrivedTime: 13.11.2004 14:42:30 -//Message.AttachSenderId: True -//Message.Authenticated: False -//Message.AuthenticationProviderName: -//Message.AuthenticationProviderType: None -//Message.Body: Order -//Message.ConnectorType: 00000000-0000-0000-0000-000000000000 -//MessageReadPropertyFilter.DefaultBodySize: 2048 -//MessageReadPropertyFilter.DefaultExtensionSize: 1024 -//MessageReadPropertyFilter.DefaultLabelSize: 1024 -//Message.Destinationqueue->QueueName: orderqueue -//Message.DestinationSymmetricKey: System.Byte[] -//Message.DigitalSignature: System.Byte[] -//Message.EncryptionAlgorithm: None -//Message.Extension: System.Byte[] -//Message.HashAlgorithm: None -//Message.Id: f2c7b57e-da35-4596-8b30-3b2ce0dd3756\2058 -//Message.Label: Order Message -//Message.MessageType: Normal -//Message.Recoverable: False -//Message.SenderCertificate: System.Byte[] -//Message.SenderId: System.Byte[] -//Message.SenderVersion: 16 -//Message.SentTime: 13.11.2004 14:42:30 -//Message.SourceMachine: ulkdev1 -//Message.TimeToBeReceived: 49710.06:28:15 -//Message.TimeToReachQueue: 4.00:00:00 -//Message.UseAuthentication: False -//Message.UseDeadLetterQueue: False -//Message.UseEncryption: False -//Message.UseJournalQueue: False -//Message.UseTracing: False -//.\orderTransQueue already exists. -//Message.IsFirstInTransaction: True -//Message.IsLastInTransaction: True -//Message.TransactionId: f2c7b57e-da35-4596-8b30-3b2ce0dd3756\2059 -//Message.TransactionStatusqueue->QueueName: private$\order_queue$ \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_TimeSpanStateObject/CPP/mqbeginpeek_timeoutstateobject.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_TimeSpanStateObject/CPP/mqbeginpeek_timeoutstateobject.cpp deleted file mode 100644 index f0d2909861803..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_TimeSpanStateObject/CPP/mqbeginpeek_timeoutstateobject.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - // Represents a state object associated with each message. - static int messageNumber = 0; - - // Provides an event handler for the PeekCompleted - // event. - // - static void MyPeekCompleted( Object^ source, PeekCompletedEventArgs^ asyncResult ) - { - try - { - // Connect to the queue. - MessageQueue^ mq = dynamic_cast(source); - - // End the asynchronous peek operation. - Message^ m = mq->EndPeek( asyncResult->AsyncResult ); - - // Display message information on the screen, - // including the message number (state object). - Console::WriteLine( "Message: {0} {1}", asyncResult->AsyncResult->AsyncState, static_cast(m->Body) ); - - // Restart the asynchronous peek operation, with the - // same time-out. - mq->BeginPeek( TimeSpan(0,1,0), messageNumber++ ); - } - catch ( MessageQueueException^ e ) - { - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::IOTimeout ) - { - Console::WriteLine( e ); - } - - // Handle other sources of MessageQueueException. - } - - // Handle other exceptions. - return; - } -}; - - -// Provides an entry point into the application. -// -// This example performs asynchronous peek operation -// processing. -int main() -{ - // Create an instance of MessageQueue. Set its formatter. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Add an event handler for the PeekCompleted event. - myQueue->PeekCompleted += gcnew PeekCompletedEventHandler( MyNewQueue::MyPeekCompleted ); - - // Begin the asynchronous peek operation with a timeout - // of one minute. - myQueue->BeginPeek( TimeSpan(0,1,0), MyNewQueue::messageNumber++ ); - - // Do other work on the current thread. - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_noparms/CPP/mqbeginpeek_noparms.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_noparms/CPP/mqbeginpeek_noparms.cpp deleted file mode 100644 index 7ba1236a1c668..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_noparms/CPP/mqbeginpeek_noparms.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// This example performs asynchronous peek operation -// processing. -//************************************************* -ref class MyNewQueue -{ -public: - - // Provides an event handler for the PeekCompleted - // event. - static void MyPeekCompleted( Object^ source, PeekCompletedEventArgs^ asyncResult ) - { - // Connect to the queue. - MessageQueue^ mq = dynamic_cast(source); - - // End the asynchronous peek operation. - Message^ m = mq->EndPeek( asyncResult->AsyncResult ); - - // Display message information on the screen. - Console::WriteLine( "Message: {0}", static_cast(m->Body) ); - - // Restart the asynchronous peek operation. - mq->BeginPeek(); - return; - } -}; - -// Provides an entry point into the application. -// -int main() -{ - // Create an instance of MessageQueue. Set its formatter. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Add an event handler for the PeekCompleted event. - myQueue->PeekCompleted += gcnew PeekCompletedEventHandler( MyNewQueue::MyPeekCompleted ); - - // Begin the asynchronous peek operation. - myQueue->BeginPeek(); - - // Do other work on the current thread. - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_timeout/CPP/mqbeginpeek_timeout.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_timeout/CPP/mqbeginpeek_timeout.cpp deleted file mode 100644 index 7b1891001d43e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginPeek_timeout/CPP/mqbeginpeek_timeout.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - static void MyPeekCompleted( Object^ source, PeekCompletedEventArgs^ asyncResult ) - { try - { - // Connect to the queue. - MessageQueue^ mq = dynamic_cast(source); - - // End the asynchronous peek operation. - Message^ m = mq->EndPeek( asyncResult->AsyncResult ); - - // Display message information on the screen. - Console::WriteLine( "Message: {0}", static_cast(m->Body) ); - - // Restart the asynchronous peek operation, with the - // same time-out. - mq->BeginPeek( TimeSpan(0,1,0) ); - } - catch ( MessageQueueException^ e ) - { - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::IOTimeout ) - { - Console::WriteLine( e ); - } - - // Handle other sources of MessageQueueException. - } - - // Handle other exceptions. - return; - } -}; - -int main() -{ - // Create an instance of MessageQueue. Set its formatter. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Add an event handler for the PeekCompleted event. - myQueue->PeekCompleted += gcnew PeekCompletedEventHandler( MyNewQueue::MyPeekCompleted ); - - // Begin the asynchronous peek operation with a timeout - // of one minute. - myQueue->BeginPeek( TimeSpan(0,1,0) ); - - // Do other work on the current thread. - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginReceive_noparms_combined/CPP/mqbeginreceive_noparms_mre.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginReceive_noparms_combined/CPP/mqbeginreceive_noparms_mre.cpp deleted file mode 100644 index d7d9f34865391..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginReceive_noparms_combined/CPP/mqbeginreceive_noparms_mre.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Messaging; -using namespace System::Threading; - -ref class MyNewQueue -{ -public: - - // Define static class members. - static ManualResetEvent^ signal = gcnew ManualResetEvent( false ); - static int count = 0; - - // Provides an event handler for the ReceiveCompleted - // event. - static void MyReceiveCompleted( Object^ source, ReceiveCompletedEventArgs^ asyncResult ) - { - try - { - // Connect to the queue. - MessageQueue^ mq = dynamic_cast(source); - - // End the asynchronous receive operation. - mq->EndReceive( asyncResult->AsyncResult ); - count += 1; - if ( count == 10 ) - { - signal->Set(); - } - - // Restart the asynchronous receive operation. - mq->BeginReceive(); - } - catch ( MessageQueueException^ ) - { - // Handle sources of MessageQueueException. - } - - // Handle other exceptions. - return; - } -}; - -// Provides an entry point into the application. -// -// This example performs asynchronous receive -// operation processing. -int main() -{ - // Create an instance of MessageQueue. Set its formatter. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Add an event handler for the ReceiveCompleted event. - myQueue->ReceiveCompleted += gcnew ReceiveCompletedEventHandler( MyNewQueue::MyReceiveCompleted ); - - // Begin the asynchronous receive operation. - myQueue->BeginReceive(); - MyNewQueue::signal->WaitOne(); - - // Do other work on the current thread. - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginReceive_noparms_combined/CPP/mqbeginreceive_noparms_wh.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginReceive_noparms_combined/CPP/mqbeginreceive_noparms_wh.cpp deleted file mode 100644 index 9a88b22ee3cef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.BeginReceive_noparms_combined/CPP/mqbeginreceive_noparms_wh.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Messaging; -using namespace System::Threading; - -ref class MyNewQueue -{ -public: - - // Provides an event handler for the ReceiveCompleted - // event. - static void MyReceiveCompleted( Object^ source, ReceiveCompletedEventArgs^ asyncResult ) - { - try - { - // Connect to the queue. - MessageQueue^ mq = dynamic_cast(source); - - // End the asynchronous receive operation. - mq->EndReceive( asyncResult->AsyncResult ); - - // Process the message here. - Console::WriteLine( "Message received." ); - } - catch ( MessageQueueException^ ) - { - // Handle sources of MessageQueueException. - } - // Handle other exceptions. - return; - } -}; - -// Provides an entry point into the application. -// -// This example performs asynchronous receive -// operation processing. -int main() -{ - // Create an instance of MessageQueue. Set its formatter. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Add an event handler for the ReceiveCompleted event. - myQueue->ReceiveCompleted += gcnew ReceiveCompletedEventHandler( MyNewQueue::MyReceiveCompleted ); - - // Define wait handles for multiple operations. - array^waitHandleArray = gcnew array(10); - for ( int i = 0; i < 10; i++ ) - { - // Begin asynchronous operations. - waitHandleArray[ i ] = myQueue->BeginReceive()->AsyncWaitHandle; - } - - // Specify to wait for all operations to return. - WaitHandle::WaitAll( waitHandleArray ); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Close/CPP/mqclose.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Close/CPP/mqclose.cpp deleted file mode 100644 index 5bddf73feadc3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Close/CPP/mqclose.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - // Sends a message to a queue. - void SendMessage() - { - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Send a message to the queue. - myQueue->Send( "My message data1." ); - - // Explicitly release resources. - myQueue->Close(); - - // Attempt to reaquire resources. - myQueue->Send( "My message data2." ); - return; - } - - // Receives a message from a queue. - void ReceiveMessage() - { - // Connect to the a on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Set the formatter to indicate body contains an Order. - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - try - { - // Receive and format the message. - Message^ myMessage1 = myQueue->Receive(); - Message^ myMessage2 = myQueue->Receive(); - } - catch ( MessageQueueException^ ) - { - // Handle sources of any MessageQueueException. - } - finally - { - // Free resources. - myQueue->Close(); - } - - return; - } -}; - - -// Provides an entry point into the application. -// This example closes a queue and frees its -// resources. -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send a message to a queue. - myNewQueue->SendMessage(); - - // Receive a message from a queue. - myNewQueue->ReceiveMessage(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Create_PathTransactional/CPP/mqcreate_transactional.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Create_PathTransactional/CPP/mqcreate_transactional.cpp deleted file mode 100644 index 6d9baa8ba1726..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Create_PathTransactional/CPP/mqcreate_transactional.cpp +++ /dev/null @@ -1,106 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - // Creates public transactional queues and sends a - // message. - void CreatePublicTransactionalQueues() - { - - // Create and connect to a public message Queuing queue. - if ( !MessageQueue::Exists( ".\\newPublicTransQueue1" ) ) - { - - // Create the queue if it does not exist. - MessageQueue::Create( ".\\newPublicTransQueue1", true ); - } - - - // Connect to the queue. - MessageQueue^ myNewPublicQueue = gcnew MessageQueue( ".\\newPublicTransQueue1" ); - - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - - // Begin the transaction. - myTransaction->Begin(); - - // Send the message. - myNewPublicQueue->Send( "My Message Data.", myTransaction ); - - // Commit the transaction. - myTransaction->Commit(); - if ( !MessageQueue::Exists( ".\\newPublicTransQueue2" ) ) - { - - // Create (but do not connect to) second public queue - MessageQueue::Create( ".\\newPublicTransQueue2", true ); - } - - return; - } - - - // Creates private queues and sends a message. - void CreatePrivateTransactionalQueues() - { - - // Create and connect to a private Message Queuing queue. - if ( !MessageQueue::Exists( ".\\Private$\\newPrivTransQ1" ) ) - { - - // Create the queue if it does not exist. - MessageQueue^ myNewPrivateQueue = MessageQueue::Create( ".\\Private$\\newPrivTransQ1", true ); - } - - - // Connect to the queue. - MessageQueue^ myNewPrivateQueue = gcnew MessageQueue( ".\\Private$\\newPrivTransQ1" ); - - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - - // Begin the transaction. - myTransaction->Begin(); - - // Send the message. - myNewPrivateQueue->Send( "My Message Data.", myTransaction ); - - // Commit the transaction. - myTransaction->Commit(); - - // Create (but do not connect to) a second private queue. - if ( !MessageQueue::Exists( ".\\Private$\\newPrivTransQ2" ) ) - { - MessageQueue::Create( ".\\Private$\\newPrivTransQ2", true ); - } - - return; - } - -}; - - -// Provides an entry point into the application. -// This example creates new transactional queues. -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Create transactional queues. - myNewQueue->CreatePublicTransactionalQueues(); - myNewQueue->CreatePrivateTransactionalQueues(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Create_path/CPP/mqcreate.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Create_path/CPP/mqcreate.cpp deleted file mode 100644 index f90ef5700fc65..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Create_path/CPP/mqcreate.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// This example creates new public and private queues. -ref class MyNewQueue -{ -public: - void CreatePublicQueues() - { - - // Create and connect to a public Message Queuing queue. - if ( !MessageQueue::Exists( ".\\newPublicQueue" ) ) - { - - // Create the queue if it does not exist. - MessageQueue^ myNewPublicQueue = MessageQueue::Create( ".\\newPublicQueue" ); - - // Send a message to the queue. - myNewPublicQueue->Send( "My message data." ); - } - - - // Create (but do not connect to) a second public queue. - if ( !MessageQueue::Exists( ".\\newPublicResponseQueue" ) ) - { - MessageQueue::Create( ".\\newPublicResponseQueue" ); - } - - return; - } - - - // Creates private queues and sends a message. - void CreatePrivateQueues() - { - - // Create and connect to a private Message Queuing queue. - if ( !MessageQueue::Exists( ".\\Private$\\newPrivQueue" ) ) - { - - // Create the queue if it does not exist. - MessageQueue^ myNewPrivateQueue = MessageQueue::Create( ".\\Private$\\newPrivQueue" ); - - // Send a message to the queue. - myNewPrivateQueue->Send( "My message data." ); - } - - - // Create (but do not connect to) a second private queue. - if ( !MessageQueue::Exists( ".\\Private$\\newResponseQueue" ) ) - { - MessageQueue::Create( ".\\Private$\\newResponseQueue" ); - } - - return; - } - -}; - - -// Provides an entry point into the application. -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Create public and private queues. - myNewQueue->CreatePublicQueues(); - myNewQueue->CreatePrivateQueues(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.DefaultPropertiesToSend/CPP/mqdefaultpropertiestosend.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.DefaultPropertiesToSend/CPP/mqdefaultpropertiestosend.cpp deleted file mode 100644 index 6195578a276b1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.DefaultPropertiesToSend/CPP/mqdefaultpropertiestosend.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - // Associates selected message property values - // with high priority messages. - void SendHighPriorityMessages() - { - - // Connect to a message queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Associate selected default property values with high - // priority messages. - myQueue->DefaultPropertiesToSend->Priority = MessagePriority::High; - myQueue->DefaultPropertiesToSend->Label = "High Priority Message"; - myQueue->DefaultPropertiesToSend->Recoverable = true; - myQueue->DefaultPropertiesToSend->TimeToReachQueue = TimeSpan(0,0,30); - - // Send messages using these defaults. - myQueue->Send( "High priority message data 1." ); - myQueue->Send( "High priority message data 2." ); - myQueue->Send( "High priority message data 3." ); - return; - } - - - // Associates selected message property values - // with normal priority messages. - void SendNormalPriorityMessages() - { - - // Connect to a message queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Associate selected default property values with normal - // priority messages. - myQueue->DefaultPropertiesToSend->Priority = MessagePriority::Normal; - myQueue->DefaultPropertiesToSend->Label = "Normal Priority Message"; - myQueue->DefaultPropertiesToSend->Recoverable = false; - myQueue->DefaultPropertiesToSend->TimeToReachQueue = TimeSpan(0,2,0); - - // Send messages using these defaults. - myQueue->Send( "Normal priority message data 1." ); - myQueue->Send( "Normal priority message data 2." ); - myQueue->Send( "Normal priority message data 3." ); - return; - } - -}; - - -// Provides an entry point into the application. -// This example specifies different types of default -// properties for messages. -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send normal and high priority messages. - myNewQueue->SendNormalPriorityMessages(); - myNewQueue->SendHighPriorityMessages(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ExistsDelete/CPP/mqexistsdelete.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ExistsDelete/CPP/mqexistsdelete.cpp deleted file mode 100644 index 5f7ef61941745..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ExistsDelete/CPP/mqexistsdelete.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -int main() -{ - - // Determine whether the queue exists. - if ( MessageQueue::Exists( ".\\myQueue" ) ) - { - try - { - - // Delete the queue. - MessageQueue::Delete( ".\\myQueue" ); - } - catch ( MessageQueueException^ e ) - { - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::AccessDenied ) - { - Console::WriteLine( "Access is denied. Queue might be a system queue." ); - } - - // Handle other sources of MessageQueueException. - } - - } - - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageEnumerator/CPP/mqgetmessageenumerator.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageEnumerator/CPP/mqgetmessageenumerator.cpp deleted file mode 100644 index 2f0f3252ea61c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageEnumerator/CPP/mqgetmessageenumerator.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - void CountLowestPriority() - { - - // Holds the count of Lowest priority messages. - UInt32 numberItems = 0; - - // Connect to a queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Get a cursor into the messages in the queue. - MessageEnumerator^ myEnumerator = myQueue->GetMessageEnumerator(); - - // Specify that the messages's priority should be read. - myQueue->MessageReadPropertyFilter->Priority = true; - - // Move to the next message and examine its priority. - while ( myEnumerator->MoveNext() ) - { - - // Increase the count if priority is Lowest. - if ( myEnumerator->Current->Priority == MessagePriority::Lowest ) - numberItems++; - } - - - // Display final count. - Console::WriteLine( "Lowest priority messages: {0}", numberItems ); - return; - } - -}; - -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Output the count of Lowest priority messages. - myNewQueue->CountLowestPriority(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageQueueEnumerator_criteria/CPP/mqgetmessagequeueenumerator_criteria.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageQueueEnumerator_criteria/CPP/mqgetmessagequeueenumerator_criteria.cpp deleted file mode 100644 index fad785df5ce01..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageQueueEnumerator_criteria/CPP/mqgetmessagequeueenumerator_criteria.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - // Iterates through message queues and displays the - // path of each queue that was created in the last - // day and that exists on the computer "MyComputer". - void ListPublicQueuesByCriteria() - { - UInt32 numberQueues = 0; - - // Specify the criteria to filter by. - MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria; - myCriteria->MachineName = "MyComputer"; - myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) ); - - // Get a cursor into the queues on the network. - MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator( myCriteria ); - - // Move to the next queue and read its path. - while ( myQueueEnumerator->MoveNext() ) - { - - // Increase the count if priority is Lowest. - Console::WriteLine( myQueueEnumerator->Current->Path ); - numberQueues++; - } - - - // Handle no queues matching the criteria. - if ( numberQueues == 0 ) - { - Console::WriteLine( "No public queues match criteria." ); - } - - return; - } - -}; - -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Output the count of Lowest priority messages. - myNewQueue->ListPublicQueuesByCriteria(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageQueueEnumerator_noparms/CPP/mqgetmessagequeueenumerator.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageQueueEnumerator_noparms/CPP/mqgetmessagequeueenumerator.cpp deleted file mode 100644 index 2b942b46c1f91..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetMessageQueueEnumerator_noparms/CPP/mqgetmessagequeueenumerator.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -//************************************************** -// Iterates through message queues and examines the -// path for each queue. Also displays the number of -// public queues on the network. -//************************************************** -void ListPublicQueues() -{ - - // Holds the count of private queues. - int numberQueues = 0; - - // Get a cursor into the queues on the network. - MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator(); - - // Move to the next queue and read its path. - while ( myQueueEnumerator->MoveNext() ) - { - - // Increase the count if priority is Lowest. - Console::WriteLine( myQueueEnumerator->Current->Path ); - numberQueues++; - } - - - // Display final count. - Console::WriteLine( "Number of public queues: {0}", numberQueues ); - return; -} - - -//************************************************** -// Provides an entry point into the application. -// -// This example uses a cursor to step through the -// message queues and list the public queues on the -// network. -//************************************************** -int main() -{ - - // Output the count of Lowest priority messages. - ListPublicQueues(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetQueueLists/CPP/mqgetqueuelists.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetQueueLists/CPP/mqgetqueuelists.cpp deleted file mode 100644 index 8092de2b7ee03..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.GetQueueLists/CPP/mqgetqueuelists.cpp +++ /dev/null @@ -1,155 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -using namespace System::Collections; -ref class MyNewQueue -{ -public: - - // Gets a list of queues with a specified category. - // Sends a broadcast message to all queues in that - // category. - void GetQueuesByCategory() - { - - // Get a list of queues with the specified category. - array^QueueList = MessageQueue::GetPublicQueuesByCategory( Guid(" {00000000-0000-0000-0000-000000000001}") ); - - // Send a broadcast message to each queue in the array. - IEnumerator^ myEnum = QueueList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MessageQueue^ queueItem = safe_cast(myEnum->Current); - queueItem->Send( "Broadcast message." ); - } - - return; - } - - - // Gets a list of queues with a specified label. - // Sends a broadcast message to all queues with that - // label. - void GetQueuesByLabel() - { - - // Get a list of queues with the specified label. - array^QueueList = MessageQueue::GetPublicQueuesByLabel( "My Label" ); - - // Send a broadcast message to each queue in the array. - IEnumerator^ myEnum = QueueList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MessageQueue^ queueItem = safe_cast(myEnum->Current); - queueItem->Send( "Broadcast message." ); - } - - return; - } - - - // Gets a list of queues on a specified computer. - // Displays the list on screen. - void GetQueuesByComputer() - { - - // Get a list of queues on the specified computer. - array^QueueList = MessageQueue::GetPublicQueuesByMachine( "MyComputer" ); - - // Display the paths of the queues in the list. - IEnumerator^ myEnum = QueueList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MessageQueue^ queueItem = safe_cast(myEnum->Current); - Console::WriteLine( queueItem->Path ); - } - - return; - } - - - // Gets a list of all public queues. - void GetAllPublicQueues() - { - - // Get a list of public queues. - array^QueueList = MessageQueue::GetPublicQueues(); - return; - } - - - // Gets a list of all public queues that match - // specified criteria. Displays the list on - // screen. - void GetPublicQueuesByCriteria() - { - - // Define criteria to filter the queues. - MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria; - myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) ); - myCriteria->ModifiedBefore = DateTime::Now; - myCriteria->MachineName = "."; - myCriteria->Label = "My Queue"; - - // Get a list of queues with that criteria. - array^QueueList = MessageQueue::GetPublicQueues( myCriteria ); - - // Display the paths of the queues in the list. - IEnumerator^ myEnum = QueueList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MessageQueue^ queueItem = safe_cast(myEnum->Current); - Console::WriteLine( queueItem->Path ); - } - - return; - } - - - // Gets a list of private queues on the local - // computer. Displays the list on screen. - void GetPrivateQueues() - { - - // Get a list of queues with the specified category. - array^QueueList = MessageQueue::GetPrivateQueuesByMachine( "." ); - - // Display the paths of the queues in the list. - IEnumerator^ myEnum = QueueList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MessageQueue^ queueItem = safe_cast(myEnum->Current); - Console::WriteLine( queueItem->Path ); - } - - return; - } - -}; - - -// Provides an entry point into the application. -// This example gets lists of queues by a variety -// of criteria. -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send normal and high priority messages. - myNewQueue->GetQueuesByCategory(); - myNewQueue->GetQueuesByLabel(); - myNewQueue->GetQueuesByComputer(); - myNewQueue->GetAllPublicQueues(); - myNewQueue->GetPublicQueuesByCriteria(); - myNewQueue->GetPrivateQueues(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.MessageReadPropertyFilter/CPP/mqmessagereadpropertyfilter.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.MessageReadPropertyFilter/CPP/mqmessagereadpropertyfilter.cpp deleted file mode 100644 index 4cd306bad0212..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.MessageReadPropertyFilter/CPP/mqmessagereadpropertyfilter.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - //************************************************* - // Retrieves the default properties for a Message. - //************************************************* - void RetrieveDefaultProperties() - { - // Connect to a message queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Specify to retrieve the default properties only. - myQueue->MessageReadPropertyFilter->SetDefaults(); - - // Set the formatter for the Message. - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Receive the first message in the queue. - Message^ myMessage = myQueue->Receive(); - - // Display selected properties. - Console::WriteLine( "Label: {0}", myMessage->Label ); - Console::WriteLine( "Body: {0}", static_cast(myMessage->Body) ); - return; - } - - - //************************************************* - // Retrieves all properties for a Message. - //************************************************* - void RetrieveAllProperties() - { - // Connect to a message queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Specify to retrieve all properties. - myQueue->MessageReadPropertyFilter->SetAll(); - - // Set the formatter for the Message. - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Receive the first message in the queue. - Message^ myMessage = myQueue->Receive(); - - // Display selected properties. - Console::WriteLine( "Encryption algorithm: {0}", myMessage->EncryptionAlgorithm.ToString() ); - Console::WriteLine( "Body: {0}", myMessage->Body ); - return; - } - - //************************************************* - // Retrieves application-specific properties for a - // Message. - //************************************************* - void RetrieveSelectedProperties() - { - // Connect to a message queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Specify to retrieve selected properties. - MessagePropertyFilter^ myFilter = gcnew MessagePropertyFilter; - myFilter->ClearAll(); - - // The following list is a random subset of available properties. - myFilter->Body = true; - myFilter->Label = true; - myFilter->MessageType = true; - myFilter->Priority = true; - myQueue->MessageReadPropertyFilter = myFilter; - - // Set the formatter for the Message. - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Receive the first message in the queue. - Message^ myMessage = myQueue->Receive(); - - // Display selected properties. - Console::WriteLine( "Message type: {0}", myMessage->MessageType.ToString() ); - Console::WriteLine( "Priority: {0}", myMessage->Priority.ToString() ); - return; - } -}; - - -//************************************************* -// Provides an entry point into the application. -// -// This example retrieves specific groups of Message -// properties. -//************************************************* -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Retrieve specific sets of Message properties. - myNewQueue->RetrieveDefaultProperties(); - myNewQueue->RetrieveAllProperties(); - myNewQueue->RetrieveSelectedProperties(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Path/CPP/mqpath.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Path/CPP/mqpath.cpp deleted file mode 100644 index 34ef71be8b214..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Path/CPP/mqpath.cpp +++ /dev/null @@ -1,125 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - // References public queues. - void SendPublic() - { - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - myQueue->Send( "Public queue by path name." ); - return; - } - - - // References private queues. - void SendPrivate() - { - MessageQueue^ myQueue = gcnew MessageQueue( ".\\Private$\\myQueue" ); - myQueue->Send( "Private queue by path name." ); - return; - } - - - // References queues by label. - void SendByLabel() - { - MessageQueue^ myQueue = gcnew MessageQueue( "Label:TheLabel" ); - myQueue->Send( "Queue by label." ); - return; - } - - - // References queues by format name. - void SendByFormatName() - { - MessageQueue^ myQueue = gcnew MessageQueue( "FormatName:Public=5A5F7535-AE9A-41d4 -935C-845C2AFF7112" ); - myQueue->Send( "Queue by format name." ); - return; - } - - - // References computer journal queues. - void MonitorComputerJournal() - { - MessageQueue^ computerJournal = gcnew MessageQueue( ".\\Journal$" ); - while ( true ) - { - Message^ journalMessage = computerJournal->Receive(); - - // Process the journal message. - } - } - - - // References queue journal queues. - void MonitorQueueJournal() - { - MessageQueue^ queueJournal = gcnew MessageQueue( ".\\myQueue\\Journal$" ); - while ( true ) - { - Message^ journalMessage = queueJournal->Receive(); - - // Process the journal message. - } - } - - - // References dead-letter queues. - void MonitorDeadLetter() - { - MessageQueue^ deadLetter = gcnew MessageQueue( ".\\DeadLetter$" ); - while ( true ) - { - Message^ deadMessage = deadLetter->Receive(); - - // Process the dead-letter message. - } - } - - - // References transactional dead-letter queues. - void MonitorTransactionalDeadLetter() - { - MessageQueue^ TxDeadLetter = gcnew MessageQueue( ".\\XactDeadLetter$" ); - while ( true ) - { - Message^ txDeadLetter = TxDeadLetter->Receive(); - - // Process the transactional dead-letter message. - } - } - -}; - - -//************************************************* -// Provides an entry point into the application. -// -// This example demonstrates several ways to set -// a queue's path. -//************************************************* -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - myNewQueue->SendPublic(); - myNewQueue->SendPrivate(); - myNewQueue->SendByLabel(); - myNewQueue->SendByFormatName(); - myNewQueue->MonitorComputerJournal(); - myNewQueue->MonitorQueueJournal(); - myNewQueue->MonitorDeadLetter(); - myNewQueue->MonitorTransactionalDeadLetter(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Peek_noparms/CPP/mqpeek_noparms.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Peek_noparms/CPP/mqpeek_noparms.cpp deleted file mode 100644 index 15915890bde37..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Peek_noparms/CPP/mqpeek_noparms.cpp +++ /dev/null @@ -1,127 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// This class represents an object the following example -// sends to a queue and receives from a queue. -ref class Order -{ -public: - int orderId; - DateTime orderTime; -}; - - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ -public: - - //************************************************* - // Posts a notification when a message arrives in - // the queue S"monitoredQueue". Does not retrieve any - // message information when peeking the message. - //************************************************* - void NotifyArrived() - { - // Connect to a queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\monitoredQueue" ); - - // Specify to retrieve no message information. - myQueue->MessageReadPropertyFilter->ClearAll(); - - // Wait for a message to arrive. - Message^ emptyMessage = myQueue->Peek(); - - // Post a notification when a message arrives. - Console::WriteLine( "A message has arrived in the queue." ); - return; - } - - - //************************************************* - // Sends an Order to a queue. - //************************************************* - void SendMessage() - { - // Create a new order and set values. - Order^ sentOrder = gcnew Order; - sentOrder->orderId = 3; - sentOrder->orderTime = DateTime::Now; - - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Send the Order to the queue. - myQueue->Send( sentOrder ); - return; - } - - //************************************************* - // Peeks a message containing an Order. - //************************************************* - void PeekFirstMessage() - { - // Connect to a queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Set the formatter to indicate the body contains an Order. - array^p = gcnew array(1); - p[ 0 ] = Order::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - try - { - // Peek and format the message. - Message^ myMessage = myQueue->Peek(); - Order^ myOrder = static_cast(myMessage->Body); - - // Display message information. - Console::WriteLine( "Order ID: {0}", myOrder->orderId ); - Console::WriteLine( "Sent: {0}", myOrder->orderTime ); - } - catch ( MessageQueueException^ ) - { - // Handle Message Queuing exceptions. - } - // Handle invalid serialization format. - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( e->Message ); - } - - // Catch other exceptions as necessary. - return; - } -}; - -//************************************************* -// Provides an entry point into the application. -// -// This example posts a notification that a message -// has arrived in a queue. It sends a message -// containing an other to a separate queue, and then -// peeks the first message in the queue. -//************************************************* -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Wait for a message to arrive in the queue. - myNewQueue->NotifyArrived(); - - // Send a message to a queue. - myNewQueue->SendMessage(); - - // Peek the first message in the queue. - myNewQueue->PeekFirstMessage(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Peek_timeout/CPP/mqpeek_timeout.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Peek_timeout/CPP/mqpeek_timeout.cpp deleted file mode 100644 index 25b765ab9499f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Peek_timeout/CPP/mqpeek_timeout.cpp +++ /dev/null @@ -1,73 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - //************************************************* - // Determines whether a queue is empty. The Peek() - // method throws an exception if there is no message - // in the queue. This method handles that exception - // by returning true to the calling method. - //************************************************* - bool IsQueueEmpty() - { - bool isQueueEmpty = false; - - // Connect to a queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - try - { - - // Set Peek to return immediately. - myQueue->Peek( TimeSpan(0) ); - - // If an IOTime->Item[Out] was* not thrown, there is a message - // in the queue. - isQueueEmpty = false; - } - catch ( MessageQueueException^ e ) - { - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::IOTimeout ) - { - - // No message was in the queue. - isQueueEmpty = true; - } - - - // Handle other sources of MessageQueueException. - } - - - // Handle other exceptions as necessary. - // Return true if there are no messages in the queue. - return isQueueEmpty; - } - -}; - - -//************************************************* -// Provides an entry point into the application. -// -// This example determines whether a queue is empty. -//************************************************* -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Determine whether a queue is empty. - bool isQueueEmpty = myNewQueue->IsQueueEmpty(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ReceiveCompleted/CPP/mqreceivecompletedeventhandler.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ReceiveCompleted/CPP/mqreceivecompletedeventhandler.cpp deleted file mode 100644 index 693998fa99587..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ReceiveCompleted/CPP/mqreceivecompletedeventhandler.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - //************************************************* - // Provides an event handler for the ReceiveCompleted - // event. - //************************************************* - static void MyReceiveCompleted( Object^ source, ReceiveCompletedEventArgs^ asyncResult ) - { - // Connect to the queue. - MessageQueue^ mq = dynamic_cast(source); - - // End the asynchronous Receive operation. - Message^ m = mq->EndReceive( asyncResult->AsyncResult ); - - // Display message information on the screen. - Console::WriteLine( "Message: {0}", m->Body ); - - // Restart the asynchronous Receive operation. - mq->BeginReceive(); - return; - } -}; - - -//************************************************* -// Provides an entry point into the application. -// -// This example performs asynchronous receive operation -// processing. -//************************************************* -int main() -{ - // Create an instance of MessageQueue. Set its formatter. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Add an event handler for the ReceiveCompleted event. - myQueue->ReceiveCompleted += gcnew ReceiveCompletedEventHandler( MyNewQueue::MyReceiveCompleted ); - - // Begin the asynchronous receive operation. - myQueue->BeginReceive(); - - // Do other work on the current thread. - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_TimeoutTransaction/CPP/mqreceive_timeouttransaction.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_TimeoutTransaction/CPP/mqreceive_timeouttransaction.cpp deleted file mode 100644 index 4908e655b4aa3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_TimeoutTransaction/CPP/mqreceive_timeouttransaction.cpp +++ /dev/null @@ -1,121 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ -public: - - //************************************************* - // Sends a message to a transactional queue. - //************************************************* - void SendMessageTransactional() - { - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" ); - - // Send a message to the queue. - if ( myQueue->Transactional == true ) - { - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - - // Begin the transaction. - myTransaction->Begin(); - - // Send the message. - myQueue->Send( "My Message Data.", myTransaction ); - - // Commit the transaction. - myTransaction->Commit(); - } - - return; - } - - //************************************************* - // Receives a message from the transactional queue. - //************************************************* - void ReceiveMessageTransactional() - { - // Connect to a transactional queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" ); - - // Set the formatter. - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - try - { - // Begin the transaction. - myTransaction->Begin(); - - // Receive the message. - // Wait five seconds for a message to arrive. - Message^ myMessage = myQueue->Receive( TimeSpan(0,0,5), myTransaction ); - String^ myOrder = static_cast(myMessage->Body); - - // Display message information. - Console::WriteLine( myOrder ); - - // Commit the transaction. - myTransaction->Commit(); - } - catch ( MessageQueueException^ e ) - { - // Handle nontransactional queues. - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::TransactionUsage ) - { - Console::WriteLine( "Queue is not transactional." ); - } - // Handle no message arriving in the queue. - else - - // Handle no message arriving in the queue. - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::IOTimeout ) - { - Console::WriteLine( "No message in queue." ); - } - - // Else catch other sources of MessageQueueException. - // Roll back the transaction. - myTransaction->Abort(); - } - - // Catch other exceptions as necessary, such as - // InvalidOperationException, thrown when the formatter - // cannot deserialize the message. - return; - } -}; - -//************************************************* -// Provides an entry point into the application. -// -// This example sends and receives a message from -// a transactional queue. -//************************************************* -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send a message to a queue. - myNewQueue->SendMessageTransactional(); - - // Receive a message from a queue. - myNewQueue->ReceiveMessageTransactional(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_noparms/CPP/mqreceive_noparms.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_noparms/CPP/mqreceive_noparms.cpp deleted file mode 100644 index ab3720fe0ac0d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_noparms/CPP/mqreceive_noparms.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// This class represents an object the following example -// sends to a queue and receives from a queue. -ref class Order -{ -public: - int orderId; - DateTime orderTime; -}; - - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ -public: - - //************************************************* - // Sends an Order to a queue. - //************************************************* - void SendMessage() - { - // Create a new order and set values. - Order^ sentOrder = gcnew Order; - sentOrder->orderId = 3; - sentOrder->orderTime = DateTime::Now; - - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Send the Order to the queue. - myQueue->Send( sentOrder ); - return; - } - - //************************************************* - // Receives a message containing an Order. - //************************************************* - void ReceiveMessage() - { - // Connect to the a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Set the formatter to indicate body contains an Order. - array^p = gcnew array(1); - p[ 0 ] = Order::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - try - { - // Receive and format the message. - Message^ myMessage = myQueue->Receive(); - Order^ myOrder = static_cast(myMessage->Body); - - // Display message information. - Console::WriteLine( "Order ID: {0}", myOrder->orderId ); - Console::WriteLine( "Sent: {0}", myOrder->orderTime ); - } - catch ( MessageQueueException^ ) - { - // Handle Message Queuing exceptions. - } - // Handle invalid serialization format. - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( e->Message ); - } - - // Catch other exceptions as necessary. - return; - } -}; - -//************************************************* -// Provides an entry point into the application. -// -// This example sends and receives a message from -// a queue. -//************************************************* -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send a message to a queue. - myNewQueue->SendMessage(); - - // Receive a message from a queue. - myNewQueue->ReceiveMessage(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_timeout/CPP/mqreceive_timeout.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_timeout/CPP/mqreceive_timeout.cpp deleted file mode 100644 index eedcb10741066..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_timeout/CPP/mqreceive_timeout.cpp +++ /dev/null @@ -1,85 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// This class represents an object the following example -// receives from a queue. -ref class Order -{ -public: - int orderId; - DateTime orderTime; -}; - - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ -public: - - //************************************************* - // Receives a message containing an Order. - //************************************************* - void ReceiveMessage() - { - // Connect to the a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Set the formatter to indicate body contains an Order. - array^p = gcnew array(1); - p[ 0 ] = Order::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - try - { - // Receive and format the message. - // Wait 5 seconds for a message to arrive. - Message^ myMessage = myQueue->Receive( TimeSpan(0,0,5) ); - Order^ myOrder = static_cast(myMessage->Body); - - // Display message information. - Console::WriteLine( "Order ID: {0}", myOrder->orderId ); - Console::WriteLine( "Sent: {0}", myOrder->orderTime ); - } - catch ( MessageQueueException^ e ) - { - // Handle no message arriving in the queue. - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::IOTimeout ) - { - Console::WriteLine( "No message arrived in queue." ); - } - - // Handle other sources of a MessageQueueException. - } - // Handle invalid serialization format. - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( e->Message ); - } - - // Catch other exceptions as necessary. - return; - } -}; - -//************************************************* -// Provides an entry point into the application. -// -// This example receives a message from a queue. -//************************************************* -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Receive a message from a queue. - myNewQueue->ReceiveMessage(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_transaction/CPP/mqreceive_transaction.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_transaction/CPP/mqreceive_transaction.cpp deleted file mode 100644 index 885fce58c6cdf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Receive_transaction/CPP/mqreceive_transaction.cpp +++ /dev/null @@ -1,113 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ -public: - - //************************************************* - // Sends a message to a queue. - //************************************************* - void SendMessageTransactional() - { - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" ); - - // Send a message to the queue. - if ( myQueue->Transactional == true ) - { - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - - // Begin the transaction. - myTransaction->Begin(); - - // Send the message. - myQueue->Send( "My Message Data.", myTransaction ); - - // Commit the transaction. - myTransaction->Commit(); - } - - return; - } - - - //************************************************* - // Receives a message containing an Order. - //************************************************* - void ReceiveMessageTransactional() - { - // Connect to a transactional queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" ); - - // Set the formatter. - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - try - { - // Begin the transaction. - myTransaction->Begin(); - - // Receive the message. - Message^ myMessage = myQueue->Receive( myTransaction ); - String^ myOrder = static_cast(myMessage->Body); - - // Display message information. - Console::WriteLine( myOrder ); - - // Commit the transaction. - myTransaction->Commit(); - } - catch ( MessageQueueException^ e ) - { - // Handle nontransactional queues. - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::TransactionUsage ) - { - Console::WriteLine( "Queue is not transactional." ); - } - - // Else catch other sources of a MessageQueueException. - // Roll back the transaction. - myTransaction->Abort(); - } - - // Catch other exceptions as necessary, such as - // InvalidOperationException, thrown when the formatter - // cannot deserialize the message. - return; - } -}; - -//************************************************* -// Provides an entry point into the application. -// -// This example sends and receives a message from -// a transactional queue. -//************************************************* -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send a message to a queue. - myNewQueue->SendMessageTransactional(); - - // Receive a message from a queue. - myNewQueue->ReceiveMessageTransactional(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Send_ObjectTransaction/CPP/mqsend_objtransaction.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Send_ObjectTransaction/CPP/mqsend_objtransaction.cpp deleted file mode 100644 index 79d277ad91ea3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Send_ObjectTransaction/CPP/mqsend_objtransaction.cpp +++ /dev/null @@ -1,113 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ -public: - - //************************************************* - // Sends a message to a queue. - //************************************************* - void SendMessageTransactional() - { - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" ); - - // Send a message to the queue. - if ( myQueue->Transactional == true ) - { - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - - // Begin the transaction. - myTransaction->Begin(); - - // Send the message. - myQueue->Send( "My Message Data.", myTransaction ); - - // Commit the transaction. - myTransaction->Commit(); - } - - return; - } - - - //************************************************* - // Receives a message containing an Order. - //************************************************* - void ReceiveMessageTransactional() - { - // Connect to a transactional queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" ); - - // Set the formatter. - array^p = gcnew array(1); - p[ 0 ] = String::typeid; - myQueue->Formatter = gcnew XmlMessageFormatter( p ); - - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - try - { - // Begin the transaction. - myTransaction->Begin(); - - // Receive the message. - Message^ myMessage = myQueue->Receive( myTransaction ); - String^ myOrder = static_cast(myMessage->Body); - - // Display message information. - Console::WriteLine( myOrder ); - - // Commit the transaction. - myTransaction->Commit(); - } - catch ( MessageQueueException^ e ) - { - // Handle nontransactional queues. - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::TransactionUsage ) - { - Console::WriteLine( "Queue is not transactional." ); - } - - // Else catch other sources of MessageQueueException. - // Roll back the transaction. - myTransaction->Abort(); - } - - // Catch other exceptions as necessary, such as - // InvalidOperationException, thrown when the formatter - // cannot deserialize the message. - return; - } -}; - -//************************************************* -// Provides an entry point into the application. -// -// This example sends and receives a message from -// a transactional queue. -//************************************************* -int main() -{ - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send a message to a queue. - myNewQueue->SendMessageTransactional(); - - // Receive a message from a queue. - myNewQueue->ReceiveMessageTransactional(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Send_obj/CPP/mqsend_generic.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Send_obj/CPP/mqsend_generic.cpp deleted file mode 100644 index 512936db003c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.Send_obj/CPP/mqsend_generic.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - void SendMessage() - { - - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Send a message to the queue. - if ( myQueue->Transactional == true ) - { - - // Create a transaction. - MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction; - - // Begin the transaction. - myTransaction->Begin(); - - // Send the message. - myQueue->Send( "My Message Data.", myTransaction ); - - // Commit the transaction. - myTransaction->Commit(); - } - else - { - myQueue->Send( "My Message Data." ); - } - - return; - } - -}; - -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Send a message to a queue. - myNewQueue->SendMessage(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ctor_PathSharedModeDenyReceive/CPP/mqctor_denysharedreceive.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ctor_PathSharedModeDenyReceive/CPP/mqctor_denysharedreceive.cpp deleted file mode 100644 index c09921d9b5bf6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue.ctor_PathSharedModeDenyReceive/CPP/mqctor_denysharedreceive.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Messaging; -ref class MyNewQueue -{ -public: - - // Requests exlusive read access to the queue. If - // access is granted, receives a message from the - // queue. - void GetExclusiveAccess() - { - try - { - - // Request exclusive read access to the queue. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue",true ); - - // Receive a message. This is where SharingViolation - // exceptions would be thrown. - Message^ myMessage = myQueue->Receive(); - } - catch ( MessageQueueException^ e ) - { - - // Handle request for denial of exclusive read access. - if ( e->MessageQueueErrorCode == MessageQueueErrorCode::SharingViolation ) - { - Console::WriteLine( "Denied exclusive read access" ); - } - - - // Handle other sources of a MessageQueueException. - } - - - // Handle other exceptions as necessary. - return; - } - -}; - - -// Provides an entry point into the application. -// This example connects to a message queue, and -// requests exclusive read access to the queue. -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Output the count of Lowest priority messages. - myNewQueue->GetExclusiveAccess(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue2/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue2/cpp/class1.cpp deleted file mode 100644 index 5293d6d567ac5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue2/cpp/class1.cpp +++ /dev/null @@ -1,1101 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Creates a new queue. -static void CreateQueue(String^ queuePath, bool transactional) -{ - if (!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -void SendObjectString() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label"); - - queue->Close(); - - // -} - -void SendObjectTransactionType() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, MessageQueueTransactionType::Single); - - queue->Close(); - - // -} - -void SendObjectStringTransactionType() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label", - MessageQueueTransactionType::Single); - - queue->Close(); - - // -} - -void SendObjectStringTransaction() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Create a message queuing transaction. - MessageQueueTransaction^ transaction = gcnew MessageQueueTransaction(); - - try - { - // Begin a transaction. - transaction->Begin(); - - // Send the message to the queue. - queue->Send(msg, "Example Message Label", transaction); - - // Commit the transaction. - transaction->Commit(); - } - catch (Exception^ ex) - { - // Cancel the transaction. - transaction->Abort(); - - // Propagate the exception. - throw ex; - } - finally - { - // Dispose of the transaction object. - delete transaction; - queue->Close(); - } - - // -} - -void PeekByCorrelationIdStringTimespan() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Designate a queue to receive the acknowledgement message for this - // message. - msg->AdministrationQueue = - gcnew MessageQueue(".\\exampleAdminQueue"); - - // Set the message to generate an acknowledgement message upon its - // arrival. - msg->AcknowledgeType = AcknowledgeTypes::PositiveArrival; - - // Send the message. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0)); - - // Connect to the admin queue. - MessageQueue^ adminQueue = - gcnew MessageQueue(".\\exampleAdminQueue"); - - // Set the admin queue's MessageReadPropertyFilter property to ensure - // that the acknowledgement message includes the desired properties. - adminQueue->MessageReadPropertyFilter->Acknowledgment = true; - adminQueue->MessageReadPropertyFilter->CorrelationId = true; - - // Peek at the acknowledgement message. - Message^ ackMsg = adminQueue->PeekByCorrelationId(id, - TimeSpan::FromSeconds(10.0)); - - // Display the acknowledgement message's property values. - Console::WriteLine("Message.Label: {0}", ackMsg->Label); - Console::WriteLine("Message.Acknowledgment: {0}", - ackMsg->Acknowledgment); - Console::WriteLine("Message.CorrelationId: {0}", ackMsg->CorrelationId); - - adminQueue->Close(); - queue->Close(); - - // -} - -void PeekByIdString() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Simulate doing other work so the message has time to arrive. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - // Peek at the message. - msg = queue->PeekById(id); - - queue->Close(); - - // -} - -void PeekByIdStringTimespan() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Peek at the message. - msg = queue->PeekById(id, TimeSpan::FromSeconds(10.0)); - - queue->Close(); - - // -} - -void ReceiveTimespanTransactionType() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, MessageQueueTransactionType::Single); - - // Set the formatter to indicate the message body contains a String. - queue->Formatter = gcnew XmlMessageFormatter( - gcnew array{String::typeid}); - - // Receive the message from the queue. Because the Id of the message - // is not specified, it might not be the message just sent. - msg = queue->Receive(TimeSpan::FromSeconds(10.0), - MessageQueueTransactionType::Single); - - queue->Close(); - - // -} - -void ReceiveTransactionType() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, MessageQueueTransactionType::Single); - - // Simulate doing other work so the message has time to arrive. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - // Set the formatter to indicate the message body contains a String. - queue->Formatter = gcnew XmlMessageFormatter( - gcnew array{String::typeid}); - - // Receive the message from the queue. Because the Id of the message - // , it might not be the message just sent. - msg = queue->Receive(MessageQueueTransactionType::Single); - - queue->Close(); - - // -} - -void ReceiveByCorrelationIdStringTimespan() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Designate a queue to receive the acknowledgement message for this - // message. - msg->AdministrationQueue = - gcnew MessageQueue(".\\exampleAdminQueue"); - - // Set the message to generate an acknowledgement message upon its - // arrival. - msg->AcknowledgeType = AcknowledgeTypes::PositiveArrival; - - // Send the message. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0)); - - // Connect to the admin queue. - MessageQueue^ adminQueue = - gcnew MessageQueue(".\\exampleAdminQueue"); - - // Set the admin queue's MessageReadPropertyFilter property to ensure - // that the acknowledgement message includes the desired properties. - adminQueue->MessageReadPropertyFilter->Acknowledgment = true; - adminQueue->MessageReadPropertyFilter->CorrelationId = true; - - // Receive the acknowledgement message from the admin queue. - Message^ ackMsg = adminQueue->ReceiveByCorrelationId(id, - TimeSpan::FromSeconds(10.0)); - - // Display the acknowledgement message's property values. - Console::WriteLine("Message.Label: {0}", ackMsg->Label); - Console::WriteLine("Message.Acknowledgment: {0}", - ackMsg->Acknowledgment); - Console::WriteLine("Message.CorrelationId: {0}", ackMsg->CorrelationId); - - adminQueue->Close(); - queue->Close(); - - // -} - -void ReceiveByCorrelationIdStringTransactionType() -{ - // - - // Connect to a nontransactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message to the nontransactional queue. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the nontransactional queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0)); - - // Connect to a transactional queue on the local computer. - MessageQueue^ transQueue = - gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message in response to the original message. - Message^ responseMsg = gcnew Message("Example Response Message Body"); - - // Set the response message's CorrelationId property value to the Id - // property value of the original message. - responseMsg->CorrelationId = id; - - // Send the response message to the transactional queue. - transQueue->Send(responseMsg, "Example Response Message Label", - MessageQueueTransactionType::Single); - - // Simulate doing other work so the message has time to arrive. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - // Set the transactional queue's MessageReadPropertyFilter property to - // ensure that the response message includes the desired properties. - transQueue->MessageReadPropertyFilter->CorrelationId = true; - - // Receive the response message from the transactional queue. - responseMsg = transQueue->ReceiveByCorrelationId(id, - MessageQueueTransactionType::Single); - - // Display the response message's property values. - Console::WriteLine("Message.Label: {0}", responseMsg->Label); - Console::WriteLine("Message.CorrelationId: {0}", - responseMsg->CorrelationId); - - transQueue->Close(); - queue->Close(); - - // -} - -void ReceiveByCorrelationIdStringTimespanTransactionType() -{ - // - - // Connect to a nontransactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message to the nontransactional queue. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the nontransactional queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0)); - - // Connect to a transactional queue on the local computer. - MessageQueue^ transQueue = - gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message in response to the original message. - Message^ responseMsg = gcnew Message("Example Response Message Body"); - - // Set the response message's CorrelationId property value to the Id - // property value of the original message. - responseMsg->CorrelationId = id; - - // Send the response message to the transactional queue. - transQueue->Send(responseMsg, "Example Response Message Label", - MessageQueueTransactionType::Single); - - // Set the transactional queue's MessageReadPropertyFilter property to - // ensure that the response message includes the desired properties. - transQueue->MessageReadPropertyFilter->CorrelationId = true; - - // Receive the response message from the transactional queue. - responseMsg = transQueue->ReceiveByCorrelationId(id, - TimeSpan::FromSeconds(10.0), MessageQueueTransactionType::Single); - - // Display the response message's property values. - Console::WriteLine("Message.Label: {0}", responseMsg->Label); - Console::WriteLine("Message.CorrelationId: {0}", - responseMsg->CorrelationId); - - transQueue->Close(); - queue->Close(); - - // -} - -void ReceiveByCorrelationIdStringTimespanTransaction() -{ - // - - // Connect to a nontransactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message to the nontransactional queue. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the nontransactional queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0)); - - // Connect to a transactional queue on the local computer. - MessageQueue^ transQueue = - gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message in response to the original message. - Message^ responseMsg = gcnew Message("Example Response Message Body"); - - // Set the response message's CorrelationId property value to the Id - // property value of the original message. - responseMsg->CorrelationId = id; - - // Send the response message to the transactional queue. - transQueue->Send(responseMsg, "Example Response Message Label", - MessageQueueTransactionType::Single); - - // Set the transactional queue's MessageReadPropertyFilter property to - // ensure that the response message includes the desired properties. - transQueue->MessageReadPropertyFilter->CorrelationId = true; - - // Create a message queuing transaction. - MessageQueueTransaction^ transaction = gcnew MessageQueueTransaction(); - - try - { - // Begin a transaction. - transaction->Begin(); - - // Receive the response message from the transactional queue. - responseMsg = transQueue->ReceiveByCorrelationId(id, - TimeSpan::FromSeconds(10.0), transaction); - - // Commit the transaction. - transaction->Commit(); - } - catch (Exception^ ex) - { - // Cancel the transaction. - transaction->Abort(); - - // Propagate the exception. - throw ex; - } - finally - { - // Dispose of the transaction object. - delete transaction; - transQueue->Close(); - queue->Close(); - } - - // Display the response message's property values. - Console::WriteLine("Message.Label: {0}", responseMsg->Label); - Console::WriteLine("Message.CorrelationId: {0}", - responseMsg->CorrelationId); - - // -} - -void ReceiveByCorrelationIdStringTransaction() -{ - // - - // Connect to a nontransactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message to the nontransactional queue. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the nontransactional queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0)); - - // Connect to a transactional queue on the local computer. - MessageQueue^ transQueue = - gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message in response to the original message. - Message^ responseMsg = gcnew Message("Example Response Message Body"); - - // Set the response message's CorrelationId property value to the Id - // property value of the original message. - responseMsg->CorrelationId = id; - - // Send the response message to the transactional queue. - transQueue->Send(responseMsg, "Example Response Message Label", - MessageQueueTransactionType::Single); - - // Simulate doing other work so the message has time to arrive. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - // Set the transactional queue's MessageReadPropertyFilter property to - // ensure that the response message includes the desired properties. - transQueue->MessageReadPropertyFilter->CorrelationId = true; - - // Create a message queuing transaction. - MessageQueueTransaction^ transaction = gcnew MessageQueueTransaction(); - - try - { - // Begin a transaction. - transaction->Begin(); - - // Receive the response message from the transactional queue. - responseMsg = transQueue->ReceiveByCorrelationId(id, transaction); - - // Commit the transaction. - transaction->Commit(); - } - catch (Exception^ ex) - { - // Cancel the transaction. - transaction->Abort(); - - // Propagate the exception. - throw ex; - } - finally - { - // Dispose of the transaction object. - delete transaction; - transQueue->Close(); - queue->Close(); - } - - // Display the response message's property values. - Console::WriteLine("Message.Label: {0}", responseMsg->Label); - Console::WriteLine("Message.CorrelationId: {0}", - responseMsg->CorrelationId); - - // -} - -void ReceiveByIdStringTransactionType() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label", - MessageQueueTransactionType::Single); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Simulate doing other work so the message has time to arrive. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - // Receive the message from the queue. - msg = queue->ReceiveById(id, MessageQueueTransactionType::Single); - - queue->Close(); - - // -} - -void ReceiveByIdString() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Simulate doing other work so the message has time to arrive. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - // Receive the message from the queue. - msg = queue->ReceiveById(id); - - queue->Close(); - - // -} - -void ReceiveByIdStringTransaction() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label", - MessageQueueTransactionType::Single); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Simulate doing other work so the message has time to arrive. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - // Create a message queuing transaction. - MessageQueueTransaction^ transaction = gcnew MessageQueueTransaction(); - - try - { - // Begin a transaction. - transaction->Begin(); - - // Receive the message from the queue. - msg = queue->ReceiveById(id, transaction); - - // Commit the transaction. - transaction->Commit(); - } - catch (Exception^ ex) - { - // Cancel the transaction. - transaction->Abort(); - - // Propagate the exception. - throw ex; - } - finally - { - // Dispose of the transaction object. - delete transaction; - queue->Close(); - } - - // -} - -void ReceiveByIdStringTimespanTransaction() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label", - MessageQueueTransactionType::Single); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Create a message queuing transaction. - MessageQueueTransaction^ transaction = gcnew MessageQueueTransaction(); - - try - { - // Begin a transaction. - transaction->Begin(); - - // Receive the message from the queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0), - transaction); - - // Commit the transaction. - transaction->Commit(); - } - catch (Exception^ ex) - { - // Cancel the transaction. - transaction->Abort(); - - // Propagate the exception. - throw ex; - } - finally - { - // Dispose of the transaction object. - delete transaction; - queue->Close(); - } - - // -} - -void ReceiveByIdStringTimespanTransactionType() -{ - // - - // Connect to a transactional queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleTransQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label", - MessageQueueTransactionType::Single); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0), - MessageQueueTransactionType::Single); - - queue->Close(); - - // -} - -void ReceiveByIdStringTimespan() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new message. - Message^ msg = gcnew Message("Example Message Body"); - - // Send the message. - queue->Send(msg, "Example Message Label"); - - // Get the message's Id property value. - String^ id = msg->Id; - - // Receive the message from the queue. - msg = queue->ReceiveById(id, TimeSpan::FromSeconds(10.0)); - - queue->Close(); - - // -} - -void GetAllMessages() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Populate an array with copies of all the messages in the queue. - array^ msgs = queue->GetAllMessages(); - - // Loop through the messages. - for each(Message^ msg in msgs) - { - // Display the label of each message. - Console::WriteLine(msg->Label); - } - - queue->Close(); - - // -} - -void GetEnumerator() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Get an IEnumerator object. - System::Collections::IEnumerator^ enumerator = - queue->GetMessageEnumerator2(); - - // Use the IEnumerator object to loop through the messages. - while(enumerator->MoveNext()) - { - // Get a message from the enumerator. - Message^ msg = (Message^)enumerator->Current; - - // Display the label of the message. - Console::WriteLine(msg->Label); - } - - queue->Close(); - - // -} - -void SetPermissionsStringAccessRights() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Grant all users in the "Everyone" user group the right to receive - // messages from the queue. - queue->SetPermissions("Everyone", - MessageQueueAccessRights::ReceiveMessage); - - queue->Close(); - - // -} - -void SetPermissionsAccessControlEntry() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new trustee to represent the "Everyone" user group. - Trustee^ tr = gcnew Trustee("Everyone"); - - // Create a MessageQueueAccessControlEntry, granting the trustee the - // right to receive messages from the queue. - MessageQueueAccessControlEntry^ entry = gcnew - MessageQueueAccessControlEntry( - tr, MessageQueueAccessRights::ReceiveMessage, - AccessControlEntryType::Allow); - - // Apply the MessageQueueAccessControlEntry to the queue. - queue->SetPermissions(entry); - - queue->Close(); - - // -} - -void SetPermissionsStringAccessRightsAccessControlEntryType() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Grant all users in the "Everyone" user group the right to receive - // messages from the queue. - queue->SetPermissions("Everyone", - MessageQueueAccessRights::ReceiveMessage, - AccessControlEntryType::Allow); - - queue->Close(); - - // -} - -void SetPermissionsAccessControlList() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create an AccessControlList. - AccessControlList^ list = gcnew AccessControlList(); - - // Create a new trustee to represent the "Everyone" user group. - Trustee^ tr = gcnew Trustee("Everyone"); - - // Create an AccessControlEntry, granting the trustee read access to - // the queue. - AccessControlEntry^ entry = gcnew AccessControlEntry( - tr, GenericAccessRights::Read, - StandardAccessRights::Read, - AccessControlEntryType::Allow); - - // Add the AccessControlEntry to the AccessControlList. - list->Add(entry); - - // Apply the AccessControlList to the queue. - queue->SetPermissions(list); - - queue->Close(); - - // -} - -void ResetPermissions() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Reset the queue's permission list to its default values. - queue->ResetPermissions(); - - queue->Close(); - - // -} - -void Refresh() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Refresh the queue's property values to obtain its current state. - queue->Refresh(); - - queue->Close(); - - // -} - -void Purge() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Delete all messages from the queue. - queue->Purge(); - - queue->Close(); - - // -} - -void main() -{ - try - { - // Create a nontransactional queue on the local computer. - // Note that the queue might not be immediately accessible, and - // therefore this example might throw an exception of type - // System.Messaging.MessageQueueException when trying to send a - // message to the newly created queue. - CreateQueue(".\\exampleQueue", false); - - // Create a nontransactional queue on the local computer. This - // queue will be used to receive acknowledgement messages. - CreateQueue(".\\exampleAdminQueue", false); - - // Create a transactional queue on the local computer. - CreateQueue(".\\exampleTransQueue", true); - - // Send a message to a queue. - SendObjectString(); - - // Send a message to a transactional queue. - SendObjectTransactionType(); - - // Send a message to a transactional queue. - SendObjectStringTransactionType(); - - // Send a message to a transactional queue. - SendObjectStringTransaction(); - - // Demonstrate PeekById. - PeekByIdString(); - - // Demonstrate PeekById. - PeekByIdStringTimespan(); - - // Demonstrate PeekByCorrelationId. - PeekByCorrelationIdStringTimespan(); - - // Receive a message from a transactional queue. - ReceiveTimespanTransactionType(); - - // Receive a message from a transactional queue. - ReceiveTransactionType(); - - // Demonstrate ReceiveByCorrelationId. - ReceiveByCorrelationIdStringTimespan(); - - // Demonstrate ReceiveByCorrelationId. - ReceiveByCorrelationIdStringTransactionType(); - - // Demonstrate ReceiveByCorrelationId. - ReceiveByCorrelationIdStringTimespanTransactionType(); - - // Demonstrate ReceiveByCorrelationId. - ReceiveByCorrelationIdStringTimespanTransaction(); - - // Demonstrate ReceiveByCorrelationId. - ReceiveByCorrelationIdStringTransaction(); - - // Demonstrate ReceiveById. - ReceiveByIdStringTransactionType(); - - // Demonstrate ReceiveById. - ReceiveByIdString(); - - // Demonstrate ReceiveById. - ReceiveByIdStringTransaction(); - - // Demonstrate ReceiveById. - ReceiveByIdStringTimespanTransaction(); - - // Demonstrate ReceiveById. - ReceiveByIdStringTimespanTransactionType(); - - // Demonstrate ReceiveById. - ReceiveByIdStringTimespan(); - - // Demonstrate GetAllMessages. - GetAllMessages(); - - // Demonstrate GetEnumerator. - GetEnumerator(); - - // Demonstrate SetPermissions. - SetPermissionsStringAccessRights(); - - // Demonstrate SetPermissions. - SetPermissionsAccessControlEntry(); - - // Demonstrate SetPermissions. - SetPermissionsStringAccessRightsAccessControlEntryType(); - - // Demonstrate SetPermissions. - SetPermissionsAccessControlList(); - - // Demonstrate ResetPermissions. - ResetPermissions(); - - // Demonstrate Refresh. - Refresh(); - - // Demonstrate Purge. - Purge(); - } - catch (InvalidOperationException^) - { - Console::WriteLine("Please install Message Queuing."); - } - catch (MessageQueueException^ ex) - { - // Write the exception information to the console. - Console::WriteLine(ex->Message); - } -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue2/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue2/cpp/makefile deleted file mode 100644 index 03224e4c8d8d6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue2/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueue2.exe : class1.cpp - cl /W4 /clr:pure /FeMessageQueue2.exe class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue4/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue4/cpp/class1.cpp deleted file mode 100644 index 27cc2fcd0f3c8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue4/cpp/class1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// - -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Create a new queue. -static void CreateQueue(String^ queuePath, bool transactional) -{ - if (!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -static void UseQueue() -{ - // - // Connect to a queue on the local computer, grant exclusive read - // access to the first application that accesses the queue, and - // enable connection caching. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue", true, true); - - queue->Close(); - // -} - -int main() -{ - // Create a nontransactional queue on the local computer. - CreateQueue(".\\exampleQueue", false); - - UseQueue(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue4/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue4/cpp/makefile deleted file mode 100644 index 638386ac1e59c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueue4/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueue4.exe : class1.cpp - cl /W4 /clr:pure /FeMessageQueue4.exe class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginPeek/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginPeek/cpp/class1.cpp deleted file mode 100644 index bd142a855da0a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginPeek/cpp/class1.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Creates a new queue. -void CreateQueue(String^ queuePath, bool transactional) -{ - if(!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -// Provides an event handler for the PeekCompleted event. -void MyPeekCompleted(IAsyncResult^ asyncResult) -{ - // Connect to the queue. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // End the asynchronous peek operation. - Message^ msg = queue->EndPeek(asyncResult); - - // Display the message information on the screen. - Console::WriteLine("Message number: {0}", asyncResult->AsyncState); - Console::WriteLine("Message body: {0}", msg->Body); - - // Receive the message. This will remove the message from the queue. - msg = queue->Receive(TimeSpan::FromSeconds(10.0)); - - queue->Close(); -} - -int main() -{ - // Represents a state object associated with each message. - int messageNumber = 0; - - // Create a non-transactional queue on the local computer. - // Note that the queue might not be immediately accessible, and - // therefore this example might throw an exception of type - // System.Messaging.MessageQueueException when trying to send a - // message to the newly created queue. - CreateQueue(".\\exampleQueue", false); - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Send a message to the queue. - queue->Send("Example Message"); - - // Begin the asynchronous peek operation. - queue->BeginPeek(TimeSpan::FromSeconds(10.0), messageNumber++, - gcnew AsyncCallback(MyPeekCompleted)); - - // Simulate doing other work on the current thread. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - - queue->Close(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginPeek/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginPeek/cpp/makefile deleted file mode 100644 index 176fc9b351425..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginPeek/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueueBeginPeek.exe: class1.cpp - cl /clr:pure /FeMessageQueueBeginPeek.exe class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive1/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive1/cpp/class1.cpp deleted file mode 100644 index f55dd96f51c9f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive1/cpp/class1.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Creates a new queue. -void CreateQueue(String^ queuePath, bool transactional) -{ - if(!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -// Provides an event handler for the ReceiveCompleted event. -void HandleReceiveCompleted(Object^ source, ReceiveCompletedEventArgs^ e) -{ - // Connect to the queue. - MessageQueue^ queue = (MessageQueue^)source; - - // End the asynchronous receive operation. - Message^ msg = queue->EndReceive(e->AsyncResult); - - // Display the message information on the screen. - Console::WriteLine("Message body: {0}", msg->Body); - - queue->Close(); -} - -int main() -{ - // Create a non-transactional queue on the local computer. - // Note that the queue might not be immediately accessible, and - // therefore this example might throw an exception of type - // System.Messaging.MessageQueueException when trying to send a - // message to the newly created queue. - MessageQueue^ queue = nullptr; - try - { - CreateQueue(".\\exampleQueue", false); - - // Connect to a queue on the local computer. - queue = gcnew MessageQueue(".\\exampleQueue"); - - // Add an event handler for the ReceiveCompleted event. - queue->ReceiveCompleted += gcnew - ReceiveCompletedEventHandler(HandleReceiveCompleted); - - // Send a message to the queue. - queue->Send("Example Message"); - - // Begin the asynchronous receive operation. - queue->BeginReceive(TimeSpan::FromSeconds(10.0)); - - // Simulate doing other work on the current thread. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - } - - catch (InvalidOperationException^) - { - Console::WriteLine("Please install Message Queuing."); - } - - catch (MessageQueueException^ ex) - { - Console::WriteLine(ex->Message); - } - - finally - { - queue->Close(); - } - -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive1/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive1/cpp/makefile deleted file mode 100644 index e0058c351763e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive1/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueueBeginReceive1.exe: class1.cpp - cl /clr:pure /FeMessageQueueBeginReceive1.exe class1.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive2/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive2/cpp/class1.cpp deleted file mode 100644 index b75428d1df71c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive2/cpp/class1.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Creates a new queue. -void CreateQueue(String^ queuePath, bool transactional) -{ - if(!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -// Provides an event handler for the ReceiveCompleted event. -void HandleReceiveCompleted(Object^ source, ReceiveCompletedEventArgs^ e) -{ - // Connect to the queue. - MessageQueue^ queue = (MessageQueue^)source; - - // End the asynchronous receive operation. - Message^ msg = queue->EndReceive(e->AsyncResult); - - // Display the message information on the screen. - Console::WriteLine("Message number: {0}", e->AsyncResult->AsyncState); - Console::WriteLine("Message body: {0}", msg->Body); - - queue->Close(); -} - -int main() -{ - // Create a non-transactional queue on the local computer. - // Note that the queue might not be immediately accessible, and - // therefore this example might throw an exception of type - // System.Messaging.MessageQueueException when trying to send a - // message to the newly created queue. - MessageQueue^ queue = nullptr; - - // Represents a state object associated with each message. - int messageNumber = 0; - - try - { - CreateQueue(".\\exampleQueue", false); - - // Connect to a queue on the local computer. - queue = gcnew MessageQueue(".\\exampleQueue"); - - // Add an event handler for the ReceiveCompleted event. - queue->ReceiveCompleted += gcnew - ReceiveCompletedEventHandler(HandleReceiveCompleted); - - // Send a message to the queue. - queue->Send("Example Message"); - - // Begin the asynchronous receive operation. - queue->BeginReceive(TimeSpan::FromSeconds(10.0), messageNumber++); - - // Simulate doing other work on the current thread. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - } - catch (InvalidOperationException^) - { - Console::WriteLine("Please install Message Queuing."); - } - - catch (MessageQueueException^ ex) - { - Console::WriteLine(ex->Message); - } - - finally - { - queue->Close(); - } -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive2/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive2/cpp/makefile deleted file mode 100644 index 9f2a5f5a0720d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive2/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueueBeginReceive2.exe: class1.cpp - cl /clr:pure /FeMessageQueueBeginReceive2.exe class1.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive3/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive3/cpp/class1.cpp deleted file mode 100644 index a60adfa80c763..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive3/cpp/class1.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Creates a new queue. -void CreateQueue(String^ queuePath, bool transactional) -{ - if (!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -// Provides an event handler for the ReceiveCompleted event. -void HandleReceiveCompleted(IAsyncResult^ asyncResult) -{ - // Connect to the queue. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // End the asynchronous receive operation. - Message^ msg = queue->EndReceive(asyncResult); - - // Display the message information on the screen. - Console::WriteLine("Message number: {0}", asyncResult->AsyncState); - Console::WriteLine("Message body: {0}", msg->Body); - - queue->Close(); -} - -int main() -{ - // Represents a state object associated with each message. - int messageNumber = 0; - - // Create a non-transactional queue on the local computer. - // Note that the queue might not be immediately accessible, and - // therefore this example might throw an exception of type - // System.Messaging.MessageQueueException when trying to send a - // message to the newly created queue. - MessageQueue^ queue = nullptr; - try - { - CreateQueue(".\\exampleQueue", false); - - // Connect to a queue on the local computer. - queue = gcnew MessageQueue(".\\exampleQueue"); - - // Send a message to the queue. - queue->Send("Example Message"); - - // Begin the asynchronous receive operation. - queue->BeginReceive(TimeSpan::FromSeconds(10.0), messageNumber++, - gcnew AsyncCallback(HandleReceiveCompleted)); - - // Simulate doing other work on the current thread. - System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0)); - } - catch (InvalidOperationException^) - { - Console::WriteLine("Please install Message Queuing."); - } - - catch (MessageQueueException^ ex) - { - Console::WriteLine(ex->Message); - } - - finally - { - queue->Close(); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive3/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive3/cpp/makefile deleted file mode 100644 index 9efb68a4d4ef9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueueBeginReceive3/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueueBeginReceive3.exe: class1.cpp - cl /FeMessageQueueBeginReceive3.exe /clr:pure class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAccess/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAccess/cpp/class1.cpp deleted file mode 100644 index e77794103caff..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAccess/cpp/class1.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// - -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Creates a new queue. -void CreateQueue(String^ queuePath, bool transactional) -{ - if (!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.",queuePath); - } -} - -// Demonstrates the use of MessageQueuePermissionAccess -void CreatePermission() -{ - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission( - MessageQueuePermissionAccess::Receive, queue->MachineName, - queue->Label, queue->Category.ToString()); - - queue->Close(); - // -} - -int main() -{ - try - { - - // Create a non-transactional queue on the local computer. - CreateQueue(".\\exampleQueue", false); - - // Demonstrate use of MessageQueuePermissionAccess. - CreatePermission(); - } - - catch (InvalidOperationException^) - { - Console::WriteLine("Please install Message Queuing."); - } - - catch (MessageQueueException^ ex) - { - Console::WriteLine(ex->Message); - } -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAccess/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAccess/cpp/makefile deleted file mode 100644 index a5b8094e50aae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAccess/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueuePermissionAccess.exe : class1.cpp - cl /W4 /clr:pure /FeMessageQueuePermissionAccess.exe class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAttribute/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAttribute/cpp/class1.cpp deleted file mode 100644 index c5679d136b80c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAttribute/cpp/class1.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// - -#using -#using - -using namespace System; -using namespace System::Messaging; - -// Creates a new queue. -void CreateQueue(String^ queuePath, bool transactional) -{ - if (!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -// Demonstrates the following MessageQueuePermissionAttribute constructor: -// public #ctor (SecurityAction action) -void CreateAttribute() -{ - // - - // Create a new instance of MessageQueuePermissionAttribute. - MessageQueuePermissionAttribute^ attribute = - gcnew MessageQueuePermissionAttribute( - System::Security::Permissions::SecurityAction::Assert); - - // -} - - -void CategoryExample() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionAttribute. - MessageQueuePermissionAttribute^ attribute = - gcnew MessageQueuePermissionAttribute( - System::Security::Permissions::SecurityAction::Assert); - - // Set the attribute's Category property value, based on the queue's - // Category property value. - attribute->Category = queue->Category.ToString(); - - // Display the new value of the attribute's Category property. - Console::WriteLine("attribute->Category: {0}", - attribute->Category); - - queue->Close(); - // -} - -void LabelExample() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionAttribute. - MessageQueuePermissionAttribute^ attribute = - gcnew MessageQueuePermissionAttribute( - System::Security::Permissions::SecurityAction::Assert); - - // Set the attribute's Label property value, based on the queue's Label - // property value. - attribute->Label = queue->Label; - - // Display the new value of the attribute's Label property. - Console::WriteLine("attribute->Label: {0}", attribute->Label); - - queue->Close(); - // -} - - -void MachineNameExample() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionAttribute. - MessageQueuePermissionAttribute^ attribute = - gcnew MessageQueuePermissionAttribute( - System::Security::Permissions::SecurityAction::Assert); - - // Set the attribute's MachineName property value, based on the queue's - // MachineName property value. - attribute->MachineName = queue->MachineName; - - // Display the new value of the attribute's MachineName property. - Console::WriteLine("attribute->MachineName: {0}", - attribute->MachineName); - - queue->Close(); - // -} - -void PathExample() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionAttribute. - MessageQueuePermissionAttribute^ attribute = - gcnew MessageQueuePermissionAttribute( - System::Security::Permissions::SecurityAction::Assert); - - // Set the attribute's Path property value, based on the queue's Path - // property value. - attribute->Path = queue->Path; - - // Display the new value of the attribute's Path property. - Console::WriteLine("attribute->Path: {0}", attribute->Path); - - queue->Close(); - // -} - -void PermissionAccessExample() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionAttribute. - MessageQueuePermissionAttribute^ attribute = - gcnew MessageQueuePermissionAttribute( - System::Security::Permissions::SecurityAction::Assert); - - // Set the attribute's PermissionAccess property value. - attribute->PermissionAccess = MessageQueuePermissionAccess::Receive; - - // Display the new value of the attribute's PermissionAccess property. - Console::WriteLine("attribute->PermissionAccess: {0}", - attribute->PermissionAccess); - - queue->Close(); - // -} - -void CreatePermissionExample() -{ - // - - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionAttribute. - MessageQueuePermissionAttribute^ attribute = - gcnew MessageQueuePermissionAttribute( - System::Security::Permissions::SecurityAction::Assert); - - // Set the attribute's Path property value, based on the queue's Path - // property value. - attribute->Path = queue->Path; - - // Get an IPermission interface by calling the attribute's - // CreatePermission() method. - System::Security::IPermission^ permission = attribute->CreatePermission(); - - queue->Close(); - // -} - -int main() -{ - try - { - - // Create a non-transactional queue on the local computer. - CreateQueue(".\\exampleQueue", false); - - // Demonstrate the members of MessageQueuePermissionAttribute. - // Note that the Path, FormatName, MachineName, Label, and Category - // property values cannot all be set on the same instance of - // MessageQueuePermissionAttribute. Trying to do so will throw an - // exception of type System.InvalidOperationException. - - CreateAttribute(); - CategoryExample(); - LabelExample(); - MachineNameExample(); - PathExample(); - PermissionAccessExample(); - CreatePermissionExample(); - } - - catch (InvalidOperationException^) - { - Console::WriteLine("Please install Message Queuing."); - } - - catch (MessageQueueException^ ex) - { - Console::WriteLine(ex->Message); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAttribute/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAttribute/cpp/makefile deleted file mode 100644 index a39af17a883dc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionAttribute/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueuePermissionAttribute.exe : class1.cpp - cl /W4 /clr:pure /FeMessageQueuePermissionAttribute.exe class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntry/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntry/cpp/class1.cpp deleted file mode 100644 index 50c49a55ddcf0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntry/cpp/class1.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// - -#using -#using - -using namespace System; -using namespace System::Messaging; - -public ref class MessageQueuePermissionEntryExample -{ - // Creates a new queue. -public: - static void CreateQueue(String^ queuePath, bool transactional) - { - if(!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } - } - - // Demonstrates the following MessageQueuePermission constructor: - // public #ctor (MessageQueuePermissionAccess permissionAccess, - // String path) -public: - void CreateEntryShortCtor() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->Path); - - queue->Close(); - // - } - - // Demonstrates the following MessageQueuePermission constructor: - // public #ctor (MessageQueuePermissionAccess permissionAccess, - // String machineName, String label, String category) -public: - void CreateEntryLongCtor() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - queue->Close(); - // - } - -public: - void CategoryExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Display the value of the entry's Category property. - Console::WriteLine("Category: {0}", entry->Category->ToString()); - - queue->Close(); - // - } - -public: - void LabelExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Display the value of the entry's Label property. - Console::WriteLine("Label: {0}", entry->Label); - - queue->Close(); - // - } - -public: - void MachineNameExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Display the value of the entry's MachineName property. - Console::WriteLine("MachineName: {0}", entry->MachineName); - - queue->Close(); - // - } - -public: - void PathExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->Path); - - // Display the value of the entry's Path property. - Console::WriteLine("Path: {0}", entry->Path); - - queue->Close(); - // - } - -public: - void PermissionAccessExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Display the value of the entry's PermissionAccess property. - Console::WriteLine("PermissionAccess: {0}", entry->PermissionAccess); - - queue->Close(); - // - } -}; - -int main() -{ - // Create a new instance of the class. - MessageQueuePermissionEntryExample^ example = - gcnew MessageQueuePermissionEntryExample(); - - try - { - // Create a non-transactional queue on the local computer. - // Note that the queue might not be immediately accessible, and - // therefore this example might throw an exception of type - // System.Messaging.MessageQueueException when trying to send a - // message to the newly created queue. - example->CreateQueue(".\\exampleQueue", false); - - // Demonstrate MessageQueuePermissionEntry's constructors. - example->CreateEntryShortCtor(); - example->CreateEntryLongCtor(); - - // Demonstrate MessageQueuePermissionEntry's properties. - example->CategoryExample(); - example->LabelExample(); - example->MachineNameExample(); - example->PathExample(); - example->PermissionAccessExample(); - } - - catch (InvalidOperationException^) - { - Console::WriteLine("Please install Message Queuing."); - } - - catch (MessageQueueException^ ex) - { - // Write the exception information to the console. - Console::WriteLine(ex->Message); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntry/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntry/cpp/makefile deleted file mode 100644 index a8d395ad158ac..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntry/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueuePermissionEntry.exe: class1.cpp - cl /clr:pure /FeMessageQueuePermissionEntry.exe class1.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntryCollection/cpp/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntryCollection/cpp/class1.cpp deleted file mode 100644 index 01ab6fd2ada08..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntryCollection/cpp/class1.cpp +++ /dev/null @@ -1,408 +0,0 @@ -// - -#using -#using -using namespace System; -using namespace System::Messaging; - -public ref class MessageQueuePermissionEntryCollectionExample -{ - // Demonstrates: - // public Int32 Add (MessageQueuePermissionEntry value) -public: - void AddExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, queue->Category.ToString()); - - // Add the entry to the collection. - collection->Add(entry); - - queue->Close(); - // - } - - // Demonstrates: - // public Void AddRange (MessageQueuePermissionEntry[] value) -public: - void AddRangeExample1() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create an array of type MessageQueuePermissionEntry. - array^ entries = - gcnew array(1); - - // Create a new instance of MessageQueuePermissionEntry and place the - // instance in the array. - entries[0] = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Add the array to the collection. - collection->AddRange(entries); - - queue->Close(); - // - } - - // Demonstrates: - // public Void AddRange (MessageQueuePermissionEntryCollection value) -public: - void AddRangeExample2() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, queue->Category.ToString()); - - // Add the entry to the permission's collection. - permission->PermissionEntries->Add(entry); - - // Create another new instance of MessageQueuePermission. - MessageQueuePermission^ newPermission = gcnew MessageQueuePermission(); - - // Use AddRange() to append the original permission's collection to the - // new permission's collection. - newPermission->PermissionEntries->AddRange( - permission->PermissionEntries); - - // To show that AddRange() copies collections by value and not by - // reference, we'll clear the original permission's collection, then - // display a count of how many entries are in the original permission's - // collection and how many entries are in the new permission's - // collection. - - // Clear the original permission's collection. - permission->PermissionEntries->Clear(); - - // The original permission now contains 0 entries, but the new - // permission still contains 1 entry. - Console::WriteLine("Original permission contains {0} entries.", - permission->PermissionEntries->Count); - Console::WriteLine("New permission contains {0} entries.", - newPermission->PermissionEntries->Count); - - queue->Close(); - // - } - - // Demonstrates: - // public Boolean Contains (MessageQueuePermissionEntry value) -public: - void ContainsExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Add the entry to the collection. - collection->Add(entry); - - // Show that the collection contains the entry. - Console::WriteLine("Collection contains first entry (true/false): {0}", - collection->Contains(entry)); - - // Create another new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ newEntry = - gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Send, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Show that the collection does not contain the new entry. - Console::WriteLine( - "Collection contains second entry (true/false): {0}", - collection->Contains(newEntry)); - - queue->Close(); - // - } - - // Demonstrates: - // public Void CopyTo (MessageQueuePermissionEntry[] array, Int32 index) -public: - void CopyToExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Add the entry to the collection. - collection->Add(entry); - - // Create an array of type MessageQueuePermissionEntry. - array^ entries = - gcnew array(1); - - // Copy the collection to index 0 of the array. - collection->CopyTo(entries, 0); - - // Show that the array now contains the entry. - Console::WriteLine("entries[0].PermissionAccess: {0}", - entries[0]->PermissionAccess); - Console::WriteLine("entries[0].MachineName: {0}", - entries[0]->MachineName); - Console::WriteLine("entries[0].Label: {0}", entries[0]->Label); - Console::WriteLine("entries[0].Category: {0}", - entries[0]->Category); - - queue->Close(); - // - } - - // Demonstrates: - // public Int32 IndexOf (MessageQueuePermissionEntry value) -public: - void IndexOfExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Add the entry to the collection. - collection->Add(entry); - - // Display the index of the entry in the collection. - Console::WriteLine("Collection contains entry at index: {0}", - collection->IndexOf(entry)); - - queue->Close(); - // - } - - // Demonstrates: - // public Void Insert (Int32 index, MessageQueuePermissionEntry value) -public: - void InsertExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Add the entry to the collection. - collection->Add(entry); - - // Create another new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ newEntry = - gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Send, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Insert the new entry into the collection before the original entry. - collection->Insert(0, newEntry); - - queue->Close(); - // - } - - // Demonstrates: - // public MessageQueuePermissionEntry Item [Int32 index] { get; set; } -public: - void ItemExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Add the entry to the collection. - collection->Add(entry); - - // Display the entry's properties, using the collection's Item - // accessor. - Console::WriteLine("collection[0].PermissionAccess: {0}", - collection[0]->PermissionAccess); - Console::WriteLine("collection[0].MachineName: {0}", - collection[0]->MachineName); - Console::WriteLine("collection[0].Label: {0}", collection[0]->Label); - Console::WriteLine("collection[0].Category: {0}", - collection[0]->Category); - - queue->Close(); - // - } - - // Demonstrates: - // public Void Remove (MessageQueuePermissionEntry value) -public: - void RemoveExample() - { - // - // Connect to a queue on the local computer. - MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); - - // Create a new instance of MessageQueuePermission. - MessageQueuePermission^ permission = gcnew MessageQueuePermission(); - - // Get an instance of MessageQueuePermissionEntryCollection from the - // permission's PermissionEntries property. - MessageQueuePermissionEntryCollection^ collection = - permission->PermissionEntries; - - // Create a new instance of MessageQueuePermissionEntry. - MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( - MessageQueuePermissionAccess::Receive, - queue->MachineName, - queue->Label, - queue->Category.ToString()); - - // Add the entry to the collection. - collection->Add(entry); - - // Remove the entry from the collection. - collection->Remove(entry); - - queue->Close(); - // - } -}; - -// Creates a new queue. -void CreateQueue(String^ queuePath, bool transactional) -{ - if (!MessageQueue::Exists(queuePath)) - { - MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); - queue->Close(); - } - else - { - Console::WriteLine("{0} already exists.", queuePath); - } -} - -int main() -{ - // Create a new instance of the class. - MessageQueuePermissionEntryCollectionExample^ example = - gcnew MessageQueuePermissionEntryCollectionExample(); - - // Create a non-transactional queue on the local computer. - CreateQueue(".\\exampleQueue", false); - - // Demonstrate MessageQueuePermissionEntryCollection's members. - example->AddExample(); - example->AddRangeExample1(); - example->AddRangeExample2(); - example->ContainsExample(); - example->CopyToExample(); - example->IndexOfExample(); - example->InsertExample(); - example->ItemExample(); - example->RemoveExample(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntryCollection/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntryCollection/cpp/makefile deleted file mode 100644 index b28e01adfd640..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessageQueuePermissionEntryCollection/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -MessageQueuePermissionEntryCollection.exe : class1.cpp - cl /clr:pure /FeMessageQueuePermissionEntryCollection.exe class1.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Message_Samples3/CPP/message_samples3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Message_Samples3/CPP/message_samples3.cpp deleted file mode 100644 index ec5c5a7a24008..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Message_Samples3/CPP/message_samples3.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Web::Services::Description.Message::FindPartsByName -// System::Web::Services::Description.Message::ServiceDescription -// System::Web::Services::Description.Message::FindPartByName - -/* The following program demonstrates the property ' ServiceDescription' and -methods 'FindPartsByName', 'FindPartByName' of class 'Message'. The program -reads a wsdl document S"MathService::wsdl" and instantiates a -ServiceDescription instance from WSDL document. -The program invokes 'FindPartsByName' to obtain an array of MessageParts and also invokes -'FindPartByName' to retrieve a specific 'MessagePart'. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - try - { - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_cpp.wsdl" ); - - // - // Get message from ServiceDescription. - Message^ myMessage1 = myServiceDescription->Messages[ "AddHttpPostIn" ]; - Console::WriteLine( "ServiceDescription : {0}", myMessage1->ServiceDescription ); - - // - array^myParts = gcnew array(2); - myParts[ 0 ] = "a"; - myParts[ 1 ] = "b"; - array^myMessageParts = myMessage1->FindPartsByName( myParts ); - Console::WriteLine( "Results of FindPartsByName operation:" ); - for ( int i = 0; i < myMessageParts->Length; ++i ) - { - Console::WriteLine( "Part Name: {0}", myMessageParts[ i ]->Name ); - Console::WriteLine( "Part Type: {0}", myMessageParts[ i ]->Type ); - } - // - // - // Get another message from ServiceDescription. - Message^ myMessage2 = myServiceDescription->Messages[ "DivideHttpGetOut" ]; - MessagePart^ myMessagePart = myMessage2->FindPartByName( "Body" ); - Console::WriteLine( "Results of FindPartByName operation:" ); - Console::WriteLine( "Part Name: {0}", myMessagePart->Name ); - Console::WriteLine( "Part Element: {0}", myMessagePart->Element ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MessagingBinaryFormatter/CPP/message_binaryformatter.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MessagingBinaryFormatter/CPP/message_binaryformatter.cpp deleted file mode 100644 index e5e40864ae4e6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MessagingBinaryFormatter/CPP/message_binaryformatter.cpp +++ /dev/null @@ -1,141 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Messaging; -using namespace System::Drawing; -using namespace System::IO; - -/// -/// Provides a container class for the example. -/// -ref class MyNewQueue -{ -public: - - //************************************************* - // Creates a new queue. - //************************************************* - static void CreateQueue( String^ queuePath ) - { - try - { - if ( !MessageQueue::Exists( queuePath ) ) - { - MessageQueue::Create( queuePath ); - } - else - { - Console::WriteLine( "{0} already exists.", queuePath ); - } - } - catch ( MessageQueueException^ e ) - { - Console::WriteLine( e->Message ); - } - - } - - - //************************************************* - // Sends an image to a queue, using the BinaryMessageFormatter. - //************************************************* - void SendMessage() - { - try - { - - // Create a new bitmap. - // The file must be in the \bin\debug or \bin\retail folder, or - // you must give a full path to its location. - Image^ myImage = Bitmap::FromFile( "SentImage::bmp" ); - - // Connect to a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - Message^ myMessage = gcnew Message( myImage,gcnew BinaryMessageFormatter ); - - // Send the image to the queue. - myQueue->Send( myMessage ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - - return; - } - - - //************************************************* - // Receives a message containing an image. - //************************************************* - void ReceiveMessage() - { - try - { - - // Connect to the a queue on the local computer. - MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); - - // Set the formatter to indicate body contains an Order. - myQueue->Formatter = gcnew BinaryMessageFormatter; - - // Receive and format the message. - Message^ myMessage = myQueue->Receive(); - Bitmap^ myImage = static_cast(myMessage->Body); - - // This will be saved in the \bin\debug or \bin\retail folder. - myImage->Save( "ReceivedImage::bmp", System::Drawing::Imaging::ImageFormat::Bmp ); - } - catch ( MessageQueueException^ ) - { - - // Handle Message Queuing exceptions. - } - // Handle invalid serialization format. - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( e->Message ); - } - catch ( IOException^ e ) - { - - // Handle file access exceptions. - } - - - // Catch other exceptions as necessary. - return; - } - -}; - - -//************************************************* -// Provides an entry point into the application. -// -// This example sends and receives a message from -// a queue. -//************************************************* -int main() -{ - - // Create a new instance of the class. - MyNewQueue^ myNewQueue = gcnew MyNewQueue; - - // Create a queue on the local computer. - MyNewQueue::CreateQueue( ".\\myQueue" ); - - // Send a message to a queue. - myNewQueue->SendMessage(); - - // Receive a message from a queue. - myNewQueue->ReceiveMessage(); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertCodeSourceFileToAssemblyFile/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertCodeSourceFileToAssemblyFile/CPP/source.cpp deleted file mode 100644 index a60f0e1720b57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertCodeSourceFileToAssemblyFile/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting::MetadataServices; -int main() -{ - MetaData::ConvertCodeSourceFileToAssemblyFile( "CsSource.cs", "testAssm.dll", "" ); - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertTypesToSchemaToFile/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertTypesToSchemaToFile/CPP/source.cpp deleted file mode 100644 index c8665cf1b3c27..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertTypesToSchemaToFile/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting::Metadata; -using namespace System::Runtime::Remoting::MetadataServices; - -ref class TestClass -{ -private: - int integer; - -public: - static const double dFloatingPoint = 5.1999; - - property int Int - { - int get() - { - return integer; - } - void set( int value ) - { - integer = value; - } - } - void Print() - { - Console::WriteLine( "The double is equal to {0}.", dFloatingPoint ); - } -}; - -int main() -{ - array^types = gcnew array(4); - String^ s = "a"; - int i = -5; - double d = 3.1415; - TestClass^ tc = gcnew TestClass; - types[ 0 ] = s->GetType(); - types[ 1 ] = i.GetType(); - types[ 2 ] = d.GetType(); - types[ 3 ] = tc->GetType(); - MetaData::ConvertTypesToSchemaToFile( types, SdlType::Wsdl, "test.xml" ); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertTypesToSchemaToStream/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertTypesToSchemaToStream/CPP/source.cpp deleted file mode 100644 index 6fd71eb46d7b0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MetaData.ConvertTypesToSchemaToStream/CPP/source.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting::Metadata; -using namespace System::Runtime::Remoting::MetadataServices; -using namespace System::IO; - -ref class TestClass -{ -private: - int integer; - -public: - static const double dFloatingPoint = 5.1999; - - property int Int - { - int get() - { - return integer; - } - void set( int value ) - { - integer = value; - } - } - void Print() - { - Console::WriteLine( "The double is equal to {0}.", dFloatingPoint ); - } -}; - -int main() -{ - array^types = gcnew array(4); - String^ s = "a"; - int i = -5; - double d = 3.1415; - TestClass^ tc = gcnew TestClass; - types[ 0 ] = s->GetType(); - types[ 1 ] = i.GetType(); - types[ 2 ] = i.GetType(); - types[ 3 ] = tc->GetType(); - FileStream^ fs = gcnew FileStream( "test.xml",FileMode::OpenOrCreate ); - MetaData::ConvertTypesToSchemaToStream( types, SdlType::Wsdl, fs ); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeContentBinding_Part_4/CPP/mimecontentbinding_part_4.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimeContentBinding_Part_4/CPP/mimecontentbinding_part_4.cpp deleted file mode 100644 index 3eae8f13886ed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeContentBinding_Part_4/CPP/mimecontentbinding_part_4.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Web::Services::Description.MimeContentBinding::Type -// System::Web::Services::Description.MimeContentBinding::Part -// System::Web::Services::Description.MimeContentBinding::NameSpace -// System::Web::Services::Description.MimeContentBinding - -/* The following program demonstrates properties 'Type', 'Part' -and field 'NameSpace'of class 'MimeContentBinding'.It reads 'MimeContentSample_cs::wsdl'file -and instantiates a ServiceDescription Object*.'MimeContentBinding' objects are retrieved from Extension -points of OutputBinding for one of the Binding Object* and its properties 'Type', 'Part'are displayed.It also -displays 'NameSpace' of the 'MimeContentBinding' Object*. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; - -int main() -{ - // - // - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimeContentSample_cpp.wsdl" ); - - // Get the Binding. - Binding^ myBinding = myServiceDescription->Bindings[ "b1" ]; - - // Get the first OperationBinding. - OperationBinding^ myOperationBinding = myBinding->Operations[ 0 ]; - OutputBinding^ myOutputBinding = myOperationBinding->Output; - ServiceDescriptionFormatExtensionCollection ^ myServiceDescriptionFormatExtensionCollection = myOutputBinding->Extensions; - - // Find all MimeContentBinding objects in extensions. - array^myMimeContentBindings = (array^)myServiceDescriptionFormatExtensionCollection->FindAll( MimeContentBinding::typeid ); - - // Enumerate the array and display MimeContentBinding properties. - IEnumerator^ myEnum = myMimeContentBindings->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MimeContentBinding^ myMimeContentBinding = safe_cast(myEnum->Current); - Console::WriteLine( "Type: {0}", myMimeContentBinding->Type ); - Console::WriteLine( "Part: {0}", myMimeContentBinding->Part ); - } - // - // - Console::WriteLine( "Namespace: {0}", MimeContentBinding::Namespace ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeMultiPartRelatedBinding_Parts_2/CPP/MimeMultiPartRelatedSample_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/MimeMultiPartRelatedBinding_Parts_2/CPP/MimeMultiPartRelatedSample_cpp.wsdl deleted file mode 100644 index 4ad0d84133fb7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeMultiPartRelatedBinding_Parts_2/CPP/MimeMultiPartRelatedSample_cpp.wsdl +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeMultiPartRelatedBinding_Parts_2/CPP/mimemultipartrelatedbinding_parts_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimeMultiPartRelatedBinding_Parts_2/CPP/mimemultipartrelatedbinding_parts_2.cpp deleted file mode 100644 index f7387c482ad06..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeMultiPartRelatedBinding_Parts_2/CPP/mimemultipartrelatedbinding_parts_2.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// System::Web::Services::Description.MimeMultipartRelatedBinding -// System::Web::Services::Description.MimeMultipartRelatedBinding::Parts; - -/* The following program demonstrates the property 'Parts' of class 'MimeMultipartRelatedBinding'. -It reads 'MimeMultiPartRelatedSample_cpp.wsdl'file and instantiates a ServiceDescription Object*. -'MimeMultipartRelatedBinding' Object* is retrieved from Extension -points of OutputBinding for one of the Binding Object* and its property'Parts' has been demonstrated. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; - -int main() -{ - // - ServiceDescription^ myServicDescription = ServiceDescription::Read( "MimeMultiPartRelatedSample_cpp.wsdl" ); - - // Get the binding collection. - BindingCollection^ myBindingCollection = myServicDescription->Bindings; - int index = 0; - for ( int i = 0; i < myBindingCollection->Count; i++ ) - // Get the collection for MimeServiceHttpPost. - if ( String::Compare( myBindingCollection[ i ]->Name, "MimeServiceHttpPost" ) == 0 ) - { - OperationBindingCollection^ myOperationBindingCollection = myBindingCollection[ i ]->Operations; - OutputBinding^ myOutputBinding = myOperationBindingCollection[ 0 ]->Output; - ServiceDescriptionFormatExtensionCollection ^ myServiceDescriptionFormatExtensionCollection = myOutputBinding->Extensions; - MimeMultipartRelatedBinding^ myMimeMultipartRelatedBinding = dynamic_cast(myServiceDescriptionFormatExtensionCollection->Find( MimeMultipartRelatedBinding::typeid )); - MimePartCollection^ myMimePartCollection = myMimeMultipartRelatedBinding->Parts; - IEnumerator^ myEnum = myMimePartCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MimePart^ myMimePart = dynamic_cast(myEnum->Current); - Console::WriteLine( "Extension Types added to MimePart: {0}", index++ ); - Console::WriteLine( "----------------------------" ); - IEnumerator^ myEnum2 = myMimePart->Extensions->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - Console::WriteLine( myEnum2->Current->GetType() ); - } - - Console::WriteLine( "" ); - } - - break; - } - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_1/CPP/MimePartCollection_1_Input_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_1/CPP/MimePartCollection_1_Input_cpp.wsdl deleted file mode 100644 index 745bfd01aee48..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_1/CPP/MimePartCollection_1_Input_cpp.wsdl +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_1/CPP/mimepartcollection_1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_1/CPP/mimepartcollection_1.cpp deleted file mode 100644 index 5648074bf2a05..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_1/CPP/mimepartcollection_1.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// System::Web::Services::Description.MimePartCollection - -/* The following program demostrates 'MimePartCollection' class. It -takes 'MimePartCollection_1_Input_cpp.wsdl' as input which -contains one 'MimePart' Object* that supports 'HttpPost'. -A mimepartcollection Object* is created and mimepart is added to the -mimepartcollection at the specified location, finally writes -into the file'MimePartCollection_1_Output_cpp.wsdl'. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimePartCollection_1_Input_cpp.wsdl" ); - ServiceDescriptionCollection^ myServiceDescriptionCol = gcnew ServiceDescriptionCollection; - myServiceDescriptionCol->Add( myServiceDescription ); - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "MimeServiceHttpPost","http://tempuri.org/" ); - - // Create a 'Binding' object. - Binding^ myBinding = myServiceDescriptionCol->GetBinding( myXmlQualifiedName ); - OperationBinding^ myOperationBinding = nullptr; - for ( int i = 0; i < myBinding->Operations->Count; i++ ) - if ( myBinding->Operations[ i ]->Name->Equals( "AddNumbers" ) ) - myOperationBinding = myBinding->Operations[ i ]; - - OutputBinding^ myOutputBinding = myOperationBinding->Output; - MimeMultipartRelatedBinding^ myMimeMultipartRelatedBinding = nullptr; - IEnumerator^ myIEnumerator = myOutputBinding->Extensions->GetEnumerator(); - while ( myIEnumerator->MoveNext() ) - myMimeMultipartRelatedBinding = dynamic_cast(myIEnumerator->Current); - - // Create an instances of 'MimePartCollection'. - MimePartCollection^ myMimePartCollection = gcnew MimePartCollection; - myMimePartCollection = myMimeMultipartRelatedBinding->Parts; - Console::WriteLine( "Total number of mimepart elements initially is: {0}", myMimePartCollection->Count ); - - // Create an instance of 'MimePart'. - MimePart^ myMimePart = gcnew MimePart; - - // Create an instance of 'MimeXmlBinding'. - MimeXmlBinding^ myMimeXmlBinding = gcnew MimeXmlBinding; - myMimeXmlBinding->Part = "body"; - myMimePart->Extensions->Add( myMimeXmlBinding ); - - // Insert a mimepart at first position. - myMimePartCollection->Insert( 0, myMimePart ); - Console::WriteLine( "Inserting a mimepart object..." ); - if ( myMimePartCollection->Contains( myMimePart ) ) - { - Console::WriteLine( "'MimePart' is succesffully added at position: {0}", myMimePartCollection->IndexOf( myMimePart ) ); - Console::WriteLine( "Total number of mimepart elements after inserting is: {0}", myMimePartCollection->Count ); - } - - myServiceDescription->Write( "MimePartCollection_1_Output_cpp.wsdl" ); - Console::WriteLine( "MimePartCollection_1_Output_cpp.wsdl has been generated successfully." ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_8/CPP/mimepartcollection_8.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_8/CPP/mimepartcollection_8.cpp deleted file mode 100644 index e2a877fe7ae53..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimePartCollection_8/CPP/mimepartcollection_8.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// System::Web::Services::Description.MimePartCollection::MimePartCollection() -// System::Web::Services::Description.MimePartCollection::Item->Item[System::Int32 index] -// System::Web::Services::Description.MimePartCollection::Insert -// System::Web::Services::Description.MimePartCollection::IndexOf -// System::Web::Services::Description.MimePartCollection->Add -// System::Web::Services::Description.MimePartCollection::Contains -// System::Web::Services::Description.MimePartCollection::CopyTo -// System::Web::Services::Description.MimePartCollection::Remove - -/* This program demostrates constructor, 'Item' property , 'Insert', 'IndexOf', 'Add', -'Contains', 'CopyTo', and 'Remove' methods of 'MimePartCollection' class. -It takes 'MimePartCollection_8_Input_cpp.wsdl' as an input file which contains -one 'MimePart' object that supports 'HttpPost'. A mimepartcollection object is -created and new mimepart objects are added to mimepartcollection using 'Insert' -and 'Add' methods. A mimepart object is removed from the mimepartcollection using -'Remove'method.The ServiceDescription is finally written into output wsdl file -'MimePartCollection_8_out_CS::wsdl'. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimePartCollection_8_Input_cpp.wsdl" ); - ServiceDescriptionCollection^ myServiceDescriptionCol = gcnew ServiceDescriptionCollection; - myServiceDescriptionCol->Add( myServiceDescription ); - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "MimeServiceHttpPost","http://tempuri.org/" ); - - // Create a binding object. - Binding^ myBinding = myServiceDescriptionCol->GetBinding( myXmlQualifiedName ); - OperationBinding^ myOperationBinding = nullptr; - for ( int i = 0; i < myBinding->Operations->Count; i++ ) - if ( myBinding->Operations[ i ]->Name->Equals( "AddNumbers" ) ) - myOperationBinding = myBinding->Operations[ i ]; - - OutputBinding^ myOutputBinding = myOperationBinding->Output; - - // - // - // - // - MimeMultipartRelatedBinding^ myMimeMultipartRelatedBinding = nullptr; - IEnumerator^ myIEnumerator = myOutputBinding->Extensions->GetEnumerator(); - while ( myIEnumerator->MoveNext() ) - myMimeMultipartRelatedBinding = (MimeMultipartRelatedBinding^)myIEnumerator->Current; - - // Create an instance of 'MimePartCollection'. - MimePartCollection^ myMimePartCollection = gcnew MimePartCollection; - myMimePartCollection = myMimeMultipartRelatedBinding->Parts; - Console::WriteLine( "Total number of mimepart elements in the collection initially is: {0}", myMimePartCollection->Count ); - - // Get the type of first 'Item' in collection. - Console::WriteLine( "The first object in collection is of type: {0}", myMimePartCollection[ 0 ] ); - MimePart^ myMimePart1 = gcnew MimePart; - - // Create an instance of 'MimeXmlBinding'. - MimeXmlBinding^ myMimeXmlBinding1 = gcnew MimeXmlBinding; - myMimeXmlBinding1->Part = "body"; - myMimePart1->Extensions->Add( myMimeXmlBinding1 ); - - // a mimepart at first position. - myMimePartCollection->Insert( 0, myMimePart1 ); - Console::WriteLine( "Inserting a mimepart object..." ); - - // Check whether 'Insert' was successful or not. - if ( myMimePartCollection->Contains( myMimePart1 ) ) - { - // Display the index of inserted 'MimePart'. - Console::WriteLine( "'MimePart' is succesfully inserted at position: {0}", myMimePartCollection->IndexOf( myMimePart1 ) ); - } - // - // - // - // - - Console::WriteLine( "Total number of mimepart elements after inserting is: {0}", myMimePartCollection->Count ); - - // - // - MimePart^ myMimePart2 = gcnew MimePart; - MimeXmlBinding^ myMimeXmlBinding2 = gcnew MimeXmlBinding; - myMimeXmlBinding2->Part = "body"; - myMimePart2->Extensions->Add( myMimeXmlBinding2 ); - - // Add a mimepart to the mimepartcollection. - myMimePartCollection->Add( myMimePart2 ); - Console::WriteLine( "Adding a mimepart object..." ); - - // Check if collection contains added mimepart object. - if ( myMimePartCollection->Contains( myMimePart2 ) ) - Console::WriteLine( "'MimePart' is succesfully added at position: {0}", myMimePartCollection->IndexOf( myMimePart2 ) ); - // - // - - Console::WriteLine( "Total number of mimepart elements after adding is: {0}", myMimePartCollection->Count ); - - // - array^myArray = gcnew array(myMimePartCollection->Count); - - // Copy the mimepartcollection to an array. - myMimePartCollection->CopyTo( myArray, 0 ); - Console::WriteLine( "Displaying the array copied from mimepartcollection" ); - for ( int j = 0; j < myMimePartCollection->Count; j++ ) - { - Console::WriteLine( "Mimepart object at position : {0}", j ); - for ( int i = 0; i < myArray[ j ]->Extensions->Count; i++ ) - { - MimeXmlBinding^ myMimeXmlBinding3 = (MimeXmlBinding^)(myArray[ j ]->Extensions[ i ]); - Console::WriteLine( "Part: {0}", (myMimeXmlBinding3->Part) ); - } - } - // - // - Console::WriteLine( "Removing a mimepart object..." ); - - // Remove the mimepart from the mimepartcollection. - myMimePartCollection->Remove( myMimePart1 ); - - // Check whether the mimepart is removed or not. - if ( !myMimePartCollection->Contains( myMimePart1 ) ) - Console::WriteLine( "Mimepart is succesfully removed from mimepartcollection" ); - // - - Console::WriteLine( "Total number of elements in collection after removing is: {0}", myMimePartCollection->Count ); - array^myArray1 = gcnew array(myMimePartCollection->Count); - myMimePartCollection->CopyTo( myArray1, 0 ); - Console::WriteLine( "Dispalying the 'MimePartCollection' after removing" ); - for ( int j = 0; j < myMimePartCollection->Count; j++ ) - { - Console::WriteLine( "Mimepart object at position : {0}", j ); - for ( int i = 0; i < myArray1[ j ]->Extensions->Count; i++ ) - { - MimeXmlBinding^ myMimeXmlBinding3 = (MimeXmlBinding^)(myArray1[ j ]->Extensions[ i ]); - Console::WriteLine( "part: {0}", (myMimeXmlBinding3->Part) ); - } - } - myServiceDescription->Write( "MimePartCollection_8_output.wsdl" ); - Console::WriteLine( "MimePartCollection_8_output.wsdl has been generated successfully." ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimePart_3/CPP/MimePart_3_Input_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/MimePart_3/CPP/MimePart_3_Input_cpp.wsdl deleted file mode 100644 index 64548b47a649d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimePart_3/CPP/MimePart_3_Input_cpp.wsdl +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimePart_3/CPP/mimepart_3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimePart_3/CPP/mimepart_3.cpp deleted file mode 100644 index 78518047dc2f2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimePart_3/CPP/mimepart_3.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// System.Web.Services.Description.MimePart -// System.Web.Services.Description.MimePart.ctor() -// System.Web.Services.Description.MimePart.Extensions -/* The following program demonstrates the 'MimePart' class, constructor -and 'Extensions' property of 'MimePart' class. It reads -'MimePart_3_Input_cpp.wsdl' file which does not have 'MimePart' object -supporting 'OutPut' of 'HttpPost'. It adds the 'MimePart' and finally -writes into 'MimePart_3_OutPut_cpp.wsdl' file. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimePart_3_Input_cpp.wsdl" ); - ServiceDescriptionCollection^ myServiceDescriptionCol = gcnew ServiceDescriptionCollection; - myServiceDescriptionCol->Add( myServiceDescription ); - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "MimeServiceHttpPost","http://tempuri.org/" ); - - // Create the Binding. - Binding^ myBinding = myServiceDescriptionCol->GetBinding( myXmlQualifiedName ); - OperationBinding^ myOperationBinding = nullptr; - for ( int i = 0; i < myBinding->Operations->Count; i++ ) - { - if ( myBinding->Operations[ i ]->Name->Equals( "AddNumbers" ) ) - { - myOperationBinding = myBinding->Operations[ i ]; - } - } - - // - // - // Create the OutputBinding. - OutputBinding^ myOutputBinding = myOperationBinding->Output; - MimeXmlBinding^ myMimeXmlBinding = gcnew MimeXmlBinding; - myMimeXmlBinding->Part = "body"; - - // Create the MimePart. - MimePart^ myMimePart = gcnew MimePart; - myMimePart->Extensions->Add( myMimeXmlBinding ); - MimeMultipartRelatedBinding^ myMimePartRelatedBinding = gcnew MimeMultipartRelatedBinding; - - // Add the MimePart to the MimePartRelatedBinding. - myMimePartRelatedBinding->Parts->Add( myMimePart ); - myOutputBinding->Extensions->Add( myMimePartRelatedBinding ); - // - // - - myServiceDescription->Write( "MimePart_3_Output_CPP.wsdl" ); - Console::WriteLine( "MimePart_3_Output_CPP.wsdl has been generated successfully." ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeTextMatch_5/CPP/MimeTextMatch_5_Input_CPP.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/MimeTextMatch_5/CPP/MimeTextMatch_5_Input_CPP.wsdl deleted file mode 100644 index b0b37666a68a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeTextMatch_5/CPP/MimeTextMatch_5_Input_CPP.wsdl +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeTextMatch_5/CPP/mimetextmatch_5.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimeTextMatch_5/CPP/mimetextmatch_5.cpp deleted file mode 100644 index a1904f5cf88ca..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeTextMatch_5/CPP/mimetextmatch_5.cpp +++ /dev/null @@ -1,138 +0,0 @@ - - -// System.Web.Services.Description.MimeTextMatch -// System.Web.Services.Description.MimeTextMatch.Capture -// System.Web.Services.Description.MimeTextMatch.Group -// System.Web.Services.Description.MimeTextMatch.Repeats -// System.Web.Services.Description.MimeTextMatch.RepeatsString -/* The following program demostrates constructor, 'Capture', 'Group', - 'Repeats' and 'RepeatsString' properties of 'MimeTextMatch'class. - It takes 'MimeTextMatch_5_Input_CPP.wsdl' as input which does not - contain 'Binding' object supporting 'HttpPost'. A text pattern - ''TITLE>(.*?)<' with text name as 'Title' and type - name set which is to be searched in a HTTP transmission is added to the ServiceDescription. - The modified ServiceDescription is written into 'MimeTextMatch_5_Output_CPP.wsdl'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - try - { - int myInt = 0; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimeTextMatch_5_Input_CPP.wsdl" ); - - // Create the 'Binding' object. - Binding^ myBinding = gcnew Binding; - - // Initialize 'Name' property of 'Binding' class. - myBinding->Name = "MimeTextMatchServiceHttpPost"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MimeTextMatchServiceHttpPost" ); - myBinding->Type = myXmlQualifiedName; - - // Create the 'HttpBinding' object. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the 'HttpBinding' to the 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - - // Create the 'OperationBinding' object. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myHttpOperationBinding = gcnew HttpOperationBinding; - myHttpOperationBinding->Location = "/AddNumbers"; - - // Add the 'HttpOperationBinding' object to 'OperationBinding'. - myOperationBinding->Extensions->Add( myHttpOperationBinding ); - - // - // - // - // - // Create an InputBinding. - InputBinding^ myInputBinding = gcnew InputBinding; - MimeTextBinding^ myMimeTextBinding = gcnew MimeTextBinding; - MimeTextMatchCollection^ myMimeTextMatchCollection1 = gcnew MimeTextMatchCollection; - array^myMimeTextMatch = gcnew array(3); - myMimeTextMatchCollection1 = myMimeTextBinding->Matches; - - // Intialize the MimeTextMatch. - for ( myInt = 0; myInt < 3; myInt++ ) - { - // Get a new MimeTextMatch. - myMimeTextMatch[ myInt ] = gcnew MimeTextMatch; - - // Assign values to properties of the MimeTextMatch. - myMimeTextMatch[ myInt ]->Name = String::Format( "Title{0}", Convert::ToString( myInt ) ); - myMimeTextMatch[ myInt ]->Type = "*/*"; - myMimeTextMatch[ myInt ]->Pattern = "TITLE>(.*?)<"; - myMimeTextMatch[ myInt ]->IgnoreCase = true; - myMimeTextMatch[ myInt ]->Capture = 2; - myMimeTextMatch[ myInt ]->Group = 2; - if ( myInt != 0 ) - { - - // Assign the Repeats property if the index is not 0. - myMimeTextMatch[ myInt ]->Repeats = 2; - } - else - { - - // Assign the RepeatsString property if the index is 0. - myMimeTextMatch[ myInt ]->RepeatsString = "4"; - } - myMimeTextMatchCollection1->Add( myMimeTextMatch[ myInt ] ); - - } - // - // - // - // - - myInputBinding->Extensions->Add( myMimeTextBinding ); - - // Add the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - - // Create the 'OutputBinding' instance. - OutputBinding^ myOutput = gcnew OutputBinding; - MimeXmlBinding^ postMimeXmlbinding = gcnew MimeXmlBinding; - - // Initialize 'Part' property of 'MimeXmlBinding' class. - postMimeXmlbinding->Part = "Body"; - - // Add 'MimeXmlBinding' instance to 'OutputBinding' instance. - myOutput->Extensions->Add( postMimeXmlbinding ); - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myServiceDescription->Bindings->Add( myBinding ); - - // Write the 'ServiceDescription' as a WSDL file. - myServiceDescription->Write( "MimeTextMatch_5_Output_CPP.wsdl" ); - Console::WriteLine( "WSDL file with name 'MimeTextMatch_5_Output_CPP.wsdl' is" - " created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Binding_Match_8/CPP/MimeText_Binding_Match_8_Input_CPP.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Binding_Match_8/CPP/MimeText_Binding_Match_8_Input_CPP.wsdl deleted file mode 100644 index 521d34c6e62ef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Binding_Match_8/CPP/MimeText_Binding_Match_8_Input_CPP.wsdl +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Binding_Match_8/CPP/mimetext_binding_match_8.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Binding_Match_8/CPP/mimetext_binding_match_8.cpp deleted file mode 100644 index 495d3ca8b8266..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Binding_Match_8/CPP/mimetext_binding_match_8.cpp +++ /dev/null @@ -1,128 +0,0 @@ - - -// System.Web.Services.Description.MimeTextBinding -// System.Web.Services.Description.MimeTextBinding() -// System.Web.Services.Description.MimeTextMatch() -// System.Web.Services.Description.MimeTextMatch.Name -// System.Web.Services.Description.MimeTextMatch.Type -// System.Web.Services.Description.MimeTextMatch.Pattern -// System.Web.Services.Description.MimeTextMatch.IgnoreCase -// System.Web.Services.Description.MimeTextBinding.Matches -/* This program demostrates constructor and 'Matches' property -of 'MimeTextBinding' class and 'Name', 'Type', 'Pattern', -'IgnoreCase' properties of 'MimeTextMatch' class. -It takes 'MimeText_Binding_Match_8_Input_CPP.wsdl' as an -input file which does not contain 'Binding' object that supports -'HttpPost'. A text pattern ''TITLE>(.*?)<' with text name -as 'Title' and with type name set, is added to the wsdl file. Finally the -' modified ServiceDescription is written to 'MimeText_Binding_Match_8_Output_CPP.wsdl'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimeText_Binding_Match_8_Input_CPP.wsdl" ); - - // Create a Binding. - Binding^ myBinding = gcnew Binding; - - // Initialize the Name property of the Binding. - myBinding->Name = "MimeText_Binding_MatchServiceHttpPost"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MimeText_Binding_MatchServiceHttpPost" ); - myBinding->Type = myXmlQualifiedName; - - // Create an HttpBinding. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the HttpBinding to the Binding. - myBinding->Extensions->Add( myHttpBinding ); - - // Create an OperationBinding. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myHttpOperationBinding = gcnew HttpOperationBinding; - myHttpOperationBinding->Location = "/AddNumbers"; - - // Add the HttpOperationBinding to the OperationBinding. - myOperationBinding->Extensions->Add( myHttpOperationBinding ); - - // Create an InputBinding. - InputBinding^ myInputBinding = gcnew InputBinding; - MimeContentBinding^ postMimeContentbinding = gcnew MimeContentBinding; - postMimeContentbinding->Type = "application/x-www-form-urlencoded"; - myInputBinding->Extensions->Add( postMimeContentbinding ); - - // Add the InputBinding to the OperationBinding. - myOperationBinding->Input = myInputBinding; - - // - // - // - // - // - // - // - // Create an OutputBinding. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - - // Create a MimeTextBinding. - MimeTextBinding^ myMimeTextBinding = gcnew MimeTextBinding; - - // Create a MimeTextMatch. - MimeTextMatch^ myMimeTextMatch = gcnew MimeTextMatch; - MimeTextMatchCollection^ myMimeTextMatchCollection; - - // Initialize properties of the MimeTextMatch. - myMimeTextMatch->Name = "Title"; - myMimeTextMatch->Type = "*/*"; - myMimeTextMatch->Pattern = "'TITLE>(.*?)<"; - myMimeTextMatch->IgnoreCase = true; - - // Initialize a MimeTextMatchCollection. - myMimeTextMatchCollection = myMimeTextBinding->Matches; - - // Add the MimeTextMatch to the MimeTextMatchCollection. - myMimeTextMatchCollection->Add( myMimeTextMatch ); - myOutputBinding->Extensions->Add( myMimeTextBinding ); - - // Add the OutputBinding to the OperationBinding. - myOperationBinding->Output = myOutputBinding; - // - // - // - // - // - // - // - - // Add the OutputBinding to the OperationBinding. - myOperationBinding->Output = myOutputBinding; - - // Add the OperationBinding to the Binding. - myBinding->Operations->Add( myOperationBinding ); - - // Add the Binding to the BindingCollection of the ServiceDescription. - myServiceDescription->Bindings->Add( myBinding ); - - // Write the ServiceDescription as a WSDL file. - myServiceDescription->Write( "MimeText_Binding_Match_8_Output_CPP.wsdl" ); - Console::WriteLine( "WSDL file named 'MimeText_Binding_Match_8_Output_CPP.wsdl' was" - " created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Match_MatchColl_9/CPP/MimeText_Match_MatchColl_9_Input_CPP.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Match_MatchColl_9/CPP/MimeText_Match_MatchColl_9_Input_CPP.wsdl deleted file mode 100644 index f547e5013869b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Match_MatchColl_9/CPP/MimeText_Match_MatchColl_9_Input_CPP.wsdl +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Match_MatchColl_9/CPP/mimetext_match_matchcoll_9.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Match_MatchColl_9/CPP/mimetext_match_matchcoll_9.cpp deleted file mode 100644 index c488a6fea4901..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeText_Match_MatchColl_9/CPP/mimetext_match_matchcoll_9.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// System.Web.Services.Description.MimeTextMatchCollection -// System.Web.Services.Description.MimeTextMatchCollection() -// System.Web.Services.Description.MimeTextMatchCollection.Contains -// System.Web.Services.Description.MimeTextMatchCollection.Add -// System.Web.Services.Description.MimeTextMatchCollection.CopyTo -// System.Web.Services.Description.MimeTextMatchCollection.Remove -// System.Web.Services.Description.MimeTextMatchCollection.Item -// System.Web.Services.Description.MimeTextMatchCollection.IndexOf -// System.Web.Services.Description.MimeTextMatchCollection.Insert - -/* This program demostrates constructor, Contains, Add, Item, - IndexOf, Insert and Remove property of 'MimeTextMatchCollection'. - This program takes 'MimeText_Match_MatchColl_9_Input_CPP.wsdl' as an - input file which does not contain 'Binding' object that supports - 'HttpPost'. A name, type, Group and Capture properties are set - which are to be searched in a HTTP transmission and - 'MimeTextMatchCollection' collection object is created - for input and output of 'HttpPost' and finally writes into - 'MimeText_Match_MatchColl_9_Output_CPP.wsdl'. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - try - { - int myInt = 0; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimeText_Match_MatchColl_9_Input_CPP.wsdl" ); - - // Create the 'Binding' object. - Binding^ myBinding = gcnew Binding; - - // Initialize 'Name' property of 'Binding' class. - myBinding->Name = "MimeText_Match_MatchCollServiceHttpPost"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MimeText_Match_MatchCollServiceHttpPost" ); - myBinding->Type = myXmlQualifiedName; - - // Create the 'HttpBinding' object. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the 'HttpBinding' to the 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - - // Create the 'OperationBinding' object. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myHttpOperationBinding = gcnew HttpOperationBinding; - myHttpOperationBinding->Location = "/AddNumbers"; - - // Add the 'HttpOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( myHttpOperationBinding ); - - // - // Create the 'InputBinding' object. - InputBinding^ myInputBinding = gcnew InputBinding; - MimeTextBinding^ myMimeTextBinding = gcnew MimeTextBinding; - MimeTextMatchCollection^ myMimeTextMatchCollection; - - // - // - // - // Get an array instance of 'MimeTextMatch' class. - array^myMimeTextMatch = gcnew array(4); - myMimeTextMatchCollection = myMimeTextBinding->Matches; - - // Initialize properties of 'MimeTextMatch' class. - for ( myInt = 0; myInt < 4; myInt++ ) - { - // Create the 'MimeTextMatch' instance. - myMimeTextMatch[ myInt ] = gcnew MimeTextMatch; - myMimeTextMatch[ myInt ]->Name = "Title"; - myMimeTextMatch[ myInt ]->Type = "*/*"; - myMimeTextMatch[ myInt ]->IgnoreCase = true; - if ( true == myMimeTextMatchCollection->Contains( myMimeTextMatch[ 0 ] ) ) - { - myMimeTextMatch[ myInt ]->Name = String::Format( "Title{0}", Convert::ToString( myInt ) ); - myMimeTextMatch[ myInt ]->Capture = 2; - myMimeTextMatch[ myInt ]->Group = 2; - myMimeTextMatchCollection->Add( myMimeTextMatch[ myInt ] ); - } - else - { - myMimeTextMatchCollection->Add( myMimeTextMatch[ myInt ] ); - myMimeTextMatchCollection[ myInt ]->RepeatsString = "2"; - } - } - myMimeTextMatchCollection = myMimeTextBinding->Matches; - - // Copy collection to 'MimeTextMatch' array instance. - myMimeTextMatchCollection->CopyTo( myMimeTextMatch, 0 ); - // - // - // - - myInputBinding->Extensions->Add( myMimeTextBinding ); - - // Add the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - - // Create the 'OutputBinding' instance. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - - // Create the 'MimeTextBinding' instance. - MimeTextBinding^ myMimeTextBinding1 = gcnew MimeTextBinding; - - // - // - // - // - // - // Get an instance of 'MimeTextMatchCollection'. - MimeTextMatchCollection^ myMimeTextMatchCollection1 = gcnew MimeTextMatchCollection; - array^myMimeTextMatch1 = gcnew array(5); - myMimeTextMatchCollection1 = myMimeTextBinding1->Matches; - for ( myInt = 0; myInt < 4; myInt++ ) - { - myMimeTextMatch1[ myInt ] = gcnew MimeTextMatch; - myMimeTextMatch1[ myInt ]->Name = String::Format( "Title{0}", Convert::ToString( myInt ) ); - if ( myInt != 0 ) - { - myMimeTextMatch1[ myInt ]->RepeatsString = "7"; - } - myMimeTextMatchCollection1->Add( myMimeTextMatch1[ myInt ] ); - } - myMimeTextMatch1[ 4 ] = gcnew MimeTextMatch; - - // Remove 'MimeTextMatch' instance from collection. - myMimeTextMatchCollection1->Remove( myMimeTextMatch1[ 1 ] ); - - // Using MimeTextMatchCollection.Item indexer to comapre. - if ( myMimeTextMatch1[ 2 ] == myMimeTextMatchCollection1[ 1 ] ) - { - // Check whether 'MimeTextMatch' instance exists. - myInt = myMimeTextMatchCollection1->IndexOf( myMimeTextMatch1[ 2 ] ); - - // Insert 'MimeTextMatch' instance at a desired position. - myMimeTextMatchCollection1->Insert( 1, myMimeTextMatch1[ myInt ] ); - myMimeTextMatchCollection1[ 1 ]->RepeatsString = "5"; - myMimeTextMatchCollection1->Insert( 4, myMimeTextMatch1[ myInt ] ); - } - // - // - // - // - // - // - - myOutputBinding->Extensions->Add( myMimeTextBinding1 ); - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutputBinding; - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutputBinding; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myServiceDescription->Bindings->Add( myBinding ); - - // Write the 'ServiceDescription' as a WSDL file. - myServiceDescription->Write( "MimeText_Match_MatchColl_9_Output_CPP.wsdl" ); - Console::WriteLine( "WSDL file with name 'MimeText_Match_MatchColl_9_Output_CPP.wsdl' is" - " created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeXmlBinding_Part_3/CPP/MimeXmlBinding_Part_3_Input_CPP.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/MimeXmlBinding_Part_3/CPP/MimeXmlBinding_Part_3_Input_CPP.wsdl deleted file mode 100644 index 6f44c8aff5ffc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeXmlBinding_Part_3/CPP/MimeXmlBinding_Part_3_Input_CPP.wsdl +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/MimeXmlBinding_Part_3/CPP/mimexmlbinding_part_3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/MimeXmlBinding_Part_3/CPP/mimexmlbinding_part_3.cpp deleted file mode 100644 index 0cb0a7cb654c7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/MimeXmlBinding_Part_3/CPP/mimexmlbinding_part_3.cpp +++ /dev/null @@ -1,93 +0,0 @@ - - -// System.Web.Services.Description.MimeXmlBinding -// System.Web.Services.Description.MimeXmlBinding.MimeXmlBinding() -// System.Web.Services.Description.MimeXmlBinding.Part -/* The following program demonstrates constructor and 'Part'property -of 'MimeXmlBinding' class. This program takes 'MimeXmlBinding_Part_3_Input_CPP.wsdl' -as input, which does not contain 'Binding' object that supports 'HttpPost'. -It sets message part property to 'Body' on which 'MimeXmlBinding' is -applied and finally writes into 'MimeXmlBinding_Part_3_Output_CPP.wsdl'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "MimeXmlBinding_Part_3_Input_CPP.wsdl" ); - - // Create the 'Binding' object. - Binding^ myBinding = gcnew Binding; - - // Initialize 'Name' property of 'Binding' class. - myBinding->Name = "MimeXmlBinding_Part_3_ServiceHttpPost"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MimeXmlBinding_Part_3_ServiceHttpPost" ); - myBinding->Type = myXmlQualifiedName; - - // Create the 'HttpBinding' object. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the 'HttpBinding' to the 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - - // Create the 'OperationBinding' object. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myHttpOperationBinding = gcnew HttpOperationBinding; - myHttpOperationBinding->Location = "/AddNumbers"; - - // Add the 'HttpOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( myHttpOperationBinding ); - - // Create the 'InputBinding' object. - InputBinding^ myInputBinding = gcnew InputBinding; - MimeContentBinding^ myMimeContentBinding = gcnew MimeContentBinding; - myMimeContentBinding->Type = "application/x-www-form-urlencoded"; - myInputBinding->Extensions->Add( myMimeContentBinding ); - - // Add the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - - // - // - // Create an OutputBinding. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - MimeXmlBinding^ myMimeXmlBinding = gcnew MimeXmlBinding; - - // Initialize the Part property of the MimeXmlBinding. - myMimeXmlBinding->Part = "Body"; - - // Add the MimeXmlBinding to the OutputBinding. - myOutputBinding->Extensions->Add( myMimeXmlBinding ); - // - // - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutputBinding; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myDescription->Bindings->Add( myBinding ); - - // Write the 'ServiceDescription' as a WSDL file. - myDescription->Write( "MimeXmlBinding_Part_3_Output_CPP.wsdl" ); - Console::WriteLine( "WSDL file with name 'MimeXmlBinding_Part_3_Output_CPP.wsdl' is" - " created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp deleted file mode 100644 index 6fdfe8f6904f1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp +++ /dev/null @@ -1,235 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; - -// -// The following method displays the properties of the -// specified WebProxy instance. -void DisplayProxyProperties( WebProxy^ proxy ) -{ - Console::WriteLine( "Address: {0}", proxy->Address ); - Console::WriteLine( "Bypass on local: {0}", proxy->BypassProxyOnLocal ); - - int count = proxy->BypassList->Length; - if ( count == 0 ) - { - Console::WriteLine( "The bypass list is empty." ); - return; - } - - array^bypass = proxy->BypassList; - Console::WriteLine( "The bypass list contents:" ); - for ( int i = 0; i < count; i++ ) - { - Console::WriteLine( bypass[ i ] ); - - } -} -// - -// -// The following method creates a Web proxy that uses -// Web proxy auto-discovery and supplies -// credentials to be used to download the wpad.dat script. -void CheckAutoProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // See what proxy is used for the resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see if a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", - resource, resourceProxy ); - } -} -// - -// -// The following method creates a WebProxy object that uses Internet Explorer's -// detected script if it is found in the registry; otherwise, it -// tries to use Web proxy auto-discovery to set the proxy used for -// the request. -void CheckAutoGlobalProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // Display the proxy's properties. - DisplayProxyProperties( proxy ); - - // See what proxy is used for the resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see whether a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, resourceProxy ); - } -} -// - -// The following method creates a Web proxy that -// has its initial values set by the Internet Explorer's -// explicit proxy address and bypass list. -// The proxy uses Internet Explorer's automatically detected -// script if it found in the registry; otherwise, it tries to use -// Web proxy auto-discovery to set the proxy used for -// the request. -void CheckAutoDefaultProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = dynamic_cast(WebRequest::DefaultWebProxy); - - // Display the proxy properties. - DisplayProxyProperties( proxy ); - - // See what proxy is used for resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see if a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, resourceProxy ); - } -} - -// -// This method specifies a script that should -// be used in the event that auto-discovery fails. -void CheckAutoProxyAndScriptForRequest( Uri^ resource, Uri^ script ) -{ - WebProxy^ proxy = gcnew WebProxy; - DisplayProxyProperties( proxy ); - - // See what proxy is used for resource. - Uri^ resourceProxy = dynamic_cast(proxy->GetProxy(resource)); - - // Test to see whether a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, resourceProxy ); - } -} -// - -// if construct with glocabl select -// if use system = true then if proxy = Glocalproxy.Select - the returned instance -// will have its values set -// by IE settings. If you do webProxy get default roxy reads manual setting (proxy address and -// bypass - doesn't matter what the config file has. -// -// The following method explicitly identifies -// the script to be downloaded and used to select the proxy. -void CheckScriptedProxyForRequest( Uri^ resource, Uri^ script ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // See what proxy is used for resource. - Uri^ resourceProxy = dynamic_cast(proxy->GetProxy(resource)); - - // Test to see whether a proxy was selected. - if ( resourceProxy == nullptr ) - { - Console::WriteLine( "No proxy selected for {0}.", resource ); - return; - } - else - { - Console::WriteLine( "proxy returned for {0}.", resource ); - { - - // DIRECT in script is returned as a null Uri object. - if ( resourceProxy == nullptr ) - Console::WriteLine( "DIRECT" ); - else - Console::WriteLine( "{0}", resourceProxy ); - - } - } -} -// - -// -WebResponse^ CheckLatestScriptRequest( Uri^ resource, WebProxy^ proxy ) -{ - WebRequest^ request = WebRequest::Create( resource ); - request->Proxy = proxy; - WebResponse^ response = request->GetResponse(); - return response; -} -// - -void CheckScriptedProxyForRequest2( Uri^ resource, Uri^ script ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // if use ssystem = true then if proxy = Glocalproxy.Select - the returned instance - // will have its values set - // by IE settings. If you do webProxy get defaultProxy reads manual setting (proxy address and - // bypass - doesn't matter what the config file has. - - // if construct with global select - - // See what proxy is used for resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - Console::WriteLine( "GetProxy returned for {0} is {1}.", resource, resourceProxy ); - - -} - -void Underline() -{ - Console::WriteLine( "=======================================" ); -} - -int main() -{ - Uri^ resource = gcnew Uri( "http://www.example.com" ); - - // Console.WriteLine("nothing - default ctor"); Underline(); - // DisplayProxyProperties(new WebProxy()); - // Console.WriteLine ("\n\nAuto-only - default ctor"); Underline(); - // CheckAutoProxyForRequest(resource); - Console::WriteLine( "\n\nAuto-only - GlobalProxySelection.Select" ); - Underline(); - CheckAutoGlobalProxyForRequest( resource ); - - /* - Console.WriteLine ("\n\nAuto-only - DefaultProxy"); Underline(); - CheckAutoDefaultProxyForRequest(resource); - */ - // Console.WriteLine("\n\n IE auto + Valid Script-only"); - // CheckScriptedProxyForRequest(resource, new Uri("http://sharriso1/wpad.dat")); - // Console.WriteLine("\n\n IE auto Invalid Script-only"); - // CheckScriptedProxyForRequest(resource, new Uri("http://sharriso1/wpadx.dat")); - /* Console.WriteLine("Auto and Valid script"); - CheckAutoProxyAndScriptForRequest(resource, new Uri("http://sharriso1/wpad.dat")); - - Console.WriteLine("Auto and Invalid script"); - CheckAutoProxyAndScriptForRequest(resource, new Uri("http://sharriso1/wpadx.dat")); - */ - // check snippet 5 - // CheckLatestScriptRequest(resource, WebProxy.GetDefaultProxy()); - // check snippet 6 - //CheckAutoProxyForRequest( resource); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp deleted file mode 100644 index 18275c877c28a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp +++ /dev/null @@ -1,77 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; - -// This example is run at the command line. -// Specify one argument: the name of the host to -// send the request to. -// If the request is sucessful, the example displays the contents of the cookies -// returned by the host. -// -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args == nullptr || args->Length != 2 ) - { - Console::WriteLine( "Specify the URL to receive the request." ); - Environment::Exit( 1 ); - } - - - // - HttpWebRequest^ request = dynamic_cast(WebRequest::Create( args[ 1 ] )); - request->CookieContainer = gcnew CookieContainer; - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - response->Cookies = request->CookieContainer->GetCookies( request->RequestUri ); - - // Print the properties of each cookie. - System::Collections::IEnumerator^ myEnum = response->Cookies->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Cookie^ cook = safe_cast(myEnum->Current); - Console::WriteLine( "Cookie:" ); - Console::WriteLine( "{0} = {1}", cook->Name, cook->Value ); - Console::WriteLine( "Domain: {0}", cook->Domain ); - Console::WriteLine( "Path: {0}", cook->Path ); - Console::WriteLine( "Port: {0}", cook->Port ); - Console::WriteLine( "Secure: {0}", cook->Secure ); - Console::WriteLine( "When issued: {0}", cook->TimeStamp ); - Console::WriteLine( "Expires: {0} (expired? {1})", cook->Expires, cook->Expired ); - Console::WriteLine( "Don't save: {0}", cook->Discard ); - Console::WriteLine( "Comment: {0}", cook->Comment ); - Console::WriteLine( "Uri for comments: {0}", cook->CommentUri ); - Console::WriteLine( "Version: RFC {0}", cook->Version == 1 ? (String^)"2109" : "2965" ); - - // - // Show the string representation of the cookie. - Console::WriteLine( "String: {0}", cook ); - - // - } - // - -} - -// -// Output from this example will be vary depending on the host name specified, -// but will be similar to the following. -/* -Cookie: -CustomerID = 13xyz -Domain: .contoso.com -Path: / -Port: -Secure: False -When issued: 1/14/2003 3:20:57 PM -Expires: 1/17/2013 11:14:07 AM (expired? False) -Don't save: False -Comment: -Uri for comments: -Version: RFC 2965 -String: CustomerID = 13xyz -*/ -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp deleted file mode 100644 index 43ec554b17892..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp +++ /dev/null @@ -1,249 +0,0 @@ - -// NCLCredPolicy -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::IO; -using namespace System::Text; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace Microsoft::Win32; - -// -public ref class SelectedHostsCredentialPolicy: public ICredentialPolicy -{ -public: - SelectedHostsCredentialPolicy(){} - - virtual bool ShouldSendCredential( Uri^ challengeUri, WebRequest^ request, NetworkCredential^ /*credential*/, IAuthenticationModule^ /*authModule*/ ) - { - Console::WriteLine( L"Checking custom credential policy." ); - if ( request->RequestUri->Host->Equals( L"www.contoso.com" ) || challengeUri->IsLoopback == true ) - return true; - - return false; - } -}; -// - -// -// The following class allows credentials to be sent if they are for requests for resources -// in the same domain, or if the request uses the HTTPSscheme and basic authentication is -// required. -public ref class HttpsBasicCredentialPolicy: public IntranetZoneCredentialPolicy -{ -public: - HttpsBasicCredentialPolicy(){} - - virtual bool ShouldSendCredential( Uri^ challengeUri, WebRequest^ request, NetworkCredential^ credential, IAuthenticationModule^ authModule ) override - { - Console::WriteLine( L"Checking custom credential policy for HTTPS and basic." ); - bool answer = IntranetZoneCredentialPolicy::ShouldSendCredential( challengeUri, request, credential, authModule ); - if ( answer == true ) - { - Console::WriteLine( L"Sending credential for intranet resource." ); - return answer; - } - - // Determine whether the base implementation returned false for basic and HTTPS. - if ( request->RequestUri->Scheme == Uri::UriSchemeHttps && authModule->AuthenticationType->Equals( L"Basic" ) ) - { - Console::WriteLine( L"Sending credential for HTTPS and basic." ); - return true; - } - - return false; - } -}; -// - -public ref class CredentialPolicyExamples -{ -public: - static void UseHttpsBasicCredentialPolicy() - { - HttpsBasicCredentialPolicy^ encryptedBasic = gcnew HttpsBasicCredentialPolicy; - AuthenticationManager::CredentialPolicy = encryptedBasic; - } - - static void UseCustomCredentialPolicy() - { - SelectedHostsCredentialPolicy^ hosts = gcnew SelectedHostsCredentialPolicy; - AuthenticationManager::CredentialPolicy = hosts; - } - - // - static void UseIntranetCredentialPolicy() - { - IntranetZoneCredentialPolicy^ policy = gcnew IntranetZoneCredentialPolicy; - AuthenticationManager::CredentialPolicy = policy; - } - // - - // - // The following example uses the System, System.Net, - // and System.IO namespaces. - static void RequestMutualAuth( Uri^ resource ) - { - // Create a new HttpWebRequest object for the specified resource. - WebRequest^ request = dynamic_cast(WebRequest::Create( resource )); - - // Request mutual authentication. - request->AuthenticationLevel = AuthenticationLevel::MutualAuthRequested; - - // Supply client credentials. - request->Credentials = CredentialCache::DefaultCredentials; - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // Determine whether mutual authentication was used. - Console::WriteLine( L"Is mutually authenticated? {0}", response->IsMutuallyAuthenticated ); - - // Read and display the response. - Stream^ streamResponse = response->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - String^ responseString = streamRead->ReadToEnd(); - Console::WriteLine( responseString ); - - // Close the stream objects. - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse. - response->Close(); - } - // - - -private: - - static String^ GetUserName() - { - return L"sharriso1\\Jane"; - } - - static String^ GetUserPassword() - { - return L"LXMP9804!"; - } - -public: - ref class HttpsBasicCredentialOnlyPolicy: public ICredentialPolicy - { - public: - HttpsBasicCredentialOnlyPolicy(){} - - virtual bool ShouldSendCredential( Uri^ /*challengeUri*/, WebRequest^ request, NetworkCredential^ /*credential*/, IAuthenticationModule^ authModule ) - { - Console::WriteLine( L"Checking custom credential policy for HTTPS and basic." ); - - // Determine whether the base implementation returned false for basic and https. - if ( request->RequestUri->Scheme == Uri::UriSchemeHttps && authModule->AuthenticationType->Equals( L"Basic" ) ) - { - Console::WriteLine( L"Sending credential for HTTPS and basic." ); - return true; - } - - return false; - } - - }; - - static void RequestHttpBasicResource( Uri^ resource ) - { - // Set policy to send credentials when using HTTPS and basic authentication; - HttpsBasicCredentialOnlyPolicy^ encryptedBasic = gcnew HttpsBasicCredentialOnlyPolicy; - AuthenticationManager::CredentialPolicy = encryptedBasic; - - // Create a new HttpWebRequest object for the specified resource. - WebRequest^ request = dynamic_cast(WebRequest::Create( resource )); - - // Supply client credentials for basic authentication. - request->Credentials = gcnew NetworkCredential( GetUserName(),GetUserPassword() ); - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // Determine whether mutual authentication was used. - Console::WriteLine( L"Is mutually authenticated? {0}", response->IsMutuallyAuthenticated ); - - // Read and display the response. - System::IO::Stream^ streamResponse = response->GetResponseStream(); - System::IO::StreamReader^ streamRead = gcnew System::IO::StreamReader( streamResponse ); - String^ responseString = streamRead->ReadToEnd(); - Console::WriteLine( responseString ); - - // Close the stream objects. - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse. - response->Close(); - } - - // - static void RequestResource( Uri^ resource ) - { - // Set policy to send credentials when using HTTPS and basic authentication. - // Create a new HttpWebRequest object for the specified resource. - WebRequest^ request = dynamic_cast(WebRequest::Create( resource )); - - // Supply client credentials for basic authentication. - request->UseDefaultCredentials = true; - request->AuthenticationLevel = AuthenticationLevel::MutualAuthRequired; - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // Determine mutual authentication was used. - Console::WriteLine( L"Is mutually authenticated? {0}", response->IsMutuallyAuthenticated ); - System::Collections::Specialized::StringDictionary^ spnDictionary = AuthenticationManager::CustomTargetNameDictionary; - System::Collections::IEnumerator^ myEnum = spnDictionary->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ e = safe_cast(myEnum->Current); - Console::WriteLine( "Key: {0} - {1}", dynamic_cast(e->Key), dynamic_cast(e->Value) ); - } - - // Read and display the response. - System::IO::Stream^ streamResponse = response->GetResponseStream(); - System::IO::StreamReader^ streamRead = gcnew System::IO::StreamReader( streamResponse ); - String^ responseString = streamRead->ReadToEnd(); - Console::WriteLine( responseString ); - - // Close the stream objects. - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse. - response->Close(); - } - - /* - - The output from this example will differ based on the requested resource - and whether mutual authentication was successful. For the purpose of illustration, - a sample of the output is shown here: - - Is mutually authenticated? True - Key: http://server1.someDomain.contoso.com - HTTP/server1.someDomain.contoso.com - - - ... - - - */ - // - int TestCredentialPolicy() - { - // UseCustomCredentialPolicy(); - //RequestMutualAuth(new Uri("http://wasabi/noribeta/NamespaceExceptionReport.aspx?Namespace=System.Net")); - //RequestMutualAuth(new Uri("http://sharriso1/test/postaccepter.aspx")); - // RequestResource(new Uri("http://sharriso1.redmond.corp.microsoft.com/test/postaccepter.aspx")); - RequestResource( gcnew Uri( L"http://www.google.com" ) ); - return 1; - } -}; - -void main() -{ - CredentialPolicyExamples^ cpe = gcnew CredentialPolicyExamples; - cpe->TestCredentialPolicy(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLCustomWebClient/CPP/mywebclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLCustomWebClient/CPP/mywebclient.cpp deleted file mode 100644 index 57313e17fac96..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLCustomWebClient/CPP/mywebclient.cpp +++ /dev/null @@ -1,188 +0,0 @@ - - -//NCLCustomWebClient -#using - -using namespace System; -using namespace System::Net; - -public ref class CustomWebClient: public WebClient -{ -protected: - - // - virtual WebRequest^ GetWebRequest ( Uri^ address ) override - { - WebRequest^ request = dynamic_cast(WebClient::GetWebRequest( address )); - - // Perform any customizations on the request. - // This version of WebClient always preauthenticates. - request->PreAuthenticate = true; - return request; - } - // - - // - virtual WebResponse^ GetWebResponse( WebRequest^ request ) override - { - WebResponse^ response = WebClient::GetWebResponse( request ); - - // Perform any custom actions with the response ... - return response; - } - // - - // - virtual WebResponse^ GetWebResponse( WebRequest^ request, IAsyncResult^ result ) override - { - WebResponse^ response = WebClient::GetWebResponse( request, result ); - - // Perform any custom actions with the response ... - return response; - } - // - - // - virtual void OnDownloadDataCompleted( DownloadDataCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnDownloadDataCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnDownloadFileCompleted( System::ComponentModel::AsyncCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnDownloadFileCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnDownloadStringCompleted( DownloadStringCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnDownloadStringCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnOpenReadCompleted( OpenReadCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnOpenReadCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnOpenWriteCompleted( OpenWriteCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnOpenWriteCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnUploadDataCompleted( UploadDataCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnUploadDataCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnUploadFileCompleted( UploadFileCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnUploadFileCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnUploadStringCompleted( UploadStringCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnUploadStringCompleted( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnDownloadProgressChanged( DownloadProgressChangedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnDownloadProgressChanged( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnUploadProgressChanged( UploadProgressChangedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnUploadProgressChanged( e ); - - // Here you can perform any post event actions... - } - // - - // - virtual void OnUploadValuesCompleted( UploadValuesCompletedEventArgs ^ e ) override - { - // Here you can perform any custom actions before the event is raised - // and event handlers are called... - WebClient::OnUploadValuesCompleted( e ); - - // Here you can perform any post event actions... - } - // -}; - -int main() -{ - CustomWebClient^ newClient = gcnew CustomWebClient; -} - -// Output from this example will be vary depending on the host name specified, -// but will be similar to the following. -/* -Cookie: -CustomerID = 13xyz -Domain: .contoso.com -Path: / -Port: -Secure: False -When issued: 1/14/2003 3:20:57 PM -Expires: 1/17/2013 11:14:07 AM (expired? False) -Don't save: False -Comment: -Uri for comments: -Version: RFC 2965 -String: CustomerID = 13xyz -*/ diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp deleted file mode 100644 index 6a13836357ff0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -int main() -{ - - // Create a request for the Web page at www.contoso.com. - WebRequest^ request = WebRequest::Create( L"http://www.contoso.com" ); - - // This application doesn't want they proxy to be used so it sets - // the global proxy to an empy proxy. - IWebProxy^ myProxy = GlobalProxySelection::GetEmptyWebProxy(); - - // Get the response. - WebResponse^ response = request->GetResponse(); - - // Display the response to the console. - Stream^ stream = response->GetResponseStream(); - StreamReader^ reader = gcnew StreamReader( stream ); - Console::WriteLine( reader->ReadToEnd() ); - - // Clean up. - reader->Close(); - stream->Close(); - response->Close(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp deleted file mode 100644 index e507d6263b90a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp +++ /dev/null @@ -1,227 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Threading; -using namespace System::IO; - -// -public ref class FtpState -{ -private: - ManualResetEvent^ wait; - FtpWebRequest^ request; - String^ fileName; - Exception^ operationException; - String^ status; - -public: - FtpState() - { - wait = gcnew ManualResetEvent( false ); - } - - property ManualResetEvent^ OperationComplete - { - ManualResetEvent^ get() - { - return wait; - } - - } - - property FtpWebRequest^ Request - { - FtpWebRequest^ get() - { - return request; - } - - void set( FtpWebRequest^ value ) - { - request = value; - } - - } - - property String^ FileName - { - String^ get() - { - return fileName; - } - - void set( String^ value ) - { - fileName = value; - } - - } - - property Exception^ OperationException - { - Exception^ get() - { - return operationException; - } - - void set( Exception^ value ) - { - operationException = value; - } - - } - - property String^ StatusDescription - { - String^ get() - { - return status; - } - - void set( String^ value ) - { - status = value; - } - - } -}; -// - -// -public ref class AsynchronousFtpUpLoader -{ -public: - - // - // Command line arguments are two strings: - // 1. The url that is the name of the file being uploaded to the server. - // 2. The name of the file on the local machine. - // - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - - // Create a Uri instance with the specified URI string. - // If the URI is not correctly formed, the Uri constructor - // will throw an exception. - ManualResetEvent^ waitObject; - Uri^ target = gcnew Uri( args[ 1 ] ); - String^ fileName = args[ 2 ]; - FtpState^ state = gcnew FtpState; - FtpWebRequest ^ request = dynamic_cast(WebRequest::Create( target )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // This example uses anonymous logon. - // The request is anonymous by default; the credential does not have to be specified. - // The example specifies the credential only to - // control how actions are logged on the server. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - - // Store the request in the object that we pass into the - // asynchronous operations. - state->Request = request; - state->FileName = fileName; - - // Get the event to wait on. - waitObject = state->OperationComplete; - - // Asynchronously get the stream for the file contents. - request->BeginGetRequestStream( gcnew AsyncCallback( EndGetStreamCallback ), state ); - - // Block the current thread until all operations are complete. - waitObject->WaitOne(); - - // The operations either completed or threw an exception. - if ( state->OperationException != nullptr ) - { - throw state->OperationException; - } - else - { - Console::WriteLine( "The operation completed - {0}", state->StatusDescription ); - } - } - // - - // -private: - static void EndGetStreamCallback( IAsyncResult^ ar ) - { - FtpState^ state = dynamic_cast(ar->AsyncState); - Stream^ requestStream = nullptr; - - // End the asynchronous call to get the request stream. - try - { - requestStream = state->Request->EndGetRequestStream( ar ); - - // Copy the file contents to the request stream. - const int bufferLength = 2048; - array^buffer = gcnew array(bufferLength); - int count = 0; - int readBytes = 0; - FileStream^ stream = File::OpenRead( state->FileName ); - do - { - readBytes = stream->Read( buffer, 0, bufferLength ); - requestStream->Write( buffer, 0, bufferLength ); - count += readBytes; - } - while ( readBytes != 0 ); - Console::WriteLine( "Writing {0} bytes to the stream.", count ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - - // Asynchronously get the response to the upload request. - state->Request->BeginGetResponse( gcnew AsyncCallback( EndGetResponseCallback ), state ); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Could not get the request stream." ); - state->OperationException = e; - state->OperationComplete->Set(); - return; - } - } - // - - // - // The EndGetResponseCallback method - // completes a call to BeginGetResponse. - static void EndGetResponseCallback( IAsyncResult^ ar ) - { - FtpState^ state = dynamic_cast(ar->AsyncState); - FtpWebResponse ^ response = nullptr; - try - { - response = dynamic_cast(state->Request->EndGetResponse( ar )); - response->Close(); - state->StatusDescription = response->StatusDescription; - - // Signal the main application thread that - // the operation is complete. - state->OperationComplete->Set(); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Error getting response." ); - state->OperationException = e; - state->OperationComplete->Set(); - } - } - // -}; -// - -int main() -{ - AsynchronousFtpUpLoader::Main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp deleted file mode 100644 index 779372bd9864c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp +++ /dev/null @@ -1,842 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::IO; -using namespace System::Threading; -using namespace System::Security::Cryptography::X509Certificates; - -public ref class FtpRequestTest -{ -private: - - // FxCop rule requires a private constructor. - FtpRequestTest(){} - - -public: - - // - static bool ListFilesOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::ListDirectory; - - // Get the ServicePoint object used for this request, and limit it to one connection. - // In a real-world application you might use the default number of connections (2), - // or select a value that works best for your application. - ServicePoint^ sp = request->ServicePoint; - Console::WriteLine( "ServicePoint connections = {0}.", sp->ConnectionLimit ); - sp->ConnectionLimit = 1; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // The following streams are used to read the data returned from the server. - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - try - { - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - if ( readStream != nullptr ) - { - // Display the data received from the server. - Console::WriteLine( readStream->ReadToEnd() ); - } - - Console::WriteLine( "List status: {0}", response->StatusDescription ); - } - finally - { - if ( readStream != nullptr ) - { - readStream->Close(); - } - - if ( response != nullptr ) - { - response->Close(); - } - } - - return true; - } - // - - // new content - // - static bool NameListFilesOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::ListDirectoryDetails; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // The following streams are used to read the data returned from the server. - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - try - { - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - if ( readStream != nullptr ) - { - // Display the data received from the server. - Console::WriteLine( readStream->ReadToEnd() ); - } - - Console::WriteLine( "Status: {0}", response->StatusDescription ); - } - finally - { - if ( readStream != nullptr ) - { - readStream->Close(); - } - - if ( response != nullptr ) - { - response->Close(); - } - } - - return true; - } - // - - // - static bool GetDateTimestampOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::GetDateTimestamp; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "{0} {1}", serverUri, response->LastModified ); - - // The output from this method will vary depening on the - // file specified and your regional settings. It is similar to: - // ftp://contoso.com/Data.txt 4/15/2003 10:46:02 AM - return true; - } - // - - // - static bool MakeDirectoryOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::MakeDirectory; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Status: {0}", response->StatusDescription ); - return true; - } - // - - // - static bool UploadUniqueFileOnServer( Uri^ serverUri, String^ fileName ) - { - // The URI described by serverUri should use the ftp:// scheme. - // It contains the name of the directory on the server. - // Example: ftp://contoso.com. - // - // The fileName parameter identifies the file containing the data to be uploaded. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFileWithUniqueName; - - // Don't set a time limit for the operation to complete. - request->Timeout = System::Threading::Timeout::Infinite; - - // Copy the file contents to the request stream. - const int bufferLength = 2048; - array^buffer = gcnew array(bufferLength); - int count = 0; - int readBytes = 0; - FileStream^ stream = File::OpenRead( fileName ); - Stream^ requestStream = request->GetRequestStream(); - do - { - readBytes = stream->Read( buffer, 0, bufferLength ); - requestStream->Write( buffer, 0, bufferLength ); - count += readBytes; - } - while ( readBytes != 0 ); - - Console::WriteLine( "Writing {0} bytes to the stream.", count ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Upload status: {0}, {1}", response->StatusCode, response->StatusDescription ); - Console::WriteLine( "File name: {0}", response->ResponseUri ); - response->Close(); - return true; - } - // - - // - static bool RemoveDirectoryOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::RemoveDirectory; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Status: {0}", response->StatusDescription ); - return true; - } - // - - // - static bool UploadFileToServer( String^ fileName, Uri^ serverUri ) - { - // The URI described by serverUri should use the ftp:// scheme. - // It contains the name of the file on the server. - // Example: ftp://contoso.com/someFile.txt. - // - // The fileName parameter identifies the file containing the data to be uploaded. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // Don't set a time limit for the operation to complete. - request->Timeout = System::Threading::Timeout::Infinite; - - // Copy the file contents to the request stream. - const int bufferLength = 2048; - array^buffer = gcnew array(bufferLength); - int count = 0; - int readBytes = 0; - FileStream^ stream = File::OpenRead( fileName ); - Stream^ requestStream = request->GetRequestStream(); - do - { - readBytes = stream->Read( buffer, 0, bufferLength ); - requestStream->Write( buffer, 0, bufferLength ); - count += readBytes; - } - while ( readBytes != 0 ); - - Console::WriteLine( "Writing {0} bytes to the stream.", count ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Upload status: {0}, {1}", response->StatusCode, response->StatusDescription ); - response->Close(); - return true; - } - // - - // - static bool AppendFileOnServer( String^ fileName, Uri^ serverUri ) - { - // The URI described by serverUri should use the ftp:// scheme. - // It contains the name of the file on the server. - // Example: ftp://contoso.com/someFile.txt. - // The fileName parameter identifies the file containing - // the data to be appended to the file on the server. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::AppendFile; - StreamReader^ sourceStream = gcnew StreamReader( fileName ); - array^fileContents = Encoding::UTF8->GetBytes( sourceStream->ReadToEnd() ); - sourceStream->Close(); - request->ContentLength = fileContents->Length; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - Stream^ requestStream = request->GetRequestStream(); - requestStream->Write( fileContents, 0, fileContents->Length ); - requestStream->Close(); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Append status: {0}", response->StatusDescription ); - response->Close(); - return true; - } - // - - // - static bool DeleteFileOnServer( Uri^ serverUri ) - { - // The serverUri parameter should use the ftp:// scheme. - // It contains the name of the server file that is to be deleted. - // Example: ftp://contoso.com/someFile.txt. - // - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::DeleteFile; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Delete status: {0}", response->StatusDescription ); - response->Close(); - return true; - } - // - - // - static bool DisplayFileFromServer( Uri^ serverUri ) - { - // The serverUri parameter should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - WebClient^ request = gcnew WebClient; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - try - { - array^newFileData = request->DownloadData( serverUri->ToString() ); - String^ fileString = System::Text::Encoding::UTF8->GetString( newFileData ); - Console::WriteLine( fileString ); - } - catch ( WebException^ e ) - { - Console::WriteLine( e ); - } - - return true; - } - // - - - // -private: - // DisplayRequestProperties prints a request's properties. - // This method should be called after the request is sent to the server. - static void DisplayRequestProperties( FtpWebRequest^ request ) - { - // - Console::WriteLine( "User {0} {1}", request->Credentials->GetCredential( request->RequestUri, "basic" )->UserName, request->RequestUri ); - - // - Console::WriteLine( "Request: {0} {1}", request->Method, request->RequestUri ); - - // - Console::WriteLine( "Passive: {0} Keep alive: {1} Binary: {2} Timeout: {3}.", request->UsePassive, request->KeepAlive, request->UseBinary, request->Timeout == -1 ? "none" : request->Timeout.ToString() ); - - // - // - IWebProxy^ proxy = request->Proxy; - if ( proxy ) - { - Console::WriteLine( "Proxy: {0}", proxy->GetProxy( request->RequestUri ) ); - } - else - { - Console::WriteLine( "Proxy: (none)" ); - } - - Console::WriteLine( "ConnectionGroup: {0}", request->ConnectionGroupName == nullptr ? "none" : request->ConnectionGroupName ); - // - - Console::WriteLine( "Encrypted connection: {0}", request->EnableSsl ); - - Console::WriteLine("Method: {0}", request->Method); - } - // - - // -public: - // NOT Working - throws a protocolError - 350 Restarting at 8. for args shown in Main. - static bool RestartDownloadFromServer( String^ fileName, Uri^ serverUri, long offset ) - { - // The serverUri parameter should use the ftp:// scheme. - // It identifies the server file that is to be appended. - // Example: ftp://contoso.com/someFile.txt. - // - // The fileName parameter identifies the local file - // - // The offset parameter specifies where in the server file to start reading data. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::DownloadFile; - request->ContentOffset = offset; - FtpWebResponse^ response = nullptr; - try - { - response = dynamic_cast(request->GetResponse()); - } - catch ( WebException^ e ) - { - Console::WriteLine( e->Status ); - Console::WriteLine( e->Message ); - return false; - } - - Stream^ newFile = response->GetResponseStream(); - StreamReader^ reader = gcnew StreamReader( newFile ); - - // Display downloaded data. - String^ newFileData = reader->ReadToEnd(); - - // Append the response data to the local file - // using a StreamWriter. - StreamWriter^ writer = File::AppendText(fileName); - writer->Write(newFileData); - - // Display the status description. - - // Cleanup. - writer->Close(); - reader->Close(); - response->Close(); - // string fileString = System.Text.Encoding.UTF8.GetString(newFileData); - // Console::WriteLine( sr ); - Console::WriteLine("Download restart - status: {0}",response->StatusDescription); - return true; - } - // - - // not enabled in M2 - // Sample call: SendCommandToServer("ftp://contoso.com/", "pwd"); - // The output can only return status information. - static bool SendCommandToServer( String^ serverUri, String^ command ) - { - // The serverUri parameter should start with the ftp:// scheme. - // It contains the name of the file on the server that will be appended. - // Example: ftp://contoso.com/someFile.txt. - // - // The command parameter identifies the command to send to the server. - if ( serverUri->ToLower()->StartsWith( Uri::UriSchemeFtp ) == false ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = command; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "{0} status: {1}", command, response->StatusDescription ); - response->Close(); - return true; - } - - // - static bool DownloadFileFromServer( Uri^ serverUri, String^ localFileName ) - { - // The serverUri parameter should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - // Note that the cast to FtpWebRequest is done only - // for the purposes of illustration. If your application - // does not set any properties other than those defined in the - // System.Net.WebRequest class, you can use the following line instead: - // WebRequest request = WebRequest.Create(serverUri); - // - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::DownloadFile; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - StreamWriter^ writeStream = nullptr; - try - { - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - - // Display information about the data received from the server. - Console::WriteLine( "Bytes received: {0}", response->ContentLength ); - Console::WriteLine( "Message from server: {0}", response->StatusDescription ); - Console::WriteLine( "Resource: {0}", response->ResponseUri ); - - // Write the bytes received from the server to the local file. - if ( readStream != nullptr ) - { - writeStream = gcnew StreamWriter( localFileName,false ); - writeStream->Write( readStream->ReadToEnd() ); - } - } - finally - { - if ( readStream != nullptr ) - { - readStream->Close(); - } - - if ( response != nullptr ) - { - response->Close(); - } - - if ( writeStream != nullptr ) - { - writeStream->Close(); - } - } - - return true; - } - // - - // Make a request to show the request properties - static void GetRequestProperties( Uri^ serverUri ) - { - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - request->Proxy = gcnew WebProxy; - request->Method = WebRequestMethods::Ftp::DownloadFile; - request->Abort(); - DisplayRequestProperties( request ); - } - - // async snippets - // - static bool GetFileSizeFromServer( Uri^ serverUri ) - { - // The serverUri parameter should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::GetFileSize; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // Display information about the server response. - Console::WriteLine( "size of file: {0}", response->ContentLength ); - response->Close(); - return true; - } - // - - // - static bool ListFilesOnServerSsl( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::ListDirectory; - request->EnableSsl = true; - - // Get the ServicePoint object used for this request, and limit it to one connection. - // In a real-world application you might use the default number of connections (2), - // or select a value that works best for your application. - ServicePoint^ sp = request->ServicePoint; - Console::WriteLine( "ServicePoint connections = {0}.", sp->ConnectionLimit ); - sp->ConnectionLimit = 1; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "The content length is {0}", response->ContentLength ); - - // The following streams are used to read the data returned from the server. - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - - // Display the data received from the server. - Console::WriteLine( readStream->ReadToEnd() ); - Console::WriteLine( "List status: {0}", response->StatusDescription ); - readStream->Close(); - response->Close(); - - // - Console::WriteLine( "Banner message: {0}", response->BannerMessage ); - // - - // - Console::WriteLine( "Welcome message: {0}", response->WelcomeMessage ); - // - - // - Console::WriteLine( "Exit message: {0}", response->ExitMessage ); - // - - return true; - } - - // -internal: - static FtpStatusCode WaitForFinalStatus( FtpWebResponse^ response ) - { - int status = (int)response->StatusCode; - - // < 200 is undefined or informational messages. - // 300 and 400 are intermediate and temporary errors respectively. - // 200- 299 and 500- 599 are final statuses indicating - // sucess or failure respectively. - while ( status < 200 || (status >= 300 && status < 500) ) - { - Console::Write( "{0}. ", status ); - System::Threading::Thread::Sleep( 100 ); - status = (int)response->StatusCode; - } - - return response->StatusCode; - } - - -public: - static void Main() - { - // tests for snippets: - // ListFilesOnServer(new Uri(S"ftp://sharriso1")); - // works m3.1 - // NameListFilesOnServer (new Uri (S"ftp://sharriso1")); - // throws - // GetDateTimestampOnServer (new Uri ("ftp://sharriso1")); - // GetDateTimestampOnServer (new Uri (S"ftp://sharriso1/localfile.txt")); - // RemoveDirectoryOnServer (new Uri (S"ftp://sharriso1/DirtyDir")); - // MakeDirectoryOnServer (new Uri (S"ftp://sharriso1/DirtyDir")); - // UploadUniqueFileOnServer (new Uri (S"ftp://sharriso1/SherdieDir/"), "sharriso2.log"); - // ListFilesOnServer (new Uri (S"ftp://sharriso1")); - ListFilesOnServerSsl( gcnew Uri( "ftp://sharriso1" ) ); - - // snippet 8 - not working - // snippet 1 - // ListFilesOnServer(new Uri("ftp://sharriso1/")); - // snippet 8 - not working - //SendCommandToServer("ftp://sharriso1/", "rename localfile.txt loc2.txt"); - // new snippet 7 - // upload is just helper - //UploadFileToServer("NCLFtpClient.xml", new Uri("ftp://sharriso1/NCLFtpClient.xml")); - // RestartDownloadFromServer("piecexml.txt", new Uri("ftp://sharriso1/NCLFtpClient.xml"), 8); - // DownloadFileFromServer(new Uri("ftp://sharriso1/onesandtwos.txt"), "downloadedFile0320_1.txt"); - // snippet 11 - GetFileSizeFromServer( gcnew Uri( "ftp://sharriso1/localfile.txt" ) ); - - // snippet 5 - // DisplayFileFromServer Not working! - // DisplayFileFromServer(new Uri("ftp://sharriso1/ss1.txt")); - // snippet 2 - // UploadFileToServer("local.txt", new Uri("ftp://sharriso1/localfile.txt")); - //DeleteFileOnServer(new Uri("ftp://sharriso1/localfile.txt")); - // DownloadFileFromServer(new Uri("ftp://sharriso1/localFileagain.txt"), "dlagain.txt"); - // AppendFileOnServer("dlagain.txt", new Uri("ftp://sharriso1/localfile.txt")); - // Snippet 14, 15, and 16 - // GetRequestProperties(new Uri("ftp://sharriso1/localfile.txt")); - // Snippet 9 - // DownloadFileFromServer(new Uri("ftp://sharriso1/localFileagain.txt"), "dlagain.txt"); - //AsynchronousUploadFileToServer( "system.pdb","ftp://sharriso1/localFile.pdb"); - // ListFilesOnServer(new Uri("ftp://sharriso1")); - //DownloadFileFromServer(new Uri("ftp://sharriso1/localFileagain.txt"), "dlagain.txt"); - //UploadPartialFileOnServer("allOnes.txt", "ftp://sharriso1/babyones.txt", 20 ); - // TestCloning(); - // test the async methods - // ManualResetEvent wait = new ManualResetEvent(false); - // AsynchronousFtpUpLoader uploader = new AsynchronousFtpUpLoader(wait); - // uploader.AsynchronousUploadFileToServer("ftptests.cs", "ftp://sharriso1/ftptests.txt"); - // wait.WaitOne(); - // Snippet 10 - // ManualResetEvent wait = new ManualResetEvent(false); - // AsynchronousFtpUpLoader uploader = new AsynchronousFtpUpLoader(wait); - // uploader.AbortUpload("mscorlib.xml", "ftp://sharriso1/ftptests.txt"); - // wait.WaitOne(); - } -}; - - -// The RequestState class is the state object used to store the request information -// during asynchronous operations. -private ref class RequestState -{ -internal: - FtpWebRequest^ request; - Object^ requestData; - RequestState( FtpWebRequest ^theRequest, Object^ data ) - { - request = theRequest; - requestData = data; - } -}; - -public ref class AsynchronousFtpUpLoader -{ -private: - ManualResetEvent^ wait; - FtpWebRequest^ request; - array^fileContents; - Exception^ asyncException; - -public: - AsynchronousFtpUpLoader( ManualResetEvent^ wait ) - { - this->wait = wait; - } - - // In the AsynchronousUploadFileToServer method, - // serverUri contains the name of the file on the FTP server, and - // fileName contains the name of the file on the local computer. - void AsynchronousUploadFileToServer( String^ fileName, String^ serverUri ) - { - request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - - // Get the file to be uploaded and convert it to bytes. - StreamReader^ sourceStream = gcnew StreamReader( fileName ); - fileContents = Encoding::UTF8->GetBytes( sourceStream->ReadToEnd() ); - sourceStream->Close(); - - // Set the content length to the number of bytes in the file. - request->ContentLength = fileContents->Length; - - // Asynchronously get the stream for the file contents. - IAsyncResult^ ar = request->BeginGetRequestStream( gcnew AsyncCallback( this, &AsynchronousFtpUpLoader::EndGetStreamCallback ), nullptr ); - Console::WriteLine( "Getting the request stream asynchronously..." ); - } - -private: - void EndGetStreamCallback( IAsyncResult^ ar ) - { - // Thread.Sleep(5000); - // Console.WriteLine("I'm awake now"); - Stream^ requestStream = nullptr; - - // End the asynchronous call to get the request stream. - try - { - requestStream = request->EndGetRequestStream( ar ); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Could not get the request stream." ); - asyncException = e; - wait->Set(); - return; - } - - // Write the file contents to the request stream. - requestStream->Write( fileContents, 0, fileContents->Length ); - Console::WriteLine( "Writing {0} bytes to the stream.", fileContents->Length ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - IAsyncResult^ responseAR = request->BeginGetResponse( gcnew AsyncCallback( this, &AsynchronousFtpUpLoader::EndGetResponseCallback ), nullptr ); - } - - // The EndGetResponseCallback method - // completes a call to BeginGetResponse. - void EndGetResponseCallback( IAsyncResult^ ar ) - { - FtpWebResponse^ response = nullptr; - try - { - response = dynamic_cast(request->EndGetResponse( ar )); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Error getting response." ); - asyncException = e; - } - - Console::WriteLine( "Upload status: {0}", response->StatusDescription ); - - // Signal the application thread that this is complete. - wait->Set(); - } - - // -public: - void AbortUpload( String^ fileName, String^ serverUri ) - { - request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // Get the file to be uploaded and convert it to bytes. - StreamReader^ sourceStream = gcnew StreamReader( fileName ); - fileContents = Encoding::UTF8->GetBytes( sourceStream->ReadToEnd() ); - sourceStream->Close(); - - // Set the content length to the number of bytes in the file. - request->ContentLength = fileContents->Length; - - // Asynchronously get the stream for the file contents. - IAsyncResult^ ar = request->BeginGetRequestStream( gcnew AsyncCallback( this, &AsynchronousFtpUpLoader::EndGetStreamCallback ), nullptr ); - Console::WriteLine( "Getting the request stream asynchronously..." ); - Console::WriteLine( "Press 'a' to abort the upload or any other key to continue" ); - String^ input = Console::ReadLine(); - if ( input->Equals( "a" ) ) - { - request->Abort(); - Console::WriteLine( "Request aborted" ); - return; - } - } - // -}; - -int main() -{ - FtpRequestTest::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp deleted file mode 100644 index caa3478f6592d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp +++ /dev/null @@ -1,1086 +0,0 @@ - -// NclMailSync -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; -using namespace System::Net::Mime; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::IO; -using namespace System::Text; - -public ref class CtorExamples -{ -public: - - // - static void CreateTestMessage1( String^ server, int port ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - String^ subject = L"Using the new SMTP client."; - String^ body = L"Using this new feature, you can send an email message from an application very easily."; - MailMessage^ message = gcnew MailMessage( from,to,subject,body ); - SmtpClient^ client = gcnew SmtpClient( server,port ); - - // Credentials are necessary if the server requires the client - // to authenticate before it will send email on the client's behalf. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - - //Display the properties on the service point. - ServicePoint^ p = client->ServicePoint; - Console::WriteLine( L"Connection lease timeout: {0}", p->ConnectionLeaseTimeout ); - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateTestMessage2( String^ server ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the new SMTP client."; - message->Body = L"Using this new feature, you can send an email message from an application very easily."; - SmtpClient^ client = gcnew SmtpClient( server ); - - // Credentials are necessary if the server requires the client - // to authenticate before it will send email on the client's behalf. - client->UseDefaultCredentials = true; - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateTimeoutTestMessage( String^ server ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - String^ subject = L"Using the new SMTP client."; - String^ body = L"Using this new feature, you can send an email message from an application very easily."; - MailMessage^ message = gcnew MailMessage( from,to,subject,body ); - SmtpClient^ client = gcnew SmtpClient( server ); - Console::WriteLine( L"Changing time out from {0} to 100.", client->Timeout ); - client->Timeout = 100; - - // Credentials are necessary if the server requires the client - // to authenticate before it will send email on the client's behalf. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - } - - - // - // - static void CreateTestMessage3() - { - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com" ); - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com" ); - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the new SMTP client."; - message->Body = L"Using this new feature, you can send an email message from an application very easily."; - - // Use the application or machine configuration to get the - // host, port, and credentials. - SmtpClient^ client = gcnew SmtpClient; - Console::WriteLine( L"Sending an email message to {0} at {1} by using the SMTP host {2}.", to->User, to->Host, client->Host ); - client->Send( message ); - } - - - // - // - static void CreateMessageWithMultipleViews( String^ server, String^ recipients ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",recipients,L"This email message has multiple views.",L"This is some plain text." ); - - // Construct the alternate body as HTML. - String^ body = L""; - body = String::Concat( body, L"" ); - body = String::Concat( body, L"
this is some HTML text" ); - body = String::Concat( body, L"
" ); - - // Add the alternate body to the message. - AlternateView^ alternate = AlternateView::CreateAlternateViewFromString(body); - message->AlternateViews->Add(alternate); - - // Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - - // Display the values in the ContentType for the attachment. - ContentType^ c = alternate->ContentType; - Console::WriteLine( L"Content type" ); - Console::WriteLine( c ); - Console::WriteLine( L"Boundary {0}", c->Boundary ); - Console::WriteLine( L"CharSet {0}", c->CharSet ); - Console::WriteLine( L"MediaType {0}", c->MediaType ); - Console::WriteLine( L"Name {0}", c->Name ); - Console::WriteLine( L"Parameters: {0}", c->Parameters->Count ); - IEnumerator^ myEnum = c->Parameters->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - - Console::WriteLine(); - alternate->~AlternateView(); - } - - - //
- // - static void CreateMessageWithAttachment( String^ server ) - { - - // Specify the file to be attached and sent. - // This example assumes that a file named Data.xls exists in the - // current working directory. - String^ file = L"data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"Quarterly data report.",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment(file, MediaTypeNames::Application::Octet); - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - - // Display the values in the ContentDisposition for the attachment. - ContentDisposition^ cd = data->ContentDisposition; - Console::WriteLine( L"Content disposition" ); - Console::WriteLine( cd ); - Console::WriteLine( L"File {0}", cd->FileName ); - Console::WriteLine( L"Size {0}", cd->Size ); - Console::WriteLine( L"Creation {0}", cd->CreationDate ); - Console::WriteLine( L"Modification {0}", cd->ModificationDate ); - Console::WriteLine( L"Read {0}", cd->ReadDate ); - Console::WriteLine( L"Inline {0}", cd->Inline ); - Console::WriteLine( L"Parameters: {0}", cd->Parameters->Count ); - IEnumerator^ myEnum1 = cd->Parameters->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum1->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateTestMessage4( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com" ); - MailAddress^ to = gcnew MailAddress( L"Jane@contoso.com" ); - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - SmtpClient^ client = gcnew SmtpClient( server ); - Console::WriteLine( L"Sending an email message to {0} by using SMTP host {1} port {2}.", to, client->Host, client->Port ); - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateTestMessage5( String^ server ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - String^ subject = L"Using the new SMTP client."; - String^ body = L"Using this new feature, you can send an email message from an application very easily."; - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( from, to, subject, body ); - client->~SmtpClient(); - } - - - // - // - static void CreateBccTestMessage( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com",L"Ben Miller" ); - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com",L"Jane Clayton" ); - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - MailAddress^ bcc = gcnew MailAddress( L"manager1@contoso.com" ); - message->Bcc->Add( bcc ); - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - Console::WriteLine( L"Sending an email message to {0} and {1}.", to->DisplayName, message->Bcc ); - try - { - client->Send( message ); - } - catch ( Exception^ ex ) - { - Console::WriteLine(L"Exception caught in CreateBccTestMessage(): {0}", - ex->ToString() ); - } - client->~SmtpClient(); - } - - - // - // - static void CreateCopyMessage( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com",L"Ben Miller" ); - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com",L"Jane Clayton" ); - MailMessage^ message = gcnew MailMessage( from,to ); - - // message.Subject = "Using the SmtpClient class."; - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - - // Add a carbon copy recipient. - MailAddress^ copy = gcnew MailAddress( L"Notification_List@contoso.com" ); - message->CC->Add( copy ); - SmtpClient^ client = gcnew SmtpClient( server ); - - // Include credentials if the server requires them. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - Console::WriteLine( L"Sending an email message to {0} by using the SMTP host {1}.", to->Address, client->Host ); - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageAttachment1( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"A text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain ); - ContentDisposition^ disposition = data->ContentDisposition; - - // Suggest a file name for the attachment. - disposition->FileName = String::Format( L"message{0}", DateTime::Now ); - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - - // Display the values in the ContentDisposition for the attachment. - Console::WriteLine( L"Content disposition" ); - Console::WriteLine( disposition ); - Console::WriteLine( L"File {0}", disposition->FileName ); - Console::WriteLine( L"Size {0}", disposition->Size ); - Console::WriteLine( L"Creation {0}", disposition->CreationDate ); - Console::WriteLine( L"Modification {0}", disposition->ModificationDate ); - Console::WriteLine( L"Read {0}", disposition->ReadDate ); - Console::WriteLine( L"Inline {0}", disposition->Inline ); - Console::WriteLine( L"Parameters: {0}", disposition->Parameters->Count ); - IEnumerator^ myEnum2 = disposition->Parameters->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum2->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageInlineAttachment( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"An inline text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain ); - - // Send textMessage as part of the email body. - message->Attachments->Add( data ); - ContentDisposition^ disposition = data->ContentDisposition; - disposition->Inline = true; - - //Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageInlineAttachment2( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"A text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage ); - - // Send textMessage as part of the email body. - message->Attachments->Add( data ); - ContentType^ content = data->ContentType; - content->MediaType = MediaTypeNames::Text::Plain; - - //Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - // The following example sends a summary of a log file as the message - // and the log as an email attachment. - static void SendErrorLog( String^ server, String^ recipientList ) - { - - // Create a message from logMailer@contoso.com to recipientList. - MailMessage^ message = gcnew MailMessage( L"logMailer@contoso.com",recipientList ); - message->Subject = L"Error Log report"; - String^ fileName = L"log.txt"; - - // Get the file stream for the error log. - // Requires the System.IO namespace. - FileStream^ fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - StreamReader^ s = gcnew StreamReader( fs ); - int errors = 0; - while ( s->ReadLine() != nullptr ) - { - - // Process each line from the log file here. - errors++; - } - - message->Body = String::Format( L"{0} errors in log as of {1}", errors, DateTime::Now ); - - // Close the stream reader. This also closes the file. - s->Close(); - - // Re-open the file at the beginning to make the attachment. - fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - - // Make a contentType indicating that the log data - // that is attached is plain text. - ContentType^ ct = gcnew ContentType( MediaTypeNames::Text::Plain ); - - // Attach the log file stream to the email message. - Attachment^ data = gcnew Attachment( fs,ct ); - ContentDisposition^ disposition = data->ContentDisposition; - - // Suggest a file name for the attachment. - disposition->FileName = String::Format( L"log{0}.txt", DateTime::Now ); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - // Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - - // Close the log file. - fs->Close(); - } - - - // - // - // The following example sends a summary of a log file as the message - // and the log as an email attachment. - static void SendNamedErrorLog( String^ server, String^ recipientList ) - { - - // Create a message from logMailer@contoso.com to recipientList. - MailMessage^ message = gcnew MailMessage( L"logMailer@contoso.com",recipientList ); - message->Subject = L"Error Log report"; - String^ fileName = L"log.txt"; - - // Get the file stream for the error log. - // Requires the System.IO namespace. - FileStream^ fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - StreamReader^ s = gcnew StreamReader( fs ); - int errors = 0; - while ( s->ReadLine() != nullptr ) - { - - // Process each line from the log file here. - errors++; - } - - message->Body = String::Format( L"{0} errors in log as of {1}", errors, DateTime::Now ); - - // Close the stream reader. This also closes the file. - s->Close(); - - // Re-open the file at the beginning to make the attachment. - fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - - // Make a ContentType indicating that the log data - // that is attached is plain text and is named. - ContentType^ ct = gcnew ContentType; - ct->MediaType = MediaTypeNames::Text::Plain; - ct->Name = String::Format( L"log{0}.txt", DateTime::Now ); - - // Create the attachment. - Attachment^ data = gcnew Attachment( fs,ct ); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - // Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - - // Close the log file. - fs->Close(); - return; - } - - - // - // - // The following example sends a summary of a log file as the message - // and the log as an email attachment. - static void SendNamedAndTypedErrorLog( String^ server, String^ recipientList ) - { - - // Create a message from logMailer@contoso.com to recipientList. - MailMessage^ message = gcnew MailMessage( L"logMailer@contoso.com",recipientList ); - message->Subject = L"Error Log report"; - String^ fileName = L"log.txt"; - - // Get the file stream for the error log. - // Requires the System.IO namespace. - FileStream^ fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - StreamReader^ s = gcnew StreamReader( fs ); - int errors = 0; - while ( s->ReadLine() != nullptr ) - { - - // Process each line from the log file here. - errors++; - } - - message->Body = String::Format( L"{0} errors in log as of {1}", errors, DateTime::Now ); - - // Close the stream reader. This also closes the file. - s->Close(); - - // Re-open the file at the beginning to make the attachment. - fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - - // Create a name for the log data file. - String^ name = String::Format( L"log{0}.txt", DateTime::Now ); - - // Create the attachment, name it, and specify the MIME type. - Attachment^ data = gcnew Attachment( fs,name,MediaTypeNames::Text::Plain ); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - // Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - - // Close the log file. - fs->Close(); - } - - - // - // - static Attachment^ SendAttachedMessage( String^ server ) - { - - // Set up the sender information. - String^ from = String::Concat( Environment::UserDomainName, L".", Environment::UserName, L"@contoso.com" ); - Console::WriteLine( L"From: {0}", from ); - - // Have the user enter the message recipient. - Console::Write( L"To: " ); - String^ recipient = Console::ReadLine(); - - // Check for recipient data. - // A real application would add error checking here for a valid email - // address format. This example accepts any input. - if ( recipient->Length == 0 ) - return nullptr; - - - // Get the subject. - Console::Write( L"Subject: " ); - String^ subject = Console::ReadLine(); - - // Get the message content. - Console::WriteLine( L"Enter the message. Press return on a blank line to finish:" ); - StringBuilder^ sb = gcnew StringBuilder; - String^ line; - while ( true ) - { - line = Console::ReadLine(); - if ( line->Length > 0 ) - { - - // Store the message and the end-of-line characters. - sb->AppendFormat( L"{0},{1}", line, Environment::NewLine ); - } - else - break; - } - - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( from,recipient ); - message->Subject = subject; - - // Attach the message string to this email message. - // Set the encoding to the computer's current encoding. - Attachment^ data = gcnew Attachment( sb->ToString(),MediaTypeNames::Text::Plain); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - //Send the message. Supply credentials if necessary. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - Console::WriteLine( L"Ready to send. Press enter to send. Type any character to quit:" ); - String^ answer = Console::ReadLine(); - if ( answer->Length == 0 ) - { - client->Send( message ); - Console::WriteLine( L"Message sent." ); - } - else - { - Console::WriteLine( L"Send canceled." ); - } - - client->~SmtpClient(); - return data; - } - - - // - // - static void CreateMessageWithFile( String^ server, String^ to ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to ); - message->Subject = L"Monthly Expense report"; - message->Body = L"Please review the attached report."; - - // Attach a file to this email message. - Attachment^ data = gcnew Attachment("data.xls", MediaTypeNames::Application::Octet); - AttachmentCollection^ attachments = message->Attachments; - attachments->Add( data ); - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void DisplayFileAttachment( Attachment^ a ) - { - Console::WriteLine( L"Content Disposition {0}", a->ContentDisposition ); - Console::WriteLine( L"Content Type {0}", a->ContentType ); - Console::WriteLine( L"Name {0}", a->Name ); - } - - - // - // - static void DisplayStringAttachment( Attachment^ a ) - { - Console::WriteLine( L"Content: {0}", a->ContentType ); - Console::WriteLine( L"Encoding {0}", a->TransferEncoding ); - Console::WriteLine( L"Content Disposition {0}", a->ContentDisposition->ToString() ); - Console::WriteLine( L"Content Type {0}", a->ContentType->ToString() ); - } - - - // - // - static void DisplayStreamAttachment( Attachment^ a ) - { - Stream^ s = a->ContentStream; - StreamReader^ reader = gcnew StreamReader( s ); - Console::WriteLine( L"Content: {0}", reader->ReadToEnd() ); - Console::WriteLine( L"Content Type {0}", a->ContentType ); - Console::WriteLine( L"Transfer Encoding {0}", a->TransferEncoding ); - - // Note that you cannot close the reader before the email is sent. - // Closing the reader before sending the email will close the - // ContentStream and cause an SmtpException. - reader = nullptr; - } - - - // - // - static void CreateMessageWithAttachment2( String^ server, String^ to ) - { - - // Specify the file to be attached and sent. - // This example assumes that a file named Data.xls exists in the - // current working directory. - String^ file = L"data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment(file); - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageWithAttachment3( String^ server, String^ to ) - { - - // Specify the file to be attached and sent. - // This example assumes that a file named data.xls exists in the - // current working directory. - String^ file = L"data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment("Qtr3.xls"); - - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - - // Notify user if an error occurs. - try - { - client->Send( message ); - } - catch ( SmtpException^ e ) - { - Console::WriteLine( L"Error: {0}", e->StatusCode ); - } - finally - { - data->~Attachment(); - client->~SmtpClient(); - } - - } - - - // - // - static void CreateMessageWithAttachment4( String^ server, String^ to ) - { - - // Specify the file to be attached and sent. - // This example uses a file on a UNC share. - String^ file = L"\\\\share3\\c$\\reports\\data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment("qtr3.xls", MediaTypeNames::Application::Octet); - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - disposition->DispositionType = DispositionTypeNames::Attachment; - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - - // Display the message headers. - array^keys = message->Headers->AllKeys; - Console::WriteLine( L"Headers" ); - IEnumerator^ myEnum3 = keys->GetEnumerator(); - while ( myEnum3->MoveNext() ) - { - String^ s = safe_cast(myEnum3->Current); - Console::WriteLine( L"{0}:", s ); - Console::WriteLine( L" {0}", message->Headers[ s ] ); - } - - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageAttachment5( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"A text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment(textMessage, - MediaTypeNames::Text::Plain); - ContentDisposition^ disposition = data->ContentDisposition; - - // Suggest a file name for the attachment. - disposition->FileName = String::Format( L"message{0}", DateTime::Now ); - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageInlineAttachment3( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"An inline text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain ); - - // Send textMessage as part of the email body. - message->Attachments->Add( data ); - ContentDisposition^ disposition = data->ContentDisposition; - disposition->DispositionType = DispositionTypeNames::Inline; - - //Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void RetryIfBusy( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com" ); - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com" ); - MailMessage^ message = gcnew MailMessage( from,to ); - - // message.Subject = "Using the SmtpClient class."; - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - - // Add a carbon copy recipient. - MailAddress^ copy = gcnew MailAddress( L"Notifications@contoso.com" ); - message->CC->Add( copy ); - SmtpClient^ client = gcnew SmtpClient( server ); - - // Include credentials if the server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - Console::WriteLine( L"Sending an email message to {0} using the SMTP host {1}.", to->Address, client->Host ); - try - { - client->Send( message ); - } - catch ( SmtpFailedRecipientsException^ ex ) - { - for ( int i = 0; i < ex->InnerExceptions->Length; i++ ) - { - SmtpStatusCode status = ex->InnerExceptions[ i ]->StatusCode; - if ( status == SmtpStatusCode::MailboxBusy || status == SmtpStatusCode::MailboxUnavailable ) - { - Console::WriteLine( L"Delivery failed - retrying in 5 seconds." ); - System::Threading::Thread::Sleep( 5000 ); - client->Send( message ); - } - else - { - Console::WriteLine( L"Failed to deliver message to {0}", ex->InnerExceptions[ i ] ); - } - - } - } - catch ( Exception^ ex ) - { - Console::WriteLine(L"Exception caught in RetryIfBusy(): {0}", - ex->ToString() ); - } - finally - { - client->~SmtpClient(); - } - } - - - // - // silly snippets to get code coverage in exceptions! - // - static SmtpException^ GenerateDefaultSmtpException() - { - return gcnew SmtpException; - } - - - // - // - static SmtpException^ GenerateSmtpException( String^ message ) - { - return gcnew SmtpException( message ); - } - - - // - // - static SmtpException^ GenerateSmtpException( SmtpStatusCode status ) - { - return gcnew SmtpException( status ); - } - - - // - // - static SmtpException^ GenerateSmtpException( SmtpStatusCode status, String^ message ) - { - return gcnew SmtpException( status,message ); - } - - - // - // - static SmtpException^ GenerateSmtpException( String^ message, Exception^ innerException ) - { - return gcnew SmtpException( message,innerException ); - } - - - // - static void CreateSampleDispositions() - { - - // - ContentDisposition^ c1 = gcnew ContentDisposition; - Console::WriteLine( c1 ); - - // - // - ContentDisposition^ c2 = gcnew ContentDisposition( L"attachment" ); - Console::WriteLine( c2 ); - - // - ContentDisposition^ c3 = gcnew ContentDisposition( L"Attachment; filename = myFile;" ); - Console::WriteLine( c3 ); - } - - static void DumpMailAddress( MailAddress^ a ) - { - Console::WriteLine( L"Display: {0} Host: {1} User: {2} Address: {3}", a->DisplayName, a->Host, a->User, a->Address ); - } - - static void CreateSampleAddresses() - { - MailAddress^ a1 = gcnew MailAddress( L"Ben Miller " ); - Console::WriteLine( a1 ); - DumpMailAddress( a1 ); - - // WRONG but legal: Should not include angle brackets. - MailAddress^ a2 = gcnew MailAddress( L"" ); - Console::WriteLine( a2 ); - DumpMailAddress( a2 ); - MailAddress^ a3 = gcnew MailAddress( L"ben.address1@contoso.com" ); - Console::WriteLine( a3 ); - DumpMailAddress( a3 ); - - // Use a constructor that takes an address and the display name separately. - // Throwing a format exception - // MailAddress a4 = new MailAddress("tom@contoso.com", "Tom Smith"); - // Console.WriteLine(a4.ToString()); - // DumpMailAddress(a4); - // WRONG: Should not include angle brackets. - // MailAddress a5 = new MailAddress(" ", "Tom Smith"); - // Console.WriteLine(a5.ToString()); - // DumpMailAddress(a5); - // WRONG but legal: Should not include display name as part of address. - MailAddress^ a6 = gcnew MailAddress( L"Tom Smith",L"Bill Jones" ); - Console::WriteLine( a6 ); - DumpMailAddress( a6 ); - MailAddress^ a7 = gcnew MailAddress( L"tom@contoso.com",L" Tom Smith " ); - Console::WriteLine( a7 ); - DumpMailAddress( a7 ); - } - - static void DisplayContentType( ContentType^ c ) - { - Console::WriteLine( L"Boundary {0}", c->Boundary ); - Console::WriteLine( L"Charset {0}", c->CharSet ); - Console::WriteLine( L"MediaType {0}", c->MediaType ); - Console::WriteLine( L"Name {0}", c->Name ); - Console::WriteLine( L"Parameters: {0}", c->Parameters->Count ); - IEnumerator^ myEnum4 = c->Parameters->GetEnumerator(); - while ( myEnum4->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum4->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - } - - static void CreateContentTypes() - { - ContentType^ c1 = gcnew ContentType; - Console::WriteLine( L"---c1 {0}", c1 ); - DisplayContentType( c1 ); - ContentType^ c2 = gcnew ContentType( L"text/html" ); - Console::WriteLine( L"---c2 {0}", c2 ); - DisplayContentType( c2 ); - ContentType^ c3 = gcnew ContentType( L"application/x-myPrivateSubtype; name=data.xyz; charset=us-ascii" ); - Console::WriteLine( L"---c3 {0}", c3 ); - DisplayContentType( c3 ); - } - - - // The first argument is the recipient. - // The second argument is the sender. - void NCLMailSyncRun() - { - - // CreateTestMessage2(args[0]); - //CreateMessageInlineAttachment3("smarthost", "string textMessage"); - //CreateTestMessage3(); - //CreateTestMessage4(args[0]); - // CreateTestMessageX(args[0]); - //CreateMessageWithMultipleViews("smarthost","sharriso@microsoft.com"); - CreateBccTestMessage( L"sharriso1" ); - - //CreateCopyMessage("sharriso1"); - // CreateMessageWithMultipleRecipients("sharriso1"); - //CreateTestMessageY("sharriso1"); - //CreateMessageWithAttachment("smarthost"); - //CreateContentTypes(); - // CreateMessageWithMultipleRecipients("smarthost"); - //CreateSampleAddresses(); - // CreateMessageAttachment1("smarthost", "This is an attached message."); - //CreateMessageInlineAttachment("sharriso1", "How cool is this?"); - //CreateMessageInlineAttachment2("smarthost", "This is an attached message."); - //SendErrorLog("smarthost", "sharriso@microsoft.com"); - //Attachment log = SendNamedErrorLog("smarthost", "sharriso@microsoft.com"); - //SendNamedAndTypedErrorLog("smarthost", "sharriso@microsoft.com"); - //Attachment a = SendAttachedMessage("smarthost"); - //DisplayStringAttachment(a); - // CreateMessageWithFile("smarthost", "sharriso@microsoft.com"); - // CreateMessageWithAttachment2("smarthost", "sharriso@microsoft.com"); - // CreateMessageWithAttachment3("xx","sharriso@microsoft.com"); - // CreateMessageWithAttachment4("smarthost", "sharriso@microsoft.com"); - // CreateMessageAttachment5("sharriso1", "string textMessage"); - //CreateSampleDispositions(); - RetryIfBusy("sharriso1"); - } - -}; - -void main() -{ - CtorExamples^ ce = gcnew CtorExamples; - ce->NCLMailSyncRun(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp deleted file mode 100644 index 7e698f37f1fc7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp +++ /dev/null @@ -1,1015 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::Net::Sockets; - -// -void GetTcpConnections() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^connections = properties->GetActiveTcpConnections(); - System::Collections::IEnumerator^ myEnum = connections->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - TcpConnectionInformation ^ t = safe_cast(myEnum->Current); - Console::Write( "Local endpoint: {0} ", t->LocalEndPoint->Address ); - Console::Write( "Remote endpoint: {0} ", t->RemoteEndPoint->Address ); - Console::WriteLine( "{0}", t->State ); - } -} -// - -// -void CountTcpConnections() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^connections = properties->GetActiveTcpConnections(); - int establishedConnections = 0; - System::Collections::IEnumerator^ myEnum1 = connections->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - TcpConnectionInformation ^ t = safe_cast(myEnum1->Current); - if ( t->State == TcpState::Established ) - { - establishedConnections++; - } - - Console::Write( "Local endpoint: {0} ", t->LocalEndPoint->Address ); - Console::WriteLine( "Remote endpoint: {0} ", t->RemoteEndPoint->Address ); - } - - Console::WriteLine( "There are {0} established TCP connections.", establishedConnections ); -} -// - -// -void DisplayActiveUdpListeners() -{ - Console::WriteLine( "Active UDP Listeners" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^endPoints = properties->GetActiveUdpListeners(); - System::Collections::IEnumerator^ myEnum2 = endPoints->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - IPEndPoint^ e = safe_cast(myEnum2->Current); - Console::WriteLine( e ); - } -} -// - -// -void ShowNetworkInterfaces() -{ - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - if ( !nics || nics->Length < 1 ) - { - Console::WriteLine( " No network interfaces found." ); - return; - } - - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "Interface information for {0}.{1}", properties->HostName, properties->DomainName ); - Console::WriteLine( " Number of interfaces .................... : {0}", nics->Length ); - System::Collections::IEnumerator^ myEnum3 = nics->GetEnumerator(); - while ( myEnum3->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum3->Current); - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - } -} -// - -// -void ShowTcpTimeouts() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( " Minimum Transmission Timeout............. : {0}", - tcpstat->MinimumTransmissionTimeout ); - Console::WriteLine( " Maximum Transmission Timeout............. : {0}", - tcpstat->MaximumTransmissionTimeout ); - Console::WriteLine( " Maximum connections ............. : {0}", - tcpstat->MaximumConnections ); -} -// - -// -void ShowTcpConnectionStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( " Connection Data:" ); - Console::WriteLine( " Current ............................ : {0}", - tcpstat->CurrentConnections ); - Console::WriteLine( " Cumulative .......................... : {0}", - tcpstat->CumulativeConnections ); - Console::WriteLine( " Initiated ........................... : {0}", - tcpstat->ConnectionsInitiated ); - Console::WriteLine( " Accepted ............................ : {0}", - tcpstat->ConnectionsAccepted ); - Console::WriteLine( " Failed Attempts ..................... : {0}", - tcpstat->FailedConnectionAttempts ); - Console::WriteLine( " Reset ............................... : {0}", - tcpstat->ResetConnections ); - Console::WriteLine( " Errors .............................. : {0}", - tcpstat->ErrorsReceived ); -} -// - -// -void ShowTcpSegmentData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( " Segment Data:" ); - Console::WriteLine( " Received ........................... : {0}", - tcpstat->SegmentsReceived ); - Console::WriteLine( " Sent ................................ : {0}", - tcpstat->SegmentsSent ); - Console::WriteLine( " Retransmitted ....................... : {0}", - tcpstat->SegmentsResent ); - Console::WriteLine( " Resent with reset ................... : {0}", - tcpstat->ResetsSent ); -} -// - -// -void ShowInterfaceByteCounts() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum4 = adapters->GetEnumerator(); - while ( myEnum4->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum4->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Bytes sent ............................: {0}", - stats->BytesSent ); - Console::WriteLine( " Bytes received ........................: {0}", - stats->BytesReceived ); - } -} -// - -// -void ShowUnicastCounts() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum5 = adapters->GetEnumerator(); - while ( myEnum5->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum5->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Unicast Packets Sent ..................: {0}", - stats->UnicastPacketsSent ); - Console::WriteLine( " Unicast Packets Received ..............: {0}", - stats->UnicastPacketsReceived ); - } -} -// - -// -void ShowNonUnicastCounts() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum6 = adapters->GetEnumerator(); - while ( myEnum6->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum6->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Non Unicast Packets Sent ..............: {0}", - stats->NonUnicastPacketsSent ); - Console::WriteLine( " Non Unicast Packets Received ..........: {0}", - stats->NonUnicastPacketsReceived ); - } -} -// - -// -void ShowPacketDiscards() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum7 = adapters->GetEnumerator(); - while ( myEnum7->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum7->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Incoming Packets Discarded ............: {0}", - stats->IncomingPacketsDiscarded ); - Console::WriteLine( " Outgoing Packets Discarded ............: {0}", - stats->OutgoingPacketsDiscarded ); - } -} -// - -// -void ShowPacketErrors() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum8 = adapters->GetEnumerator(); - while ( myEnum8->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum8->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Incoming Packets Errors ...............: {0}", - stats->IncomingPacketsWithErrors ); - Console::WriteLine( " Outgoing packets Errors ...............: {0}", - stats->OutgoingPacketsWithErrors ); - Console::WriteLine( " Incoming Unknown Protocol Errors ......: {0}", - stats->IncomingUnknownProtocolPackets ); - } -} -// - -// -void ShowInterfaceSpeedAndQueue() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum9 = adapters->GetEnumerator(); - while ( myEnum9->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum9->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Speed .................................: {0}", - adapter->Speed ); - Console::WriteLine( " Output queue length....................: {0}", - stats->OutputQueueLength ); - } -} -// - -// -void ShowIPStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Forwarding enabled ...................... : {0}", - ipstat->ForwardingEnabled ); - Console::WriteLine( " Interfaces .............................. : {0}", - ipstat->NumberOfInterfaces ); - Console::WriteLine( " IP addresses ............................ : {0}", - ipstat->NumberOfIPAddresses ); - Console::WriteLine( " Routes .................................. : {0}", - ipstat->NumberOfRoutes ); - Console::WriteLine( " Default TTL ............................. : {0}", - ipstat->DefaultTtl ); -} -// - -// -void ShowInboundIPStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Inbound Packet Data:" ); - Console::WriteLine( " Received ............................ : {0}", - ipstat->ReceivedPackets ); - Console::WriteLine( " Forwarded ........................... : {0}", - ipstat->ReceivedPacketsForwarded ); - Console::WriteLine( " Delivered ........................... : {0}", - ipstat->ReceivedPacketsDelivered ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->ReceivedPacketsDiscarded ); -} -// - -// -void ShowInboundIPErrors() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Inbound Packet Errors:" ); - Console::WriteLine( " Header Errors ....................... : {0}", - ipstat->ReceivedPacketsWithHeadersErrors ); - Console::WriteLine( " Address Errors ...................... : {0}", - ipstat->ReceivedPacketsWithAddressErrors ); - Console::WriteLine( " Unknown Protocol Errors ............. : {0}", - ipstat->ReceivedPacketsWithUnknownProtocol ); -} -// - -// -void ShowOutboundIPStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Outbound Packet Data:" ); - Console::WriteLine( " Requested ........................... : {0}", - ipstat->OutputPacketRequests ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->OutputPacketsDiscarded ); - Console::WriteLine( " No Routing Discards ................. : {0}", - ipstat->OutputPacketsWithNoRoute ); - Console::WriteLine( " Routing Entry Discards .............. : {0}", - ipstat->OutputPacketRoutingDiscards ); -} -// - -// -void ShowFragmentationStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Reassembly Data:" ); - Console::WriteLine( " Reassembly Timeout .................. : {0}", - ipstat->PacketReassemblyTimeout ); - Console::WriteLine( " Reassemblies Required ............... : {0}", - ipstat->PacketReassembliesRequired ); - Console::WriteLine( " Packets Reassembled ................. : {0}", - ipstat->PacketsReassembled ); - Console::WriteLine( " Packets Fragmented .................. : {0}", - ipstat->PacketsFragmented ); - Console::WriteLine( " Fragment Failures ................... : {0}", - ipstat->PacketFragmentFailures ); -} -// - -// -void ShowIcmpV4MessageData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", - statistics->MessagesSent, statistics->MessagesReceived ); -} -// - -// -void ShowIcmpV4EchoData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", - statistics->EchoRequestsSent, - statistics->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", - statistics->EchoRepliesSent, - statistics->EchoRepliesReceived ); -} -// - -// -void ShowIcmpV4ErrorData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", - statistics->ErrorsSent, - statistics->ErrorsReceived ); -} -// - -// -void ShowIcmpV4UnreachableData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", - statistics->DestinationUnreachableMessagesSent, - statistics->DestinationUnreachableMessagesReceived ); -} -// - -// -void ShowSourceQuenchData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Source Quenches ..................... Sent: {0,-10} Received: {1,-10}", - statistics->SourceQuenchesSent, - statistics->SourceQuenchesReceived ); -} -// - -// -void ShowRedirectsData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", - statistics->RedirectsSent, - statistics->RedirectsReceived ); -} -// - -// -void ShowTimeExceededData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", - statistics->TimeExceededMessagesSent, - statistics->TimeExceededMessagesReceived ); -} -// - -// -void ShowParameterData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", - statistics->ParameterProblemsSent, - statistics->ParameterProblemsReceived ); -} -// - -// -void ShowTimestampData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Timestamp Requests .................. Sent: {0,-10} Received: {1,-10}", - statistics->TimestampRequestsSent, - statistics->TimestampRequestsReceived ); - Console::WriteLine( " Timestamp Replies ................... Sent: {0,-10} Received: {1,-10}", - statistics->TimestampRepliesSent, - statistics->TimestampRepliesReceived ); -} -// - -// -void ShowAddressMaskData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Address Mask Requests ............... Sent: {0,-10} Received: {1,-10}", - statistics->AddressMaskRequestsSent, - statistics->AddressMaskRequestsReceived ); - Console::WriteLine( " Address Mask Replies ................ Sent: {0,-10} Received: {1,-10}", - statistics->AddressMaskRepliesSent, - statistics->AddressMaskRepliesReceived ); -} -// - -// -void ShowIcmpV6EchoData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", - statistics->EchoRequestsSent, statistics->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", - statistics->EchoRepliesSent, statistics->EchoRepliesReceived ); -} -// - -// -void ShowIcmpV6ErrorData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", - statistics->ErrorsSent, statistics->ErrorsReceived ); -} -// - -// -void ShowIcmpV6UnreachableData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", - statistics->DestinationUnreachableMessagesSent, - statistics->DestinationUnreachableMessagesReceived ); -} -// - -// -void ShowIcmpV6MessageData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", - statistics->MessagesSent, statistics->MessagesReceived ); -} -// - -// -void ShowIcmpV6MembershipData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Queries .............................. Sent: {0,-10} Received: {1,-10}", - statistics->MembershipQueriesSent, statistics->MembershipQueriesReceived ); - Console::WriteLine( " Reductions ........................... Sent: {0,-10} Received: {1,-10}", - statistics->MembershipReductionsSent, statistics->MembershipReductionsReceived ); - Console::WriteLine( " Reports .............................. Sent: {0,-10} Received: {1,-10}", - statistics->MembershipReportsSent, statistics->MembershipReportsReceived ); -} -// - -// -void ShowIcmpV6NeighborData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Advertisements ...................... Sent: {0,-10} Received: {1,-10}", - statistics->NeighborAdvertisementsSent, statistics->NeighborAdvertisementsReceived ); - Console::WriteLine( " Solicits ............................ Sent: {0,-10} Received: {1,-10}", - statistics->NeighborSolicitsSent, statistics->NeighborSolicitsReceived ); -} -// - -// -void ShowIcmpV6BigPacketData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Too Big Packet ........................ Sent: {0,-10} Received: {1,-10}", - statistics->PacketTooBigMessagesSent, - statistics->PacketTooBigMessagesReceived ); -} -// - -// -void ShowIcmpV6RedirectsData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", - statistics->RedirectsSent, - statistics->RedirectsReceived ); -} -// - -// -void ShowIcmpV6TimeExceededData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", - statistics->TimeExceededMessagesSent, - statistics->TimeExceededMessagesReceived ); -} -// - -// -void ShowIcmpV6ParameterData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", - statistics->ParameterProblemsSent, - statistics->ParameterProblemsReceived ); -} -// - -// -void ShowIcmpV6RouterData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Advertisements ....................... Sent: {0,-10} Received: {1,-10}", - statistics->RouterAdvertisementsSent, - statistics->RouterAdvertisementsReceived ); - Console::WriteLine( " Solicits ............................. Sent: {0,-10} Received: {1,-10}", - statistics->RouterSolicitsSent, - statistics->RouterSolicitsReceived ); -} -// - -// New content 10/29/03 -// -void DisplayDnsConfiguration() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum10 = adapters->GetEnumerator(); - while ( myEnum10->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum10->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " DNS suffix................................. :{0}", - properties->DnsSuffix ); - Console::WriteLine( " DNS enabled ............................. : {0}", - properties->IsDnsEnabled ); - Console::WriteLine( " Dynamically configured DNS .............. : {0}", - properties->IsDynamicDnsEnabled ); - } -} -// - -// -void DisplayDnsAddresses() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum11 = adapters->GetEnumerator(); - while ( myEnum11->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum11->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressCollection ^ dnsServers = adapterProperties->DnsAddresses; - if ( dnsServers->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum12 = dnsServers->GetEnumerator(); - while ( myEnum12->MoveNext() ) - { - IPAddress ^ dns = safe_cast(myEnum12->Current); - Console::WriteLine( " DNS Servers ............................. : {0}", - dns->ToString()); - } - } - } -} -// - -// -void DisplayAnycastAddresses() -{ - int count = 0; - - Console::WriteLine( "Anycast Addresses" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum13 = adapters->GetEnumerator(); - while ( myEnum13->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum13->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressInformationCollection ^ anyCast = adapterProperties->AnycastAddresses; - if ( anyCast->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum14 = anyCast->GetEnumerator(); - while ( myEnum14->MoveNext() ) - { - IPAddressInformation ^ any = safe_cast(myEnum14->Current); - Console::WriteLine( " Anycast Address .......................... : {0} {1} {2}", - any->Address, any->IsTransient ? "Transient" : "", - any->IsDnsEligible ? "DNS Eligible" : "" ); - count++; - } - Console::WriteLine(); - } - } - if (count == 0) - { - Console::WriteLine(" No anycast addresses were found."); - Console::WriteLine(); - } -} -// - -// -void DisplayMulticastAddresses() -{ - int count = 0; - - Console::WriteLine( "Multicast Addresses" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum15 = adapters->GetEnumerator(); - while ( myEnum15->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum15->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - MulticastIPAddressInformationCollection ^ multiCast = adapterProperties->MulticastAddresses; - if ( multiCast->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum16 = multiCast->GetEnumerator(); - while ( myEnum16->MoveNext() ) - { - MulticastIPAddressInformation ^ multi = safe_cast(myEnum16->Current); - Console::WriteLine( " Multicast Address ....................... : {0} {1} {2}", - multi->Address, multi->IsTransient ? "Transient" : "", - multi->IsDnsEligible ? "DNS Eligible" : "" ); - count++; - } - Console::WriteLine(); - } - } - if (count == 0) - { - Console::WriteLine(" No multicast addresses were found."); - Console::WriteLine(); - } -} -// - -// -void DisplayUnicastAddresses() -{ - Console::WriteLine( "Unicast Addresses" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum17 = adapters->GetEnumerator(); - while ( myEnum17->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum17->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - UnicastIPAddressInformationCollection ^ uniCast = adapterProperties->UnicastAddresses; - if ( uniCast->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - String^ lifeTimeFormat = "dddd, MMMM dd, yyyy hh:mm:ss tt"; - System::Collections::IEnumerator^ myEnum18 = uniCast->GetEnumerator(); - while ( myEnum18->MoveNext() ) - { - UnicastIPAddressInformation ^ uni = safe_cast(myEnum18->Current); - DateTime when; - Console::WriteLine( " Unicast Address ......................... : {0}", - uni->Address ); - Console::WriteLine( " Prefix Origin ........................ : {0}", - uni->PrefixOrigin ); - Console::WriteLine( " Suffix Origin ........................ : {0}", - uni->SuffixOrigin ); - Console::WriteLine( " Duplicate Address Detection .......... : {0}", - uni->DuplicateAddressDetectionState ); - - // Format the lifetimes as Sunday, February 16, 2003 11:33:44 PM - // if en-us is the current culture. - // Calculate the date and time at the end of the lifetimes. - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressValidLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Valid Life Time ...................... : {0}", - when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressPreferredLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Preferred life time .................. : {0}", - when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->DhcpLeaseLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " DHCP Leased Life Time ................ : {0}", - when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayDhcpServerAddresses() -{ - Console::WriteLine( "DHCP Servers" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum19 = adapters->GetEnumerator(); - while ( myEnum19->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum19->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressCollection ^ addresses = adapterProperties->DhcpServerAddresses; - if ( addresses->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum20 = addresses->GetEnumerator(); - while ( myEnum20->MoveNext() ) - { - IPAddress^ address = safe_cast(myEnum20->Current); - Console::WriteLine( " Dhcp Address ............................ : {0}", - address ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayGatewayAddresses() -{ - Console::WriteLine( "Gateways" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum21 = adapters->GetEnumerator(); - while ( myEnum21->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum21->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - GatewayIPAddressInformationCollection ^ addresses = adapterProperties->GatewayAddresses; - if ( addresses->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum22 = addresses->GetEnumerator(); - while ( myEnum22->MoveNext() ) - { - GatewayIPAddressInformation^ address = safe_cast(myEnum22->Current); - Console::WriteLine( " Gateway Address ......................... : {0}", - address->Address->ToString() ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayIPv4NetworkInterfaces() -{ - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "IPv4 interface information for {0}.{1}", properties->HostName, properties->DomainName ); - System::Collections::IEnumerator^ myEnum23 = nics->GetEnumerator(); - while ( myEnum23->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum23->Current); - - // Only display informatin for interfaces that support IPv4. - if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) == false ) - { - continue; - } - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - - // Underline the description. - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - - // Try to get the IPv4 interface properties. - IPv4InterfaceProperties ^ p = adapterProperties->GetIPv4Properties(); - if ( !p ) - { - Console::WriteLine( "No IPv4 information is available for this interface." ); - continue; - } - - // Display the IPv4 specific data. - Console::WriteLine( " Index ............................. : {0}", - p->Index ); - Console::WriteLine( " MTU ............................... : {0}", - p->Mtu ); - Console::WriteLine( " APIPA active....................... : {0}", - p->IsAutomaticPrivateAddressingActive ); - Console::WriteLine( " APIPA enabled...................... : {0}", - p->IsAutomaticPrivateAddressingEnabled ); - Console::WriteLine( " Forwarding enabled................. : {0}", - p->IsForwardingEnabled ); - Console::WriteLine( " Uses WINS ......................... : {0}", - p->UsesWins ); - } -} -// - -// -void DisplayIPv6NetworkInterfaces() -{ - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "IPv6 interface information for {0}.{1}", - properties->HostName, properties->DomainName ); - - int count = 0; - - System::Collections::IEnumerator^ myEnum24 = nics->GetEnumerator(); - while ( myEnum24->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum24->Current); - - // Only display informatin for interfaces that support IPv6. - if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) == false ) - { - continue; - } - - count++; - - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - - // Underline the description. - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - - // Try to get the IPv6 interface properties. - IPv6InterfaceProperties ^ p = adapterProperties->GetIPv6Properties(); - if ( !p ) - { - Console::WriteLine( "No IPv6 information is available for this interface." ); - continue; - } - - // Display the IPv6 specific data. - Console::WriteLine( " Index ............................. : {0}", - p->Index ); - Console::WriteLine( " MTU ............................... : {0}", - p->Mtu ); - } - if (count == 0) - { - Console::WriteLine(" No IPv6 interfaces were found."); - Console::WriteLine(); - } -} -// - -// -void DisplayWinsServerAddresses() -{ - Console::WriteLine( "WINS Servers" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum25 = adapters->GetEnumerator(); - while ( myEnum25->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum25->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressCollection ^ addresses = adapterProperties->WinsServersAddresses; - if ( addresses->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum26 = addresses->GetEnumerator(); - while ( myEnum26->MoveNext() ) - { - IPAddress^ address = safe_cast(myEnum26->Current); - Console::WriteLine( " WINS Server ............................ : {0}", - address ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayTypeAndAddress() -{ - IPGlobalProperties ^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - Console::WriteLine( "Interface information for {0}.{1} ", computerProperties->HostName, computerProperties->DomainName ); - System::Collections::IEnumerator^ myEnum27 = nics->GetEnumerator(); - while ( myEnum27->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum27->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - Console::WriteLine( " Physical Address ........................ : {0}", - adapter->GetPhysicalAddress() ); - Console::WriteLine( " Is receive only.......................... : {0}", - adapter->IsReceiveOnly ); - Console::WriteLine( " Multicast................................ : {0}", - adapter->SupportsMulticast ); - } -} -// - -int main() -{ - DisplayDnsAddresses(); - DisplayDnsConfiguration(); - DisplayAnycastAddresses(); - DisplayMulticastAddresses(); - DisplayUnicastAddresses(); - - DisplayDhcpServerAddresses(); - DisplayGatewayAddresses(); - - DisplayIPv4NetworkInterfaces(); - DisplayIPv6NetworkInterfaces(); - DisplayWinsServerAddresses(); - - DisplayTypeAndAddress(); - - GetTcpConnections(); - CountTcpConnections(); - DisplayActiveUdpListeners(); - ShowTcpSegmentData(); - ShowTcpConnectionStatistics(); - ShowTcpTimeouts(); - ShowInterfaceSpeedAndQueue(); - ShowPacketErrors(); - ShowPacketDiscards(); - ShowNonUnicastCounts(); - ShowUnicastCounts(); - ShowInterfaceByteCounts(); - ShowFragmentationStatistics(); - ShowOutboundIPStatistics(); - // - ShowInboundIPErrors(); - ShowInboundIPStatistics(); - ShowIPStatistics(); - if (Socket::OSSupportsIPv6) - { - ShowIcmpV6MessageData(); - ShowIcmpV6EchoData(); - ShowIcmpV6ErrorData(); - ShowIcmpV6UnreachableData (); - ShowIcmpV6RouterData (); - } - ShowRedirectsData(); - ShowTimeExceededData(); - if (Socket::OSSupportsIPv6) - { - ShowIcmpV6ParameterData (); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp deleted file mode 100644 index 850060ff81c7a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp +++ /dev/null @@ -1,603 +0,0 @@ - - -// Sample NCLNetInfoReport -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Net::NetworkInformation; -using namespace System::Text; - -// -void ShowIPStatistics( NetworkInterfaceComponent version ) -{ - // - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = nullptr; - switch ( version ) - { - case NetworkInterfaceComponent::IPv4: - ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( "{0}IPv4 Statistics ", Environment::NewLine ); - break; - - case NetworkInterfaceComponent::IPv6: - ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( "{0}IPv6 Statistics ", Environment::NewLine ); - break; - - default: - throw gcnew ArgumentException( "version" ); - break; - } - // - - Console::WriteLine( " Forwarding enabled ...................... : {0}", - ipstat->ForwardingEnabled ); - Console::WriteLine( " Interfaces .............................. : {0}", - ipstat->NumberOfInterfaces ); - Console::WriteLine( " IP addresses ............................ : {0}", - ipstat->NumberOfIPAddresses ); - Console::WriteLine( " Routes .................................. : {0}", - ipstat->NumberOfRoutes ); - Console::WriteLine( " Default TTL ............................. : {0}", - ipstat->DefaultTtl ); - Console::WriteLine( "" ); - Console::WriteLine( " Inbound Packet Data:" ); - Console::WriteLine( " Received ............................ : {0}", - ipstat->ReceivedPackets ); - Console::WriteLine( " Forwarded ........................... : {0}", - ipstat->ReceivedPacketsForwarded ); - Console::WriteLine( " Delivered ........................... : {0}", - ipstat->ReceivedPacketsDelivered ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->ReceivedPacketsDiscarded ); - Console::WriteLine( " Header Errors ....................... : {0}", - ipstat->ReceivedPacketsWithHeadersErrors ); - Console::WriteLine( " Address Errors ...................... : {0}", - ipstat->ReceivedPacketsWithAddressErrors ); - Console::WriteLine( " Unknown Protocol Errors ............. : {0}", - ipstat->ReceivedPacketsWithUnknownProtocol ); - Console::WriteLine( "" ); - Console::WriteLine( " Outbound Packet Data:" ); - Console::WriteLine( " Requested ........................... : {0}", - ipstat->OutputPacketRequests ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->OutputPacketsDiscarded ); - Console::WriteLine( " No Routing Discards ................. : {0}", - ipstat->OutputPacketsWithNoRoute ); - Console::WriteLine( " Routing Entry Discards .............. : {0}", - ipstat->OutputPacketRoutingDiscards ); - Console::WriteLine( "" ); - Console::WriteLine( " Reassembly Data:" ); - Console::WriteLine( " Reassembly Timeout .................. : {0}", - ipstat->PacketReassemblyTimeout ); - Console::WriteLine( " Reassemblies Required ............... : {0}", - ipstat->PacketReassembliesRequired ); - Console::WriteLine( " Packets Reassembled ................. : {0}", - ipstat->PacketsReassembled ); - Console::WriteLine( " Packets Fragmented .................. : {0}", - ipstat->PacketsFragmented ); - Console::WriteLine( " Fragment Failures ................... : {0}", - ipstat->PacketFragmentFailures ); - Console::WriteLine( "" ); -} -// - -// -void ShowTcpStatistics( NetworkInterfaceComponent version ) -{ - // - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = nullptr; - Console::WriteLine( "" ); - switch ( version ) - { - case NetworkInterfaceComponent::IPv4: - tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( "TCP/IPv4 Statistics:" ); - break; - - case NetworkInterfaceComponent::IPv6: - tcpstat = properties->GetTcpIPv6Statistics(); - Console::WriteLine( "TCP/IPv6 Statistics:" ); - break; - - default: - throw gcnew ArgumentException( "version" ); - break; - } - // - Console::WriteLine( " Minimum Transmission Timeout............. : {0}", - tcpstat->MinimumTransmissionTimeout ); - Console::WriteLine( " Maximum Transmission Timeout............. : {0}", - tcpstat->MaximumTransmissionTimeout ); - Console::WriteLine( " Connection Data:" ); - Console::WriteLine( " Current ............................ : {0}", - tcpstat->CurrentConnections ); - Console::WriteLine( " Cumulative .......................... : {0}", - tcpstat->CumulativeConnections ); - Console::WriteLine( " Initiated ........................... : {0}", - tcpstat->ConnectionsInitiated ); - Console::WriteLine( " Accepted ............................ : {0}", - tcpstat->ConnectionsAccepted ); - Console::WriteLine( " Failed Attempts ..................... : {0}", - tcpstat->FailedConnectionAttempts ); - Console::WriteLine( " Reset ............................... : {0}", - tcpstat->ResetConnections ); - Console::WriteLine( "" ); - Console::WriteLine( " Segment Data:" ); - Console::WriteLine( " Received ........................... : {0}", - tcpstat->SegmentsReceived ); - Console::WriteLine( " Sent ................................ : {0}", - tcpstat->SegmentsSent ); - Console::WriteLine( " Retransmitted ....................... : {0}", - tcpstat->SegmentsResent ); - Console::WriteLine( "" ); -} -// - -// -void ShowUdpStatistics( NetworkInterfaceComponent version ) -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - UdpStatistics ^ udpStat = nullptr; - switch ( version ) - { - case NetworkInterfaceComponent::IPv4: - udpStat = properties->GetUdpIPv4Statistics(); - Console::WriteLine( "UDP IPv4 Statistics" ); - break; - - case NetworkInterfaceComponent::IPv6: - udpStat = properties->GetUdpIPv6Statistics(); - Console::WriteLine( "UDP IPv6 Statistics" ); - break; - - default: - throw gcnew ArgumentException( "version" ); - break; - } - Console::WriteLine( " Datagrams Received ...................... : {0}", udpStat->DatagramsReceived ); - Console::WriteLine( " Datagrams Sent .......................... : {0}", udpStat->DatagramsSent ); - Console::WriteLine( " Incoming Datagrams Discarded ............ : {0}", udpStat->IncomingDatagramsDiscarded ); - Console::WriteLine( " Incoming Datagrams With Errors .......... : {0}", udpStat->IncomingDatagramsWithErrors ); - Console::WriteLine( " UDP Listeners ........................... : {0}", udpStat->UdpListeners ); - Console::WriteLine( "" ); -} -// - -// -void ShowEchoIcmpv4( IcmpV4Statistics ^ stat4 ) -{ - if ( stat4 != nullptr ) - { - Console::WriteLine( "ICMP v4 Echo Requests ................. Sent: {0,-10} Received: {1,-10}", stat4->EchoRequestsSent, stat4->EchoRequestsReceived ); - Console::WriteLine( "ICMP v4 Echo Replies .................. Sent: {0,-10} Received: {1,-10}", stat4->EchoRepliesSent, stat4->EchoRepliesReceived ); - } -} - -void ShowEchoIcmpv6( IcmpV6Statistics ^ stat6 ) -{ - if ( stat6 != nullptr ) - { - Console::WriteLine( "ICMP v6 Echo Requests.................. Sent: {0,-10} Received: {1,-10}", stat6->EchoRequestsSent, stat6->EchoRequestsReceived ); - Console::WriteLine( "ICMP v6 Echo Replies .................. Sent: {0,-10} Received: {1,-10}", stat6->EchoRepliesSent, stat6->EchoRepliesReceived ); - } -} - -// - -// -void ShowIcmpv4MessagesAndErrors( IcmpV4Statistics ^ stat4 ) -{ - if ( stat4 != nullptr ) - { - Console::WriteLine( "ICMP v4 Messages ...................... Sent: {0,-10} Received: {1,-10}", stat4->MessagesSent, stat4->MessagesReceived ); - Console::WriteLine( "ICMP v6 Errors ........................ Sent: {0,-10} Received: {1,-10}", stat4->ErrorsSent, stat4->ErrorsReceived ); - } - -} - -void ShowIcmpv6MessagesAndErrors( IcmpV6Statistics ^ stat6 ) -{ - if ( stat6 != nullptr ) - { - Console::WriteLine( "ICMP v6 Messages ...................... Sent: {0,-10} Received: {1,-10}", stat6->MessagesSent, stat6->MessagesReceived ); - Console::WriteLine( "ICMP v6 Errors ........................ Sent: {0,-10} Received: {1,-10}", stat6->ErrorsSent, stat6->ErrorsReceived ); - } -} -// - -// -void ShowIcmpV4Statistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ stat = properties->GetIcmpV4Statistics(); - Console::WriteLine( "ICMP V4 Statistics:" ); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", stat->MessagesSent, stat->MessagesReceived ); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", stat->ErrorsSent, stat->ErrorsReceived ); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", stat->EchoRequestsSent, stat->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", stat->EchoRepliesSent, stat->EchoRepliesReceived ); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", stat->DestinationUnreachableMessagesSent, stat->DestinationUnreachableMessagesReceived ); - Console::WriteLine( " Source Quenches ..................... Sent: {0,-10} Received: {1,-10}", stat->SourceQuenchesSent, stat->SourceQuenchesReceived ); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", stat->RedirectsSent, stat->RedirectsReceived ); - Console::WriteLine( " TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", stat->TimeExceededMessagesSent, stat->TimeExceededMessagesReceived ); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", stat->ParameterProblemsSent, stat->ParameterProblemsReceived ); - Console::WriteLine( " Timestamp Requests .................. Sent: {0,-10} Received: {1,-10}", stat->TimestampRequestsSent, stat->TimestampRequestsReceived ); - Console::WriteLine( " Timestamp Replies ................... Sent: {0,-10} Received: {1,-10}", stat->TimestampRepliesSent, stat->TimestampRepliesReceived ); - Console::WriteLine( " Address Mask Requests ............... Sent: {0,-10} Received: {1,-10}", stat->AddressMaskRequestsSent, stat->AddressMaskRequestsReceived ); - Console::WriteLine( " Address Mask Replies ................ Sent: {0,-10} Received: {1,-10}", stat->AddressMaskRepliesSent, stat->AddressMaskRepliesReceived ); - Console::WriteLine( "" ); -} -// - -// -void ShowIcmpV6Statistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ stat = properties->GetIcmpV6Statistics(); - Console::WriteLine( "ICMP V6 Statistics:" ); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", stat->MessagesSent, stat->MessagesReceived ); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", stat->ErrorsSent, stat->ErrorsReceived ); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", stat->EchoRequestsSent, stat->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", stat->EchoRepliesSent, stat->EchoRepliesReceived ); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", stat->DestinationUnreachableMessagesSent, stat->DestinationUnreachableMessagesReceived ); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", stat->ParameterProblemsSent, stat->ParameterProblemsReceived ); - Console::WriteLine( " Packets Too Big ..................... Sent: {0,-10} Received: {1,-10}", stat->PacketTooBigMessagesSent, stat->PacketTooBigMessagesReceived ); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", stat->RedirectsSent, stat->RedirectsReceived ); - Console::WriteLine( " Router Advertisements ............... Sent: {0,-10} Received: {1,-10}", stat->RouterAdvertisementsSent, stat->RouterAdvertisementsReceived ); - Console::WriteLine( " Router Solicitations ................ Sent: {0,-10} Received: {1,-10}", stat->RouterSolicitsSent, stat->RouterSolicitsReceived ); - Console::WriteLine( " Time Exceeded ....................... Sent: {0,-10} Received: {1,-10}", stat->TimeExceededMessagesSent, stat->TimeExceededMessagesReceived ); - Console::WriteLine( " Neighbor Advertisements ............. Sent: {0,-10} Received: {1,-10}", stat->NeighborAdvertisementsSent, stat->NeighborAdvertisementsReceived ); - Console::WriteLine( " Neighbor Solicitations .............. Sent: {0,-10} Received: {1,-10}", stat->NeighborSolicitsSent, stat->NeighborSolicitsReceived ); - Console::WriteLine( " Membership Queries .................. Sent: {0,-10} Received: {1,-10}", stat->MembershipQueriesSent, stat->MembershipQueriesReceived ); - Console::WriteLine( " Membership Reports .................. Sent: {0,-10} Received: {1,-10}", stat->MembershipReportsSent, stat->MembershipReportsReceived ); - Console::WriteLine( " Membership Reductions ............... Sent: {0,-10} Received: {1,-10}", stat->MembershipReductionsSent, stat->MembershipReductionsReceived ); - Console::WriteLine( "" ); -} -// - -// -void ShowIPAddresses( String^ label, IPAddressCollection^ addresses ) -{ - if ( addresses->Count == 0 ) - return; - -// Console::WriteLine( "{0} {1} ", label, addresses->Item[ 0 ] ); - if ( addresses->Count > 1 ) - { - for ( int i = 1; i < addresses->Count; i++ ) - { - String^ address = addresses->ToString(); - String^ line = address->PadLeft( label->Length + address->Length + 1 ); - Console::WriteLine( "{0}", line ); - - } - } -} -// - -// -void ShowIPAddresses( IPInterfaceProperties ^ adapterProperties ) -{ - // - IPAddressCollection ^ dnsServers = adapterProperties->DnsAddresses; - if ( dnsServers != nullptr ) - { - System::Collections::IEnumerator^ myEnum = dnsServers->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IPAddressInformation ^ dns = safe_cast(myEnum->Current); - Console::WriteLine( " DNS Servers ............................. : {0} ({1} {2})", - dns->Address, dns->IsTransient ? (String^)"Transient" : "", dns->IsDnsEligible ? (String^)"DNS Eligible" : "" ); - } - } - // - - IPAddressInformationCollection ^ anyCast = adapterProperties->AnycastAddresses; - if ( anyCast != nullptr ) - { - System::Collections::IEnumerator^ myEnum1 = anyCast->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - IPAddressInformation ^ any = safe_cast(myEnum1->Current); - Console::WriteLine( " Anycast Address .......................... : {0} {1} {2}", any->Address, any->IsTransient ? (String^)"Transient" : "", any->IsDnsEligible ? (String^)"DNS Eligible" : "" ); - } - - Console::WriteLine(); - } - - MulticastIPAddressInformationCollection ^ multiCast = adapterProperties->MulticastAddresses; - if ( multiCast != nullptr ) - { - System::Collections::IEnumerator^ myEnum2 = multiCast->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - IPAddressInformation ^ multi = safe_cast(myEnum2->Current); - Console::WriteLine( " Multicast Address ....................... : {0} {1} {2}", multi->Address, multi->IsTransient ? (String^)"Transient" : "", multi->IsDnsEligible ? (String^)"DNS Eligible" : "" ); - } - - Console::WriteLine(); - } - - // - UnicastIPAddressInformationCollection ^ uniCast = adapterProperties->UnicastAddresses; - if ( uniCast != nullptr ) - { - String^ lifeTimeFormat = "dddd, MMMM dd, yyyy hh:mm:ss tt"; - System::Collections::IEnumerator^ myEnum3 = uniCast->GetEnumerator(); - while ( myEnum3->MoveNext() ) - { - UnicastIPAddressInformation ^ uni = safe_cast(myEnum3->Current); - DateTime when; - Console::WriteLine( " Unicast Address ......................... : {0}", uni->Address ); - Console::WriteLine( " Prefix Origin ........................ : {0}", uni->PrefixOrigin ); - Console::WriteLine( " Suffix Origin ........................ : {0}", uni->SuffixOrigin ); - Console::WriteLine( " Duplicate Address Detection .......... : {0}", uni->DuplicateAddressDetectionState ); - - // Format the lifetimes as Sunday, February 16, 2003 11:33:44 PM - // if en-us is the current culture. - // Calculate the date and time at the end of the lifetimes. - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressValidLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Valid Life Time ...................... : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressPreferredLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Preferred life time .................. : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->DhcpLeaseLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " DHCP Leased Life Time ................ : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - } - - Console::WriteLine(); - } - // -} -// - -// -void ShowInterfaceStatistics( NetworkInterface ^ adapter ) -{ - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( "{0} Interface Statistics:", Environment::NewLine ); - Console::WriteLine( " Bytes sent ........................... : {0}", - stats->BytesSent ); - Console::WriteLine( " Bytes received ....................... : {0}", - stats->BytesReceived ); - Console::WriteLine( " Unicast Packets Sent ................. : {0}", - stats->UnicastPacketsSent ); - Console::WriteLine( " Unicast Packets Received ............. : {0}", - stats->UnicastPacketsReceived ); - Console::WriteLine( " Non Unicast Packets Sent ............. : {0}", - stats->NonUnicastPacketsSent ); - Console::WriteLine( " Non Unicast Packets Received ......... : {0}", - stats->NonUnicastPacketsReceived ); - Console::WriteLine( " Incoming Packets Discarded ........... : {0}", - stats->IncomingPacketsDiscarded ); - Console::WriteLine( " Outgoing Packets Discarded ........... : {0}", - stats->OutgoingPacketsDiscarded ); - Console::WriteLine( " Incoming Packets Errors .............. : {0}", - stats->IncomingPacketsWithErrors ); - Console::WriteLine( " Outgoing packets Errors .............. : {0}", - stats->OutgoingPacketsWithErrors ); - Console::WriteLine( " Incoming Unknown Protocol Errors ..... : {0}", - stats->IncomingUnknownProtocolPackets ); - Console::WriteLine( " Speed ................................ : {0}", - adapter->Speed ); - Console::WriteLine( " Output queue length................... : {0}", - stats->OutputQueueLength ); - Console::WriteLine(); -} -// - -// -void ShowNetworkInterfaces() -{ - IPGlobalProperties ^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - Console::WriteLine( "Interface information for {0}.{1} ", computerProperties->HostName, computerProperties->DomainName ); - if ( nics == nullptr || nics->Length < 1 ) - { - Console::WriteLine( " No network interfaces found." ); - return; - } - - Console::WriteLine( " Number of interfaces .................... : {0}", nics->Length ); - System::Collections::IEnumerator^ myEnum4 = nics->GetEnumerator(); - while ( myEnum4->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum4->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - Console::WriteLine( " Physical Address ........................ : {0}", - adapter->GetPhysicalAddress() ); - Console::WriteLine( " Operational status ...................... : {0}", - adapter->OperationalStatus ); - String^ versions = ""; - - // Create a display string for the supported IP versions. - if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) ) - { - versions = "IPv4"; - } - if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) ) - { - if ( versions->Length > 0 ) - { - versions = String::Concat( versions, " " ); - } - versions = String::Concat( versions, "IPv6" ); - } - Console::WriteLine( " IP version .............................. : {0}", - versions ); - ShowIPAddresses( properties ); - - // The following information is not useful for loopback adapters. - if ( adapter->NetworkInterfaceType == NetworkInterfaceType::Loopback ) - { - continue; - } - Console::WriteLine( " DNS suffix .............................. : {0}", - properties->DnsSuffix ); - String^ label; - - // - if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) ) - { - IPv4InterfaceProperties ^ ipv4 = properties->GetIPv4Properties(); - Console::WriteLine( " MTU...................................... : {0}", - ipv4->Mtu ); - if ( ipv4->UsesWins ) - { - IPAddressCollection ^ winsServers = properties->WinsServersAddresses; - if ( winsServers->Count > 0 ) - { - label = " WINS Servers ............................ :"; - ShowIPAddresses( label, winsServers ); - } - } - } - // - Console::WriteLine( " DNS enabled ............................. : {0}", - properties->IsDnsEnabled ); - Console::WriteLine( " Dynamically configured DNS .............. : {0}", - properties->IsDynamicDnsEnabled ); - Console::WriteLine( " Receive Only ............................ : {0}", - adapter->IsReceiveOnly ); - Console::WriteLine( " Multicast ............................... : {0}", - adapter->SupportsMulticast ); - ShowInterfaceStatistics( adapter ); - Console::WriteLine(); - } -} -// - - -// -void ShowInterfaceSummary() -{ - array^interfaces = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum5 = interfaces->GetEnumerator(); - while ( myEnum5->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum5->Current); - Console::WriteLine( "Name: {0}", adapter->Name ); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - Console::WriteLine( " Operational status ...................... : {0}", adapter->OperationalStatus ); - String^ versions = ""; - - // Create a display string for the supported IP versions. - if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) ) - { - versions = "IPv4"; - } - - if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) ) - { - if ( versions->Length > 0 ) - { - versions = String::Concat( versions, " " ); - } - - versions = String::Concat( versions, "IPv6" ); - } - - Console::WriteLine( " IP version .............................. : {0}", versions ); - Console::WriteLine(); - } - - Console::WriteLine(); -} -// - -// -void ShowActiveTcpConnections() -{ - Console::WriteLine( "Active TCP Connections" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^connections = properties->GetActiveTcpConnections(); - System::Collections::IEnumerator^ myEnum6 = connections->GetEnumerator(); - while ( myEnum6->MoveNext() ) - { - TcpConnectionInformation ^ c = safe_cast(myEnum6->Current); - Console::WriteLine( "{0} <==> {1}", c->LocalEndPoint, c->RemoteEndPoint ); - } -} -// - -// -void ShowActiveTcpListeners() -{ - Console::WriteLine( "Active TCP Listeners" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^endPoints = properties->GetActiveTcpListeners(); - System::Collections::IEnumerator^ myEnum7 = endPoints->GetEnumerator(); - while ( myEnum7->MoveNext() ) - { - IPEndPoint^ e = safe_cast(myEnum7->Current); - Console::WriteLine( e ); - } -} -// - -// -void ShowActiveUdpListeners() -{ - Console::WriteLine( "Active UDP Listeners" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^endPoints = properties->GetActiveUdpListeners(); - System::Collections::IEnumerator^ myEnum8 = endPoints->GetEnumerator(); - while ( myEnum8->MoveNext() ) - { - IPEndPoint^ e = safe_cast(myEnum8->Current); - Console::WriteLine( e ); - } -} -// - -int main() -{ - // - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "Computer name: {0}", properties->HostName ); - Console::WriteLine( "Domain name: {0}", properties->DomainName ); - Console::WriteLine( "Node type: {0:f}", properties->NodeType ); - Console::WriteLine( "DHCP scope: {0}", properties->DhcpScopeName ); - Console::WriteLine( "WINS proxy? {0}", properties->IsWinsProxy ); - // - - ShowActiveTcpConnections(); - ShowActiveTcpListeners(); - ShowActiveUdpListeners(); - if (Socket::SupportsIPv4) - { - ShowIcmpV4Statistics(); - } - if (Socket::OSSupportsIPv6) - { - ShowIcmpV6Statistics(); - } - ShowIPStatistics( NetworkInterfaceComponent::IPv4 ); - ShowTcpStatistics( NetworkInterfaceComponent::IPv4 ); - ShowUdpStatistics( NetworkInterfaceComponent::IPv4 ); - ShowEchoIcmpv4(properties->GetIcmpV4Statistics()); - ShowIcmpv4MessagesAndErrors(properties->GetIcmpV4Statistics()); - - if (Socket::OSSupportsIPv6) - { - ShowEchoIcmpv6(properties->GetIcmpV6Statistics()); - ShowIcmpv6MessagesAndErrors(properties->GetIcmpV6Statistics()); - } - - ShowNetworkInterfaces(); - ShowInterfaceSummary(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp deleted file mode 100644 index c3837c3296085..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp +++ /dev/null @@ -1,140 +0,0 @@ - -#using - -using namespace System; -using namespace System::Net::NetworkInformation; -using namespace System::Collections; - -// -void DisplayAddressNone() -{ - PhysicalAddress^ none = PhysicalAddress::None; - Console::WriteLine( L"None: {0}", none ); - array^bytes = none->GetAddressBytes(); - System::Collections::IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( L"{0} ", b.ToString() ); - } - - Console::WriteLine(); -} - - -// -// -void ShowNetworkInterfaces() -{ - IPGlobalProperties^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - Console::WriteLine( L"Interface information for {0}.{1} ", computerProperties->HostName, computerProperties->DomainName ); - if ( nics == nullptr || nics->Length < 1 ) - { - Console::WriteLine( L" No network interfaces found." ); - return; - } - - Console::WriteLine( L" Number of interfaces .................... : {0}", (nics->Length).ToString() ); - IEnumerator^ myEnum1 = nics->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - NetworkInterface^ adapter = safe_cast(myEnum1->Current); - IPInterfaceProperties^ properties = adapter->GetIPProperties(); - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( L" Interface type .......................... : {0}", adapter->NetworkInterfaceType ); - Console::Write( L" Physical address ........................ : " ); - PhysicalAddress^ address = adapter->GetPhysicalAddress(); - array^bytes = address->GetAddressBytes(); - for ( int i = 0; i < bytes->Length; i++ ) - { - - // Display the physical address in hexadecimal. - Console::Write( L"{0}", bytes[ i ].ToString( L"X2" ) ); - - // Insert a hyphen after each byte, unless we are at the end of the - // address. - if ( i != bytes->Length - 1 ) - { - Console::Write( L"-" ); - } - - } - Console::WriteLine(); - } -} - - -// -// -void ParseTest() -{ - PhysicalAddress^ address = PhysicalAddress::Parse( L"AC1EBA22" ); - Console::WriteLine( L"Address parsed as {0}", address->ToString() ); - PhysicalAddress^ address2 = PhysicalAddress::Parse( L"ac1eba22" ); - Console::WriteLine( L"Address2 parsed as {0}", address2->ToString() ); - bool test = address->Equals( address2 ); - Console::WriteLine( L"Equal? {0}", test ); -} - - -// -// -array^ StoreNetworkInterfaceAddresses() -{ - IPGlobalProperties^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - if ( nics == nullptr || nics->Length < 1 ) - { - Console::WriteLine( L" No network interfaces found." ); - return nullptr; - } - - array^ addresses = gcnew array(nics->Length); - int i = 0; - IEnumerator^ myEnum2 = nics->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - NetworkInterface^ adapter = safe_cast(myEnum2->Current); - IPInterfaceProperties^ properties = adapter->GetIPProperties(); - PhysicalAddress^ address = adapter->GetPhysicalAddress(); - array^bytes = address->GetAddressBytes(); - PhysicalAddress^ newAddress = gcnew PhysicalAddress( bytes ); - addresses[ i++ ] = newAddress; - } - - return addresses; -} - - -// -// -PhysicalAddress^ StrictParseAddress( String^ address ) -{ - PhysicalAddress^ newAddress = PhysicalAddress::Parse( address ); - if ( PhysicalAddress::None->Equals( newAddress ) ) - return nullptr; - - return newAddress; -} - - -// -int main() -{ - - DisplayAddressNone(); - ShowNetworkInterfaces(); - ParseTest(); - /* PhysicalAddress[] addresses = StoreNetworkInterfaceAddresses(); - foreach (PhysicalAddress address in addresses) - { - Console.WriteLine(address.ToString()); - } - */ - PhysicalAddress^ a = StrictParseAddress( nullptr ); - Console::WriteLine( a == nullptr ? L"null" : a->ToString() ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp deleted file mode 100644 index 845a8d231bd15..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp +++ /dev/null @@ -1,249 +0,0 @@ - - -//NCLPingSampler -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::Text; -using namespace System::Threading; - -// -void SimplePing(); -void ComplexPing(); -void LocalPing(); -void ComplexLocalPing(); -void LocalPingTimeout(); -void AsyncComplexLocalPing(); -void PingCompletedCallback( Object^ sender, PingCompletedEventArgs^ e ); - -int main() -{ - -// SimplePing(); - LocalPing(); Console::WriteLine(); -// ComplexPing(); Console::WriteLine(); - ComplexLocalPing(); Console::WriteLine(); - AsyncComplexLocalPing(); -} - - -// -void SimplePing() -{ - Ping ^ pingSender = gcnew Ping; - PingReply ^ reply = pingSender->Send( "www.contoso.com" ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void ComplexPing() -{ - Ping ^ pingSender = gcnew Ping; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - - // Send the request. - PingReply ^ reply = pingSender->Send( "www.contoso.com", timeout, buffer, options ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void LocalPing() -{ - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - IPAddress^ address = IPAddress::Loopback; - PingReply ^ reply = pingSender->Send( address ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void ComplexLocalPing() -{ - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - IPAddress^ address = IPAddress::Loopback; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - PingReply ^ reply = pingSender->Send( address, timeout, buffer, options ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void LocalPingTimeout() -{ - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - IPAddress^ address = IPAddress::Loopback; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - PingReply ^ reply = pingSender->Send( address, timeout, buffer); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void AsyncComplexLocalPing() -{ - - // Get an object that will block the main thread. - AutoResetEvent^ waiter = gcnew AutoResetEvent( false ); - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - - // When the PingCompleted event is raised, - // the PingCompletedCallback method is called. - pingSender->PingCompleted += gcnew PingCompletedEventHandler( PingCompletedCallback ); - IPAddress^ address = IPAddress::Loopback; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - - // Send the ping asynchronously. - // Use the waiter as the user token. - // When the callback completes, it can wake up this thread. - pingSender->SendAsync( address, timeout, buffer, options, waiter ); - - // Prevent this example application from ending. - // A real application should do something useful - // when possible. - waiter->WaitOne(); - Console::WriteLine( "Ping example completed." ); -} - - -// -// -void PingCompletedCallback( Object^ /*sender*/, PingCompletedEventArgs^ e ) -{ - - // If the operation was canceled, display a message to the user. - if ( e->Cancelled ) - { - Console::WriteLine( "Ping canceled." ); - } - - - // If an error occurred, display the exception to the user. - if ( e->Error != nullptr ) - { - Console::WriteLine( "Ping failed:" ); - Console::WriteLine( e->Error->ToString() ); - } - - PingReply ^ reply = e->Reply; - Console::WriteLine( reply->Status ); - - // Let the main thread resume. - (dynamic_cast(e->UserState))->Set(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp deleted file mode 100644 index 65f45fbe5eb57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp +++ /dev/null @@ -1,51 +0,0 @@ - - -// SampleID="NCLResponse1" -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::IO; - -// Specify the URL to receive the request. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - HttpWebRequest^ request = dynamic_cast(WebRequest::Create( args[ 1 ] )); - - // Set some reasonable limits on resources used by this request - request->MaximumAutomaticRedirections = 4; - request->MaximumResponseHeadersLength = 4; - - // Set credentials to use for this request. - request->Credentials = CredentialCache::DefaultCredentials; - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Content length is {0}", response->ContentLength ); - Console::WriteLine( "Content type is {0}", response->ContentType ); - - // Get the stream associated with the response. - Stream^ receiveStream = response->GetResponseStream(); - - // Pipes the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( receiveStream,Encoding::UTF8 ); - Console::WriteLine( "Response stream received." ); - Console::WriteLine( readStream->ReadToEnd() ); - response->Close(); - readStream->Close(); -} - -/* -The output from this example will vary depending on the value passed into Main -but will be similar to the following: - -Content length is 1542 -Content type is text/html; charset=utf-8 -Response stream received. - -... - - -*/ -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp deleted file mode 100644 index d9632b38b2c1b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::IO; -using namespace System::Threading; - -namespace SystemNetExamples -{ - public ref class ServicePointExample - { - public: - - // Pass in the name of the Web page to retrieve. - static void PrintResponse(String^ page) - { - - // Create the request. - HttpWebRequest^ request; - Uri^ uri; - - - - try - { - uri = gcnew Uri(page); - } - catch (UriFormatException^ ex) - { - Console::WriteLine(ex->Message); - } - - request = (HttpWebRequest^) WebRequest::Create(uri); - - // Get the service point that handles the request's - // socket connection. - ServicePoint^ point = request->ServicePoint; - - // Set the receive buffer size on the underlying socket. - point->ReceiveBufferSize = 2048; - - // Set the connection lease timeout to infinite. - point->ConnectionLeaseTimeout = Timeout::Infinite; - - // Send the request. - HttpWebResponse^ response = - (HttpWebResponse^) request->GetResponse(); - Stream^ responseStream = response->GetResponseStream(); - StreamReader^ streamReader = - gcnew StreamReader(responseStream); - try - { - // Display the response. - Console::WriteLine(streamReader->ReadToEnd()); - responseStream->Close(); - response->Close(); - } - finally - { - streamReader->Close(); - } - } - }; -} - -// - -using namespace SystemNetExamples; - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - String^ page; - - if ((args == nullptr)||(args->Length < 2)||(args[1]->Length == 0)) - { - page = "http://www.contoso.com/default.html"; - } - else - { - page = args[1]; - } - ServicePointExample::PrintResponse(page); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp deleted file mode 100644 index 0c201db6c1c43..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp +++ /dev/null @@ -1,274 +0,0 @@ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Cache; -using namespace System::IO; -using namespace System::Text; -using namespace System::Collections::Specialized; -using namespace System::Collections; - -public ref class CacheExample -{ -public: - - // - static WebResponse^ GetResponseUsingDefaultCache( Uri^ uri ) - { - // Set a cache policy level for the "http:" scheme. - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::Default ); - - // Create the request. - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy {0}.", policy ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - // The following method demonstrates overriding the - // caching policy for a request. - static WebResponse^ GetResponseNoCache( Uri^ uri ) - { - // Set a default policy level for the "http:" and "https" schemes. - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::Default ); - HttpWebRequest::DefaultCachePolicy = policy; - - // Create the request. - WebRequest^ request = WebRequest::Create( uri ); - - // Define a cache policy for this request only. - HttpRequestCachePolicy^ noCachePolicy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::NoCacheNoStore ); - request->CachePolicy = noCachePolicy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"IsFromCache? {0}", response->IsFromCache ); - - return response; - } - // - - // - static HttpRequestCachePolicy^ CreateLastSyncPolicy( DateTime when ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( when ); - Console::WriteLine( L"When: {0}", when ); - Console::WriteLine( policy->CacheSyncDate ); - return policy; - } - // - - // - static void DisplayPolicyDetails( HttpRequestCachePolicy^ policy ) - { - Console::WriteLine( L"Synchronize date: {0}", policy->CacheSyncDate ); - Console::WriteLine( L"Max age: {0}", policy->MaxAge ); - Console::WriteLine( L"Max stale: {0}", policy->MaxStale ); - Console::WriteLine( L"Min fresh: {0}", policy->MinFresh ); - } - // - - // - static HttpRequestCachePolicy^ CreateMinFreshPolicy( TimeSpan span ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MinFresh,span ); - Console::WriteLine( L"Minimum freshness {0}", policy->MinFresh ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateMaxStalePolicy( TimeSpan span ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxStale,span ); - Console::WriteLine( L"Max stale is {0}", policy->MaxStale ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateMaxAgePolicy( TimeSpan span ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAge,span ); - Console::WriteLine( L"Max age is {0}", policy->MaxAge ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateDefaultPolicy() - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy; - Console::WriteLine( policy ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateFreshAndAgePolicy( TimeSpan freshMinimum, TimeSpan ageMaximum ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAgeAndMinFresh, - ageMaximum, freshMinimum ); - Console::WriteLine( policy ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateFreshAndAgePolicy2( TimeSpan freshMinimum, TimeSpan ageMaximum, DateTime when ) - { - HttpRequestCachePolicy^ policy = - gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAgeAndMinFresh, - ageMaximum, freshMinimum, when ); - Console::WriteLine( policy ); - return policy; - - // For the following invocation: CreateFreshAndAgePolicy(new TimeSpan(5,0,0), new TimeSpan(10,0,0), ); - // the output is: - // Level:Automatic AgeControl:MinFreshAndMaxAge MinFresh:18000 MaxAge:36000 - } - // - - // - static WebResponse^ GetResponseUsingCacheDefault( Uri^ uri ) - { - // Set the default cache policy level for the "http:" scheme. - RequestCachePolicy^ policy = gcnew RequestCachePolicy; - - // Create the request. - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy level is {0}.", policy->Level ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - static HttpRequestCachePolicy^ CreateCacheIfAvailablePolicy() - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::CacheIfAvailable ); - Console::WriteLine( policy ); - return policy; - } - // - - // - static WebResponse^ GetResponseFromCache( Uri^ uri ) - { - RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::CacheOnly ); - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy level is {0}.", policy->Level ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - static WebResponse^ GetResponseFromServer( Uri^ uri ) - { - RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::NoCacheNoStore ); - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy is {0}.", policy ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - static WebResponse^ GetResponseFromServer2( Uri^ uri ) - { - RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::NoCacheNoStore ); - WebRequest^ request = WebRequest::Create( uri ); - WebRequest::DefaultCachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy is {0}.", policy ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - void TestSimpleCache() - { - /* WebResponse response = GetResponseUsingDefaultCache (new Uri("http://www.example.com")); - DisplayResponseStream (response); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - response = GetResponseNoCache (new Uri("http://www.example.com")); - DisplayResponseStream (response); - - DisplayPolicyDetails(CreateLastSyncPolicy(DateTime.Now)); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateMinFreshPolicy(new TimeSpan(10,0,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateMaxStalePolicy(new TimeSpan(1,10,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - DisplayPolicyDetails(CreateMaxAgePolicy(new TimeSpan(10,0,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateDefaultPolicy()); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateFreshAndAgePolicy(new TimeSpan(5,0,0), new TimeSpan(10,0,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateFreshAndAgePolicy2(new TimeSpan(5,0,0), new TimeSpan(10,0,0), DateTime.Now)); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - response = GetResponseUsingCacheDefault (new Uri("http://www.example.com")); - DisplayResponseStream (response); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateCacheIfAvailablePolicy()); - - response = GetResponseFromCache (new Uri("http://www.example.com")); - DisplayResponseStream (response); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - response = GetResponseFromServer (new Uri("http://www.example.com")); - DisplayResponseStream (response); - - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - */ - WebResponse^ response = GetResponseFromServer2( gcnew Uri( L"http://www.example.com" ) ); - DisplayResponseStream( response ); - Console::WriteLine( L"done." ); - } - - static void DisplayResponseStream( WebResponse^ response ) - { - Stream^ stream = response->GetResponseStream(); - while ( true ) - { - array^buffer = gcnew array(1024); - int read = stream->Read( buffer, 0, buffer->Length ); - if ( read == 0 ) - { - stream->Close(); - break; - } - else - { - Console::Write( Encoding::UTF8->GetString( buffer ) ); - } - } - - stream->Close(); - } - -}; - -void main() -{ - CacheExample^ ce = gcnew CacheExample; - ce->TestSimpleCache(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp deleted file mode 100644 index 30bada0e6beba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp +++ /dev/null @@ -1,728 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -/***************************** -commented out contents of snippets 1,2,8 becuase this is not legal cpp. -the use of jagged arrays is not supprted and these throw a compiler error. - -*******************************/ -// State object for reading client data asynchronously -private ref class StateObject -{ -public private: - - // Client socket. - Socket^ workSocket; - - // Size of receive buffer. - literal int BufferSize = 1024; - - // Receive buffer. - array^buffer; - - // Received data string. - StringBuilder^ sb; - -public: - StateObject() - { - workSocket = nullptr; - buffer = gcnew array(BufferSize); - sb = gcnew StringBuilder; - } - -}; - -public ref class Test -{ -public: - - // Incoming data from client. - static String^ data = nullptr; - -private: - - // ManualResetEvent instances signal completion. - static ManualResetEvent^ connectDone = gcnew ManualResetEvent( false ); - static ManualResetEvent^ sendDone = gcnew ManualResetEvent( false ); - static ManualResetEvent^ receiveDone = gcnew ManualResetEvent( false ); - static ManualResetEvent^ disconnectDone = gcnew ManualResetEvent( false ); - - // The response from the remote device. - static String^ response = String::Empty; - -public: - - // Thread signal. - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - Console::WriteLine( "{0}", args ); - if ( args[ 1 ]->Equals( "as" ) ) - { - - // Start the asynchronous server. - Console::WriteLine( "the asychronous server" ); - AsynchronousServer(); - } - else - if ( args[ 1 ]->Equals( "ac" ) ) - { - - // Start the asynchronous client. - Console::WriteLine( "the asynchronous client" ); - AsynchronousClient(); - } - else - if ( args[ 1 ]->Equals( "ss" ) ) - { - - // Start the synchronous server. - Console::WriteLine( "the sychronous server" ); - SynchronousServer(); - } - else - if ( args[ 1 ]->Equals( "sc" ) ) - { - - // Start the synchronous client. - Console::WriteLine( "the synchronous client" ); - SynchronousClient(); - } - else - { - Console::WriteLine( "default" ); - } - } - - static void AsynchronousServer() - { - - // This server waits for a connection and then uses asychronous operations to - // accept the connection, get data from the connected client, - // echo that data back to the connected client. - // It then disconnects from the client and waits for another client. - Listen(); - - // ListenWithSocket(); - } - - static void Listen() - { - - // - // This server waits for a connection and then uses asynchronous operations to - // accept the connection with initial data sent from the client. - // Establish the local endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ localEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ listener = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Bind the socket to the local endpoint, and listen for incoming connections. - listener->Bind( localEndPoint ); - listener->Listen( 100 ); - for ( ; ; ) - { - - // Set the event to nonsignaled state. - allDone->Reset(); - - // Start an asynchronous socket to listen for connections and receive data from the client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection and receive the first 10 bytes of data. - int receivedDataSize = 10; - listener->BeginAccept( receivedDataSize, gcnew AsyncCallback( AcceptReceiveCallback ), listener ); - - // Wait until a connection is made and processed before continuing. - allDone->WaitOne(); - - } - } - - static void AcceptReceiveCallback( IAsyncResult^ ar ) - { - // Get the socket that handles the client request. - Socket^ listener = dynamic_cast(ar->AsyncState); - - // End the operation and display the received data on the console. - array^Buffer; - int bytesTransferred; - Socket^ handler = listener->EndAccept( Buffer, bytesTransferred, ar ); - String^ stringTransferred = Encoding::ASCII->GetString( Buffer, 0, bytesTransferred ); - Console::WriteLine( stringTransferred ); - Console::WriteLine( "Size of data transferred is {0}", bytesTransferred ); - - // Create the state object for the asynchronous receive. - StateObject^ state = gcnew StateObject; - state->workSocket = handler; - handler->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReadCallback ), state ); - } - - - // - static void ListenWithSocket() - { - // - // This server waits for a connection and then uses asynchronous operations to - // accept the connection with initial data sent from the client. - // Establish the local endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ localEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ listener = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Bind the socket to the local endpoint, and listen for incoming connections. - listener->Bind( localEndPoint ); - listener->Listen( 100 ); - for ( ; ; ) - { - // Set the event to nonsignaled state. - allDone->Reset(); - - // Start an asynchronous socket to listen for connections and receive data from the client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection and receive the first 10 bytes of data. - // BeginAccept() creates the accepted socket. - int receivedDataSize = 10; - listener->BeginAccept( nullptr, receivedDataSize, gcnew AsyncCallback( AcceptReceiveDataCallback ), listener ); - - // Wait until a connection is made and processed before continuing. - allDone->WaitOne(); - } - } - - static void AcceptReceiveDataCallback( IAsyncResult^ ar ) - { - // Get the socket that handles the client request. - Socket^ listener = dynamic_cast(ar->AsyncState); - - // End the operation and display the received data on the console. - array^Buffer; - int bytesTransferred; - Socket^ handler = listener->EndAccept( Buffer, bytesTransferred, ar ); - String^ stringTransferred = Encoding::ASCII->GetString( Buffer, 0, bytesTransferred ); - Console::WriteLine( stringTransferred ); - Console::WriteLine( "Size of data transferred is {0}", bytesTransferred ); - - // Create the state object for the asynchronous receive. - StateObject^ state = gcnew StateObject; - state->workSocket = handler; - handler->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReadCallback ), state ); - } - - // - static void ReadCallback( IAsyncResult^ ar ) - { - String^ content = String::Empty; - - // Retrieve the state object and the handler socket - // from the asynchronous state object. - StateObject^ state = dynamic_cast(ar->AsyncState); - Socket^ handler = state->workSocket; - - // Read data from the client socket. - int bytesRead = handler->EndReceive( ar ); - if ( bytesRead > 0 ) - { - // There might be more data, so store the data received so far. - state->sb->Append( Encoding::ASCII->GetString( state->buffer, 0, bytesRead ) ); - - // Check for end-of-file tag. If it is not there, read - // more data. - content = state->sb->ToString(); - if ( content->IndexOf( "" ) > -1 ) - { - // All the data has been read from the - // client. Display it on the console. - Console::WriteLine( "Read {0} bytes from socket. Data : {1}", content->Length, content ); - - // Echo the data back to the client. - Send( handler, content ); - } - else - { - // Not all data received. Get more. - handler->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReadCallback ), state ); - } - } - } - - -private: - static void Send( Socket^ handler, String^ data ) - { - // Convert the string data to byte data using ASCII encoding. - array^byteData = Encoding::ASCII->GetBytes( data ); - - // Begin sending the data to the remote device. - handler->BeginSend( byteData, 0, byteData->Length, static_cast(0), gcnew AsyncCallback( SendCallback ), handler ); - } - - static void SendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ handler = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - int bytesSent = handler->EndSend( ar ); - Console::WriteLine( "Sent {0} bytes to client.", bytesSent ); - handler->Shutdown( SocketShutdown::Both ); - handler->Close(); - - // Signal the main thread to continue. - allDone->Set(); - } - -public: - static void AsynchronousClient() - { - // The following methods set up a socket and demonstrate the use of a new Sockets method. - // Send multiple buffers to remote device. - // AsynchronousSendBuffers(); - // Send a file to the remote host. - // AsynchronousFileSend(); - // Send a file with pre and post buffers. - // AsynchronousFileSendWithBuffers(); - // Show use of Begin/EndDisconnect - ClientDisconnect(); - } - - -private: - static void ClientSendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - int bytesSent = client->EndSend( ar ); - - // Write to the console the number of bytes sent. - Console::WriteLine( "Sent {0} bytes to server.", bytesSent ); - - // Signal that all bytes have been sent. - sendDone->Set(); - } - - -public: - - // - static void AsynchronousFileSend() - { - // Send a file to a remote device. - // Establish the remote endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the remote endpoint. - client->BeginConnect( remoteEP, gcnew AsyncCallback( ConnectCallback ), client ); - - // Wait for connect. - connectDone->WaitOne(); - - // There is a text file test.txt in the root directory. - String^ fileName = "C:\\test.txt"; - - // Send file fileName to the remote device. - Console::WriteLine( fileName ); - client->BeginSendFile( fileName, gcnew AsyncCallback( FileSendCallback ), client ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - } - -private: - static void FileSendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - client->EndSendFile( ar ); - sendDone->Set(); - } - - // - - - // -public: - static void AsynchronousFileSendWithBuffers() - { - // Send a file asynchronously to the remote device. Send a buffer before the file and a buffer afterwards. - // Establish the remote endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the remote endpoint. - client->BeginConnect( remoteEP, gcnew AsyncCallback( ConnectCallback ), client ); - - // Wait for connect. - connectDone->WaitOne(); - - // Send a file fileName to the remote device with preBuffer and postBuffer data. - // Create the preBuffer data. - String^ string1 = String::Format( "This is text data that precedes the file.{0}", Environment::NewLine ); - array^preBuf = Encoding::ASCII->GetBytes( string1 ); - - // Create the postBuffer data. - String^ string2 = String::Format( "This is text data that will follow the file.{0}", Environment::NewLine ); - array^postBuf = Encoding::ASCII->GetBytes( string2 ); - - // There is a file test.txt in the root directory. - String^ fileName = "C:\\test.txt"; - - //Send file fileName with buffers and default flags to the remote device. - Console::WriteLine( fileName ); - client->BeginSendFile( fileName, preBuf, postBuf, static_cast(0), gcnew AsyncCallback( AsynchronousFileSendCallback ), client ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - } - - -private: - static void AsynchronousFileSendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - client->EndSendFile( ar ); - sendDone->Set(); - } - // - - static void ConnectCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete the connection. - client->EndConnect( ar ); - Console::WriteLine( "Socket connected to {0}", client->RemoteEndPoint ); - - // Signal that the connection has been made. - connectDone->Set(); - } - - static void Receive( Socket^ client ) - { - // Create the state object. - StateObject^ state = gcnew StateObject; - state->workSocket = client; - - // Begin receiving the data from the remote device. - client->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReceiveCallback ), state ); - } - - static void ReceiveCallback( IAsyncResult^ ar ) - { - // Retrieve the state object and the client socket - // from the asynchronous state object. - StateObject^ state = dynamic_cast(ar->AsyncState); - Socket^ client = state->workSocket; - - // Read data from the remote device. - int bytesRead = client->EndReceive( ar ); - if ( bytesRead > 0 ) - { - // There might be more data, so store the data received so far. - state->sb->Append( Encoding::ASCII->GetString( state->buffer, 0, bytesRead ) ); - - // Get the rest of the data. - client->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReceiveCallback ), state ); - } - else - { - // All the data has arrived; put it in response. - if ( state->sb->Length > 1 ) - { - response = state->sb->ToString(); - } - - // Signal that all bytes have been received. - receiveDone->Set(); - } - } - - -public: - static void ClientDisconnect() - { - // - // Establish the remote endpoint for the socket. - // For this example use local computer. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the remote endpoint. - client->BeginConnect( remoteEP, gcnew AsyncCallback( ConnectCallback ), client ); - - // Wait for connect. - connectDone->WaitOne(); - - // Send some data to the remote device. - String^ data = "This is a string of data "; - array^buffer = Encoding::ASCII->GetBytes( data ); - client->BeginSend( buffer, 0, buffer->Length, static_cast(0), gcnew AsyncCallback( ClientSendCallback ), client ); - - // Wait for send done. - sendDone->WaitOne(); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->BeginDisconnect( true, gcnew AsyncCallback( DisconnectCallback ), client ); - - // Wait for the disconnect to complete. - disconnectDone->WaitOne(); - if ( client->Connected ) - Console::WriteLine( "We're still connected" ); - else - Console::WriteLine( "We're disconnected" ); - } - -private: - static void DisconnectCallback( IAsyncResult^ ar ) - { - // Complete the disconnect request. - Socket^ client = dynamic_cast(ar->AsyncState); - client->EndDisconnect( ar ); - - // Signal that the disconnect is complete. - disconnectDone->Set(); - } - -public: - - // - static void SynchronousServer() - { - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // For the purposes of this example, we will send and - // receive on the same machine. - // - Socket^ listener = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Bind to the local endpoint and listen to the incoming sockets. - listener->Bind( ipEndPoint ); - listener->Listen( 10 ); - for ( ; ; ) - { - Console::WriteLine( "Waiting for a connection..." ); - Socket^ handler = listener->Accept(); - String^ data = nullptr; - - // A client is connecting. - for ( ; ; ) - { - array^bytes = gcnew array(1024); - int bytesReceived = handler->Receive( bytes ); - data = String::Concat( data, Encoding::ASCII->GetString( bytes, 0, bytesReceived ) ); - if ( data->IndexOf( "" ) > -1 ) - { - break; - } - } - - // All the data has been read from the client. - // Display it on the console. - Console::WriteLine( "Read {0} bytes from socket. Data : {1}", data->Length, data ); - - // Echo the data back to the client. - //Send(handler, content); - handler->Send( Encoding::ASCII->GetBytes( data ) ); - handler->Shutdown( SocketShutdown::Both ); - handler->Close(); - } - } - - static void SynchronousClient() - { - // The following methods set up a socket and demonstrate the use of a new Sockets method. - // Set the socket options - // SetSocketOptions(); - // Send multiple buffers to remote device. - // SendMultiBuffers(); - // Send multiple buffers with socket flags - // SendMultiBuffersWithFlags(); - // Send a file to the remote host. - // FileSend(); - // Send a file with pre and post buffers - // FileSendWithBuffers(); - // Show synchronous disconnect - SynchronousDisconnect(); - } - -private: - static void SetSocketOptions() - { - // - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // Create a TCP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote endpoint. - client->Connect( ipEndPoint ); - - // Set option that allows socket to close gracefully without lingering. - client->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::DontLinger, true ); - - // Set option that allows socket to receive out-of-band information in the data stream. - client->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::OutOfBandInline, true ); - - // - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - } - - static void FileSend() - { - // - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // Create a TCP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote endpoint. - client->Connect( ipEndPoint ); - - // There is a text file test.txt located in the root directory. - String^ fileName = "C:\\test.txt"; - - // Send file fileName to remote device - Console::WriteLine( "Sending {0} to the host.", fileName ); - client->SendFile( fileName ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - // - } - - static void FileSendWithBuffers() - { - // - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // Create a TCP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote endpoint. - client->Connect( ipEndPoint ); - - // Send file fileName to the remote host with preBuffer and postBuffer data. - // There is a text file test.txt located in the root directory. - String^ fileName = "C:\\test.txt"; - - // Create the preBuffer data. - String^ string1 = String::Format( "This is text data that precedes the file.{0}", Environment::NewLine ); - array^preBuf = Encoding::ASCII->GetBytes( string1 ); - - // Create the postBuffer data. - String^ string2 = String::Format( "This is text data that will follow the file.{0}", Environment::NewLine ); - array^postBuf = Encoding::ASCII->GetBytes( string2 ); - - //Send file fileName with buffers and default flags to the remote device. - Console::WriteLine( "Sending {0} with buffers to the host.{1}", fileName, Environment::NewLine ); - client->SendFile( fileName, preBuf, postBuf, TransmitFileOptions::UseDefaultWorkerThread ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - // - } - -public: - static void SynchronousDisconnect() - { - // - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote end point. - client->Connect( ipEndPoint ); - - // Send some data to the remote device. - String^ data = "This is a string of data "; - array^buffer = Encoding::ASCII->GetBytes( data ); - int bytesTransferred = client->Send( buffer ); - - // Write to the console the number of bytes transferred. - Console::WriteLine( "{0} bytes were sent.\n", bytesTransferred ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Disconnect( true ); - if ( client->Connected ) - Console::WriteLine( "We're still connnected" ); - else - Console::WriteLine( "We're disconnected" ); - // - } -}; - -int main() -{ - Test::Main(); -} - -/* -The output from this example will vary depending on the value passed into Main -but will be similar to the following: - -Content length is 1542 -Content type is text/html; charset=utf-8 -Response stream received. - -... - - -*/ diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp deleted file mode 100644 index 41bffbe3ab78c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -// -// FIONREAD is also available as the "Available" property. -const int FIONREAD = 0x4004667F; - -void DisplayPendingByteCount( Socket^ s ) -{ - array^ outValue = BitConverter::GetBytes( 0 ); - - // Check how many bytes have been received. - s->IOControl( FIONREAD, nullptr, outValue ); - - UInt32 bytesAvailable = BitConverter::ToUInt32( outValue, 0 ); - Console::WriteLine( "server has {0} bytes pending. Available property says {1}.", - bytesAvailable, s->Available ); - - return; -} -// - -int main() -{ - IPHostEntry^ localHost = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( localHost->AddressList[ 0 ], 11000 ); - - // For the purposes of this example, we will send and - // receive on the same machine. - // - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - s->Bind( endPoint ); - - s->Listen( 1 ); - Console::WriteLine( "Waiting to receive messages from client..." ); - Socket^ client = s->Accept(); - - // Creates a byte buffer to receive the message. - array^ buffer = gcnew array(256); - String^ message; - - for ( ; ; ) - { - Thread::Sleep( 10000 ); - DisplayPendingByteCount( client ); - client->Receive( buffer ); - message = Encoding::UTF8->GetString( buffer ); - - // Displays the information received to the screen - Console::WriteLine( " Server received the following message : {0}", - message ); - - // Look for "" to end session. - if ( message->IndexOf( "" ) != -1 ) - { - break; - } - } - client->Close(); - s->Close(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp deleted file mode 100644 index b3fabcf3081d6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -// -void DisplayPendingByteCount( Socket^ s ) -{ - array^ outValue = BitConverter::GetBytes( 0 ); - - // Check how many bytes have been received. - s->IOControl( IOControlCode::DataToRead, nullptr, outValue ); - - UInt32 bytesAvailable = BitConverter::ToUInt32( outValue, 0 ); - Console::Write( "server has {0} bytes pending,", - bytesAvailable ); - Console::WriteLine( "Available property says {1}.", - s->Available ); - return; -} -// - -int main() -{ - IPHostEntry^ localHost = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( - localHost->AddressList[ 0 ],11000 ); - - // For the purposes of this example, we will send and - // receive on the same machine. - // - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - - s->Bind( endPoint ); - - s->Listen( 1 ); - Console::WriteLine( - "Waiting to receive messages from client.." ); - Socket^ client = s->Accept(); - - // Creates a byte buffer to receive the message. - array^ buffer = gcnew array(256); - String^ message; - - for ( ; ; ) - { - Thread::Sleep( 10000 ); - DisplayPendingByteCount( client ); - client->Receive( buffer ); - message = Encoding::UTF8->GetString( buffer ); - - // Displays the information received to the screen - Console::WriteLine( - " Server received the following message: {0}", - message ); - - // Look for "" to end session. - if ( message->IndexOf( "" ) != -1 ) - { - break; - } - } - client->Close(); - s->Close(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp deleted file mode 100644 index 3a204ecc032de..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; -int main() -{ - - // Create a client that will connect to a - // server listening on the contoso1 computer - // at port 11000. - TcpClient^ tcpClient = gcnew TcpClient; - tcpClient->Connect( "contosoServer", 11000 ); - - // Get the stream used to read the message sent by the server. - NetworkStream^ networkStream = tcpClient->GetStream(); - - // Set a 10 millisecond timeout for reading. - networkStream->ReadTimeout = 10; - - // Read the server message into a byte buffer. - array^bytes = gcnew array(1024); - networkStream->Read( bytes, 0, 1024 ); - - //Convert the server's message into a string and display it. - String^ data = Encoding::UTF8->GetString( bytes ); - Console::WriteLine( "Server sent message: {0}", data ); - networkStream->Close(); - tcpClient->Close(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp deleted file mode 100644 index bbdc6d6e2b6b3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp +++ /dev/null @@ -1,150 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::Threading; - -// TryCreate -void SampleTryCreate() -{ - // - // String to parse. - String^ addressString = "catalog/shownew.htm?date=today"; - - // Parse the string and create a new Uri instance, if possible. - Uri^ result; - if ( Uri::TryCreate( addressString, UriKind::RelativeOrAbsolute, result ) == true ) - { - // The call was successful. Write the URI address to the console. - Console::Write( result ); - - // Check whether new Uri instance is absolute or relative. - if ( result->IsAbsoluteUri ) - Console::WriteLine( " is an absolute Uri." ); - else - Console::WriteLine( " is a relative Uri." ); - } - else - { - // Let the user know that the call failed. - Console::WriteLine( "addressString could not be parsed as a URI address." ); - } - // -} - -// Constructor -void SampleConstructor() -{ - // - // Create an absolute Uri from a string. - String^ addressString1 = "http://www.contoso.com/"; - String^ addressString2 = "catalog/shownew.htm?date=today"; - Uri^ absoluteUri = gcnew Uri(addressString1); - - // Create a relative Uri from a string. allowRelative = true to allow for - // creating a relative Uri. - Uri^ relativeUri = gcnew Uri(addressString2); - - // Check whether the new Uri is absolute or relative. - if ( !relativeUri->IsAbsoluteUri ) - Console::WriteLine( "{0} is a relative Uri.", relativeUri ); - - // Create a new Uri from an absolute Uri and a relative Uri. - Uri^ combinedUri = gcnew Uri( absoluteUri,relativeUri ); - Console::WriteLine( combinedUri->AbsoluteUri ); - // -} - -// OriginalString -void SampleOriginalString() -{ - // - // Create a new Uri from a string address. - Uri^ uriAddress = gcnew Uri( "HTTP://www.ConToso.com:80//thick%20and%20thin.htm" ); - - // Write the new Uri to the console and note the difference in the two values. - // ToString() gives the canonical version. OriginalString gives the orginal - // string that was passed to the constructor. - // The following outputs "http://www.contoso.com/thick and thin.htm". - Console::WriteLine( uriAddress ); - - // The following outputs "HTTP://www.ConToso.com:80//thick%20and%20thin.htm". - Console::WriteLine( uriAddress->OriginalString ); - // -} - - -// DNSSafeHost -void SampleDNSSafeHost() -{ - // - // Create new Uri using a string address. - Uri^ address = gcnew Uri( "http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm" ); - - // Make the address DNS safe. - // The following outputs "[fe80::200:39ff:fe36:1a2d]". - Console::WriteLine( address->Host ); - - // The following outputs "fe80::200:39ff:fe36:1a2d%254". - Console::WriteLine( address->DnsSafeHost ); - // -} - -// operator == and !== -void SampleOperatorEqual() -{ - // - // Create some Uris. - Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm" ); - Uri^ address3 = gcnew Uri( "http://www.contoso.com/index.htm?date=today" ); - - // The first two are equal because the fragment is ignored. - if ( address1 == address2 ) - Console::WriteLine( "{0} is equal to {1}", address1, address2 ); - - // The second two are not equal. - if ( address2 != address3 ) - Console::WriteLine( "{0} is not equal to {1}", address2, address3 ); - // -} - -// IsBaseOf -void SampleIsBaseOf() -{ - // - // Create a base Uri. - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - - // Create a new Uri from a string. - Uri^ uriAddress = gcnew Uri( "http://www.contoso.com/index.htm?date=today" ); - - // Determine whether BaseUri is a base of UriAddress. - if ( baseUri->IsBaseOf( uriAddress ) ) - Console::WriteLine( "{0} is the base of {1}", baseUri, uriAddress ); - // -} - -int main() -{ - // TryParse - SampleTryCreate(); - - // Constructor - SampleConstructor(); - - // OriginalString - SampleOriginalString(); - - // DNSSafeHost - SampleDNSSafeHost(); - - // operator == and !== - SampleOperatorEqual(); - - // IsBaseOf - SampleIsBaseOf(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp deleted file mode 100644 index d92779f548dd1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp +++ /dev/null @@ -1,271 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::Threading; -using namespace System::Runtime::Serialization; - -namespace Example -{ - public ref class Test - { - public: - static void Main() - { - // Snippets 1 and 2 - HexConversions(); - - // snippet 7 - SampleToString(); - - // snippet 8 - SampleEquals(); - - // snippets 4, 5, and 6 - GetParts(); - - // snippet 3 - SampleMakeRelative(); - - // snippets 9 - 17 - SampleCheckSchemeName(); - - // snippets 18 - SampleUserInfo(); - } - - private: - static void SampleToString() - { - // - // Create a new Uri from a string address. - Uri^ uriAddress = gcnew Uri( "HTTP://www.Contoso.com:80/thick%20and%20thin.htm" ); - - // Write the new Uri to the console and note the difference in the two values. - // ToString() gives the canonical version. OriginalString gives the orginal - // string that was passed to the constructor. - // The following outputs "http://www.contoso.com/thick and thin.htm". - Console::WriteLine( uriAddress ); - - // The following outputs "HTTP://www.Contoso.com:80/thick%20and%20thin.htm". - Console::WriteLine( uriAddress->OriginalString ); - // - } - - static void SampleEquals() - { - // - // Create some Uris. - Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm" ); - if ( address1->Equals( address2 ) ) - { - Console::WriteLine( "The two addresses are equal" ); - } - else - { - Console::WriteLine( "The two addresses are not equal" ); - } - // Will output "The two addresses are equal" - // - } - - static void GetParts() - { - // - // Create Uri - Uri^ uriAddress = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Console::WriteLine( uriAddress->Fragment ); - Console::WriteLine( "Uri {0} the default port ", uriAddress->IsDefaultPort ? (String^)"uses" : "does not use" ); - - Console::WriteLine( "The path of this Uri is {0}", uriAddress->GetLeftPart( UriPartial::Path ) ); - Console::WriteLine( "Hash code {0}", uriAddress->GetHashCode() ); - // The example displays the following output: - // #search - // Uri uses the default port - // The path of this Uri is http://www.contoso.com/index.htm - // Hash code -988419291 - // - - // - Uri^ uriAddress1 = gcnew Uri( "http://www.contoso.com/title/index.htm" ); - Console::WriteLine( "The parts are {0}, {1}, {2}", uriAddress1->Segments[ 0 ], uriAddress1->Segments[ 1 ], uriAddress1->Segments[ 2 ] ); - // - - // - Uri^ uriAddress2 = gcnew Uri( "file://server/filename.ext" ); - Console::WriteLine( uriAddress2->LocalPath ); - Console::WriteLine( "Uri {0} a UNC path", uriAddress2->IsUnc ? (String^)"is" : "is not" ); - Console::WriteLine( "Uri {0} a local host", uriAddress2->IsLoopback ? (String^)"is" : "is not" ); - Console::WriteLine( "Uri {0} a file", uriAddress2->IsFile ? (String^)"is" : "is not" ); - // The example displays the following output: - // \\server\filename.ext - // Uri is a UNC path - // Uri is not a local host - // Uri is a file - // - } - - static void HexConversions() - { - - // - char testChar = 'e'; - if ( Uri::IsHexDigit( testChar ) == true ) - { - Console::WriteLine( "'{0}' is the hexadecimal representation of {1}", - testChar, Uri::FromHex( testChar ) ); - } - else - { - Console::WriteLine( "'{0}' is not a hex character", testChar ); - } - - String^ returnString = Uri::HexEscape( testChar ); - Console::WriteLine( "The hexadecimal value of '{0}' is {1}", testChar, returnString ); - // - - // - String^ testString = "%75"; - int index = 0; - if ( Uri::IsHexEncoding( testString, index ) ) - { - Console::WriteLine( "The character is {0}", - Uri::HexUnescape( testString, index ) ); - } - else - { - Console::WriteLine( "The character is not hex encoded" ); - } - // - } - - // MakeRelative - static void SampleMakeRelative() - { - // - // Create a base Uri. - Uri^ address1 = gcnew Uri( "http://www.contoso.com/" ); - - // Create a new Uri from a string. - Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm?date=today" ); - - // Determine the relative Uri. - Console::WriteLine( "The difference is {0}", address1->MakeRelativeUri( address2 ) ); - // - } - - //CheckSchemeName - static void SampleCheckSchemeName() - { - // - Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Console::WriteLine( "address 1 {0} a valid scheme name", - Uri::CheckSchemeName( address1->Scheme ) ? (String^)" has" : " does not have" ); - if ( address1->Scheme == Uri::UriSchemeHttp ) - { - Console::WriteLine( "Uri is HTTP type" ); - } - - Console::WriteLine( address1->HostNameType ); - // - - // - Uri^ address2 = gcnew Uri( "file://server/filename.ext" ); - if ( address2->Scheme == Uri::UriSchemeFile ) - { - Console::WriteLine( "Uri is a file" ); - } - // - - Console::WriteLine( address2->HostNameType ); - - // - Uri^ address3 = gcnew Uri( "mailto:user@contoso.com?subject=uri" ); - if ( address3->Scheme == Uri::UriSchemeMailto ) - { - Console::WriteLine( "Uri is an email address" ); - } - // - - // - Uri^ address4 = gcnew Uri( "news:123456@contoso.com" ); - if ( address4->Scheme == Uri::UriSchemeNews ) - { - Console::WriteLine( "Uri is an Internet news group" ); - } - // - - // - Uri^ address5 = gcnew Uri( "nntp://news.contoso.com/123456@contoso.com" ); - if ( address5->Scheme == Uri::UriSchemeNntp ) - { - Console::WriteLine( "Uri is nntp protocol" ); - } - // - - // - Uri^ address6 = gcnew Uri( "gopher://example.contoso.com/" ); - if ( address6->Scheme == Uri::UriSchemeGopher ) - { - Console::WriteLine( "Uri is Gopher protocol" ); - } - // - - // - Uri^ address7 = gcnew Uri( "ftp://contoso/files/testfile.txt" ); - if ( address7->Scheme == Uri::UriSchemeFtp ) - { - Console::WriteLine( "Uri is Ftp protocol" ); - } - // - - // - Uri^ address8 = gcnew Uri( "https://example.contoso.com" ); - if ( address8->Scheme == Uri::UriSchemeHttps ) - { - Console::WriteLine( "Uri is Https protocol." ); - } - // - - // - String^ address = "www.contoso.com"; - String^ uriString = String::Format( "{0}{1}{2}", - Uri::UriSchemeHttp, Uri::SchemeDelimiter, address ); - -#if OLDMETHOD - Uri^ result; - if ( Uri::TryParse( uriString, false, false, result ) == true ) - { - Console::WriteLine( "{0} is a valid Uri", result ); - } - else - { - Console::WriteLine( "Uri not created" ); - } -#endif - Uri ^result = gcnew Uri(uriString); - if (result->IsWellFormedOriginalString()) - Console::WriteLine("{0} is a well formed Uri", uriString); - else - Console::WriteLine("{0} is not a well formed Uri", uriString); - // - } - - static void SampleUserInfo() - { - // - Uri^ uriAddress = gcnew Uri( "http://user:password@www.contoso.com/index.htm " ); - Console::WriteLine( uriAddress->UserInfo ); - Console::WriteLine( "Fully Escaped {0}", - uriAddress->UserEscaped ? (String^)"yes" : "no" ); - // - } - }; -} - -int main() -{ - Example::Test::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp deleted file mode 100644 index 74106f56e464e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp +++ /dev/null @@ -1,861 +0,0 @@ - - -// NCLWebClientAsync -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::ComponentModel; - -// - static void UploadProgressCallback(Object^ sender, - UploadProgressChangedEventArgs^ e) - { - // Displays the operation identifier, and the transfer progress. - Console::WriteLine("{0} uploaded {1} of {2} bytes. {3} % complete...", - (String ^)e->UserState, - e->BytesSent, - e->TotalBytesToSend, - e->ProgressPercentage); - } - static void DownloadProgressCallback(Object^ sender, - DownloadProgressChangedEventArgs^ e) - { - // Displays the operation identifier, and the transfer progress. - Console::WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...", - (String ^)e->UserState, - e->BytesReceived, - e->TotalBytesToReceive, - e->ProgressPercentage); - } -// - -// -void UploadString( String^ address ) -{ - String^ data = "Time = 12:00am temperature = 50"; - WebClient^ client = gcnew WebClient; - - // Optionally specify an encoding for uploading and downloading strings. - client->Encoding = System::Text::Encoding::UTF8; - - // Upload the data. - String^ reply = client->UploadString( address, data ); - - // Disply the server's response. - Console::WriteLine( reply ); -} - - -// -// -void PostString( String^ address ) -{ - String^ data = "Time = 12:00am temperature = 50"; - String^ method = "POST"; - WebClient^ client = gcnew WebClient; - String^ reply = client->UploadString( address, method, data ); - Console::WriteLine( reply ); -} - - -// -void UploadFileCallback2( Object^ sender, UploadFileCompletedEventArgs^ e ); - -// -// Sample call: UploadFileInBackground3("http://www.contoso.com/fileUpload.aspx", "data.txt") -void UploadFileInBackground3( String^ address, String^ fileName ) -{ - - // - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - client->UseDefaultCredentials = true; - - // - client->UploadFileCompleted += gcnew UploadFileCompletedEventHandler( UploadFileCallback2 ); - client->UploadFileAsync( uri, fileName ); - Console::WriteLine( "File upload started." ); -} - -// - -// -// Sample call: UploadFileInBackground2("http://www.contoso.com/fileUpload.aspx", "data.txt") -void UploadFileInBackground2( String^ address, String^ fileName ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - client->UploadFileCompleted += - gcnew UploadFileCompletedEventHandler (UploadFileCallback2); - - // Specify a progress notification handler. - client->UploadProgressChanged += - gcnew UploadProgressChangedEventHandler( UploadProgressCallback ); - client->UploadFileAsync( uri, "POST", fileName ); - Console::WriteLine( "File upload started." ); -} - - -// -// -void UploadFileCallback2( Object^ /*sender*/, UploadFileCompletedEventArgs^ e ) -{ - String^ reply = System::Text::Encoding::UTF8->GetString( e->Result ); - Console::WriteLine( reply ); -} - - -// -void UploadFileCallback( Object^ sender, UploadFileCompletedEventArgs^ e ); - -// -// Sample call: UploadFileInBackground("http://www.contoso.com/fileUpload.aspx", "data.txt") -void UploadFileInBackground( String^ address, String^ fileName ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - String^ method = "POST"; - - // Specify that UploadFileCallback method gets called - // when the file upload completes. - client->UploadFileCompleted += gcnew UploadFileCompletedEventHandler( UploadFileCallback ); - client->UploadFileAsync( uri, method, fileName, waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the upload to complete. - waiter->WaitOne(); - Console::WriteLine( "File upload is complete." ); -} - - -// -// -void UploadFileCallback( Object^ /*sender*/, UploadFileCompletedEventArgs^ e ) -{ - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - ; - try - { - String^ reply = System::Text::Encoding::UTF8->GetString( e->Result ); - Console::WriteLine( reply ); - } - finally - { - - // If this thread throws an exception, make sure that - // you let the main application thread resume. - waiter->Set(); - } - -} - - -// -void UploadStringCallback( Object^ sender, UploadStringCompletedEventArgs^ e ); - -// -void UploadStringInBackground( String^ address ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - String^ data = "Time = 12:00am temperature = 50"; - String^ method = "POST"; - - client->UploadStringCompleted += gcnew UploadStringCompletedEventHandler( UploadStringCallback ); - client->UploadStringAsync( uri, method, data, waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the upload to complete. - waiter->WaitOne(); - Console::WriteLine( "String upload is complete." ); -} - - -// -// -void UploadStringCallback( Object^ /*sender*/, UploadStringCompletedEventArgs^ e ) -{ - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - try - { - String^ reply = dynamic_cast(e->Result); - Console::WriteLine( reply ); - } - finally - { - - // If this thread throws an exception, make sure that - // you let the main application thread resume. - waiter->Set(); - } - -} - - -// -void OpenReadCallback( Object^ sender, OpenReadCompletedEventArgs^ e ); - -// -void OpenResourceForReading( String^ address ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - client->OpenReadCompleted += gcnew OpenReadCompletedEventHandler( OpenReadCallback ); - client->OpenReadAsync( uri, waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the upload to complete. - waiter->WaitOne(); -} - - -// -// -void OpenReadCallback( Object^ /*sender*/, OpenReadCompletedEventArgs^ e ) -{ - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - Stream^ reply = nullptr; - StreamReader^ s = nullptr; - try - { - reply = dynamic_cast(e->Result); - s = gcnew StreamReader( reply ); - Console::WriteLine( s->ReadToEnd() ); - } - finally - { - if ( s != nullptr ) - { - s->Close(); - } - if ( reply != nullptr ) - { - reply->Close(); - } - - // If this thread throws an exception, make sure that - // you let the main application thread resume. - waiter->Set(); - } - -} - - -// -void OpenWriteCallback( Object^ sender, OpenWriteCompletedEventArgs^ e ); - -// -void OpenResourceForWriting( String^ address ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the OpenWriteCallback method gets called - // when the writeable stream is available. - client->OpenWriteCompleted += gcnew OpenWriteCompletedEventHandler( OpenWriteCallback ); - client->OpenWriteAsync( uri, "POST", waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the upload to complete. - waiter->WaitOne(); -} - - -// -// -void OpenWriteCallback( Object^ /*sender*/, OpenWriteCompletedEventArgs^ e ) -{ - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - Stream^ body = nullptr; - StreamWriter^ s = nullptr; - try - { - body = dynamic_cast(e->Result); - s = gcnew StreamWriter( body ); - s->AutoFlush = true; - s->Write( "This is content data to be sent to the server." ); - } - finally - { - if ( s != nullptr ) - { - s->Close(); - } - if ( body != nullptr ) - { - body->Close(); - } - - // If this thread throws an exception, make sure that - // you let the main application thread resume. - waiter->Set(); - } - -} - - -// -void OpenWriteCallback2( Object^ sender, OpenWriteCompletedEventArgs^ e ); - -// -void OpenResourceForWriting2( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the OpenWriteCallback method gets called - // when the writeable stream is available. - client->OpenWriteCompleted += gcnew OpenWriteCompletedEventHandler( OpenWriteCallback2 ); - client->OpenWriteAsync( uri, "POST" ); - - // Applications can perform other tasks - // while waiting for the upload to complete. -} - - -// -// -void OpenWriteCallback2( Object^ /*sender*/, OpenWriteCompletedEventArgs^ e ) -{ - Stream^ body = nullptr; - StreamWriter^ s = nullptr; - try - { - body = dynamic_cast(e->Result); - s = gcnew StreamWriter( body ); - s->AutoFlush = true; - s->Write( "This is content data to be sent to the server." ); - } - finally - { - if ( s != nullptr ) - { - s->Close(); - } - if ( body != nullptr ) - { - body->Close(); - } - } - -} - - -// -// -void OpenResourceForPosting( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the OpenWriteCallback method gets called - // when the writeable stream is available. - client->OpenWriteCompleted += gcnew OpenWriteCompletedEventHandler( OpenWriteCallback2 ); - client->OpenWriteAsync( uri ); - - // Applications can perform other tasks - // while waiting for the upload to complete. -} - - -// -void DownloadFileCallback( Object^ sender, System::ComponentModel::AsyncCompletedEventArgs^ e ); - -// -// Sample call : DownLoadFileInBackground ("http://www.contoso.com/logs/January.txt"); -void DownLoadFileInBackground( String^ address ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the DownloadFileCallback method gets called - // when the download completes. - client->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallback ); - client->DownloadFileAsync( uri, "serverdata.txt", waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the download to complete. - waiter->WaitOne(); -} - - -// -// -void DownloadFileCallback( Object^ /*sender*/, System::ComponentModel::AsyncCompletedEventArgs^ e ) -{ - if ( e->Cancelled ) - { - Console::WriteLine( "File download cancelled." ); - } - - if ( e->Error != nullptr ) - { - Console::WriteLine( e->Error->ToString() ); - } - - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - - // Let the main application thread resume. - waiter->Set(); -} - - -// -void DownloadFileCallback2( Object^ sender, System::ComponentModel::AsyncCompletedEventArgs^ e ); - -// -// Sample call : DownLoadFileInBackground2 ("http://www.contoso.com/logs/January.txt"); -void DownLoadFileInBackground2( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the DownloadFileCallback method gets called - // when the download completes. - client->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallback2 ); - - // Specify a progress notification handler. - client->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler( DownloadProgressCallback ); - client->DownloadFileAsync( uri, "serverdata.txt" ); -} - - -// -// -void DownloadFileCallback2( Object^ /*sender*/, System::ComponentModel::AsyncCompletedEventArgs^ e ) -{ - if ( e->Cancelled ) - { - Console::WriteLine( "File download cancelled." ); - } - - if ( e->Error != nullptr ) - { - Console::WriteLine( e->Error->ToString() ); - } -} - - -// -void DownloadDataCallback( Object^ sender, DownloadDataCompletedEventArgs^ e ); - -// -// Sample call : DownLoadDataInBackground ("http://www.contoso.com/GameScores.html"); -void DownloadDataInBackground( String^ address ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the DownloadDataCallback method gets called - // when the download completes. - client->DownloadDataCompleted += gcnew DownloadDataCompletedEventHandler( DownloadDataCallback ); - client->DownloadDataAsync( uri, waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the download to complete. - waiter->WaitOne(); -} - - -// -// -void DownloadDataCallback( Object^ /*sender*/, DownloadDataCompletedEventArgs^ e ) -{ - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - try - { - - // If the request was not canceled and did not throw - // an exception, display the resource. - if ( !e->Cancelled && e->Error == nullptr ) - { - array^data = dynamic_cast^>(e->Result); - String^ textData = System::Text::Encoding::UTF8->GetString( data ); - Console::WriteLine( textData ); - } - } - finally - { - - // Let the main application thread resume. - waiter->Set(); - } - -} - - -// -void DownloadDataCallback2( Object^ sender, DownloadDataCompletedEventArgs^ e ); - -// -// Sample call : DownloadDataInBackground2 ("http://www.contoso.com/GameScores.html"); -void DownloadDataInBackground2( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the DownloadDataCallback2 method gets called - // when the download completes. - client->DownloadDataCompleted += gcnew DownloadDataCompletedEventHandler( DownloadDataCallback2 ); - client->DownloadDataAsync( uri ); -} - - -// -// -void DownloadDataCallback2( Object^ /*sender*/, DownloadDataCompletedEventArgs^ e ) -{ - - // If the request was not canceled and did not throw - // an exception, display the resource. - if ( !e->Cancelled && e->Error == nullptr ) - { - array^data = dynamic_cast^>(e->Result); - String^ textData = System::Text::Encoding::UTF8->GetString( data ); - Console::WriteLine( textData ); - } -} - - -// -// -void DownloadString( String^ address ) -{ - WebClient^ client = gcnew WebClient; - String^ reply = client->DownloadString( address ); - Console::WriteLine( reply ); -} - - -// -void DownloadStringCallback( Object^ sender, DownloadStringCompletedEventArgs^ e ); - -// -// Sample call : DownLoadStringInBackground ("http://www.contoso.com/GameScores.html"); -void DownloadStringInBackground( String^ address ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the DownloadStringCallback method gets called - // when the download completes. - client->DownloadStringCompleted += gcnew DownloadStringCompletedEventHandler( DownloadStringCallback ); - client->DownloadStringAsync( uri, waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the download to complete. - waiter->WaitOne(); -} - - -// -// -void DownloadStringCallback( Object^ /*sender*/, DownloadStringCompletedEventArgs^ e ) -{ - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - try - { - - // If the request was not canceled and did not throw - // an exception, display the resource. - if ( !e->Cancelled && e->Error == nullptr ) - { - String^ textString = dynamic_cast(e->Result); - Console::WriteLine( textString ); - } - } - finally - { - - // Let the main application thread resume. - waiter->Set(); - } - -} - - -// -void DownloadStringCallback2( Object^ sender, DownloadStringCompletedEventArgs^ e ); - -// -// Sample call : DownloadStringInBackground2 ("http://www.contoso.com/GameScores.html"); -void DownloadStringInBackground2( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the DownloadStringCallback2 method gets called - // when the download completes. - client->DownloadStringCompleted += gcnew DownloadStringCompletedEventHandler( DownloadStringCallback2 ); - client->DownloadStringAsync( uri ); -} - - -// -// -void DownloadStringCallback2( Object^ /*sender*/, DownloadStringCompletedEventArgs^ e ) -{ - - // If the request was not canceled and did not throw - // an exception, display the resource. - if ( !e->Cancelled && e->Error == nullptr ) - { - String^ textString = dynamic_cast(e->Result); - Console::WriteLine( textString ); - } -} - - -// -void OpenReadCallback2( Object^ sender, OpenReadCompletedEventArgs^ e ); - -// -void OpenResourceForReading2( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - client->OpenReadCompleted += gcnew OpenReadCompletedEventHandler( OpenReadCallback2 ); - client->OpenReadAsync( uri ); -} - - -// -// -void OpenReadCallback2( Object^ /*sender*/, OpenReadCompletedEventArgs^ e ) -{ - Stream^ reply = nullptr; - StreamReader^ s = nullptr; - try - { - reply = dynamic_cast(e->Result); - s = gcnew StreamReader( reply ); - Console::WriteLine( s->ReadToEnd() ); - } - finally - { - if ( s != nullptr ) - { - s->Close(); - } - if ( reply != nullptr ) - { - reply->Close(); - } - } - -} - - -// -void UploadDataCallback( Object^ sender, UploadDataCompletedEventArgs^ e ); - -// -void UploadDataInBackground( String^ address ) -{ - System::Threading::AutoResetEvent^ waiter = gcnew System::Threading::AutoResetEvent( false ); - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - String^ text = "Time = 12:00am temperature = 50"; - array^data = System::Text::Encoding::UTF8->GetBytes( text ); - String^ method = "POST"; - - client->UploadDataCompleted += gcnew UploadDataCompletedEventHandler( UploadDataCallback ); - client->UploadDataAsync( uri, method, data, waiter ); - - // Block the main application thread. Real applications - // can perform other tasks while waiting for the upload to complete. - waiter->WaitOne(); - Console::WriteLine( "Data upload is complete." ); -} - - -// -// -void UploadDataCallback( Object^ /*sender*/, UploadDataCompletedEventArgs^ e ) -{ - System::Threading::AutoResetEvent^ waiter = dynamic_cast(e->UserState); - try - { - array^data = dynamic_cast^>(e->Result); - String^ reply = System::Text::Encoding::UTF8->GetString( data ); - Console::WriteLine( reply ); - } - finally - { - - // If this thread throws an exception, make sure that - // you let the main application thread resume. - waiter->Set(); - } - -} - - -// -void UploadDataCallback2( Object^ sender, UploadDataCompletedEventArgs^ e ); - -// -void UploadDataInBackground2( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - String^ text = "Time = 12:00am temperature = 50"; - array^data = System::Text::Encoding::UTF8->GetBytes( text ); - String^ method = "POST"; - - client->UploadDataCompleted += gcnew UploadDataCompletedEventHandler( UploadDataCallback2 ); - client->UploadDataAsync( uri, method, data ); -} - - -// -// -void UploadDataCallback2( Object^ /*sender*/, UploadDataCompletedEventArgs^ e ) -{ - array^data = dynamic_cast^>(e->Result); - String^ reply = System::Text::Encoding::UTF8->GetString( data ); - Console::WriteLine( reply ); -} - - -// -void UploadDataCallback3( Object^ sender, UploadDataCompletedEventArgs^ e ); - -// -void UploadDataInBackground3( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - String^ text = "Time = 12:00am temperature = 50"; - array^data = System::Text::Encoding::UTF8->GetBytes( text ); - - client->UploadDataCompleted += gcnew UploadDataCompletedEventHandler( UploadDataCallback3 ); - client->UploadDataAsync( uri, data ); -} - - -// -// -void UploadDataCallback3( Object^ /*sender*/, UploadDataCompletedEventArgs^ e ) -{ - array^data = dynamic_cast^>(e->Result); - String^ reply = System::Text::Encoding::UTF8->GetString( data ); - Console::WriteLine( reply ); -} - - -// -void UploadStringCallback2( Object^ sender, UploadStringCompletedEventArgs^ e ); - -// -void UploadStringInBackground2( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - String^ data = "Time = 12:00am temperature = 50"; - - client->UploadStringCompleted += gcnew UploadStringCompletedEventHandler( UploadStringCallback2 ); - client->UploadStringAsync( uri, data ); -} - - -// -// -void UploadStringCallback2( Object^ /*sender*/, UploadStringCompletedEventArgs^ e ) -{ - String^ reply = dynamic_cast(e->Result); - Console::WriteLine( reply ); -} - - -// -// -void UploadStringInBackground3( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - String^ data = "Time = 12:00am temperature = 50"; - String^ method = "POST"; - - client->UploadStringCompleted += gcnew UploadStringCompletedEventHandler( UploadStringCallback2 ); - client->UploadStringAsync( uri, method, data ); -} - - -// -// -// Sample call : DownLoadFileWithProgressNotify ("http://www.contoso.com/logs/January.txt"); -void DownLoadFileWithProgressNotify( String^ address ) -{ - WebClient^ client = gcnew WebClient; - Uri ^uri = gcnew Uri(address); - - // Specify that the DownloadFileCallback method gets called - // when the download completes. - client->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallback2 ); - - // Specify a progress notification handler. - client->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler( DownloadProgressCallback ); - - // The user token, shown here as ID 1234, is used to uniquely - // identify notification events raised for this data transfer operation. - client->DownloadFileAsync( uri, "serverdata.txt", "ID 1234" ); -} - - -// -// nothing below this line appears in the docs. -//[System.Security.Permissions.FileIOPermissionAttribute(System.Security.Permissions.SecurityAction.Deny, Write=@"c:\whidbeycode\ncl.xml")] -int main() -{ - - // OpenResourceForReading ("http://google.com"); - //OpenResourceForReading2("http://google.com"); - // System.Threading.Thread.Sleep (10000); - UploadDataInBackground2( "http://sharriso1/test/postaccepter.aspx" ); - - // DownloadString ("http://google.com"); - /* - UploadDataInBackground ("http://sharriso1/test/postaccepter.aspx"); - - System.Threading.Thread.Sleep (1000); - UploadDataInBackground3 ("http://sharriso1/test/postaccepter.aspx"); - System.Threading.Thread.Sleep (1000); - - UploadStringInBackground ("http://sharriso1/test/postaccepter.aspx"); - UploadStringInBackground2 ("http://sharriso1/test/postaccepter.aspx"); - System.Threading.Thread.Sleep (1000); - UploadStringInBackground3 ("http://sharriso1/test/postaccepter.aspx"); - System.Threading.Thread.Sleep (1000); - */ - // OpenResourceForWriting2("http://sharriso1/test/postaccepter.aspx"); - // DownloadDataInBackground ("http://google.com"); - //System.Threading.Thread.Sleep (10000); - // DownloadString ("http://google.com"); - // DownloadStringInBackground ("http://google.com"); - // DownloadStringInBackground2 ("http://google.com"); - // System.Threading.Thread.Sleep (1000); - // DownLoadFileInBackground2 ("http://sharriso1/test/uploadedFiles/onesandtwos.txt"); - DownLoadFileWithProgressNotify( "http://sharriso1/test/uploadedFiles/onesandtwos.txt" ); - - //System.Threading.Thread.Sleep (10000); - // UploadString (); - // UploadStringInBackground ("http://sharriso1/test/fileUploadercs.aspx"); - // UploadFileInBackground2 ("http://sharriso1/test/fileUploadercs.aspx", "onesandtwos.txt"); - // UploadFileInBackground3 ("http://sharriso1/test/fileUploadercs.aspx", "onesandtwos.txt"); - System::Threading::Thread::Sleep( 1000 ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebClientUserAgent/CPP/useragent.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebClientUserAgent/CPP/useragent.cpp deleted file mode 100644 index 6dff2981ec87d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebClientUserAgent/CPP/useragent.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args == nullptr || args->Length == 1 ) - { - throw gcnew ApplicationException( "Specify the URI of the resource to retrieve." ); - } - - WebClient^ client = gcnew WebClient; - - // Add a user agent header in case the - // requested URI contains a query. - client->Headers->Add( "user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)" ); - Stream^ data = client->OpenRead( args[ 1 ] ); - StreamReader^ reader = gcnew StreamReader( data ); - String^ s = reader->ReadToEnd(); - Console::WriteLine( s ); - data->Close(); - reader->Close(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp deleted file mode 100644 index bbfd7a0afd978..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; - -// -WebProxy^ CreateProxy() -{ - return gcnew WebProxy; -} -// - -// -WebProxy^ CreateProxyWithExampleAddress() -{ - return gcnew WebProxy( gcnew Uri( "http://contoso" ) ); -} -// - -// -WebProxy^ CreateProxyWithExampleAddress( bool bypassLocal ) -{ - return gcnew WebProxy( gcnew Uri( "http://contoso" ), bypassLocal ); -} -// - -// -WebProxy^ CreateProxyWithBypassList( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( gcnew Uri( "http://contoso" ), - bypassLocal, - bypassList ); -} -// - -// -WebProxy^ CreateProxyWithHost() -{ - return gcnew WebProxy( "http://contoso" ); -} -// - -// -WebProxy^ CreateProxyWithHostAndPort() -{ - return gcnew WebProxy( "contoso",80 ); -} -// - -// -WebProxy^ CreateProxyWithHostAddress( bool bypassLocal ) -{ - WebProxy^ proxy = gcnew WebProxy( "http://contoso",bypassLocal ); - Console::WriteLine( "Bypass proxy for local URIs?: {0}", - proxy->BypassProxyOnLocal ); - return proxy; -} -// - -// -WebProxy^ CreateProxyWithHostAndBypassList( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( "http://contoso", - bypassLocal, - bypassList ); -} -// - -// -WebProxy^ CreateProxyWithCredentials( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( "http://contoso", - bypassLocal, - bypassList, - CredentialCache::DefaultCredentials ); -} -// - -// -void DisplayDefaultProxy() -{ - WebProxy^ proxy = WebProxy::GetDefaultProxy(); - - Console::WriteLine( "Address: {0}", proxy->Address ); - - Console::WriteLine( "Bypass on local: {0}", - proxy->BypassProxyOnLocal ); - int count = proxy->BypassList->Length; - if ( count == 0 ) - { - Console::WriteLine( "The bypass list is empty." ); - return; - } - array^ bypass = proxy->BypassList; - Console::WriteLine( "The bypass list contents:" ); - - for ( int i = 0; i < count; i++ ) - { - Console::WriteLine( bypass[ i ] ); - } -} -// - -// -void CheckDefaultProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = (WebProxy^)( WebProxy::GetDefaultProxy() ); - - // See what proxy is used for resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see whether a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, - resourceProxy ); - } -} -// - -// -WebProxy^ CreateProxyAndCheckBypass( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - WebProxy^ proxy = gcnew WebProxy( "http://contoso", - bypassLocal, - bypassList ); - - // Test the bypass list. - if ( !proxy->IsBypassed( gcnew Uri( "http://www.Contoso.com" ) ) ) - { - Console::WriteLine( "Bypass not working!" ); - return nullptr; - } - else - { - Console::WriteLine( "Bypass is working." ); - return proxy; - } -} -// - -// -WebProxy^ CreateProxyWithCredentials2( bool bypassLocal ) -{ - - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( gcnew Uri( "http://contoso" ), - bypassLocal, - bypassList, - CredentialCache::DefaultCredentials ); -} -// - -int main() -{ - Uri^ resource = gcnew Uri( "http://www.example.com" ); - - /* - CreateProxy(); - CreateProxyWithExampleAddress(); - CreateProxyWithExampleAddress(true); - CreateProxyWithBypassList(true); - CreateProxyWithHost(); - CreateProxyWithHostAndPort(); - CreateProxyWithHostAddress(true); - CreateProxyWithHostAndBypassList(true); - CreateProxyWithCredentials(true); - - DisplayDefaultProxy(); - */ - // CreateProxyAndCheckBypass(false); - CreateProxyWithCredentials2( false ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp deleted file mode 100644 index 51c732b40054e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; -int main() -{ - - // - // Create a request for the URL. - WebRequest^ request = WebRequest::Create( "http://www.contoso.com/default.html" ); - - // If required by the server, set the credentials. - request->Credentials = CredentialCache::DefaultCredentials; - - // Get the response. - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // - // Display the status. - Console::WriteLine( response->StatusDescription ); - - // Get the stream containing content returned by the server. - Stream^ dataStream = response->GetResponseStream(); - - // Open the stream using a StreamReader for easy access. - StreamReader^ reader = gcnew StreamReader( dataStream ); - - // Read the content. - String^ responseFromServer = reader->ReadToEnd(); - - // Display the content. - Console::WriteLine( responseFromServer ); - - // Cleanup the streams and the response. - reader->Close(); - dataStream->Close(); - response->Close(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp deleted file mode 100644 index bdb99bf4675a3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//The following sample initializes a CredentialCache with multiple security credentials -//and later uses NTLM credentials with SmtpClient - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; - -void main() -{ -// - SmtpClient^ client = gcnew SmtpClient("ContosoMail", 45); - MailAddress^ from = gcnew MailAddress("sender@SenderMailServerName.com", "Sender Name"); - MailAddress^ to = gcnew MailAddress("recepient@RecepientMailServerName.com", "Recepient Name"); - MailMessage^ message = gcnew MailMessage(from, to); - - message->Body = "This is a test email message sent by an application. "; - message->Subject = "Test Email using Credentials"; - - NetworkCredential^ myCreds = gcnew NetworkCredential("username", "password", "domain"); - CredentialCache^ myCredentialCache = gcnew CredentialCache(); - try - { - myCredentialCache->Add("ContoscoMail", 35, "Basic", myCreds); - myCredentialCache->Add("ContoscoMail", 45, "NTLM", myCreds); - - client->Credentials = myCredentialCache->GetCredential("ContosoMail", 45, "NTLM"); - client->Send(message); - Console::WriteLine("Goodbye."); - } - catch(Exception^ e) - { - Console::WriteLine("Exception is raised. "); - Console::WriteLine("Message: {0} ",e->Message); - } -// - -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclCodeGroup/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/NclCodeGroup/cpp/makefile deleted file mode 100644 index b09411db679e7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclCodeGroup/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -NclGodeGroup.exe : sample.cpp - cl /W4 /clr:pure /FeNclCodeGroup.exe sample.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclCodeGroup/cpp/sample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclCodeGroup/cpp/sample.cpp deleted file mode 100644 index 4f475ac7f01fb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclCodeGroup/cpp/sample.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#using - -using namespace System; -using namespace System::Security::Policy; - -static void DisplayConnectionAccessRules(NetCodeGroup^ group); -// - - -static CodeConnectAccess^ CreateFtpAndDefaultPortAccess() -{ - return gcnew CodeConnectAccess(Uri::UriSchemeFtp, - CodeConnectAccess::DefaultPort); -} -// -// - - -static CodeConnectAccess^ CreateHttpAndOriginPortAccess() -{ - return gcnew CodeConnectAccess(Uri::UriSchemeHttp, - CodeConnectAccess::OriginPort); -} -// -// - -static CodeConnectAccess^ CreateAnySchemeOriginPortAccess() -{ - return CodeConnectAccess::CreateAnySchemeAccess - (CodeConnectAccess::OriginPort); -} -// -// - -static void SetNetCodeGroupAccess() -{ - String^ userPolicyLevel = "User"; - // Locate the User policy level. - PolicyLevel^ level = nullptr; - System::Collections::IEnumerator^ ph = - System::Security::SecurityManager::PolicyHierarchy(); - while(ph->MoveNext()) - { - level = (PolicyLevel^)ph->Current; - if (level->Label == userPolicyLevel) - { - break; - } - } - if (level->Label != userPolicyLevel) - throw gcnew ApplicationException("Could not find User policy level."); - // - - IMembershipCondition^ membership = - gcnew UrlMembershipCondition("http://www.contoso.com/*"); - NetCodeGroup^ codeGroup = gcnew NetCodeGroup(membership); - // Delete default settings. - codeGroup->ResetConnectAccess(); - // Create an object that represents access to the FTP scheme and - // default port. - CodeConnectAccess^ CodeAccessFtp = - gcnew CodeConnectAccess(Uri::UriSchemeFtp, - CodeConnectAccess::DefaultPort); - // Create an object that represents access to the HTTPS scheme - // and default port. - CodeConnectAccess^ CodeAccessHttps = - gcnew CodeConnectAccess(Uri::UriSchemeHttps, - CodeConnectAccess::DefaultPort); - // Create an object that represents access to the origin - // scheme and port. - CodeConnectAccess^ CodeAccessOrigin = - CodeConnectAccess::CreateOriginSchemeAccess - (CodeConnectAccess::OriginPort); - // Add connection access objects to the NetCodeGroup object. - codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessFtp); - codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessHttps); - codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessOrigin); - // - // Provide name and description information for caspol.exe tool. - codeGroup->Name = "ContosoHttpCodeGroup"; - codeGroup->Description = "Code originating from contoso.com can" + - " connect back using the FTP or HTTPS."; - // Add the code group to the User policy's root node. - level->RootCodeGroup->AddChild(codeGroup); - // Save the changes to the policy level. - System::Security::SecurityManager::SavePolicy(); -} -// -// - -static void DisplayProperties (CodeConnectAccess^ access) -{ - Console::WriteLine("Scheme:{0} Port: {1}", - access->Scheme, access->Port); -} -// -// - -static void DisplayFields () -{ - Console::WriteLine("Origin scheme value:{0} AnyScheme value: {1}", - CodeConnectAccess::OriginScheme, CodeConnectAccess::AnyScheme); -} -// - - -static void CreateNetCodeGroup() -{ - IMembershipCondition^ membership = - gcnew UrlMembershipCondition("http://www.contoso.com/*"); - NetCodeGroup^ codeGroup = gcnew NetCodeGroup(membership); - - // Display default settings. - DisplayConnectionAccessRules(codeGroup); - // Delete default settings. - codeGroup->ResetConnectAccess(); - // Create an object that represents access to the ftp scheme and - // default port. - CodeConnectAccess^ CodeAccessFtp = - gcnew CodeConnectAccess(Uri::UriSchemeFtp, - CodeConnectAccess::DefaultPort); - // Create an object that represents access to the HTTPS scheme - // and default port. - CodeConnectAccess^ CodeAccessHttps = - gcnew CodeConnectAccess(Uri::UriSchemeHttps, - CodeConnectAccess::DefaultPort); - // Create an object that represents access to the origin scheme - // and port. - CodeConnectAccess^ CodeAccessOrigin = - CodeConnectAccess::CreateOriginSchemeAccess - (CodeConnectAccess::OriginPort); - - codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessFtp); - codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessHttps); - codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessOrigin); - Console::WriteLine("New NetCodeGroup settings:"); - DisplayConnectionAccessRules(codeGroup); -} -// - -static void DisplayConnectionAccessRules(NetCodeGroup^ group) -{ - array^ rules = - group->GetConnectAccessRules(); - for each (System::Collections::DictionaryEntry^ o in rules) - { - String^ key = (String^)(o->Key); - array^ values = (array^)(o->Value); - Console::WriteLine("Origin scheme: {0}", key); - for each (CodeConnectAccess^ c in values) - { - Console::WriteLine("Scheme {0} Port: {1}", c->Scheme, c->Port); - } - Console::WriteLine("__________________________"); - } -} -// - -int main() -{ - DisplayProperties(CreateFtpAndDefaultPortAccess()); - DisplayFields(); - DisplayProperties(CreateHttpAndOriginPortAccess()); - DisplayProperties(CreateAnySchemeOriginPortAccess()); - SetNetCodeGroupAccess(); - CreateNetCodeGroup(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp deleted file mode 100644 index 29feeb6784ad0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp +++ /dev/null @@ -1,93 +0,0 @@ -//NclMailASync - -// -#using -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; -using namespace System::Net::Mime; -using namespace System::Threading; -using namespace System::ComponentModel; - -static bool mailSent; - -static void SendCompletedCallback(Object^ sender, AsyncCompletedEventArgs^ e) -{ - // Get the unique identifier for this asynchronous - // operation. - String^ token = (String^) e->UserState; - - if (e->Cancelled) - { - Console::WriteLine("[{0}] Send canceled.", token); - } - if (e->Error != nullptr) - { - Console::WriteLine("[{0}] {1}", token, - e->Error->ToString()); - } else - { - Console::WriteLine("Message sent."); - } - mailSent = true; -} - -int main(array^ args) -{ - if (args->Length > 1) - { - // Command-line argument must be the SMTP host. - SmtpClient^ client = gcnew SmtpClient(args[1]); - // Specify the email sender. - // - // Create a mailing address that includes a UTF8 - // character in the display name. - MailAddress^ from = gcnew MailAddress("jane@contoso.com", - "Jane " + (wchar_t)0xD8 + " Clayton", - System::Text::Encoding::UTF8); - // - // Set destinations for the email message. - MailAddress^ to = gcnew MailAddress("ben@contoso.com"); - // Specify the message content. - // - MailMessage^ message = gcnew MailMessage(from, to); - message->Body = "This is a test email message sent" + - " by an application. "; - // Include some non-ASCII characters in body and - // subject. - String^ someArrows = gcnew String(gcnew array{L'\u2190', - L'\u2191', L'\u2192', L'\u2193'}); - message->Body += Environment::NewLine + someArrows; - message->BodyEncoding = System::Text::Encoding::UTF8; - message->Subject = "test message 1" + someArrows; - message->SubjectEncoding = System::Text::Encoding::UTF8; - // - // Set the method that is called back when the send - // operation ends. - client->SendCompleted += gcnew - SendCompletedEventHandler(SendCompletedCallback); - // The userState can be any object that allows your - // callback method to identify this send operation. - // For this example, the userToken is a string constant. - String^ userState = "test message1"; - client->SendAsync(message, userState); - Console::WriteLine("Sending message... press c to" + - " cancel mail. Press any other key to exit."); - String^ answer = Console::ReadLine(); - // If the user canceled the send, and mail hasn't been - // sent yet,then cancel the pending operation. - if (answer->ToLower()->StartsWith("c") && mailSent == false) - { - client->SendAsyncCancel(); - } - // Clean up. - delete message; - client = nullptr; - Console::WriteLine("Goodbye."); - } - else - { - Console::WriteLine("Please give SMTP server name!"); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/makefile deleted file mode 100644 index 2cd48a3137294..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -NclMailASync.exe : mailasync.cpp - cl /W4 /clr:pure /FeNclMailASync.exe mailasync.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp deleted file mode 100644 index 9e6468dcd8f82..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// NCLMailPerms -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; -using namespace System::Net::Mime; -using namespace System::Security::Permissions; - -namespace SmtpPermissionsExamples -{ - public ref class TestSmtpPermissions - { - public: - // - static SmtpPermission^ CreateConnectPermission() - { - SmtpPermission^ connectAccess = - gcnew SmtpPermission(SmtpAccess::Connect); - Console::WriteLine("Access? {0}", connectAccess->Access); - return connectAccess; - } - // - - // - static SmtpPermission^ CreateUnrestrictedPermission() - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - Console::WriteLine("Is unrestricted? {0}", - allAccess->IsUnrestricted()); - return allAccess; - } - // - - // - static SmtpPermission^ CreatePermissionCopy(SmtpPermission^ p) - { - SmtpPermission^ copy = (SmtpPermission^) p->Copy(); - return copy; - } - // - - // - static SmtpPermission^ CreateUnrestrictedPermission2() - { - SmtpPermission^ allAccess = gcnew SmtpPermission(true); - Console::WriteLine("Is unrestricted? {0}", - allAccess->IsUnrestricted()); - return allAccess; - } - // - - // - static SmtpPermission^ GiveFullAccess( - SmtpPermission^ permission) - { - permission->AddPermission(SmtpAccess::Connect); - return permission; - } - // - - // - static SmtpPermission^ IntersectionWithFull( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return (SmtpPermission^) permission->Intersect(allAccess); - } - // - - // - static bool CheckSubSet( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return permission->IsSubsetOf(allAccess); - } - // - - // - static SmtpPermission^ UnionWithFull( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return (SmtpPermission^) permission->Union(allAccess); - } - // - }; -}; - -int main() -{ -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoAsyncServer/CPP/NclNegoAsyncServer.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoAsyncServer/CPP/NclNegoAsyncServer.cpp deleted file mode 100644 index 6f24d42284f1f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoAsyncServer/CPP/NclNegoAsyncServer.cpp +++ /dev/null @@ -1,239 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::Net::Sockets; -using namespace System::Security::Authentication; -using namespace System::Security::Principal; -using namespace System::Text; -using namespace System::IO; -using namespace System::Threading; - -// ClientState is the AsyncState object. -private ref class ClientState -{ -private: - AuthenticatedStream^ authStream; - TcpClient^ client; - array^buffer; - StringBuilder^ message; - ManualResetEvent^ waiter; - -internal: - ClientState( AuthenticatedStream^ a, TcpClient^ theClient ) - { - authStream = a; - client = theClient; - message = nullptr; - buffer = gcnew array(2048); - waiter = gcnew ManualResetEvent( false ); - } - -internal: - property TcpClient^ Client - { - TcpClient^ get() - { - return client; - } - } - - property AuthenticatedStream^ AuthStream - { - AuthenticatedStream^ get() - { - return authStream; - } - } - - property array^ Buffer - { - array^ get() - { - return buffer; - } - - } - - property StringBuilder^ Message - { - StringBuilder^ get() - { - if ( message == nullptr ) - message = gcnew StringBuilder; - - return message; - } - - } - - property ManualResetEvent^ Waiter - { - ManualResetEvent^ get() - { - return waiter; - } - - } - -}; - -public ref class AsynchronousAuthenticatingTcpListener -{ -public: - int Main() - { - - // Create an IPv4 TCP/IP socket. - TcpListener^ listener = gcnew TcpListener( IPAddress::Any,11000 ); - - // Listen for incoming connections. - listener->Start(); - while ( true ) - { - TcpClient^ clientRequest = nullptr; - - // Application blocks while waiting for an incoming connection. - // Type CNTL-C to terminate the server. - clientRequest = listener->AcceptTcpClient(); - Console::WriteLine( L"Client connected." ); - - // A client has connected. - try - { - AuthenticateClient( clientRequest ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - continue; - } - - } - } - - - // - static void AuthenticateClient( TcpClient^ clientRequest ) - { - NetworkStream^ stream = clientRequest->GetStream(); - - // Create the NegotiateStream. - NegotiateStream^ authStream = gcnew NegotiateStream( stream,false ); - - // Save the current client and NegotiateStream instance - // in a ClientState object. - ClientState^ cState = gcnew ClientState( authStream,clientRequest ); - - // Listen for the client authentication request. - authStream->BeginAuthenticateAsServer( gcnew AsyncCallback( EndAuthenticateCallback ), cState ); - - // Wait until the authentication completes. - cState->Waiter->WaitOne(); - cState->Waiter->Reset(); - authStream->BeginRead( cState->Buffer, 0, cState->Buffer->Length, gcnew AsyncCallback( EndReadCallback ), cState ); - cState->Waiter->WaitOne(); - - // Finished with the current client. - authStream->Close(); - clientRequest->Close(); - } - - - // - // The following method is invoked by the - // BeginServerAuthenticate callback delegate. - // - static void EndAuthenticateCallback( IAsyncResult^ ar ) - { - - // Get the saved data. - ClientState^ cState = dynamic_cast(ar->AsyncState); - TcpClient^ clientRequest = cState->Client; - NegotiateStream^ authStream = dynamic_cast(cState->AuthStream); - Console::WriteLine( L"Ending authentication." ); - - // Any exceptions that occurred during authentication are - // thrown by the EndServerAuthenticate method. - try - { - - // This call blocks until the authentication is complete. - authStream->EndAuthenticateAsServer( ar ); - } - catch ( AuthenticationException^ e ) - { - Console::WriteLine( e ); - Console::WriteLine( L"Authentication failed - closing connection." ); - cState->Waiter->Set(); - return; - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - Console::WriteLine( L"Closing connection." ); - cState->Waiter->Set(); - return; - } - - - // Display properties of the authenticated client. - IIdentity^ id = authStream->RemoteIdentity; - Console::WriteLine( L"{0} was authenticated using {1}.", id->Name, id->AuthenticationType ); - cState->Waiter->Set(); - } - - - // - // - static void EndReadCallback( IAsyncResult^ ar ) - { - - // Get the saved data. - ClientState^ cState = dynamic_cast(ar->AsyncState); - TcpClient^ clientRequest = cState->Client; - NegotiateStream^ authStream = dynamic_cast(cState->AuthStream); - - // Get the buffer that stores the message sent by the client. - int bytes = -1; - - // Read the client message. - try - { - bytes = authStream->EndRead( ar ); - cState->Message->Append( Encoding::UTF8->GetChars( cState->Buffer, 0, bytes ) ); - if ( bytes != 0 ) - { - authStream->BeginRead( cState->Buffer, 0, cState->Buffer->Length, gcnew AsyncCallback( EndReadCallback ), cState ); - return; - } - } - catch ( Exception^ e ) - { - - // A real application should do something - // useful here, such as logging the failure. - Console::WriteLine( L"Client message exception:" ); - Console::WriteLine( e ); - cState->Waiter->Set(); - return; - } - - IIdentity^ id = authStream->RemoteIdentity; - Console::WriteLine( L"{0} says {1}", id->Name, cState->Message ); - cState->Waiter->Set(); - } - - // -}; - -void main() -{ - AsynchronousAuthenticatingTcpListener^ aatl = gcnew AsynchronousAuthenticatingTcpListener; - aatl->Main(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoSyncClient/CPP/NclNegoSyncClient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoSyncClient/CPP/NclNegoSyncClient.cpp deleted file mode 100644 index 1a0a913e1d9c4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoSyncClient/CPP/NclNegoSyncClient.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::Net::Sockets; -using namespace System::Security::Principal; - -// -static void DisplayStreamProperties( NegotiateStream^ stream ) -{ - Console::WriteLine( L"Can read: {0}", stream->CanRead ); - Console::WriteLine( L"Can write: {0}", stream->CanWrite ); - Console::WriteLine( L"Can seek: {0}", stream->CanSeek ); - try - { - - // If the underlying stream supports it, display the length. - Console::WriteLine( L"Length: {0}", stream->Length ); - } - catch ( NotSupportedException^ ) - { - Console::WriteLine( L"Cannot get the length of the underlying stream." ); - } - - if ( stream->CanTimeout ) - { - Console::WriteLine( L"Read time-out: {0}", stream->ReadTimeout ); - Console::WriteLine( L"Write time-out: {0}", stream->WriteTimeout ); - } -} - - -// -// -static void DisplayAuthenticationProperties( NegotiateStream^ stream ) -{ - Console::WriteLine( L"IsAuthenticated: {0}", stream->IsAuthenticated ); - Console::WriteLine( L"IsMutuallyAuthenticated: {0}", stream->IsMutuallyAuthenticated ); - Console::WriteLine( L"IsEncrypted: {0}", stream->IsEncrypted ); - Console::WriteLine( L"IsSigned: {0}", stream->IsSigned ); - Console::WriteLine( L"ImpersonationLevel: {0}", stream->ImpersonationLevel ); - Console::WriteLine( L"IsServer: {0}", stream->IsServer ); -} - - -// -// -int main() -{ - - // - // Establish the remote endpoint for the socket. - // For this example, use the local machine. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - - // Client and server use port 11000. - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - TcpClient^ client = gcnew TcpClient; - - // Connect the socket to the remote endpoint. - client->Connect( remoteEP ); - Console::WriteLine( L"Client connected to {0}.", remoteEP ); - - // Ensure the client does not close when there is - // still data to be sent to the server. - client->LingerState = (gcnew LingerOption( true,0 )); - - // Request authentication. - NetworkStream^ clientStream = client->GetStream(); - NegotiateStream^ authStream = gcnew NegotiateStream( clientStream ); - - // Request authentication for the client only (no mutual authentication). - // Authenicate using the client's default credetials. - // Permit the server to impersonate the client to access resources on the server only. - // Request that data be transmitted using encryption and data signing. - authStream->AuthenticateAsClient( dynamic_cast(CredentialCache::DefaultCredentials), - L"", - ProtectionLevel::EncryptAndSign, - TokenImpersonationLevel::Impersonation ); - - // - DisplayAuthenticationProperties( authStream ); - DisplayStreamProperties( authStream ); - if ( authStream->CanWrite ) - { - - // Encode the test data into a byte array. - array^message = System::Text::Encoding::UTF8->GetBytes( L"Hello from the client." ); - authStream->Write( message, 0, message->Length ); - authStream->Flush(); - Console::WriteLine( L"Sent {0} bytes.", message->Length ); - } - - - // Close the client connection. - authStream->Close(); - Console::WriteLine( L"Client closed." ); -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoSyncServer/CPP/NclNegoSyncServer.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoSyncServer/CPP/NclNegoSyncServer.cpp deleted file mode 100644 index b02ceda8bc7dd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoSyncServer/CPP/NclNegoSyncServer.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::Net::Sockets; -using namespace System::Security::Principal; -using namespace System::Text; -using namespace System::IO; -using namespace System::Threading; - -// -static void AuthenticateClient( TcpClient^ clientRequest ) -{ - NetworkStream^ stream = clientRequest->GetStream(); - - // Create the NegotiateStream. - NegotiateStream^ authStream = gcnew NegotiateStream( stream,false ); - - // Perform the server side of the authentication. - authStream->AuthenticateAsServer(); - - // Display properties of the authenticated client. - IIdentity^ id = authStream->RemoteIdentity; - Console::WriteLine( L"{0} was authenticated using {1}.", id->Name, id->AuthenticationType ); - - // Read a message from the client. - array^buffer = gcnew array(2048); - int charLength = authStream->Read( buffer, 0, buffer->Length ); - String^ messageData = gcnew String( Encoding::UTF8->GetChars( buffer, 0, buffer->Length ) ); - Console::WriteLine( L"READ {0}", messageData ); - - // Finished with the current client. - authStream->Close(); - - // Close the client connection. - clientRequest->Close(); -} - - -// -int main() -{ - - // Create an IPv4 TCP/IP socket. - TcpListener^ listener = gcnew TcpListener( IPAddress::Any,11000 ); - - // Listen for incoming connections. - listener->Start(); - while ( true ) - { - TcpClient^ clientRequest = nullptr; - - // Application blocks while waiting for an incoming connection. - // Type CNTL-C to terminate the server. - clientRequest = listener->AcceptTcpClient(); - - // A client has connected. - try - { - AuthenticateClient( clientRequest ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - continue; - } - - Console::WriteLine( L"Client connected." ); - } -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoasyncClient/CPP/NclNegoasyncClient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoasyncClient/CPP/NclNegoasyncClient.cpp deleted file mode 100644 index 8a961ac9aff45..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclNegoasyncClient/CPP/NclNegoasyncClient.cpp +++ /dev/null @@ -1,128 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::Net::Sockets; -using namespace System::Text; - -// -// The following class displays the properties of an authenticatedStream. -public ref class AuthenticatedStreamReporter -{ -public: - static void DisplayProperties( AuthenticatedStream^ stream ) - { - Console::WriteLine( L"IsAuthenticated: {0}", stream->IsAuthenticated ); - Console::WriteLine( L"IsMutuallyAuthenticated: {0}", stream->IsMutuallyAuthenticated ); - Console::WriteLine( L"IsEncrypted: {0}", stream->IsEncrypted ); - Console::WriteLine( L"IsSigned: {0}", stream->IsSigned ); - Console::WriteLine( L"IsServer: {0}", stream->IsServer ); - } - -}; - - -// -public ref class ASynchronousAuthenticatingTcpClient -{ -private: - static TcpClient^ client = nullptr; - -public: - void Main() - { - - // - // - // Establish the remote endpoint for the socket. - // For this example, use the local machine. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - - // Client and server use port 11000. - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - client = gcnew TcpClient; - - // Connect the socket to the remote endpoint. - client->Connect( remoteEP ); - Console::WriteLine( L"Client connected to {0}.", remoteEP ); - - // Ensure the client does not close when there is - // still data to be sent to the server. - client->LingerState = (gcnew LingerOption( true,0 )); - - // - // Request authentication. - NetworkStream^ clientStream = client->GetStream(); - NegotiateStream^ authStream = gcnew NegotiateStream( clientStream,false ); - - // - // Pass the NegotiateStream as the AsyncState object - // so that it is available to the callback delegate. - IAsyncResult^ ar = authStream->BeginAuthenticateAsClient( gcnew AsyncCallback( EndAuthenticateCallback ), authStream ); - - // - Console::WriteLine( L"Client waiting for authentication..." ); - - // Wait until the result is available. - ar->AsyncWaitHandle->WaitOne(); - - // Display the properties of the authenticated stream. - AuthenticatedStreamReporter::DisplayProperties( authStream ); - - // Send a message to the server. - // Encode the test data into a byte array. - array^message = Encoding::UTF8->GetBytes( L"Hello from the client." ); - ar = authStream->BeginWrite( message, 0, message->Length, gcnew AsyncCallback( EndWriteCallback ), authStream ); - - // - ar->AsyncWaitHandle->WaitOne(); - Console::WriteLine( L"Sent {0} bytes.", message->Length ); - - // Close the client connection. - authStream->Close(); - Console::WriteLine( L"Client closed." ); - } - - - // - // The following method is called when the authentication completes. - static void EndAuthenticateCallback( IAsyncResult^ ar ) - { - Console::WriteLine( L"Client ending authentication..." ); - NegotiateStream^ authStream = dynamic_cast(ar->AsyncState); - - // End the asynchronous operation. - authStream->EndAuthenticateAsClient( ar ); - - // Console.WriteLine("AllowedImpersonation: {0}", authStream.AllowedImpersonation); - } - - - // - // - // The following method is called when the write operation completes. - static void EndWriteCallback( IAsyncResult^ ar ) - { - Console::WriteLine( L"Client ending write operation..." ); - NegotiateStream^ authStream = dynamic_cast(ar->AsyncState); - - // End the asynchronous operation. - authStream->EndWrite( ar ); - } - - // -}; - -void main() -{ - ASynchronousAuthenticatingTcpClient^ aatc = gcnew ASynchronousAuthenticatingTcpClient; - aatc->Main(); -} -// - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp deleted file mode 100644 index ee93819179c6e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -void AddressChangedCallback( Object^ /*sender*/, EventArgs^ /*e*/ ) -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum = adapters->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - NetworkInterface^ n = safe_cast(myEnum->Current); - Console::WriteLine( " {0} is {1}", n->Name, n->OperationalStatus ); - } -} - -int main() -{ - NetworkChange::NetworkAddressChanged += gcnew NetworkAddressChangedEventHandler( AddressChangedCallback ); - Console::WriteLine( "Listening for address changes. Press any key to exit." ); - Console::ReadLine(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp deleted file mode 100644 index c38764723e020..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// NclNetworkInfoPerms -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -static void CreatePermission() -{ - - // - // - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ unrestricted = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::Unrestricted ); - - // - Console::WriteLine( L"Is unrestricted? {0}", unrestricted->IsUnrestricted() ); - - // - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ read = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read ); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ copyPermission = dynamic_cast(read->Copy()); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ unionPermission = dynamic_cast(read->Union( unrestricted )); - Console::WriteLine( L"Is subset?{0}", read->IsSubsetOf( unionPermission ) ); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ intersectPermission = dynamic_cast(read->Intersect( unrestricted )); - - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ permission = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::None ); - permission->AddPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read ); - Console::WriteLine( L"Access is {0}", permission->Access ); - - // -} - -int main() -{ - CreatePermission(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp deleted file mode 100644 index 813df811c2122..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -//NCLPingAsync -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::ComponentModel; -using namespace System::Threading; -void PingCompletedCallback( Object^ sender, PingCompletedEventArgs^ e ); -void DisplayReply( PingReply^ reply ); -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length == 1 ) - throw gcnew ArgumentException( "Ping needs a host or IP Address." ); - - String^ who = args[ 1 ]; - AutoResetEvent^ waiter = gcnew AutoResetEvent( false ); - - // - Ping ^ pingSender = gcnew Ping; - - // When the PingCompleted event is raised, - // the PingCompletedCallback method is called. - pingSender->PingCompleted += gcnew PingCompletedEventHandler( PingCompletedCallback ); - - // - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 12 seconds for a reply. - int timeout = 12000; - - // - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - Console::WriteLine( "Time to live: {0}", options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", options->DontFragment ); - - // - // Send the ping asynchronously. - // Use the waiter as the user token. - // When the callback completes, it can wake up this thread. - pingSender->SendAsync( who, timeout, buffer, options, waiter ); - - // Prevent this example application from ending. - // A real application should do something useful - // when possible. - waiter->WaitOne(); - Console::WriteLine( "Ping example completed." ); -} - - -// -void PingCompletedCallback( Object^ /*sender*/, PingCompletedEventArgs^ e ) -{ - - // If the operation was canceled, display a message to the user. - if ( e->Cancelled ) - { - Console::WriteLine( "Ping canceled." ); - - // Let the main thread resume. - // UserToken is the AutoResetEvent object that the main thread - // is waiting for. - (dynamic_cast(e->UserState))->Set(); - } - - - // If an error occurred, display the exception to the user. - if ( e->Error != nullptr ) - { - Console::WriteLine( "Ping failed:" ); - Console::WriteLine( e->Error->ToString() ); - - // Let the main thread resume. - (dynamic_cast(e->UserState))->Set(); - } - - PingReply ^ reply = e->Reply; - DisplayReply( reply ); - - // Let the main thread resume. - (dynamic_cast(e->UserState))->Set(); -} - - -// -// -void DisplayReply( PingReply ^ reply ) -{ - if ( reply == nullptr ) - return; - - Console::WriteLine( "ping status: {0}", reply->Status ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp deleted file mode 100644 index 49704c6adde83..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -//NCLPingSync -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::Text; - -// args[1] can be an IPaddress or host name. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // - // - Ping ^ pingSender = gcnew Ping; - PingOptions ^ options = gcnew PingOptions; - - // Use the default Ttl value which is 128, - // but change the fragmentation behavior. - options->DontFragment = true; - - // - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - int timeout = 120; - PingReply ^ reply = pingSender->Send( args[ 1 ], timeout, buffer, options ); - - // - // - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - - - // -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp deleted file mode 100644 index aed364516a4f7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp +++ /dev/null @@ -1,337 +0,0 @@ - -// NclSslClientAsync -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::Net::Sockets; -using namespace System::Security::Authentication; -using namespace System::Text; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -// The following example demonstrates the client side of a -// client-server application that communicates using the -// SslStream and TcpClient classes. -// After connecting to the server and authenticating, -// the client sends the server a message, receives a message from the server, -// and then terminates. Messages sent to and from the server are terminated -// with ''. -public ref class SslTcpClient -{ -private: - - // certificateErrors holds the mapping of Win32 results to descriptive strings. - // It is used by the CertificateErrorDescription method. - static Hashtable^ certificateErrors = gcnew Hashtable; - - // complete is used to terminate the application when all - // asynchronous calls have completed or any call has thrown an exception. - // complete might be used by any of the callback methods. - static bool complete = false; - - // e stores any exception thrown by an asynchronous method so that - // the mail application thread can display the exception and terminate gracefully. - // e might be used by any of the callback methods. - static Exception^ e = nullptr; - - // - // readData and buffer holds the data read from the server. - // They is used by the ReadCallback method. - static StringBuilder^ readData = gcnew StringBuilder; - static array^buffer = gcnew array(2048); - - // - // - // Load a table of errors that might cause the certificate authentication to fail. - static void InitializeCertificateErrors() - { - certificateErrors->Add( 0x800B0101, L"The certification has expired." ); - certificateErrors->Add( 0x800B0104, L"A path length constraint in the certification chain has been violated." ); - certificateErrors->Add( 0x800B0105, L"A certificate contains an unknown extension that is marked critical." ); - certificateErrors->Add( 0x800B0107, L"A parent of a given certificate in fact did not issue that child certificate." ); - certificateErrors->Add( 0x800B0108, L"A certificate is missing or has an empty value for a necessary field." ); - certificateErrors->Add( 0x800B0109, L"The certificate root is not trusted." ); - certificateErrors->Add( 0x800B010C, L"The certificate has been revoked." ); - certificateErrors->Add( 0x800B010F, L"The name in the certificate does not not match the host name requested by the client." ); - certificateErrors->Add( 0x800B0111, L"The certificate was explicitly marked as untrusted by the user." ); - certificateErrors->Add( 0x800B0112, L"A certification chain processed correctly, but one of the CA certificates is not trusted." ); - certificateErrors->Add( 0x800B0113, L"The certificate has an invalid policy." ); - certificateErrors->Add( 0x800B0114, L"The certificate name is either not in the permitted list or is explicitly excluded." ); - certificateErrors->Add( 0x80092012, L"The revocation function was unable to check revocation for the certificate." ); - certificateErrors->Add( 0x80090327, L"An unknown error occurred while processing the certificate." ); - certificateErrors->Add( 0x80096001, L"A system-level error occurred while verifying trust." ); - certificateErrors->Add( 0x80096002, L"The certificate for the signer of the message is invalid or not found." ); - certificateErrors->Add( 0x80096003, L"One of the counter signatures was invalid." ); - certificateErrors->Add( 0x80096004, L"The signature of the certificate cannot be verified." ); - certificateErrors->Add( 0x80096005, L"The time stamp signature or certificate could not be verified or is malformed." ); - certificateErrors->Add( 0x80096010, L"The digital signature of the object was not verified." ); - certificateErrors->Add( 0x80096019, L"The basic constraint extension of a certificate has not been observed." ); - } - - static String^ CertificateErrorDescription( int problem ) - { - - // Initialize the error message dictionary if it is not yet available. - if ( certificateErrors->Count == 0 ) - { - InitializeCertificateErrors(); - } - - String^ description = dynamic_cast(certificateErrors[ problem ]); - if ( description == nullptr ) - { - description = String::Format( L"Unknown certificate error - 0x{0:x8}", problem ); - } - - return description; - } - - -public: - - // The following method is invoked by the CertificateValidationDelegate. - static bool ValidateServerCertificate( - Object^ sender, - X509Certificate^ certificate, - X509Chain^ chain, - SslPolicyErrors sslPolicyErrors) - { - - Console::WriteLine("Validating the server certificate."); - if (sslPolicyErrors == SslPolicyErrors::None) - return true; - - Console::WriteLine("Certificate error: {0}", sslPolicyErrors); - - // Do not allow this client to communicate with unauthenticated servers. - return false; - } - - // - // - static X509Certificate^ SelectLocalCertificate( - Object^ sender, - String^ targetHost, - X509CertificateCollection^ localCertificates, - X509Certificate^ remoteCertificate, - array^ acceptableIssuers - ) - { - Console::WriteLine("Client is selecting a local certificate."); - if (acceptableIssuers != nullptr && - acceptableIssuers->Length > 0 && - localCertificates != nullptr && - localCertificates->Count > 0) - { - // Use the first certificate that is from an acceptable issuer. - IEnumerator^ myEnum1 = localCertificates->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - X509Certificate^ certificate = safe_cast(myEnum1->Current); - String^ issuer = certificate->Issuer; - if ( Array::IndexOf( acceptableIssuers, issuer ) != -1 ) - return certificate; - } - } - if (localCertificates != nullptr && - localCertificates->Count > 0) - return localCertificates[0]; - - return nullptr; - } - - // - // - static void AuthenticateCallback( IAsyncResult^ ar ) - { - SslStream^ stream = dynamic_cast(ar->AsyncState); - try - { - stream->EndAuthenticateAsClient( ar ); - Console::WriteLine( L"Authentication succeeded." ); - Console::WriteLine( L"Cipher: {0} strength {1}", stream->CipherAlgorithm, stream->CipherStrength ); - Console::WriteLine( L"Hash: {0} strength {1}", stream->HashAlgorithm, stream->HashStrength ); - Console::WriteLine( L"Key exchange: {0} strength {1}", stream->KeyExchangeAlgorithm, stream->KeyExchangeStrength ); - Console::WriteLine( L"Protocol: {0}", stream->SslProtocol ); - - // Encode a test message into a byte array. - // Signal the end of the message using the "". - array^message = Encoding::UTF8->GetBytes( L"Hello from the client." ); - - // Asynchronously send a message to the server. - stream->BeginWrite( message, 0, message->Length, gcnew AsyncCallback( WriteCallback ), stream ); - } - catch ( Exception^ authenticationException ) - { - e = authenticationException; - complete = true; - return; - } - - } - - - // - // - static void WriteCallback( IAsyncResult^ ar ) - { - SslStream^ stream = dynamic_cast(ar->AsyncState); - try - { - Console::WriteLine( L"Writing data to the server." ); - stream->EndWrite( ar ); - - // Asynchronously read a message from the server. - stream->BeginRead( buffer, 0, buffer->Length, gcnew AsyncCallback( ReadCallback ), stream ); - } - catch ( Exception^ writeException ) - { - e = writeException; - complete = true; - return; - } - - } - - - // - // - static void ReadCallback( IAsyncResult^ ar ) - { - - // Read the message sent by the server. - // The end of the message is signaled using the - // "" marker. - SslStream^ stream = dynamic_cast(ar->AsyncState); - int byteCount = -1; - try - { - Console::WriteLine( L"Reading data from the server." ); - byteCount = stream->EndRead( ar ); - - // Use Decoder class to convert from bytes to UTF8 - // in case a character spans two buffers. - Decoder^ decoder = Encoding::UTF8->GetDecoder(); - array^chars = gcnew array(decoder->GetCharCount( buffer, 0, byteCount )); - decoder->GetChars( buffer, 0, byteCount, chars, 0 ); - readData->Append( chars ); - - // Check for EOF or an empty message. - if ( readData->ToString()->IndexOf( L"" ) == -1 && byteCount != 0 ) - { - - // We are not finished reading. - // Asynchronously read more message data from the server. - stream->BeginRead( buffer, 0, buffer->Length, gcnew AsyncCallback( ReadCallback ), stream ); - } - else - { - Console::WriteLine( L"Message from the server: {0}", readData ); - } - } - catch ( Exception^ readException ) - { - e = readException; - complete = true; - return; - } - - complete = true; - } - - - // - // - int TestNclSslClient() - { - array^args = Environment::GetCommandLineArgs(); - String^ serverName = nullptr; - if ( args == nullptr || args->Length < 3 ) - { - Console::WriteLine( L"To start the client specify the host name and" - L" one or more client certificate file names." ); - return 1; - } - - - // - // Server name must match the host name and the name on the host's certificate. - serverName = args[ 1 ]; - - // Create a TCP/IP client socket. - TcpClient^ client = gcnew TcpClient( serverName,80 ); - Console::WriteLine( L"Client connected." ); - - // Create an SSL stream that will close the client's stream. - SslStream^ sslStream = gcnew SslStream( - client->GetStream(), - false, - gcnew RemoteCertificateValidationCallback( ValidateServerCertificate ), - gcnew LocalCertificateSelectionCallback( SelectLocalCertificate ) ); - - // - // Create the certificate collection to hold the client's certificate. - X509CertificateCollection^ clientCertificates = gcnew X509CertificateCollection; - for ( int i = 2; i < args->Length; i++ ) - { - X509Certificate^ certificate = X509Certificate::CreateFromCertFile( args[ i ] ); - clientCertificates->Add( certificate ); - - } - - // The server name must match the name on the server certificate. - sslStream->BeginAuthenticateAsClient( - serverName, - clientCertificates, - SslProtocols::Ssl3, - true, - gcnew AsyncCallback( AuthenticateCallback ), - sslStream ); - - // User can press a key to exit application, or let the - // asynchronous calls continue until they complete. - Console::WriteLine( L"To quit, press the enter key." ); - do - { - - // Real world applications would do work here - // while waiting for the asynchronous calls to complete. - System::Threading::Thread::Sleep( 100 ); - } - while ( complete != true && Console::KeyAvailable == false ); - - if ( Console::KeyAvailable ) - { - Console::ReadLine(); - Console::WriteLine( L"Quitting." ); - client->Close(); - sslStream->Close(); - return 1; - } - - if ( e != nullptr ) - { - Console::WriteLine( L"An exception was thrown: {0}", e ); - } - - sslStream->Close(); - client->Close(); - Console::WriteLine( L"Good bye." ); - return 0; - } - - // -}; - - -// -int main() -{ - SslTcpClient^ stc = gcnew SslTcpClient; - stc->TestNclSslClient(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp deleted file mode 100644 index 399131ddf3b64..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// NclSslClientSync -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::Net::Sockets; -using namespace System::Security::Authentication; -using namespace System::Text; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -namespace NlsClientSync -{ - public ref class SslTcpClient - { - private: - static Hashtable^ certificateErrors = gcnew Hashtable; - // - // Load a table of errors that might cause - // the certificate authentication to fail. - static void InitializeCertificateErrors() - { - certificateErrors->Add(0x800B0101, - "The certification has expired."); - certificateErrors->Add(0x800B0104, - "A path length constraint " - "in the certification chain has been violated."); - certificateErrors->Add(0x800B0105, - "A certificate contains an unknown extension " - "that is marked critical."); - certificateErrors->Add(0x800B0107, - "A parent of a given certificate in fact " - "did not issue that child certificate."); - certificateErrors->Add(0x800B0108, - "A certificate is missing or has an empty value " - "for a necessary field."); - certificateErrors->Add(0x800B0109, - "The certificate root is not trusted."); - certificateErrors->Add(0x800B010C, - "The certificate has been revoked."); - certificateErrors->Add(0x800B010F, - "The name in the certificate does not not match " - "the host name requested by the client."); - certificateErrors->Add(0x800B0111, - "The certificate was explicitly marked " - "as untrusted by the user."); - certificateErrors->Add(0x800B0112, - "A certification chain processed correctly, " - "but one of the CA certificates is not trusted."); - certificateErrors->Add(0x800B0113, - "The certificate has an invalid policy."); - certificateErrors->Add(0x800B0114, - "The certificate name is either not " - "in the permitted list or is explicitly excluded."); - certificateErrors->Add(0x80092012, - "The revocation function was unable to check " - "revocation for the certificate."); - certificateErrors->Add(0x80090327, - "An unknown error occurred while " - "processing the certificate."); - certificateErrors->Add(0x80096001, - "A system-level error occurred " - "while verifying trust."); - certificateErrors->Add(0x80096002, - "The certificate for the signer of the message " - "is invalid or not found."); - certificateErrors->Add(0x80096003, - "One of the counter signatures was invalid."); - certificateErrors->Add(0x80096004, - "The signature of the certificate " - "cannot be verified."); - certificateErrors->Add(0x80096005, - "The time stamp signature or certificate " - "could not be verified or is malformed."); - certificateErrors->Add(0x80096010, - "The digital signature of the object " - "was not verified."); - certificateErrors->Add(0x80096019, - "The basic constraint extension of a certificate " - "has not been observed."); - } - - static String^ CertificateErrorDescription(UInt32 problem) - { - // Initialize the error message dictionary - // if it is not yet available. - if (certificateErrors->Count == 0) - { - InitializeCertificateErrors(); - } - - String^ description = safe_cast( - certificateErrors[problem]); - if (description == nullptr) - { - description = String::Format( - CultureInfo::CurrentCulture, - "Unknown certificate error - 0x{0:x8}", - problem); - } - - return description; - } - - public: - // The following method is invoked - // by the CertificateValidationDelegate. - static bool ValidateServerCertificate( - Object^ sender, - X509Certificate^ certificate, - X509Chain^ chain, - SslPolicyErrors sslPolicyErrors) - { - - Console::WriteLine("Validating the server certificate."); - if (sslPolicyErrors == SslPolicyErrors::None) - return true; - - Console::WriteLine("Certificate error: {0}", sslPolicyErrors); - - // Do not allow this client to communicate with unauthenticated servers. - return false; - } - // - - // - static void RunClient(String^ machineName, String^ serverName) - { - - // - // - // Create a TCP/IP client socket. - // machineName is the host running the server application. - TcpClient^ client = gcnew TcpClient(machineName, 8080); - Console::WriteLine("Client connected."); - - // Create an SSL stream that will close - // the client's stream. - SslStream^ sslStream = gcnew SslStream( - client->GetStream(), false, - gcnew RemoteCertificateValidationCallback(ValidateServerCertificate), - nullptr); - - // The server name must match the name - // on the server certificate. - try - { - sslStream->AuthenticateAsClient(serverName); - } - catch (AuthenticationException^ ex) - { - Console::WriteLine("Exception: {0}", ex->Message); - if (ex->InnerException != nullptr) - { - Console::WriteLine("Inner exception: {0}", - ex->InnerException->Message); - } - - Console::WriteLine("Authentication failed - " - "closing the connection."); - sslStream->Close(); - client->Close(); - return; - } - // - // Encode a test message into a byte array. - // Signal the end of the message using the "". - array^ messsage = Encoding::UTF8->GetBytes( - "Hello from the client."); - - // Send hello message to the server. - sslStream->Write(messsage); - sslStream->Flush(); - // - // Read message from the server. - String^ serverMessage = ReadMessage(sslStream); - Console::WriteLine("Server says: {0}", serverMessage); - - // Close the client connection. - sslStream->Close(); - client->Close(); - Console::WriteLine("Client closed."); - } - // - // - private: - static String^ ReadMessage(SslStream^ sslStream) - { - - // Read the message sent by the server. - // The end of the message is signaled using the - // "" marker. - array^ buffer = gcnew array(2048); - StringBuilder^ messageData = gcnew StringBuilder; - // Use Decoder class to convert from bytes to UTF8 - // in case a character spans two buffers. - Encoding^ u8 = Encoding::UTF8; - Decoder^ decoder = u8->GetDecoder(); - - int bytes = -1; - do - { - bytes = sslStream->Read(buffer, 0, buffer->Length); - - array<__wchar_t>^ chars = gcnew array<__wchar_t>( - decoder->GetCharCount(buffer, 0, bytes)); - decoder->GetChars(buffer, 0, bytes, chars, 0); - messageData->Append(chars); - - // Check for EOF. - if (messageData->ToString()->IndexOf("") != -1) - { - break; - } - } - while (bytes != 0); - - return messageData->ToString(); - } - // - }; -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - String^ serverCertificateName = nullptr; - String^ machineName = nullptr; - if (args == nullptr || args->Length < 2) - { - Console::WriteLine("To start the client specify:"); - Console::WriteLine("clientSync machineName [serverName]"); - return 1; - } - - // User can specify the machine name and server name. - // Server name must match the name on - // the server's certificate. - machineName = args[1]; - if (args->Length < 3) - { - serverCertificateName = machineName; - } - else - { - serverCertificateName = args[2]; - }; - - NlsClientSync::SslTcpClient::RunClient(machineName, - serverCertificateName); - - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp deleted file mode 100644 index c4d7e313017c0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp +++ /dev/null @@ -1,265 +0,0 @@ - -// NclSslServerAsync -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Net::Security; -using namespace System::Security::Authentication; -using namespace System::Text; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -// The following example demonstrates the server side of a -// client-server application that communicates using the -// SslStream, TcpListener, and TcpClient classes. -// After connecting to the server and authenticating, -// the server reads a message from the client, -// sends a message to the client, -// and then terminates. Messages sent to and from the client are terminated -// with ''. -// The ClientState class holds information shared -// by asynchronous calls. -// -public ref class ClientState -{ -internal: - SslStream^ stream; - TcpClient^ client; - StringBuilder^ readData; - array^buffer; - ClientState( SslStream^ stream, TcpClient^ client ) - { - this->stream = stream; - this->client = client; - readData = gcnew StringBuilder; - buffer = gcnew array(2048); - } - - void Close() - { - - // Close the SslStream. This will also close the - // NetworkStream allocated to the TcpClient. - stream->Close(); - - // Close the TcpClient. - client->Close(); - readData = nullptr; - buffer = nullptr; - Console::WriteLine( L"Client closed." ); - } - -}; - - -// -public ref class SslTcpListener -{ -public: - - // - // The following method is invoked by the CertificateValidationDelegate. - static bool ValidateCertificate( - Object^ sender, - X509Certificate^ certificate, - X509Chain^ chain, - SslPolicyErrors sslPolicyErrors) - { - if ( certificate == nullptr ) - { - - // Null certificate and no errors means that the client was not - // required to provide a certificate. - if ( sslPolicyErrors == SslPolicyErrors::None) - { - return true; - } - else - { - Console::WriteLine(L"Certificate error: {0}", sslPolicyErrors); - } - return false; - } - - Console::WriteLine( L"Server is validating certificate." ); - Console::WriteLine( L"Certificate was issued to {0} and is valid from {1} until {2}.", - certificate->Subject, - certificate->GetEffectiveDateString(), - certificate->GetExpirationDateString() ); - return true; - } - - - // - // - void AuthenticateCallback( IAsyncResult^ ar ) - { - ClientState^ state = dynamic_cast(ar->AsyncState); - SslStream^ stream = state->stream; - try - { - stream->EndAuthenticateAsServer( ar ); - Console::WriteLine( L"Authentication succeeded." ); - Console::WriteLine( L"Cipher: {0} strength {1}", stream->CipherAlgorithm, stream->CipherStrength ); - Console::WriteLine( L"Hash: {0} strength {1}", stream->HashAlgorithm, stream->HashStrength ); - Console::WriteLine( L"Key exchange: {0} strength {1}", stream->KeyExchangeAlgorithm, stream->KeyExchangeStrength ); - Console::WriteLine( L"Protocol: {0}", stream->SslProtocol ); - - // Asynchronously read a message from the client. - stream->BeginRead( state->buffer, 0, state->buffer->Length, gcnew AsyncCallback( this, &SslTcpListener::ReadCallback ), state ); - } - catch ( Exception^ authenticationException ) - { - Console::WriteLine( L"Authentication error: {0}", authenticationException->Message ); - if ( authenticationException->InnerException != nullptr ) - { - Console::WriteLine( L" Inner exception: {0}", authenticationException->InnerException->Message ); - } - state->Close(); - return; - } - - } - - - // - // - void WriteCallback( IAsyncResult^ ar ) - { - ClientState^ state = dynamic_cast(ar->AsyncState); - SslStream^ stream = state->stream; - try - { - Console::WriteLine( L"Writing data to the client." ); - stream->EndWrite( ar ); - } - catch ( Exception^ writeException ) - { - Console::WriteLine( L"Write error: {0}", writeException->Message ); - state->Close(); - return; - } - - Console::WriteLine( L"Finished with client." ); - state->Close(); - } - - - // - // - void ReadCallback( IAsyncResult^ ar ) - { - ClientState^ state = dynamic_cast(ar->AsyncState); - SslStream^ stream = state->stream; - - // Read the message sent by the client. - // The end of the message is signaled using the - // "" marker. - int byteCount = -1; - try - { - Console::WriteLine( L"Reading data from the client." ); - byteCount = stream->EndRead( ar ); - - // Use Decoder class to convert from bytes to UTF8 - // in case a character spans two buffers. - Decoder^ decoder = Encoding::UTF8->GetDecoder(); - array^chars = gcnew array(decoder->GetCharCount( state->buffer, 0, byteCount )); - decoder->GetChars( state->buffer, 0, byteCount, chars, 0 ); - state->readData->Append( chars ); - - // Check for EOF or an empty message. - if ( state->readData->ToString()->IndexOf( L"" ) == -1 && byteCount != 0 ) - { - - // We are not finished reading. - // Asynchronously read more message data from the client. - stream->BeginRead( state->buffer, 0, state->buffer->Length, gcnew AsyncCallback( this, &SslTcpListener::ReadCallback ), state ); - } - else - { - Console::WriteLine( L"Message from the client: {0}", state->readData ); - } - - // Encode a test message into a byte array. - // Signal the end of the message using "". - array^message = Encoding::UTF8->GetBytes( L"Hello from the server." ); - - // Asynchronously send the message to the client. - stream->BeginWrite( message, 0, message->Length, gcnew AsyncCallback( this, &SslTcpListener::WriteCallback ), state ); - } - catch ( Exception^ readException ) - { - Console::WriteLine( L"Read error: {0}", readException->Message ); - state->Close(); - return; - } - - } - - - // - // - void ProcessClient( ClientState^ state, X509Certificate^ serverCertificate ) - { - try - { - state->stream->BeginAuthenticateAsServer( - serverCertificate, true, SslProtocols::Tls, true, - gcnew AsyncCallback( this, &SslTcpListener::AuthenticateCallback ), state ); - } - catch ( Exception^ authenticationException ) - { - Console::WriteLine( L"Authentication error: {0}", authenticationException->Message ); - state->Close(); - return; - } - - } - - - // - // - int ServerSideTest() - { - array^args = Environment::GetCommandLineArgs(); - if ( args == nullptr || args->Length == 0 ) - { - Console::WriteLine( L"You must specify the server certificate file." ); - return 0; - } - - X509Certificate^ serverCertificate = X509Certificate::CreateFromCertFile( args[ 1 ] ); - - // Create a TCP/IP (IPv4) socket and listen for incoming connections. - TcpListener^ listener = gcnew TcpListener( IPAddress::Any,8080 ); - listener->Start(); - while ( true ) - { - - // Application blocks while waiting for an incoming connection. - // Type CNTL-C to terminate the server. - TcpClient^ client = listener->AcceptTcpClient(); - Console::WriteLine( L"Client connected." ); - SslStream^ stream = gcnew SslStream( client->GetStream(),false, - gcnew RemoteCertificateValidationCallback( ValidateCertificate ) ); - ClientState^ state = gcnew ClientState( stream,client ); - SslTcpListener^ listenerWorker = gcnew SslTcpListener; - listenerWorker->ProcessClient( state, serverCertificate ); - } - } - - // -}; - -int main() -{ - SslTcpListener^ stl = gcnew SslTcpListener; - stl->ServerSideTest(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp deleted file mode 100644 index fd1b337702e24..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp +++ /dev/null @@ -1,234 +0,0 @@ - -// NclSslServerSync -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Net::Security; -using namespace System::Security::Authentication; -using namespace System::Text; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; -public ref class SslTcpServer sealed -{ -private: - static X509Certificate^ serverCertificate = nullptr; - -public: - - // The certificate parameter specifies the name of the file - // containing the machine certificate. - static void RunServer( String^ certificate ) - { - serverCertificate = X509Certificate::CreateFromCertFile( certificate ); - - // Create a TCP/IP (IPv4) socket and listen for incoming connections. - TcpListener^ listener = gcnew TcpListener( IPAddress::Any,8080 ); - listener->Start(); - - while (true) - { - Console::WriteLine( L"Waiting for a client to connect..." ); - - // Application blocks while waiting for an incoming connection. - // Type CNTL-C to terminate the server. - TcpClient^ client = listener->AcceptTcpClient(); - ProcessClient( client ); - - } - } - - - // - static void ProcessClient( TcpClient^ client ) - { - - // A client has connected. Create the - // SslStream using the client's network stream. - SslStream^ sslStream = gcnew SslStream( client->GetStream(),false ); - - // Authenticate the server but don't require the client to authenticate. - try - { - sslStream->AuthenticateAsServer( serverCertificate, false, true ); - // false == no client cert required; true == check cert revocation. - - // Display the properties and settings for the authenticated stream. - DisplaySecurityLevel( sslStream ); - DisplaySecurityServices( sslStream ); - DisplayCertificateInformation( sslStream ); - DisplayStreamProperties( sslStream ); - - // Set timeouts for the read and write to 5 seconds. - sslStream->ReadTimeout = 5000; - sslStream->WriteTimeout = 5000; - - // Read a message from the client. - Console::WriteLine( L"Waiting for client message..." ); - String^ messageData = ReadMessage( sslStream ); - Console::WriteLine( L"Received: {0}", messageData ); - - // Write a message to the client. - array^message = Encoding::UTF8->GetBytes( L"Hello from the server." ); - Console::WriteLine( L"Sending hello message." ); - sslStream->Write( message ); - } - catch ( AuthenticationException^ e ) - { - Console::WriteLine( L"Exception: {0}", e->Message ); - if ( e->InnerException != nullptr ) - { - Console::WriteLine( L"Inner exception: {0}", e->InnerException->Message ); - } - Console::WriteLine( L"Authentication failed - closing the connection." ); - sslStream->Close(); - client->Close(); - return; - } - finally - { - - // The client stream will be closed with the sslStream - // because we specified this behavior when creating - // the sslStream. - sslStream->Close(); - client->Close(); - } - - } - - - // - // - static String^ ReadMessage( SslStream^ sslStream ) - { - - // Read the message sent by the client. - // The client signals the end of the message using the - // "" marker. - array^buffer = gcnew array(2048); - StringBuilder^ messageData = gcnew StringBuilder; - int bytes = -1; - do - { - - // Read the client's test message. - bytes = sslStream->Read( buffer, 0, buffer->Length ); - - // Use Decoder class to convert from bytes to UTF8 - // in case a character spans two buffers. - Decoder^ decoder = Encoding::UTF8->GetDecoder(); - array^chars = gcnew array(decoder->GetCharCount( buffer, 0, bytes )); - decoder->GetChars( buffer, 0, bytes, chars, 0 ); - messageData->Append( chars ); - - // Check for EOF or an empty message. - if ( messageData->ToString()->IndexOf( L"" ) != -1 ) - { - break; - } - } - while ( bytes != 0 ); - - return messageData->ToString(); - } - - - // - // - static void DisplaySecurityLevel( SslStream^ stream ) - { - Console::WriteLine( L"Cipher: {0} strength {1}", stream->CipherAlgorithm, stream->CipherStrength ); - Console::WriteLine( L"Hash: {0} strength {1}", stream->HashAlgorithm, stream->HashStrength ); - Console::WriteLine( L"Key exchange: {0} strength {1}", stream->KeyExchangeAlgorithm, stream->KeyExchangeStrength ); - Console::WriteLine( L"Protocol: {0}", stream->SslProtocol ); - } - - - // - // - static void DisplaySecurityServices( SslStream^ stream ) - { - Console::WriteLine( L"Is authenticated: {0} as server? {1}", stream->IsAuthenticated, stream->IsServer ); - Console::WriteLine( L"IsSigned: {0}", stream->IsSigned ); - Console::WriteLine( L"Is Encrypted: {0}", stream->IsEncrypted ); - } - - - // - // - static void DisplayStreamProperties( SslStream^ stream ) - { - Console::WriteLine( L"Can read: {0}, write {1}", stream->CanRead, stream->CanWrite ); - Console::WriteLine( L"Can timeout: {0}", stream->CanTimeout ); - } - - - // - // - static void DisplayCertificateInformation( SslStream^ stream ) - { - Console::WriteLine( L"Certificate revocation list checked: {0}", stream->CheckCertRevocationStatus ); - X509Certificate^ localCertificate = stream->LocalCertificate; - if ( stream->LocalCertificate != nullptr ) - { - Console::WriteLine( L"Local cert was issued to {0} and is valid from {1} until {2}.", - localCertificate->Subject, - localCertificate->GetEffectiveDateString(), - localCertificate->GetExpirationDateString() ); - } - else - { - Console::WriteLine( L"Local certificate is null." ); - } - - X509Certificate^ remoteCertificate = stream->RemoteCertificate; - if ( stream->RemoteCertificate != nullptr ) - { - Console::WriteLine( L"Remote cert was issued to {0} and is valid from {1} until {2}.", - remoteCertificate->Subject, - remoteCertificate->GetEffectiveDateString(), - remoteCertificate->GetExpirationDateString() ); - } - else - { - Console::WriteLine( L"Remote certificate is null." ); - } - } - - -private: - - // - static void DisplayUsage() - { - Console::WriteLine( L"To start the server specify:" ); - Console::WriteLine( L"serverSync certificateFile.cer" ); - Environment::Exit( 1 ); - } - -public: - int RunServerASync() - { - array^args = Environment::GetCommandLineArgs(); - String^ certificate = nullptr; - if ( args == nullptr || args->Length < 2 ) - { - DisplayUsage(); - } - - certificate = args[ 1 ]; - SslTcpServer::RunServer( certificate ); - return 0; - } - -}; - -int main(){ - SslTcpServer^ sts = gcnew SslTcpServer(); - sts->RunServerASync(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/makefile deleted file mode 100644 index 72e67f7e20e2c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -NclTcpServerSync.exe : tcplistener.cpp - cl /clr:pure /FeNclTcpServerSync.exe tcplistener.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp deleted file mode 100644 index 36b29236e7815..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -#using -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -int main() -{ - // Create the server side connection and - // start listening for clients. - TcpListener^ tcpListener = gcnew TcpListener(IPAddress::Any, 11000); - tcpListener->Start(); - Console::WriteLine("Waiting for a connection...."); - - // Accept the pending client connection. - TcpClient^ tcpClient = tcpListener->AcceptTcpClient(); - Console::WriteLine("Connection accepted."); - // Get the stream to write the message - // that will be sent to the client. - NetworkStream^ networkStream = tcpClient->GetStream(); - String^ responseString = "Hello."; - // Set the write timeout to 10 millseconds. - networkStream->WriteTimeout = 10; - // Convert the message to a byte array and sent it to the client. - array^ sendBytes = Encoding::UTF8->GetBytes(responseString); - networkStream->Write(sendBytes, 0, sendBytes->Length); - Console::WriteLine("Message Sent."); - // Close the connection to the client. - tcpClient->Close(); - // Stop listening for incoming connections - // and close the server. - tcpListener->Stop(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/makefile deleted file mode 100644 index 1af47739763f3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -NestingLevel.exe : nestinglevel.cpp - cl /W4 /clr:pure /FeNestingLevel.exe nestinglevel.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp deleted file mode 100644 index 1418ec5d41410..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class Forest -{ - // Set the NestingLevel for each array. The first - // attribute (NestingLevel = 0) is optional. -public: - [XmlArrayItem(ElementName = "tree", NestingLevel = 0)] - [XmlArrayItem(ElementName = "branch", NestingLevel = 1)] - [XmlArrayItem(ElementName = "leaf",NestingLevel = 2)] - array^>^>^ TreeArray; -}; - -int main() -{ - XmlSerializer^ serializer = gcnew XmlSerializer(Forest::typeid); - - Forest^ constructedForest = gcnew Forest(); - array^>^>^ tree = - gcnew array^>^>(2); - - array^>^ firstBranch = gcnew array^>(1); - firstBranch[0] = gcnew array{"One"}; - tree[0] = firstBranch; - - array^>^ secondBranch = gcnew array^>(2); - secondBranch[0] = gcnew array{"One","Two"}; - secondBranch[1] = gcnew array{"One","Two","Three"}; - tree[1] = secondBranch; - - constructedForest->TreeArray = tree; - - serializer->Serialize(Console::Out, constructedForest); -} - -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp deleted file mode 100644 index 1ad521299e22b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Net::NetworkCredential::NetworkCredential(String*, String*) - -/*This program demontrates the 'NetworkCredential(String*, String*)' constructor of 'NetworkCredential' class. -It takes an URL, username, password and domainname from console and forms a 'NetworkCredential' Object* with -these arguments.Then a 'WebRequest' Object* is created and the 'NetworkCredential' Object* is associated with -it.A message is displayed onto the console on successful reception of response otherwise an exception is thrown. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url, String^ username, String^ passwd, String^ domain ) -{ - try - { -// - // Call the onstructor to create an instance of NetworkCredential with the - // specified user name and password. - NetworkCredential^ myCredentials = gcnew NetworkCredential( username,passwd ); - - // Create a WebRequest with the specified URL. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myCredentials->Domain = domain; - myWebRequest->Credentials = myCredentials; - Console::WriteLine( "\n\nCredentials Domain : {0} , UserName : {1} , Password : {2}", - myCredentials->Domain, myCredentials->UserName, myCredentials->Password ); - Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response..." ); - - // Send the request and wait for a response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response. - Console::WriteLine( "\nResponse received successfully." ); - - // Release the resources of the response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException is raised.The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 5 ) - { - Console::WriteLine( "\nPlease enter a protected resource Url and other details as command line parameter as below:" ); - Console::WriteLine( "\nUsage: NetworkCredential_Constructor2 URLname username password domainname" ); - Console::WriteLine( "\nExample: NetworkCredential_Constructor2 http://dotnet.microsoft.com/ george george123 microsoft" ); - } - else - { - GetPage( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ] ); - } - - Console::WriteLine( "\n\nPress 'Enter key' to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp deleted file mode 100644 index d4f7d1217e7c1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp +++ /dev/null @@ -1,68 +0,0 @@ - - -// System::Net::NetworkCredential::GetCredential -/*This program demontrates the 'GetCredential' of 'NetworkCredential' class. -It accepts an URL, username and password from console. Creates a 'NetworkCredential' Object* -using these parameters. A 'WebRequest' Object* is created to access the Uri S"http://www.microsoft.com" -and the 'NetworkCredential' Object* is assigned as it's Credentials. -A message is displayed onto the console on successful reception of response -otherwise an exception is thrown. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url, String^ userName, String^ password ) -{ - try - { -// - // Create an empty instance of the NetworkCredential class. - NetworkCredential^ myCredentials = gcnew NetworkCredential( userName,password ); - - // Create a webrequest with the specified URL. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentials->GetCredential( gcnew Uri( url ), "" ); - Console::WriteLine( "\n\nUser Credentials:- UserName : {0} , Password : {1}", - myCredentials->UserName, myCredentials->Password ); - - // Send the request and wait for a response. - Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response...Please wait ..." ); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response. - Console::WriteLine( "\nResponse received sucessfully" ); - - // Release the resources of the response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException is raised.The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\nPlease enter a protected resource Url and other details as* command line parameter as below:" ); - Console::WriteLine( "\nUsage: NetworkCredential_GetCredential URLname username password" ); - Console::WriteLine( "\nExample: NetworkCredential_GetCredential http://dotnet.microsoft.com/ george george123" ); - } - else - { - GetPage( args[ 1 ], args[ 2 ], args[ 3 ] ); - } - - Console::WriteLine( "\n\nPress 'Enter' to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp deleted file mode 100644 index 47fb7e93ba3d9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// System::Net::NetworkCredential::Username;System::Net::NetworkCredential::Domain;System::Net::NetworkCredential::Password -/*This program demontrates the 'UserName', 'Domain' and 'Password' properties of 'NetworkCredential' class. -It takes an URL, username, password and domainname from console. An empty 'NetworkCredential' Object* -is created.The 'UserName' , 'Password' and 'Domain' porperties of 'NetworkCredential' class are initialised -with the respective values taken from console. Then a 'WebRequest' Object* is created and the 'NetworkCredential' -Object* is associated with it.A message is displayed onto the console on successful reception of response -otherwise an exception is thrown. -*/ - -#using - -using namespace System; -using namespace System::Net; -void GetPage( String^ url, String^ username, String^ passwd, String^ domain ) -{ - try - { -// -// -// - // Create an empty instance of the NetworkCredential class. - NetworkCredential^ myCredentials = gcnew NetworkCredential( "","","" ); - myCredentials->Domain = domain; - myCredentials->UserName = username; - myCredentials->Password = passwd; - - // Create a WebRequest with the specified URL. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentials; - Console::WriteLine( "\n\nUser Credentials:- Domain : {0} , UserName : {1} , Password : {2}", - myCredentials->Domain, myCredentials->UserName, myCredentials->Password ); - - // Send the request and wait for a response. - Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response...Please wait ..." ); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response. - Console::WriteLine( "\nResponse received sucessfully" ); - - // Release the resources of the response object. - myWebResponse->Close(); -// -// -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException is raised.The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 5 ) - { - Console::WriteLine( "\nPlease enter a protected resource Url and other details as command line parameter as below:" ); - Console::WriteLine( "\nUsage: NetworkCredential_UserName_Password_Domain URLname username password domainname" ); - Console::WriteLine( "\nExample: NetworkCredential_UserName_Password_Domain http://dotnet.microsoft.com/ george george123 microsoft" ); - } - else - { - GetPage( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ] ); - } - - Console::WriteLine( "\n\nPress 'Enter key' to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Async_SendAndReceive/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Async_SendAndReceive/CPP/source.cpp deleted file mode 100644 index c2a97a0eded60..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Async_SendAndReceive/CPP/source.cpp +++ /dev/null @@ -1,137 +0,0 @@ - - -// The following sample is intended to demonstrate how to use a -//NetworkStream for synchronous communcation with a remote host -//This class uses several NetworkStream members that would be useful -// in a synchronous communciation senario -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -ref class MyNetworkStreamClass -{ -public: - - // - - // Example of EndWrite - static void myWriteCallBack( IAsyncResult^ ar ) - { - NetworkStream^ myNetworkStream = safe_cast(ar->AsyncState); - myNetworkStream->EndWrite( ar ); - } - // - - // - // Example of EndRead, DataAvailable and BeginRead. - static void myReadCallBack( IAsyncResult^ ar ) - { - NetworkStream^ myNetworkStream = safe_cast(ar->AsyncState); - array^myReadBuffer = gcnew array(1024); - String^ myCompleteMessage = ""; - int numberOfBytesRead; - numberOfBytesRead = myNetworkStream->EndRead( ar ); - myCompleteMessage = String::Concat( myCompleteMessage, Encoding::ASCII->GetString( myReadBuffer, 0, numberOfBytesRead ) ); - - // message received may be larger than buffer size so loop through until you have it all. - while ( myNetworkStream->DataAvailable ) - { - AsyncCallback^ pasync = gcnew AsyncCallback( &myReadCallBack ); - myNetworkStream->BeginRead( myReadBuffer, 0, myReadBuffer->Length, pasync, myNetworkStream ); - } - - // Print out the received message to the console. - Console::WriteLine( "You received the following message : {0}", myCompleteMessage ); - } - // - - static void MySample( bool networkStreamOwnsSocket ) - { - ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - - // Create a socket and connect with a remote host. - IPHostEntry^ myIpHostEntry = Dns::GetHostEntry( "www.contoso.com" ); - IPEndPoint^ myIpEndPoint = gcnew IPEndPoint( myIpHostEntry->AddressList[ 0 ],1001 ); - Socket^ mySocket = gcnew Socket( myIpEndPoint->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - try - { - // - // Example for creating a NetworkStreams - mySocket->Connect( myIpEndPoint ); - - // Create the NetworkStream for communicating with the remote host. - NetworkStream^ myNetworkStream; - if ( networkStreamOwnsSocket ) - { - myNetworkStream = gcnew NetworkStream( mySocket,FileAccess::ReadWrite,true ); - } - else - { - myNetworkStream = gcnew NetworkStream( mySocket,FileAccess::ReadWrite ); - } - // - - // - // Example of CanWrite, and BeginWrite. - // Check to see if this NetworkStream is writable. - if ( myNetworkStream->CanWrite ) - { - array^myWriteBuffer = Encoding::ASCII->GetBytes( "Are you receiving this message?" ); - myNetworkStream->BeginWrite( myWriteBuffer, 0, myWriteBuffer->Length, gcnew AsyncCallback( &MyNetworkStreamClass::myWriteCallBack ), myNetworkStream ); - allDone->WaitOne(); - } - else - { - Console::WriteLine( "Sorry. You cannot write to this NetworkStream." ); - } - // - - // - // Example of CanRead, and BeginRead. - // Check to see if this NetworkStream is readable. - if ( myNetworkStream->CanRead ) - { - array^myReadBuffer = gcnew array(1024); - myNetworkStream->BeginRead( myReadBuffer, 0, myReadBuffer->Length, gcnew AsyncCallback( &MyNetworkStreamClass::myReadCallBack ), myNetworkStream ); - allDone->WaitOne(); - } - else - { - Console::WriteLine( "Sorry. You cannot read from this NetworkStream." ); - } - // - - // Close the NetworkStream - myNetworkStream->Close(); - } - catch ( Exception^ exception ) - { - Console::WriteLine( "Exception Thrown: {0}", exception ); - } - } -}; - -int main( int argc, char *argv[] ) -{ - if ( "yes" == gcnew String(argv[1]) ) - { - MyNetworkStreamClass::MySample( true ); - } - else - if ( "no" == gcnew String(argv[1]) ) - { - MyNetworkStreamClass::MySample( false ); - } - else - { - Console::WriteLine( "Must use 'yes' to allow the NetworkStream to own the Socket or {0}", "\n 'no' to prohibit NetworkStream from owning the Socket." ); - } -} - -//Output: -//-1, 234.00 -//(-)1, 234.00 diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp deleted file mode 100644 index 17f565e5d3c2a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -ref class MyNetworkStream_Sub_Class: public NetworkStream -{ -public: - MyNetworkStream_Sub_Class( System::Net::Sockets::Socket^ socket, bool ownsSocket ) - : NetworkStream( socket, ownsSocket ) - { - } - - property bool IsConnected - { - // You can use the Socket method to examine the underlying Socket. - bool get() - { - return this->Socket->Connected; - } - } - - property bool CanCommunicate - { - bool get() - { - if ( !this->Readable | !this->Writeable ) - { - return false; - } - else - { - return true; - } - } - } -// - - static void DoSomethingSignificant() - { - // Do something significant in here - } - -}; - -int main() -{ - MyNetworkStream_Sub_Class::DoSomethingSignificant(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp deleted file mode 100644 index 1a8522fdbae29..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// The following sample is intended to demonstrate how to use a -//NetworkStream for synchronous communcation with a remote host -//This class uses several NetworkStream members that would be useful -// in a synchronous communciation senario - -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -void MySample( bool networkStreamOwnsSocket ) -{ - // - // This should be the classwide example. - // Create a socket and connect with a remote host. - IPHostEntry^ myIpHostEntry = Dns::GetHostEntry( "www.contoso.com" ); - IPEndPoint^ myIpEndPoint = gcnew IPEndPoint( myIpHostEntry->AddressList[ 0 ],1001 ); - - Socket^ mySocket = gcnew Socket( myIpEndPoint->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - mySocket->Connect( myIpEndPoint ); - - // - // Examples for constructors that do not specify file permission. - // Create the NetworkStream for communicating with the remote host. - NetworkStream^ myNetworkStream; - - if ( networkStreamOwnsSocket ) - { - myNetworkStream = gcnew NetworkStream( mySocket,true ); - } - else - { - myNetworkStream = gcnew NetworkStream( mySocket ); - } - // - - // - // Examples for CanWrite, and CanWrite - // Check to see if this NetworkStream is writable. - if ( myNetworkStream->CanWrite ) - { - array^ myWriteBuffer = Encoding::ASCII->GetBytes( - "Are you receiving this message?" ); - myNetworkStream->Write( myWriteBuffer, 0, myWriteBuffer->Length ); - } - else - { - Console::WriteLine( "Sorry. You cannot write to this NetworkStream." ); - } - // - - // - // Examples for CanRead, Read, and DataAvailable. - // Check to see if this NetworkStream is readable. - if ( myNetworkStream->CanRead ) - { - array^ myReadBuffer = gcnew array(1024); - String^ myCompleteMessage = ""; - int numberOfBytesRead = 0; - - // Incoming message may be larger than the buffer size. - do - { - numberOfBytesRead = myNetworkStream->Read( myReadBuffer, 0, - myReadBuffer->Length ); - myCompleteMessage = String::Concat( myCompleteMessage, - Encoding::ASCII->GetString( myReadBuffer, 0, numberOfBytesRead ) ); - } - while ( myNetworkStream->DataAvailable ); - - // Print out the received message to the console. - Console::WriteLine( "You received the following message : {0}", - myCompleteMessage ); - } - else - { - Console::WriteLine( "Sorry. You cannot read from this NetworkStream." ); - } - // - - // - // Example for closing the NetworkStream. - // Close the NetworkStream - myNetworkStream->Close(); - // - - } - catch ( Exception^ exception ) - { - Console::WriteLine( "Exception Thrown: {0}", exception->ToString() ); - } -} -// - -int main( int argc, char *argv[] ) -{ - if ( "yes" == gcnew String(argv[1]) ) - { - MySample( true ); - } - else - if ( "no" == gcnew String(argv[1]) ) - { - MySample( false ); - } - else - { - Console::WriteLine( "Must use 'yes' to allow the NetworkStream to own the Socket or {0}", "\n 'no' to prohibit NetworkStream from owning the Socket." ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ObjectHandle/CPP/objecthandleassembly.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ObjectHandle/CPP/objecthandleassembly.cpp deleted file mode 100644 index 6afe3a48d866b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ObjectHandle/CPP/objecthandleassembly.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::Remoting; -public ref class MyType: public MarshalByRefObject -{ -public: - MyType() - { - Console::Write( "Created an instance of MyType in an AppDomain with the " ); - Console::WriteLine( "hash code {0}", AppDomain::CurrentDomain->GetHashCode() ); - Console::WriteLine( "" ); - } - - int GetAppDomainHashCode() - { - return AppDomain::CurrentDomain->GetHashCode(); - } - -}; - -int main() -{ - Console::WriteLine( "The hash code of the default AppDomain is {0}.", AppDomain::CurrentDomain->GetHashCode() ); - Console::WriteLine( "" ); - - // Creates another AppDomain. - AppDomain^ domain = AppDomain::CreateDomain( "AnotherDomain", nullptr, (AppDomainSetup^)nullptr ); - - // - // Creates an instance of MyType defined in the assembly called ObjectHandleAssembly. - ObjectHandle^ obj = domain->CreateInstance( "ObjectHandleAssembly", "MyType" ); - - // Unwraps the proxy to the MyType object created in the other AppDomain. - MyType^ testObj = dynamic_cast(obj->Unwrap()); - if ( RemotingServices::IsTransparentProxy( testObj ) ) - Console::WriteLine( "The unwrapped object is a proxy." ); - else - Console::WriteLine( "The unwrapped object is not a proxy!" ); - - Console::WriteLine( "" ); - Console::Write( "Calling a method on the object located in an AppDomain with the hash code " ); - Console::WriteLine( testObj->GetAppDomainHashCode() ); - - // -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationBindingCollection_OperationBindingCollection/CPP/MathService_input_cpp.wsdl b/samples/snippets/cpp/VS_Snippets_Remoting/OperationBindingCollection_OperationBindingCollection/CPP/MathService_input_cpp.wsdl deleted file mode 100644 index fa9de60ff9a91..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationBindingCollection_OperationBindingCollection/CPP/MathService_input_cpp.wsdl +++ /dev/null @@ -1,312 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationBindingCollection_OperationBindingCollection/CPP/operationbindingcollection_operationbindingcollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationBindingCollection_OperationBindingCollection/CPP/operationbindingcollection_operationbindingcollection.cpp deleted file mode 100644 index 73662f4cd6683..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationBindingCollection_OperationBindingCollection/CPP/operationbindingcollection_operationbindingcollection.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// System.Web.Services.Description.OperationBindingCollection -// System.Web.Services.Description.OperationBindingCollection.Contains -// System.Web.Services.Description.OperationBindingCollection.Add -// System.Web.Services.Description.OperationBindingCollection.Item -// System.Web.Services.Description.OperationBindingCollection.Remove -// System.Web.Services.Description.OperationBindingCollection.Insert -// System.Web.Services.Description.OperationBindingCollection.IndexOf -// System.Web.Services.Description.OperationBindingCollection.CopyTo - -/* -The following example demonstrates the usage of the -'OperationBindingCollection' class, the 'Item' property and various methods of the -class. The input to the program is a WSDL file 'MathService_input_cpp.wsdl' without -the add operation binding of SOAP protocol. In this example the WSDL file -is modified to insert a new 'OperationBinding' for SOAP. The -'OperationBindingCollection' is populated based on WSDL document -structure defined in WSDL specification. The updated instance is then -written to 'MathService_new_cpp.wsdl'. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -int main() -{ - try - { - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input_cpp.wsdl" ); - - // Add the OperationBinding for the Add operation. - OperationBinding^ addOperationBinding = gcnew OperationBinding; - String^ addOperation = "Add"; - String^ myTargetNamespace = myServiceDescription->TargetNamespace; - addOperationBinding->Name = addOperation; - - // Add the InputBinding for the operation. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - addOperationBinding->Input = myInputBinding; - - // Add the OutputBinding for the operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - addOperationBinding->Output = myOutputBinding; - - // Add the extensibility element for the SoapOperationBinding. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = String::Concat( myTargetNamespace, addOperation ); - addOperationBinding->Extensions->Add( mySoapOperationBinding ); - - // Get the BindingCollection from the ServiceDescription. - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - - // Get the OperationBindingCollection of SOAP binding from - // the BindingCollection. - OperationBindingCollection^ myOperationBindingCollection = myBindingCollection[ 0 ]->Operations; - - // - // Check for the Add OperationBinding in the collection. - bool contains = myOperationBindingCollection->Contains( addOperationBinding ); - Console::WriteLine( "\nWhether the collection contains the Add OperationBinding : {0}", contains ); - // - - // - // Add the Add OperationBinding to the collection. - myOperationBindingCollection->Add( addOperationBinding ); - Console::WriteLine( "\nAdded the OperationBinding of the Add" - " operation to the collection." ); - // - - // - // - // Get the OperationBinding of the Add operation from the collection. - OperationBinding^ myOperationBinding = myOperationBindingCollection[ 3 ]; - - // Remove the OperationBinding of the Add operation from - // the collection. - myOperationBindingCollection->Remove( myOperationBinding ); - Console::WriteLine( "\nRemoved the OperationBinding of the " - "Add operation from the collection." ); - // - // - - // - // - // Insert the OperationBinding of the Add operation at index 0. - myOperationBindingCollection->Insert( 0, addOperationBinding ); - Console::WriteLine( "\nInserted the OperationBinding of the " - "Add operation in the collection." ); - - // Get the index of the OperationBinding of the Add - // operation from the collection. - int index = myOperationBindingCollection->IndexOf( addOperationBinding ); - Console::WriteLine( "\nThe index of the OperationBinding of the Add operation : {0}", index ); - // - // - - Console::WriteLine( "" ); - - // - array^operationBindingArray = - gcnew array(myOperationBindingCollection->Count); - - // Copy this collection to the OperationBinding array. - myOperationBindingCollection->CopyTo( operationBindingArray, 0 ); - Console::WriteLine( "The operations supported by this service " - "are :" ); - - for each(OperationBinding^ myOperationBinding1 in operationBindingArray) - { - Binding^ myBinding = myOperationBinding1->Binding; - Console::WriteLine(" Binding : "+ myBinding->Name + " Name of " + - "operation : " + myOperationBinding1->Name); - } - // - - // Save the ServiceDescription to an external file. - myServiceDescription->Write( "MathService_new_cpp.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationBinding_OperationBinding/CPP/operationbinding_operationbinding.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationBinding_OperationBinding/CPP/operationbinding_operationbinding.cpp deleted file mode 100644 index 6e56ab4aa9aa8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationBinding_OperationBinding/CPP/operationbinding_operationbinding.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// System.Web.Services.Description.OperationBinding -// System.Web.Services.Description.OperationBinding.OperationBinding -// System.Web.Services.Description.OperationBinding.Name -// System.Web.Services.Description.OperationBinding.Input -// System.Web.Services.Description.OperationBinding.Output -// System.Web.Services.Description.OperationBinding.Extensions -// System.Web.Services.Description.OperationBinding.Faults -// System.Web.Services.Description.OperationBinding.Binding - -/* -The following example demonstrates the usage of the 'OperationBinding' -class, constructor 'OperationBinding()' and various properties of the class. The -input to the program is a WSDL file 'MathService_input_cs.wsdl' without the -add operation binding for SOAP protocol. In the example the WSDL file is modified to insert -a new 'OperationBinding' instance for SOAP. The 'OperationBinding' instance -is populated based on WSDL document structure defined in WSDL specification.The updated -instance is then written to 'MathService_new_cs.wsdl'. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input_cs.wsdl" ); - String^ myTargetNamespace = myServiceDescription->TargetNamespace; - - // - // - // Create an OperationBinding for the Add operation. - OperationBinding^ addOperationBinding = gcnew OperationBinding; - String^ addOperation = "Add"; - addOperationBinding->Name = addOperation; - // - - // - // Create an InputBinding for the Add operation. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add the InputBinding to the OperationBinding. - addOperationBinding->Input = myInputBinding; - // - - // - // Create an OutputBinding for the Add operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add the OutputBinding to the OperationBinding. - addOperationBinding->Output = myOutputBinding; - // - - // - // Create an extensibility element for a SoapOperationBinding. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = String::Concat( myTargetNamespace, addOperation ); - - // Add the extensibility element SoapOperationBinding to - // the OperationBinding. - addOperationBinding->Extensions->Add( mySoapOperationBinding ); - // - // - - // - ServiceDescriptionFormatExtensionCollection^ myExtensions; - - // Get the FaultBindingCollection from the OperationBinding. - FaultBindingCollection^ myFaultBindingCollection = addOperationBinding->Faults; - FaultBinding^ myFaultBinding = gcnew FaultBinding; - myFaultBinding->Name = "ErrorFloat"; - - // Associate SOAP fault binding to the fault binding of the operation. - myExtensions = myFaultBinding->Extensions; - SoapFaultBinding^ mySoapFaultBinding = gcnew SoapFaultBinding; - mySoapFaultBinding->Use = SoapBindingUse::Literal; - mySoapFaultBinding->Namespace = myTargetNamespace; - myExtensions->Add( mySoapFaultBinding ); - myFaultBindingCollection->Add( myFaultBinding ); - // - - // Get the BindingCollection from the ServiceDescription. - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - - // Get the OperationBindingCollection of SOAP binding - // from the BindingCollection. - OperationBindingCollection^ myOperationBindingCollection = myBindingCollection[ 0 ]->Operations; - myOperationBindingCollection->Add( addOperationBinding ); - Console::WriteLine( "The operations supported by this service are:" ); - System::Collections::IEnumerator^ myEnum = myOperationBindingCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - OperationBinding^ myOperationBinding = safe_cast(myEnum->Current); - - // - Binding^ myBinding = myOperationBinding->Binding; - Console::WriteLine( " Binding : {0} :: Name of operation : {1}", myBinding->Name, myOperationBinding->Name ); - // - - FaultBindingCollection^ myFaultBindingCollection1 = myOperationBinding->Faults; - System::Collections::IEnumerator^ myEnum1 = myFaultBindingCollection1->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - FaultBinding^ myFaultBinding1 = safe_cast(myEnum1->Current); - Console::WriteLine( " Fault : {0}", myFaultBinding1->Name ); - } - } - myServiceDescription->Write( "MathService_new_cs.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationCollection_Methods/CPP/operationcollection_methods.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationCollection_Methods/CPP/operationcollection_methods.cpp deleted file mode 100644 index 1a8d04b1690b7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationCollection_Methods/CPP/operationcollection_methods.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// System.Web.Sevices.Description.OperationCollection -// System.Web.Sevices.Description.OperationCollection.Add -// System.Web.Sevices.Description.OperationCollection.Contains -// System.Web.Sevices.Description.OperationCollection.IndexOf -// System.Web.Sevices.Description.OperationCollection.Remove -// System.Web.Sevices.Description.OperationCollection.Insert -// System.Web.Sevices.Description.OperationCollection.Item -// System.Web.Sevices.Description.OperationCollection.CopyTo - -/* -The following example demonstrates the usage of the -'OperationCollection' class , its property 'Item' and its methods -'Add', 'Contains', 'CopyTo', 'IndexOf', 'Insert' and 'Remove'. -The input to the program is a WSDL file 'MathService_input_cs.wsdl'with -information related to the 'Add' operation for the SOAP protocol, -removed from it. It creates a new file 'MathService_new_cs.wsdl' with -the added information about the 'Add' method. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Xml; -using namespace System::Web::Services::Description; -int main() -{ - try - { - // Read the 'MathService_Input_cs.wsdl' file. - ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_Input_cs.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes; - - // Get the 'OperationCollection' for 'SOAP' protocol. - - // - OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations; - Operation^ myOperation = gcnew Operation; - myOperation->Name = "Add"; - OperationMessage^ myOperationMessageInput = (OperationMessage^)(gcnew OperationInput); - myOperationMessageInput->Message = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace ); - OperationMessage^ myOperationMessageOutput = (OperationMessage^)(gcnew OperationOutput); - myOperationMessageOutput->Message = gcnew XmlQualifiedName( "AddSoapOut",myDescription->TargetNamespace ); - myOperation->Messages->Add( myOperationMessageInput ); - myOperation->Messages->Add( myOperationMessageOutput ); - myOperationCollection->Add( myOperation ); - // - - // - // - if ( myOperationCollection->Contains( myOperation ) == true ) - { - Console::WriteLine( "The index of the added 'myOperation' operation is : {0}", myOperationCollection->IndexOf( myOperation ) ); - } - // - // - - // - // - // - myOperationCollection->Remove( myOperation ); - - // Insert the 'myOpearation' operation at the index '0'. - myOperationCollection->Insert( 0, myOperation ); - Console::WriteLine( "The operation at index '0' is : {0}", myOperationCollection[ 0 ]->Name ); - // - // - // - - // - array^myOperationArray = gcnew array(myOperationCollection->Count); - myOperationCollection->CopyTo( myOperationArray, 0 ); - Console::WriteLine( "The operation(s) in the collection are :" ); - for ( int i = 0; i < myOperationCollection->Count; i++ ) - { - Console::WriteLine( " {0}", myOperationArray[ i ]->Name ); - } - // - - myDescription->Write( "MathService_New_cs.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_7/CPP/operationfaultcollection_7.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_7/CPP/operationfaultcollection_7.cpp deleted file mode 100644 index ad166a972198c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_7/CPP/operationfaultcollection_7.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// System::Web::Services::Description.OperationFaultCollection -// System::Web::Services::Description.OperationFaultCollection::Contains -// System::Web::Services::Description.OperationFaultCollection::CopyTo -// System::Web::Services::Description.OperationFaultCollection::IndexOf -// System::Web::Services::Description.OperationFaultCollection::Insert -// System::Web::Services::Description.OperationFaultCollection::Item -// System::Web::Services::Description.OperationFaultCollection::Remove - -/* -The following example demonstrates the usage of the -'OperationFaultCollection' class, the 'Contains', 'CopyTo', 'IndexOf', -'Insert', 'Remove', methods and the 'Item' property of the class. -The program reverses the fault bindings that appear in the WSDL file. -It also reverses the operation faults and writes the resultant WSDL -file. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -int main() -{ - try - { - // Read the StockQuote.wsdl file as input. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote_cpp.wsdl" ); - - // - // - // - // - // - // - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = myPortTypeCollection[ 0 ]; - OperationCollection^ myOperationCollection = myPortType->Operations; - Operation^ myOperation = myOperationCollection[ 0 ]; - OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults; - - // Reverse the operation fault order. - if ( myOperationFaultCollection->Count > 1 ) - { - OperationFault^ myOperationFault = myOperationFaultCollection[ 0 ]; - array^myOperationFaultArray = gcnew array(myOperationFaultCollection->Count); - - // Copy the operation fault to a temporary array. - myOperationFaultCollection->CopyTo( myOperationFaultArray, 0 ); - - // Remove all the operation faults from the collection. - for ( int i = 0; i < myOperationFaultArray->Length; i++ ) - myOperationFaultCollection->Remove( myOperationFaultArray[ i ] ); - - // Insert the operation faults in the reverse order. - for ( int i = 0,j = (myOperationFaultArray->Length - 1); i < myOperationFaultArray->Length; i++,j-- ) - myOperationFaultCollection->Insert( i, myOperationFaultArray[ j ] ); - if ( myOperationFaultCollection->Contains( myOperationFault ) && (myOperationFaultCollection->IndexOf( myOperationFault ) == myOperationFaultCollection->Count - 1) ) - Console::WriteLine( "Succeeded in reversing the operation faults." ); - else - Console::WriteLine( "Error while reversing the faults." ); - } - // - // - // - // - // - // - - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - Binding^ myBinding = myBindingCollection[ 0 ]; - OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations; - OperationBinding^ myOperationBinding = myOperationBindingCollection[ 0 ]; - FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults; - - // Reverse the fault binding order. - if ( myFaultBindingCollection->Count > 1 ) - { - FaultBinding^ myFaultBinding = myFaultBindingCollection[ 0 ]; - array^myFaultBindingArray = gcnew array(myFaultBindingCollection->Count); - - // Copy the fault bindings to a temporary array. - myFaultBindingCollection->CopyTo( myFaultBindingArray, 0 ); - - // Remove all the fault bindings. - for ( int i = 0; i < myFaultBindingArray->Length; i++ ) - myFaultBindingCollection->Remove( myFaultBindingArray[ i ] ); - - // Insert the fault bindings in the reverse order. - for ( int i = 0,j = (myFaultBindingArray->Length - 1); i < myFaultBindingArray->Length; i++,j-- ) - myFaultBindingCollection->Insert( i, myFaultBindingArray[ j ] ); - - // Check whether the first element before the reversal - // is now the last element. - if ( myFaultBindingCollection->Contains( myFaultBinding ) && myFaultBindingCollection->IndexOf( myFaultBinding ) == (myFaultBindingCollection->Count - 1) ) - { - // Write the WSDL generated to a file. - myServiceDescription->Write( "StockQuoteOut_cpp.wsdl" ); - Console::WriteLine( "The file StockQuoteOut_cpp.wsdl was successfully written" ); - } - else - Console::WriteLine( "An error occurred while reversing the input WSDL file." ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_Add/CPP/operationfaultcollection_add.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_Add/CPP/operationfaultcollection_add.cpp deleted file mode 100644 index 82de5e660ad46..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_Add/CPP/operationfaultcollection_add.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// System::Web::Services::Description.OperationFaultCollection->Add - -/* -The following example demonstrates the 'Add' method of the -'OperationFaultCollection' class. Based on 'StockQuote_cs::wsdl', the program generates a WSDL file -'StockQuoteNew_cs::wsdl' which contains 'Fault' information written out. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -int main() -{ - try - { - // Read the 'StockQuote::wsdl' file as input. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote_cpp.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = myPortTypeCollection[ 0 ]; - OperationCollection^ myOperationCollection = myPortType->Operations; - Operation^ myOperation = myOperationCollection[ 0 ]; - - // - OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults; - OperationFault^ myOperationFault = gcnew OperationFault; - myOperationFault->Name = "ErrorString"; - myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceStringFault" ); - myOperationFaultCollection->Add( myOperationFault ); - // - - Console::WriteLine( "Added OperationFault with Name: {0}", myOperationFault->Name ); - myOperationFault = gcnew OperationFault; - myOperationFault->Name = "ErrorInt"; - myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceIntFault" ); - myOperationFaultCollection->Add( myOperationFault ); - myOperationCollection->Add( myOperation ); - Console::WriteLine( "Added Second OperationFault with Name: {0}", myOperationFault->Name ); - myServiceDescription->Write( "StockQuoteNew_cpp.wsdl" ); - Console::WriteLine( "\nThe file 'StockQuoteNew_cpp.wsdl' is created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_Item/CPP/operationfaultcollection_item.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_Item/CPP/operationfaultcollection_item.cpp deleted file mode 100644 index 845e68c61640c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFaultCollection_Item/CPP/operationfaultcollection_item.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Web::Services::Description.OperationFaultCollection::Item->Item[String*] - -/* -The following example demonstrates the 'Item' property of the -'OperationFaultCollection' class. The program removes a fault binding -with the name 'ErrorString' from the WSDL file. It also removes an -operation fault with the name 'ErrorString' and generates a WSDL file. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -int main() -{ - try - { - // Read the 'StockQuote::wsdl' file as input. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote_cpp.wsdl" ); - - // Remove the operation fault with the name 'ErrorString'. - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = myPortTypeCollection[ 0 ]; - OperationCollection^ myOperationCollection = myPortType->Operations; - Operation^ myOperation = myOperationCollection[ 0 ]; - - // - OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults; - OperationFault^ myOperationFault = myOperationFaultCollection[ "ErrorString" ]; - if ( myOperationFault != nullptr ) - myOperationFaultCollection->Remove( myOperationFault ); - // - - // Remove the fault binding with the name 'ErrorString'. - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - Binding^ myBinding = myBindingCollection[ 0 ]; - OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations; - OperationBinding^ myOperationBinding = myOperationBindingCollection[ 0 ]; - FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults; - if ( myFaultBindingCollection->Contains( myFaultBindingCollection[ "ErrorString" ] ) ) - myFaultBindingCollection->Remove( myFaultBindingCollection[ "ErrorString" ] ); - myServiceDescription->Write( "OperationFaultCollection_out.wsdl" ); - Console::WriteLine( "WSDL file with name 'OperationFaultCollection_out.wsdl' created Successfully" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFault_OperationFault/CPP/operationfault_operationfault.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationFault_OperationFault/CPP/operationfault_operationfault.cpp deleted file mode 100644 index b5f3b55eaa1a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFault_OperationFault/CPP/operationfault_operationfault.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// System::Web::Services::Description.OperationFault -// System::Web::Services::Description.OperationFault::OperationFault - -/* The following example demonstrates the usage of the 'OperationFault' -class and its constructor. The program generates a WSDL file -'StockQuoteNew_cs::wsdl' which contains 'Fault' information written -out. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; -int main() -{ - try - { - // Read the 'StockQuote_cpp.wsdl' file as input. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote_cpp.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = myPortTypeCollection[ 0 ]; - OperationCollection^ myOperationCollection = myPortType->Operations; - Operation^ myOperation = myOperationCollection[ 0 ]; - - // - OperationFault^ myOperationFault = gcnew OperationFault; - myOperationFault->Name = "ErrorString"; - myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceStringFault" ); - myOperation->Faults->Add( myOperationFault ); - Console::WriteLine( "Added OperationFault with Name: {0}", myOperationFault->Name ); - myOperationFault = gcnew OperationFault; - myOperationFault->Name = "ErrorInt"; - myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceIntFault" ); - myOperation->Faults->Add( myOperationFault ); - // - - myOperationCollection->Add( myOperation ); - Console::WriteLine( "Added Second OperationFault with Name: {0}", myOperationFault->Name ); - myServiceDescription->Write( "StockQuoteNew_cpp.wsdl" ); - Console::WriteLine( "\nThe file 'StockQuoteNew_cpp.wsdl' is created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFlow_Enum/CPP/operationflow_enum.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationFlow_Enum/CPP/operationflow_enum.cpp deleted file mode 100644 index 200d1635e9458..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationFlow_Enum/CPP/operationflow_enum.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// System.Web.Sevices.Description.OperationFlow -// System.Web.Sevices.Description.OperationFlow.None -// System.Web.Sevices.Description.OperationFlow.OneWay -// System.Web.Sevices.Description.OperationFlow.Notification -// System.Web.Sevices.Description.OperationFlow.SolicitResponse -// System.Web.Sevices.Description.OperationFlow.RequestResponse - -/* -The following example demonstrates the usage of the 'OperationFlow' -Enumeration, its members 'None', 'OneWay', 'Notification', -'SolicitResponse', 'RequestResponse'. The input to the program is a -WSDL file 'MathService_input_cs.wsdl' It creates a new file -'MathService_new_cs.wsdl' by adding the operation messages -'OperationInput' and 'OperationOutput' are added to the -'OperationInput' and 'OperationOutput' in such way that all members of -the 'OperationFlow' enumeration are generated. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; - -// -// -// -// -// -void DisplayOperationFlowDescription( OperationFlow myOperationFlow ) -{ - switch ( myOperationFlow ) - { - case OperationFlow::None: - Console::WriteLine( "Indicates that the endpoint or service " - "receives no transmissions (None)." ); - break; - - case OperationFlow::OneWay: - Console::WriteLine( "Indicates that the endpoint or service " - "receives a message (OneWay)." ); - break; - - case OperationFlow::Notification: - Console::WriteLine( "Indicates that the endpoint or service " - "sends a message (Notification)." ); - break; - - case OperationFlow::SolicitResponse: - Console::WriteLine( "Indicates that the endpoint or service " - "sends a message, then receives a " - "correlated message (SolicitResponse)." ); - break; - - case OperationFlow::RequestResponse: - Console::WriteLine( "Indicates that the endpoint or service " - "receives a message, then sends a " - "correlated message (RequestResponse)." ); - break; - } -} -// -// -// -// -// - -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_Input_cs.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes; - - // Get the OperationCollection for SOAP protocol. - OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations; - - // Get the OperationMessageCollection for the Add operation. - OperationMessageCollection^ myOperationMessageCollection = myOperationCollection[ 0 ]->Messages; - - // Indicate that the endpoint or service receives no - // transmissions (None). - Console::WriteLine( "myOperationMessageCollection does not " - "contain any operation messages." ); - DisplayOperationFlowDescription( myOperationMessageCollection->Flow ); - Console::WriteLine(); - - // Indicate that the endpoint or service receives a message (OneWay). - OperationMessage^ myInputOperationMessage = dynamic_cast(gcnew OperationInput); - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace ); - myInputOperationMessage->Message = myXmlQualifiedName; - myOperationMessageCollection->Add( myInputOperationMessage ); - Console::WriteLine( "myOperationMessageCollection contains " - "only input operation messages." ); - DisplayOperationFlowDescription( myOperationMessageCollection->Flow ); - Console::WriteLine(); - myOperationMessageCollection->Remove( myInputOperationMessage ); - - // Indicate that an endpoint or service sends a message (Notification). - OperationMessage^ myOutputOperationMessage = dynamic_cast(gcnew OperationOutput); - XmlQualifiedName^ myXmlQualifiedName1 = gcnew XmlQualifiedName( "AddSoapOut",myDescription->TargetNamespace ); - myOutputOperationMessage->Message = myXmlQualifiedName1; - myOperationMessageCollection->Add( myOutputOperationMessage ); - Console::WriteLine( "myOperationMessageCollection contains " - "only output operation messages." ); - DisplayOperationFlowDescription( myOperationMessageCollection->Flow ); - Console::WriteLine(); - - // Indicate that an endpoint or service sends a message, then - // receives a correlated message (SolicitResponse). - myOperationMessageCollection->Add( myInputOperationMessage ); - Console::WriteLine( "'myOperationMessageCollection' contains " - "an output operation message first, then " - "an input operation message." ); - DisplayOperationFlowDescription( myOperationMessageCollection->Flow ); - Console::WriteLine(); - - // Indicate that an endpoint or service receives a message, - // then sends a correlated message (RequestResponse). - myOperationMessageCollection->Remove( myInputOperationMessage ); - myOperationMessageCollection->Insert( 0, myInputOperationMessage ); - Console::WriteLine( "myOperationMessageCollection contains " - "an input operation message first, then " - "an output operation message." ); - DisplayOperationFlowDescription( myOperationMessageCollection->Flow ); - Console::WriteLine(); - myDescription->Write( "MathService_new_cs.wsdl" ); - Console::WriteLine( "The file MathService_new_cs.wsdl was successfully written." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationInput_OperationInput/CPP/operationinput_operationinput.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationInput_OperationInput/CPP/operationinput_operationinput.cpp deleted file mode 100644 index fdc4a94dd1da5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationInput_OperationInput/CPP/operationinput_operationinput.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// System.Web.Services.Description.OperationInput -// System.Web.Services.Description.OperationInput.OperationInput - -/* -The following example demonstrates the usage of the 'OperationInput' -class and its constructor 'OperationInput'. It instantiates the -'ServiceDescription' object by reading a file 'AddNumbersIn_cs.wsdl' -and then creates 'AddNumbersOut_cs.wsdl' file which corresponds to -added attributes in the 'ServiceDescription' instance. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "AddNumbersIn_cs.wsdl" ); - - // Add the ServiceHttpPost binding. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "ServiceHttpPost"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:ServiceHttpPost" ); - myBinding->Type = myXmlQualifiedName; - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - myBinding->Extensions->Add( myHttpBinding ); - - // Add the operation name AddNumbers. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myOperation = gcnew HttpOperationBinding; - myOperation->Location = "/AddNumbers"; - myOperationBinding->Extensions->Add( myOperation ); - - // Add the input binding. - InputBinding^ myInput = gcnew InputBinding; - MimeContentBinding^ postMimeContentbinding = gcnew MimeContentBinding; - postMimeContentbinding->Type = "application/x-www-form-urlencoded"; - myInput->Extensions->Add( postMimeContentbinding ); - - // Add the InputBinding to the OperationBinding. - myOperationBinding->Input = myInput; - - // Add the ouput binding. - OutputBinding^ myOutput = gcnew OutputBinding; - MimeXmlBinding^ postMimeXmlBinding = gcnew MimeXmlBinding; - postMimeXmlBinding->Part = "Body"; - myOutput->Extensions->Add( postMimeXmlBinding ); - - // Add the OutputBinding to the OperationBinding. - myOperationBinding->Output = myOutput; - myBinding->Operations->Add( myOperationBinding ); - myDescription->Bindings->Add( myBinding ); - - // Add the port definition. - Port^ postPort = gcnew Port; - postPort->Name = "ServiceHttpPost"; - postPort->Binding = gcnew XmlQualifiedName( "s0:ServiceHttpPost" ); - HttpAddressBinding^ postAddressBinding = gcnew HttpAddressBinding; - postAddressBinding->Location = "http://localhost/Service.cs.asmx"; - postPort->Extensions->Add( postAddressBinding ); - myDescription->Services[ 0 ]->Ports->Add( postPort ); - - // Add the post port type definition. - PortType^ postPortType = gcnew PortType; - postPortType->Name = "ServiceHttpPost"; - Operation^ postOperation = gcnew Operation; - postOperation->Name = "AddNumbers"; - OperationMessage^ postOutput = dynamic_cast(gcnew OperationOutput); - postOutput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostOut" ); - - // - OperationInput^ postInput = gcnew OperationInput; - postInput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostIn" ); - postOperation->Messages->Add( postInput ); - postOperation->Messages->Add( postOutput ); - postPortType->Operations->Add( postOperation ); - // - - myDescription->PortTypes->Add( postPortType ); - - // Add the first message information. - Message^ postMessage1 = gcnew Message; - postMessage1->Name = "AddNumbersHttpPostIn"; - MessagePart^ postMessagePart1 = gcnew MessagePart; - postMessagePart1->Name = "firstnumber"; - postMessagePart1->Type = gcnew XmlQualifiedName( "s:string" ); - - // Add the second message information. - MessagePart^ postMessagePart2 = gcnew MessagePart; - postMessagePart2->Name = "secondnumber"; - postMessagePart2->Type = gcnew XmlQualifiedName( "s:string" ); - postMessage1->Parts->Add( postMessagePart1 ); - postMessage1->Parts->Add( postMessagePart2 ); - Message^ postMessage2 = gcnew Message; - postMessage2->Name = "AddNumbersHttpPostOut"; - - // Add the third message information. - MessagePart^ postMessagePart3 = gcnew MessagePart; - postMessagePart3->Name = "Body"; - postMessagePart3->Element = gcnew XmlQualifiedName( "s0:int" ); - postMessage2->Parts->Add( postMessagePart3 ); - myDescription->Messages->Add( postMessage1 ); - myDescription->Messages->Add( postMessage2 ); - - // Write the ServiceDescription as a WSDL file. - myDescription->Write( "AddNumbersOut_cs.wsdl" ); - Console::WriteLine( "WSDL file named AddNumberOut_cs.Wsdl" - " created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationMessageCollection_Sample/CPP/operationmessagecollection_sample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationMessageCollection_Sample/CPP/operationmessagecollection_sample.cpp deleted file mode 100644 index b9b0d6dc3f909..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationMessageCollection_Sample/CPP/operationmessagecollection_sample.cpp +++ /dev/null @@ -1,129 +0,0 @@ - - -// System.Web.Services.Description.OperationMessageCollection -// System.Web.Services.Description.OperationMessageCollection.Item -// System.Web.Services.Description.OperationMessageCollection.CopyTo -// System.Web.Services.Description.OperationMessageCollection.Add -// System.Web.Services.Description.OperationMessageCollection.Contains -// System.Web.Services.Description.OperationMessageCollection.IndexOf -// System.Web.Services.Description.OperationMessageCollection.Remove -// System.Web.Services.Description.OperationMessageCollection.Insert -// System.Web.Services.Description.OperationMessageCollection.Flow -// System.Web.Services.Description.OperationMessageCollection.Input -// System.Web.Services.Description.OperationMessageCollection.Output - -/* -The following example demonstrates the usage of the -'OperationMessageCollection' class and various methods and properties of it. -The input to the program is a WSDL file 'MathService_input_vb.wsdl' without -the input message of 'Add' operation for the SOAP -protocol. In a way it tries to simulate a scenario -wherein the operation flow was 'Notification', however later operation -flow changed to 'Request-Response'.The WSDL file is -modified by inserting a new input message for the 'Add' operation. The -input message in the ServiceDescription instance is loaded with values for -'Input Message'. The instance is then written to 'MathService_new_vb.wsdl'. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; - -// -// -// -// Displays the properties of the OperationMessageCollection. -void DisplayFlowInputOutput( OperationMessageCollection^ myOperationMessageCollection, String^ myOperation ) -{ - Console::WriteLine( "After {0}:", myOperation ); - Console::WriteLine( "Flow : {0}", myOperationMessageCollection->Flow ); - Console::WriteLine( "The first occurrence of operation Input in the collection {0}", myOperationMessageCollection->Input ); - Console::WriteLine( "The first occurrence of operation Output in the collection {0}", myOperationMessageCollection->Output ); - Console::WriteLine(); -} -// -// -// - -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_input_cs.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes; - - // Get the OperationCollection for the SOAP protocol. - OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations; - - // Get the OperationMessageCollection for the Add operation. - OperationMessageCollection^ myOperationMessageCollection = myOperationCollection[ 0 ]->Messages; - - // Display the Flow, Input, and Output properties. - DisplayFlowInputOutput( myOperationMessageCollection, "Start" ); - - // - // - // Get the operation message for the Add operation. - OperationMessage^ myOperationMessage = myOperationMessageCollection[ 0 ]; - OperationMessage^ myInputOperationMessage = dynamic_cast(gcnew OperationInput); - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace ); - myInputOperationMessage->Message = myXmlQualifiedName; - - // - array^myCollection = gcnew array(myOperationMessageCollection->Count); - myOperationMessageCollection->CopyTo( myCollection, 0 ); - Console::WriteLine( "Operation name(s) :" ); - for ( int i = 0; i < myCollection->Length; i++ ) - { - Console::WriteLine( " {0}", myCollection[ i ]->Operation->Name ); - } - // - - // Add the OperationMessage to the collection. - myOperationMessageCollection->Add( myInputOperationMessage ); - - // - DisplayFlowInputOutput( myOperationMessageCollection, "Add" ); - - // - // - if ( myOperationMessageCollection->Contains( myOperationMessage ) == true ) - { - int myIndex = myOperationMessageCollection->IndexOf( myOperationMessage ); - Console::WriteLine( " The index of the Add operation message in the collection is : {0}", myIndex ); - } - // - // - // - - // - // - myOperationMessageCollection->Remove( myInputOperationMessage ); - - // Display Flow, Input, and Output after removing. - DisplayFlowInputOutput( myOperationMessageCollection, "Remove" ); - - // Insert the message at index 0 in the collection. - myOperationMessageCollection->Insert( 0, myInputOperationMessage ); - - // Display Flow, Input, and Output after inserting. - DisplayFlowInputOutput( myOperationMessageCollection, "Insert" ); - // - // - - myDescription->Write( "MathService_new_cs.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationMessage_Properties/CPP/operationmessage_properties.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationMessage_Properties/CPP/operationmessage_properties.cpp deleted file mode 100644 index c7cd7a8b49c75..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationMessage_Properties/CPP/operationmessage_properties.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// System.Web.Services.Description.OperationMessage -// System.Web.Services.Description.OperationMessage.OperationMessage -// System.Web.Services.Description.OperationMessage.Message -// System.Web.Services.Description.OperationMessage.Operation - -/* -The following example demonstrates the usage of the 'OperationMessage' -class, its constructor and the properties 'Message' and 'Operation'. -The input to the program is a WSDL file 'MathService_input_cs.wsdl' without -the input message of 'Add' operation for the SOAP -protocol. In this example a new input message for the 'Add' operation is created. -The input message in the ServiceDescription instance is loaded with values for -'InputMessage'. The instance is then written to 'MathService_new_cs.wsdl'. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_input_cs.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes; - - // Get the OperationCollection for the SOAP protocol. - OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations; - - // Get the OperationMessageCollection for the Add operation. - OperationMessageCollection^ myOperationMessageCollection = myOperationCollection[ 0 ]->Messages; - - // - // - // - OperationMessage^ myInputOperationMessage = (OperationMessage^)(gcnew OperationInput); - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace ); - myInputOperationMessage->Message = myXmlQualifiedName; - // - - myOperationMessageCollection->Insert( 0, myInputOperationMessage ); - - // Display the operation name of the InputMessage. - Console::WriteLine( "The operation name is {0}", myInputOperationMessage->Operation->Name ); - // - // - - // Add the OperationMessage to the collection. - myDescription->Write( "MathService_new_cs.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/OperationOutput_OperationOutput/CPP/operationoutput_operationoutput.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/OperationOutput_OperationOutput/CPP/operationoutput_operationoutput.cpp deleted file mode 100644 index 9500f4f962e78..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/OperationOutput_OperationOutput/CPP/operationoutput_operationoutput.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// System.Web.Services.Description.OperationOutput -// System.Web.Services.Description.OperationOutput.OperationOutput - -/* -The following example demonstrates the usage of the 'OperationOutput' -class and its constructor 'OperationOutput'. It creates a -'ServiceDescription' object by reading the file 'AddNumbersIn_cs.wsdl' and -then creates 'AddNumbersOut_cs.wsdl' file which corresponds to added -attributes in the 'ServiceDescription' instance. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "AddNumbersIn_cs.wsdl" ); - - // Add the ServiceHttpPost binding. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "ServiceHttpPost"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:ServiceHttpPost" ); - myBinding->Type = myXmlQualifiedName; - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - myBinding->Extensions->Add( myHttpBinding ); - - // Add the operation name AddNumbers. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myOperation = gcnew HttpOperationBinding; - myOperation->Location = "/AddNumbers"; - myOperationBinding->Extensions->Add( myOperation ); - - // Add the input binding. - InputBinding^ myInput = gcnew InputBinding; - MimeContentBinding^ postMimeContentbinding = gcnew MimeContentBinding; - postMimeContentbinding->Type = "application/x-www-form-urlencoded"; - myInput->Extensions->Add( postMimeContentbinding ); - - // Add the InputBinding to the OperationBinding. - myOperationBinding->Input = myInput; - - // Add the ouput binding. - OutputBinding^ myOutput = gcnew OutputBinding; - MimeXmlBinding^ postMimeXmlbinding = gcnew MimeXmlBinding; - postMimeXmlbinding->Part = "Body"; - myOutput->Extensions->Add( postMimeXmlbinding ); - - // Add the OutPutBinding to the OperationBinding. - myOperationBinding->Output = myOutput; - myBinding->Operations->Add( myOperationBinding ); - myDescription->Bindings->Add( myBinding ); - - // Add the port definition. - Port^ postPort = gcnew Port; - postPort->Name = "ServiceHttpPost"; - postPort->Binding = gcnew XmlQualifiedName( "s0:ServiceHttpPost" ); - HttpAddressBinding^ postAddressBinding = gcnew HttpAddressBinding; - postAddressBinding->Location = "http://localhost/Service_cs.asmx"; - postPort->Extensions->Add( postAddressBinding ); - myDescription->Services[ 0 ]->Ports->Add( postPort ); - - // Add the post port type definition. - PortType^ postPortType = gcnew PortType; - postPortType->Name = "ServiceHttpPost"; - Operation^ postOperation = gcnew Operation; - postOperation->Name = "AddNumbers"; - OperationMessage^ postInput = dynamic_cast(gcnew OperationInput); - postInput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostIn" ); - - // - OperationOutput^ postOutput = gcnew OperationOutput; - postOutput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostOut" ); - postOperation->Messages->Add( postInput ); - postOperation->Messages->Add( postOutput ); - postPortType->Operations->Add( postOperation ); - // - - myDescription->PortTypes->Add( postPortType ); - - // Add the first message information. - Message^ postMessage1 = gcnew Message; - postMessage1->Name = "AddNumbersHttpPostIn"; - MessagePart^ postMessagePart1 = gcnew MessagePart; - postMessagePart1->Name = "firstnumber"; - postMessagePart1->Type = gcnew XmlQualifiedName( "s:string" ); - - // Add the second message information. - MessagePart^ postMessagePart2 = gcnew MessagePart; - postMessagePart2->Name = "secondnumber"; - postMessagePart2->Type = gcnew XmlQualifiedName( "s:string" ); - postMessage1->Parts->Add( postMessagePart1 ); - postMessage1->Parts->Add( postMessagePart2 ); - Message^ postMessage2 = gcnew Message; - postMessage2->Name = "AddNumbersHttpPostOut"; - - // Add the third message information. - MessagePart^ postMessagePart3 = gcnew MessagePart; - postMessagePart3->Name = "Body"; - postMessagePart3->Element = gcnew XmlQualifiedName( "s0:int" ); - postMessage2->Parts->Add( postMessagePart3 ); - myDescription->Messages->Add( postMessage1 ); - myDescription->Messages->Add( postMessage2 ); - - // Write the ServiceDescription as a WSDL file. - myDescription->Write( "AddNumbersOut_cs.wsdl" ); - Console::WriteLine( "WSDL file named AddNumbersOut_cs.Wsdl" - " created successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_2/CPP/operation_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Operation_2/CPP/operation_2.cpp deleted file mode 100644 index 6af07a14872f4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_2/CPP/operation_2.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// System.Web.Services.Description Operation.ParameterOrderString -// System.Web.Services.Description Operation.ParameterOrder - -/* The following program demonstrates the 'ParameterOrderString' and - 'ParameterOrder' properties of 'Operation' class. It collects the - message part names from the input WSDL file and sets to the - 'ParameterOrderString'. It then displays the same using 'ParameterOrder' - property. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "Operation_2_Input_CS.wsdl" ); - Binding^ myBinding = gcnew Binding; - myBinding->Name = "Operation_2_ServiceHttpPost"; - XmlQualifiedName^ myQualifiedName = gcnew XmlQualifiedName( "s0:Operation_2_ServiceHttpPost" ); - myBinding->Type = myQualifiedName; - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the 'HttpBinding' to the 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myHttpOperationBinding = gcnew HttpOperationBinding; - myHttpOperationBinding->Location = "/AddNumbers"; - - // Add the 'HttpOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( myHttpOperationBinding ); - InputBinding^ myInputBinding = gcnew InputBinding; - MimeContentBinding^ myPostMimeContentbinding = gcnew MimeContentBinding; - myPostMimeContentbinding->Type = "application/x-www-form-urlencoded"; - myInputBinding->Extensions->Add( myPostMimeContentbinding ); - - // Add the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - OutputBinding^ myOutputBinding = gcnew OutputBinding; - MimeXmlBinding^ myPostMimeXmlbinding = gcnew MimeXmlBinding; - myPostMimeXmlbinding->Part = "Body"; - myOutputBinding->Extensions->Add( myPostMimeXmlbinding ); - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutputBinding; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myDescription->Bindings->Add( myBinding ); - Port^ myPostPort = gcnew Port; - myPostPort->Name = "Operation_2_ServiceHttpPost"; - myPostPort->Binding = gcnew XmlQualifiedName( "s0:Operation_2_ServiceHttpPost" ); - HttpAddressBinding^ myPostAddressBinding = gcnew HttpAddressBinding; - myPostAddressBinding->Location = "http://localhost/Operation_2/Operation_2_Service.cs.asmx"; - - // Add the 'HttpAddressBinding' to the 'Port'. - myPostPort->Extensions->Add( myPostAddressBinding ); - - // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. - myDescription->Services[ 0 ]->Ports->Add( myPostPort ); - PortType^ myPostPortType = gcnew PortType; - myPostPortType->Name = "Operation_2_ServiceHttpPost"; - Operation^ myPostOperation = gcnew Operation; - myPostOperation->Name = "AddNumbers"; - OperationMessage^ myPostOperationInput = dynamic_cast(gcnew OperationInput); - myPostOperationInput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostIn" ); - OperationMessage^ myPostOperationOutput = dynamic_cast(gcnew OperationOutput); - myPostOperationOutput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostout" ); - myPostOperation->Messages->Add( myPostOperationInput ); - myPostOperation->Messages->Add( myPostOperationOutput ); - - // Add the 'Operation' to 'PortType'. - myPostPortType->Operations->Add( myPostOperation ); - - // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. - myDescription->PortTypes->Add( myPostPortType ); - Message^ myPostMessage1 = gcnew Message; - myPostMessage1->Name = "AddNumbersHttpPostIn"; - MessagePart^ myPostMessagePart1 = gcnew MessagePart; - myPostMessagePart1->Name = "firstnumber"; - myPostMessagePart1->Type = gcnew XmlQualifiedName( "s:string" ); - MessagePart^ myPostMessagePart2 = gcnew MessagePart; - myPostMessagePart2->Name = "secondnumber"; - myPostMessagePart2->Type = gcnew XmlQualifiedName( "s:string" ); - - // Add the 'MessagePart' objects to 'Messages'. - myPostMessage1->Parts->Add( myPostMessagePart1 ); - myPostMessage1->Parts->Add( myPostMessagePart2 ); - Message^ myPostMessage2 = gcnew Message; - myPostMessage2->Name = "AddNumbersHttpPostout"; - MessagePart^ myPostMessagePart3 = gcnew MessagePart; - myPostMessagePart3->Name = "Body"; - myPostMessagePart3->Element = gcnew XmlQualifiedName( "s0:int" ); - - // Add the 'MessagePart' to 'Message'. - myPostMessage2->Parts->Add( myPostMessagePart3 ); - - // Add the 'Message' objects to 'ServiceDescription'. - myDescription->Messages->Add( myPostMessage1 ); - myDescription->Messages->Add( myPostMessage2 ); - - // Write the 'ServiceDescription' as a WSDL file. - myDescription->Write( "Operation_2_Output_CS.wsdl" ); - Console::WriteLine( " 'Operation_2_Output_CS.wsdl' file created Successfully" ); - - // - // - String^ myString = nullptr; - Operation^ myOperation = gcnew Operation; - myDescription = ServiceDescription::Read( "Operation_2_Input_CS.wsdl" ); - array^myMessage = gcnew array(myDescription->Messages->Count); - - // Copy the messages from the service description. - myDescription->Messages->CopyTo( myMessage, 0 ); - for ( int i = 0; i < myDescription->Messages->Count; i++ ) - { - array^myMessagePart = gcnew array(myMessage[ i ]->Parts->Count); - - // Copy the message parts into a MessagePart. - myMessage[ i ]->Parts->CopyTo( myMessagePart, 0 ); - for ( int j = 0; j < myMessage[ i ]->Parts->Count; j++ ) - { - myString = String::Concat( myString, myMessagePart[ j ]->Name, " " ); - } - } - - // message part names. - myOperation->ParameterOrderString = myString; - array^myString1 = myOperation->ParameterOrder; - int k = 0; - Console::WriteLine( "The list of message part names is as follows:" ); - while ( k < 5 ) - { - Console::WriteLine( myString1[ k ] ); - k++; - } - // - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following Exception is raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_5/CPP/operation_5.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Operation_5/CPP/operation_5.cpp deleted file mode 100644 index 13001d530c732..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_5/CPP/operation_5.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// System.Web.Services.Description.Operation -// System.Web.Services.Description.Operation.Operation -// System.Web.Services.Description.Operation.Messages -// System.Web.Services.Description.Operation.Name -// System.Web.Services.Description.Operation.PortType -/* The following program demonstrates 'Operation' class, its contructor -and 'Messages','Name' and 'PortType' properties. It reads the file -'Operation_5_Input_CS.wsdl' which does not have 'PortType' object that -supports 'HttpPost'. It adds a 'PortType' object that supports 'HttpPost' -protocol and writes into 'Operation_5_Output_CS.wsdl'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; -Operation^ CreateOperation( String^ myOperationName, String^ myInputMesg, String^ myOutputMesg ) -{ - - // - // - // - // Create an Operation. - Operation^ myOperation = gcnew Operation; - myOperation->Name = myOperationName; - OperationMessage^ myInput = dynamic_cast(gcnew OperationInput); - myInput->Message = gcnew XmlQualifiedName( myInputMesg ); - OperationMessage^ myOutput = dynamic_cast(gcnew OperationOutput); - myOutput->Message = gcnew XmlQualifiedName( myOutputMesg ); - - // Add messages to the OperationMessageCollection. - myOperation->Messages->Add( myInput ); - myOperation->Messages->Add( myOutput ); - Console::WriteLine( "Operation name is: {0}", myOperation->Name ); - - // - // - // - return myOperation; -} - -int main() -{ - ServiceDescription^ myDescription = ServiceDescription::Read( "Operation_5_Input_CS.wsdl" ); - - // Create a 'PortType' object. - PortType^ myPortType = gcnew PortType; - myPortType->Name = "OperationServiceHttpPost"; - Operation^ myOperation = CreateOperation( "AddNumbers", "s0:AddNumbersHttpPostIn", "s0:AddNumbersHttpPostOut" ); - myPortType->Operations->Add( myOperation ); - - // - // Get the PortType of the Operation. - PortType^ myPort = myOperation->PortType; - Console::WriteLine( "The port type of the operation is: {0}", myPort->Name ); - - // - // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'. - myDescription->PortTypes->Add( myPortType ); - - // Write the 'ServiceDescription' as a WSDL file. - myDescription->Write( "Operation_5_Output_CS.wsdl" ); - Console::WriteLine( "WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully" ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_Faults/CPP/operation_faults.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Operation_Faults/CPP/operation_faults.cpp deleted file mode 100644 index 69a3b7c85e8d1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_Faults/CPP/operation_faults.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// System::Web::Services::Description.Operation::Faults - -/* The following program demonstrates the 'Faults' property of 'Operation' -class. It reads from a 'Operation_Faults_Input_CS::wsdl' file removes fault -binding and operation fault with the name 'ErrorString'. The modified -ServiceDescriptor is written to 'Operation_Faults_Output_Cpp.wsdl' file. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - // - // Read the 'Operation_Faults_Input_cpp.wsdl' file as input. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Operation_Faults_Input_cpp.wsdl" ); - - // Get the operation fault collection. - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - PortType^ myPortType = myPortTypeCollection[ 0 ]; - OperationCollection^ myOperationCollection = myPortType->Operations; - - // Remove the operation fault with the name 'ErrorString'. - Operation^ myOperation = myOperationCollection[ 0 ]; - OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults; - if ( myOperationFaultCollection->Contains( myOperationFaultCollection[ "ErrorString" ] ) ) - myOperationFaultCollection->Remove( myOperationFaultCollection[ "ErrorString" ] ); - // - - // Get the fault binding collection. - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - Binding^ myBinding = myBindingCollection[ 0 ]; - OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations; - - // Remove the fault binding with the name 'ErrorString'. - OperationBinding^ myOperationBinding = myOperationBindingCollection[ 0 ]; - FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults; - if ( myFaultBindingCollection->Contains( myFaultBindingCollection[ "ErrorString" ] ) ) - myFaultBindingCollection->Remove( myFaultBindingCollection[ "ErrorString" ] ); - - myServiceDescription->Write( "Operation_Faults_Output_cpp.wsdl" ); - Console::WriteLine( "WSDL file with name 'Operation_Faults_Output_cpp.wsdl' file created Successfully" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_IsBoundBy/CPP/operation_isboundby.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Operation_IsBoundBy/CPP/operation_isboundby.cpp deleted file mode 100644 index 9b42a03b3064f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Operation_IsBoundBy/CPP/operation_isboundby.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// System.Web.Services.Description.Operation.IsBoundBy -/* The following program demonstrates the 'IsBoundBy' method of - 'Operation' class. It takes "Operation_IsBoundBy_Input_CS.wsdl" - as input which does not contain 'PortType' and 'Binding' objects - supporting 'HttpPost'.It then adds those objects and writes into - 'Operation_IsBoundBy_Output_CS.wsdl'. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Operation_IsBoundBy_Input_CS.wsdl" ); - - // Create the 'Binding' object. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "MyOperationIsBoundByServiceHttpPost"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:OperationServiceHttpPost" ); - myBinding->Type = myXmlQualifiedName; - - // Create the 'HttpBinding' object. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the 'HttpBinding' to the 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - - // Create the 'OperationBinding' object. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myHttpOperationBinding = gcnew HttpOperationBinding; - myHttpOperationBinding->Location = "/AddNumbers"; - - // Add the 'HttpOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( myHttpOperationBinding ); - - // Create the 'InputBinding' object. - InputBinding^ myInputBinding = gcnew InputBinding; - MimeContentBinding^ myPostMimeContentBinding = gcnew MimeContentBinding; - myPostMimeContentBinding->Type = "application/x-www-form-urlencoded"; - myInputBinding->Extensions->Add( myPostMimeContentBinding ); - - // Add the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - - // Create the 'OutputBinding' object. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - MimeXmlBinding^ myPostMimeXmlBinding = gcnew MimeXmlBinding; - myPostMimeXmlBinding->Part = "Body"; - myOutputBinding->Extensions->Add( myPostMimeXmlBinding ); - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutputBinding; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myServiceDescription->Bindings->Add( myBinding ); - - // Create a 'PortType' object. - PortType^ myPostPortType = gcnew PortType; - myPostPortType->Name = "OperationServiceHttpPost"; - -// - Operation^ myPostOperation = gcnew Operation; - myPostOperation->Name = myOperationBinding->Name; - Console::WriteLine( "'Operation' instance uses 'OperationBinding': {0}", - myPostOperation->IsBoundBy( myOperationBinding ) ); -// - - OperationMessage^ myOperationMessage = dynamic_cast(gcnew OperationInput); - myOperationMessage->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostIn" ); - OperationMessage^ myOperationMessage1 = dynamic_cast(gcnew OperationOutput); - myOperationMessage1->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostOut" ); - myPostOperation->Messages->Add( myOperationMessage ); - myPostOperation->Messages->Add( myOperationMessage1 ); - - // Add the 'Operation' to 'PortType'. - myPostPortType->Operations->Add( myPostOperation ); - - // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. - myServiceDescription->PortTypes->Add( myPostPortType ); - - // Write the 'ServiceDescription' as a WSDL file. - myServiceDescription->Write( "Operation_IsBoundBy_Output_CS.wsdl" ); - Console::WriteLine( "WSDL file with name 'Operation_IsBoundBy_Output_CS.wsdl' created Successfully" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortClass/CPP/portclass.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortClass/CPP/portclass.cpp deleted file mode 100644 index 458ca2e8f8e78..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortClass/CPP/portclass.cpp +++ /dev/null @@ -1,166 +0,0 @@ - - -// System.Web.Services.Description.Port.ctor(). -// System.Web.Services.Description.Port.Binding(). -// System.Web.Services.Description.Portt.Extensions. -// System.Web.Services.Description.Port.Name. -// System.Web.Services.Description.Port.Service. -/* The following example demonstrates the constructor and the properties 'Binding', - 'Extensions','Name', and 'Service' of the 'Port' class. - The input to the program is a WSDL file 'AddNumbers_cs.wsdl'. - It creates a 'ServiceDescription' instance by using the static read method - of 'ServiceDescription' by passing the 'AddNumbers.wsdl' name as an argument. - It creates a 'Binding' object and adds that binding object to - 'ServiceDescription'. It adds the 'PortType',Messages to the 'ServiceDescription' - object. Finally it writes the 'ServiceDescrption' as a WSDL file with - name 'AddNumbersOne.wsdl. - */ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Web; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - try - { - ServiceDescription^ myDescription = ServiceDescription::Read( "AddNumbers_cs.wsdl" ); - - // Create the 'Binding' object. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "PortServiceHttpPost"; - XmlQualifiedName^ qualifiedName = gcnew XmlQualifiedName( "s0:PortServiceHttpPost" ); - myBinding->Type = qualifiedName; - - // Create the 'HttpBinding' object. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the 'HttpBinding' to the 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - - // Create the 'OperationBinding' object. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myOperation = gcnew HttpOperationBinding; - myOperation->Location = "/AddNumbers"; - - // Add the 'HttpOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( myOperation ); - - // Create the 'InputBinding' object. - InputBinding^ myInput = gcnew InputBinding; - MimeContentBinding^ postMimeContentbinding = gcnew MimeContentBinding; - postMimeContentbinding->Type = "application/x-www-form-urlencoded"; - myInput->Extensions->Add( postMimeContentbinding ); - - // Add the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInput; - - // Create the 'OutputBinding' object. - OutputBinding^ myOutput = gcnew OutputBinding; - MimeXmlBinding^ postMimeXmlbinding = gcnew MimeXmlBinding; - postMimeXmlbinding->Part = "Body"; - myOutput->Extensions->Add( postMimeXmlbinding ); - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myDescription->Bindings->Add( myBinding ); - - // - // - // - // - // - // Create a Port. - Port^ postPort = gcnew Port; - postPort->Name = "PortServiceHttpPost"; - postPort->Binding = gcnew XmlQualifiedName( "s0:PortServiceHttpPost" ); - // - // - - // Create an HttpAddressBinding. - HttpAddressBinding^ postAddressBinding = gcnew HttpAddressBinding; - postAddressBinding->Location = "http://localhost/PortClass/PortService_cs.asmx"; - - // Add the HttpAddressBinding to the Port. - postPort->Extensions->Add( postAddressBinding ); - // - - // Get the Service of the postPort. - Service^ myService = postPort->Service; - - // Print the service name for the port. - Console::WriteLine( "This is the service name of the postPort:*{0}*", myDescription->Services[ 0 ]->Ports[ 0 ]->Service->Name ); - - // Add the Port to the PortCollection of the ServiceDescription. - myDescription->Services[ 0 ]->Ports->Add( postPort ); - // - // - - // Create a 'PortType' object. - PortType^ postPortType = gcnew PortType; - postPortType->Name = "PortServiceHttpPost"; - Operation^ postOperation = gcnew Operation; - postOperation->Name = "AddNumbers"; - OperationMessage^ postInput = dynamic_cast(gcnew OperationInput); - postInput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostIn" ); - OperationMessage^ postOutput = dynamic_cast(gcnew OperationOutput); - postOutput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostOut" ); - postOperation->Messages->Add( postInput ); - postOperation->Messages->Add( postOutput ); - - // Add the 'Operation' to 'PortType'. - postPortType->Operations->Add( postOperation ); - - // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. - myDescription->PortTypes->Add( postPortType ); - - // Create the 'Message' object. - Message^ postMessage1 = gcnew Message; - postMessage1->Name = "AddNumbersHttpPostIn"; - - // Create the 'MessageParts'. - MessagePart^ postMessagePart1 = gcnew MessagePart; - postMessagePart1->Name = "firstnumber"; - postMessagePart1->Type = gcnew XmlQualifiedName( "s:string" ); - MessagePart^ postMessagePart2 = gcnew MessagePart; - postMessagePart2->Name = "secondnumber"; - postMessagePart2->Type = gcnew XmlQualifiedName( "s:string" ); - - // Add the 'MessagePart' objects to 'Messages'. - postMessage1->Parts->Add( postMessagePart1 ); - postMessage1->Parts->Add( postMessagePart2 ); - - // Create another 'Message' object. - Message^ postMessage2 = gcnew Message; - postMessage2->Name = "AddNumbersHttpPostOut"; - MessagePart^ postMessagePart3 = gcnew MessagePart; - postMessagePart3->Name = "Body"; - postMessagePart3->Element = gcnew XmlQualifiedName( "s0:int" ); - - // Add the 'MessagePart' to 'Message' - postMessage2->Parts->Add( postMessagePart3 ); - - // Add the 'Message' objects to 'ServiceDescription'. - myDescription->Messages->Add( postMessage1 ); - myDescription->Messages->Add( postMessage2 ); - - // Write the 'ServiceDescription' as a WSDL file. - myDescription->Write( "AddNumbersOne.wsdl" ); - Console::WriteLine( "WSDL file with name 'AddNumbersOne.Wsdl' file created Successfully" ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Exception {0} occurred", ex->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_Add/CPP/portcollection_add.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_Add/CPP/portcollection_add.cpp deleted file mode 100644 index aea7134fd0b1a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_Add/CPP/portcollection_add.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// System.Web.Services.Description.PortCollection.Contains -// System.Web.Services.Description.PortCollection.Add -/* - The following sample reads the contents of a file 'MathServiceAdd_cs.wsdl' - into a 'ServiceDescription' instance. It gets the collection of Service - instances from 'ServiceDescription'. It then adds a new port and checks - whether a port exists. The programs writes a new web service description - file. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -int main() -{ - try - { - Service^ myService; - PortCollection^ myPortCollection; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathServiceAdd_cs.wsdl" ); - Console::WriteLine( "\nTotal Number of Services :{0}", myServiceDescription->Services->Count ); - for ( int i = 0; i < myServiceDescription->Services->Count; ++i ) - { - myService = myServiceDescription->Services[ i ]; - Console::WriteLine( "Name : {0}", myService->Name ); - - // - // - myPortCollection = myService->Ports; - Port^ myNewPort = myPortCollection[ 0 ]; - myPortCollection->Remove( myNewPort ); - - // Display the number of ports. - Console::WriteLine( "\nTotal number of ports before adding a new port : {0}", myService->Ports->Count ); - - // Add a new port. - myPortCollection->Add( myNewPort ); - - // Display the number of ports after adding a port. - Console::WriteLine( "Total number of ports after adding a new port : {0}", myService->Ports->Count ); - // - - bool bContain = myPortCollection->Contains( myNewPort ); - Console::WriteLine( "\nPort '{0}' exists : {1}", myNewPort->Name, bContain ); - - // Remove a port from the collection. - myPortCollection->Remove( myPortCollection[ myNewPort->Name ] ); - bContain = myPortCollection->Contains( myNewPort ); - Console::WriteLine( "Port '{0}' exists : {1}", myNewPort->Name, bContain ); - - // Create the description file. - myPortCollection->Insert( 0, myNewPort ); - myServiceDescription->Write( "MathServiceAddNew_cs.wsdl" ); - // - - } - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Exception:{0}", ex->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_CopyTo/CPP/portcollection_copyto.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_CopyTo/CPP/portcollection_copyto.cpp deleted file mode 100644 index 3f20f18b74adf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_CopyTo/CPP/portcollection_copyto.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// System.Web.Services.Description.PortCollection.Insert -// System.Web.Services.Description.PortCollection.IndexOf -// System.Web.Services.Description.PortCollection.CopyTo -/* - The following sample reads the contents of a file 'MathService.wsdl' - into a 'ServiceDescription' instance. It gets the collection of Service - instances from 'ServiceDescription'. It instantiates 'PortCollection' for - each service in the collection. 'CopyTo' is called to copy - the contents into an array. Calls 'IndexOf' for a given port. - 'Insert' method is called to insert a new port in the collection. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -int main() -{ - try - { - Service^ myService; - PortCollection^ myPortCollection; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathServiceCopyTo_cs.wsdl" ); - Console::WriteLine( "Total Number of Services :{0}", myServiceDescription->Services->Count ); - for ( int i = 0; i < myServiceDescription->Services->Count; ++i ) - { - myService = myServiceDescription->Services[ i ]; - Console::WriteLine( "Name : {0}", myService->Name ); - - // - // - // - myPortCollection = myService->Ports; - - // Create an array of Port objects. - Console::WriteLine( "\nPort collection :" ); - array^myPortArray = gcnew array(myService->Ports->Count); - myPortCollection->CopyTo( myPortArray, 0 ); - for ( int i1 = 0; i1 < myService->Ports->Count; ++i1 ) - { - Console::WriteLine( "Port[{0}] : {1}", i1, myPortArray[ i1 ]->Name ); - - } - // - Port^ myIndexPort = myPortCollection[ 0 ]; - Console::WriteLine( "\n\nThe index of port '{0}' is : {1}", myIndexPort->Name, myPortCollection->IndexOf( myIndexPort ) ); - // - - Port^ myPortTestInsert = myPortCollection[ 0 ]; - myPortCollection->Remove( myPortTestInsert ); - myPortCollection->Insert( 0, myPortTestInsert ); - Console::WriteLine( "\n\nTotal Number of Ports after inserting a new port '{0}' is : {1}", myPortTestInsert->Name, myService->Ports->Count ); - for ( int i1 = 0; i1 < myService->Ports->Count; ++i1 ) - { - Console::WriteLine( "Port[{0}] : {1}", i1, myPortArray[ i1 ]->Name ); - - } - myServiceDescription->Write( "MathServiceCopyToNew_cs.wsdl" ); - // - } - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Exception:{0}", ex->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_Item/CPP/portcollection_item.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_Item/CPP/portcollection_item.cpp deleted file mode 100644 index 9b3c46cc59d6f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortCollection_Item/CPP/portcollection_item.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// System.Web.Services.Description.PortCollection -// System.Web.Services.Description.PortCollection.Remove -// System.Web.Services.Description.PortCollection.Item(String) -// System.Web.Services.Description.PortCollection.Item(Int32) -/* - The following sample reads the contents of a file 'MathService_cs.wsdl' - into a 'ServiceDescription' instance. It gets the collection of Service - instances from 'ServiceDescription'. It instantiates 'PortCollection' for - each service in the collection. It access the ports from the collection and - displays them. It accesses a port by its name from the collection and - displays its index. It adds a new port and calls 'Remove' - to remove the newly added port.The programs writes a new web service - description file. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - // - // - // - // - Service^ myService; - PortCollection^ myPortCollection; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathServiceItem_cs.wsdl" ); - Console::WriteLine( "Total number of services : {0}", myServiceDescription->Services->Count ); - for ( int i = 0; i < myServiceDescription->Services->Count; ++i ) - { - myService = myServiceDescription->Services[ i ]; - Console::WriteLine( "Name : {0}", myService->Name ); - myPortCollection = myService->Ports; - - // Create an array of ports. - Console::WriteLine( "\nPort collection :" ); - for ( int i1 = 0; i1 < myService->Ports->Count; ++i1 ) - { - Console::WriteLine( "Port[{0}] : {1}", i1, myPortCollection[ i1 ]->Name ); - } - // - - String^ strPort = myPortCollection[ 0 ]->Name; - Port^ myPort = myPortCollection[ strPort ]; - Console::WriteLine( "\nIndex of Port[{0}] : {1}", strPort, myPortCollection->IndexOf( myPort ) ); - // - - Port^ myPortTestRemove = myPortCollection[ 0 ]; - Console::WriteLine( "\nTotal number of ports before removing a port '{0}' is : {1}", myPortTestRemove->Name, myService->Ports->Count ); - myPortCollection->Remove( myPortTestRemove ); - Console::WriteLine( "Total number of ports after removing a port '{0}' is : {1}", myPortTestRemove->Name, myService->Ports->Count ); - - // Create the WSDL file. - myPortCollection->Insert( 0, myPortTestRemove ); - myServiceDescription->Write( "MathServiceItemNew_cs.wsdl" ); - // - // - } - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Exception: {0}", ex->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortType/CPP/porttype.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortType/CPP/porttype.cpp deleted file mode 100644 index 0862e7f024994..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortType/CPP/porttype.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// System.Web.Services.Description.PortType.Operations -// System.Web.Services.Description.PortType.PortType() -// System.Web.Services.Description.PortType.Name -/*The following sample demonstrates the properties 'Operations','Name' and constructor -'PortType()' of class 'PortType'.This sample reads the contents of a file 'MathService_cs.wsdl' -into a 'ServiceDescription' instance. It gets the collection of 'PortType' -instances from 'ServiceDescription'. It removes a 'PortType' from the collection, creates a -new 'PortType' and adds it into collection.The programs writes a new web service description -file 'MathService_New.wsdl'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -Operation^ CreateOperation( String^ operationName, String^ inputMessage, String^ outputMessage, String^ targetNamespace ) -{ - Operation^ myOperation = gcnew Operation; - myOperation->Name = operationName; - OperationMessage^ input = dynamic_cast(gcnew OperationInput); - input->Message = gcnew XmlQualifiedName( inputMessage,targetNamespace ); - OperationMessage^ output = dynamic_cast(gcnew OperationOutput); - output->Message = gcnew XmlQualifiedName( outputMessage,targetNamespace ); - myOperation->Messages->Add( input ); - myOperation->Messages->Add( output ); - return myOperation; -} - -int main() -{ - try - { - // - // - PortTypeCollection^ myPortTypeCollection; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); - myPortTypeCollection = myServiceDescription->PortTypes; - int noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes : {0}", noOfPortTypes ); - PortType^ myPortType = myPortTypeCollection[ "MathServiceSoap" ]; - myPortTypeCollection->Remove( myPortType ); - - // Create a new PortType. - PortType^ myNewPortType = gcnew PortType; - myNewPortType->Name = "MathServiceSoap"; - OperationCollection^ myOperationCollection = myServiceDescription->PortTypes[ 0 ]->Operations; - String^ inputMsg; - String^ outputMsg; - for ( int i = 0; i < myOperationCollection->Count; i++ ) - { - inputMsg = String::Concat( myOperationCollection[ i ]->Name, "SoapIn" ); - outputMsg = String::Concat( myOperationCollection[ i ]->Name, "SoapOut" ); - Console::WriteLine( " Operation = {0}", myOperationCollection[ i ]->Name ); - myNewPortType->Operations->Add( CreateOperation( myOperationCollection[ i ]->Name, inputMsg, outputMsg, myServiceDescription->TargetNamespace ) ); - - } - myPortTypeCollection->Add( myNewPortType ); - noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes : {0}", noOfPortTypes ); - myServiceDescription->Write( "MathService_New.wsdl" ); - // - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception:{0}", e->Message ); - } - -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_1/CPP/porttypecollection_1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_1/CPP/porttypecollection_1.cpp deleted file mode 100644 index bfaa4c38ac4c2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_1/CPP/porttypecollection_1.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// System.Web.Services.Description.PortTypeCollection.Item[int] -// System.Web.Services.Description.PortTypeCollection.Remove() -// System.Web.Services.Description.PortTypeCollection.Add() -/*The following sample demonstrates the indexer 'Item[int]', methods -'Remove()' and 'Add()' of class 'PortTypeCollection'. It reads the -contents of a file 'MathService.wsdl'into a 'ServiceDescription' instance. -It gets the collection of 'PortType' from 'ServiceDescription' and adds -a new PortType and writes a new web service description file into -'MathService_New.wsdl'. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -int main() -{ - try - { - // - // - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - int noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes: {0}", myServiceDescription->PortTypes->Count ); - - // Get the first PortType in the collection. - PortType^ myNewPortType = myPortTypeCollection[ 0 ]; - Console::WriteLine( "The PortType at index 0 is: {0}", myNewPortType->Name ); - Console::WriteLine( "Removing the PortType {0}", myNewPortType->Name ); - - // Remove the PortType from the collection. - myPortTypeCollection->Remove( myNewPortType ); - - // Display the number of PortTypes. - Console::WriteLine( "\nTotal number of PortTypes after removing: {0}", myServiceDescription->PortTypes->Count ); - Console::WriteLine( "Adding a PortType {0}", myNewPortType->Name ); - - // Add a new PortType from the collection. - myPortTypeCollection->Add( myNewPortType ); - - // Display the number of PortTypes after adding a port. - Console::WriteLine( "Total number of PortTypes after adding a new port: {0}", myServiceDescription->PortTypes->Count ); - myServiceDescription->Write( "MathService_New.wsdl" ); - // - // - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_2/CPP/porttypecollection_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_2/CPP/porttypecollection_2.cpp deleted file mode 100644 index 5aba1957af5ab..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_2/CPP/porttypecollection_2.cpp +++ /dev/null @@ -1,68 +0,0 @@ - - -// System.Web.Services.Description.PortTypeCollection.Contains() -// System.Web.Services.Description.PortTypeCollection.Insert() -// System.Web.Services.Description.PortTypeCollection.IndexOf() -// System.Web.Services.Description.PortTypeCollection.Item[string] -/* -The following sample demonstrates the methods 'IndexOf()','Insert()','Contains()' and -indexer 'Item[string]' of class 'PortTypeCollection'. This sample reads the contents -of 'MathService.wsdl' into a 'ServiceDescription' instance. It gets the collection of -'PortType' instances from 'ServiceDescription'. It removes a 'PortType' with the name -'MathServiceSoap' and adds the same later. Then it checks whether the collection contains -the added 'PortType'.The sample writes a new web service description file 'MathService_New.wsdl'. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -int main() -{ - try - { - // - // - // - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - int noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes: {0}", noOfPortTypes ); - PortType^ myNewPortType = myPortTypeCollection[ "MathServiceSoap" ]; - // - - // Get the index in the collection. - int index = myPortTypeCollection->IndexOf( myNewPortType ); - // - - Console::WriteLine( "Removing the PortType named {0}", myNewPortType->Name ); - - // Remove the PortType from the collection. - myPortTypeCollection->Remove( myNewPortType ); - noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes: {0}", noOfPortTypes ); - - // Check whether the PortType exists in the collection. - bool bContains = myPortTypeCollection->Contains( myNewPortType ); - Console::WriteLine( "Port Type'{0}' exists: {1}", myNewPortType->Name, bContains ); - Console::WriteLine( "Adding the PortType" ); - - // Insert a new portType at the index location. - myPortTypeCollection->Insert( index, myNewPortType ); - // - - // Display the number of portTypes after adding a port. - Console::WriteLine( "Total number of PortTypes after adding a new port: {0}", myServiceDescription->PortTypes->Count ); - bContains = myPortTypeCollection->Contains( myNewPortType ); - Console::WriteLine( "Port Type'{0}' exists: {1}", myNewPortType->Name, bContains ); - myServiceDescription->Write( "MathService_New.wsdl" ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_Class/CPP/porttypecollection_class.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_Class/CPP/porttypecollection_class.cpp deleted file mode 100644 index a0c7a4790fc82..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_Class/CPP/porttypecollection_class.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// System.Web.Services.Description.PortTypeCollection -/* The following sample demonstrates the class 'PortTypeCollection'. It reads the -contents of WSDL document 'MathService.wsdl'into a 'ServiceDescription' instance. -It gets the collection of 'PortType'from 'ServiceDescription'. It copies the -collection into an array of 'PortType' and displays their names. Then it removes a -'PortType', checks whether the collection contains the removed 'PortType'. -It adds the same 'PortType' and writes a new web service description file into -'MathService_New.wsdl'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -using namespace System::Collections; -int main() -{ - try - { - // Read the existing Web service description file. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - int noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes: {0}", myServiceDescription->PortTypes->Count ); - - // Get the first PortType in the collection. - PortType^ myNewPortType = myPortTypeCollection[ "MathServiceSoap" ]; - int index = myPortTypeCollection->IndexOf( myNewPortType ); - Console::WriteLine( "The PortType with the name {0} is at index: {1}", myNewPortType->Name, (index + 1) ); - Console::WriteLine( "Removing the PortType: {0}", myNewPortType->Name ); - - // Remove the PortType from the collection. - myPortTypeCollection->Remove( myNewPortType ); - bool bContains = myPortTypeCollection->Contains( myNewPortType ); - Console::WriteLine( "The PortType with the name {0} exists: {1}", myNewPortType->Name, bContains ); - Console::WriteLine( "Total number of PortTypes after removing: {0}", myServiceDescription->PortTypes->Count ); - Console::WriteLine( "Adding a PortType: {0}", myNewPortType->Name ); - - // Add a new portType from the collection. - myPortTypeCollection->Add( myNewPortType ); - - // Display the number of portTypes after adding a port. - Console::WriteLine( "Total number of PortTypes after adding a new port: {0}", myServiceDescription->PortTypes->Count ); - - // List the PortTypes available in the WSDL document. - IEnumerator^ myEnum = myPortTypeCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - PortType^ myPortType = safe_cast(myEnum->Current); - Console::WriteLine( "The PortType name is: {0}", myPortType->Name ); - } - myServiceDescription->Write( "MathService_New.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_CopyTo/CPP/porttypecollection_copyto.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_CopyTo/CPP/porttypecollection_copyto.cpp deleted file mode 100644 index a64d2d2fc97f4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortTypeCollection_CopyTo/CPP/porttypecollection_copyto.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// System.Web.Services.Description.PortTypeCollection.CopyTo() - -/* -The following sample demonstrates the 'CopyTo()' method of the class -'PortTypeCollection'.This sample reads the contents of a file 'MathService.wsdl' -into a 'ServiceDescription' instance. It gets the collection of 'PortType' -from 'ServiceDescription'. It copies the collection into an array of 'PortType' -and displays their names. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -int main() -{ - try - { -// - PortTypeCollection^ myPortTypeCollection; - - ServiceDescription^ myServiceDescription = - ServiceDescription::Read( "MathService_CS.wsdl" ); - - myPortTypeCollection = myServiceDescription->PortTypes; - int noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes: {0}", - myServiceDescription->PortTypes->Count ); - - // Copy the collection into an array. - array^ myPortTypeArray = gcnew array(noOfPortTypes); - myPortTypeCollection->CopyTo( myPortTypeArray, 0 ); - - // Display names of all PortTypes. - for ( int i = 0; i < noOfPortTypes; i++ ) - { - Console::WriteLine( "PortType name: {0}", myPortTypeArray[ i ]->Name ); - } - myServiceDescription->Write( "MathService_New.wsdl" ); -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/PortType_Class/CPP/porttype_class.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/PortType_Class/CPP/porttype_class.cpp deleted file mode 100644 index e96a8f14d0a6e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/PortType_Class/CPP/porttype_class.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// System.Web.Services.Description.PortType -/* -The following sample demonstrates the class 'PortType'. This sample reads -the contents of a file 'MathService_cs.wsdl' into a 'ServiceDescription' instance. -It gets the collection of 'PortType'instances from 'ServiceDescription'. -It removes a 'PortType' from the collection, creates a new 'PortType' and adds -it into collection.The programs writes a new web service description -file 'MathService_New.wsdl'. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; -Operation^ CreateOperation( String^ operationName, String^ inputMessage, String^ outputMessage, String^ targetNamespace ) -{ - Operation^ myOperation = gcnew Operation; - myOperation->Name = operationName; - OperationMessage^ input = dynamic_cast(gcnew OperationInput); - input->Message = gcnew XmlQualifiedName( inputMessage,targetNamespace ); - OperationMessage^ output = dynamic_cast(gcnew OperationOutput); - output->Message = gcnew XmlQualifiedName( outputMessage,targetNamespace ); - myOperation->Messages->Add( input ); - myOperation->Messages->Add( output ); - return myOperation; -} - -int main() -{ - try - { - PortTypeCollection^ myPortTypeCollection; - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); - myPortTypeCollection = myServiceDescription->PortTypes; - int noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal number of PortTypes : {0}", noOfPortTypes ); - PortType^ myPortType = myPortTypeCollection[ "MathServiceSoap" ]; - myPortTypeCollection->Remove( myPortType ); - - // Create a new PortType. - PortType^ myNewPortType = gcnew PortType; - myNewPortType->Name = "MathServiceSoap"; - OperationCollection^ myOperationCollection = myServiceDescription->PortTypes[ 0 ]->Operations; - for ( int i = 0; i < myOperationCollection->Count; i++ ) - { - String^ inputmsg = String::Concat( myOperationCollection[ i ]->Name, "SoapIn" ); - String^ outputmsg = String::Concat( myOperationCollection[ i ]->Name, "SoapOut" ); - Console::WriteLine( "Operation = {0}", myOperationCollection[ i ]->Name ); - myNewPortType->Operations->Add( CreateOperation( myOperationCollection[ i ]->Name, inputmsg, outputmsg, myServiceDescription->TargetNamespace ) ); - - } - - // Add the PortType to the collection. - myPortTypeCollection->Add( myNewPortType ); - noOfPortTypes = myServiceDescription->PortTypes->Count; - Console::WriteLine( "\nTotal Number of PortTypes : {0}", noOfPortTypes ); - myServiceDescription->Write( "MathService_New.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RealProxy_Sample/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RealProxy_Sample/CPP/makefile deleted file mode 100644 index dfe5cf66691f9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RealProxy_Sample/CPP/makefile +++ /dev/null @@ -1,3 +0,0 @@ -all: realproxy_sample.exe -realproxy_sample.exe: realproxy_sample.cpp - cl /clr:pure realproxy_sample.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RealProxy_Sample/CPP/realproxy_sample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RealProxy_Sample/CPP/realproxy_sample.cpp deleted file mode 100644 index 1df6d73f92567..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RealProxy_Sample/CPP/realproxy_sample.cpp +++ /dev/null @@ -1,131 +0,0 @@ - - -// System.Runtime.Remoting.Proxies.RealProxy.SupportsInterface(Guid); -// System.Runtime.Remoting.Proxies.RealProxy.GetCOMIUnknown(bool); -// System.Runtime.Remoting.Proxies.RealProxy.SetCOMIUnknown(IntPtr); -/* The following example demonstrates implementation of methods -'GetCOMIUnknown','SupportsInterface' and 'SetCOMIUnknown' of -System.Runtime.Remoting.Proxies.RealProxy. - -The following program has a 'CustomProxy' referring to unmanaged COM component. -A COM Runtime Wrapper takes care of method call to unmanaged world. SupportsInterface -method is overridden to return address of COM Runtime Wrapper. -*/ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Activation; -using namespace System::Runtime::Remoting::Proxies; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Contexts; -using namespace System::Runtime::InteropServices; -using namespace System::Security::Permissions; -using namespace ActiveDs; -// using namespace InterOpADS; -public ref class MyProxy: public RealProxy -{ -private: - String^ m_URI; - MarshalByRefObject^ myMarshalByRefObject; - -public: - [SecurityPermission(SecurityAction::LinkDemand)] - MyProxy() - : RealProxy() - { - Console::WriteLine( "MyProxy Constructor Called..." ); - myMarshalByRefObject = dynamic_cast(Activator::CreateInstance(WinNTSystemInfo::typeid )); - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - m_URI = myObjRef->URI; - } - - [SecurityPermission(SecurityAction::LinkDemand)] - MyProxy( Type^ myType ) - : RealProxy( myType ) - { - Console::WriteLine( "MyProxy Constructor Called..." ); - myMarshalByRefObject = dynamic_cast(Activator::CreateInstance( myType )); - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - m_URI = myObjRef->URI; - } - - [SecurityPermission(SecurityAction::LinkDemand)] - MyProxy( Type^ myType, MarshalByRefObject^ targetObject ) - : RealProxy( myType ) - { - Console::WriteLine( "MyProxy Constructor Called..." ); - myMarshalByRefObject = targetObject; - ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject ); - m_URI = myObjRef->URI; - } - - [SecurityPermission(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::Infrastructure)] - virtual IMessage^ Invoke( IMessage^ msg ) override - { - if ( dynamic_cast(msg) ) - { - - // Initialize a new instance of remote object - IConstructionReturnMessage^ myIConstructionReturnMessage = this->InitializeServerObject( dynamic_cast(msg) ); - ConstructionResponse^ constructionResponse = gcnew ConstructionResponse( nullptr,dynamic_cast(msg) ); - return constructionResponse; - } - - IDictionary^ myIDictionary = msg->Properties; - IMessage^ retMsg; - myIDictionary->default[ "__Uri" ] = m_URI; - - // Synchronously dispatch messages to server. - retMsg = ChannelServices::SyncDispatchMessage( msg ); - - // Pushing return value and OUT parameters back onto stack - IMethodReturnMessage^ mrm = dynamic_cast(retMsg); - return retMsg; - } - - // - // - // - [SecurityPermission(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::Infrastructure)] - IntPtr SupportsInterface( Guid * /*myGuid*/ ) - { - Console::WriteLine( "SupportsInterface method called" ); - - // Object reference is requested for communication with unmanaged objects - // in the current process through COM. - IntPtr myIntPtr = this->GetCOMIUnknown( false ); - - // Stores an unmanaged proxy of the object. - this->SetCOMIUnknown( myIntPtr ); - - // return COM Runtime Wrapper pointer. - return myIntPtr; - } - // - // - // -}; - - -// Acts as a custom proxy user. -[SecurityPermission(SecurityAction::LinkDemand)] -int main() -{ - Console::WriteLine( "" ); - Console::WriteLine( "CustomProxy Sample" ); - Console::WriteLine( "==================" ); - MyProxy^ mProxy = gcnew MyProxy( WinNTSystemInfo::typeid); - WinNTSystemInfo^ myHelloServer = dynamic_cast(mProxy->GetTransparentProxy()); - Console::WriteLine( "Machine Name = {0}", myHelloServer->ComputerName ); - Console::WriteLine( "Domain Name = {0}", myHelloServer->DomainName ); - Console::WriteLine( "User Name = {0}", myHelloServer->UserName ); - - // Construct Guid object from unmanaged Interface 'IADsWinNTSystemInfo' guid. - Guid myGuid = Guid("{6C6D65DC-AFD1-11D2-9CB9-0000F87A369E}"); - IntPtr myIntrPtr = mProxy->SupportsInterface( &myGuid ); - Console::WriteLine( "Requested Interface Pointer= {0}", myIntrPtr.ToInt32() ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/client.cpp deleted file mode 100644 index 11d4599ec999d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/client.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -#using -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Runtime::Remoting::Contexts; -using namespace System::Runtime::Serialization; -using namespace System::Collections; -using namespace SampleNamespace; - -int main() -{ - ChannelServices::RegisterChannel( gcnew HttpChannel( 0 ) ); - RemotingConfiguration::RegisterActivatedClientType( SampleService::typeid, "http://localhost:9000/MySampleService" ); - SampleService ^ myRemoteObject = gcnew SampleService; - bool result = myRemoteObject->SampleMethod(); - - // System::Runtime::Remoting::ObjRef - // - ObjRef^ objRefSample = RemotingServices::GetObjRefForProxy( myRemoteObject ); - Console::WriteLine( "***ObjRef Details***" ); - Console::WriteLine( "URI:\t {0}", objRefSample->URI ); - array^channelData = objRefSample->ChannelInfo->ChannelData; - Console::WriteLine( "Channel Info:" ); - for each(Object^ o in channelData) - Console::WriteLine("\t{0}", o->ToString()); - IEnvoyInfo^ envoyInfo = objRefSample->EnvoyInfo; - if ( envoyInfo == nullptr ) - { - Console::WriteLine( "This ObjRef does not have envoy information." ); - } - else - { - IMessageSink^ envoySinks = envoyInfo->EnvoySinks; - Console::WriteLine( "Envoy Sink Class: {0}", envoySinks ); - } - IRemotingTypeInfo^ typeInfo = objRefSample->TypeInfo; - Console::WriteLine( "Remote type name: {0}", typeInfo->TypeName ); - Console::WriteLine( "Can my Object cast to a Bitmap? {0}", typeInfo->CanCastTo( System::Drawing::Bitmap::typeid, objRefSample ) ); - Console::WriteLine( "Is this Object from this AppDomain? {0}", objRefSample->IsFromThisAppDomain() ); - Console::WriteLine( "Is this Object from this process? {0}", objRefSample->IsFromThisProcess() ); - // - - return 0; -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/makefile deleted file mode 100644 index 0123a1cccaabe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -makefile : server.exe client.exe - -server.exe : server.cpp service.dll - cl /clr:pure server.cpp - -client.exe : client.cpp service.dll - cl /clr:pure client.cpp - -service.dll : service.cpp - cl /clr:pure /LD service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/server.cpp deleted file mode 100644 index e63960c89bd7a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/server.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; -using namespace SampleNamespace; - -int main() -{ - HttpChannel^ channel = gcnew HttpChannel( 9000 ); - ChannelServices::RegisterChannel( channel ); - RemotingConfiguration::ApplicationName = "MySampleService"; - RemotingConfiguration::RegisterActivatedServiceType( SampleService::typeid ); - Console::WriteLine( "Press enter to end the server process." ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/service.cpp deleted file mode 100644 index a0d9caedd44fc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting.ObjRef/CPP/service.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; - -namespace SampleNamespace -{ - // Define the remote service class - public ref class SampleService: public MarshalByRefObject - { - public: - bool SampleMethod() - { - Console::WriteLine( "Hello, you have called SampleMethod()." ); - return true; - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/client.cpp deleted file mode 100644 index ef46529987d8f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/client.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel ); - RemotingConfiguration::RegisterActivatedClientType( HelloServiceClass::typeid, "tcp://localhost:8082" ); - try - { - HelloServiceClass ^ service = gcnew HelloServiceClass; - - // Calls the remote method. - Console::WriteLine(); - Console::WriteLine( "Calling remote Object" ); - Console::WriteLine( service->HelloMethod( "Caveman" ) ); - Console::WriteLine( service->HelloMethod( "Spaceman" ) ); - Console::WriteLine( service->HelloMethod( "Client Man" ) ); - Console::WriteLine( "Finished remote Object call" ); - } - catch (Exception ex) - { - Console::WriteLine("An exception occurred: " + ex.Message); - } - Console::WriteLine(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/makefile deleted file mode 100644 index 2f15fb3bfe717..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: Service.dll Client.exe Server.exe - -Server.exe: Server.cpp - cl /clr:pure Server.cpp - -Client.exe: Client.cpp - cl /clr:pure Client.cpp - -Service.dll: service.cpp - cl /clr:pure /LD service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/server.cpp deleted file mode 100644 index f11b436af12db..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/server.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) ); - RemotingConfiguration::RegisterActivatedServiceType( HelloServiceClass::typeid ); - Console::WriteLine( "Press enter to stop this process." ); - Console::ReadLine(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/service.cpp deleted file mode 100644 index 75ffaf57d8f6e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ClientActivation/CPP/service.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; - -public ref class HelloServiceClass: public MarshalByRefObject -{ -private: - static int n_instance; - -public: - HelloServiceClass() - { - n_instance++; - Console::WriteLine( "{0} has been created. Instance # = {1}", this->GetType()->Name, n_instance ); - } - - ~HelloServiceClass() - { - Console::WriteLine( "Destroyed instance {0} of HelloServiceClass.", n_instance ); - n_instance--; - } - - String^ HelloMethod( String^ name ) - { - // Reports that the method was called. - Console::WriteLine(); - Console::WriteLine( "Called HelloMethod on instance {0} with the '{1}' parameter.", n_instance, name ); - - // Calculates and returns the result to the client. - return String::Format( "Hi there {0}", name ); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/client.cpp deleted file mode 100644 index cc94e608fe1d4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/client.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -#using -#using -#using "server.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels; - -int main() -{ - // open channel and get handle to Object - ChannelServices::RegisterChannel( gcnew TcpChannel ); - - //Registering the well known Object on the client side for use by the operator gcnew. - RemotingConfiguration::RegisterWellKnownClientType( HelloServer::typeid, - "tcp://localhost:8084/SayHello" ); - HelloServer^ obj = gcnew HelloServer; - - // call remote method - Console::WriteLine(); - Console::WriteLine( "Before Call" ); - Console::WriteLine( obj->HelloMethod( "Caveman" ) ); - Console::WriteLine( obj->HelloMethod( "Spaceman" ) ); - Console::WriteLine( obj->HelloMethod( "Client Man" ) ); - Console::WriteLine( "After Call" ); - Console::WriteLine(); -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/makefile deleted file mode 100644 index 2a6b27ebd19cb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all : server.dll client.exe - -server.dll : server.cpp - cl /LD /clr:pure server.cpp - -client.exe : client.cpp server.dll - cl /clr:pure client.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/server.cpp deleted file mode 100644 index a7646f3ab1cd2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation/CPP/server.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -public ref class HelloServer: public MarshalByRefObject -{ -private: - static int n_called = 0; - -public: - static void Main() - { -// -// - // Registers the server and waits until the user hits enter. - TcpChannel^ chan = gcnew TcpChannel( 8084 ); - ChannelServices::RegisterChannel( chan ); - - RemotingConfiguration::RegisterWellKnownServiceType( - Type::GetType( "HelloServer,server" ), - "SayHello", - WellKnownObjectMode::SingleCall ); - System::Console::WriteLine( L"Hit to exit..." ); - System::Console::ReadLine(); -// -// - } - - HelloServer() - { - Console::WriteLine( "HelloServer activated" ); - } - - ~HelloServer() - { - Console::WriteLine( "Object Destroyed" ); - } - - String^ HelloMethod( String^ name ) - { - // Reports that the method was called. - Console::WriteLine(); - Console::WriteLine( "Hello.HelloMethod : {0}", name ); - n_called++; - Console::WriteLine( "The method was called {0} times.", n_called ); - - // Calculates and returns the result to the client. - return String::Format( "Hi there {0}", name ); - } -}; -// - -int main() -{ - HelloServer::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/client.cpp deleted file mode 100644 index 4a3d08ad8ade0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/client.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels; -int main() -{ - // - // - ChannelServices::RegisterChannel( gcnew TcpChannel ); - RemotingConfiguration::RegisterWellKnownClientType( HelloService::typeid, - "tcp://localhost:8082/HelloServiceApplication/MyUri" ); - HelloService ^ service = gcnew HelloService; - // - // - if ( service == nullptr ) - { - Console::WriteLine( "Could not locate server." ); - return -1; - } - - // Calls the remote method. - Console::WriteLine(); - Console::WriteLine( "Calling remote Object*" ); - Console::WriteLine( service->HelloMethod( "Caveman" ) ); - Console::WriteLine( service->HelloMethod( "Spaceman" ) ); - Console::WriteLine( service->HelloMethod( "Client Man" ) ); - Console::WriteLine( "Finished remote Object* call" ); - Console::WriteLine(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/makefile deleted file mode 100644 index 2a9cfc0149e10..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: service.dll Client.exe Server.exe - -service.dll: service.cpp - cl /clr:pure /LD service.cpp - -Server.exe: Server.cpp - cl /clr:pure Server.cpp - -Client.exe: Client.cpp - cl /clr:pure Client.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/server.cpp deleted file mode 100644 index 35c1d834e809f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/server.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - // - // - ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) ); - RemotingConfiguration::ApplicationName = "HelloServiceApplication"; - RemotingConfiguration::RegisterWellKnownServiceType( HelloService::typeid, - "MyUri", - WellKnownObjectMode::SingleCall ); - // - // - Console::WriteLine( "Press enter to stop this process." ); - Console::ReadLine(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/service.cpp deleted file mode 100644 index f8d912e49bf33..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration.ServerActivation1/CPP/service.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using - -using namespace System; -public ref class HelloService: public MarshalByRefObject -{ -private: - static int n_instances; - -public: - HelloService() - { - n_instances++; - Console::WriteLine( "" ); - Console::WriteLine( "HelloService activated - instance # {0}.", n_instances ); - } - - ~HelloService() - { - Console::WriteLine( "HelloService instance {0} destroyed.", n_instances ); - n_instances--; - } - - String^ HelloMethod( String^ name ) - { - Console::WriteLine( "HelloMethod called on HelloService instance {0}.", n_instances ); - return String::Format( "Hi there {0}.", name ); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/RemotingConfiguration_Configure_Client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/RemotingConfiguration_Configure_Client.cpp deleted file mode 100644 index 1c5b46ac99a86..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/RemotingConfiguration_Configure_Client.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - TcpChannel^ myChannel = gcnew TcpChannel; - ChannelServices::RegisterChannel( myChannel ); - MyServerImpl ^ myObject = dynamic_cast(Activator::GetObject( MyServerImpl::typeid, "tcp://localhost:8085/SayHello" )); - Console::WriteLine( myObject->MyMethod( "ClientString" ) ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/RemotingConfiguration_Configure_Shared.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/RemotingConfiguration_Configure_Shared.cpp deleted file mode 100644 index 5b74d849a263b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/RemotingConfiguration_Configure_Shared.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// This is the implementation class for the remote object. -using namespace System; -public ref class MyServerImpl: public MarshalByRefObject -{ -public: - MyServerImpl(){} - - String^ MyMethod( String^ name ) - { - return String::Format( "The string from client is {0}", name ); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/makefile deleted file mode 100644 index 8f67adf1f7caf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all : remotingconfiguration_configure_server.exe RemotingConfiguration_Configure_Client.exe - - -remotingconfiguration_configure_server.exe : remotingconfiguration_configure_server.cpp RemotingConfiguration_Configure_Shared.dll - cl /clr:pure remotingconfiguration_configure_server.cpp - -RemotingConfiguration_Configure_Client.exe : RemotingConfiguration_Configure_Client.cpp RemotingConfiguration_Configure_Shared.dll - cl /clr:pure RemotingConfiguration_Configure_Client.cpp - -RemotingConfiguration_Configure_Shared.dll : RemotingConfiguration_Configure_Shared.cpp - cl /clr:pure /LD RemotingConfiguration_Configure_Shared.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/remotingconfiguration_configure_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/remotingconfiguration_configure_server.cpp deleted file mode 100644 index 122bcd549e09e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_Configure_Client/CPP/remotingconfiguration_configure_server.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// System.Runtime.Remoting.RemotingConfiguration.Configure -// System.Runtime.Remoting.RemotingConfiguration.GetRegisteredWellKnownServiceTypes -/* - The following example demonstrates the 'Configure' and - 'GetRegisteredWellKnownServiceTypes' methods of 'RemotingConfiguration' class. - It configures the remoting infrastructure using the 'Configure' method.Then gets - the registered well-known objects at the service end and displays it's properties - on the console. -*/ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; - -int main() -{ - // - // Configure the remoting structure. - RemotingConfiguration::Configure( "server.config" ); - // - - // - // Retrive the array of objects registered as well known types at - // the service end. - array^myEntries = RemotingConfiguration::GetRegisteredWellKnownServiceTypes(); - Console::WriteLine( "The number of WellKnownServiceTypeEntries are:{0}", myEntries->Length ); - Console::WriteLine( "The Object Type is:{0}", myEntries[ 0 ]->ObjectType ); - Console::WriteLine( "The Object Uri is:{0}", myEntries[ 0 ]->ObjectUri ); - Console::WriteLine( "The Mode is:{0}", myEntries[ 0 ]->Mode ); - // - - Console::WriteLine( "Press to exit..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_Client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_Client.cpp deleted file mode 100644 index 5fd1b48ad1500..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_Client.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - try - { - ChannelServices::RegisterChannel( gcnew TcpChannel ); - RemotingConfiguration::RegisterActivatedClientType( MyServerImpl::typeid, "tcp://localhost:8085" ); - MyServerImpl ^ myObject = gcnew MyServerImpl; - for ( int i = 0; i <= 4; i++ ) - Console::WriteLine( myObject->MyMethod( String::Format( "invoke the server method {0} time", (i + 1) ) ) ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_server.cpp deleted file mode 100644 index 8853fd1bced2c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_server.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// System.Runtime.Remoting.RemotingConfiguration.IsActivationAllowed -// System.Runtime.Remoting.RemotingConfiguration.GetRegisteredActivatedServiceTypes -/* -The following example demonstrates the 'IsActivationAllowed' and -'GetRegisteredActivatedServiceTypes' methods of 'RemotingConfiguration' class. -It registers a 'TcpChannel' object with the channel services. Then registers the 'MyServerImpl' -object at the service end that can be activated on request from a client.By using the -'GetRegisteredActivatedClientTypes' method it gets the registered activated service types -and displays it's properties to the console. - -*/ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel( 8085 ) ); - RemotingConfiguration::RegisterActivatedServiceType( MyServerImpl::typeid ); - - // - // - // Check whether the 'MyServerImpl' object is allowed for - // activation or not. - if ( RemotingConfiguration::IsActivationAllowed( MyServerImpl::typeid ) ) - { - // Get the registered activated service types . - array^myActivatedServiceEntries = RemotingConfiguration::GetRegisteredActivatedServiceTypes(); - Console::WriteLine( "The Length of the registered activated service type array is {0}", myActivatedServiceEntries->Length ); - Console::WriteLine( "The Object type is:{0}", myActivatedServiceEntries[ 0 ]->ObjectType ); - } - // - // - - Console::WriteLine( "Press enter to stop this process." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_shared.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_shared.cpp deleted file mode 100644 index a117c15ab5410..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/RemotingConfiguration_GetRegisteredActivatedService_shared.cpp +++ /dev/null @@ -1,15 +0,0 @@ - -using namespace System; -public ref class MyServerImpl: public MarshalByRefObject -{ -public: - MyServerImpl() - { - Console::WriteLine( "Server Activated..." ); - } - - String^ MyMethod( String^ name ) - { - return String::Format( "The client requests to {0}", name ); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/makefile deleted file mode 100644 index dda16a4cb4d08..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredActivatedServer_Client/CPP/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all : remotingconfiguration_getregisteredactivatedservice_server.exe RemotingConfiguration_GetRegisteredActivatedService_Client.exe - - -remotingconfiguration_getregisteredactivatedservice_server.exe : remotingconfiguration_getregisteredactivatedservice_server.cpp RemotingConfiguration_GetRegisteredActivatedService_Shared.dll - cl /clr:pure remotingconfiguration_getregisteredactivatedservice_server.cpp - -RemotingConfiguration_GetRegisteredActivatedService_Client.exe : RemotingConfiguration_GetRegisteredActivatedService_Client.cpp RemotingConfiguration_GetRegisteredActivatedService_Shared.dll - cl /clr:pure RemotingConfiguration_GetRegisteredActivatedService_Client.cpp - -RemotingConfiguration_GetRegisteredActivatedService_Shared.dll : RemotingConfiguration_GetRegisteredActivatedService_Shared.cpp - cl /clr:pure /LD RemotingConfiguration_GetRegisteredActivatedService_Shared.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/makefile deleted file mode 100644 index e3934ed1ef375..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_GetRegisteredWellKnownClient_Server.exe remotingconfiguration_getregisteredwellknownclient_client.exe - - -RemotingConfiguration_GetRegisteredWellKnownClient_Server.exe : RemotingConfiguration_GetRegisteredWellKnownClient_Server.cpp RemotingConfiguration_GetRegisteredWellKnownClient_Shared.dll - cl /clr:pure RemotingConfiguration_GetRegisteredWellKnownClient_Server.cpp - -remotingconfiguration_getregisteredwellknownclient_client.exe : remotingconfiguration_getregisteredwellknownclient_client.cpp RemotingConfiguration_GetRegisteredWellKnownClient_Shared.dll - cl /clr:pure remotingconfiguration_getregisteredwellknownclient_client.cpp - -RemotingConfiguration_GetRegisteredWellKnownClient_Shared.dll : RemotingConfiguration_GetRegisteredWellKnownClient_Shared.cpp - cl /clr:pure /LD RemotingConfiguration_GetRegisteredWellKnownClient_Shared.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_client.cpp deleted file mode 100644 index e149f6b0fb6cc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_client.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// System.Runtime.Remoting.RemotingConfiguration.GetRegisteredWellKnownClientTypes -/* -The following example demonstrates the 'GetRegisteredWellKnownClientTypes' method -of 'RemotingConfiguration' class. -It registers a 'TcpChannel' object with the channel services. Then registers the -'MyServerImpl' object as well-known type at the client end. By using the -'GetRegisteredWellKnownClientTypes' method it gets well-known types registered -at the client side and displays it's properties to the console. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel ); - - // Register the specified object as well-known type at client end. - RemotingConfiguration::RegisterWellKnownClientType( MyServerImpl::typeid, "tcp://localhost:8085/SayHello" ); - MyServerImpl ^ myObject = gcnew MyServerImpl; - Console::WriteLine( myObject->MyMethod( "ClientString" ) ); - - // - // Get the well-known types registered at the client. - array^myEntries = RemotingConfiguration::GetRegisteredWellKnownClientTypes(); - Console::WriteLine( "The number of WellKnownClientTypeEntries are:{0}", myEntries->Length ); - Console::WriteLine( "The Object type is:{0}", myEntries[ 0 ]->ObjectType ); - Console::WriteLine( "The Object Url is:{0}", myEntries[ 0 ]->ObjectUrl ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_server.cpp deleted file mode 100644 index 359f51a9b1d32..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_server.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - TcpChannel^ chan = gcnew TcpChannel( 8085 ); - ChannelServices::RegisterChannel( chan ); - RemotingConfiguration::RegisterWellKnownServiceType( MyServerImpl::typeid, "SayHello", WellKnownObjectMode::Singleton ); - Console::WriteLine( "Press to exit..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_shared.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_shared.cpp deleted file mode 100644 index 69aee02c2b088..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_GetRegisteredWellKnownClient_Client/CPP/remotingconfiguration_getregisteredwellknownclient_shared.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -using namespace System; - -public ref class MyServerImpl: public MarshalByRefObject -{ -public: - MyServerImpl() - { - Console::WriteLine( "Server Activated" ); - } - - String^ MyMethod( String^ name ) - { - return String::Format( "The string from client is {0}", name ); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs deleted file mode 100644 index 007015ae6222f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated..."); - } - - public String MyMethod(String name) - { - return "The client requests to "+name; - } - } diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/makefile deleted file mode 100644 index 72013b6e09fde..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: remotingconfiguration_isremotelyactivatedclienttype1_server.exe remotingconfiguration_isremotelyactivatedclienttype1_client.exe RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.dll - -RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll : RemotingConfiguration_IsRemotelyActivatedClientType1_shared.cs - csc /t:library RemotingConfiguration_IsRemotelyActivatedClientType1_shared.cs - -remotingconfiguration_isremotelyactivatedclienttype1_server.exe : remotingconfiguration_isremotelyactivatedclienttype1_server.cpp RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.dll - cl /clr:pure remotingconfiguration_isremotelyactivatedclienttype1_server.cpp - -remotingconfiguration_isremotelyactivatedclienttype1_client.exe : remotingconfiguration_isremotelyactivatedclienttype1_client.cpp RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.dll - cl /clr:pure remotingconfiguration_isremotelyactivatedclienttype1_client.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype1_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype1_client.cpp deleted file mode 100644 index 39c71256e28ed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype1_client.cpp +++ /dev/null @@ -1,43 +0,0 @@ - - -// System.Runtime.Remoting.RemotingConfiguration.IsRemotelyActivatedClientType(Type) -/* -The following example demonstrates the 'IsRemotelyActivatedClientType(Type)' method -of 'RemotingConfiguration' class. -It registers a 'TcpChannel' object with the channel services. Then registers the 'MyServerImpl' -object as activated client type which can be activated at the server. By using the above -method it gets the activated client type registered at the client side and displays it's -properties to the console. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - try - { - ChannelServices::RegisterChannel( gcnew TcpChannel, false ); - RemotingConfiguration::RegisterActivatedClientType( MyServerImpl::typeid, "tcp://localhost:8085" ); - MyServerImpl ^ myObject = gcnew MyServerImpl; - for ( int i = 0; i <= 4; i++ ) - Console::WriteLine( myObject->MyMethod( String::Format( "invoke the server method {0} time.", (i + 1) ) ) ); - - // - // Check whether the 'MyServerImpl' type is registered as - // a remotely activated client type. - ActivatedClientTypeEntry^ myActivatedClientEntry = RemotingConfiguration::IsRemotelyActivatedClientType( MyServerImpl::typeid); - Console::WriteLine( "The Object type is {0}", myActivatedClientEntry->ObjectType ); - Console::WriteLine( "The Application Url is {0}", myActivatedClientEntry->ApplicationUrl ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype1_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype1_server.cpp deleted file mode 100644 index 6732b27807198..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType1_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype1_server.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel( 8085 ), false ); - RemotingConfiguration::RegisterActivatedServiceType( MyServerImpl::typeid ); - Console::WriteLine( "Press enter to stop this process." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs deleted file mode 100644 index f19ff43b19bbe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - int i; - public MyServerImpl() - { - i=0; - Console.WriteLine("Server Activated..."); - } - - public String MyMethod(String name) - { - i=i+1; - return "The client requests to "+name +i+" time"; - } - } diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/makefile deleted file mode 100644 index efdfd5a9bee59..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/makefile +++ /dev/null @@ -1,14 +0,0 @@ -all: RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.dll remotingconfiguration_isremotelyactivatedclienttype2_server.exe remotingconfiguration_isremotelyactivatedclienttype2_client.exe - -RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.dll : RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs - csc /t:library RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs - -remotingconfiguration_isremotelyactivatedclienttype2_server.exe : remotingconfiguration_isremotelyactivatedclienttype2_server.cpp RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.dll - cl /clr:pure remotingconfiguration_isremotelyactivatedclienttype2_server.cpp - -remotingconfiguration_isremotelyactivatedclienttype2_client.exe : remotingconfiguration_isremotelyactivatedclienttype2_client.cpp RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.dll - cl /clr:pure remotingconfiguration_isremotelyactivatedclienttype2_client.cpp - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype2_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype2_client.cpp deleted file mode 100644 index ee5aae8ca7cea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype2_client.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// System.Runtime.Remoting.RemotingConfiguration.IsRemotelyActivatedClientType(String,String) -/* -The following example demonstrates the 'IsRemotelyActivatedClientType(String,String)' method -of 'RemotingConfiguration' class. -It registers a 'TcpChannel' object with the channel services. Then registers the 'MyServerImpl' -object as activated client type which can be activated at the server and displays it's -properties to the console. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - try - { - ChannelServices::RegisterChannel( gcnew TcpChannel, false ); - RemotingConfiguration::RegisterActivatedClientType( MyServerImpl::typeid, "tcp://localhost:8085" ); - MyServerImpl ^ myObject = gcnew MyServerImpl; - for ( int i = 0; i <= 4; i++ ) - Console::WriteLine( myObject->MyMethod( "invoke the server method " ) ); - - // Get the assembly for the 'MyServerImpl' object. - // - Assembly^ myAssembly = Assembly::GetAssembly( MyServerImpl::typeid ); - AssemblyName^ myName = myAssembly->GetName(); - - // Check whether the 'MyServerImpl' type is registered as - // a remotely activated client type. - ActivatedClientTypeEntry^ myActivatedClientEntry = - RemotingConfiguration::IsRemotelyActivatedClientType( MyServerImpl::typeid->FullName, myName->Name ); - Console::WriteLine( "The Object type : {0}", myActivatedClientEntry->ObjectType ); - Console::WriteLine( "The Application Url : {0}", myActivatedClientEntry->ApplicationUrl ); - if (myActivatedClientEntry) - Console::WriteLine( "The object is client activated"); - else - Console::WriteLine("The object is not client activated"); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype2_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype2_server.cpp deleted file mode 100644 index a14fe90241989..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsRemotelyActivatedClientType2_Client/CPP/remotingconfiguration_isremotelyactivatedclienttype2_server.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel( 8085 ), false ); - RemotingConfiguration::RegisterActivatedServiceType( MyServerImpl::typeid ); - Console::WriteLine( "Press enter to stop this process." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/RemotingConfiguration_IsWellKnownClientType1_Shared.cs b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/RemotingConfiguration_IsWellKnownClientType1_Shared.cs deleted file mode 100644 index 4779f34178062..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/RemotingConfiguration_IsWellKnownClientType1_Shared.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated"); - } - - public String MyMethod(String name) - { - return "The string from client is " + name; - } - } diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/makefile deleted file mode 100644 index e3eabdfb65d68..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: RemotingConfiguration_IsWellKnownClientType1_Shared.dll remotingconfiguration_iswellknownclienttype1_client.exe - -RemotingConfiguration_IsWellKnownClientType1_Shared.dll : RemotingConfiguration_IsWellKnownClientType1_Shared.cs - csc /t:library RemotingConfiguration_IsWellKnownClientType1_Shared.cs - -remotingconfiguration_iswellknownclienttype1_client.exe : remotingconfiguration_iswellknownclienttype1_client.cpp RemotingConfiguration_IsWellKnownClientType1_Shared.dll - cl /clr:pure remotingconfiguration_iswellknownclienttype1_client.cpp - - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/remotingconfiguration_iswellknownclienttype1_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/remotingconfiguration_iswellknownclienttype1_client.cpp deleted file mode 100644 index 00ffa473c279a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType1_Client/CPP/remotingconfiguration_iswellknownclienttype1_client.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// System.Runtime.Remoting.RemotingConfiguration.IsWellKnownClientType(Type) -/* -The following example demonstrates the 'IsWellKnownClientType(Type)' method -of 'RemotingConfiguration' class. It registers a 'TcpChannel' object with the channel -services. Then registers the 'MyServerImpl' object as well-known type. By using the above -method it gets the well-known type registered at the client side and displays it's -properties to the console. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel, false ); - - // Register the 'MyServerImpl' object as well known type - // at client end. - RemotingConfiguration::RegisterWellKnownClientType( MyServerImpl::typeid, "tcp://localhost:8085/SayHello" ); - MyServerImpl ^ myObject = gcnew MyServerImpl; - Console::WriteLine( myObject->MyMethod( "ClientString" ) ); - - // - // Check whether the specified object type is registered as - // well known client type or not. - WellKnownClientTypeEntry^ myWellKnownClientType = RemotingConfiguration::IsWellKnownClientType( MyServerImpl::typeid ); - Console::WriteLine( "The Object type is {0}", myWellKnownClientType->ObjectType ); - Console::WriteLine( "The Object Url is {0}", myWellKnownClientType->ObjectUrl ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/RemotingConfiguration_IsWellKnownClientType2_Shared.cs b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/RemotingConfiguration_IsWellKnownClientType2_Shared.cs deleted file mode 100644 index ed75db7d4c923..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/RemotingConfiguration_IsWellKnownClientType2_Shared.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated"); - } - - public String MyMethod(String name) - { - Console.WriteLine(name); - return "The string from server : " + name; - } - } diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/makefile deleted file mode 100644 index ad6b6af057759..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: RemotingConfiguration_IsWellKnownClientType2_Shared.dll remotingconfiguration_iswellknownclienttype2_client.exe - -RemotingConfiguration_IsWellKnownClientType2_Shared.dll : RemotingConfiguration_IsWellKnownClientType2_Shared.cs - csc /t:library RemotingConfiguration_IsWellKnownClientType2_Shared.cs - -remotingconfiguration_iswellknownclienttype2_client.exe : remotingconfiguration_iswellknownclienttype2_client.cpp RemotingConfiguration_IsWellKnownClientType2_Shared.dll - cl /clr:pure remotingconfiguration_iswellknownclienttype2_client.cpp - - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/remotingconfiguration_iswellknownclienttype2_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/remotingconfiguration_iswellknownclienttype2_client.cpp deleted file mode 100644 index ba0e93af1f077..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingConfiguration_IsWellKnownClientType2_Client/CPP/remotingconfiguration_iswellknownclienttype2_client.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -// System.Runtime.Remoting.RemotingConfiguration.IsWellKnownClientType(String,String) -/* -The following example demonstrates the 'IsWellKnownClientType(String,String)' method -of 'RemotingConfiguration' class. It registers a 'TcpChannel' object with the channel -services. Then registers the 'MyServerImpl' object as well-known type at the client end. -and displays it's properties to the console. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel, false ); - - // Register the 'MyServerImpl' object as well known type - // at client end. - RemotingConfiguration::RegisterWellKnownClientType( MyServerImpl::typeid, "tcp://localhost:8085/SayHello" ); - - // - MyServerImpl ^ myObject = gcnew MyServerImpl; - - // Get the assembly for the 'MyServerImpl' object. - Assembly^ myAssembly = Assembly::GetAssembly( MyServerImpl::typeid ); - AssemblyName^ myName = myAssembly->GetName(); - - // Check whether the specified object type is registered as - // well-known client type. - WellKnownClientTypeEntry^ myWellKnownClientType = RemotingConfiguration::IsWellKnownClientType( MyServerImpl::typeid->FullName, myName->Name ); - Console::WriteLine( "The Object type :{0}", myWellKnownClientType->ObjectType ); - Console::WriteLine( "The Object Uri :{0}", myWellKnownClientType->ObjectUrl ); - // - Console::WriteLine( myObject->MyMethod( "Remote method is called." ) ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices IsObject Snippets/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices IsObject Snippets/CPP/class1.cpp deleted file mode 100644 index d1b75b89c64dd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices IsObject Snippets/CPP/class1.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Runtime::Remoting; - -namespace TempConverter -{ - public ref class Converter: public MarshalByRefObject{}; - -} - -ref class Client -{ -public: - void RunSnippet() - { - // - // Create a remote version of TempConverter::Converter. - TempConverter::Converter^ converter1 = - dynamic_cast(Activator::GetObject( - TempConverter::Converter::typeid, - "http://localhost:8085/TempConverter" )); - - // Create a local version of TempConverter::Converter. - TempConverter::Converter^ converter2 = gcnew TempConverter::Converter; - - // Returns true, converter1 is remote and in a different appdomain. - System::Runtime::Remoting::RemotingServices::IsObjectOutOfAppDomain( converter1 ); - - // Returns false, converter2 is local and running in this appdomain. - System::Runtime::Remoting::RemotingServices::IsObjectOutOfAppDomain( converter2 ); - - // Returns true, converter1 is remote and in a different context. - System::Runtime::Remoting::RemotingServices::IsObjectOutOfContext( converter1 ); - - // Returns false, converter2 is local and running in this context. - System::Runtime::Remoting::RemotingServices::IsObjectOutOfContext( converter2 ); - // - - // Print those function calls. - System::Console::WriteLine( " {0}", RemotingServices::IsObjectOutOfAppDomain( converter1 ) ); - System::Console::WriteLine( " {0}", RemotingServices::IsObjectOutOfAppDomain( converter2 ) ); - System::Console::WriteLine( " {0}", RemotingServices::IsObjectOutOfContext( converter1 ) ); - System::Console::WriteLine( " {0}", RemotingServices::IsObjectOutOfContext( converter2 ) ); - } -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - Client^ client = gcnew Client; - client->RunSnippet(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/basicclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/basicclient.cpp deleted file mode 100644 index 0bfe3822e7412..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/basicclient.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace SampleNamespace; -using namespace System::Security::Permissions; - -public ref class SampleClient -{ -private: - static const String^ SERVER_URL = "http://localhost:9000/MySampleService/SampleWellKnown.soap"; - -public: - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::RemotingConfiguration)] - static void Snippet1() - { - // - Console::WriteLine( "Connecting to SampleNamespace::SampleWellKnown." ); - SampleWellKnown ^ proxy = dynamic_cast(RemotingServices::Connect( SampleWellKnown::typeid, const_cast(SERVER_URL) )); - Console::WriteLine( "Connected to SampleWellKnown" ); - - // Verifies that the Object* reference is to a transparent proxy. - if ( RemotingServices::IsTransparentProxy( proxy ) ) - Console::WriteLine( "proxy is a reference to a transparent proxy." ); - else - Console::WriteLine( "proxy is not a transparent proxy. This is unexpected." ); - - // Calls a method on the server Object*. - Console::WriteLine( "proxy->Add returned {0}.", proxy->Add( 2, 3 ) ); - // - } - -}; - -int main() -{ - SampleClient::Snippet1(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/basicserver.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/basicserver.cpp deleted file mode 100644 index 52e699a41001d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/basicserver.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Threading; -using namespace SampleNamespace; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ serverConfigFile = "basicserver.exe.config"; - if ( (args->Length > 2) && (args[ 1 ]->ToLower()->Equals( "/c" ) | args[ 1 ]->ToLower()->Equals( "-c" )) ) - { - serverConfigFile = args[ 2 ]; - } - - RemotingConfiguration::Configure( "channels.config" ); - RemotingConfiguration::Configure( serverConfigFile ); - Console::WriteLine( "Listening..." ); - String^ keyState = ""; - while ( String::Compare( keyState, "0", true ) != 0 ) - { - Console::WriteLine( "***** Press 0 to exit this service *****" ); - keyState = Console::ReadLine(); - } - - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/makefile deleted file mode 100644 index fd15841afe743..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/makefile +++ /dev/null @@ -1,17 +0,0 @@ - -all: basicserver.exe basicclient.exe manualserver.exe manualclient.exe - -basicserver.exe: basicserver.cpp service.dll - cl /clr:pure basicserver.cpp - -basicclient.exe: basicclient.cpp service.dll - cl /clr:pure basicclient.cpp - -manualserver.exe: manualserver.cpp service.dll - cl /clr:pure manualserver.cpp - -manualclient.exe: manualclient.cpp service.dll - cl /clr:pure manualclient.cpp - -service.dll: service.cpp - cl /clr:pure /LD service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/manualclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/manualclient.cpp deleted file mode 100644 index 93b01ca8cceaf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/manualclient.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace SampleNamespace; - -// Note: this snippet is based on v-ralphs' Dynamic Remoting sample. -int main() -{ - // System::Runtime::Remoting::RemotingServices.Disconnect() -- ManualServer::cs has a snippet for Disconnect, too. - - // - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( SampleWellKnown::typeid,"tcp://localhost:9000/objectWellKnownUri" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - SampleWellKnown^ objectWellKnown = gcnew SampleWellKnown; - try - { - objectWellKnown->Add( 2, 3 ); - Console::WriteLine( "The add method on SampleWellKnown was successfully called." ); - } - catch ( SocketException^ ) - { - Console::WriteLine( "The server is not available. Is it still running?" ); - } - catch ( RemotingException^ ) - { - Console::WriteLine( "SampleWellKnown is currently not available. The server probably called Disconnect()." ); - } - // - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/manualserver.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/manualserver.cpp deleted file mode 100644 index d526055447af6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/manualserver.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace SampleNamespace; - -// Note: this snippet is based on v-ralphs' Dynamic Remoting sample. -int main() -{ - // - TcpChannel^ channel = gcnew TcpChannel( 9000 ); - ChannelServices::RegisterChannel( channel ); - SampleWellKnown ^ objectWellKnown = gcnew SampleWellKnown; - - // After the channel is registered, the Object* needs to be registered - // with the remoting infrastructure. So, Marshal is called. - ObjRef^ objrefWellKnown = RemotingServices::Marshal( objectWellKnown, "objectWellKnownUri" ); - Console::WriteLine( "An instance of SampleWellKnown type is published at {0}.", objrefWellKnown->URI ); - Console::WriteLine( "Press enter to unregister SampleWellKnown, so that it is no longer available on this channel." ); - Console::ReadLine(); - RemotingServices::Disconnect( objectWellKnown ); - Console::WriteLine( "Press enter to end the server process." ); - Console::ReadLine(); - // - - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/service.cpp deleted file mode 100644 index 05a59c3feab28..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.BasicSample/CPP/service.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Runtime::Remoting; - -namespace SampleNamespace -{ - public ref class SampleWellKnown: public MarshalByRefObject - { - public: - int State; - int Add( int a, int b ) - { - Console::WriteLine( "Add method called" ); - return a + b; - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/client.cpp deleted file mode 100644 index 366f610432aa1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/client.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using -#using -#using "serviceclass.dll" - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Reflection; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel ); - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( SampleService::typeid,"tcp://localhost:9000/SampleServiceUri" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - SampleService^ service = gcnew SampleService; - Console::WriteLine( "Connected to SampleService" ); - service->UpdateServer( 3, 3.14, "Pi" ); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/makefile deleted file mode 100644 index 2c14cfc29ce0b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/makefile +++ /dev/null @@ -1,12 +0,0 @@ -all : server.exe client.exe - - -server.exe : server.cpp serviceclass.dll - cl /clr:pure server.cpp - -client.exe : client.cpp serviceclass.dll - cl /clr:pure client.cpp - -serviceclass.dll : serviceclass.cpp - cl /clr:pure /LD serviceclass.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/server.cpp deleted file mode 100644 index dbbe1ba79ecbc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/server.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -#using -#using -#using "serviceclass.dll" - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Contexts; -int main() -{ - array^args = Environment::GetCommandLineArgs(); - TcpChannel^ channel; - bool isReplicationServer = false; - - // Determine if this should be the replication server - if ( (args->Length > 1) && (args[ 1 ]->ToLower()->Equals( "r" )) ) - { - isReplicationServer = true; - channel = gcnew TcpChannel( 9001 ); - } - else - { - channel = gcnew TcpChannel( 9000 ); - } - - ChannelServices::RegisterChannel( channel ); - WellKnownServiceTypeEntry^ entry = gcnew WellKnownServiceTypeEntry( SampleService::typeid,"SampleServiceUri",WellKnownObjectMode::Singleton ); - RemotingConfiguration::RegisterWellKnownServiceType( entry ); - if ( !isReplicationServer ) - { - ReplicationSinkProp ^ myProp = gcnew ReplicationSinkProp; - Context::RegisterDynamicProperty( myProp, nullptr, nullptr ); - } - - Console::WriteLine( "**** Press enter to stop this process. ****\n" ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/serviceclass.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/serviceclass.cpp deleted file mode 100644 index 79aaac386f2a0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.ExecuteMessage/CPP/serviceclass.cpp +++ /dev/null @@ -1,153 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Diagnostics; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Contexts; -using namespace System::Runtime::Remoting::Channels; - -public ref class SampleService: public ContextBoundObject -{ -public: - bool UpdateServer( int i, double d, String^ s ) - { - Console::WriteLine( "SampleService::UpdateServer called: {0}, {1}, {2}", i, d, s ); - return true; - } - -}; - -public ref class ReplicationSink: public IDynamicMessageSink -{ -private: - static const String^ replicatedServiceUri = "/SampleServiceUri"; - static const String^ replicationServerUrl = "tcp://localhost:9001"; - -public: - - // System::Runtime::Remoting::RemotingServices.ExecuteMessage - // System::Runtime::Remoting::RemotingServices.GetSessionIdForMethodMessage - // - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void ProcessMessageStart( IMessage^ requestMessage, bool /*bClientSide*/, bool /*bAsyncCall*/ ) - { - Console::WriteLine( "\nProcessMessageStart" ); - Console::WriteLine( "requestMessage = {0}", requestMessage ); - try - { - Console::WriteLine( "SessionId = {0}.", RemotingServices::GetSessionIdForMethodMessage( dynamic_cast(requestMessage) ) ); - } - catch ( InvalidCastException^ ) - { - Console::WriteLine( "The requestMessage is not an IMethodMessage*." ); - } - - IMethodCallMessage^ requestMethodCallMessage; - try - { - requestMethodCallMessage = dynamic_cast(requestMessage); - - // Prints the details of the IMethodCallMessage* to the console. - Console::WriteLine( "\nMethodCall details" ); - Console::WriteLine( "Uri = {0}", requestMethodCallMessage->Uri ); - Console::WriteLine( "TypeName = {0}", requestMethodCallMessage->TypeName ); - Console::WriteLine( "MethodName = {0}", requestMethodCallMessage->MethodName ); - Console::WriteLine( "ArgCount = {0}", requestMethodCallMessage->ArgCount ); - Console::WriteLine( "MethodCall::Args" ); - IEnumerator^ myEnum = requestMethodCallMessage->Args->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::WriteLine( "\t {0}", o ); - - // Sends this method call message to another server to replicate - // the call at the second server. - if ( requestMethodCallMessage->Uri == replicatedServiceUri ) - { - String^ repSvr = String::Format( "{0}{1}", const_cast(replicationServerUrl), const_cast(replicatedServiceUri) ); - SampleService^ replicationService = dynamic_cast(Activator::GetObject( SampleService::typeid, repSvr )); - IMethodReturnMessage^ returnMessage = RemotingServices::ExecuteMessage( replicationService, requestMethodCallMessage ); - - // Prints the results of the method call stored in the IMethodReturnMessage*. - Console::WriteLine( "\nMessage returned by ExecuteMessage." ); - Console::WriteLine( "\tException = {0}", returnMessage->Exception ); - Console::WriteLine( "\tReturnValue = {0}", returnMessage->ReturnValue ); - Console::WriteLine( "\tOutArgCount = {0}", returnMessage->OutArgCount ); - Console::WriteLine( "Return message OutArgs" ); - IEnumerator^ myEnum = requestMethodCallMessage->Args->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::WriteLine( "\t {0}", o ); - } - } - } - } - catch ( InvalidCastException^ ) - { - Console::WriteLine( "The requestMessage is not a MethodCall" ); - } - } - // - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void ProcessMessageFinish( IMessage^ requestMessage, bool /*bClientSide*/, bool /*bAsyncCall*/ ) - { - Console::WriteLine( "\nProcessMessageFinish" ); - Console::WriteLine( "requestMessage = {0}", requestMessage ); - ReturnMessage^ requestMethodReturn; - try - { - requestMethodReturn = static_cast(requestMessage); - - // Print the details of the ReturnMessage to the console - Console::WriteLine( "\nReturnMessage details" ); - Console::WriteLine( "\tException = {0}", requestMethodReturn->Exception ); - Console::WriteLine( "\tReturnValue = {0}", requestMethodReturn->ReturnValue ); - Console::WriteLine( "\tOutArgCount = {0}", requestMethodReturn->OutArgCount ); - Console::WriteLine( "Return message OutArgs" ); - IEnumerator^ myEnum = requestMethodReturn->Args->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::WriteLine( "\t {0}", o ); - } - } - catch ( InvalidCastException^ ) - { - Console::WriteLine( "The requestMessage is not a ReturnMessage." ); - } - } -}; - -public ref class ReplicationSinkProp: public IDynamicProperty, public IContributeDynamicSink -{ -public: - - property String^ Name - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual String^ get() - { - return "ReplicationSinkProp"; - } - } - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual IDynamicMessageSink^ GetDynamicSink() - { - return gcnew ReplicationSink; - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/client.cpp deleted file mode 100644 index b8502b5c48bf4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/client.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -#using -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Collections; -using namespace SampleNamespace; - -int main() -{ - ChannelServices::RegisterChannel( gcnew HttpChannel( 0 ), false ); - RemotingConfiguration::RegisterActivatedClientType( SampleService::typeid, "http://localhost:9000/MySampleService" ); - SampleService ^ myRemoteObject = gcnew SampleService; - bool result = myRemoteObject->SampleMethod(); - - // System::Runtime::Remoting::RemotingServices.GetObjRefForProxy - // - ObjRef^ objRefSample = RemotingServices::GetObjRefForProxy( myRemoteObject ); - Console::WriteLine( "***ObjRef Details***" ); - Console::WriteLine( "URI:\t {0}", objRefSample->URI ); - array^channelData = objRefSample->ChannelInfo->ChannelData; - Console::WriteLine( "Channel Info:" ); - IEnumerator^ myEnum = channelData->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::WriteLine( "\t {0}", o ); - } - - IEnvoyInfo^ envoyInfo = objRefSample->EnvoyInfo; - if ( envoyInfo == nullptr ) - { - Console::WriteLine( "This ObjRef does not have envoy information." ); - } - else - { - IMessageSink^ envoySinks = envoyInfo->EnvoySinks; - Console::WriteLine( "Envoy Sink Class: {0}", envoySinks ); - } - - IRemotingTypeInfo^ typeInfo = objRefSample->TypeInfo; - Console::WriteLine( "Remote type name: {0}", typeInfo->TypeName ); - Console::WriteLine( "Can my Object* cast to a Bitmap? {0}", typeInfo->CanCastTo( System::Drawing::Bitmap::typeid, objRefSample ) ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/makefile deleted file mode 100644 index af9980200399f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all: service.dll server.exe client.exe - -service.dll : service.cs - csc /t:library service.cs - -server.exe : server.cpp service.dll - cl /clr:pure server.cpp - -client.exe : client.cpp service.dll - cl /clr:pure client.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/server.cpp deleted file mode 100644 index 7c0c3498a56e2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/server.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; -using namespace SampleNamespace; - -int main() -{ - HttpChannel^ channel = gcnew HttpChannel( 9000 ); - ChannelServices::RegisterChannel( channel, false ); - RemotingConfiguration::ApplicationName = "MySampleService"; - RemotingConfiguration::RegisterActivatedServiceType( SampleService::typeid ); - Console::WriteLine( "Press enter to end the server process." ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/service.cs b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/service.cs deleted file mode 100644 index aede08cfc26bc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.GetObjRefForProxy/CPP/service.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; -using System.Runtime.Remoting.Channels.Http; -using System.Runtime.Remoting.Lifetime; - -namespace SampleNamespace { - // Define the remote service class - public class SampleService : MarshalByRefObject { - public bool SampleMethod() { - Console.WriteLine("Hello, you have called SampleMethod()."); - return true; - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/makefile deleted file mode 100644 index c35829a2adeef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: timerserver.exe timerclient.exe - -timerserver.exe: timerserver.cpp timerservice.dll - cl /clr:pure timerserver.cpp - -timerclient.exe: timerclient.cpp timerservice.dll - cl /clr:pure timerclient.cpp - -timerservice.dll: timerservice.cpp - cl /clr:pure /LD timerservice.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerclient.cpp deleted file mode 100644 index 590b94dffc718..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerclient.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// System::Runtime::Remoting::RemotingServices.GetLifetimeService -// This sample is of a remote client for a group coffee timer. -// Since the client must stay connected to a stateful server object -// for minutes without calling it, it needs to register as a sponsor -// of the lease to prevent the server from being collected. -// Multiple clients can connect to the same timer object, and receive -// notification when the timer expires. -// System::Runtime::Remoting::RemotingServices.GetLifetimeService -// -#using -#using -#using "timerservice.dll" - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Lifetime; -using namespace TimerSample; -using namespace System::Security::Permissions; - -namespace GroupCoffeeTimer -{ - public ref class TimerClient: public MarshalByRefObject, public ISponsor - { - public: - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - TimerClient() - { - // Registers the HTTP Channel so that this client can receive - // events from the remote service. - ChannelServices::RegisterChannel( gcnew HttpChannel( 0 ), false ); - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( TimerService::typeid,"http://localhost:9000/MyService/TimerService.soap" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - TimerService^ groupTimer = gcnew TimerService; - groupTimer->MinutesToTime = 4.0; - - // Registers this client as a lease sponsor so that it can - // prevent the expiration of the TimerService. - ILease^ leaseObject = dynamic_cast(RemotingServices::GetLifetimeService( groupTimer )); - leaseObject->Register( this ); - - // Subscribes to the event so that the client can receive notifications from the server. - groupTimer->TimerExpired += gcnew TimerExpiredEventHandler( this, &TimerClient::OnTimerExpired ); - Console::WriteLine( "Connected to TimerExpired event" ); - groupTimer->Start(); - Console::WriteLine( "Timer started for {0} minutes.", groupTimer->MinutesToTime ); - Console::WriteLine( "Press enter to end the client process." ); - Console::ReadLine(); - } - - private: - void OnTimerExpired( Object^, TimerServiceEventArgs^ e ) - { - Console::WriteLine( "TimerHelper::OnTimerExpired: {0}", e->Message ); - } - public: - [System::Security::Permissions::PermissionSet(System::Security:: - Permissions::SecurityAction::Demand, Name = "FullTrust")] - virtual TimeSpan Renewal( ILease^ ) - { - Console::WriteLine( "TimerClient: Renewal called." ); - return TimeSpan::FromMinutes( 0.5 ); - } - }; -} - -int main() -{ - using namespace GroupCoffeeTimer; - gcnew TimerClient; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerserver.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerserver.cpp deleted file mode 100644 index a1dfd6cd549c1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerserver.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -#using -#using "timerservice.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Timers; -using namespace TimerSample; - -int main() -{ - HttpChannel^ channel = gcnew HttpChannel( 9000 ); - ChannelServices::RegisterChannel( channel, false ); - RemotingConfiguration::RegisterWellKnownServiceType( TimerService::typeid, "MyService/TimerService.soap", WellKnownObjectMode::Singleton ); - Console::WriteLine( "Press enter to end the server process." ); - Console::ReadLine(); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerservice.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerservice.cpp deleted file mode 100644 index b57341a1d8734..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.TimerSample/CPP/timerservice.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Timers; - -namespace TimerSample -{ - // Define the event arguments - - [Serializable] - public ref class TimerServiceEventArgs: public EventArgs - { - private: - String^ m_Message; - - public: - TimerServiceEventArgs( String^ message ) - { - m_Message = message; - } - - property String^ Message - { - String^ get() - { - return m_Message; - } - } - }; - - public delegate void TimerExpiredEventHandler( // Define the delegate for the event - Object^ sender, TimerServiceEventArgs^ e ); - - // Define the remote service class - public ref class TimerService: public MarshalByRefObject - { - private: - double m_MinutesToTime; - Timer^ m_Timer; - - public: - event TimerExpiredEventHandler^ TimerExpired; - - // The client will subscribe and unsubscribe to this event - // Default: Initialize the TimerService to 4 minutes, the time required - // to brew coffee in a French Press. - TimerService() - { - Console::WriteLine( "TimerService instantiated." ); - m_MinutesToTime = 4.0; - m_Timer = gcnew Timer; - m_Timer->Elapsed += gcnew ElapsedEventHandler( this, &TimerService::OnElapsed ); - } - - TimerService( double minutes ) - { - Console::WriteLine( "TimerService instantiated." ); - m_MinutesToTime = minutes; - m_Timer = gcnew Timer; - m_Timer->Elapsed += gcnew ElapsedEventHandler( this, &TimerService::OnElapsed ); - } - - property double MinutesToTime - { - double get() - { - return m_MinutesToTime; - } - - void set( double value ) - { - m_MinutesToTime = value; - } - - } - void Start() - { - if ( !m_Timer->Enabled ) - { - TimeSpan interval = TimeSpan::FromMinutes( m_MinutesToTime ); - m_Timer->Interval = interval.TotalMilliseconds; - m_Timer->Enabled = true; - } - else - { - // TODO: Raise an exception - } - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual Object^ InitializeLifetimeService() override - { - ILease^ lease = dynamic_cast(MarshalByRefObject::InitializeLifetimeService()); - if ( lease->CurrentState == LeaseState::Initial ) - { - lease->InitialLeaseTime = TimeSpan::FromMinutes( 0.125 ); - lease->SponsorshipTimeout = TimeSpan::FromMinutes( 2 ); - lease->RenewOnCallTime = TimeSpan::FromSeconds( 2 ); - Console::WriteLine( "TimerService: InitializeLifetimeService" ); - } - - return lease; - } - private: - void OnElapsed( Object^ source, ElapsedEventArgs^ e ) - { - m_Timer->Enabled = false; - - // Fire Event - // Package String in TimerServiceEventArgs - TimerServiceEventArgs^ timerEventArgs = gcnew TimerServiceEventArgs( "TimerServiceEventArgs: Timer Expired." ); - Console::WriteLine( "Firing TimerExpired Event" ); - TimerExpired( this, timerEventArgs ); - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/client.cpp deleted file mode 100644 index d7f3d4b569d39..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/client.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// System::Runtime::Remoting::RemotingServices.GetLifetimeService -// This sample is of a remote client for a group coffee timer. -// Since the client must stay connected to a stateful server Object* -// for minutes with->Item[Out] calling* it, it needs to register as a sponsor -// of the lease to prevent the server from being collected. -// Multiple clients can connect to the same timer Object*, and receive -// notification when the timer expires. - -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Lifetime; -using namespace SampleNamespace; - -int main() -{ - // System::Runtime::Remoting::RemotingServices.Unmarshal - // - ChannelServices::RegisterChannel( gcnew HttpChannel ); - - SampleService ^ objectSample = (SampleService^)( Activator::GetObject( SampleService::typeid, - "http://localhost:9000/MySampleService/SampleService.soap" ) ); - - // The GetManuallyMarshaledObject() method uses RemotingServices::Marshal() - // to create an ObjRef object for a SampleTwo object. - ObjRef^ objRefSampleTwo = objectSample->GetManuallyMarshaledObject(); - - SampleTwo ^ objectSampleTwo = (SampleTwo^)( RemotingServices::Unmarshal( objRefSampleTwo ) ); - - objectSampleTwo->PrintMessage( "ObjRef successfuly unmarshaled." ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/makefile deleted file mode 100644 index a804d9e3e10e2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all : server.exe client.exe - -server.exe : server.cpp service.dll - cl /clr:pure server.cpp - -client.exe : client.cpp service.dll - cl /clr:pure client.cpp - -service.dll : service.cpp - cl /LD /clr:pure service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/server.cpp deleted file mode 100644 index 3f715d0fa45cb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/server.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; -using namespace SampleNamespace; - -int main() -{ - // System::Runtime::Remoting::RemotingServices.SetObjectUriForMarshal - // - RemotingConfiguration::ApplicationName = "MySampleService"; - HttpChannel^ channel = gcnew HttpChannel( 9000 ); - ChannelServices::RegisterChannel( channel ); - SampleService^ objectService = gcnew SampleService; - RemotingServices::SetObjectUriForMarshal( objectService, "SampleService.soap" ); - RemotingServices::Marshal( objectService ); - - Console::WriteLine( "Press enter to end the server process." ); - Console::ReadLine(); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/service.cpp deleted file mode 100644 index 0872b8161fdaf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/RemotingServices.Unmarshal/CPP/service.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; - -namespace SampleNamespace -{ - public ref class SampleTwo: public MarshalByRefObject - { - public: - void PrintMessage( String^ s ) - { - Console::WriteLine( "This message was received from the client:" ); - Console::WriteLine( "\t {0}", s ); - } - }; - - // Define the remote service class - public ref class SampleService: public MarshalByRefObject - { - public: - bool SampleMethod() - { - Console::WriteLine( "Hello, you have called SampleMethod()." ); - return true; - } - - ObjRef^ GetManuallyMarshaledObject() - { - SampleTwo^ objectTwo = gcnew SampleTwo; - ObjRef^ objRefTwo = RemotingServices::Marshal( objectTwo ); - return objRefTwo; - } - }; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/client.cpp deleted file mode 100644 index a25a8b273ca34..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/client.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; - -public ref class Client -{ -public: - void ClientTest() - { - // - IpcClientChannel^ clientChannel = gcnew IpcClientChannel; - ChannelServices::RegisterChannel( clientChannel ); - // - - RemotingConfiguration::RegisterWellKnownClientType( Counter::typeid, L"ipc://remote/counter" ); - Counter^ counter = gcnew Counter; - Console::WriteLine( L"This is call number {0}.", counter->Count ); - } -}; - -int main() -{ - Client^ c = gcnew Client; - c->ClientTest(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/counter.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/counter.cpp deleted file mode 100644 index 57f389d01b4b3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/counter.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// Counter.cs -// -using namespace System; -public ref class Counter: public MarshalByRefObject -{ -private: - int count; - -public: - Counter() - { - count = 0; - } - - property int Count - { - int get() - { - return (count)++; - } - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/makefile deleted file mode 100644 index aca530f08d7ba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: Counter.dll Client.exe Server.exe - -Counter.dll: Counter.cpp - cl /clr:pure /LD Counter.cpp - -Server.exe: Server.cpp - cl /clr:pure Server.cpp - -Client.exe: Client.cpp - cl /clr:pure Client.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/server.cpp deleted file mode 100644 index 3e9a5712ad176..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Ipc/CPP/server.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; - -public ref class IpcServer -{ -public: - void IpcServerTest() - { - // - // Create and register an IPC channel - IpcServerChannel^ serverChannel = gcnew IpcServerChannel( L"remote" ); - ChannelServices::RegisterChannel( serverChannel ); - // - - // Expose an object - RemotingConfiguration::RegisterWellKnownServiceType( Counter::typeid, L"counter", WellKnownObjectMode::Singleton ); - - // Wait for calls - // - Console::WriteLine( L"Listening on {0}", serverChannel->GetChannelUri() ); - // - - Console::ReadLine(); - } -}; - -int main() -{ - IpcServer^ is = gcnew IpcServer; - is->IpcServerTest(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/client.cpp deleted file mode 100644 index 99ac0db930000..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/client.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Runtime::Remoting; - -int main() -{ - // Set up a remoting client. - RemotingConfiguration::Configure( "Client.config" ); - - // Call a method on a remote object. - Remotable ^ remoteObject = gcnew Remotable; - Console::WriteLine( remoteObject->GetCount() ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/clientsink.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/clientsink.cpp deleted file mode 100644 index 849a76f616ef7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/clientsink.cpp +++ /dev/null @@ -1,142 +0,0 @@ - -// -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; - -[System::Security::Permissions::PermissionSet(System::Security:: - Permissions::SecurityAction::Demand, Name = "FullTrust")] -public ref class ClientSink: public BaseChannelSinkWithProperties, public IClientChannelSink -{ -private: - - // This class inherits from BaseChannelSinkWithPropertes - // to get an implementation of IChannelSinkBase. - // - // The next sink in the chain. - IClientChannelSink^ nextSink; - // - - - // -public: - property IClientChannelSink^ NextChannelSink - { - virtual IClientChannelSink^ get() - { - return (nextSink); - } - } - // - - // - virtual Stream^ GetRequestStream( IMessage^ message, ITransportHeaders^ requestHeaders ) - { - // Get the request stream from the next sink in the chain. - return (nextSink->GetRequestStream( message, requestHeaders )); - } - // - - // - virtual void ProcessMessage( IMessage^ message, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) - { - // Print the request message properties. - Console::WriteLine( "---- Message from the client ----" ); - IDictionary^ dictionary = message->Properties; - IEnumerator^ myEnum = dictionary->Keys->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ key = safe_cast(myEnum->Current); - Console::WriteLine( "{0} = {1}", key, dictionary[ key ] ); - } - - Console::WriteLine( "---------------------------------" ); - - // Hand off to the next sink in the chain. - nextSink->ProcessMessage( message, requestHeaders, requestStream, responseHeaders, responseStream ); - } - // - - // - // For synchronous remoting, it is not necessary to implement this method. - virtual void AsyncProcessRequest( IClientChannelSinkStack^ /*sinkStack*/, IMessage^ /*message*/, ITransportHeaders^ /*requestHeaders*/, Stream^ /*requestStream*/ ) - { - throw gcnew NotImplementedException; - } - // - - // - virtual void AsyncProcessResponse( IClientResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, ITransportHeaders^ /*responseHeaders*/, Stream^ /*responseStream*/ ) - { - throw gcnew NotImplementedException; - } - - // - property System::Collections::IDictionary^ Properties - { - virtual System::Collections::IDictionary^ get() override - { - return (dynamic_cast(this))->Properties; - } - } - - // Constructor - ClientSink( IClientChannelSink^ sink ) - { - if ( sink == nullptr ) - throw gcnew ArgumentNullException( "sink" ); - - nextSink = sink; - } -}; -// - -// -[System::Security::Permissions::PermissionSet(System::Security:: - Permissions::SecurityAction::Demand, Name = "FullTrust")] -public ref class ClientSinkProvider: public IClientChannelSinkProvider -{ -private: - - // - // The next provider in the chain. - IClientChannelSinkProvider^ nextProvider; - // - - // -public: - property IClientChannelSinkProvider^ Next - { - virtual IClientChannelSinkProvider^ get() - { - return (nextProvider); - } - - virtual void set( IClientChannelSinkProvider^ value ) - { - nextProvider = value; - } - } - // - - // - virtual IClientChannelSink^ CreateSink( IChannelSender^ channel, String^ url, Object^ remoteChannelData ) - { - Console::WriteLine( "Creating ClientSink for {0}", url ); - - // Create the next sink in the chain. - IClientChannelSink^ nextSink = nextProvider->CreateSink( channel, url, remoteChannelData ); - - // Hook our sink up to it. - return (gcnew ClientSink( nextSink )); - } - // - - // This constructor is required in order to use the provider in file-based configuration. - // It need not do anything unless you want to use the information in the parameters. - ClientSinkProvider( IDictionary^ /*properties*/, ICollection^ /*providerData*/ ){} -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/makefile deleted file mode 100644 index c1426b57e8dd0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/makefile +++ /dev/null @@ -1,12 +0,0 @@ -# Comment here -all: Server.exe Client.exe -Remotable.dll: Remotable.cpp - cl /clr:pure /LD Remotable.cpp -ServerSink.dll: ServerSink.cpp - cl /clr:pure /LD ServerSink.cpp -Server.exe: Server.cpp Remotable.dll ServerSink.dll - cl /clr:pure Server.cpp -ClientSink.dll: ClientSink.cpp - cl /clr:pure /LD ClientSink.cpp -Client.exe: Client.cpp ClientSink.dll Remotable.dll - cl /clr:pure Client.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/remotable.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/remotable.cpp deleted file mode 100644 index adbb36ff4042d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/remotable.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::Remoting; - -public ref class Remotable: public MarshalByRefObject -{ -private: - int callCount; - -public: - Remotable() - : callCount( 0 ) - {} - - int GetCount() - { - callCount++; - return (callCount); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/server.cpp deleted file mode 100644 index 7163b96de7faa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/server.cpp +++ /dev/null @@ -1,15 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::Remoting; - -int main() -{ - // Set up a remoting server. - RemotingConfiguration::Configure( "Server.config" ); - - // Wait for method calls. - Console::WriteLine( "Listening..." ); - Console::ReadLine(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/serversink.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/serversink.cpp deleted file mode 100644 index 93da1a676ea0a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_Sinks/CPP/serversink.cpp +++ /dev/null @@ -1,137 +0,0 @@ - -// -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; - -[System::Security::Permissions::PermissionSet(System::Security:: - Permissions::SecurityAction::Demand, Name = "FullTrust")] -public ref class ServerSink: public BaseChannelSinkWithProperties, public IServerChannelSink -{ -private: - - // This class inherits from BaseChannelSinkWithPropertes - // to get an implementation of IChannelSinkBase. - // - // The next sink in the chain. - IServerChannelSink^ nextSink; - // - - // -public: - property IServerChannelSink^ NextChannelSink - { - virtual IServerChannelSink^ get() - { - return (nextSink); - } - } - // - - // - virtual Stream^ GetResponseStream( IServerResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, IMessage^ /*message*/, ITransportHeaders^ /*responseHeaders*/ ) - { - return nullptr; - } - // - - // - virtual ServerProcessing ProcessMessage( IServerChannelSinkStack^ sinkStack, IMessage^ requestMessage, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]IMessage^% responseMessage, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) - { - // Hand off to the next sink for processing. - sinkStack->Push( this, nullptr ); - ServerProcessing status = nextSink->ProcessMessage( sinkStack, requestMessage, requestHeaders, requestStream, responseMessage, responseHeaders, responseStream ); - - // Print the response message properties. - Console::WriteLine( "---- Message from the server ----" ); - IDictionary^ dictionary = ( *responseMessage).Properties; - IEnumerator^ myEnum = dictionary->Keys->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ key = safe_cast(myEnum->Current); - Console::WriteLine( "{0} = {1}", key, dictionary[ key ] ); - } - - Console::WriteLine( "---------------------------------" ); - return (status); - } - // - - // - virtual void AsyncProcessResponse( IServerResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, IMessage^ /*message*/, ITransportHeaders^ /*responseHeaders*/, Stream^ /*responseStream*/ ) - { - throw gcnew NotImplementedException; - } - // - - property System::Collections::IDictionary^ Properties - { - virtual System::Collections::IDictionary^ get() override - { - return (dynamic_cast(this))->Properties; - } - } - - // Constructor - ServerSink( IServerChannelSink^ sink ) - { - if ( sink == nullptr ) - throw gcnew ArgumentNullException( "sink" ); - - nextSink = sink; - } -}; -// - -// -[System::Security::Permissions::PermissionSet(System::Security:: - Permissions::SecurityAction::Demand, Name = "FullTrust")] -public ref class ServerSinkProvider: public IServerChannelSinkProvider -{ - // - // The next provider in the chain. -private: - IServerChannelSinkProvider^ nextProvider; - // - - // -public: - property IServerChannelSinkProvider^ Next - { - virtual IServerChannelSinkProvider^ get() - { - return (nextProvider); - } - - virtual void set( IServerChannelSinkProvider^ value ) - { - nextProvider = value; - } - } - // - - // - virtual IServerChannelSink^ CreateSink( IChannelReceiver^ channel ) - { - Console::WriteLine( "Creating ServerSink" ); - - // Create the next sink in the chain. - IServerChannelSink^ nextSink = nextProvider->CreateSink( channel ); - - // Hook our sink up to it. - return (gcnew ServerSink( nextSink )); - } - // - - // - virtual void GetChannelData( IChannelDataStore^ /*channelData*/ ){} - // - - // This constructor is required in order to use the provider in file-based configuration. - // It need not do anything unless you want to use the information in the parameters. - ServerSinkProvider( IDictionary^ /*properties*/, ICollection^ /*providerData*/ ){} -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/client.cpp deleted file mode 100644 index 5b2824ec1ef94..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/client.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - // - // Specify client channel properties. - IDictionary^ dict = gcnew Hashtable; - dict[ "port" ] = 9090; - dict[ "impersonationLevel" ] = "Identify"; - dict[ "authenticationPolicy" ] = "AuthPolicy, Policy"; - - // Set up a client channel. - TcpClientChannel^ clientChannel = gcnew TcpClientChannel( dict, nullptr ); - ChannelServices::RegisterChannel( clientChannel, false ); - // - - // Obtain a proxy for a remote object. - RemotingConfiguration::RegisterWellKnownClientType( Remotable::typeid, "tcp://localhost:9090/Remotable.rem" ); - - // Call a method on the object. - Remotable ^ remoteObject = gcnew Remotable; - Console::WriteLine( remoteObject->GetMessage() ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/makefile deleted file mode 100644 index 641994d912bad..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: Remotable.dll Server.exe Client.exe -Remotable.dll: Remotable.cpp - cl /clr:pure /LD Remotable.cpp -Server.exe: Server.cpp Remotable.dll - cl /clr:pure Server.cpp -Client.exe: Client.cpp Remotable.dll - cl /clr:pure Client.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/remotable.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/remotable.cpp deleted file mode 100644 index 7a3be490f0ba9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/remotable.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Security::Principal; -using namespace System::Text; -using namespace System::Security::Permissions; - -public ref class Remotable: public MarshalByRefObject -{ -public: - - // A method to call remotely. - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - String^ GetMessage() - { - // Create a message. - StringBuilder^ message = gcnew StringBuilder( "call" ); - - // Identity the calling principal. - IIdentity^ remoteIdentity = dynamic_cast(System::Runtime::Remoting::Messaging::CallContext::GetData( "__remotePrincipal" )); - if ( remoteIdentity == nullptr ) - { - message->Append( " by an unknown caller" ); - } - else - { - message->AppendFormat( " by {0}", remoteIdentity->Name ); - } - - - // Identify the executing principal. - IIdentity^ localIdentity = dynamic_cast(WindowsIdentity::GetCurrent()); - message->AppendFormat( " was executed as {0}.", localIdentity->Name ); - - // Return the message. - return (message->ToString()); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/server.cpp deleted file mode 100644 index fc2018f899f7d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpAuth/CPP/server.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - // - // Specify server channel properties. - IDictionary^ dict = gcnew Hashtable; - dict[ "port" ] = 9090; - dict[ "authenticationMode" ] = "IdentifyCallers"; - - // Set up a server channel. - TcpServerChannel^ serverChannel = gcnew TcpServerChannel( dict, nullptr ); - ChannelServices::RegisterChannel( serverChannel, false ); - - // - // Set up a remote object. - RemotingConfiguration::RegisterWellKnownServiceType( Remotable::typeid, "Remotable.rem", WellKnownObjectMode::Singleton ); - - // Wait for method calls. - Console::WriteLine( "Listening..." ); - Console::ReadLine(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/client.cpp deleted file mode 100644 index ced0c327846c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/client.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - - // - // Set up a client channel. - TcpClientChannel^ clientChannel = gcnew TcpClientChannel; - ChannelServices::RegisterChannel( clientChannel ); - - // - // - // Show the name and priority of the channel. - Console::WriteLine( "Channel Name: {0}", clientChannel->ChannelName ); - Console::WriteLine( "Channel Priority: {0}", clientChannel->ChannelPriority ); - - // - // Obtain a proxy for a remote object. - RemotingConfiguration::RegisterWellKnownClientType( Remotable::typeid, "tcp://localhost:9090/Remotable.rem" ); - - // Call a method on the object. - Remotable ^ remoteObject = gcnew Remotable; - Console::WriteLine( remoteObject->GetCount() ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/makefile deleted file mode 100644 index d8e75e869e224..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: Remotable.dll Server.exe Client.exe -Remotable.dll: Remotable.cpp - cl /clr:pure /LD Remotable.cpp -Server.exe: Server.cpp Remotable.dll - cl /clr:pure Server.cpp -Client.exe: Client.cpp Remotable.dll - cl /clr:pure Client.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/remotable.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/remotable.cpp deleted file mode 100644 index 81b3b1ffd8fbf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/remotable.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::Remoting; - -public ref class Remotable: public MarshalByRefObject -{ -private: - int callCount; - -public: - Remotable() - : callCount( 0 ) - {} - - int GetCount() - { - callCount++; - return (callCount); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/server.cpp deleted file mode 100644 index 7688f7f257edd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Remoting_TcpInfo/CPP/server.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - // - // Set up a server channel. - TcpServerChannel^ serverChannel = gcnew TcpServerChannel( 9090 ); - ChannelServices::RegisterChannel( serverChannel ); - // - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( Remotable::typeid, "Remotable.rem", WellKnownObjectMode::Singleton ); - - // - // Show the name and priority of the channel. - Console::WriteLine( "Channel Name: {0}", serverChannel->ChannelName ); - Console::WriteLine( "Channel Priority: {0}", serverChannel->ChannelPriority ); - // - - // - // Show the URIs associated with the channel. - ChannelDataStore^ data = dynamic_cast(serverChannel->ChannelData); - System::Collections::IEnumerator^ myEnum = data->ChannelUris->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ uri = safe_cast(myEnum->Current); - Console::WriteLine( uri ); - } - // - - // Wait for method calls. - Console::WriteLine( "Listening..." ); - Console::ReadLine(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SchemaReference/CPP/schemareference.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SchemaReference/CPP/schemareference.cpp deleted file mode 100644 index 56b4a19308eae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SchemaReference/CPP/schemareference.cpp +++ /dev/null @@ -1,83 +0,0 @@ - - -// System::Web::Services::Discovery.SchemaReference::SchemaReference() -// System::Web::Services::Discovery.SchemaReference::SchemaReference(String*) -// System::Web::Services::Discovery.SchemaReference::SchemaReference.DefaultFileName -// System::Web::Services::Discovery.SchemaReference::SchemaReference.Namespace -// System::Web::Services::Discovery.SchemaReference::SchemaReference.ReadDocument(stream) -// System::Web::Services::Discovery.SchemaReference::SchemaReference.Schema -// System::Web::Services::Discovery.SchemaReference::SchemaReference.Ref -// System::Web::Services::Discovery.SchemaReference::SchemaReference.TargetNamespace -// System::Web::Services::Discovery.SchemaReference::SchemaReference.Url -// System::Web::Services::Discovery.SchemaReference::SchemaReference.WriteDocument(Object*, stream) -// System::Web::Services::Discovery.SchemaReference::SchemaReference -/* This example demonstrates 'SchemaReference' class, its constructors, 'ReadDocument', -* 'WriteDocument', 'Namespace, 'DefaultFileName', 'Schema', 'Ref', 'TargetNamespace', -* and 'Url' members. A variable of type 'SchemaReference' is taken. An xml schema -* document is passed as parameter to overloaded constructor. All the membes are shown -* using 'SchemaReference' variable. -Note : The dataservice.xsd file should be copied to Inetpub\wwwroot -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Web::Services::Discovery; -int main() -{ - try - { - - // - // Reference the schema document. - String^ myStringUrl = "c:\\Inetpub\\wwwroot\\dataservice.xsd"; - XmlSchema^ myXmlSchema; - - // Create the client protocol. - DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol; - myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials; - - // Create a schema reference. - SchemaReference^ mySchemaReferenceNoParam = gcnew SchemaReference; - SchemaReference^ mySchemaReference = gcnew SchemaReference( myStringUrl ); - - // Set the client protocol. - mySchemaReference->ClientProtocol = myDiscoveryClientProtocol; - - // Access the default file name associated with the schema reference. - Console::WriteLine( "Default filename is : {0}", mySchemaReference->DefaultFilename ); - - // Access the namespace associated with schema reference class. - Console::WriteLine( "Namespace is : {0}", SchemaReference::Namespace ); - FileStream^ myStream = gcnew FileStream( myStringUrl,FileMode::OpenOrCreate ); - - // Read the document in a stream. - mySchemaReference->ReadDocument( myStream ); - - // Get the schema of referenced document. - myXmlSchema = mySchemaReference->Schema; - Console::WriteLine( "Reference is : {0}", mySchemaReference->Ref ); - Console::WriteLine( "Target namespace (default empty) is : {0}", mySchemaReference->TargetNamespace ); - Console::WriteLine( "URL is : {0}", mySchemaReference->Url ); - - // Write the document in the stream. - mySchemaReference->WriteDocument( myXmlSchema, myStream ); - myStream->Close(); - mySchemaReference = nullptr; - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp deleted file mode 100644 index 13bca5b2a4375..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -int main() -{ - - //Set up variables and String to write to the server. - Encoding^ ASCII = Encoding::ASCII; - String^ Get = "GET / HTTP/1.1\r\nHost: www.contoso.com" + - "\r\nConnection: Close\r\n\r\n"; - array^ ByteGet = ASCII->GetBytes( Get ); - array^ RecvBytes = gcnew array(256); - String^ strRetPage = nullptr; - - // IPAddress and IPEndPoint represent the endpoint that will - // receive the request. - // Get first IPAddress in list return by DNS. - IPAddress^ hostadd = Dns::GetHostEntry( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ EPhost = gcnew IPEndPoint( hostadd,80 ); - - // - //Creates the Socket for sending data over TCP. - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, - ProtocolType::Tcp ); - - // Connects to host using IPEndPoint. - s->Connect( EPhost ); - if ( !s->Connected ) - { - strRetPage = "Unable to connect to host"; - } - // Use the SelectWrite enumeration to obtain Socket status. - if ( s->Poll( -1, SelectMode::SelectWrite ) ) - { - Console::WriteLine( "This Socket is writable." ); - } - else if ( s->Poll( -1, SelectMode::SelectRead ) ) - { - Console::WriteLine( "This Socket is readable." ); - } - else if ( s->Poll( -1, SelectMode::SelectError ) ) - { - Console::WriteLine( "This Socket has an error." ); - } - // - - // Sent the GET text to the host. - s->Send( ByteGet, ByteGet->Length, SocketFlags::None ); - - // Receives the page, loops until all bytes are received. - Int32 bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage = "Default HTML page on www.contoso.com:\r\n"; - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - - while ( bytes > 0 ) - { - bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp deleted file mode 100644 index 19c0b28945873..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Runtime::Serialization::Formatters::Soap; - -// A test object that needs to be serialized. - -[Serializable] -ref class TestSimpleObject -{ -private: - int member1; - String^ member2; - String^ member3; - double member4; - -public: - - // A field that is not serialized. - - [NonSerialized] - String^ member5; - TestSimpleObject() - { - member1 = 11; - member2 = "hello"; - member3 = "hello"; - member4 = 3.14159265; - member5 = "hello world!"; - } - - void Print() - { - Console::WriteLine( "member1 = ' {0}'", member1 ); - Console::WriteLine( "member2 = ' {0}'", member2 ); - Console::WriteLine( "member3 = ' {0}'", member3 ); - Console::WriteLine( "member4 = ' {0}'", member4 ); - Console::WriteLine( "member5 = ' {0}'", member5 ); - } - -}; - -int main() -{ - // Creates a new TestSimpleObject object. - TestSimpleObject^ obj = gcnew TestSimpleObject; - Console::WriteLine( "Before serialization the Object* contains: " ); - obj->Print(); - - // Opens a file and serializes the object into it in binary format. - Stream^ stream = File::Open( "data.xml", FileMode::Create ); - SoapFormatter^ formatter = gcnew SoapFormatter; - - //BinaryFormatter* formatter = new BinaryFormatter(); - formatter->Serialize( stream, obj ); - stream->Close(); - - // Empties obj. - obj = nullptr; - - // Opens file S"data.xml" and deserializes the object from it. - stream = File::Open( "data.xml", FileMode::Open ); - formatter = gcnew SoapFormatter; - - //formatter = new BinaryFormatter(); - obj = dynamic_cast(formatter->Deserialize( stream )); - stream->Close(); - Console::WriteLine( "" ); - Console::WriteLine( "After deserialization the object contains: " ); - obj->Print(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SerializationBinder Example/CPP/serializationbinder.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SerializationBinder Example/CPP/serializationbinder.cpp deleted file mode 100644 index 0173b3dfbb52f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SerializationBinder Example/CPP/serializationbinder.cpp +++ /dev/null @@ -1,161 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Serialization::Formatters::Binary; -using namespace System::Reflection; -using namespace System::Security::Permissions; -ref class Version1ToVersion2DeserializationBinder; - -[Serializable] -ref class Version1Type -{ -public: - Int32 x; -}; - - -[Serializable] -ref class Version2Type: public ISerializable -{ -public: - Int32 x; - String^ name; - - // The security attribute demands that code that calls - // this method have permission to perform serialization. - - [SecurityPermissionAttribute(SecurityAction::Demand,SerializationFormatter=true)] - virtual void GetObjectData( SerializationInfo^ info, StreamingContext context ) - { - info->AddValue( "x", x ); - info->AddValue( "name", name ); - } - - -private: - - // The security attribute demands that code that calls - // this method have permission to perform serialization. - - [SecurityPermissionAttribute(SecurityAction::Demand,SerializationFormatter=true)] - Version2Type( SerializationInfo^ info, StreamingContext context ) - { - x = info->GetInt32( "x" ); - try - { - name = info->GetString( "name" ); - } - catch ( SerializationException^ ) - { - // The 'name' field was not serialized because Version1Type - // did not contain this field. - // We will set this field to a reasonable default value. - name = "Reasonable default value"; - } - } -}; - -ref class Version1ToVersion2DeserializationBinder sealed: public SerializationBinder -{ -public: - virtual Type^ BindToType( String^ assemblyName, String^ typeName ) override - { - Type^ typeToDeserialize = nullptr; - - // For each assemblyName/typeName that you want to deserialize to - // a different type, set typeToDeserialize to the desired type. - String^ assemVer1 = Assembly::GetExecutingAssembly()->FullName; - String^ typeVer1 = "Version1Type"; - if ( assemblyName->Equals( assemVer1 ) && typeName->Equals( typeVer1 ) ) - { - // To use a type from a different assembly version, - // change the version number using the following line of code. - // assemblyName = assemblyName.Replace("1.0.0.0", "2.0.0.0"); - // To use a different type from the same assembly, - // change the type name. - typeName = "Version2Type"; - } - - // The following line of code returns the type. - typeToDeserialize = Type::GetType( String::Format( "{0}, {1}", typeName, assemblyName ) ); - return typeToDeserialize; - } -}; - -ref class App -{ -public: - static void Serialize() - { - // To serialize the objects, you must first open a stream for writing. - // We will use a file stream here. - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Create ); - try - { - // Construct a BinaryFormatter and use it - // to serialize the data to the stream. - BinaryFormatter^ formatter = gcnew BinaryFormatter; - - // Construct a Version1Type Object and serialize it. - Version1Type^ obj = gcnew Version1Type; - obj->x = 123; - formatter->Serialize( fs, obj ); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to serialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - } - - static void Deserialize() - { - // Declare the Version2Type reference. - Version2Type^ obj = nullptr; - - // Open the file containing the data that we want to deserialize. - FileStream^ fs = gcnew FileStream( "DataFile.dat",FileMode::Open ); - try - { - // Construct a BinaryFormatter and use it - // to deserialize the data from the stream. - BinaryFormatter^ formatter = gcnew BinaryFormatter; - - // Construct an instance of our - // Version1ToVersion2TypeSerialiationBinder type. - // This Binder type knows how to deserialize a Version1Type - // Object* to a Version2Type Object. - formatter->Binder = gcnew Version1ToVersion2DeserializationBinder; - obj = dynamic_cast(formatter->Deserialize( fs )); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to deserialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - - // To prove that a Version2Type Object* was deserialized, - // display the Object's type and fields to the console. - Console::WriteLine( "Type of Object deserialized: {0}", obj->GetType() ); - Console::WriteLine( "x = {0}, name = {1}", obj->x, obj->name ); - } -}; - -[STAThread] -int main() -{ - App::Serialize(); - App::Deserialize(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceClass/CPP/serviceclass.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceClass/CPP/serviceclass.cpp deleted file mode 100644 index 6b5d11452a777..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceClass/CPP/serviceclass.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// System.Web.Services.Description.Service - -/* The following sample demonstrates the class 'Service'.This sample reads the -contents of a file 'MathService_cs.wsdl' into a 'ServiceDescription' instance. -It gets the collection of Service instances from 'ServiceDescription'. It -then removes a 'Service' from the collection and creates a new 'Service' and -adds it into collection. It writes a new web service description file 'MathService_New.wsdl'. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -Port^ CreatePort( String^ PortName, String^ BindingName, String^ targetNamespace ) -{ - Port^ myPort = gcnew Port; - myPort->Name = PortName; - myPort->Binding = gcnew XmlQualifiedName( BindingName,targetNamespace ); - - // Create a SoapAddress extensibility element to add to the port. - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/ServiceClass/MathService_CS.asmx"; - myPort->Extensions->Add( mySoapAddressBinding ); - return myPort; -} - -int main() -{ - try - { - // Read a WSDL document. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); - ServiceCollection^ myServiceCollection = myServiceDescription->Services; - int noOfServices = myServiceCollection->Count; - Console::WriteLine( "\nTotal number of services: {0}", noOfServices ); - - // Gets a reference to the service. - Service^ myOldService = myServiceCollection[ 0 ]; - Console::WriteLine( "No. of ports in the service: {0}", myServiceCollection[ 0 ]->Ports->Count ); - Console::WriteLine( "These are the ports in the service:" ); - for ( int i = 0; i < myOldService->Ports->Count; i++ ) - Console::WriteLine( "Port name: {0}", myOldService->Ports[ i ]->Name ); - Console::WriteLine( "Service name: {0}", myOldService->Name ); - Service^ myService = gcnew Service; - myService->Name = "MathService"; - - // Add the Ports to the newly created Service. - for ( int i = 0; i < myOldService->Ports->Count; i++ ) - { - String^ PortName = myServiceCollection[ 0 ]->Ports[ i ]->Name; - String^ BindingName = myServiceCollection[ 0 ]->Ports[ i ]->Binding->Name; - myService->Ports->Add( CreatePort( PortName, BindingName, myServiceDescription->TargetNamespace ) ); - } - Console::WriteLine( "Newly created ports -" ); - for ( int i = 0; i < myService->Ports->Count; i++ ) - Console::WriteLine( "Port name: {0}", myOldService->Ports[ i ]->Name ); - - // Add the extensions to the newly created Service. - int noOfExtensions = myOldService->Extensions->Count; - Console::WriteLine( "No. of extensions: {0}", noOfExtensions ); - if ( noOfExtensions > 0 ) - { - for ( int i = 0; i < myOldService->Ports->Count; i++ ) - myService->Extensions->Add( myServiceCollection[ 0 ]->Extensions[ i ] ); - } - - // Remove the service from the collection. - myServiceCollection->Remove( myOldService ); - - // Add the newly created service. - myServiceCollection->Add( myService ); - myServiceDescription->Write( "MathService_New.wsdl" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceCollection_CopyTo/CPP/servicecollection_copyto.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceCollection_CopyTo/CPP/servicecollection_copyto.cpp deleted file mode 100644 index 8935936e70fe2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceCollection_CopyTo/CPP/servicecollection_copyto.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// System.Web.Services.Description.ServiceCollection.Contains(Service) -// System.Web.Services.Description.ServiceCollection.IndexOf(service) -// System.Web.Services.Description.ServiceCollection.CopyTo(System[],int) - -/* -The following program demonstrates the methods of -ServiceDescription and ServiceCollection class. An existing WSDL document -is read. An exiting service named "MathService" is removed from the -collection. A new Service object is constructed and added at index 1 of the -Collection .A new WSDL file is created as output. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Text; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - try - { - // Read the Existing Wsdl. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "AddSubtractService_CS.wsdl" ); - - // Remove the service named "MathService". - ServiceCollection^ myServiceDescriptionCollection = myServiceDescription->Services; - myServiceDescriptionCollection->Remove( myServiceDescription->Services[ "MathService" ] ); - - // Build a new Service. - Service^ myService = gcnew Service; - myService->Name = "MathService"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" ); - - // Build a new Port for Soap. - Port^ mySoapPort = gcnew Port; - mySoapPort->Name = "MathServiceSoap"; - mySoapPort->Binding = myXmlQualifiedName; - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/ServiceCollection_CopyTo/AddSubtractService_CS.asmx"; - mySoapPort->Extensions->Add( mySoapAddressBinding ); - - // Build a new Port for HttpGet. - XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:MathServiceHttpGet" ); - Port^ myHttpGetPort = gcnew Port; - myHttpGetPort->Name = "MathServiceHttpGet"; - myHttpGetPort->Binding = myXmlQualifiedName2; - HttpAddressBinding^ myHttpAddressBinding = gcnew HttpAddressBinding; - myHttpAddressBinding->Location = "http://localhost/ServiceCollection_CopyTo/AddSubtractService_CS.asmx"; - myHttpGetPort->Extensions->Add( myHttpAddressBinding ); - - // Build a new Port for HttpPost. - XmlQualifiedName^ myXmlQualifiedName3 = gcnew XmlQualifiedName( "s0:MathServiceHttpPost" ); - - // Build a new Port for Soap. - Port^ myHttpPostPort = gcnew Port; - myHttpPostPort->Name = "MathServiceHttpPost"; - myHttpPostPort->Binding = myXmlQualifiedName3; - HttpAddressBinding^ myHttpAddressBinding1 = gcnew HttpAddressBinding; - myHttpAddressBinding1->Location = "http://localhost/ServiceCollection_CopyTo/AddSubtractService_CS.asmx"; - myHttpPostPort->Extensions->Add( myHttpAddressBinding1 ); - - // Add the ports to the service. - myService->Ports->Add( mySoapPort ); - myService->Ports->Add( myHttpGetPort ); - myService->Ports->Add( myHttpPostPort ); - - // Add the Service to the ServiceCollection. - myServiceDescription->Services->Insert( 1, myService ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( "output.wsdl" ); - - // Output the Wsdl. - myServiceDescription->Write( myStreamWriter ); - myStreamWriter->Close(); - - // - // - if ( myServiceDescription->Services->Contains( myService ) ) - { - Console::WriteLine( "The mentioned service exists at index {0} in the WSDL.", myServiceDescription->Services->IndexOf( myService ) ); - - // - array^myServiceArray = gcnew array(myServiceDescription->Services->Count); - - // Copy the services into an array. - myServiceDescription->Services->CopyTo( myServiceArray, 0 ); - IEnumerator^ myEnumerator = myServiceArray->GetEnumerator(); - Console::WriteLine( "The names of services in the array are" ); - while ( myEnumerator->MoveNext() ) - { - Service^ myService1 = dynamic_cast(myEnumerator->Current); - Console::WriteLine( myService1->Name ); - } - // - } - else - { - Console::WriteLine( "Service does not exist in the WSDL." ); - } - // - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught! {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceCollection_Item/CPP/servicecollection_item.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceCollection_Item/CPP/servicecollection_item.cpp deleted file mode 100644 index 64701ed31f107..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceCollection_Item/CPP/servicecollection_item.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// System.Web.Services.Description.ServiceDescription.Write(FileName) -// System.Web.Services.Description.ServiceCollection.Remove -// System.Web.Services.Description.ServiceCollection.Item(int) -// System.Web.Services.Description.ServiceDescription.Services -// System.Web.Services.Description.ServiceDescription.TargetNamespace -// System.Web.Services.Description.ServiceCollection.Add - -/* -The following example demonstrates methods and properties of -ServiceDescription and ServiceCollection classes. -A new WSDL is read and the existing service "MathService" in the -ServiceCollection is removed.The service by default is defined for -SOAP,HttpGet,HttpPost.A new Service defined for SOAP and HttpGet is -constructed and added to the ServiceCollection. -The programs writes a new web service description file. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - // - // - // - // - // - // Read a ServiceDescription from existing WSDL. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Input_CS.wsdl" ); - myServiceDescription->TargetNamespace = "http://tempuri.org/"; - // - - // Get the ServiceCollection of the ServiceDescription. - ServiceCollection^ myServiceCollection = myServiceDescription->Services; - - // Remove the Service at index 0 of the collection. - myServiceCollection->Remove( myServiceDescription->Services[ 0 ] ); - // - // - // - // - // Build a new Service. - Service^ myService = gcnew Service; - myService->Name = "MathService"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" ); - - // Build a new Port for SOAP. - Port^ mySoapPort = gcnew Port; - mySoapPort->Name = "MathServiceSoap"; - mySoapPort->Binding = myXmlQualifiedName; - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/ServiceCollection_Item/AddSub_CS.asmx"; - mySoapPort->Extensions->Add( mySoapAddressBinding ); - - // Build a new Port for HTTP-GET. - XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:MathServiceHttpGet" ); - Port^ myHttpGetPort = gcnew Port; - myHttpGetPort->Name = "MathServiceHttpGet"; - myHttpGetPort->Binding = myXmlQualifiedName2; - HttpAddressBinding^ myHttpAddressBinding = gcnew HttpAddressBinding; - myHttpAddressBinding->Location = "http://localhost/ServiceCollection_Item/AddSub_CS.asmx"; - myHttpGetPort->Extensions->Add( myHttpAddressBinding ); - - // Add the ports to the service. - myService->Ports->Add( myHttpGetPort ); - myService->Ports->Add( mySoapPort ); - - // Add the service to the ServiceCollection. - myServiceCollection->Add( myService ); - - // - // Write to a new WSDL file. - myServiceDescription->Write( "output.wsdl" ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription/CPP/servicedescription.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription/CPP/servicedescription.cpp deleted file mode 100644 index fa70e899296c4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription/CPP/servicedescription.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// System.Web.Services.Description.ServiceDescription - -/* -The following example demonstrates the 'ServiceDescription' class. -The input to the program is a WSDL file 'MyWsdl.wsdl'. -This program removes one 'Binding' from the existing WSDL. -A new Binding is defined and added to the ServiceDescription object. -The program generates a new Web Service Description document. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -// Used to create OperationBinding instances within 'Binding'. -OperationBinding^ CreateOperationBinding( String^ operation, String^ targetNamespace ) -{ - // Create OperationBinding instance for operation. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = operation; - - // Create InputBinding for operation. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - - // Create OutputBinding for operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - - // Create extensibility element for 'SoapOperationBinding'. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = targetNamespace + operation; - - // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - return myOperationBinding; -} - -int main() -{ - try - { - // - // Obtain the ServiceDescription of existing Wsdl. - ServiceDescription^ myDescription = ServiceDescription::Read( "MyWsdl_CS.wsdl" ); - - // Remove the Binding from the Binding Collection of ServiceDescription. - BindingCollection^ myBindingCollection = myDescription->Bindings; - myBindingCollection->Remove( myBindingCollection[ 0 ] ); - - // Form a new Binding. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "Service1Soap"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:Service1Soap" ); - myBinding->Type = myXmlQualifiedName; - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myDescription->TargetNamespace ); - myBinding->Operations->Add( addOperationBinding ); - myBinding->Extensions->Add( mySoapBinding ); - - // Add the Binding to the ServiceDescription. - myDescription->Bindings->Add( myBinding ); - myDescription->Write( "MyOutWsdl.wsdl" ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception :{0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionBaseCollection/CPP/servicedescriptionbasecollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionBaseCollection/CPP/servicedescriptionbasecollection.cpp deleted file mode 100644 index a8845c0e0db03..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionBaseCollection/CPP/servicedescriptionbasecollection.cpp +++ /dev/null @@ -1,192 +0,0 @@ - - -// System.Web.Services.Description.ServiceDescriptionBaseCollection. -/* -The following example demonstrates 'ServiceDescriptionBaseCollection' class. -A 'ServiceDescription' instance is obtained from the existing Wsdl. -'MyMethod' takes an instance of 'ServiceDescriptionBaseCollection' as a parameter. -Instance of different types of collections that were actually derived from -'ServiceDescriptionBaseCollection' are passed to my method and modifications of -corresponding instances in done. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; -ref class ServiceDescription_Sample -{ -public: - static ServiceDescription^ myServiceDescription; - static void Main() - { - // Read a ServiceDescription of existing WSDL. - myServiceDescription = ServiceDescription::Read( "Input_CS.wsdl" ); - - // Get the ServiceCollection of the ServiceDescription. - ServiceCollection^ myServiceCollection = myServiceDescription->Services; - MyMethod( myServiceCollection ); - BindingCollection^ myBindingCollection = myServiceDescription->Bindings; - MyMethod( myBindingCollection ); - PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; - MyMethod( myPortTypeCollection ); - myServiceDescription->Write( "Output.Wsdl" ); - } - - // - static void MyMethod( ServiceDescriptionBaseCollection^ myServiceCollection ) - { - Type^ myType = myServiceCollection->GetType(); - if ( myType->Equals( System::Web::Services::Description::ServiceCollection::typeid ) ) - { - // Remove the services at index 0 of the collection. - (dynamic_cast(myServiceCollection))->Remove( myServiceDescription->Services[ 0 ] ); - - // Build a new Service. - Service^ myService = gcnew Service; - myService->Name = "MathService"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" ); - - // Build a new Port for SOAP. - Port^ mySoapPort = gcnew Port; - mySoapPort->Name = "MathServiceSoap"; - mySoapPort->Binding = myXmlQualifiedName; - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/" - "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx"; - mySoapPort->Extensions->Add( mySoapAddressBinding ); - - // Build a new Port for HTTP-GET. - XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:MathServiceHttpGet" ); - Port^ myHttpGetPort = gcnew Port; - myHttpGetPort->Name = "MathServiceHttpGet"; - myHttpGetPort->Binding = myXmlQualifiedName2; - HttpAddressBinding^ myHttpAddressBinding = gcnew HttpAddressBinding; - myHttpAddressBinding->Location = "http://localhost/" - "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx"; - myHttpGetPort->Extensions->Add( myHttpAddressBinding ); - - // Add the ports to the Service. - myService->Ports->Add( myHttpGetPort ); - myService->Ports->Add( mySoapPort ); - - // Add the Service to the ServiceCollection. - myServiceDescription->Services->Add( myService ); - } - else - if ( myType->Equals( System::Web::Services::Description::BindingCollection::typeid ) ) - { - // Remove the Binding in the BindingCollection at index 0. - (dynamic_cast(myServiceCollection))->Remove( myServiceDescription->Bindings[ 0 ] ); - - // Build a new Binding. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "MathServiceSoap"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" ); - myBinding->Type = myXmlQualifiedName; - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - - // Create the operations for the binding. - OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace ); - OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace ); - - // Add the operations to the Binding. - myBinding->Operations->Add( subtractOperationBinding ); - myBinding->Operations->Add( addOperationBinding ); - myBinding->Extensions->Add( mySoapBinding ); - - // Add the Binding to the Bindings collection. - myServiceDescription->Bindings->Add( myBinding ); - } - else - if ( myType->Equals( System::Web::Services::Description::PortTypeCollection::typeid ) ) - { - // Remove the PortType at index 0. - (dynamic_cast(myServiceCollection))->Remove( myServiceDescription->PortTypes[ 0 ] ); - - // Build a new PortType. - PortType^ myPortType = gcnew PortType; - myPortType->Name = "MathServiceSoap"; - - // Build an Add Operation for the PortType. - Operation^ myAddOperation = gcnew Operation; - myAddOperation->Name = "Add"; - - // Build the Input and Output messages for the Operations. - OperationInput^ myOperationInputMessage1 = gcnew OperationInput; - XmlQualifiedName^ myXmlQualifiedName1 = gcnew XmlQualifiedName( "s0:AddSoapIn" ); - myOperationInputMessage1->Message = myXmlQualifiedName1; - OperationOutput^ myOperationOutputMessage1 = gcnew OperationOutput; - XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:AddSoapOut" ); - myOperationOutputMessage1->Message = myXmlQualifiedName2; - - // Add the messages to the operations. - myAddOperation->Messages->Add( myOperationInputMessage1 ); - myAddOperation->Messages->Add( myOperationOutputMessage1 ); - - // Build an Add Operation for the PortType. - Operation^ mySubtractOperation = gcnew Operation; - mySubtractOperation->Name = "Subtract"; - - // Build the Input and Output messages for the operations. - OperationInput^ myOperationInputMessage2 = gcnew OperationInput; - XmlQualifiedName^ myXmlQualifiedName3 = gcnew XmlQualifiedName( "s0:SubtractSoapIn" ); - myOperationInputMessage2->Message = myXmlQualifiedName3; - OperationOutput^ myOperationOutputMessage2 = gcnew OperationOutput; - XmlQualifiedName^ myXmlQualifiedName4 = gcnew XmlQualifiedName( "s0:SubtractSoapOut" ); - myOperationOutputMessage2->Message = myXmlQualifiedName4; - - // Add the messages to the operations. - mySubtractOperation->Messages->Add( myOperationInputMessage2 ); - mySubtractOperation->Messages->Add( myOperationOutputMessage2 ); - - // Add the operations to the PortType. - myPortType->Operations->Add( myAddOperation ); - myPortType->Operations->Add( mySubtractOperation ); - - // Add the PortType to the collection. - myServiceDescription->PortTypes->Add( myPortType ); - } - } - // - - static OperationBinding^ CreateOperationBinding( String^ operation, String^ targetNamespace ) - { - // Create OperationBinding instance for operation. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = operation; - - // Create InputBinding for operation. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - - // Create OutputBinding for operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - - // Create extensibility element for 'SoapOperationBinding'. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = String::Concat( targetNamespace, operation ); - - // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - return myOperationBinding; - } -}; - -int main() -{ - ServiceDescription_Sample::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection/CPP/servicedescriptioncollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection/CPP/servicedescriptioncollection.cpp deleted file mode 100644 index 3a27bf22ab5d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection/CPP/servicedescriptioncollection.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// System::Web::Services::Description.ServiceDescriptionCollection -/*The following program demonstrates the 'ServiceDescriptionCollection' class. -It creates two 'ServiceDescription' objects and add them to -'ServiceDescriptionCollection' Object*. It displays the name of 'ServiceDescription' -objects using 'Item' property. 'GetBinding' method is used to display binding instance of the -'ServiceDescription' Object*. - -Note: This program requires 'DataTypes_CS.wsdl' and 'MathService_cpp.wsdl' files to -be placed in same directory as that of .exe for running. -*/ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - // Get ServiceDescription objects. - ServiceDescription^ myServiceDescription1 = ServiceDescription::Read( "DataTypes_cpp.wsdl" ); - ServiceDescription^ myServiceDescription2 = ServiceDescription::Read( "MathService_cpp.wsdl" ); - - // Set the names of the ServiceDescriptions. - myServiceDescription1->Name = "DataTypes"; - myServiceDescription2->Name = "MathService"; - - // Create a ServiceDescriptionCollection. - ServiceDescriptionCollection^ myServiceDescriptionCollection = gcnew ServiceDescriptionCollection; - - // Add the ServiceDescriptions to the collection. - myServiceDescriptionCollection->Add( myServiceDescription1 ); - myServiceDescriptionCollection->Add( myServiceDescription2 ); - - // Display the elements of the collection using the Item property. - Console::WriteLine( "Elements in the collection: " ); - for ( int i = 0; i < myServiceDescriptionCollection->Count; i++ ) - Console::WriteLine( myServiceDescriptionCollection[ i ]->Name ); - - // Construct an XML qualified name. - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "MathServiceSoap","http://tempuri2.org/" ); - - // Get the Binding from the collection. - Binding^ myBinding = myServiceDescriptionCollection->GetBinding( myXmlQualifiedName ); - Console::WriteLine( "Binding found in collection with name: {0}", myBinding->ServiceDescription->Name ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Constructor_Add_Item/CPP/sdcollection_constructor_add_item.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Constructor_Add_Item/CPP/sdcollection_constructor_add_item.cpp deleted file mode 100644 index 1f4b047229c35..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Constructor_Add_Item/CPP/sdcollection_constructor_add_item.cpp +++ /dev/null @@ -1,50 +0,0 @@ - - -// System::Web::Services::Description.ServiceDescriptionCollection::ServiceDescriptionCollection() -// System::Web::Services::Description.ServiceDescriptionCollection->Add() -// System::Web::Services::Description.ServiceDescriptionCollection::Item(Int32) -/* The following program demonstrates 'Constructor', 'Add' method and -'Item' property of 'ServiceDescriptionCollection' class. It creates an -instance of 'ServiceDescriptionCollection' and adds -'ServiceDescription' objects to the collection. The Item property is used to -display the TargetNamespace of elements in the collection. - -Note: This program requires 'DataTypes_CS::wsdl' and 'MathService_CS::wsdl' -files to be placed in same directory as that of .exe for running. -*/ -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription1 = ServiceDescription::Read( "DataTypes_cpp.wsdl" ); - ServiceDescription^ myServiceDescription2 = ServiceDescription::Read( "MathService_cpp.wsdl" ); - - // - // - // Create a ServiceDescriptionCollection. - ServiceDescriptionCollection^ myCollection = gcnew ServiceDescriptionCollection; - - // Add ServiceDescriptions to the collection. - myCollection->Add( myServiceDescription1 ); - myCollection->Add( myServiceDescription2 ); - // - // - - // - // Display element properties in the collection using - // the Item property. - for ( int i = 0; i < myCollection->Count; i++ ) - Console::WriteLine( myCollection[ i ]->TargetNamespace ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Contains_IndexOf_Remove/CPP/sdcollection_contains_indexof_remove.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Contains_IndexOf_Remove/CPP/sdcollection_contains_indexof_remove.cpp deleted file mode 100644 index 6a6f1f0c8b26c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Contains_IndexOf_Remove/CPP/sdcollection_contains_indexof_remove.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// System::Web::Services::Description.ServiceDescriptionCollection::Contains() -// System::Web::Services::Description.ServiceDescriptionCollection::IndexOf() -// System::Web::Services::Description.ServiceDescriptionCollection::Remove() - -/* The following program demonstrates 'Contains', 'IndexOf' and -'Remove' methods of 'ServiceDescriptionCollection' class. It creates an -instance of 'ServiceDescriptionCollection' and adds 'ServiceDescription' -objects to the collection. It checks for an Object* of 'ServiceDescription', -retrieves the index of the Object* and removes it from the collection. - -Note: This program requires 'DataTypes_cpp.wsdl' and 'MathService_cpp.wsdl' -files to be placed in the same directory as that of .exe for -running. -*/ - -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription1 = - ServiceDescription::Read( "DataTypes_cpp.wsdl" ); - ServiceDescription^ myServiceDescription2 = - ServiceDescription::Read( "MathService_cpp.wsdl" ); - ServiceDescriptionCollection^ myCollection = - gcnew ServiceDescriptionCollection; - - // Add 'ServiceDescription' objects. - myCollection->Add( myServiceDescription1 ); - myCollection->Add( myServiceDescription2 ); - -// - // Check for 'ServiceDescription' object in the collection. - if ( myCollection->Contains( myServiceDescription2 ) ) - { -// -// - // Get the index of 'ServiceDescription' object. - int myIndex = myCollection->IndexOf( myServiceDescription2 ); - - // Remove 'ServiceDescription' object from the collection. - myCollection->Remove( myServiceDescription2 ); - Console::WriteLine( "Element at index {0} is removed ", myIndex ); -// - // - } - else - Console::WriteLine( "Element not found." ); -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetBinding/CPP/servicedescriptioncollection_getbinding.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetBinding/CPP/servicedescriptioncollection_getbinding.cpp deleted file mode 100644 index 79ca7ba38d2d3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetBinding/CPP/servicedescriptioncollection_getbinding.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// System::Web::Services::Description.ServiceDescriptionCollection::GetBinding() -/* The following program demonstrates the 'GetBinding' method -of 'ServiceDescriptionCollection' class. It searches for a -'Binding' in the collection and returns the Binding instance. -On success, a message is displayed on the console. - -Note: This program requires 'DataTypes_cpp.wsdl' and 'MathService_cpp.wsdl' -files to be placed in same directory as that of .exe for running. -*/ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription1 = - ServiceDescription::Read( "DataTypes_cpp.wsdl" ); - ServiceDescription^ myServiceDescription2 = - ServiceDescription::Read( "MathService_cpp.wsdl" ); - - // Create the Object* of 'ServiceDescriptionCollection' class. - ServiceDescriptionCollection^ myCollection = - gcnew ServiceDescriptionCollection; - - // Add ServiceDescription objects. - myCollection->Add( myServiceDescription1 ); - myCollection->Add( myServiceDescription2 ); - -// - // Construct an XML qualified name. - XmlQualifiedName^ myXmlQualifiedName = - gcnew XmlQualifiedName( "MathServiceSoap","http://tempuri2.org/" ); - - // Get the Binding from the collection. - myCollection->GetBinding( myXmlQualifiedName ); -// - Console::WriteLine( "Specified Binding is a member of ServiceDescription " - + "instances within the collection" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetMessage/CPP/servicedescriptioncollection_getmessage.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetMessage/CPP/servicedescriptioncollection_getmessage.cpp deleted file mode 100644 index e84c9b0113472..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetMessage/CPP/servicedescriptioncollection_getmessage.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Web::Services::Description.ServiceDescriptionCollection::GetMessage() - -/* The following program demonstrates the 'GetMessage' method -of 'ServiceDescriptionCollection' class. It searches for a -'Message' in the collection and returns the Message instance. On success, -a message is displayed on the console. - -Note: This program requires 'DataTypes_cpp.wsdl' and 'MathService_cpp.wsdl' -files to be placed in same directory as that of .exe for running. -*/ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription1 = - ServiceDescription::Read( "DataTypes_cpp.wsdl" ); - ServiceDescription^ myServiceDescription2 = - ServiceDescription::Read( "MathService_cpp.wsdl" ); - - // Create the Object* of 'ServiceDescriptionCollection' class. - ServiceDescriptionCollection^ myCollection = - gcnew ServiceDescriptionCollection; - - // Add 'ServiceDescription' objects. - myCollection->Add( myServiceDescription1 ); - myCollection->Add( myServiceDescription2 ); - -// - // Construct an XML qualified name. - XmlQualifiedName^ myXmlQualifiedName = - gcnew XmlQualifiedName( "AddSoapIn","http://tempuri2.org/" ); - - // Get the Message from the collection. - myCollection->GetMessage( myXmlQualifiedName ); -// - - Console::WriteLine( "Specified Message is a member of ServiceDescription " - + "instances within the collection." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetPortType/CPP/servicedescriptioncollection_getporttype.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetPortType/CPP/servicedescriptioncollection_getporttype.cpp deleted file mode 100644 index 8374664ea9d9d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetPortType/CPP/servicedescriptioncollection_getporttype.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Web::Services::Description.ServiceDescriptionCollection::GetPortType() - -/* The following program demonstrates the 'GetPortType' method -of 'ServiceDescriptionCollection' class. It searches for a -'PortType' with XmlQualifiedName in the collection and returns a -PortType instance. On success, a message is displayed on the -console. - -Note: This program requires 'DataTypes_cpp..wsdl' and 'MathService_cpp..wsdl' -files to be placed in same directory as that of .exe for running. -*/ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription1 = - ServiceDescription::Read( "DataTypes_cpp..wsdl" ); - ServiceDescription^ myServiceDescription2 = - ServiceDescription::Read( "MathService_cpp..wsdl" ); - - // Create the Object* of 'ServiceDescriptionCollection' class. - ServiceDescriptionCollection^ myCollection = - gcnew ServiceDescriptionCollection; - - // Add 'ServiceDescription' objects. - myCollection->Add( myServiceDescription1 ); - myCollection->Add( myServiceDescription2 ); - -// - // Construct an XML qualified name. - XmlQualifiedName^ myXmlQualifiedName = - gcnew XmlQualifiedName( "MathServiceSoap","http://tempuri2.org/" ); - - // Get the PortType from the collection. - myCollection->GetPortType( myXmlQualifiedName ); -// - - Console::WriteLine( "Specified PortType is a member of ServiceDescription " - + "instances within the collection." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetService/CPP/servicedescriptioncollection_getservice.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetService/CPP/servicedescriptioncollection_getservice.cpp deleted file mode 100644 index 393a442e65a27..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_GetService/CPP/servicedescriptioncollection_getservice.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Web::Services::Description.ServiceDescriptionCollection::GetService() - -/* The following program demonstrates the 'GetService' method -of 'ServiceDescriptionCollection' class. It searches for a -'Service' with XmlQualifiedName in the collection and returns -the Service instance. On success, a message is displayed on the -console. - -Note: This program requires 'DataTypes_cpp.wsdl' and 'MathService_cpp.wsdl' -files to be placed in same directory as that of .exe for running. -*/ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription1 = - ServiceDescription::Read( "DataTypes_cpp.wsdl" ); - ServiceDescription^ myServiceDescription2 = - ServiceDescription::Read( "MathService_cpp.wsdl" ); - - // Create the Object* of 'ServiceDescriptionCollection' class. - ServiceDescriptionCollection^ myCollection = - gcnew ServiceDescriptionCollection; - - // Add 'ServiceDescription' objects. - myCollection->Add( myServiceDescription1 ); - myCollection->Add( myServiceDescription2 ); - -// - // Construct an XML qualified name. - XmlQualifiedName^ myXmlQualifiedName = - gcnew XmlQualifiedName( "MathService","http://tempuri2.org/" ); - - // Get the Service from the collection. - myCollection->GetService( myXmlQualifiedName ); -// - - Console::WriteLine( "Specified Service is a member of ServiceDescription " - + "instances within the collection" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Insert_Item_CopyTo/CPP/sdcollection_insert_item_copyto.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Insert_Item_CopyTo/CPP/sdcollection_insert_item_copyto.cpp deleted file mode 100644 index 65f79d261a7c0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionCollection_Insert_Item_CopyTo/CPP/sdcollection_insert_item_copyto.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// System::Web::Services::Description.ServiceDescriptionCollection::Insert() -// System::Web::Services::Description.ServiceDescriptionCollection::Item(String) -// System::Web::Services::Description.ServiceDescriptionCollection::CopyTo() -/* The following program demonstrates 'Item' property, 'Insert' and 'CopyTo' -methods of the 'ServiceDescriptionCollection' class. It creates an instance of -'ServiceDescriptionCollection' and adds 'ServiceDescription' objects to the -collection. The elements of the collection are copied to a 'ServiceDescription' -array. - -Note: This program requires 'DataTypes_cpp.wsdl' and 'MathService_cpp.wsdl' -files to be placed in the same directory as that of .exe for running. -*/ -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - ServiceDescription^ myServiceDescription1 = ServiceDescription::Read( "DataTypes_cpp.wsdl" ); - myServiceDescription1->Name = "DataTypes"; - ServiceDescription^ myServiceDescription2 = ServiceDescription::Read( "MathService_cpp.wsdl" ); - myServiceDescription2->Name = "MathService"; - - // Create the object of 'ServiceDescriptionCollection' class. - ServiceDescriptionCollection^ myCollection = gcnew ServiceDescriptionCollection; - - // Add 'ServiceDescription' objects. - myCollection->Add( myServiceDescription1 ); - - // - // Insert a ServiceDescription into the collection. - myCollection->Insert( 1, myServiceDescription2 ); - // - - // - // Get a ServiceDescription in the collection using - // the Item property. - ServiceDescription^ myServiceDescription = myCollection[ "http://tempuri1.org/" ]; - // - - Console::WriteLine( "Name of the object retrieved using 'Item' property: {0}", myServiceDescription->Name ); - - // - array^myArray = gcnew array(myCollection->Count); - - // Copy the collection to a ServiceDescription array. - myCollection->CopyTo( myArray, 0 ); - for ( int i = 0; i < myArray->Length; i++ ) - Console::WriteLine( "Name of element in array: {0}", myArray[ i ]->Name ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionFormatExtension_13/CPP/servicedescriptionformatextension_13.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionFormatExtension_13/CPP/servicedescriptionformatextension_13.cpp deleted file mode 100644 index bd4ca4802098c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionFormatExtension_13/CPP/servicedescriptionformatextension_13.cpp +++ /dev/null @@ -1,142 +0,0 @@ - - -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::ctor -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection->Add() -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::Item -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::Find(System::Type type) -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::FindAll(System::Type type) -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::IsHandled() -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::IsRequired() -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::CopyTo() -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::Contains() -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::IndexOf() -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::Remove() -// System::Web::Services::Description.ServiceDescriptionFormatExtensionCollection::Insert() -/* The following program demonstrates the class, properties and methods of -'ServiceDescriptionFormatExtensionCollection' -class. It creates a ServiceDescription object, uses it to create -'ServiceDescriptionFormatExtensionCollection' object. Collection -object is used for demonstration of class properties and methods. - -Note: This program requires 'Sample_cpp.wsdl' file to be placed in -the same directory as that of .exe for running. -*/ -// -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; - -ref class MyFormatExtension: public ServiceDescriptionFormatExtension -{ -public: - MyFormatExtension() - { - // Set the properties. - this->Handled = true; - this->Required = true; - } -}; - -int main() -{ - try - { - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Sample_cpp.wsdl" ); - ServiceDescriptionFormatExtensionCollection^ myCollection = gcnew ServiceDescriptionFormatExtensionCollection( myServiceDescription ); - // - - // - SoapBinding^ mySoapBinding1 = gcnew SoapBinding; - SoapBinding^ mySoapBinding2 = gcnew SoapBinding; - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - MyFormatExtension^ myFormatExtensionObject = gcnew MyFormatExtension; - - // Add elements to collection. - myCollection->Add( mySoapBinding1 ); - myCollection->Add( mySoapAddressBinding ); - myCollection->Add( mySoapBinding2 ); - myCollection->Add( myFormatExtensionObject ); - // - - // - Console::WriteLine( "Collection contains following types of elements: " ); - - // Display the 'Type' of the elements in collection. - for ( int i = 0; i < myCollection->Count; i++ ) - Console::WriteLine( myCollection[ i ]->GetType() ); - // - - // - // Check element of type 'SoapAddressBinding' in collection. - Object^ myObj = myCollection->Find( mySoapAddressBinding->GetType() ); - if ( myObj == nullptr ) - Console::WriteLine( "Element of type ' {0}' not found in collection.", mySoapAddressBinding->GetType() ); - else - Console::WriteLine( "Element of type ' {0}' found in collection.", mySoapAddressBinding->GetType() ); - // - - // - // Check all elements of type 'SoapBinding' in collection. - array^myObjectArray1 = gcnew array(myCollection->Count); - myObjectArray1 = myCollection->FindAll( mySoapBinding1->GetType() ); - int myNumberOfElements = 0; - IEnumerator^ myIEnumerator = myObjectArray1->GetEnumerator(); - - // Calculate number of elements of type 'SoapBinding'. - while ( myIEnumerator->MoveNext() ) - if ( mySoapBinding1->GetType() == myIEnumerator->Current->GetType() ) - myNumberOfElements++; - Console::WriteLine( "Collection contains {0} objects of type ' {1}'.", myNumberOfElements, mySoapBinding1->GetType() ); - // - - // - // Check 'IsHandled' status for 'myFormatExtensionObject' object in collection. - Console::WriteLine( "'IsHandled' status for {0} object is {1}.", myFormatExtensionObject, myCollection->IsHandled( myFormatExtensionObject ) ); - // - - // - // Check 'IsRequired' status for 'myFormatExtensionObject' object in collection. - Console::WriteLine( "'IsRequired' status for {0} object is {1}.", myFormatExtensionObject, myCollection->IsRequired( myFormatExtensionObject ) ); - // - - // - // Copy elements of collection to an Object array. - array^myObjectArray2 = gcnew array(myCollection->Count); - myCollection->CopyTo( myObjectArray2, 0 ); - Console::WriteLine( "Collection elements are copied to an object array." ); - // - - // - // Check for 'myFormatExtension' object in collection. - if ( myCollection->Contains( myFormatExtensionObject ) ) - { - // - // Get index of a 'myFormatExtension' object in collection. - Console::WriteLine( "Index of 'myFormatExtensionObject' is {0} in collection.", myCollection->IndexOf( myFormatExtensionObject ) ); - // - - // - // Remove 'myFormatExtensionObject' element from collection. - myCollection->Remove( myFormatExtensionObject ); - Console::WriteLine( "'myFormatExtensionObject' is removed from collection." ); - // - } - // - - // - // Insert 'MyFormatExtension' object. - myCollection->Insert( 0, myFormatExtensionObject ); - Console::WriteLine( "'myFormatExtensionObject' is inserted to collection." ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionImportStyle_Client/CPP/servicedescriptionimportstyle_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionImportStyle_Client/CPP/servicedescriptionimportstyle_client.cpp deleted file mode 100644 index bed420f5e0155..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionImportStyle_Client/CPP/servicedescriptionimportstyle_client.cpp +++ /dev/null @@ -1,39 +0,0 @@ - - -// System::Web::Services::Description.ServiceDescriptionImportStyle -// System::Web::Services::Description.ServiceDescriptionImportStyle::Client -/* The following program demonstrates the 'ServiceDescriptionImportStyle' -enumeration and 'Client' member of 'ServiceDescriptionImportStyle' in -'System::Web::Services::Description' namespace. It creates a -ServiceDescriptionImporter Object* from a .wsdl file and demonstrates -the usage of Client. */ -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -int main() -{ - try - { - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Sample_cpp.wsdl" ); - ServiceDescriptionImporter^ myImporter = gcnew ServiceDescriptionImporter; - myImporter->ProtocolName = "Soap"; - myImporter->AddServiceDescription( myServiceDescription, "", "" ); - - // - ServiceDescriptionImportStyle myStyle = myImporter->Style; - Console::WriteLine( "Import style: {0}", myStyle ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Following exception was thrown: {0}", e ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionImportWarnings_Enum/CPP/servicedescriptionimportwarnings_enum.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionImportWarnings_Enum/CPP/servicedescriptionimportwarnings_enum.cpp deleted file mode 100644 index 475d65bae5aff..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescriptionImportWarnings_Enum/CPP/servicedescriptionimportwarnings_enum.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// System::Web::Services::Description.ServiceDescriptionImportWarnings::NoCodeGenerated -// System::Web::Services::Description.ServiceDescriptionImportWarnings::NoMethodsGenerated -// System::Web::Services::Description.ServiceDescriptionImportWarnings::UnsupportedOperationsIgnored -// System::Web::Services::Description.ServiceDescriptionImportWarnings::OptionalExtensionsIgnored -// System::Web::Services::Description.ServiceDescriptionImportWarnings::RequiredExtensionsIgnored -// System::Web::Services::Description.ServiceDescriptionImportWarnings::UnsupportedBindingsIgnored - -/* -The following program demonstrates the enum values of 'ServiceDescriptionImportWarnings'. -'Import' method of 'ServiceDescriptionImporter' will give the enumaration. The user selected -option will help in taking the related wsdl file and returns the corresponding warning which -is displayed on the console. -*/ - -using namespace System; - -#using -#using -#using - -using namespace System::Web::Services::Description; -using namespace System::CodeDom; - -void DisplayWarning( String^ myWSDLFileName ) -{ -// - String^ myDisplay; - // Read wsdl file. - ServiceDescription^ myServiceDescription = ServiceDescription::Read - ( myWSDLFileName ); - - ServiceDescriptionImporter^ myServiceDescriptionImporter = - gcnew ServiceDescriptionImporter; - - // Add 'myServiceDescription' to 'myServiceDescriptionImporter'. - myServiceDescriptionImporter->AddServiceDescription - ( myServiceDescription, "", "" ); - - myServiceDescriptionImporter->ProtocolName = "HttpGet"; - CodeNamespace^ myCodeNamespace = gcnew CodeNamespace; - CodeCompileUnit^ myCodeCompileUnit = gcnew CodeCompileUnit; - - // Invoke 'Import' method. - ServiceDescriptionImportWarnings myWarning = - myServiceDescriptionImporter->Import(myCodeNamespace, - myCodeCompileUnit); - - switch ( myWarning ) - { - case ServiceDescriptionImportWarnings::NoCodeGenerated: - myDisplay = "NoCodeGenerated"; - break; - case ServiceDescriptionImportWarnings::NoMethodsGenerated: - myDisplay = "NoMethodsGenerated"; - break; - case ServiceDescriptionImportWarnings::UnsupportedOperationsIgnored: - myDisplay = "UnsupportedOperationsIgnored"; - break; - case ServiceDescriptionImportWarnings::OptionalExtensionsIgnored: - myDisplay = "OptionalExtensionsIgnored"; - break; - case ServiceDescriptionImportWarnings::RequiredExtensionsIgnored: - myDisplay = "RequiredExtensionsIgnored"; - break; - case ServiceDescriptionImportWarnings::UnsupportedBindingsIgnored: - myDisplay = "UnsupportedBindingsIgnored"; - break; - default: - myDisplay = "General Warning"; - break; - } - Console::WriteLine( "Warning : " + myDisplay ); -// -} - -int main() -{ - DisplayWarning( "ServiceDescriptionImportWarnings_NoCodeGenerated.wsdl" ); - DisplayWarning( "ServiceDescriptionImportWarnings_NoMethodsGenerated::wsdl" ); - DisplayWarning( "ServiceDescriptionImportWarnings_UnsupportedOperationsIgnored::wsdl" ); - DisplayWarning( "ServiceDescriptionImportWarnings_OptionalExtensionsIgnored::wsdl" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Bindings/CPP/servicedescription_bindings.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Bindings/CPP/servicedescription_bindings.cpp deleted file mode 100644 index 7b2a6a89d1b9c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Bindings/CPP/servicedescription_bindings.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// System.Web.Services.Description.ServiceDescription.Bindings - -/* -The following example demonstrates the property 'Bindings' of -'ServiceDescription' class. The input to the program is a WSDL file -'MyWsdl_CS.wsdl'. This program removes one 'Binding' from the existing WSDL. -A new Binding is defined and added to the ServiceDescription object. -The program generates a new Web Service Description document. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -// Used to create OperationBinding instances within 'Binding'. -OperationBinding^ CreateOperationBinding( String^ operation, String^ targetNamespace ) -{ - // Create OperationBinding instance for operation. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = operation; - - // Create InputBinding for operation. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - - // Create OutputBinding for operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - - // Create extensibility element for 'SoapOperationBinding'. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - mySoapOperationBinding->SoapAction = targetNamespace + operation; - - // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - return myOperationBinding; -} - -int main() -{ - try - { - // - // Obtain the ServiceDescription from existing WSDL. - ServiceDescription^ myDescription = ServiceDescription::Read( "MyWsdl_CS.wsdl" ); - - // Remove the Binding from the BindingCollection of - // the ServiceDescription. - BindingCollection^ myBindingCollection = myDescription->Bindings; - myBindingCollection->Remove( myBindingCollection[ 0 ] ); - - // Form a new Binding. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "Service1Soap"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:Service1Soap" ); - myBinding->Type = myXmlQualifiedName; - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myDescription->TargetNamespace ); - myBinding->Operations->Add( addOperationBinding ); - myBinding->Extensions->Add( mySoapBinding ); - - // Add the Binding to the ServiceDescription. - myDescription->Bindings->Add( myBinding ); - myDescription->Write( "MyOutWsdl.wsdl" ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Constructor_4/CPP/servicedescription_constructor_4.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Constructor_4/CPP/servicedescription_constructor_4.cpp deleted file mode 100644 index 295c9eb371127..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Constructor_4/CPP/servicedescription_constructor_4.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System.Web.Services.Description.ServiceDescription.ServiceDescription() -// System.Web.Services.Description.ServiceDescription.Read(string) -// System.Web.Services.Description.ServiceDescription.Messages -// System.Web.Services.Description.ServiceDescription.Name - -/* -The following example demonstrates the constructor 'ServiceDescription()', -properties 'Messages', 'Name' and 'Read' method of 'ServiceDescription' -class.The input to the program is a WSDL file 'MyWsdl.wsdl'. -This program removes one message from the existing WSDL. -A new Message is defined and added to the ServiceDescription. -A new wsdl with modified ServiceDescription is written in 'MyOutWsdl.wsdl'. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -int main() -{ - // - // - // - // - ServiceDescription^ myDescription = gcnew ServiceDescription; - myDescription = ServiceDescription::Read( "MyWsdl_CS.wsdl" ); - myDescription->Name = "MyServiceDescription"; - Console::WriteLine( "Name: {0}", myDescription->Name ); - MessageCollection^ myMessageCollection = myDescription->Messages; - - // Remove the message at index 0 from the message collection. - myMessageCollection->Remove( myDescription->Messages[ 0 ] ); - - // Build a new message. - Message^ myMessage = gcnew Message; - myMessage->Name = "AddSoapIn"; - - // Build a new MessagePart. - MessagePart^ myMessagePart = gcnew MessagePart; - myMessagePart->Name = "parameters"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:Add" ); - myMessagePart->Element = myXmlQualifiedName; - - // Add MessageParts to the message. - myMessage->Parts->Add( myMessagePart ); - - // Add the message to the ServiceDescription. - myDescription->Messages->Add( myMessage ); - myDescription->Write( "MyOutWsdl.wsdl" ); - // - // - // - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Extensions_RetrieveUrl/CPP/servicedescription_extensions_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Extensions_RetrieveUrl/CPP/servicedescription_extensions_2.cpp deleted file mode 100644 index 5aa1c26e6f6fb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Extensions_RetrieveUrl/CPP/servicedescription_extensions_2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// System.Web.Services.Description.ServiceDescription.Extensions -// System.Web.Services.Description.ServiceDescription.RetrievalUrl -/* The following program demonstrates properties 'Extensions', 'RetrievalUrl' of -'ServiceDescription' class. The input to the program is a WSDL file -'ServiceDescription_Extensions_Input_cs.wsdl'. This program adds one object -to the extensions collection and displays the count and set the 'RetrievalURL' and displays. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; - -int main() -{ - // - // - ServiceDescription^ myServiceDescription = gcnew ServiceDescription; - myServiceDescription = ServiceDescription::Read( "ServiceDescription_Extensions_Input_cs.wsdl" ); - Console::WriteLine( myServiceDescription->Bindings[ 1 ]->Extensions[ 0 ] ); - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Required = true; - SoapBinding^ mySoapBinding1 = gcnew SoapBinding; - mySoapBinding1->Required = false; - myServiceDescription->Extensions->Add( mySoapBinding ); - myServiceDescription->Extensions->Add( mySoapBinding1 ); - System::Collections::IEnumerator^ myEnum = myServiceDescription->Extensions->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - ServiceDescriptionFormatExtension^ myServiceDescriptionFormatExtension = (ServiceDescriptionFormatExtension^)(myEnum->Current); - Console::WriteLine( "Required: {0}", myServiceDescriptionFormatExtension->Required ); - } - - myServiceDescription->Write( "ServiceDescription_Extensions_Output_cs.wsdl" ); - myServiceDescription->RetrievalUrl = "http://www.contoso.com/"; - Console::WriteLine( "Retrieval URL is: {0}", myServiceDescription->RetrievalUrl ); - // - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Imports_Service/CPP/servicedescription_imports.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Imports_Service/CPP/servicedescription_imports.cpp deleted file mode 100644 index 7f3cffea1bed6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Imports_Service/CPP/servicedescription_imports.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// System.Web.Services.Description.ServiceDescription.Imports - -/* The following program demonstrates the property 'Imports' of 'ServiceDescription' class. -The input to the program is a WSDL file 'ServiceDescription_Imports_Input_CS.wsdl' which -is not having the import element. A new 'Import' is defined and added to the new modified -'ServiceDescription_Imports_Output_CS.wsdl' file. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -int main() -{ - // - ServiceDescription^ myServiceDescription = gcnew ServiceDescription; - myServiceDescription = ServiceDescription::Read( "ServiceDescription_Imports_Input_CS.wsdl" ); - ImportCollection^ myImportCollection = myServiceDescription->Imports; - - // Create an Import. - Import^ myImport = gcnew Import; - myImport->Namespace = myServiceDescription->TargetNamespace; - - // Set the location for the Import. - myImport->Location = "http://www.contoso.com/"; - myImportCollection->Add( myImport ); - myServiceDescription->Write( "ServiceDescription_Imports_Output_CS.wsdl" ); - myImportCollection->Clear(); - myServiceDescription = ServiceDescription::Read( "ServiceDescription_Imports_Output_CS.wsdl" ); - myImportCollection = myServiceDescription->Imports; - Console::WriteLine( "The Import elements added to the ImportCollection are: " ); - for ( int i = 0; i < myImportCollection->Count; i++ ) - { - Console::WriteLine( "{0}. {1}", (i + 1), myImportCollection[ i ]->Location ); - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Namespace/CPP/servicedescription_namespace.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Namespace/CPP/servicedescription_namespace.cpp deleted file mode 100644 index c43dfec57a950..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Namespace/CPP/servicedescription_namespace.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// System::Web::Services::Description.ServiceDescription::Namespace - -/* -The following example demonstrates 'Namespace' property of 'ServiceDescription' class.The input to the program is a -WSDL file 'MyWsdl::wsdl'.This program displays the Namespace of 'ServiceDescription' class. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; - -int main() -{ - try - { -// - ServiceDescription^ myDescription = - ServiceDescription::Read( "MyWsdl_CS.wsdl" ); - Console::WriteLine( "Namespace : " + ServiceDescription::Namespace ); -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: " + e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_PortTypes_2/CPP/servicedescription_porttypes_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_PortTypes_2/CPP/servicedescription_porttypes_2.cpp deleted file mode 100644 index fb6a682faf5c8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_PortTypes_2/CPP/servicedescription_porttypes_2.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// System.Web.Services.Description.ServiceDescription.PortTypes -// System.Web.Services.Description.ServiceDescription.CanRead - -/* -The following example demonstrates the 'PortTypes' property -and 'CanRead' method of 'ServiceDescription' class. -The input to the program is a WSDL file 'MyWsdl_CS.wsdl'. -This program checks the validity of WSDL file.One of the existing -port types is removed.A new PortType is defined and added to the -port types collection of the service description. A modified WSDL -is the output of the program. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -// -// -// Creates an Operation for a PortType. -Operation^ CreateOperation( String^ operationName, String^ inputMessage, String^ outputMessage, String^ targetNamespace ) -{ - Operation^ myOperation = gcnew Operation; - myOperation->Name = operationName; - OperationMessage^ input = dynamic_cast(gcnew OperationInput); - input->Message = gcnew XmlQualifiedName( inputMessage,targetNamespace ); - OperationMessage^ output = dynamic_cast(gcnew OperationOutput); - output->Message = gcnew XmlQualifiedName( outputMessage,targetNamespace ); - myOperation->Messages->Add( input ); - myOperation->Messages->Add( output ); - return myOperation; -} - -int main() -{ - String^ myWsdlFileName = "MyWsdl_CS.wsdl"; - XmlTextReader^ myReader = gcnew XmlTextReader( myWsdlFileName ); - if ( ServiceDescription::CanRead( myReader ) ) - { - ServiceDescription^ myDescription = ServiceDescription::Read( myWsdlFileName ); - - // Remove the PortType at index 0 of the collection. - PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes; - myPortTypeCollection->Remove( myDescription->PortTypes[ 0 ] ); - - // Build a new PortType. - PortType^ myPortType = gcnew PortType; - myPortType->Name = "Service1Soap"; - Operation^ myOperation = CreateOperation( "Add", "s0:AddSoapIn", "s0:AddSoapOut", "" ); - myPortType->Operations->Add( myOperation ); - - // Add a new PortType to the PortType collection of - // the ServiceDescription. - myDescription->PortTypes->Add( myPortType ); - myDescription->Write( "MyOutWsdl.wsdl" ); - Console::WriteLine( "New WSDL file generated successfully." ); - } - else - { - Console::WriteLine( "This file is not a WSDL file." ); - } -} -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read/CPP/servicedescription_read.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read/CPP/servicedescription_read.cpp deleted file mode 100644 index 9f61643a1f432..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read/CPP/servicedescription_read.cpp +++ /dev/null @@ -1,85 +0,0 @@ - - -// System.Web.Description.ServiceDescription.Read(XmlReader) -// System.Web.Description.ServiceCollection.Item(string) -// System.Web.Description.ServiceCollection.Insert(int,Service) -// System.Web.Description.ServiceDescription.Write(XmlWriter) -/* -The following program demonstrates the properties of ServiceDescription and -ServiceCollection class.An XmlTextReader with the required url is created. -An existing WSDL document is read. -An existing service named "MathService" is removed from the collection and -A new Service object is constructed and added at index 1 of the Collection of Services. -A new WSDL file is created as output. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Text; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - try - { - // - // - // Create a new XmlTextWriter with specified URL. - XmlTextReader^ myXmlReader = gcnew XmlTextReader( "All_CS.wsdl" ); - ServiceDescription^ myServiceDescription = ServiceDescription::Read( myXmlReader ); - myServiceDescription->TargetNamespace = "http://tempuri.org/"; - - // Remove the service named MathService. - ServiceCollection^ myServiceDescriptionCollection = myServiceDescription->Services; - myServiceDescriptionCollection->Remove( myServiceDescription->Services[ "MathService" ] ); - // - // - - // - Service^ myService = gcnew Service; - myService->Name = "MathService"; - XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" ); - - // Build a new Port for SOAP. - Port^ mySoapPort = gcnew Port; - mySoapPort->Name = "MathServiceSoap"; - mySoapPort->Binding = myXmlQualifiedName; - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/ServiceDescription_Read/AddService_CS.asmx"; - mySoapPort->Extensions->Add( mySoapAddressBinding ); - - // Build a new Port for HTTP-GET. - XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:MathServiceHttpGet" ); - Port^ myHttpGetPort = gcnew Port; - myHttpGetPort->Name = "MathServiceHttpGet"; - myHttpGetPort->Binding = myXmlQualifiedName2; - HttpAddressBinding^ myHttpAddressBinding = gcnew HttpAddressBinding; - myHttpAddressBinding->Location = "http://localhost/ServiceDescription_Read/AddService_CS.asmx"; - myHttpGetPort->Extensions->Add( myHttpAddressBinding ); - - // Add the ports to the service. - myService->Ports->Add( myHttpGetPort ); - myService->Ports->Add( mySoapPort ); - - // Add the service to the ServiceCollection. - myServiceDescription->Services->Insert( 1, myService ); - // - - // - // Create a new XmlTextWriter object. - XmlTextWriter^ myWriter = gcnew XmlTextWriter( "output.wsdl",Encoding::UTF8 ); - myWriter->Formatting = Formatting::Indented; - - // Write the WSDL. - myServiceDescription->Write( myWriter ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read1/CPP/servicedescription_read1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read1/CPP/servicedescription_read1.cpp deleted file mode 100644 index ce0c8097760e3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read1/CPP/servicedescription_read1.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// System::Web::Services::Description.Read(TextReader) -/* -The following example demonstrates the 'Read(TextReader)' method of -'ServiceDescription' class.A ServiceDescription instance is -obtained from existing Wsdl::Name property of Bindings in the -ServiceDescription is displayed to console. -*/ -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; -using namespace System::Xml; -using namespace System::IO; - -int main() -{ - try - { - // - ServiceDescription^ myDescription = gcnew ServiceDescription; - - // Create a StreamReader to read a WSDL file. - TextReader^ myTextReader = gcnew StreamReader( "MyWsdl.wsdl" ); - myDescription = ServiceDescription::Read( myTextReader ); - Console::WriteLine( "Bindings are: " ); - - // Display the Bindings present in the WSDL file. - System::Collections::IEnumerator^ myEnum = myDescription->Bindings->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Binding^ myBinding = safe_cast(myEnum->Current); - Console::WriteLine( myBinding->Name ); - } - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read2/CPP/servicedescription_read2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read2/CPP/servicedescription_read2.cpp deleted file mode 100644 index 11b98b37d9b09..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Read2/CPP/servicedescription_read2.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// System::Web::Services::Description.Read(StreamReader) -/* -The following example demonstrates the 'Read(StreamReader)' method of -'ServiceDescription' class.A ServiceDescription instance is -obtained from existing Wsdl. Name property of Bindings in the -ServiceDescription is displayed to console. -*/ -#using - -// #using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Description; -using namespace System::Xml; -using namespace System::IO; - -int main() -{ - try - { - // - // Create a StreamReader to read a WSDL file. - StreamReader^ myStreamReader = gcnew StreamReader( "MyWsdl.wsdl" ); - ServiceDescription^ myDescription = ServiceDescription::Read( myStreamReader ); - Console::WriteLine( "Bindings are: " ); - - // Display the Bindings present in the WSDL file. - System::Collections::IEnumerator^ myEnum = myDescription->Bindings->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Binding^ myBinding = safe_cast(myEnum->Current); - Console::WriteLine( myBinding->Name ); - } - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Types/CPP/servicedescription_types.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Types/CPP/servicedescription_types.cpp deleted file mode 100644 index 306781ed27162..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/ServiceDescription_Types/CPP/servicedescription_types.cpp +++ /dev/null @@ -1,101 +0,0 @@ - - -// System.Web.Services.Description.ServiceDescription.Types -// System.Web.Services.Description.ServiceDescription.Write(Stream) -/* -The following program demonstrates the 'Write' method and 'Types' property -of ServiceDescription class.An existing WSDL document is read. -Types of the SericeDescription are removed.New Types are constructed. -Types are then added to ServiceDescription .A new WSDL file is created as output. -*/ -#using -#using -#using - -using namespace System; -using namespace System::Text; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -// This function creates a XmlComplex Element. -XmlSchemaElement^ CreateComplexTypeXmlElement( String^ minoccurs, String^ maxoccurs, String^ name, XmlQualifiedName^ schemaTypeName ) -{ - XmlSchemaElement^ myXmlSchemaElement = gcnew XmlSchemaElement; - myXmlSchemaElement->MinOccursString = minoccurs; - myXmlSchemaElement->MaxOccursString = maxoccurs; - myXmlSchemaElement->Name = name; - myXmlSchemaElement->SchemaTypeName = schemaTypeName; - return myXmlSchemaElement; -} - -int main() -{ - try - { - // Read the existing WSDL. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Input_CS.wsdl" ); - - // - myServiceDescription->Types->Schemas->Remove( myServiceDescription->Types->Schemas[ 0 ] ); - XmlSchema^ myXmlSchema = gcnew XmlSchema; - myXmlSchema->AttributeFormDefault = XmlSchemaForm::Qualified; - myXmlSchema->ElementFormDefault = XmlSchemaForm::Qualified; - myXmlSchema->TargetNamespace = myServiceDescription->TargetNamespace; - XmlSchemaElement^ myXmlElement1 = gcnew XmlSchemaElement; - myXmlElement1->Name = "Add"; - XmlSchemaComplexType^ myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - XmlSchemaSequence^ myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "a", gcnew XmlQualifiedName( "s:float" ) ) ); - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "b", gcnew XmlQualifiedName( "s:float" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlElement1->SchemaType = myXmlSchemaComplexType; - myXmlSchema->Items->Add( myXmlElement1 ); - XmlSchemaElement^ myXmlElement2 = gcnew XmlSchemaElement; - myXmlElement2->Name = "AddResponse"; - myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "AddResult", gcnew XmlQualifiedName( "s:float" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlElement2->SchemaType = myXmlSchemaComplexType; - myXmlSchema->Items->Add( myXmlElement2 ); - XmlSchemaElement^ myXmlElement3 = gcnew XmlSchemaElement; - myXmlElement3->Name = "Subtract"; - myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "a", gcnew XmlQualifiedName( "s:float" ) ) ); - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "b", gcnew XmlQualifiedName( "s:float" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlElement3->SchemaType = myXmlSchemaComplexType; - myXmlSchema->Items->Add( myXmlElement3 ); - XmlSchemaElement^ myXmlElement4 = gcnew XmlSchemaElement; - myXmlElement4->Name = "SubtractResponse"; - myXmlSchemaComplexType = gcnew XmlSchemaComplexType; - myXmlSchemaSequence = gcnew XmlSchemaSequence; - myXmlSchemaSequence->Items->Add( CreateComplexTypeXmlElement( "1", "1", "SubtractResult", gcnew XmlQualifiedName( "s:int" ) ) ); - myXmlSchemaComplexType->Particle = myXmlSchemaSequence; - myXmlElement4->SchemaType = myXmlSchemaComplexType; - myXmlSchema->Items->Add( myXmlElement4 ); - - // Add the schemas to the Types property of the ServiceDescription. - myServiceDescription->Types->Schemas->Add( myXmlSchema ); - // - - // - FileStream^ myFileStream = gcnew FileStream( "output.wsdl",FileMode::OpenOrCreate,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - - // Write the WSDL. - Console::WriteLine( "Writing a new WSDL file." ); - myServiceDescription->Write( myStreamWriter ); - myStreamWriter->Close(); - myFileStream->Close(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught! {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Service_Class4/CPP/service_class.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Service_Class4/CPP/service_class.cpp deleted file mode 100644 index 5d5e1df7929b6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Service_Class4/CPP/service_class.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// System.Web.Services.Description.Service.Ports -// System.Web.Services.Description.Service.Extensions -// System.Web.Services.Description.Service.Service() -// System.Web.Services.Description.Service.Name - -/*The following sample demonstrates the properties 'Ports','Extensions','Name' and -constructor 'Service()'.This sample reads the contents of a file 'MathService_cs.wsdl' -into a 'ServiceDescription' instance. It gets the collection of Service -instances from 'ServiceDescription'. It then removes a 'Service' from the collection and -creates a new 'Service' and adds it into collection. It writes a new web service description -file 'MathService_New.wsdl'. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -Port^ CreatePort( String^ PortName, String^ BindingName, String^ targetNamespace ) -{ - Port^ myPort = gcnew Port; - myPort->Name = PortName; - myPort->Binding = gcnew XmlQualifiedName( BindingName,targetNamespace ); - - // Create a SoapAddress extensibility element to add to the port. - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/Service_Class/MathService_CS.asmx"; - myPort->Extensions->Add( mySoapAddressBinding ); - return myPort; -} - -int main() -{ - try - { - // - // - // - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); - ServiceCollection^ myServiceCollection = myServiceDescription->Services; - int noOfServices = myServiceCollection->Count; - Console::WriteLine( "\nTotal number of services: {0}", noOfServices ); - - // Get a reference to the service. - Service^ myOldService = myServiceCollection[ 0 ]; - Console::WriteLine( "No. of Ports in the Service{0}", myServiceCollection[ 0 ]->Ports->Count ); - Console::WriteLine( "These are the ports in the service:" ); - for ( int i = 0; i < myOldService->Ports->Count; i++ ) - Console::WriteLine( "Port name: {0}", myOldService->Ports[ i ]->Name ); - Console::WriteLine( "Service name: {0}", myOldService->Name ); - Service^ myService = gcnew Service; - myService->Name = "MathService"; - - // Add the ports to the newly created service. - for ( int i = 0; i < myOldService->Ports->Count; i++ ) - { - String^ PortName = myServiceCollection[ 0 ]->Ports[ i ]->Name; - String^ BindingName = myServiceCollection[ 0 ]->Ports[ i ]->Binding->Name; - myService->Ports->Add( CreatePort( PortName, BindingName, myServiceDescription->TargetNamespace ) ); - - } - Console::WriteLine( "Newly created ports -" ); - for ( int i = 0; i < myService->Ports->Count; i++ ) - Console::WriteLine( "Port Name: {0}", myOldService->Ports[ i ]->Name ); - - // Add the extensions to the newly created service. - int noOfExtensions = myOldService->Extensions->Count; - Console::WriteLine( "No. of extensions: {0}", noOfExtensions ); - if ( noOfExtensions > 0 ) - { - for ( int i = 0; i < myOldService->Ports->Count; i++ ) - myService->Extensions->Add( myServiceCollection[ 0 ]->Extensions[ i ] ); - } - - // Remove the service from the collection. - myServiceCollection->Remove( myOldService ); - - // Add the newly created service. - myServiceCollection->Add( myService ); - myServiceDescription->Write( "MathService_New.wsdl" ); - // - // - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SinkProviders/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SinkProviders/CPP/source.cpp deleted file mode 100644 index 4386b6e2533ed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SinkProviders/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Security::Permissions; - -[SecurityPermission(SecurityAction::Demand)] -int main() -{ - // - IDictionary^ prop = gcnew Hashtable; - prop[ "port" ] = 9000; - IClientChannelSinkProvider^ clientChain = gcnew BinaryClientFormatterSinkProvider; - IServerChannelSinkProvider^ serverChain = gcnew SoapServerFormatterSinkProvider; - serverChain->Next = gcnew BinaryServerFormatterSinkProvider; - ChannelServices::RegisterChannel( gcnew HttpChannel( prop,clientChain,serverChain ) ); - // - - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp deleted file mode 100644 index 076a9f1908851..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp +++ /dev/null @@ -1,126 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; -using namespace System::ComponentModel; -public ref class Group -{ -public: - - // The default is set to .NET. - - [DefaultValue(".NET")] - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Setting the GroupName to '.NET' is like not setting it at all - // because it is the default value. So no value will be - // serialized, and on deserialization it will appear as a blank. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // The specifies that the default value is now - // 'Team1'. So setting the GroupName to '.NET' means - // the value will be serialized. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void DeserializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(mySerializer->Deserialize( reader )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine(); - } - - void DeserializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(overRideSerializer->Deserialize( reader )); - Console::WriteLine( myGroup->GroupName ); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - - // Create a new DefaultValueAttribute Object* for the GroupName - // property. - DefaultValueAttribute^ newDefault = gcnew DefaultValueAttribute( "Team1" ); - soapAtts->SoapDefaultValue = newDefault; - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer Object*. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapOriginal.xml" ); - test->SerializeOverride( "mySoapAttributeOverridesideAttributes.xml" ); - test->DeserializeOriginal( "SoapOriginal.xml" ); - test->DeserializeOverride( "mySoapAttributeOverridesideAttributes.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp deleted file mode 100644 index 6c2fca3bb4d6d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -//using namespace System::Runtime::Remoting::Metadata; -public ref class Vehicle -{ -public: - String^ licenseNumber; -}; - - -[SoapInclude(Vehicle::typeid)] -public ref class Group -{ -public: - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [SoapAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [SoapAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; - - [SoapElement(DataType="nonNegativeInteger",ElementName="PosInt")] - String^ PostitiveInt; - Vehicle^ GroupVehicle; -}; - -public ref class Run -{ -public: - void SerializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can generate encoded SOAP messages. - XmlSerializer^ mySerializer = ReturnSOAPSerializer(); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - - -private: - Group^ MakeGroup() - { - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2002,5,2); - myGroup->Today = myDate; - myGroup->PostitiveInt = "10000"; - myGroup->GroupVehicle = gcnew Vehicle; - myGroup->GroupVehicle->licenseNumber = "1234"; - return myGroup; - } - -public: - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can generate encoded SOAP messages. - XmlSerializer^ mySerializer = ReturnSOAPSerializer(); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - -private: - XmlSerializer^ ReturnSOAPSerializer() - { - - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - return gcnew XmlSerializer( myMapping ); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeObject( "SoapAtts.xml" ); - test->DeserializeObject( "SoapAtts.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp deleted file mode 100644 index ca2b9a2176d5f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Group -{ -public: - - // This attribute will be overridden. - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - - // Create a new SoapAttributeAttribute to the - // one applied to the Group class. The resulting XML - // stream will use the new namespace and attribute name. - SoapAttributeAttribute^ mySoapAttribute = gcnew SoapAttributeAttribute; - mySoapAttribute->AttributeName = "TeamName"; - - // Change the Namespace. - mySoapAttribute->Namespace = "http://www.cohowinery.com"; - mySoapAttributes->SoapAttribute = mySoapAttribute; - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", mySoapAttributes ); - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "SoapOveride.xml" ); -} - -// -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp deleted file mode 100644 index 723d53337e03b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - // Override the serialization of this member. - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - SoapElementAttribute^ mySoapElement = gcnew SoapElementAttribute; - mySoapElement->ElementName = "TeamName"; - mySoapAttributes->SoapElement = mySoapElement; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", mySoapAttributes ); - - // Get the SoapAttributes with the Item property. - SoapAttributes^ thisSoapAtts = mySoapAttributeOverrides[Group::typeid, "GroupName"]; - Console::WriteLine( "New serialized element name: {0}", thisSoapAtts->SoapElement->ElementName ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))-> - ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "GetSoapAttributes.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp deleted file mode 100644 index e35e9d519f261..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// The name of this type will be overridden using -// the SoapTypeAttribute. -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - SoapTypeAttribute^ mySoapType = gcnew SoapTypeAttribute; - mySoapType->TypeName = "Team"; - mySoapAttributes->SoapType = mySoapType; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( Group::typeid, mySoapAttributes ); - - // Get the SoapAttributes with the Item property. - SoapAttributes^ thisSoapAtts = mySoapAttributeOverrides[ Group::typeid ]; - Console::WriteLine( "New serialized type name: {0}", thisSoapAtts->SoapType->TypeName ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))-> - ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "GetSoapAttributes2.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributes1/CPP/s.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributes1/CPP/s.cpp deleted file mode 100644 index 97fc8013fb41f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributes1/CPP/s.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Serialization::Formatters::Soap; -using namespace System::Runtime::Remoting::Metadata; - -// A test Object* that needs to be serialized -// -[Serializable] -[SoapTypeAttribute(XmlNamespace="MyXmlNamespace")] -public ref class TestSimpleObject -{ -public: - int member1; - - [SoapFieldAttribute(XmlElementName="MyXmlElement")] String^ member2; - - String^ member3; - double member4; - - // A field that is not serialized. - - [NonSerialized] String^ member5; - - TestSimpleObject() - { - member1 = 11; - member2 = "hello"; - member3 = "hello"; - member4 = 3.14159265; - member5 = "hello world!"; - } -}; -// - -int main() -{ - // Creates a new TestSimpleObject Object^. - TestSimpleObject^ obj = gcnew TestSimpleObject; - - // Opens a file and serializes the Object^ into it in binary format. - Stream^ stream = File::Open( "data.xml", FileMode::Create ); - SoapFormatter^ formatter = gcnew SoapFormatter; - formatter->Serialize( stream, obj ); - stream->Close(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp deleted file mode 100644 index cd4ad348629fe..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp +++ /dev/null @@ -1,246 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; -ref class Car; - -// SoapInclude allows Vehicle to accept Car type. - -[SoapInclude(Car::typeid)] -public ref class Vehicle abstract -{ -public: - String^ licenseNumber; - DateTime makeDate; -}; - -public ref class Car: public Vehicle{}; - -public enum class GroupType -{ - // These enums can be overridden. - [SoapEnum("Small")] - A, - [SoapEnum("Large")] - B -}; - -public ref class Group -{ -public: - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [SoapAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [SoapAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; - - [SoapElement(DataType="nonNegativeInteger",ElementName="PosInt")] - String^ PostitiveInt; - - // This is ignored when serialized unless it's overridden. - - [SoapIgnore] - bool IgnoreThis; - GroupType Grouptype; - Vehicle^ MyVehicle; - - // The SoapInclude allows the method to return a Car. - - [SoapInclude(Car::typeid)] - Vehicle^ myCar( String^ licNumber ) - { - Vehicle^ v; - if ( licNumber->Equals( "" ) ) - { - v = gcnew Car; - v->licenseNumber = "!!!!!!"; - } - else - { - v = gcnew Car; - v->licenseNumber = licNumber; - } - - return v; - } -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapOriginal.xml" ); - test->SerializeOverride( "SoapOverrides.xml" ); - test->DeserializeOriginal( "SoapOriginal.xml" ); - test->DeserializeOverride( "SoapOverrides.xml" ); - } - - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - -private: - Group^ MakeGroup() - { - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2002,5,2); - myGroup->Today = myDate; - myGroup->PostitiveInt = "10000"; - myGroup->IgnoreThis = true; - myGroup->Grouptype = GroupType::B; - Car^ thisCar = dynamic_cast(myGroup->myCar( "1234566" )); - myGroup->MyVehicle = thisCar; - return myGroup; - } - -public: - void DeserializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - - void DeserializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(overRideSerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - ReadGroup( myGroup ); - } - -private: - void ReadGroup( Group^ myGroup ) - { - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->GroupNumber[ 0 ] ); - Console::WriteLine( myGroup->GroupNumber[ 1 ] ); - Console::WriteLine( myGroup->Today ); - Console::WriteLine( myGroup->PostitiveInt ); - Console::WriteLine( myGroup->IgnoreThis ); - Console::WriteLine(); - } - - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - SoapElementAttribute^ mySoapElement = gcnew SoapElementAttribute; - mySoapElement->ElementName = "xxxx"; - soapAtts->SoapElement = mySoapElement; - mySoapAttributeOverrides->Add( Group::typeid, "PostitiveInt", soapAtts ); - - // Override the IgnoreThis property. - SoapIgnoreAttribute^ myIgnore = gcnew SoapIgnoreAttribute; - soapAtts = gcnew SoapAttributes; - soapAtts->SoapIgnore = false; - mySoapAttributeOverrides->Add( Group::typeid, "IgnoreThis", soapAtts ); - - // Override the GroupType enumeration. - soapAtts = gcnew SoapAttributes; - SoapEnumAttribute^ xSoapEnum = gcnew SoapEnumAttribute; - xSoapEnum->Name = "Over1000"; - soapAtts->GroupType::SoapEnum = xSoapEnum; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( GroupType::typeid, "A", soapAtts ); - - // Create second enumeration and add it. - soapAtts = gcnew SoapAttributes; - xSoapEnum = gcnew SoapEnumAttribute; - xSoapEnum->Name = "ZeroTo1000"; - soapAtts->GroupType::SoapEnum = xSoapEnum; - mySoapAttributeOverrides->Add( GroupType::typeid, "B", soapAtts ); - - // Override the Group type. - soapAtts = gcnew SoapAttributes; - SoapTypeAttribute^ soapType = gcnew SoapTypeAttribute; - soapType->TypeName = "Team"; - soapAtts->SoapType = soapType; - mySoapAttributeOverrides->Add( Group::typeid, soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapBindingStyle_Rpc/CPP/soapbindingstyle_rpc.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapBindingStyle_Rpc/CPP/soapbindingstyle_rpc.cpp deleted file mode 100644 index 477f2e9539d73..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapBindingStyle_Rpc/CPP/soapbindingstyle_rpc.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// System::Web::Services::Description.SoapBindingStyle::Rpc -// System::Web::Services::Description.SoapBindingUse::Encoded -// System::Web::Services::Description.SoapBodyBinding::Encoding -// System::Web::Services::Description.SoapBodyBinding::Namespace -// System::Web::Services::Description.SoapHeaderBinding::Encoding -// System::Web::Services::Description.SoapHeaderBinding::Namespace - -/* -The following example demonstrates the 'Rpc' member of 'SoapBindingStyle' -enumeration , 'Encoded' member of 'SoapBindingUse' enumeration , 'Encoding' -and 'Namespace' properties of 'SoapBodyBinding' class and 'Encoding' -and 'Namespace' properties of 'SoapHeaderBinding' class. -It takes as input a wsdl file which does not contain a binding for SOAP. -By using the 'Read' method of 'ServiceDescription' class it gets a 'ServiceDescription' Object*. -It uses the SOAP protocol related classes and creates 'Binding' element -of 'SOAP' protocol which are then added to the 'ServiceDescription' Object*. -An output wsdl file is generated from 'ServiceDescription' Object* which -could be used for generating a proxy. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myServiceDescription = - ServiceDescription::Read( "SoapBindingStyleInput_cpp.wsdl" ); - Binding^ myBinding = gcnew Binding; - myBinding->Name = "SOAPSvrMgr_SOAPBinding"; - myBinding->Type = gcnew XmlQualifiedName( "tns:SOAPSvrMgr_portType" ); - -// - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - // Message to be transmitted contains parameters to call a procedure. - mySoapBinding->Style = SoapBindingStyle::Rpc; - myBinding->Extensions->Add( mySoapBinding ); -// - - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "GetServerStats"; - - SoapOperationBinding^ mySoapOperationBinding = - gcnew SoapOperationBinding; - mySoapOperationBinding->SoapAction = - "http://tempuri.org/soapsvcmgr/GetServerStats"; - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - - // Create InputBinding for operation for the 'SOAP' protocol. - InputBinding^ myInputBinding = gcnew InputBinding; - -// -// -// - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - // Encode SOAP body using rules specified by the 'Encoding' property. - mySoapBodyBinding->Use = SoapBindingUse::Encoded; - // Set URI representing the encoding style for encoding the body. - mySoapBodyBinding->Encoding = "http://schemas.xmlsoap.org/soap/encoding/"; - // Set the Uri representing the location of the specification - // for encoding of content not defined by 'Encoding' property'. - mySoapBodyBinding->Namespace = "http://tempuri.org/soapsvcmgr/"; - myInputBinding->Extensions->Add( mySoapBodyBinding ); -// -// -// - -// -// - SoapHeaderBinding^ mySoapHeaderBinding = gcnew SoapHeaderBinding; - mySoapHeaderBinding->Message = - gcnew XmlQualifiedName( "tns:Soapsvcmgr_Headers_Request" ); - mySoapHeaderBinding->Part = "AuthCS"; - // Encode SOAP header using rules specified by the 'Encoding' property. - mySoapHeaderBinding->Use = SoapBindingUse::Encoded; - // Set URI representing the encoding style for encoding the header. - mySoapHeaderBinding->Encoding = "http://schemas.xmlsoap.org/soap/encoding/"; - // Set the Uri representing the location of the specification - // for encoding of content not defined by 'Encoding' property'. - mySoapHeaderBinding->Namespace = "http://tempuri.org/SOAPSvr/soapsvcmgr/headers.xsd"; - // Add mySoapHeaderBinding to the 'myInputBinding' Object*. - myInputBinding->Extensions->Add( mySoapHeaderBinding ); -// -// - - // Create OutputBinding for operation. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - mySoapHeaderBinding->Part = "AuthSC"; - mySoapHeaderBinding->Message = - gcnew XmlQualifiedName( "tns:Soapsvcmgr_Headers_Response" ); - myOutputBinding->Extensions->Add( mySoapHeaderBinding ); - - // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - myBinding->Operations->Add( myOperationBinding ); - - myServiceDescription->Bindings->Add( myBinding ); - myServiceDescription->Write( "SoapBindingStyleOutput_cpp.wsdl" ); - Console::WriteLine( "'SoapBindingStyleOutput_cpp.wsdl' file is generated." ); - Console::WriteLine( "Proxy could be created using command" + - " 'wsdl SoapBindingStyleOutput_cpp.wsdl'" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapBinding_SoapOperationBinding/CPP/soapprotocol.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapBinding_SoapOperationBinding/CPP/soapprotocol.cpp deleted file mode 100644 index 80ca9900bb591..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapBinding_SoapOperationBinding/CPP/soapprotocol.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// System.Web.Services.Description.SoapBinding.ctor -// System.Web.Services.Description.SoapBinding.Transport -// System.Web.Services.Description.SoapBinding.Style -// System.Web.Services.Description.SoapBindingStyle.Document -// System.Web.Services.Description.SoapOperationBinding.ctor -// System.Web.Services.Description.SoapOperationBinding.SoapAction -// System.Web.Services.Description.SoapOperationBinding.Style -// System.Web.Services.Description.SoapBodyBinding.ctor -// System.Web.Services.Description.SoapBodyBinding.Use -// System.Web.Services.Description.SoapBindingUse.Literal -// System.Web.Services.Description.SoapAddressBinding.ctor -// System.Web.Services.Description.SoapAddressBinding.Location - -/* -The following example demonstrates the 'SoapBinding' constructor,'Transport','Style' -properties of 'SoapBinding' class,'Document' member of 'SoapBindingStyle' enum, -'SoapOperationBinding' constructor,'SoapAction','Style' properties of 'SoapOperationBinding' -class, 'SoapBodyBinding' contructor,'Use' property of 'SoapBodyBinding' class, -'Literal' member of 'SoapBindingUse' enum and 'SoapAddressBinding' constructor, 'Location' -property of class 'SoapAddressBinding'. - -It takes as input a wsdl file which supports two protocols 'HttpGet' and 'HttpPost' . -By using the 'Read' method of 'ServiceDescription' class it gets a 'ServiceDescription' -object. It uses the SOAP protocol related classes and creates 'Binding','Port', -'PortType' and 'Message' elements of 'SOAP' protocol. It adds all these elements to -the 'ServiceDescription' object. The 'ServiceDescription' object creates another -wsdl file which supports 'SOAP' also. This wsdl file is used to generate a proxy -which is used by the .aspx file. -Note: To run the example run the makefile provided and open the '.aspx' file in browser. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myDescription = ServiceDescription::Read( "AddNumbersInput_cs.wsdl" ); - - // Create a 'Binding' object for the 'SOAP' protocol. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "Service1Soap"; - XmlQualifiedName^ qualifiedName = gcnew XmlQualifiedName( "s0:Service1Soap" ); - myBinding->Type = qualifiedName; - - // - // - // - // - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - - // Add the 'SoapBinding' object to the 'Binding' object. - myBinding->Extensions->Add( mySoapBinding ); - // - // - // - // - - // Create the 'OperationBinding' object for the 'SOAP' protocol. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - - // - // - // - // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->SoapAction = "http://tempuri.org/AddNumbers"; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - - // Add the 'SoapOperationBinding' object to 'OperationBinding' object. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - // - // - // - - // - // - // - // Create the 'InputBinding' object for the 'SOAP' protocol. - InputBinding^ myInput = gcnew InputBinding; - SoapBodyBinding^ mySoapBinding1 = gcnew SoapBodyBinding; - mySoapBinding1->Use = SoapBindingUse::Literal; - myInput->Extensions->Add( mySoapBinding1 ); - - // Add the 'InputBinding' object to 'OperationBinding' object. - myOperationBinding->Input = myInput; - - // Create the 'OutputBinding' object'. - OutputBinding^ myOutput = gcnew OutputBinding; - myOutput->Extensions->Add( mySoapBinding1 ); - - // Add the 'OutputBinding' object to 'OperationBinding' object. - myOperationBinding->Output = myOutput; - - // Add the 'OperationBinding' object to 'Binding' object. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' object to the ServiceDescription instance. - myDescription->Bindings->Add( myBinding ); - // - // - // - - // - // - Port^ soapPort = gcnew Port; - soapPort->Name = "Service1Soap"; - soapPort->Binding = gcnew XmlQualifiedName( "s0:Service1Soap" ); - - // Create a 'SoapAddressBinding' object for the 'SOAP' protocol. - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/Service1_cs.asmx"; - - // Add the 'SoapAddressBinding' object to the 'Port'. - soapPort->Extensions->Add( mySoapAddressBinding ); - - // Add the 'Port' object to the ServiceDescription instance. - myDescription->Services[ 0 ]->Ports->Add( soapPort ); - // - // - - // Create a 'PortType' object. for SOAP protocol. - PortType^ soapPortType = gcnew PortType; - soapPortType->Name = "Service1Soap"; - Operation^ soapOperation = gcnew Operation; - soapOperation->Name = "AddNumbers"; - OperationMessage^ soapInput = (OperationMessage^)(gcnew OperationInput); - soapInput->Message = gcnew XmlQualifiedName( "s0:AddNumbersSoapIn" ); - OperationMessage^ soapOutput = (OperationMessage^)(gcnew OperationOutput); - soapOutput->Message = gcnew XmlQualifiedName( "s0:AddNumbersSoapOut" ); - soapOperation->Messages->Add( soapInput ); - soapOperation->Messages->Add( soapOutput ); - - // Add the 'Operation' object to 'PortType' object. - soapPortType->Operations->Add( soapOperation ); - - // Add the 'PortType' object first to 'PortTypeCollection' object - // and then to 'ServiceDescription' object. - myDescription->PortTypes->Add( soapPortType ); - - // Create the 'Message' object. - Message^ soapMessage1 = gcnew Message; - soapMessage1->Name = "AddNumbersSoapIn"; - - // Create the 'MessageParts' object. - MessagePart^ soapMessagePart1 = gcnew MessagePart; - soapMessagePart1->Name = "parameters"; - soapMessagePart1->Element = gcnew XmlQualifiedName( "s0:AddNumbers" ); - - // Add the 'MessagePart' object to 'Messages' object. - soapMessage1->Parts->Add( soapMessagePart1 ); - - // Create another 'Message' object. - Message^ soapMessage2 = gcnew Message; - soapMessage2->Name = "AddNumbersSoapOut"; - MessagePart^ soapMessagePart2 = gcnew MessagePart; - soapMessagePart2->Name = "parameters"; - soapMessagePart2->Element = gcnew XmlQualifiedName( "s0:AddNumbersResponse" ); - - // Add the 'MessagePart' object to second 'Message' object. - soapMessage2->Parts->Add( soapMessagePart2 ); - - // Add the 'Message' objects to 'ServiceDescription'. - myDescription->Messages->Add( soapMessage1 ); - myDescription->Messages->Add( soapMessage2 ); - - // Write the 'ServiceDescription' object as a WSDL file. - myDescription->Write( "AddNumbersOut_cs.wsdl" ); - Console::WriteLine( " 'AddNumbersOut_cs.Wsdl' file was generated" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapBodyBinding_Parts/CPP/soapbodybinding_parts.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapBodyBinding_Parts/CPP/soapbodybinding_parts.cpp deleted file mode 100644 index 72d797fd57454..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapBodyBinding_Parts/CPP/soapbodybinding_parts.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// System.Web.Services.Description.SoapBinding.Namespace -// System.Web.Services.Description.SoapBodyBinding.Parts - -/* -The following example demonstrates the 'Namespace' field of 'SoapBinding' class -and 'parts' property of 'SoapBodyBinding' class. -It takes a wsdl file which supports two protocols 'HttpGet' and 'HttpPost' as input. By -using the 'Read' method of 'ServiceDescription' class it gets the 'ServiceDescription' -object. It uses the SOAP protocol related classes to create 'Binding' elements of -'SOAP' protocol. It adds all the elements to the 'ServiceDescription' object. The -'ServiceDescription' object creates another wsdl file which supports 'SOAP' protocol -also. This wsdl file is used to generate a proxy which is used by the .aspx file. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myDescription = - ServiceDescription::Read( "AddNumbersInput_cs.wsdl" ); - // Create a 'Binding' object for the 'SOAP' protocol. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "Service1Soap"; - XmlQualifiedName^ qualifiedName = - gcnew XmlQualifiedName( "s0:Service1Soap" ); - - myBinding->Type = qualifiedName; - -// - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - // Get the URI for XML namespace of the SoapBinding class. - String^ myNameSpace = SoapBinding::Namespace; - Console::WriteLine( "The URI of the XML Namespace is :{0}", myNameSpace ); -// - - // Add the 'SoapBinding' object to the 'Binding' object. - myBinding->Extensions->Add( mySoapBinding ); - - // Create the 'OperationBinding' object for the 'SOAP' protocol. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - - // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. - SoapOperationBinding^ mySoapOperationBinding = - gcnew SoapOperationBinding; - mySoapOperationBinding->SoapAction = "http://tempuri.org/AddNumbers"; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - // Add the 'SoapOperationBinding' object to 'OperationBinding' object. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - -// - // Create the 'InputBinding' object for the 'SOAP' protocol. - InputBinding^ myInput = gcnew InputBinding; - SoapBodyBinding^ mySoapBinding1 = gcnew SoapBodyBinding; - mySoapBinding1->Use = SoapBindingUse::Literal; - - array^ myParts = gcnew array(1); - myParts[ 0 ] = "parameters"; - // Set the names of the message parts to appear in the SOAP body. - mySoapBinding1->Parts = myParts; - myInput->Extensions->Add( mySoapBinding1 ); - // Add the 'InputBinding' object to 'OperationBinding' object. - myOperationBinding->Input = myInput; - // Create the 'OutputBinding' object'. - OutputBinding^ myOutput = gcnew OutputBinding; - myOutput->Extensions->Add( mySoapBinding1 ); - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; -// - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myDescription->Bindings->Add( myBinding ); - - // Write the 'ServiceDescription' as a WSDL file. - myDescription->Write( "AddNumbersOut_cs.wsdl" ); - Console::WriteLine( " 'AddNumbersOut_cs.Wsdl' file was generated" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_BaseChannelSinkWithProperties/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_BaseChannelSinkWithProperties/CPP/makefile deleted file mode 100644 index d5fed0022ae33..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_BaseChannelSinkWithProperties/CPP/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: soapclientformattersinkprovider_customprovider.dll - -soapclientformattersinkprovider_customprovider.dll : soapclientformattersinkprovider_customprovider.cpp - cl /clr:pure /LD soapclientformattersinkprovider_customprovider.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_BaseChannelSinkWithProperties/CPP/soapclientformattersinkprovider_customprovider.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_BaseChannelSinkWithProperties/CPP/soapclientformattersinkprovider_customprovider.cpp deleted file mode 100644 index 406e0c2a195fa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_BaseChannelSinkWithProperties/CPP/soapclientformattersinkprovider_customprovider.cpp +++ /dev/null @@ -1,173 +0,0 @@ - -// System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider.CreateSink -// System.Runtime.Remoting.Channels.BaseChannelSinkWithProperties -/* -The following example demonstrates the 'BaseChannelSinkWithProperties' -class and 'CreateSink' method of 'SoapClientFormatterSinkProvider' class. -Custom client formatter provider is defined by implementing -the 'IClientChannelSinkProvider' interface and custom channel sink is -defined by inheriting 'BaseChannelSinkWithProperties' abstract class. -The sink provider chain has the custom sink provider and -'SoapClientFormatterSinkProvider'. The 'CreateSink' method is used to -return a sink to the caller and form the sink chain which is used to process -the message being passed through it. -*/ -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Security::Permissions; - -public ref class MyKey{}; - -// -[SecurityPermission(SecurityAction::Demand, Flags = SecurityPermissionFlag::Infrastructure)] -private ref class MyClientFormatterChannelSink: public BaseChannelSinkWithProperties, public IClientChannelSink, public IMessageSink -{ -private: - IClientChannelSink^ nextClientSink; - IMessageSink^ nextMessageSink; - -public: - MyClientFormatterChannelSink() - : nextClientSink( nullptr ), nextMessageSink( nullptr ) - {} - - MyClientFormatterChannelSink( IClientChannelSink^ nextSink, IMessageSink^ nextMsgSink ) - : BaseChannelSinkWithProperties() - { - nextClientSink = nextSink; - nextMessageSink = nextMsgSink; - } - - virtual void ProcessMessage( IMessage^ message, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) - { - nextClientSink->ProcessMessage( message, requestHeaders, requestStream, responseHeaders, responseStream ); - } - - - - virtual void AsyncProcessRequest( IClientChannelSinkStack^ sinkStack, IMessage^ msg, ITransportHeaders^ headers, Stream^ myStream ) - { - sinkStack->Push( this, nullptr ); - nextClientSink->AsyncProcessRequest( sinkStack, msg, headers, myStream ); - } - - virtual void AsyncProcessResponse( IClientResponseChannelSinkStack^ sinkStack, Object^ /*state*/, ITransportHeaders^ headers, Stream^ myStream ) - { - sinkStack->AsyncProcessResponse( headers, myStream ); - } - - virtual Stream^ GetRequestStream( IMessage^ /*msg*/, ITransportHeaders^ /*headers*/ ) - { - return nullptr; - } - - - property IClientChannelSink^ NextChannelSink - { - virtual IClientChannelSink^ get() - { - return nextClientSink; - } - - } - - property IMessageSink^ NextSink - { - virtual IMessageSink^ get() - { - return nextMessageSink; - } - - } - - virtual IMessageCtrl^ AsyncProcessMessage( IMessage^ /*msg*/, IMessageSink^ /*replySink*/ ) - { - return nullptr; - } - - virtual IMessage^ SyncProcessMessage( IMessage^ msg ) - { - return nextMessageSink->SyncProcessMessage( msg ); - } - - - property Object^ Item [Object^] - { - virtual Object^ get( Object^ key ) override - { - if ( key == MyKey::typeid ) - return this; - - return nullptr; - } - - virtual void set( Object^ /*value*/, Object^ /*key*/ ) override - { - throw gcnew NotSupportedException; - } - - } - - property ICollection^ Keys - { - virtual ICollection^ get() override - { - ArrayList^ myKeys = gcnew ArrayList( 1 ); - myKeys->Add( MyKey::typeid ); - return myKeys; - } - - } - -}; - - - -// -[SecurityPermission(SecurityAction::Demand, Flags = SecurityPermissionFlag::Infrastructure)] -public ref class MyClientFormatterProvider: public IClientChannelSinkProvider -{ -private: - IClientChannelSinkProvider^ nextProvider; - -public: - MyClientFormatterProvider() : nextProvider( nullptr ) {} - - virtual IClientChannelSink^ CreateSink( IChannelSender^ channel, String^ myUrl, Object^ remoteChannelData ) - { - // - IClientChannelSink^ nextSink = nullptr; - IMessageSink^ nextMsgSink = nullptr; - if ( nextProvider != nullptr ) - { - Console::WriteLine( "Next client sink provider is: {0}", nextProvider ); - - // Create a sink chain calling the next sink provider's - // 'CreateSink' method. - nextSink = nextProvider->CreateSink( channel, myUrl, remoteChannelData ); - nextMsgSink = dynamic_cast(nextSink); - } - // - return gcnew MyClientFormatterChannelSink( nextSink,nextMsgSink ); - } - - property IClientChannelSinkProvider^ Next - { - virtual IClientChannelSinkProvider^ get() - { - return nextProvider; - } - - virtual void set( IClientChannelSinkProvider^ value ) - { - nextProvider = value; - } - } -}; - - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/SoapClientFormatterSinkProvider_Next_Shared.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/SoapClientFormatterSinkProvider_Next_Shared.cpp deleted file mode 100644 index b8cd263ac3224..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/SoapClientFormatterSinkProvider_Next_Shared.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Supporting program for the 'SoapClientFormatterSinkProvider_Next_Server.cs' and - 'SoapClientFormatterSinkProvider_Next_Client.cs' - */ -using namespace System; - -public ref class HelloService : public MarshalByRefObject -{ - - static int n_instances; - -public: - HelloService() - { - n_instances++; - Console::WriteLine("HelloService activated - instance # {0}.", n_instances); - } - - ~HelloService() - { - Console::WriteLine("HelloService instance {0} destroyed.", n_instances); - n_instances--; - } - -public: - String^ HelloMethod(String^ name) - { - Console::WriteLine("HelloMethod called on HelloService instance {0}.", n_instances); - return "Hi, " + name + "."; - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/makefile deleted file mode 100644 index 19ed8e30a7038..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/makefile +++ /dev/null @@ -1,14 +0,0 @@ -all : soapclientformattersinkprovider_next_server.exe soapclientformattersinkprovider_next_client.exe - - -soapclientformattersinkprovider_next_server.exe : soapclientformattersinkprovider_next_server.cpp soapclientformattersinkprovider_customprovider.dll SoapClientFormatterSinkProvider_Next_Shared.dll - cl /clr:pure soapclientformattersinkprovider_next_server.cpp - -soapclientformattersinkprovider_next_client.exe : soapclientformattersinkprovider_next_client.cpp soapclientformattersinkprovider_customprovider.dll SoapClientFormatterSinkProvider_Next_Shared.dll - cl /clr:pure soapclientformattersinkprovider_next_client.cpp - -soapclientformattersinkprovider_customprovider.dll : soapclientformattersinkprovider_customprovider.cpp - cl /clr:pure /LD soapclientformattersinkprovider_customprovider.cpp - -SoapClientFormatterSinkProvider_Next_Shared.dll : SoapClientFormatterSinkProvider_Next_Shared.cpp - cl /clr:pure /LD SoapClientFormatterSinkProvider_Next_Shared.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_customprovider.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_customprovider.cpp deleted file mode 100644 index 269324a7eaf35..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_customprovider.cpp +++ /dev/null @@ -1,270 +0,0 @@ - -// System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider.CreateSink -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Messaging; - -public ref class MyKey{}; - -private ref class MyClientChannelSink: public BaseChannelObjectWithProperties, public IClientChannelSink -{ -private: - IClientChannelSink^ nextClientSink; - -public: - MyClientChannelSink() - : nextClientSink( nullptr ) - {} - - MyClientChannelSink( IClientChannelSink^ nextSink ) - : BaseChannelObjectWithProperties() - { - nextClientSink = nextSink; - } - - MyClientChannelSink( IChannelSender^ /*channel*/, String^ /*url*/, Object^ /*remoteChannelData*/, IClientChannelSink^ nextSink ) - : BaseChannelObjectWithProperties() - { - nextClientSink = nextSink; - } - - virtual void ProcessMessage( IMessage^ msg, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) - { - nextClientSink->ProcessMessage( msg, requestHeaders, requestStream, responseHeaders, responseStream ); - } - - virtual void AsyncProcessRequest( IClientChannelSinkStack^ sinkStack, IMessage^ msg, ITransportHeaders^ headers, Stream^ stream ) - { - sinkStack->Push( this, nullptr ); - nextClientSink->AsyncProcessRequest( sinkStack, msg, headers, stream ); - } - - virtual void AsyncProcessResponse( IClientResponseChannelSinkStack^ sinkStack, Object^ /*state*/, ITransportHeaders^ headers, Stream^ stream ) - { - sinkStack->AsyncProcessResponse( headers, stream ); - } - - virtual Stream^ GetRequestStream( IMessage^ /*msg*/, ITransportHeaders^ /*headers*/ ) - { - return nullptr; - } - - - property IClientChannelSink^ NextChannelSink - { - virtual IClientChannelSink^ get() - { - return nextClientSink; - } - - } - - property Object^ Item [Object^] - { - virtual Object^ get( Object^ key ) override - { - if ( key == MyKey::typeid ) - return this; - - return nullptr; - } - - virtual void set( Object^ /*value*/, Object^ /*key*/ ) override - { - throw gcnew NotSupportedException; - } - - } - - property ICollection^ Keys - { - virtual ICollection^ get() override - { - ArrayList^ myKeys = gcnew ArrayList( 1 ); - myKeys->Add( MyKey::typeid ); - return myKeys; - } - } -}; - -[System::Security::Permissions::PermissionSet(System::Security:: - Permissions::SecurityAction::Demand, Name = "FullTrust")] -public ref class MyClientProvider: public IClientChannelSinkProvider -{ -private: - IClientChannelSinkProvider^ nextProvider; - -public: - MyClientProvider() - : nextProvider( nullptr ) - {} - - MyClientProvider( IDictionary^ /*properties*/, ICollection^ /*providerData*/ ){} - - virtual IClientChannelSink^ CreateSink( IChannelSender^ channel, String^ myUrl, Object^ remoteChannelData ) - { - IClientChannelSink^ nextSink = nullptr; - if ( nextProvider != nullptr ) - { - nextSink = nextProvider->CreateSink( channel, myUrl, remoteChannelData ); - if ( nextSink == nullptr ) - return nullptr; - } - - return gcnew MyClientChannelSink( nextSink ); - } - - property IClientChannelSinkProvider^ Next - { - virtual IClientChannelSinkProvider^ get() - { - return nextProvider; - } - - virtual void set( IClientChannelSinkProvider^ value ) - { - nextProvider = value; - } - } -}; - -private ref class MyServerChannelSink: public BaseChannelObjectWithProperties, public IServerChannelSink -{ -private: - IServerChannelSink^ nextServerSink; - -public: - MyServerChannelSink() - : nextServerSink( nullptr ) - {} - - MyServerChannelSink( IServerChannelSink^ nextSink ) - : BaseChannelObjectWithProperties() - { - nextServerSink = nextSink; - } - - MyServerChannelSink( IChannelReceiver^ /*channel*/, IServerChannelSink^ nextSink ) - : BaseChannelObjectWithProperties() - { - nextServerSink = nextSink; - } - - virtual ServerProcessing ProcessMessage( IServerChannelSinkStack^ sinkStack, IMessage^ requestMsg, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]IMessage^% msg, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream ) - { - sinkStack->Push( this, nullptr ); - ServerProcessing processing = nextServerSink->ProcessMessage( sinkStack, requestMsg, requestHeaders, requestStream, msg, responseHeaders, responseStream ); - switch ( processing ) - { - case ServerProcessing::Complete: - sinkStack->Pop( this ); - break; - - case ServerProcessing::OneWay: - sinkStack->Pop( this ); - break; - - case ServerProcessing::Async: - sinkStack->Store( this, nullptr ); - break; - } - return processing; - } - - virtual void AsyncProcessResponse( IServerResponseChannelSinkStack^ sinkStack, Object^ /*state*/, IMessage^ msg, ITransportHeaders^ headers, Stream^ stream ) - { - sinkStack->AsyncProcessResponse( msg, headers, stream ); - } - - virtual Stream^ GetResponseStream( IServerResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, IMessage^ /*msg*/, ITransportHeaders^ /*headers*/ ) - { - return nullptr; - } - - property IServerChannelSink^ NextChannelSink - { - virtual IServerChannelSink^ get() - { - return nextServerSink; - } - - } - - property Object^ Item [Object^] - { - virtual Object^ get( Object^ key ) override - { - if ( key == MyKey::typeid ) - return this; - - return nullptr; - } - - virtual void set( Object^ /*value*/, Object^ /*key*/ ) override - { - throw gcnew NotSupportedException; - } - - } - - property ICollection^ Keys - { - virtual ICollection^ get() override - { - ArrayList^ myKeys = gcnew ArrayList( 1 ); - myKeys->Add( MyKey::typeid ); - return myKeys; - } - } -}; - -[System::Security::Permissions::PermissionSet(System::Security:: - Permissions::SecurityAction::Demand, Name = "FullTrust")] -public ref class MyServerProvider: public IServerChannelSinkProvider -{ -private: - IServerChannelSinkProvider^ nextProvider; - -public: - MyServerProvider() - : nextProvider( nullptr ) - {} - - MyServerProvider( IDictionary^ /*properties*/, ICollection^ /*providerData*/ ){} - - virtual void GetChannelData( IChannelDataStore^ /*channelData*/ ){} - - virtual IServerChannelSink^ CreateSink( IChannelReceiver^ channel ) - { - // - IServerChannelSink^ nextSink = nullptr; - if ( nextProvider != nullptr ) - { - Console::WriteLine( "The next server provider is:{0}", nextProvider ); - - // Create a sink chain calling the 'SaopServerFormatterProvider' - // 'CreateSink' method. - nextSink = nextProvider->CreateSink( channel ); - } - - return gcnew MyServerChannelSink( nextSink ); - // - } - - - property IServerChannelSinkProvider^ Next - { - virtual IServerChannelSinkProvider^ get() - { - return nextProvider; - } - - virtual void set( IServerChannelSinkProvider^ value ) - { - nextProvider = value; - } - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_next_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_next_client.cpp deleted file mode 100644 index 94a133d52d148..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_next_client.cpp +++ /dev/null @@ -1,51 +0,0 @@ - - -// System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider -// System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider.Next -/* - The following program demonstrates the 'SoapClientFormatterSinkProvider' class - and 'Next' property of 'SoapClientFormatterSinkProvider' class ,'CreateSink' - method and 'Next' property of 'ServerFormatterSinkProvider' class. - Custom client and server formatter provider are created by implementing - the interfaces IClientChannelSinkProvider and IServerChannelSinkProvider. - In the client side the custom client provider is assigned to 'Next' property - of 'SoapClientFormatterSinkProvider'. In the server side, the - 'BinaryServerFormatterSinkProvider' is assigned to 'Next' property of - 'SoapServerFormatterSinkProvider'. The 'CreateSink' method is used to return a - sink to the caller and form the sink chain which is used to process the message - being passed through it. -*/ -// -#using -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Channels; -int main() -{ - try - { - // - IClientChannelSinkProvider^ mySoapProvider = gcnew SoapClientFormatterSinkProvider; - IClientChannelSinkProvider^ myClientProvider = gcnew MyClientProvider; - - // Set the custom provider as the next 'IClientChannelSinkProvider' in the sink chain. - mySoapProvider->Next = myClientProvider; - // - - TcpChannel^ myTcpChannel = gcnew TcpChannel( nullptr,mySoapProvider,nullptr ); - ChannelServices::RegisterChannel( myTcpChannel ); - RemotingConfiguration::RegisterWellKnownClientType( HelloService::typeid, "tcp://localhost:8082/HelloServiceApplication/MyUri" ); - HelloService ^ myService = gcnew HelloService; - Console::WriteLine( myService->HelloMethod( "Welcome to .Net" ) ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception is raised at client side :{0}", ex->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_next_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_next_server.cpp deleted file mode 100644 index 17838fc6bfbbc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientFormatterSinkProvider_Next_Create/CPP/soapclientformattersinkprovider_next_server.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -// System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider.Next; -#using -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Collections; -int main() -{ - try - { - IDictionary^ myDictionaryProperty = gcnew Hashtable; - myDictionaryProperty->Add( "port", 8082 ); - - // - IServerChannelSinkProvider^ myCustomProvider = gcnew MyServerProvider; - IServerChannelSinkProvider^ mySoapProvider = gcnew SoapServerFormatterSinkProvider; - myCustomProvider->Next = mySoapProvider; - - // Set the Binary provider as the next 'IServerChannelSinkProvider' in the - // sink chain. - mySoapProvider->Next = gcnew BinaryServerFormatterSinkProvider; - // - - TcpChannel^ myTcpChannel = gcnew TcpChannel( myDictionaryProperty,nullptr,myCustomProvider ); - ChannelServices::RegisterChannel( myTcpChannel ); - RemotingConfiguration::ApplicationName = "HelloServiceApplication"; - RemotingConfiguration::RegisterWellKnownServiceType( HelloService::typeid, "MyUri", WellKnownObjectMode::Singleton ); - Console::WriteLine( "Press enter to stop this process." ); - Console::ReadLine(); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception is raised at server side: {0}", ex->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientMessage/CPP/SoapClientMessage.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientMessage/CPP/SoapClientMessage.cpp deleted file mode 100644 index 6a3351cd473d7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientMessage/CPP/SoapClientMessage.cpp +++ /dev/null @@ -1,269 +0,0 @@ -// System.Web.Services.Protocols.SoapClientMessage -// System.Web.Services.Protocols.SoapClientMessage.Action -// System.Web.Services.Protocols.SoapClientMessage.Client -// System.Web.Services.Protocols.SoapClientMessage.MethodInfo -// System.Web.Services.Protocols.SoapClientMessage.OneWay -// System.Web.Services.Protocols.SoapClientMessage.Url - -/* -The following example demonstrates the 'Action', 'Client', 'MethodInfo', -'OneWay' and 'Url' properties of the 'SoapClientMessage' class. -It extends the 'SoapExtension' class to create a class that is used to -log the SOAP messages transferred for a web service method invocation. -To associate this 'SoapExtension' class with the web service method on -the client proxy, a class that extends from 'SoapExtensionAttribute' is -used. This 'SoapExtensionAttribute' is applied to a client proxy method -which is associated with a web service method. Whenever this method is -invoked on the client side all the SOAP message that get transfered both -from the client and the server(which is hosting the web service) are -written into a log file. -*/ - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -ref class MySoapExtension; -ref class MathSvc; - -// A SoapExtensionAttribute that can be associated with an -// XML Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class MySoapExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - - // Set the name of the log file where SOAP messages will be stored. - MySoapExtensionAttribute() - : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - property Type^ ExtensionType - { - // Return the type of MySoapExtension. - Type^ get() - { - return typeid; - } - } - - property int Priority - { - // User can set priority of the SoapExtension. - int get() - { - return myPriority; - } - void set( int value ) - { - myPriority = value; - } - } - - property String^ Filename - { - String^ get() - { - return myFilename; - } - void set( String^ value ) - { - myFilename = value; - } - } -}; - -public ref class MySoapExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // Return the filename that is to log the SOAP messages. - Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) - { - return (dynamic_cast(attribute))->Filename; - } - - // Return the filename that is to log the SOAP messages. - Object^ GetInitializer( Type^ filename ) - { - return dynamic_cast(filename); - } - - // Save the name of the log file that will save the SOAP messages. - void Initialize( Object^ initializer ) - { - filename = dynamic_cast(initializer); - } - -// - // Process the SOAP message received and write to a log file. - void ProcessMessage( SoapMessage^ message ) - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( dynamic_cast(message) ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( dynamic_cast(message) ); - break; - case SoapMessageStage::AfterDeserialize: - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Write the contents of the outgoing SOAP message to the log file. - void WriteOutput( SoapClientMessage^ message ) - { -// -// -// -// -// - newStream->Position = 0; - FileStream^ myFileStream = gcnew FileStream( filename, FileMode::Append, - FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( - "================================== Request at {0}", DateTime::Now ); - - // Print to the log file the request header field for SoapAction header. - myStreamWriter->WriteLine( "The SoapAction Http request header field is: " ); - myStreamWriter->WriteLine( "\t{0}", message->Action ); - - // Print to the log file the type of the client that invoked - // the XML Web service method. - myStreamWriter->WriteLine( "The type of the client is: " ); - if ( (message->Client->GetType())->Equals( typeid ) ) - { - myStreamWriter->WriteLine( "\tMathSvc" ); - } - - // Print to the log file the method invoked by the client. - myStreamWriter->WriteLine( - "The method that has been invoked by the client is:" ); - myStreamWriter->WriteLine( "\t{0}", message->MethodInfo->Name ); - - // Print to the log file if the method invoked is OneWay. - if ( message->OneWay ) - { - myStreamWriter->WriteLine( - "The client doesn't wait for the server to finish processing" ); - } - else - { - myStreamWriter->WriteLine( - "The client waits for the server to finish processing" ); - } - - // Print to the log file the URL of the site that provides - // implementation of the method. - myStreamWriter->WriteLine( - "The URL of the XML Web service method that has been requested is: " ); - myStreamWriter->WriteLine( "\t{0}", message->Url ); - myStreamWriter->WriteLine( "The contents of the SOAP envelope are: " ); - myStreamWriter->Flush(); - - // Copy the contents of one stream to another. - Copy( newStream, myFileStream ); - myFileStream->Close(); - newStream->Position = 0; - - // Copy the contents of one stream to another. - Copy( newStream, oldStream ); -// -// -// -// -// - } -// - - // Write the contents of the incoming SOAP message to the log file. - void WriteInput( SoapClientMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ myFileStream = gcnew FileStream( filename, FileMode::Append, - FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( - "---------------------------------- Response at {0}", DateTime::Now ); - myStreamWriter->Flush(); - newStream->Position = 0; - Copy( newStream, myFileStream ); - myFileStream->Close(); - newStream->Position = 0; - } - - // Return a new MemoryStream for SOAP processing. - Stream^ ChainStream( Stream^ stream ) - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - // Utility method to copy the contents of one stream to another. - void Copy( Stream^ fromStream, Stream^ toStream ) - { - TextReader^ myTextReader = gcnew StreamReader( fromStream ); - TextWriter^ myTextWriter = gcnew StreamWriter( toStream ); - myTextWriter->WriteLine( myTextReader->ReadToEnd() ); - myTextWriter->Flush(); - } -}; - -[System::Web::Services::WebServiceBindingAttribute(Name="MathSvcSoap", - Namespace="http://tempuri.org/")] -public ref class MathSvc: public System::Web::Services::Protocols::SoapHttpClientProtocol -{ -public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MathSvc() - { - this->Url = "http://localhost/MathSvc_SoapClientMessage.asmx"; - } - - [System::Web::Services::Protocols::SoapDocumentMethodAttribute( - "http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - [MySoapExtensionAttribute] - Single Add( Single xValue, Single yValue ) - { - array^temp2 = {xValue,yValue}; - array^results = this->Invoke( "Add", temp2 ); - return safe_cast(results[ 0 ]); - } - - System::IAsyncResult^ BeginAdd( Single xValue, Single yValue, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^ temp3 = { xValue, yValue }; - return this->BeginInvoke( "Add", temp3, callback, asyncState ); - } - - Single EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return ( (Single)( results[ 0 ] ) ); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientMessage/CPP/SvcClient_SoapClientMessage.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientMessage/CPP/SvcClient_SoapClientMessage.cpp deleted file mode 100644 index a936611b24237..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapClientMessage/CPP/SvcClient_SoapClientMessage.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - This program is used as a client of the client proxy class. -*/ - -#using - -using namespace System; - -public ref class SvcClient -{ -public: - static void Main() - { - } -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp deleted file mode 100644 index bbc969c59c571..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp +++ /dev/null @@ -1,106 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Text; -public ref class Thing -{ -public: - - [SoapElement(IsNullable=true)] - String^ ThingName; -}; - -public ref class Transportation -{ -public: - - // The SoapElementAttribute specifies that the - // generated XML element name will be S"Wheels" - // instead of S"Vehicle". - - [SoapElement("Wheels")] - String^ Vehicle; - - [SoapElement(DataType="dateTime")] - DateTime CreationDate; - - [SoapElement(IsNullable=true)] - Thing^ thing; -}; - -public ref class Test -{ -public: - - // Return an XmlSerializer used for overriding. - XmlSerializer^ CreateSoapOverrider() - { - // Create the SoapAttributes and SoapAttributeOverrides objects. - SoapAttributes^ soapAttrs = gcnew SoapAttributes; - SoapAttributeOverrides^ soapOverrides = gcnew SoapAttributeOverrides; - - // Create an SoapElementAttribute to the Vehicles property. - SoapElementAttribute^ soapElement1 = gcnew SoapElementAttribute( "Truck" ); - - // Set the SoapElement to the Object*. - soapAttrs->SoapElement = soapElement1; - - // Add the SoapAttributes to the SoapAttributeOverrides,specifying the member to. - soapOverrides->Add( Transportation::typeid, "Vehicle", soapAttrs ); - - // Create the XmlSerializer, and return it. - XmlTypeMapping^ myTypeMapping = (gcnew SoapReflectionImporter( soapOverrides ))->ImportTypeMapping( Transportation::typeid ); - return gcnew XmlSerializer( myTypeMapping ); - } - - void SerializeOverride( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ ser = CreateSoapOverrider(); - - // Create the Object* and serialize it. - Transportation^ myTransportation = gcnew Transportation; - myTransportation->Vehicle = "MyCar"; - myTransportation->CreationDate = DateTime::Now; - myTransportation->thing = gcnew Thing; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, myTransportation ); - writer->WriteEndElement(); - writer->Close(); - } - - void SerializeObject( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ ser = gcnew XmlSerializer( Transportation::typeid ); - Transportation^ myTransportation = gcnew Transportation; - myTransportation->Vehicle = "MyCar"; - myTransportation->CreationDate = DateTime::Now; - myTransportation->thing = gcnew Thing; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, myTransportation ); - writer->WriteEndElement(); - writer->Close(); - } -}; - -int main() -{ - Test^ t = gcnew Test; - t->SerializeObject( "SoapElementOriginal.xml" ); - t->SerializeOverride( "SoapElementOverride.xml" ); - Console::WriteLine( "Finished writing two XML files." ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp deleted file mode 100644 index a91c48a0ab837..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp +++ /dev/null @@ -1,94 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class GroupType -{ - // Use the SoapEnumAttribute to instruct the XmlSerializer - // to generate Small and Large instead of A and B. - [SoapEnum("Small")] - A, - [SoapEnum("Large")] - B -}; - -public ref class Group -{ -public: - String^ GroupName; - GroupType Grouptype; -}; - -public ref class Run -{ -public: - void SerializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer Class. - XmlTypeMapping^ mapp = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( mapp ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the Class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - myGroup->Grouptype = GroupType::A; - - // Serialize the Class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeOverride( String^ fileName ) - { - SoapAttributeOverrides^ soapOver = gcnew SoapAttributeOverrides; - SoapAttributes^ SoapAtts = gcnew SoapAttributes; - - // Add a SoapEnumAttribute for the GroupType::A enumerator. - // Instead of 'A' it will be S"West". - SoapEnumAttribute^ soapEnum = gcnew SoapEnumAttribute( "West" ); - - // Override the S"A" enumerator. - SoapAtts->GroupType::SoapEnum = soapEnum; - soapOver->Add( GroupType::typeid, "A", SoapAtts ); - - // Add another SoapEnumAttribute for the GroupType::B enumerator. - // Instead of //B// it will be S"East". - SoapAtts = gcnew SoapAttributes; - soapEnum = gcnew SoapEnumAttribute; - soapEnum->Name = "East"; - SoapAtts->GroupType::SoapEnum = soapEnum; - soapOver->Add( GroupType::typeid, "B", SoapAtts ); - - // Create an XmlSerializer used for overriding. - XmlTypeMapping^ map = (gcnew SoapReflectionImporter( soapOver ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( map ); - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->Grouptype = GroupType::B; - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( fileName ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeObject( "SoapEnum.xml" ); - test->SerializeOverride( "SoapOverride.xml" ); - Console::WriteLine( "Fininished writing two files" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtension.GetInitializer-Type/CPP/traceextension.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtension.GetInitializer-Type/CPP/traceextension.cpp deleted file mode 100644 index f4f244fd8fea4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtension.GetInitializer-Type/CPP/traceextension.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Web::Services::Protocols; -using namespace System::IO; - -ref class TraceExtension; - -// Create a SoapExtensionAttribute for our SOAP Extension that can be -// applied to an XML Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class TraceExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ filename; // = "c:\\log.txt"; - int priority; - -public: - property Type^ ExtensionType - { - virtual Type^ get() override - { - return TraceExtension::typeid; - } - } - - property int Priority - { - virtual int get() override - { - return priority; - } - virtual void set( int value ) override - { - priority = value; - } - } - - property String^ Filename - { - String^ get() - { - return filename; - } - void set( String^ value ) - { - filename = value; - } - } -}; - -// Define a SOAP Extension that traces the SOAP request and SOAP response -// for the XML Web service method, the SOAP extension is applied to. -public ref class TraceExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // When the SOAP extension is accessed for the first time the XML Web service method it is applied - // is accessed store the file name passed in using the corresponding SoapExtensionAttribute. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) override - { - return ( (TraceExtensionAttribute^)( attribute ) )->Filename; - } - -// - // The extension was configured to run using a configuration file instead of an attribute applied to a - // specific XML Web service method. Return a file name based on the class implementing the XML Web service's type. -public: - virtual Object^ GetInitializer( Type^ WebServiceType ) override - { - // Return a file name to log the trace information to based on the passed in type. - return String::Format( "C:\\{0}.log", WebServiceType->FullName ); - } -// - - // Receive the filename stored by GetInitializer and store it in a member variable - // for this specific instance. - virtual void Initialize( Object^ initializer ) override - { - filename = (String^)( initializer ); - } - - // If the SoapMessageStage is such that the SoapRequest or SoapResponse is still in the SOAP - // format to be sent or received over the wire, save it out to filename passed in using the SoapExtensionAttribute - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - - case SoapMessageStage::AfterDeserialize: - break; - - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Save the Stream representing the SOAP request or SOAP response into a local memory buffer - virtual Stream^ ChainStream( Stream^ stream ) override - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - void WriteOutput( SoapMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "---------------------------------- Response at {0}", DateTime::Now ); - w->Flush(); - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - void WriteInput( SoapMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Append,FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - w->WriteLine( "================================== Request at {0}", DateTime::Now ); - w->Flush(); - newStream->Position = 0; - Copy( newStream, fs ); - fs->Close(); - newStream->Position = 0; - } - - void Copy( Stream^ from, Stream^ to ) - { - TextReader^ reader = gcnew StreamReader( from ); - TextWriter^ writer = gcnew StreamWriter( to ); - writer->WriteLine( reader->ReadToEnd() ); - writer->Flush(); - } -}; - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtensionAttribute/CPP/SoapExtensionAttribute.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtensionAttribute/CPP/SoapExtensionAttribute.cpp deleted file mode 100644 index 8084a23059614..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtensionAttribute/CPP/SoapExtensionAttribute.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// System.Web.Services.Protocols.SoapExtensionAttribute -// System.Web.Services.Protocols.SoapExtensionAttribute.ExtensionType -// System.Web.Services.Protocols.SoapExtensionAttribute.Priority - -/* -The following example demonstrates the 'ExtensionType' -and 'Priority' attribute of the 'SoapExtensionAttribute' class. -The program extends the 'SoapExtension' class to create a class -that is used to log the SOAP messages transferred for a web service -method invocation. To associate this 'SoapExtension' class with the -web service method on the client proxy, a class that extends from -'SoapExtensionAttribute' is used. This 'SoapExtensionAttribute' -is applied to a client proxy method which is associated with a -web service method. Whenever this method is invoked on the client -side all the SOAP message that get transffered both from the client -and the server(which is hosting the web service) are written into -a log file. -*/ - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -ref class TraceExtension; - -// -// A SoapExtensionAttribute that can be associated with an -// XML Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class TraceExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - // Set the name of the log file where SOAP messages will be stored. - TraceExtensionAttribute() : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - // - // Return the type of TraceExtension. - property Type^ ExtensionType - { - Type^ get() - { - return typeid; - } - } - // - - // - // User can set priority of the SoapExtension. - property int Priority - { - int get() - { - return myPriority; - } - void set( int value ) - { - myPriority = value; - } - - } - // - - property String^ Filename - { - String^ get() - { - return myFilename; - } - void set( String^ value ) - { - myFilename = value; - } - } -}; -// - -[System::Web::Services::WebServiceBindingAttribute(Name="MathSvcSoap",Namespace="http://tempuri.org/")] -public ref class MathSvc: public System::Web::Services::Protocols::SoapHttpClientProtocol -{ -public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MathSvc() - { - this->Url = "http://localhost/MathSvc_SoapExtensionAttribute.asmx"; - } - - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://tempuri.org/Add", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - [TraceExtension] - Single Add( Single xValue, Single yValue ) - { - array^ temp0 = { xValue, yValue }; - array^ results = this->Invoke( "Add", temp0 ); - return ( (Single)( results[ 0 ] ) ); - } - - System::IAsyncResult^ BeginAdd( Single xValue, - Single yValue, - System::AsyncCallback^ callback, - Object^ asyncState ) - { - array^ temp1 = { xValue, yValue }; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - Single EndAdd( System::IAsyncResult^ asyncResult ) - { - array^ results = this->EndInvoke( asyncResult ); - return ( (Single)( results[ 0 ] ) ); - } -}; - -// Define a SOAP Extension that traces the SOAP request and SOAP -// response for the XML Web service method the SOAP extension is -// applied to. -public ref class TraceExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // Save the Stream representing the SOAP request or SOAP response into - // a local memory buffer. - Stream^ ChainStream( Stream^ stream ) - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - // When the SOAP extension is accessed for the first time, the XML Web - // service method it is applied to is accessed to store the file - // name passed in, using the corresponding SoapExtensionAttribute. - Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) - { - return ( (TraceExtensionAttribute^)( attribute ) )->Filename; - } - - // The SOAP extension was configured to run using a configuration file - // instead of an attribute applied to a specific XML Web service - // method. - Object^ GetInitializer( Type^ WebServiceType ) - { - // Return a file name to log the trace information to, based on the - // type. - return String::Format( "C:\\{0}.log", WebServiceType->FullName ); - } - - // Receive the file name stored by GetInitializer and store it in a - // member variable for this specific instance. - void Initialize( Object^ initializer ) - { - filename = (String^)( initializer ); - } - - // If the SoapMessageStage is such that the SoapRequest or - // SoapResponse is still in the SOAP format to be sent or received, - // save it out to a file. - void ProcessMessage( SoapMessage^ message ) - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - case SoapMessageStage::AfterDeserialize: - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - void WriteOutput( SoapMessage^ message ) - { - newStream->Position = 0; - FileStream^ fs = gcnew FileStream( filename, FileMode::Append, - FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - - String^ soapString = ( (SoapServerMessage^)( message ) ) ? (String^)"SoapResponse" : "SoapRequest"; - w->WriteLine( "-----{0} at {1}", soapString, DateTime::Now ); - w->Flush(); - Copy( newStream, fs ); - w->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - void WriteInput( SoapMessage^ message ) - { - Copy( oldStream, newStream ); - FileStream^ fs = gcnew FileStream( filename, FileMode::Append, - FileAccess::Write ); - StreamWriter^ w = gcnew StreamWriter( fs ); - String^ soapString = ( (SoapServerMessage^)( message ) ) ? - (String^)"SoapRequest" : "SoapResponse"; - w->WriteLine( "-----{0} at {1}", soapString, DateTime::Now ); - w->Flush(); - newStream->Position = 0; - Copy( newStream, fs ); - w->Close(); - newStream->Position = 0; - } - - void Copy( Stream^ from, Stream^ to ) - { - TextReader^ reader = gcnew StreamReader( from ); - TextWriter^ writer = gcnew StreamWriter( to ); - writer->WriteLine( reader->ReadToEnd() ); - writer->Flush(); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtensionAttribute/CPP/SvcClient_SoapExtensionAttribute.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtensionAttribute/CPP/SvcClient_SoapExtensionAttribute.cpp deleted file mode 100644 index a936611b24237..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapExtensionAttribute/CPP/SvcClient_SoapExtensionAttribute.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - This program is used as a client of the client proxy class. -*/ - -#using - -using namespace System; - -public ref class SvcClient -{ -public: - static void Main() - { - } -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapFaultBinding/CPP/soapfaultbinding.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapFaultBinding/CPP/soapfaultbinding.cpp deleted file mode 100644 index cd2422d09e2b8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapFaultBinding/CPP/soapfaultbinding.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// System::Web::Services::Description.SoapFaultBinding - -/* -The following example demonstrates 'SoapFaultBinding' class. -It creates an instance of 'ServiceDescription' class by reading an existing -wsdl file. Then it creates an instance of 'SoapFaultBinding' and adds it to -the collection object of 'Binding' class. It generates a new wsdl file where -the properties of 'SoapFaultBinding' objects are reflected and which could be -used for generating a proxy. -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - try - { - // Input wsdl file. - String^ myInputWsdlFile = "SoapFaultBindingInput_cpp.wsdl"; - - // Output wsdl file. - String^ myOutputWsdlFile = "SoapFaultBindingOutput_cpp.wsdl"; - - // Initialize an instance of a 'ServiceDescription' object. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( myInputWsdlFile ); - - // Get a SOAP binding object with binding name S"MyService1Soap". - Binding^ myBinding = myServiceDescription->Bindings[ "MyService1Soap" ]; - - // Create a new instance of 'SoapFaultBinding' class. - SoapFaultBinding^ mySoapFaultBinding = gcnew SoapFaultBinding; - - // Encode fault message using rules specified by 'Encoding' property. - mySoapFaultBinding->Use = SoapBindingUse::Encoded; - - // Set the URI representing the encoding style. - mySoapFaultBinding->Encoding = "http://tempuri.org/stockquote"; - - // Set the URI representing the location of the specification - // for encoding of content not defined by 'Encoding' property'. - mySoapFaultBinding->Namespace = "http://tempuri.org/stockquote"; - - // Create a new instance of 'FaultBinding'. - FaultBinding^ myFaultBinding = gcnew FaultBinding; - myFaultBinding->Name = "AddFaultbinding"; - myFaultBinding->Extensions->Add( mySoapFaultBinding ); - - // Get existing 'OperationBinding' object. - OperationBinding^ myOperationBinding = myBinding->Operations[ 0 ]; - myOperationBinding->Faults->Add( myFaultBinding ); - - // Create a new wsdl file. - myServiceDescription->Write( myOutputWsdlFile ); - Console::WriteLine( "The new wsdl file created is : {0}", myOutputWsdlFile ); - Console::WriteLine( "Proxy could be created using command : wsdl {0}", myOutputWsdlFile ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error occurred : {0}", e->Message ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapFaultBinding_ctor/CPP/soapfaultbinding_ctor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapFaultBinding_ctor/CPP/soapfaultbinding_ctor.cpp deleted file mode 100644 index 0c69f5c1ea865..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapFaultBinding_ctor/CPP/soapfaultbinding_ctor.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// System::Web::Services::Description.SoapBodyBinding::PartsString -// System::Web::Services::Description.SoapFaultBinding::ctor -// System::Web::Services::Description.SoapFaultBinding::Use -// System::Web::Services::Description.SoapFaultBinding::Encoding -// System::Web::Services::Description.SoapFaultBinding::NameSpace - -/* -The following example demonstrates the 'PartsString' property of 'SoapBodyBinding' class -and constructor, 'Encoding', 'NameSpace' and 'Use'properties of 'SoapFaultBinding' class. - -It creates an instance of 'ServiceDescription' class by reading an existing -wsdl file. Then it creates an instance of 'SoapFaultBinding' and adds it to -the collection object of 'Binding' class. It generates a new wsdl file where -the properties of 'SoapFaultBinding' objects are reflected and which could be -used for generating a proxy. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -int main() -{ - try - { - // Input wsdl file. - String^ myInputWsdlFile = "SoapFaultInput_cpp.wsdl"; - - // Output wsdl file. - String^ myOutputWsdlFile = "SoapFaultOutput_cpp.wsdl"; - - // Initialize an instance of a 'ServiceDescription' object. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( myInputWsdlFile ); - - // Get a SOAP binding object with binding name S"MyService1Soap". - Binding^ myBinding = myServiceDescription->Bindings[ "MyService1Soap" ]; - - // Create the 'OperationBinding' object for the 'SOAP' protocol. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "Add"; - - // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->SoapAction = "http://tempuri.org/Add"; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - - // Add the 'SoapOperationBinding' object to 'OperationBinding' object. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - - // - // Create the 'InputBinding' object for the 'SOAP' protocol. - InputBinding^ myInput = gcnew InputBinding; - SoapBodyBinding^ mySoapBinding1 = gcnew SoapBodyBinding; - mySoapBinding1->PartsString = "parameters"; - mySoapBinding1->Use = SoapBindingUse::Literal; - myInput->Extensions->Add( mySoapBinding1 ); - - // Assign the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInput; - - // Create the 'OutputBinding' object' for the 'SOAP' protocol.. - OutputBinding^ myOutput = gcnew OutputBinding; - myOutput->Extensions->Add( mySoapBinding1 ); - - // Assign the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; - // - - // - // - // - // - // Create a new instance of 'SoapFaultBinding' class. - SoapFaultBinding^ mySoapFaultBinding = gcnew SoapFaultBinding; - - // Encode fault message using rules specified by 'Encoding' property. - mySoapFaultBinding->Use = SoapBindingUse::Encoded; - - // Set the URI representing the encoding style. - mySoapFaultBinding->Encoding = "http://tempuri.org/stockquote"; - - // Set the URI representing the location of the specification - // for encoding of content not defined by 'Encoding' property'. - mySoapFaultBinding->Namespace = "http://tempuri.org/stockquote"; - - // Create a new instance of 'FaultBinding'. - FaultBinding^ myFaultBinding = gcnew FaultBinding; - myFaultBinding->Name = "AddFaultbinding"; - myFaultBinding->Extensions->Add( mySoapFaultBinding ); - - // Get existing 'OperationBinding' object. - myOperationBinding->Faults->Add( myFaultBinding ); - myBinding->Operations->Add( myOperationBinding ); - - // - // - // - // - // Create a new wsdl file. - myServiceDescription->Write( myOutputWsdlFile ); - Console::WriteLine( "The new wsdl file created is : {0}", myOutputWsdlFile ); - Console::WriteLine( "Proxy could be created using command : wsdl {0}", myOutputWsdlFile ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error occurred : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapFormatter Example/CPP/soapformatter.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapFormatter Example/CPP/soapformatter.cpp deleted file mode 100644 index 8a4e741d33b6d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapFormatter Example/CPP/soapformatter.cpp +++ /dev/null @@ -1,90 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Collections; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Serialization::Formatters::Soap; -void Serialize() -{ - - // Create a hashtable of values that will eventually be serialized. - Hashtable^ addresses = gcnew Hashtable; - addresses->Add( "Jeff", "123 Main Street, Redmond, WA 98052" ); - addresses->Add( "Fred", "987 Pine Road, Phila., PA 19116" ); - addresses->Add( "Mary", "PO Box 112233, Palo Alto, CA 94301" ); - - // To serialize the hashtable (and its keys/values), - // you must first open a stream for writing. - // We will use a file stream here. - FileStream^ fs = gcnew FileStream( "DataFile.soap",FileMode::Create ); - - // Construct a SoapFormatter and use it - // to serialize the data to the stream. - SoapFormatter^ formatter = gcnew SoapFormatter; - try - { - formatter->Serialize( fs, addresses ); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to serialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - -} - -void Deserialize() -{ - - // Declare the hashtable reference. - Hashtable^ addresses = nullptr; - - // Open the file containing the data that we want to deserialize. - FileStream^ fs = gcnew FileStream( "DataFile.soap",FileMode::Open ); - try - { - SoapFormatter^ formatter = gcnew SoapFormatter; - - // Deserialize the hashtable from the file and - // assign the reference to our local variable. - addresses = dynamic_cast(formatter->Deserialize( fs )); - } - catch ( SerializationException^ e ) - { - Console::WriteLine( "Failed to deserialize. Reason: {0}", e->Message ); - throw; - } - finally - { - fs->Close(); - } - - - // To prove that the table deserialized correctly, - // display the keys/values to the console. - IEnumerator^ myEnum = addresses->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ de = safe_cast(myEnum->Current); - Console::WriteLine( " {0} lives at {1}.", de->Key, de->Value ); - } -} - - -[STAThread] -int main() -{ - Serialize(); - Deserialize(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding/CPP/soapheaderbinding.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding/CPP/soapheaderbinding.cpp deleted file mode 100644 index ff5d56ef650b2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding/CPP/soapheaderbinding.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Web::Services::Description.SoapHeaderBinding - -/* -The following example demonstrates the class 'SoapHeaderBinding'. -It takes as input a wsdl file. By using the 'Read' method -of 'ServiceDescription' class it gets a 'ServiceDescription' object. -It uses the SOAP protocol related classes and creates 'Binding' element -of 'SOAP' protocol which are then added to the 'ServiceDescription' object. -An output wsdl file is generated from 'ServiceDescription' object which -could be used for generating a proxy. - -*/ - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "SoapHeaderBindingInput_cpp.wsdl" ); - Binding^ myBinding = gcnew Binding; - myBinding->Name = "MyWebServiceSoap"; - myBinding->Type = gcnew XmlQualifiedName( "s0:MyWebServiceSoap" ); - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - myBinding->Extensions->Add( mySoapBinding ); - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "Hello"; - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->SoapAction = "http://tempuri.org/Hello"; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - - // Create InputBinding for operation for the 'SOAP' protocol. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - SoapHeaderBinding^ mySoapHeaderBinding = gcnew SoapHeaderBinding; - mySoapHeaderBinding->Message = gcnew XmlQualifiedName( "s0:HelloMyHeader" ); - mySoapHeaderBinding->Part = "MyHeader"; - mySoapHeaderBinding->Use = SoapBindingUse::Literal; - - // Add mySoapHeaderBinding to 'myInputBinding' object. - myInputBinding->Extensions->Add( mySoapHeaderBinding ); - - // Create OutputBinding for operation for the 'SOAP' protocol. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - myBinding->Operations->Add( myOperationBinding ); - myServiceDescription->Bindings->Add( myBinding ); - myServiceDescription->Write( "SoapHeaderBindingOut_cpp.wsdl" ); - Console::WriteLine( "'SoapHeaderBindingOut_cpp.wsdl' file is generated." ); - Console::WriteLine( "Proxy could be created using 'wsdl SoapHeaderBindingOut_cpp.wsdl'." ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding_MapToProperty/CPP/soapheaderbinding_maptoproperty.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding_MapToProperty/CPP/soapheaderbinding_maptoproperty.cpp deleted file mode 100644 index 094bfdc30089f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding_MapToProperty/CPP/soapheaderbinding_maptoproperty.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// System::Web::Services::Description.SoapHeaderBinding::MapToProperty - -/* -The following example demonstrates the 'MapToProperty' property of class 'SoapHeaderBinding'. -It reads an existing wsdl file and gets 'SoapHeaderBinding' instance from it. -'MapToProperty' property of this instance is checked to see whether this instance -is mapped to a specific property in proxy class or not. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; - -int main() -{ - // - // Read from an existing wsdl file. - ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MapToProperty_cpp.wsdl" ); - - // Get the existing binding - Binding^ myBinding = myServiceDescription->Bindings[ "MyWebServiceSoap" ]; - OperationBinding^ myOperationBinding = (OperationBinding^)(myBinding->Operations[ 0 ]); - InputBinding^ myInputBinding = myOperationBinding->Input; - - // Get the 'SoapHeaderBinding' instance from 'myInputBinding'. - SoapHeaderBinding^ mySoapHeaderBinding = (SoapHeaderBinding^)(myInputBinding->Extensions[ 1 ]); - if ( mySoapHeaderBinding->MapToProperty ) - Console::WriteLine( "'SoapHeaderBinding' instance is mapped to a specific property in proxy generated class" ); - else - Console::WriteLine( "'SoapHeaderBinding' instance is not mapped to a specific property in proxy generated class" ); - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding_Use/CPP/soapheaderbinding_use.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding_Use/CPP/soapheaderbinding_use.cpp deleted file mode 100644 index 0223ff8c50053..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderBinding_Use/CPP/soapheaderbinding_use.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// System::Web::Services::Description.SoapHeaderBinding::ctor -// System::Web::Services::Description.SoapHeaderBinding::Message -// System::Web::Services::Description.SoapHeaderBinding::Part -// System::Web::Services::Description.SoapHeaderBinding::Use - -/* -The following example demonstrates the constructor, 'Message' , 'Part' -and 'Use' properties of the class 'SoapHeaderBinding'. -It takes as input a wsdl file. The binding element corresponding to -SOAP protocol is removed from the input file. By using the 'Read' method -of 'ServiceDescription' class it gets a 'ServiceDescription' Object*. -It uses the SOAP protocol related classes and creates 'Binding' element -of 'SOAP' protocol which are then added to the 'ServiceDescription' Object*. -An output wsdl file is generated from 'ServiceDescription' Object* which -could be used for generating a proxy. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Web::Services::Description; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myServiceDescription = - ServiceDescription::Read( "SoapHeaderBindingInput_cpp.wsdl" ); - Binding^ myBinding = gcnew Binding; - myBinding->Name = "MyWebServiceSoap"; - myBinding->Type = gcnew XmlQualifiedName( "s0:MyWebServiceSoap" ); - - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; - mySoapBinding->Style = SoapBindingStyle::Document; - myBinding->Extensions->Add( mySoapBinding ); - - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "Hello"; - - SoapOperationBinding^ mySoapOperationBinding = - gcnew SoapOperationBinding; - mySoapOperationBinding->SoapAction = "http://tempuri.org/Hello"; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - - // Create InputBinding for operation for the 'SOAP' protocol. - InputBinding^ myInputBinding = gcnew InputBinding; - SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding; - mySoapBodyBinding->Use = SoapBindingUse::Literal; - myInputBinding->Extensions->Add( mySoapBodyBinding ); - -// -// -// -// - SoapHeaderBinding^ mySoapHeaderBinding = gcnew SoapHeaderBinding; - // Set the Message within the XML Web service to which the - // 'SoapHeaderBinding' applies. - mySoapHeaderBinding->Message = - gcnew XmlQualifiedName( "s0:HelloMyHeader" ); - mySoapHeaderBinding->Part = "MyHeader"; - mySoapHeaderBinding->Use = SoapBindingUse::Literal; - // Add mySoapHeaderBinding to the 'myInputBinding' object. - myInputBinding->Extensions->Add( mySoapHeaderBinding ); -// -// -// -// - - // Create OutputBinding for operation for the 'SOAP' protocol. - OutputBinding^ myOutputBinding = gcnew OutputBinding; - myOutputBinding->Extensions->Add( mySoapBodyBinding ); - - // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInputBinding; - myOperationBinding->Output = myOutputBinding; - myBinding->Operations->Add( myOperationBinding ); - - myServiceDescription->Bindings->Add( myBinding ); - myServiceDescription->Write( "SoapHeaderBindingOut_cpp.wsdl" ); - Console::WriteLine( "'SoapHeaderBindingOut_cpp.wsdl' file is generated." ); - Console::WriteLine( "Proxy could be created using " + - "'wsdl SoapHeaderBindingOut_cpp.wsdl'." ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection/CPP/SoapHeaderCollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection/CPP/SoapHeaderCollection.cpp deleted file mode 100644 index c751b8d263148..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection/CPP/SoapHeaderCollection.cpp +++ /dev/null @@ -1,257 +0,0 @@ -// System.Web.Services.Protocols.SoapHeaderCollection -// System.Web.Services.Protocols.SoapHeaderCollection.SoapHeaderCollection() -// System.Web.Services.Protocols.SoapHeaderCollection.Add(SoapHeader) -// System.Web.Services.Protocols.SoapHeaderCollection.Insert(int, SoapHeader) -// System.Web.Services.Protocols.SoapHeaderCollection.CopyTo(SoapHeader[], int) -// System.Web.Services.Protocols.SoapHeaderDirection.In - -/* - The following example demonstrates various members of the - SoapHeaderCollection class and the In member of the SoapHeaderDirection - enumeration. The program extends the SoapExtension class to create a - class that is used to log the SOAP messages transferred for an XML Web - service method invocation. Whenever this method is invoked on the client - side, all the SOAP message that are transfered both from the client and - the server are written to a log file. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -ref class MySoapExtension; - -// A SoapExtensionAttribute that can be associated with an -// XML Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class MySoapExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - - // Set the name of the log file where SOAP messages will be stored. - MySoapExtensionAttribute() - : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - property Type^ ExtensionType - { - // Return the type of MySoapExtension. - virtual Type^ get() override - { - return MySoapExtension::typeid; - } - } - - property int Priority - { - // User can set priority of the SoapExtension. - virtual int get() override - { - return myPriority; - } - - virtual void set( int value ) override - { - myPriority = value; - } - } - - property String^ Filename - { - String^ get() - { - return myFilename; - } - - void set( String^ value ) - { - myFilename = value; - } - } -}; - -public ref class MySoapHeader: public SoapHeader -{ -public: - String^ text; -}; - -// -[System::Web::Services::WebServiceBindingAttribute(Name="MathSvcSoap", - Namespace="http://tempuri.org/")] -public ref class MathSvc: public System::Web::Services::Protocols::SoapHttpClientProtocol -{ - // -public: - array^ mySoapHeaders; - - [SoapHeaderAttribute("mySoapHeaders", - Direction=SoapHeaderDirection::In)] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute( - "http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - [MySoapExtensionAttribute] - Single Add( Single xValue, Single yValue ) - { - // - SoapHeaderCollection^ mySoapHeaderCollection = gcnew SoapHeaderCollection; - MySoapHeader^ mySoapHeader; - mySoapHeader = gcnew MySoapHeader; - mySoapHeader->text = "This is the first SOAP header"; - mySoapHeaderCollection->Add( mySoapHeader ); - // - - // - mySoapHeader = gcnew MySoapHeader; - mySoapHeader->text = "This is the second SOAP header"; - mySoapHeaderCollection->Add( mySoapHeader ); - // - - // - mySoapHeader = gcnew MySoapHeader; - mySoapHeader->text = "This header is inserted before the first header"; - mySoapHeaderCollection->Insert( 0, mySoapHeader ); - // - - // - mySoapHeaders = gcnew array(mySoapHeaderCollection->Count); - mySoapHeaderCollection->CopyTo( mySoapHeaders, 0 ); - // - - array^ temp0 = {xValue,yValue}; - array^ results = this->Invoke( "Add", temp0 ); - return ( (Single)( results[ 0 ] ) ); - } - // - - [System::Diagnostics::DebuggerStepThroughAttribute] - MathSvc() - { - this->Url = "http://localhost/MathSvc_SoapHeaderCollection.cs.asmx"; - } - - System::IAsyncResult^ BeginAdd( Single xValue, - Single yValue, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^ temp1 = {xValue,yValue}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - Single EndAdd( System::IAsyncResult^ asyncResult ) - { - array^ results = this->EndInvoke( asyncResult ); - return ( (Single)( results[ 0 ] ) ); - } -}; -// - -public ref class MySoapExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // Return the file name that is to log the SOAP messages. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, - SoapExtensionAttribute^ attribute ) override - { - return ( (MySoapExtensionAttribute^)( attribute ) )->Filename; - } - - // Return the file name that is to log the SOAP messages. - virtual Object^ GetInitializer( Type^ filename ) override - { - return (Type^)( filename ); - } - - // Save the name of the log file that will save the SOAP messages. - virtual void Initialize( Object^ initializer ) override - { - filename = (String^)( initializer ); - } - - // Process the SOAP message received and write it to the log file. - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( (SoapClientMessage^)( message ) ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( (SoapClientMessage^)( message ) ); - break; - case SoapMessageStage::AfterDeserialize: - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Write the contents of the outgoing SOAP message to the log file. - void WriteOutput( SoapClientMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "================================== Request at {0}", - DateTime::Now ); - myStreamWriter->Flush(); - Copy( newStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - // Write the contents of the incoming SOAP message to the log file. - void WriteInput( SoapClientMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "---------------------------------- Response at {0}", - DateTime::Now ); - myStreamWriter->Flush(); - newStream->Position = 0; - Copy( newStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - newStream->Position = 0; - } - - // Return a new MemoryStream for SOAP processing. - virtual Stream^ ChainStream( Stream^ stream ) override - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - // Utility method to copy the contents of one stream to another. - void Copy( Stream^ fromStream, Stream^ toStream ) - { - TextReader^ myTextReader = gcnew StreamReader( fromStream ); - TextWriter^ myTextWriter = gcnew StreamWriter( toStream ); - myTextWriter->WriteLine( myTextReader->ReadToEnd() ); - myTextWriter->Flush(); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection/CPP/SvcClient_SoapHeaderCollection.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection/CPP/SvcClient_SoapHeaderCollection.cpp deleted file mode 100644 index a936611b24237..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection/CPP/SvcClient_SoapHeaderCollection.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - This program is used as a client of the client proxy class. -*/ - -#using - -using namespace System; - -public ref class SvcClient -{ -public: - static void Main() - { - } -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection_Contains/CPP/SoapHeaderCollection_Contains.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection_Contains/CPP/SoapHeaderCollection_Contains.cpp deleted file mode 100644 index fd58130e9f37d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeaderCollection_Contains/CPP/SoapHeaderCollection_Contains.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// System.Web.Services.Protocols.SoapHeaderCollection.Contains(SoapHeader); System.Web.Services.Protocols.SoapHeaderCollection.IndexOf(); System.Web.Services.Protocols.SoapHeaderCollection.Item; System.Web.Services.Protocols.SoapHeaderCollection.Remove(SoapHeader) - -/* -The following example demonstrates the methods 'Contains','IndexOf' and -'Remove' and the property 'Item' of the 'SoapHeaderCollection' class. The -program extends the 'SoapExtension' class to create a class that is -used to log the SOAP messages transferred for a web service method -invocation. Whenever this method is invoked on the client side -all the SOAP message that get transfered both from the client -and the server are written into a log file. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; -using namespace System::Xml; - -ref class MySoapExtension; - -// A 'SoapExtensionAttribute' that can be associated with web service method. - -[AttributeUsage(AttributeTargets::Method)] -public ref class MySoapExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - - // Set the name of the log file were SOAP messages will be stored. - MySoapExtensionAttribute() - : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - property Type^ ExtensionType - { - // Return the type of 'MySoapExtension' class. - virtual Type^ get() override - { - return MySoapExtension::typeid; - } - } - - property int Priority - { - // User can set priority of the 'SoapExtension'. - virtual int get() override - { - return myPriority; - } - - virtual void set( int value ) override - { - myPriority = value; - } - } - - property String^ Filename - { - String^ get() - { - return myFilename; - } - - void set( String^ value ) - { - myFilename = value; - } - - } - -}; - -public ref class MySoapHeader: public SoapHeader -{ -public: - String^ Text; -}; - -[System::Web::Services::WebServiceBindingAttribute(Name="MathSvcSoap",Namespace="http://tempuri.org/")] -public ref class MathService: public System::Web::Services::Protocols::SoapHttpClientProtocol -{ -public: - array^mySoapHeaders; - - [SoapHeaderAttribute("mySoapHeaders",Direction=SoapHeaderDirection::In,Required=false)] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - [MySoapExtensionAttribute] - Single Add( Single xValue, Single yValue ) - { - SoapHeaderCollection^ mySoapHeaderCollection = gcnew SoapHeaderCollection; - MySoapHeader^ myFirstSoapHeader; - myFirstSoapHeader = gcnew MySoapHeader; - myFirstSoapHeader->Text = "This is the first soap header"; - mySoapHeaderCollection->Add( myFirstSoapHeader ); - MySoapHeader^ mySecondSoapHeader = gcnew MySoapHeader; - mySecondSoapHeader->Text = "This is the second soap header"; - mySoapHeaderCollection->Add( mySecondSoapHeader ); - - // - // Check to see whether the collection contains mySecondSoapHeader. - if ( mySoapHeaderCollection->Contains( mySecondSoapHeader ) ) - { - // Get the index of mySecondSoapHeader from the collection. - Console::WriteLine( "Index of mySecondSoapHeader: {0}", mySoapHeaderCollection->IndexOf( mySecondSoapHeader ) ); - - // Get the SoapHeader from the collection. - MySoapHeader^ mySoapHeader1 = dynamic_cast(mySoapHeaderCollection[ mySoapHeaderCollection->IndexOf( mySecondSoapHeader ) ]); - Console::WriteLine( "SoapHeader retrieved from the collection: {0}", mySoapHeader1 ); - - // Remove a SoapHeader from the collection. - mySoapHeaderCollection->Remove( mySoapHeader1 ); - Console::WriteLine( "Number of items after removal: {0}", mySoapHeaderCollection->Count ); - } - else - Console::WriteLine( "mySoapHeaderCollection does not contain mySecondSoapHeader." ); - // - - mySoapHeaders = gcnew array(mySoapHeaderCollection->Count); - mySoapHeaderCollection->CopyTo( mySoapHeaders, 0 ); - array^temp0 = {xValue,yValue}; - array^results = this->Invoke( "Add", temp0 ); - return safe_cast(results[ 0 ]); - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - MathService() - { - this->Url = "http://localhost/MathService_SoapHeaderCollection.cs.asmx"; - } - - System::IAsyncResult^ BeginAdd( Single xValue, Single yValue, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {xValue,yValue}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - Single EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return safe_cast(results[ 0 ]); - } - -}; - -public ref class MySoapExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ myFilename; - -public: - - // Return the filename that is to log the SOAP messages. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ myAttribute ) override - { - return (dynamic_cast(myAttribute))->Filename; - } - - // Return the filename that is to log the SOAP messages. - virtual Object^ GetInitializer( Type^ myFilename ) override - { - return dynamic_cast(myFilename); - } - - // Save the name of the log file that shall save the SOAP messages. - virtual void Initialize( Object^ initializer ) override - { - myFilename = dynamic_cast(initializer); - } - - // Process the SOAP message received and write to log file. - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - - case SoapMessageStage::AfterSerialize: - WriteOutput( dynamic_cast(message) ); - break; - - case SoapMessageStage::BeforeDeserialize: - WriteInput( dynamic_cast(message) ); - break; - - case SoapMessageStage::AfterDeserialize: - break; - - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Write the contents of the outgoing SOAP message to the log file. - void WriteOutput( SoapClientMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ myFileStream = gcnew FileStream( myFilename,FileMode::Append,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "================================== Request at {0}", DateTime::Now ); - myStreamWriter->Flush(); - Copy( newStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - // Write the contents of the incoming SOAP message to the log file. - void WriteInput( SoapClientMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ myFileStream = gcnew FileStream( myFilename,FileMode::Append,FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "---------------------------------- Response at {0}", DateTime::Now ); - myStreamWriter->Flush(); - newStream->Position = 0; - Copy( newStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - newStream->Position = 0; - } - - // Return a new 'MemoryStream' instance for SOAP processing. - virtual Stream^ ChainStream( Stream^ myStream ) override - { - oldStream = myStream; - newStream = gcnew MemoryStream; - return newStream; - } - - // Utility method to copy the contents of one stream to another. - void Copy( Stream^ fromStream, Stream^ toStream ) - { - TextReader^ myTextReader = gcnew StreamReader( fromStream ); - TextWriter^ myTextWriter = gcnew StreamWriter( toStream ); - myTextWriter->WriteLine( myTextReader->ReadToEnd() ); - myTextWriter->Flush(); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeader_EncodedMustUnderstand/CPP/soapheader_encodedmustunderstand.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeader_EncodedMustUnderstand/CPP/soapheader_encodedmustunderstand.cpp deleted file mode 100644 index fa98d114ffe44..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHeader_EncodedMustUnderstand/CPP/soapheader_encodedmustunderstand.cpp +++ /dev/null @@ -1,53 +0,0 @@ - - -// System.Web.Services.Protocols.SoapHeader.EncodedMustUnderstand -/* -This program demonstrates the 'EncodedMustUnderstand' property of -the 'SoapHeader' class. This example calls two webservice methods, -namely 'WebMethod1' for which the property 'DidUnderstand' is set -to true and 'WebMethod2' for which the property 'DidUnderstand' -is set to false. The property 'EncodedMustUnderstand' is set to '1' -for the client soapheader. The client calls the method 'WebMethod2' -whose 'DidUnderstand' property is set to false and hence a 'SoapHeaderException' -is thrown. -*/ -#using -#using -#using -#using - -using namespace System; - -int main() -{ - try - { - // - // MyHeader class is derived from the SoapHeader class. - MyHeader ^ customHeader = gcnew MyHeader; - customHeader->MyValue = "Header value for MyValue"; - - // Set the EncodedMustUnderstand property to true. - customHeader->EncodedMustUnderstand = "1"; - WebService_SoapHeader_EncodedMustUnderstand ^ myWebService = gcnew WebService_SoapHeader_EncodedMustUnderstand; - myWebService->myHeader1 = customHeader; - String^ results = myWebService->MyWebMethod1(); - Console::WriteLine( results ); - try - { - results = myWebService->MyWebMethod2(); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception raised in MyWebMethod2." ); - Console::WriteLine( "Message: {0}", myException->Message ); - } - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!" ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHttpClientProtocol.Discover Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapHttpClientProtocol.Discover Example/CPP/source.cpp deleted file mode 100644 index 6553b346e86e4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapHttpClientProtocol.Discover Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using -#using - -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -namespace MyMath -{ - - [System::Web::Services::WebServiceBindingAttribute(Name="MathSoap",Namespace="http://tempuri.org/")] - public ref class Math: public System::Web::Services::Protocols::SoapHttpClientProtocol - { - public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - Math() - { - this->Url = "http://www.contoso.com/math.asmx"; - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - int Add( int num1, int num2 ) - { - array^temp0 = {num1,num2}; - array^results = this->Invoke( "Add", temp0 ); - return *dynamic_cast(results[ 0 ]); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState ) - { - array^temp1 = {num1,num2}; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - - [System::Diagnostics::DebuggerStepThroughAttribute] - int EndAdd( System::IAsyncResult^ asyncResult ) - { - array^results = this->EndInvoke( asyncResult ); - return *dynamic_cast(results[ 0 ]); - } - - }; - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage/CPP/SoapMessage.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage/CPP/SoapMessage.cpp deleted file mode 100644 index c2b34429787bf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage/CPP/SoapMessage.cpp +++ /dev/null @@ -1,322 +0,0 @@ -// System.Web.Services.Protocols.SoapMessage -// System.Web.Services.Protocols.SoapMessage.Action -// System.Web.Services.Protocols.SoapMessage.ContentType -// System.Web.Services.Protocols.SoapMessage.OneWay -// System.Web.Services.Protocols.SoapMessage.Url -// System.Web.Services.Protocols.SoapMessage.GetInParameterValue(int) -// System.Web.Services.Protocols.SoapMessage.MethodInfo -// System.Web.Services.Protocols.SoapMessage.GetOutParameterValue(int) -// System.Web.Services.Protocols.SoapMessage.GetReturnValue() - -/* -The following example demonstrates various members of the SoapMessage -class. The program extends the SoapExtension class to create a class -that is used to log the SOAP messages transferred for an XML Web service -method invocation. Whenever this method is invoked on the client side, -all the SOAP messages that get transfered both from the client and the -server are written into a log file. -*/ - -#using -#using - -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -ref class MySoapExtension; - -// A SoapExtensionAttribute that can be associated with an XML -// Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class MySoapExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - // Set the name of the log file where SOAP messages will be stored. - MySoapExtensionAttribute() : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - property Type^ ExtensionType - { - // Return the type of MySoapExtension. - virtual Type^ get() override - { - return MySoapExtension::typeid; - } - } - - property int Priority - { - // User can set priority of the SoapExtension. - virtual int get() override - { - return myPriority; - } - virtual void set( int value ) override - { - myPriority = value; - } - } - - property String^ Filename - { - String^ get() - { - return myFilename; - } - void set( String^ value ) - { - myFilename = value; - } - } -}; - -public ref class MySoapHeader: public SoapHeader -{ -public: - String^ text; -}; - -[System::Web::Services::WebServiceBindingAttribute(Name="MathSvcSoap", - Namespace="http://tempuri.org/")] -public ref class MathSvc: public System::Web::Services::Protocols::SoapHttpClientProtocol -{ -public: - MySoapHeader^ mySoapHeader; - - [SoapHeaderAttribute("mySoapHeader",Direction=SoapHeaderDirection::In)] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute( - "http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - [MySoapExtensionAttribute] - Single Add( Single xValue, Single yValue, - [System::Runtime::InteropServices::Out]interior_ptr returnValue ) - { - mySoapHeader = gcnew MySoapHeader; - mySoapHeader->text = "This is the first SOAP header"; - array^ temp0 = { xValue, yValue }; - array^ results = this->Invoke( "Add", temp0 ); - *returnValue = (Single)( results[ 1 ] ); - return (Single)( results[ 0 ] ); - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - MathSvc() - { - this->Url = "http://localhost/MathSvc_SoapMessage.cs.asmx"; - } - - System::IAsyncResult^ BeginAdd( Single xValue, - Single yValue, System::AsyncCallback^ callback, - Object^ asyncState ) - { - array^ temp1 = { xValue, yValue }; - return this->BeginInvoke( "Add", - temp1, callback, asyncState ); - } - - Single EndAdd( System::IAsyncResult^ asyncResult, - [System::Runtime::InteropServices::Out]interior_ptr returnValue ) - { - array^ results = this->EndInvoke( asyncResult ); - *returnValue = (Single)( results[ 1 ] ); - return (Single)( results[ 0 ] ); - } -}; - -public ref class MySoapExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - - // Return the file name that is to log the SOAP messages. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, - SoapExtensionAttribute^ attribute ) override - { - return ( (MySoapExtensionAttribute^)( attribute ))->Filename; - } - - // Return the file name that is to log the SOAP messages. - virtual Object^ GetInitializer( Type^ filename ) override - { - return (Type^)( filename ); - } - - // Save the name of the log file that will save the SOAP messages. - virtual void Initialize( Object^ initializer ) override - { - filename = (String^)( initializer ); - } - -// - // Process the SOAP message received and write to log file. - virtual void ProcessMessage( SoapMessage^ message ) override - { - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - WriteOutputBeforeSerialize( message ); - break; - case SoapMessageStage::AfterSerialize: - WriteOutputAfterSerialize( message ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInputBeforeDeserialize( message ); - break; - case SoapMessageStage::AfterDeserialize: - WriteInputAfterDeserialize( message ); - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // Write the contents of the outgoing SOAP message to the log file. - void WriteOutputBeforeSerialize( SoapMessage^ message ) - { - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "================================== Request at {0}", - DateTime::Now ); - - // - myStreamWriter->WriteLine( - "The method that has been invoked is: " ); - myStreamWriter->WriteLine( "\t{0}", message->MethodInfo ); - // - - // - myStreamWriter->WriteLine( "The contents of the SOAPAction HTTP header is:" ); - myStreamWriter->WriteLine( "\t{0}", message->Action ); - // - - // - myStreamWriter->WriteLine( "The contents of HTTP Content-type header is:" ); - myStreamWriter->WriteLine( "\t{0}", message->ContentType ); - // - - // - if ( message->OneWay ) - { - myStreamWriter->WriteLine( - "The method invoked on the client shall not wait" - + " till the server finishes" ); - } - else - { - myStreamWriter->WriteLine( - "The method invoked on the client shall wait" - + " till the server finishes" ); - } - // - - // - myStreamWriter->WriteLine( - "The site where the XML Web service is available is:" ); - myStreamWriter->WriteLine( "\t{0}", message->Url ); - // - - // - myStreamWriter->WriteLine( "The values of the in parameters are:" ); - myStreamWriter->WriteLine( - "Value of first in parameter: {0}", message->GetInParameterValue( 0 ) ); - myStreamWriter->WriteLine( - "Value of second in parameter: {0}", message->GetInParameterValue( 1 ) ); - // - - myStreamWriter->WriteLine(); - myStreamWriter->Flush(); - myStreamWriter->Close(); - myFileStream->Close(); - } - - // Write the contents of the incoming SOAP message to the log file. - void WriteInputAfterDeserialize( SoapMessage^ message ) - { - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine(); - - // - myStreamWriter->WriteLine( "The values of the out parameter are:" ); - myStreamWriter->WriteLine( - "The value of the out parameter is: {0}", message->GetOutParameterValue( 0 ) ); - // - - // - myStreamWriter->WriteLine( "The values of the return parameter are:" ); - myStreamWriter->WriteLine( - "The value of the return parameter is: {0}", message->GetReturnValue() ); - // - - myStreamWriter->Flush(); - myStreamWriter->Close(); - myFileStream->Close(); - } - // - - // Write the contents of the outgoing SOAP message to the log file. - void WriteOutputAfterSerialize( SoapMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->Flush(); - Copy( newStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - - // Write the contents of the incoming SOAP message to the log file. - void WriteInputBeforeDeserialize( SoapMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "---------------------------------- Response at {0}", - DateTime::Now ); - myStreamWriter->Flush(); - newStream->Position = 0; - Copy( newStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - newStream->Position = 0; - } - - // Return a new MemoryStream for SOAP processing. - virtual Stream^ ChainStream( Stream^ stream ) override - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - // Utility method to copy the contents of one stream to another. - void Copy( Stream^ fromStream, Stream^ toStream ) - { - TextReader^ myTextReader = gcnew StreamReader( fromStream ); - TextWriter^ myTextWriter = gcnew StreamWriter( toStream ); - myTextWriter->WriteLine( myTextReader->ReadToEnd() ); - myTextWriter->Flush(); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage/CPP/SvcClient_SoapMessage.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage/CPP/SvcClient_SoapMessage.cpp deleted file mode 100644 index a936611b24237..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage/CPP/SvcClient_SoapMessage.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - This program is used as a client of the client proxy class. -*/ - -#using - -using namespace System; - -public ref class SvcClient -{ -public: - static void Main() - { - } -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessageState/CPP/SoapMessageState.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessageState/CPP/SoapMessageState.cpp deleted file mode 100644 index f5ed2196e550e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessageState/CPP/SoapMessageState.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// System.Web.Services.Protocols.SoapMessageState -// System.Web.Services.Protocols.SoapMessageState.AfterDeserialize -// System.Web.Services.Protocols.SoapMessageState.AfterSerialize -// System.Web.Services.Protocols.SoapMessageState.BeforeDeserialize -// System.Web.Services.Protocols.SoapMessageState.BeforeSerialize - -/* - The following example demonstrates the 'AfterDeserialize', - 'AfterSerialize', 'BeforeDeserialize' and 'BeforeSerialize' enum - members of the 'SoapMessageState' class. The program extends the - 'SoapExtension' class to create a class that is used to log the - SOAP messages transferred for a web service method invocation. - To associate this 'SoapExtension' class with the web service - method on the client proxy a class that extends from - 'SoapExtensionAttribute' is used. This 'SoapExtensionAttribute' is - applied to a client proxy method which is associated with a web - service method. Whenever this method is invoked on the client - side all the SOAP message that get transfered both from the client - and the server(which is hosting the web service) are written into - a log file. -*/ - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -ref class MySoapExtension; - -// A 'SoapExtensionAttribute' that can be associated with web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class MySoapExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - // Set the name of the log file where SOAP messages will be stored. - MySoapExtensionAttribute() : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - property Type^ ExtensionType - { - // Return the type of 'MySoapExtension' class. - Type^ get() - { - return typeid; - } - } - - property int Priority - { - // User can set priority of the 'SoapExtension'. - int get() - { - return myPriority; - } - void set( int value ) - { - myPriority = value; - } - } - - property String^ Filename - { - String^ get() - { - return myFilename; - } - void set( String^ value ) - { - myFilename = value; - } - } -}; - -[System::Web::Services::WebServiceBindingAttribute(Name="MathSvcSoap",Namespace="http://tempuri.org/")] -public ref class MathSvc: public System::Web::Services::Protocols::SoapHttpClientProtocol -{ -public: - - [System::Diagnostics::DebuggerStepThroughAttribute] - MathSvc() - { - this->Url = "http://localhost/MathSvc_SoapMessageState.asmx"; - } - - [System::Web::Services::Protocols::SoapDocumentMethodAttribute("http://tempuri.org/Add",Use=System::Web::Services::Description::SoapBindingUse::Literal,ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - [MySoapExtensionAttribute] - Single Add( Single xValue, Single yValue ) - { - array^ temp0 = {xValue,yValue}; - array^ results = this->Invoke( "Add", temp0 ); - return (Single)( results[ 0 ] ); - } - - System::IAsyncResult^ BeginAdd( Single xValue, - Single yValue, - System::AsyncCallback^ callback, - Object^ asyncState ) - { - array^ temp1 = { xValue, yValue }; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - Single EndAdd( System::IAsyncResult^ asyncResult ) - { - array^ results = this->EndInvoke( asyncResult ); - return (Single)( results[ 0 ] ); - } - -}; - -public ref class MySoapExtension: public SoapExtension -{ -private: - Stream^ oldStream; - Stream^ newStream; - String^ filename; - -public: - // Return the filename that is to log the SOAP messages. - Object^ GetInitializer( LogicalMethodInfo^ /*methodInfo*/, SoapExtensionAttribute^ attribute ) - { - return ( (MySoapExtensionAttribute^)( attribute ))->Filename; - } - - // Return the filename that is to log the SOAP messages. - Object^ GetInitializer( Type^ filename ) - { - return (Type^)( filename ); - } - - // Save the name of the log file that shall save the SOAP messages. - void Initialize( Object^ initializer ) - { - filename = (String^)( initializer ); - } - -// - // Process the SOAP message received and write to log file. - void ProcessMessage( SoapMessage^ message ) - { -// -// -// -// - switch ( message->Stage ) - { - case SoapMessageStage::BeforeSerialize: - break; - case SoapMessageStage::AfterSerialize: - WriteOutput( message ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInput( message ); - break; - case SoapMessageStage::AfterDeserialize: - break; - default: - throw gcnew Exception( "invalid stage" ); - } -// -// -// -// - } -// - - // Return a new 'MemoryStream' instance for SOAP processing. - Stream^ ChainStream( Stream^ stream ) - { - oldStream = stream; - newStream = gcnew MemoryStream; - return newStream; - } - - - // Write the contents of the outgoing SOAP message to the log file. - void WriteOutput( SoapMessage^ /*message*/ ) - { - newStream->Position = 0; - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "================================== Request at {0}", - DateTime::Now ); - myStreamWriter->Flush(); - Copy( newStream, myFileStream ); - myFileStream->Close(); - newStream->Position = 0; - Copy( newStream, oldStream ); - } - - // Write the contents of the incoming SOAP message to the log file. - void WriteInput( SoapMessage^ /*message*/ ) - { - Copy( oldStream, newStream ); - FileStream^ myFileStream = - gcnew FileStream( filename, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( "---------------------------------- Response at {0}", - DateTime::Now ); - myStreamWriter->Flush(); - newStream->Position = 0; - Copy( newStream, myFileStream ); - myFileStream->Close(); - newStream->Position = 0; - } - - // Utility method to copy the contents of one stream to another. - void Copy( Stream^ fromStream, Stream^ toStream ) - { - TextReader^ myTextReader = gcnew StreamReader( fromStream ); - TextWriter^ myTextWriter = gcnew StreamWriter( toStream ); - myTextWriter->WriteLine( myTextReader->ReadToEnd() ); - myTextWriter->Flush(); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessageState/CPP/SvcClient_SoapMessageState.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessageState/CPP/SvcClient_SoapMessageState.cpp deleted file mode 100644 index 94a498bce1658..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessageState/CPP/SvcClient_SoapMessageState.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - This program is used as a client of the client proxy class. -*/ - -#using - -using namespace System; - -public class SvcClient -{ -public: - static void Main() - { - } -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage_Headers/CPP/SoapMessage_Headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage_Headers/CPP/SoapMessage_Headers.cpp deleted file mode 100644 index 1748283456201..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage_Headers/CPP/SoapMessage_Headers.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// System.Web.Services.Protocols.SoapMessage.Headers -// System.Web.Services.Protocols.SoapMessage.Stream - -/* - The following example demonstrates the 'Headers' and 'Stream' properties - of the 'SoapMessage' class. The program extends the - 'SoapExtension' class to create a class that is used to log the - SOAP messages transferred for a web service method invocation. - Whenever this method is invoked on the client side all the SOAP - message that get transfered both from the client and the server - are written into a log file. -*/ - -#using -#using -#using - -using namespace System::Runtime::InteropServices; -using namespace System; -using namespace System::IO; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -ref class MySoapExtension; - -// A SoapExtensionAttribute that can be associated with an -// XML Web service method. -[AttributeUsage(AttributeTargets::Method)] -public ref class MySoapExtensionAttribute: public SoapExtensionAttribute -{ -private: - String^ myFilename; - int myPriority; - -public: - // Set the name of the log file where SOAP messages will be stored. - MySoapExtensionAttribute() : SoapExtensionAttribute() - { - myFilename = "C:\\logClient.txt"; - } - - property Type^ ExtensionType - { - // Return the type of MySoapExtension. - virtual Type^ get() override - { - return MySoapExtension::typeid; - } - } - - property int Priority - { - // User can set priority of the SoapExtension. - virtual int get() override - { - return myPriority; - } - virtual void set( int value ) override - { - myPriority = value; - } - } - - property String^ Filename - { - String^ get() - { - return myFilename; - } - void set( String^ value ) - { - myFilename = value; - } - } -}; - -public ref class MySoapHeader: public SoapHeader -{ -public: - String^ myText; -}; - -[System::Web::Services::WebServiceBindingAttribute(Name="MathSvcSoap", - Namespace="http://tempuri.org/")] -public ref class MathSvc: public System::Web::Services::Protocols::SoapHttpClientProtocol -{ -public: - MySoapHeader^ mySoapHeader; - - [SoapHeaderAttribute("mySoapHeader",Direction=SoapHeaderDirection::In)] - [System::Web::Services::Protocols::SoapDocumentMethodAttribute( - "http://tempuri.org/Add", - Use=System::Web::Services::Description::SoapBindingUse::Literal, - ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] - [MySoapExtensionAttribute] - Single Add( Single xValue, - Single yValue, - [System::Runtime::InteropServices::Out]interior_ptr returnValue ) - { - mySoapHeader = gcnew MySoapHeader; - mySoapHeader->myText = "This is the first SOAP header"; - array^ temp0 = {xValue,yValue}; - array^ results = this->Invoke( "Add", temp0 ); - *returnValue = (Single)( results[ 1 ] ); - return (Single)( results[ 0 ] ); - } - - [System::Diagnostics::DebuggerStepThroughAttribute] - MathSvc() - { - this->Url = "http://localhost/SoapMessage_Headers.cs.asmx"; - } - - System::IAsyncResult^ BeginAdd( Single xValue, Single yValue, - System::AsyncCallback^ callback, Object^ asyncState ) - { - array^ temp1 = { xValue, yValue }; - return this->BeginInvoke( "Add", temp1, callback, asyncState ); - } - - Single EndAdd( System::IAsyncResult^ asyncResult, - [System::Runtime::InteropServices::Out]interior_ptr returnValue ) - { - array^ results = this->EndInvoke( asyncResult ); - *returnValue = (Single)( results[ 1 ] ); - return (Single)( results[ 0 ] ); - } -}; - -public ref class MySoapExtension: public SoapExtension -{ -private: - Stream^ myOldStream; - Stream^ myNewStream; - String^ myFileName; - -public: - // Return the filename that is to log the SOAP messages. - virtual Object^ GetInitializer( LogicalMethodInfo^ /*myMethodInfo*/, - SoapExtensionAttribute^ mySoapExtensionAttributeObject ) override - { - return ( (MySoapExtensionAttribute^)( mySoapExtensionAttributeObject ) )->Filename; - } - - // Return the filename that is to log the SOAP messages. - virtual Object^ GetInitializer( Type^ myFileName ) override - { - return (Type^)( myFileName ); - } - - // Save the name of the log file that shall save the SOAP messages. - virtual void Initialize( Object^ myInitializer ) override - { - myFileName = (String^)( myInitializer ); - } - - // Process the SOAP message received and write to log file. - virtual void ProcessMessage( SoapMessage^ myMessage ) override - { - switch ( myMessage->Stage ) - { - case SoapMessageStage::BeforeSerialize: - WriteOutputBeforeSerialize( myMessage ); - break; - case SoapMessageStage::AfterSerialize: - WriteOutputAfterSerialize( myMessage ); - break; - case SoapMessageStage::BeforeDeserialize: - WriteInputBeforeDeserialize( myMessage ); - break; - case SoapMessageStage::AfterDeserialize: - WriteInputAfterDeserialize( myMessage ); - break; - default: - throw gcnew Exception( "invalid stage" ); - } - } - - // - // Write the contents of the outgoing SOAP message to the log file. -public: - void WriteOutputBeforeSerialize( SoapMessage^ myMessage ) - { - FileStream^ myFileStream = gcnew FileStream( - myFileName, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( - "================================== Request at {0}", DateTime::Now ); - - myStreamWriter->WriteLine( "The values of the in parameters are:" ); - myStreamWriter->WriteLine( "Value of first in parameter: {0}", - myMessage->GetInParameterValue( 0 ) ); - myStreamWriter->WriteLine( "Value of second in parameter: {0}", - myMessage->GetInParameterValue( 1 ) ); - - myStreamWriter->Write( "Number of headers for the current request: " ); - myStreamWriter->WriteLine( myMessage->Headers->Count ); - - myStreamWriter->WriteLine(); - myStreamWriter->Flush(); - myStreamWriter->Close(); - myFileStream->Close(); - } - // - - // Write the contents of the incoming SOAP message to the log file. - void WriteInputAfterDeserialize( SoapMessage^ myMessage ) - { - FileStream^ myFileStream = gcnew FileStream( - myFileName, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine(); - - myStreamWriter->WriteLine( "The values of the out parameter are:" ); - myStreamWriter->WriteLine( "The value of the out parameter is: {0}", - myMessage->GetOutParameterValue( 0 ) ); - - myStreamWriter->WriteLine( "The values of the return parameter are:" ); - myStreamWriter->WriteLine( "The value of the return parameter is: {0}", - myMessage->GetReturnValue() ); - - myStreamWriter->Flush(); - myStreamWriter->Close(); - myFileStream->Close(); - } - - // Write the contents of the outgoing SOAP message to the log file. - void WriteOutputAfterSerialize( SoapMessage^ /*myMessage*/ ) - { - myNewStream->Position = 0; - FileStream^ myFileStream = gcnew FileStream( - myFileName, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->Flush(); - Copy( myNewStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - myNewStream->Position = 0; - Copy( myNewStream, myOldStream ); - } - - // - // Write the contents of the incoming SOAP message to the log file. -public: - void WriteInputBeforeDeserialize( SoapMessage^ myMessage ) - { - Copy( myOldStream, myNewStream ); - FileStream^ myFileStream = - gcnew FileStream( myFileName, FileMode::Append, FileAccess::Write ); - StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream ); - myStreamWriter->WriteLine( - "---------------------------------- Response at {0}", DateTime::Now ); - Stream^ myStream = myMessage->Stream; - myStreamWriter->Write( "Length of data in the current response: " ); - myStreamWriter->WriteLine( myStream->Length ); - myStreamWriter->Flush(); - myNewStream->Position = 0; - Copy( myNewStream, myFileStream ); - myStreamWriter->Close(); - myFileStream->Close(); - myNewStream->Position = 0; - } - // - - // Return a new MemoryStream for SOAP processing. - virtual Stream^ ChainStream( Stream^ myStream ) override - { - myOldStream = myStream; - myNewStream = gcnew MemoryStream; - return myNewStream; - } - - // Utility method to copy the contents of one stream to another. - void Copy( Stream^ fromStream, Stream^ toStream ) - { - TextReader^ myTextReader = gcnew StreamReader( fromStream ); - TextWriter^ myTextWriter = gcnew StreamWriter( toStream ); - myTextWriter->WriteLine( myTextReader->ReadToEnd() ); - myTextWriter->Flush(); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage_Headers/CPP/SvcClient_SoapMessage_Headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage_Headers/CPP/SvcClient_SoapMessage_Headers.cpp deleted file mode 100644 index 94a498bce1658..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapMessage_Headers/CPP/SvcClient_SoapMessage_Headers.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - This program is used as a client of the client proxy class. -*/ - -#using - -using namespace System; - -public class SvcClient -{ -public: - static void Main() - { - } -}; \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapOperationBinding/CPP/soapoperationbinding.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapOperationBinding/CPP/soapoperationbinding.cpp deleted file mode 100644 index c0254af595f91..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapOperationBinding/CPP/soapoperationbinding.cpp +++ /dev/null @@ -1,104 +0,0 @@ - - -// System.Web.Services.Description.SoapBinding -// System.Web.Services.Description.SoapOperationBinding -// System.Web.Services.Description.SoapBodyBinding -// System.Web.Services.Description.SoapAddressBinding -// System.Web.Services.Description.SoapBinding.HttpTransport; -/* -The following example demonstrates the 'SoapBinding', 'SoapOperationBinding' , -'SoapBodyBinding' , SoapAddressBinding' classes and 'HttpTransport' field of 'SoapBinding' class. - -It takes a wsdl file which supports two protocols 'HttpGet' and 'HttpPost' as input. By using the -'Read' method of 'ServiceDescription' class it gets the 'ServiceDescription' object. It uses -the SOAP protocol related classes and creates 'Binding','Port' and 'PortType' elements of -'SOAP' protocol. It adds all the elements to the 'ServiceDescription' object. The 'ServiceDescription' -object creates another wsdl file which supports 'SOAP' also. This wsdl file is used to generate a proxy -which is used by the .aspx file. -*/ -// -// -// -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - ServiceDescription^ myDescription = ServiceDescription::Read( "AddNumbersInput_cs.wsdl" ); - - // Create a 'Binding' object for the 'SOAP' protocol. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "Service1Soap"; - XmlQualifiedName^ qualifiedName = gcnew XmlQualifiedName( "s0:Service1Soap" ); - myBinding->Type = qualifiedName; - - // - SoapBinding^ mySoapBinding = gcnew SoapBinding; - mySoapBinding->Transport = SoapBinding::HttpTransport; - mySoapBinding->Style = SoapBindingStyle::Document; - // - - // Add the 'SoapBinding' object to the 'Binding' object. - myBinding->Extensions->Add( mySoapBinding ); - - // Create the 'OperationBinding' object for the 'SOAP' protocol. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - - // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. - SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; - mySoapOperationBinding->SoapAction = "http://tempuri.org/AddNumbers"; - mySoapOperationBinding->Style = SoapBindingStyle::Document; - - // Add the 'SoapOperationBinding' object to 'OperationBinding' object. - myOperationBinding->Extensions->Add( mySoapOperationBinding ); - - // Create the 'InputBinding' object for the 'SOAP' protocol. - InputBinding^ myInput = gcnew InputBinding; - SoapBodyBinding^ mySoapBinding1 = gcnew SoapBodyBinding; - mySoapBinding1->Use = SoapBindingUse::Literal; - myInput->Extensions->Add( mySoapBinding1 ); - - // Assign the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInput; - - // Create the 'OutputBinding' object' for the 'SOAP' protocol.. - OutputBinding^ myOutput = gcnew OutputBinding; - myOutput->Extensions->Add( mySoapBinding1 ); - - // Assign the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myDescription->Bindings->Add( myBinding ); - Port^ soapPort = gcnew Port; - soapPort->Name = "Service1Soap"; - soapPort->Binding = gcnew XmlQualifiedName( "s0:Service1Soap" ); - - // Create a 'SoapAddressBinding' object for the 'SOAP' protocol. - SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; - mySoapAddressBinding->Location = "http://localhost/AddNumbers.cs.asmx"; - - // Add the 'SoapAddressBinding' to the 'Port'. - soapPort->Extensions->Add( mySoapAddressBinding ); - - // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. - myDescription->Services[ 0 ]->Ports->Add( soapPort ); - - // Write the 'ServiceDescription' as a WSDL file. - myDescription->Write( "AddNumbersOut_cs.wsdl" ); - Console::WriteLine( " 'AddNumbersOut_cs.Wsdl' file was generated" ); -} -// -// -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp deleted file mode 100644 index 1c316326d9cc1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp +++ /dev/null @@ -1,171 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -[SoapType("EmployeeType")] -public ref class Employee -{ -public: - String^ Name; -}; - - -// The SoapType is overridden when the -// SerializeOverride method is called. - -[SoapType("SoapGroupType","http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - array^Employees; -}; - -public ref class Run -{ -public: - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can be used for serializing as a SOAP message. - XmlTypeMapping^ mapp = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( mapp ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an XML text writer. - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( writer ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - Employee^ e1 = gcnew Employee; - e1->Name = "Pat"; - myGroup->Employees = gcnew array(1); - myGroup->Employees[ 0 ] = e1; - - // Write the root element. - xmlWriter->WriteStartElement( "root" ); - - // Serialize the class. - mySerializer->Serialize( xmlWriter, myGroup ); - - // Close the root tag. - xmlWriter->WriteEndElement(); - - // Close the XmlWriter. - xmlWriter->Close(); - - // Close the TextWriter. - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // uses a SoapAttributeOverrides Object*. - XmlSerializer^ mySerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an XML text writer. - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( writer ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - Employee^ e1 = gcnew Employee; - e1->Name = "Pat"; - myGroup->Employees = gcnew array(1); - myGroup->Employees[ 0 ] = e1; - - // Write the root element. - xmlWriter->WriteStartElement( "root" ); - - // Serialize the class. - mySerializer->Serialize( xmlWriter, myGroup ); - - // Close the root tag. - xmlWriter->WriteEndElement(); - - // Close the XmlWriter. - xmlWriter->Close(); - - // Close the TextWriter. - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrideSerializer(); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Create an XML text reader. - XmlTextReader^ xmlReader = gcnew XmlTextReader( reader ); - xmlReader->ReadStartElement(); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( xmlReader )); - xmlReader->ReadEndElement(); - Console::WriteLine( "The GroupName is {0}", myGroup->GroupName ); - Console::WriteLine( "Look at the SoapType.xml and SoapType2.xml " - "files for the generated XML." ); - - // Close the readers. - xmlReader->Close(); - reader->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - // Create and return an XmlSerializer instance used to - // and create SOAP messages. - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - - // Override the SoapTypeAttribute. - SoapTypeAttribute^ soapType = gcnew SoapTypeAttribute; - soapType->TypeName = "Team"; - soapType->IncludeInSchema = false; - soapType->Namespace = "http://www.microsoft.com"; - soapAtts->SoapType = soapType; - mySoapAttributeOverrides->Add( Group::typeid, soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer Object*. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapType.xml" ); - test->SerializeOverride( "SoapType2.xml" ); - test->DeserializeObject( "SoapType2.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp deleted file mode 100644 index 252b39958805b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -using namespace System::Security::Permissions; -using namespace System::Collections; - -void MySocketPermission() -{ -// -// - // Creates a SocketPermission restricting access to and from all URIs. - SocketPermission^ mySocketPermission1 = gcnew SocketPermission( PermissionState::None ); - - // The socket to which this permission will apply will allow connections from www.contoso.com. - mySocketPermission1->AddPermission( NetworkAccess::Accept, TransportType::Tcp, "www.contoso.com", 11000 ); - - // Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com. - SocketPermission^ mySocketPermission2 = gcnew SocketPermission( NetworkAccess::Connect,TransportType::Tcp, "www.southridgevideo.com",11002 ); - - // Creates a SocketPermission from the union of two SocketPermissions. - SocketPermission^ mySocketPermissionUnion = - (SocketPermission^)( mySocketPermission1->Union( mySocketPermission2 ) ); - - // Checks to see if the union was successfully created by using the IsSubsetOf method. - if ( mySocketPermission1->IsSubsetOf( mySocketPermissionUnion ) && - mySocketPermission2->IsSubsetOf( mySocketPermissionUnion ) ) - { - Console::WriteLine( "This union contains permissions from both mySocketPermission1 and mySocketPermission2" ); - - // Prints the allowable accept URIs to the console. - Console::WriteLine( "This union accepts connections on :" ); - - IEnumerator^ myEnumerator = mySocketPermissionUnion->AcceptList; - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( safe_cast( myEnumerator->Current )->ToString() ); - } - - // Prints the allowable connect URIs to the console. - Console::WriteLine( "This union permits connections to :" ); - - myEnumerator = mySocketPermissionUnion->ConnectList; - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( safe_cast( myEnumerator->Current )->ToString() ); - } - } -// - -// - // Creates a SocketPermission from the intersect of two SocketPermissions. - SocketPermission^ mySocketPermissionIntersect = - (SocketPermission^)( mySocketPermission1->Intersect( mySocketPermissionUnion ) ); - - // mySocketPermissionIntersect should now contain the permissions of mySocketPermission1. - if ( mySocketPermission1->IsSubsetOf( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "This is expected" ); - } - - // mySocketPermissionIntersect should not contain the permissios of mySocketPermission2. - if ( mySocketPermission2->IsSubsetOf( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "This should not print" ); - } -// - -// - // Creates a copy of the intersect SocketPermission. - SocketPermission^ mySocketPermissionIntersectCopy = - (SocketPermission^)( mySocketPermissionIntersect->Copy() ); - if ( mySocketPermissionIntersectCopy->Equals( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "Copy successfull" ); - } -// - - // Converts a SocketPermission to XML format and then immediately converts it back to a SocketPermission. - mySocketPermission1->FromXml( mySocketPermission1->ToXml() ); - - // Checks to see if permission for this socket resource is unrestricted. If it is, then there is no need to - // demand that permissions be enforced. - if ( mySocketPermissionUnion->IsUnrestricted() ) - { - //Do nothing. There are no restrictions. - } - else - { - // Enforces the permissions found in mySocketPermissionUnion on any Socket Resources used below this statement. - mySocketPermissionUnion->Demand(); - } - - IPHostEntry^ myIpHostEntry = Dns::Resolve( "www.contoso.com" ); - IPEndPoint^ myLocalEndPoint = gcnew IPEndPoint( myIpHostEntry->AddressList[ 0 ], 11000 ); - - Socket^ s = gcnew Socket( myLocalEndPoint->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - s->Connect( myLocalEndPoint ); - } - catch ( Exception^ e ) - { - Console::Write( "Exception Thrown: " ); - Console::WriteLine( e->ToString() ); - } - - // Perform all socket operations in here. - s->Close(); -// -} - -int main() -{ - MySocketPermission(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp deleted file mode 100644 index 9cc9a851cc9a6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -namespace SocketOptionExamples -{ - ref class SocketPropertyTester - { - // - static void ConfigureTcpSocket(Socket^ tcpSocket) - { - - // Don't allow another socket to bind to this port. - tcpSocket->ExclusiveAddressUse = true; - - // The socket will linger for 10 seconds after - // Socket.Close is called. - tcpSocket->LingerState = gcnew LingerOption(true, 10); - - // Disable the Nagle Algorithm for this tcp socket. - tcpSocket->NoDelay = true; - - // Set the receive buffer size to 8k - tcpSocket->ReceiveBufferSize = 8192; - - // Set the timeout for synchronous receive methods to - // 1 second (1000 milliseconds.) - tcpSocket->ReceiveTimeout = 1000; - - // Set the send buffer size to 8k. - tcpSocket->SendBufferSize = 8192; - - // Set the timeout for synchronous send methods - // to 1 second (1000 milliseconds.) - tcpSocket->SendTimeout = 1000; - - // Set the Time To Live (TTL) to 42 router hops. - tcpSocket->Ttl = 42; - Console::WriteLine("Tcp Socket configured:"); - Console::WriteLine(" ExclusiveAddressUse {0}", - tcpSocket->ExclusiveAddressUse); - Console::WriteLine(" LingerState {0}, {1}", - tcpSocket->LingerState->Enabled, - tcpSocket->LingerState->LingerTime); - Console::WriteLine(" NoDelay {0}", - tcpSocket->NoDelay); - Console::WriteLine(" ReceiveBufferSize {0}", - tcpSocket->ReceiveBufferSize); - Console::WriteLine(" ReceiveTimeout {0}", - tcpSocket->ReceiveTimeout); - Console::WriteLine(" SendBufferSize {0}", - tcpSocket->SendBufferSize); - Console::WriteLine(" SendTimeout {0}", - tcpSocket->SendTimeout); - Console::WriteLine(" Ttl {0}", - tcpSocket->Ttl); - Console::WriteLine(" IsBound {0}", - tcpSocket->IsBound); - Console::WriteLine(""); - } - // - // - static void ConfigureUdpSocket(Socket^ udpSocket) - { - - // Set the Don't Fragment flag. - udpSocket->DontFragment = true; - - // Enable broadcast. - udpSocket->EnableBroadcast = true; - - // Disable multicast loopback. - udpSocket->MulticastLoopback = false; - Console::WriteLine("Udp Socket configured:"); - Console::WriteLine(" DontFragment {0}", - udpSocket->DontFragment); - Console::WriteLine(" EnableBroadcast {0}", - udpSocket->EnableBroadcast); - Console::WriteLine(" MulticastLoopback {0}", - udpSocket->MulticastLoopback); - } - // - public: - static void Work() - { - Socket^ tcpSocket = gcnew Socket( - AddressFamily::InterNetwork, - SocketType::Stream, ProtocolType::IP); - Socket^ udpSocket = gcnew Socket( - AddressFamily::InterNetwork, - SocketType::Dgram, ProtocolType::IP); - ConfigureTcpSocket(tcpSocket); - ConfigureUdpSocket(udpSocket); - } - }; -} - -int main() -{ - SocketOptionExamples::SocketPropertyTester::Work(); - return 0; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Async_Send_Receive/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Async_Send_Receive/CPP/source.cpp deleted file mode 100644 index 4c44c03d6717d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Async_Send_Receive/CPP/source.cpp +++ /dev/null @@ -1,304 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -// -public ref class StateObject -{ -public: - literal int BUFFER_SIZE = 1024; - Socket^ workSocket; - array^ buffer; - StringBuilder^ sb; - StateObject() : workSocket( nullptr ) - { - buffer = gcnew array(BUFFER_SIZE); - sb = gcnew StringBuilder; - } -}; -// - -ref class Async_Send_Receive -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void Connect() - { -// - IPHostEntry^ lipa = Dns::Resolve( "host.contoso.com" ); - IPEndPoint^ lep = gcnew IPEndPoint( lipa->AddressList[ 0 ], 11000 ); - - Socket^ s = gcnew Socket( lep->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - while ( true ) - { - allDone->Reset(); - - Console::WriteLine( "Establishing Connection" ); - s->BeginConnect( lep, gcnew AsyncCallback( - &Async_Send_Receive::Connect_Callback ), s ); - - allDone->WaitOne(); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -// - } - - static void Listen() - { -// - IPHostEntry^ lipa = Dns::Resolve( "host.contoso.com" ); - IPEndPoint^ lep = gcnew IPEndPoint( lipa->AddressList[ 0 ], 11000 ); - - Socket^ s = gcnew Socket( lep->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - s->Bind( lep ); - s->Listen( 1000 ); - - while ( true ) - { - allDone->Reset(); - - Console::WriteLine( "Waiting for a connection..." ); - s->BeginAccept( gcnew AsyncCallback( &Async_Send_Receive::Connect_Callback ), s ); - - allDone->WaitOne(); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -// - } - - static void SendTo() - { -// - IPHostEntry^ lipa = Dns::Resolve( "host.contoso.com" ); - IPEndPoint^ lep = gcnew IPEndPoint( lipa->AddressList[ 0 ], 11000 ); - - Socket^ s = gcnew Socket( lep->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - while ( true ) - { - allDone->Reset(); - - array^ buff = Encoding::ASCII->GetBytes( "This is a test" ); - - Console::WriteLine( "Sending Message Now.." ); - s->BeginSendTo( buff, 0, buff->Length, SocketFlags::None, lep, - gcnew AsyncCallback( &Async_Send_Receive::Connect_Callback ), s ); - - allDone->WaitOne(); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -// - } - - static void ReceiveFrom() - { -// - IPHostEntry^ lipa = Dns::Resolve( "host.contoso.com" ); - IPEndPoint^ lep = gcnew IPEndPoint( lipa->AddressList[ 0 ], 11000 ); - - Socket^ s = gcnew Socket( lep->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any, 0 ); - EndPoint^ tempRemoteEP = (EndPoint^)( sender ); - s->Connect( sender ); - - try - { - while ( true ) - { - allDone->Reset(); - StateObject^ so2 = gcnew StateObject; - so2->workSocket = s; - Console::WriteLine( "Attempting to Receive data from host.contoso.com" ); - - s->BeginReceiveFrom( so2->buffer, 0, StateObject::BUFFER_SIZE, SocketFlags::None, tempRemoteEP, - gcnew AsyncCallback( &Async_Send_Receive::ReceiveFrom_Callback ), so2 ); - allDone->WaitOne(); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -// - } - - static void ReceiveFrom1(){ -// - IPHostEntry^ lipa = Dns::Resolve( "host.contoso.com" ); - IPEndPoint^ lep = gcnew IPEndPoint( lipa->AddressList[ 0 ], 11000); - - Socket^ s = gcnew Socket( lep->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp); - - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any, 0 ); - EndPoint^ tempRemoteEP = (EndPoint^)( sender ); - s->Connect( sender ); - - try{ - while(true){ - allDone->Reset(); - StateObject^ so2 = gcnew StateObject(); - so2->workSocket = s; - Console::WriteLine( "Attempting to Receive data from host.contoso.com" ); - - s->BeginReceiveFrom( so2->buffer, 0, StateObject::BUFFER_SIZE, SocketFlags::None, tempRemoteEP, - gcnew AsyncCallback( &Async_Send_Receive::ReceiveFrom_Callback), so2); - allDone->WaitOne(); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -// - } - - static void Connect_Callback( IAsyncResult^ ar ) - { -// - allDone->Set(); - Socket^ s = safe_cast(ar->AsyncState); - s->EndConnect( ar ); - StateObject^ so2 = gcnew StateObject; - so2->workSocket = s; - array^ buff = Encoding::ASCII->GetBytes( "This is a test" ); - s->BeginSend( buff, 0, buff->Length, SocketFlags::None, - gcnew AsyncCallback( &Async_Send_Receive::Send_Callback ), so2 ); -// - } - - static void Send_Callback( IAsyncResult^ ar ) - { -// - StateObject^ so = safe_cast(ar->AsyncState); - Socket^ s = so->workSocket; - - int send = s->EndSend( ar ); - - Console::WriteLine( "The size of the message sent was : {0}", send ); - - s->Close(); -// - } - -// - static void Listen_Callback( IAsyncResult^ ar ) - { - allDone->Set(); - Socket^ s = safe_cast(ar->AsyncState); - Socket^ s2 = s->EndAccept( ar ); - StateObject^ so2 = gcnew StateObject; - so2->workSocket = s2; - s2->BeginReceive( so2->buffer, 0, StateObject::BUFFER_SIZE, SocketFlags::None, - gcnew AsyncCallback( &Async_Send_Receive::Read_Callback ), so2 ); - } -// - -// - static void Read_Callback( IAsyncResult^ ar ) - { - StateObject^ so = safe_cast(ar->AsyncState); - Socket^ s = so->workSocket; - - int read = s->EndReceive( ar ); - - if ( read > 0 ) - { - so->sb->Append( Encoding::ASCII->GetString( so->buffer, 0, read ) ); - s->BeginReceive( so->buffer, 0, StateObject::BUFFER_SIZE, SocketFlags::None, - gcnew AsyncCallback( &Async_Send_Receive::Read_Callback ), so ); - } - else - { - if ( so->sb->Length > 1 ) - { - //All of the data has been read, so displays it to the console - String^ strContent = so->sb->ToString(); - Console::WriteLine( String::Format( "Read {0} byte from socket" + - " data = {1} ", strContent->Length, strContent ) ); - } - s->Close(); - } - } - // - - static void SendTo_Callback( IAsyncResult^ ar ) - { -// - StateObject^ so = safe_cast(ar->AsyncState); - Socket^ s = so->workSocket; - - int send = s->EndSendTo( ar ); - - Console::WriteLine( "The size of the message sent was : {0}", send ); - - s->Close(); -// - } - - static void ReceiveFrom_Callback( IAsyncResult^ ar ) - { -// - StateObject^ so = safe_cast(ar->AsyncState); - Socket^ s = so->workSocket; - - // Creates a temporary EndPoint to pass to EndReceiveFrom. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ tempRemoteEP = safe_cast(sender); - - int read = s->EndReceiveFrom( ar, tempRemoteEP ); - - if ( read > 0 ) - { - so->sb->Append( Encoding::ASCII->GetString( so->buffer, 0, read ) ); - s->BeginReceiveFrom( so->buffer, 0, StateObject::BUFFER_SIZE, SocketFlags::None, - tempRemoteEP, gcnew AsyncCallback( &Async_Send_Receive::ReceiveFrom_Callback ), so ); - } - else - { - if ( so->sb->Length > 1 ) - { - //All the data has been read, so displays it to the console. - String^ strContent = so->sb->ToString(); - Console::WriteLine( "Read {0} byte from socket" + - " data = {1}", strContent->Length, strContent ); - } - s->Close(); - } -// - } -}; - -void main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp deleted file mode 100644 index d7441a3cbf9b3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -#using -#define NULL 0 - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -using namespace System::Collections; -public ref class Sync_Send_Receive -{ -public: - - //Displays sending and receiving with a connected socket -- buffer only - static void SendReceive1() - { - - // - IPHostEntry^ lipa = Dns::Resolve( Dns::GetHostName() ); - - //Gets three separate local endpoints. - IPEndPoint^ lep1 = gcnew IPEndPoint( lipa->AddressList[ 0 ],11000 ); - IPEndPoint^ lep2 = gcnew IPEndPoint( lipa->AddressList[ 0 ],11001 ); - IPEndPoint^ lep3 = gcnew IPEndPoint( lipa->AddressList[ 0 ],11002 ); - - //creates an array of endpoints. - array^ipendpoints = gcnew array(3); - ipendpoints[ 0 ] = lep1; - ipendpoints[ 1 ] = lep2; - ipendpoints[ 2 ] = lep3; - - //Creates three separate sockets. - Socket^ s1 = gcnew Socket( lep1->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - Socket^ s2 = gcnew Socket( lep2->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - Socket^ s3 = gcnew Socket( lep3->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - array^socketList = gcnew array(3); - socketList[ 0 ] = s1; - socketList[ 1 ] = s2; - socketList[ 2 ] = s3; - - //Binds and Listens on all sockets in the array of sockets. - for ( int i = 0; i < 3; i++ ) - { - socketList[ i ]->Bind( ipendpoints[ i ] ); - socketList[ i ]->Listen( 1000 ); - - } - - //Calls Select to determine which sockets are ready for reading. - Socket::Select( safe_cast(socketList), nullptr, nullptr, 1000 ); - - //Reads on the sockets returned by Select. - array^buffer = gcnew array(1024); - String^ outString; - for ( Int32 j = 0; j < (socketList->Length - 1); j++ ) - { - socketList[ j ]->Receive( buffer ); - outString = "Socket "; - outString->Concat( j.ToString(), " has the message", Encoding::ASCII->GetString( buffer ) ); - Console::WriteLine( outString ); - - } - } - -}; - -int main() -{ - return 0; -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp deleted file mode 100644 index e799e953dee9e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp +++ /dev/null @@ -1,128 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -String^ DoSocketGet( String^ server ) -{ - - //Set up variables and String to write to the server. - Encoding^ ASCII = Encoding::ASCII; - String^ Get = "GET / HTTP/1.1\r\nHost: "; - Get->Concat( server, "\r\nConnection: Close\r\n\r\n" ); - array^ByteGet = ASCII->GetBytes( Get ); - array^RecvBytes = gcnew array(256); - String^ strRetPage = nullptr; - - // IPAddress and IPEndPoint represent the endpoint that will - // receive the request. - // Get first IPAddress in list return by DNS. - try - { - - // Define those variables to be evaluated in the next for loop and - // then used to connect to the server. These variables are defined - // outside the for loop to make them accessible there after. - Socket^ s = nullptr; - IPEndPoint^ hostEndPoint; - IPAddress^ hostAddress = nullptr; - int conPort = 80; - - // Get DNS host information. - IPHostEntry^ hostInfo = Dns::Resolve( server ); - - // Get the DNS IP addresses associated with the host. - array^IPaddresses = hostInfo->AddressList; - - // Evaluate the socket and receiving host IPAddress and IPEndPoint. - for ( int index = 0; index < IPaddresses->Length; index++ ) - { - hostAddress = IPaddresses[ index ]; - hostEndPoint = gcnew IPEndPoint( hostAddress,conPort ); - - // - // Creates the Socket to send data over a TCP connection. - s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // - // Connect to the host using its IPEndPoint. - s->Connect( hostEndPoint ); - if ( !s->Connected ) - { - - // Connection failed, try next IPaddress. - strRetPage = "Unable to connect to host"; - s = nullptr; - continue; - } - - - // - // Sent the GET request to the host. - s->Send( ByteGet, ByteGet->Length, SocketFlags::None ); - - // - - } - - // - // Receive the host home page content and loop until all the data is received. - Int32 bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage = "Default HTML page on "; - strRetPage->Concat( server, ":\r\n", ASCII->GetString( RecvBytes, 0, bytes ) ); - while ( bytes > 0 ) - { - bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage->Concat( ASCII->GetString( RecvBytes, 0, bytes ) ); - } - - - // - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNULLException caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "NULLReferenceException caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - - return strRetPage; -} - -int main() -{ - Console::WriteLine( DoSocketGet( "localhost" ) ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp deleted file mode 100644 index 8d52d9461b9a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -public ref class Sync_Send_Receive -{ -public: - static void SetSocketOptions() - { - IPHostEntry^ lipa = Dns::Resolve( "host.contoso.com" ); - IPEndPoint^ lep = gcnew IPEndPoint( lipa->AddressList[ 0 ],11000 ); - Socket^ s = gcnew Socket( lep->Address->AddressFamily, SocketType::Stream,ProtocolType::Tcp ); - -// - // Specifies that send operations will time-out - // if confirmation is not received within 1000 milliseconds. - s->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::SendTimeout, 1000 ); - - // Specifies that the Socket will linger for 10 seconds after Close is called. - LingerOption^ lingerOption = gcnew LingerOption( true,10 ); - - s->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Linger, lingerOption ); -// - - s->Connect( lep ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - -// - Console::Write( "This application will timeout if Send does not return within " ); - Console::WriteLine( Encoding::ASCII->GetString( s->GetSocketOption( SocketOptionLevel::Socket, SocketOptionName::SendTimeout, 4 ) ) ); - - // Blocks until send returns. - int i = s->Send( msg ); - - // Blocks until read returns. - array^ bytes = gcnew array(1024); - - s->Receive( bytes ); - - //Displays to the screen. - Console::WriteLine( Encoding::ASCII->GetString( bytes ) ); - s->Shutdown( SocketShutdown::Both ); - Console::Write( "If data remains to be sent, this application will stay open for " ); - Console::WriteLine( safe_cast(s->GetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Linger ))->LingerTime.ToString() ); - s->Close(); -// - } - - static void CheckProperties() - { - IPHostEntry^ lipa = Dns::Resolve( "host.contoso.com" ); - IPEndPoint^ lep = gcnew IPEndPoint( lipa->AddressList[ 0 ],11000 ); - -// - Socket^ s = gcnew Socket( lep->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - - //Uses the AddressFamily, SocketType, and ProtocolType properties. - Console::Write( "I just set the following properties of socket: \n" ); - Console::Write( "Address Family = {0}", s->AddressFamily.ToString() ); - Console::Write( "\nSocketType = {0}", s->SocketType.ToString() ); - Console::WriteLine( "\nProtocolType = {0}", s->ProtocolType.ToString() ); -// - -// - s->Connect( lep ); - - // Uses the RemoteEndPoint property. - Console::WriteLine( "I am connected to {0} on port number {1}", - IPAddress::Parse( ( ( (IPEndPoint^)(s->RemoteEndPoint) )->Address)->ToString() ), - ( (IPEndPoint^)(s->RemoteEndPoint) )->Port.ToString() ); - - // Uses the LocalEndPoint property. - Console::Write( "My local IpAddress is : {0}\nI am connected on port number {1}", - IPAddress::Parse( ( ( (IPEndPoint^)(s->LocalEndPoint) )->Address)->ToString() ), - ( (IPEndPoint^)(s->LocalEndPoint) )->Port.ToString() ); -// - -// - //Uses low level method IOControl to set this socket to blocking mode. - int code = 0x8004667E; - array^ inBuf = gcnew array(4); - - inBuf[ 0 ] = 0; - - array^ outBuf = gcnew array(4); - - s->IOControl( code, inBuf, outBuf ); - - //Checks to see that this worked. - if ( s->Blocking ) - { - Console::WriteLine( "Socket was set to Blocking mode successfully" ); - } -// - } -}; - -int main(){} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp deleted file mode 100644 index 2c6dda9ea2a29..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp +++ /dev/null @@ -1,449 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -// -// Displays sending with a connected socket -// using the overload that takes a buffer. -int SendReceiveTest1( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - // Blocks until send returns. - int byteCount = server->Send( msg ); - Console::WriteLine( "Sent {0} bytes.", byteCount.ToString() ); - - // Get reply from the server. - byteCount = server->Receive( bytes ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return ( e->ErrorCode ); - } - return 0; -} -// - -// Displays receiving from a connected tcp socket -// using the overload that takes a buffer. -int ReceiveTest1( Socket^ client ) -{ - array^ bytes = gcnew array(256); - try - { - // It is usually preferable to use the overload - // that allows you to specify the maximum bytes returned. - if ( client->Available > 256 ) - { - throw gcnew ApplicationException( "This test socket only takes messages < 256 bytes." ); - } - // Blocks until read returns. - int byteCount = client->Receive( bytes ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - // Send reply to the client. - client->Send( Encoding::UTF8->GetBytes( "Bye." ) ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return ( e->ErrorCode ); - } - return 0; -} - -// -// Displays sending with a connected socket -// using the overload that takes a buffer and socket flags. -int SendReceiveTest2( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - // Blocks until send returns. - int byteCount = server->Send( msg, SocketFlags::None ); - Console::WriteLine( "Sent {0} bytes.", byteCount.ToString() ); - - // Get reply from the server. - byteCount = server->Receive( bytes, SocketFlags::None ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return (e->ErrorCode); - } - return 0; -} -// - -// -// Displays sending with a connected socket -// using the overload that takes a buffer, message size, and socket flags. -int SendReceiveTest3( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - // Blocks until send returns. - int i = server->Send( msg, msg->Length, SocketFlags::None ); - Console::WriteLine( "Sent {0} bytes.", i.ToString() ); - - // Get reply from the server. - int byteCount = server->Receive( bytes, server->Available, - SocketFlags::None ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return (e->ErrorCode); - } - return 0; -} -// - -// -// Displays sending with a connected socket -// using the overload that takes a buffer, offset, message size, and socket flags. -int SendReceiveTest4( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - - // Blocks until send returns. - int byteCount = server->Send( msg, 0, msg->Length, SocketFlags::None ); - Console::WriteLine( "Sent {0} bytes.", byteCount.ToString() ); - - // Get reply from the server. - byteCount = server->Receive( bytes, 0, server->Available, - SocketFlags::None ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return (e->ErrorCode); - } - return 0; -} -// - -public ref class NeedForDelegates -{ -public: - - // - static void SendTo1() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, endPoint ); - s->Close(); - } - // - - // - static void SendTo2() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, SocketFlags::None, endPoint ); - s->Close(); - } - // - - // - static void SendTo3() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, msg->Length, SocketFlags::None, endPoint ); - s->Close(); - } - // - - // - static void SendTo4() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, 0, msg->Length, SocketFlags::None, endPoint ); - s->Close(); - } - // - - // The ReceiveFroms - // - static void ReceiveFrom1() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IPEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "Waiting to receive datagrams from client..." ); - - // This call blocks. - s->ReceiveFrom( msg, senderRemote ); - s->Close(); - } - // - - // - static void ReceiveFrom2() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IpEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "Waiting to receive datagrams from client..." ); - // This call blocks. - s->ReceiveFrom( msg, SocketFlags::None, senderRemote ); - s->Close(); - } - // - - // - static void ReceiveFrom3() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IPEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "SWaiting to receive datagrams from client..." ); - // This call blocks. - s->ReceiveFrom( msg, msg->Length, SocketFlags::None, senderRemote ); - s->Close(); - } - // - - // - static void ReceiveFrom4() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IpEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "SWaiting to receive datagrams from client..." ); - // This call blocks. - s->ReceiveFrom( msg, 0, msg->Length, SocketFlags::None, senderRemote ); - s->Close(); - } - // - // end NeedForDelegates -}; - -void RunUdpTests() -{ - // Test the upd versions. - - //NeedForDelegates^ n = new NeedForDelegates(); - ThreadStart^ myThreadDelegate = gcnew ThreadStart( &NeedForDelegates::ReceiveFrom1 ); - Thread^ myThread1 = gcnew Thread( myThreadDelegate ); - myThread1->Start(); - - while ( myThread1->IsAlive == true ) - { - NeedForDelegates::SendTo1(); - } - myThread1->Join(); - - Console::WriteLine( "UDP test2" ); - Thread^ myThread2 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom2 ) ); - myThread2->Start(); - while ( myThread2->IsAlive == true ) - { - NeedForDelegates::SendTo2(); - } - myThread2->Join(); - - Console::WriteLine( "UDP test3" ); - Thread^ myThread3 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom3 ) ); - myThread3->Start(); - while ( myThread3->IsAlive == true ) - { - NeedForDelegates::SendTo3(); - } - myThread3->Join(); - - Console::WriteLine( "UDP test4" ); - Thread^ myThread4 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom4 ) ); - myThread4->Start(); - while ( myThread4->IsAlive == true ) - { - NeedForDelegates::SendTo4(); - } - myThread4->Join(); -} - -//Main tests the snippets. -// To test tcp - run 2 instances source /s runs server, source /c runs client. -// To test Upd run source /u. -int main( int /*argc*/, char *args[] ) -{ - String^ host; - bool isServer; - - if ( args[ 1 ][ 1 ] == 'c' ) - { - isServer = false; - host = "127.0.0.1"; - } - else - if ( args[ 1 ][ 1 ] == 'u' ) - { - Console::WriteLine( "running udptests" ); - RunUdpTests(); - return 0; - } - else - { - host = "localhost"; - isServer = true; - } - - // Set up the endpoint and create the socket. - IPHostEntry^ hostEntry = Dns::Resolve( host ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - // Test the TCPIP snippets (Socket.Send and Socket.Receive) - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - - // Send or receive the test messages. - if ( isServer ) - { - Socket^ sender = nullptr; - s->Bind( endPoint ); - s->Listen( 1 ); - for ( ; ; ) - { - sender = s->Accept(); - // exchange messages with all clients tests - for ( int i = 0; i < 4; i++ ) - { - ReceiveTest1( sender ); - } - sender->Close(); - s->Close(); - Environment::Exit( 0 ); - } - } - // Its the client tcp tests. - else - { - s->Connect( endPoint ); - SendReceiveTest1( s ); - SendReceiveTest2( s ); - SendReceiveTest3( s ); - SendReceiveTest4( s ); - s->Close(); - } - - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/makefile deleted file mode 100644 index 3243b84415fb5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/makefile +++ /dev/null @@ -1,6 +0,0 @@ -all: queuedcomponent.dll queuedcomponentclientclass.exe -queuedcomponent.dll: queuedcomponent.cpp - cl /clr:pure /LD queuedcomponent.cpp - -queuedcomponentclientclass.exe: queuedcomponentclientclass.cpp queuedcomponent.dll - cl /clr:pure queuedcomponentclientclass.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/queuedcomponent.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/queuedcomponent.cpp deleted file mode 100644 index e40bac9464b31..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/queuedcomponent.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -#using - -using namespace System; -using namespace System::EnterpriseServices; -using namespace System::Runtime::InteropServices; -using namespace System::Reflection; - -[assembly:AssemblyKeyFile("key.snk")]; -[assembly:ApplicationName("Queued Component")]; -[assembly:ApplicationID("AC6F4BE6-66E5-4a94-8162-A7F850150F9F")]; -[assembly:ApplicationActivation(ActivationOption::Server)]; -// Ensure that the example shows how to call the queued component. -// See QueuedComponentClient for example - -// -// Mark the COM+ application as queued at compile time by using the -// ApplicationQueuing attribute. Enable the COM+ listener by -// setting the QueueListenerEnabled to true -[assembly:ApplicationQueuing(Enabled=true,QueueListenerEnabled=true)]; -// - -[Guid("9A6233C4-7459-4c1a-808A-905FC648B5A8")] -// -public interface class IQueuedComponent -{ - void QueuedTask(); -}; - - -// Mark IQueuedComponent interface as queued -// Create the queued component class by inheriting the -// System.EnterpriseServices.ServicedComponent class and an -// interface that is marked as queued with the InterfaceQueuing attribute - -[InterfaceQueuing(true,Interface="IQueuedComponent")] -public ref class QueuedComponent sealed: public ServicedComponent, public IQueuedComponent -{ -public: - virtual void QueuedTask() - { - // Perform queued task here - } - -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/queuedcomponentclientclass.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/queuedcomponentclientclass.cpp deleted file mode 100644 index 3a9ce01642073..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.EnterpriseServices.QueuedComponents/CPP/queuedcomponentclientclass.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -#using - -using namespace System; - -[STAThread] -int main() -{ - for ( int counter = 0; counter < 10; counter++ ) - { - - // - // Use BindToMoniker to run the queued moniker, to get an instance of the recorder - IQueuedComponent ^ qc = dynamic_cast(System::Runtime::InteropServices::Marshal::BindToMoniker( "queue:/new:QueuedComponent" )); - - // Call the method that will be recorded - qc->QueuedTask(); - - // Force the release of the recorder object, to send the message to the queue - System::Runtime::InteropServices::Marshal::ReleaseComObject( qc ); - // - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp deleted file mode 100644 index 59ce360624012..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp +++ /dev/null @@ -1,355 +0,0 @@ - - -// -// This program contains snippets applicable to the following: -// System::Net::AuthenticationManger (Snippet1); -// System::Net::AuthenticationManger::Register (Snippet2); -// System::Net::AuthenticationUnregister (Snippet2); -// System::Net::AuthenticationManger::RegisteredModules (Snippet8); -// System::Net::Authorization::Authorization (Snippet3); -// System::Net::Authorization::Message (Snippet5); -// System::Net::Authorization::Complete (Snippet5); -// System::Net::Authorization::GroupId (Snippet5); -// System::Net::IAuthenticationModule* (Snippet6); -// System::Net::IAuthenticationModule*.AuthenticationType (Snippet7); -// System::Net::IAuthenticationModule*.CanPreAuthenticate (Snippet7); -// System::Net::IAuthenticationModule*.Authenticate (Snippet3); -// System::Net::IAuthenticationModule*.PreAuthenticate (Snippet4); -// -// -// This program shows how to create a custom Basic authentication module, -// how to register it via the AuthenticationManager class and how to authorize -// users to access a Web site. -// Note: In order to run this program you must create a test Web site that performs -// Basic authentication. Also you must add to your server machine a user whose -// credentials are the same you use in this program. -// Attention: Basic authenticastion sends the user's credentials over HTTP. -// Passwords and user names are encoded using Base64 encoding. Although the -// user information is encoded, it is considered insecure due to the fact that it -// could be deciphered relatively easily. -// If you must use basic authentication you are strongly adviced to use strong -// security mechanisms, such as SSL, when transfering sensitive information on -// the wire. -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Collections; - -// The ClientAuthentication class performs the following main tasks: -// 1) It obtains the user's credentials. -// 2) Unregisters the standard Basic authentication. -// 3) Registers the customized Basic authentication. -// 4) Reads the selected page and displays it on the console. -ref class TestAuthentication -{ -public: - static String^ username; - static String^ password; - static String^ domain; - static String^ uri; - - // Show how to use this program. - static void showusage() - { - Console::WriteLine( "Attempts to authenticate to a URL" ); - Console::WriteLine( "\r\nUse one of the following:" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password domain" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password" ); - Console::WriteLine( "\r\nExample:" ); - Console::WriteLine( "\tcustomBasicAuthentication http://ndpue/ncl/ basicuser basic.101 ndpue" ); - } - - - // - // Display registered authentication modules. - static void displayRegisteredModules() - { - - // The AuthenticationManager calls all authentication modules sequentially - // until one of them responds with an authorization instance. Show - // the current registered modules, for testing purposes. - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - Console::WriteLine( "\r\nThe following authentication modules are now registered with the system" ); - while ( registeredModules->MoveNext() ) - { - Console::WriteLine( "\r \n Module : {0}", registeredModules->Current ); - IAuthenticationModule^ currentAuthenticationModule = dynamic_cast(registeredModules->Current); - Console::WriteLine( "\t CanPreAuthenticate : {0}", currentAuthenticationModule->CanPreAuthenticate ); - } - } - - - // - // The getPage method accesses the selected page an displays its content - // on the console. - static void getPage( String^ url ) - { - try - { - - // Create the Web request object. - HttpWebRequest^ req = dynamic_cast(WebRequest::Create( url )); - - // Define the request access method. - req->Method = "GET"; - - // Define the request credentials according to the user's input. - if ( String::Compare( domain, String::Empty ) == 0 ) - req->Credentials = gcnew NetworkCredential( username,password ); // If the user's specifies the Internet resource domain, this usually - else - req->Credentials = gcnew NetworkCredential( username,password,domain ); - - // is by default the name of the sever hosting the resource. - // Issue the request. - // req->GetResponse(); - HttpWebResponse^ result = dynamic_cast(req->GetResponse()); - Console::WriteLine( "\nAuthentication Succeeded:" ); - - // Store the response. - Stream^ sData = result->GetResponseStream(); - - // Display the response. - displayPageContent( sData ); - } - catch ( WebException^ e ) - { - - // Display the error, if any. In particular display protocol - // related error. - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - HttpWebResponse^ hresp = dynamic_cast(e->Response); - Console::WriteLine( "\nAuthentication Failed, {0}", hresp->StatusCode ); - Console::WriteLine( "Status Code: {0}", (int)hresp->StatusCode ); - Console::WriteLine( "Status Description: {0}", hresp->StatusDescription ); - return; - } - Console::WriteLine( "Caught Exception: {0}", e->Message ); - Console::WriteLine( "Stack: {0}", e->StackTrace ); - } - - } - - - // The displayPageContent method display the content of the - // selected page. - static void displayPageContent( Stream^ ReceiveStream ) - { - - // Create an ASCII encoding object. - Encoding^ ASCII = Encoding::ASCII; - - // Define the Byte array to temporary hold the current read bytes. - array^read = gcnew array(512); - Console::WriteLine( "\r\nPage Content...\r\n" ); - - // Read the page content and display it on the console. - // Read the first 512 bytes. - int bytes = ReceiveStream->Read( read, 0, 512 ); - while ( bytes > 0 ) - { - Console::Write( ASCII->GetString( read, 0, bytes ) ); - bytes = ReceiveStream->Read( read, 0, 512 ); - } - - Console::WriteLine( "" ); - } - -}; - - -// -// The CustomBasic class creates a custom Basic authentication by implementing the -// IAuthenticationModule interface. In particular it performs the following -// tasks: -// 1) Defines and initializes the required properties. -// 2) Impements the Authenticate method. -public ref class CustomBasic: public IAuthenticationModule -{ -private: - - // - String^ m_authenticationType; - bool m_canPreAuthenticate; - -public: - - // The CustomBasic constructor initializes the properties of the customized - // authentication. - CustomBasic() - { - m_authenticationType = "Basic"; - m_canPreAuthenticate = false; - } - - - property String^ AuthenticationType - { - - // Define the authentication type. This type is then used to identify this - // custom authentication module. The default is set to Basic. - virtual String^ get() - { - return m_authenticationType; - } - - } - - property bool CanPreAuthenticate - { - - // Define the pre-authentication capabilities for the module. The default is set - // to false. - virtual bool get() - { - return m_canPreAuthenticate; - } - - } - - // - // The checkChallenge method checks if the challenge sent by the HttpWebRequest - // contains the correct type (Basic) and the correct domain name. - // Note: the challenge is in the form BASIC REALM=S"DOMAINNAME" - // and you must assure that the Internet Web site resides on a server whose - // domain name is equal to DOMAINAME. - bool checkChallenge( String^ Challenge, String^ domain ) - { - bool challengePasses = false; - String^ tempChallenge = Challenge->ToUpper(); - - // Verify that this is a Basic authorization request and the requested domain - // is correct. - // Note: When the domain is an empty string the following code only checks - // whether the authorization type is Basic. - if ( tempChallenge->IndexOf( "BASIC" ) != -1 ) - if ( String::Compare( domain, String::Empty ) != 0 ) - if ( tempChallenge->IndexOf( domain->ToUpper() ) != -1 ) - challengePasses = true; // The domain is not allowed and the authorization type is Basic. - else - challengePasses = false; - - else - challengePasses = true; - - - return challengePasses; - } - - - // - // The PreAuthenticate method specifies if the authentication implemented - // by this class allows pre-authentication. - // Even if you do not use it, this method must be implemented to obey to the rules - // of interface implemebtation. - // In this case it always returns null. - virtual Authorization^ PreAuthenticate( WebRequest^ request, ICredentials^ credentials ) - { - return nullptr; - } - - - // - // - // Authenticate is the core method for this custom authentication. - // When an internet resource requests authentication, the WebRequest::GetResponse - // method calls the AuthenticationManager::Authenticate method. This method, in - // turn, calls the Authenticate method on each of the registered authentication - // modules, in the order they were registered. When the authentication is - // complete an Authorization object is returned to the WebRequest, as - // shown by this routine's retun type. - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - Encoding^ ASCII = Encoding::ASCII; - - // Get the username and password from the credentials - NetworkCredential^ MyCreds = credentials->GetCredential( request->RequestUri, "Basic" ); - if ( PreAuthenticate( request, credentials ) == nullptr ) - Console::WriteLine( "\n Pre-authentication is not allowed." ); - else - Console::WriteLine( "\n Pre-authentication is allowed." ); - - - // Verify that the challenge satisfies the authorization requirements. - bool challengeOk = checkChallenge( challenge, MyCreds->Domain ); - if ( !challengeOk ) - return nullptr; - - - // - // Create the encrypted string according to the Basic authentication format as - // follows: - // a)Concatenate username and password separated by colon; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain the encoded - // authorization. - String^ BasicEncrypt = String::Concat( MyCreds->UserName, ":", MyCreds->Password ); - String^ BasicToken = String::Concat( "Basic ", Convert::ToBase64String( ASCII->GetBytes( BasicEncrypt ) ) ); - - // Create an Authorization object using the above encoded authorization. - Authorization^ resourceAuthorization = gcnew Authorization( BasicToken ); - - // Get the Message property which contains the authorization string that the - // client returns to the server when accessing protected resources - Console::WriteLine( "\n Authorization Message: {0}", resourceAuthorization->Message ); - - // Get the Complete property which is set to true when the authentication process - // between the client and the server is finished. - Console::WriteLine( "\n Authorization Complete: {0}", resourceAuthorization->Complete ); - - // - Console::WriteLine( "\n Authorization ConnectionGroupId: {0}", resourceAuthorization->ConnectionGroupId ); - return resourceAuthorization; - } - - // -}; - - -// -// This is the program entry point. It allows the user to enter -// their credentials and the Internet resource (Web page) to access. -// It also unregisters the standard and registers the customized basic -// authentication. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - TestAuthentication::showusage(); - else - { - - // Read the user's credentials. - TestAuthentication::uri = args[ 1 ]; - TestAuthentication::username = args[ 2 ]; - TestAuthentication::password = args[ 3 ]; - if ( args->Length == 4 ) - TestAuthentication::domain = String::Empty; // If the domain exists, store it. Usually the domain name - else - TestAuthentication::domain = args[ 4 ]; - - // is by default the name of the server hosting the Internet - // resource. - // Instantiate the custom Basic authentication module. - CustomBasic^ customBasicModule = gcnew CustomBasic; - - // Unregister the standard Basic authentication module. - AuthenticationManager::Unregister( "Basic" ); - - // Register the custom Basic authentication module. - AuthenticationManager::Register( customBasicModule ); - - // Display registered Authorization modules. - TestAuthentication::displayRegisteredModules(); - - // Read the specified page and display it on the console. - TestAuthentication::getPage( TestAuthentication::uri ); - } -} - -// -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp deleted file mode 100644 index 6c79604640fee..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -using namespace System::Collections; - -ref class DNSChanges -{ - -// -public: - static void DoGetHostEntry(String^ hostname) - { - IPHostEntry^ host = Dns::GetHostEntry(hostname); - - Console::WriteLine("GetHostEntry({0}) returns:", host->HostName); - - for (int i = 0; i < host->AddressList->Length; i++) - { - Console::WriteLine(" {0}", host->AddressList[i]->ToString()); - } - } -// - -// -public: - static void DoGetHostEntry(IPAddress^ address) - { - IPHostEntry^ host = Dns::GetHostEntry(address); - - Console::WriteLine("GetHostEntry({0}) returns HostName: {1}", address->ToString(), host->HostName); - } -// - -// - // Determine the Internet Protocol(IP) addresses for a host. -public: - static void DoGetHostAddress(String^ hostname) - { - array^ addresses; - addresses = Dns::GetHostAddresses(hostname); - - Console::WriteLine("GetHostAddresses({0}) returns:", hostname); - for each (IPAddress^ address in addresses) - { - Console::Write("{0} ", address); - } - Console::WriteLine(""); - } -// - -// - // Signals when the resolve has finished. -public: - static ManualResetEvent^ GetHostEntryFinished = - gcnew ManualResetEvent(false); - - // define the state object for the callback. - // use hostName to correlate calls with the proper result. - ref class ResolveState - { - public: - String^ hostName; - IPHostEntry^ resolvedIPs; - - ResolveState(String^ host) - { - hostName = host; - } - - property IPHostEntry^ IPs - { - IPHostEntry^ get() - { - return resolvedIPs; - } - - void set(IPHostEntry^ IPs) - { - resolvedIPs = IPs; - } - } - - property String^ host - { - String^ get() - { - return hostName; - } - - void set(String^ host) - { - hostName = host; - } - } - }; - - // Record the IPs in the state object for later use. - static void GetHostEntryCallback(IAsyncResult^ ar) - { - ResolveState^ ioContext = (ResolveState^)(ar->AsyncState); - - ioContext->IPs = Dns::EndGetHostEntry(ar); - GetHostEntryFinished->Set(); - } - - - // Determine the Internet Protocol(IP) addresses for this - // host asynchronously. -public: - static void DoGetHostEntryAsync(String^ hostName) - { - GetHostEntryFinished->Reset(); - ResolveState^ ioContext = gcnew ResolveState(hostName); - - Dns::BeginGetHostEntry(ioContext->host, - gcnew AsyncCallback(GetHostEntryCallback), ioContext); - // Wait here until the resolve completes - // (the callback calls .Set()) - GetHostEntryFinished->WaitOne(); - - Console::WriteLine("EndGetHostEntry({0}) returns:", ioContext->host); - - for (int i = 0; i < ioContext->IPs->AddressList->Length; i++) - { - Console::WriteLine(" {0}", ioContext->IPs->AddressList[i]->ToString()); - } - -// for each (IPAddress^ address in ioContext->IPs) -// { -// Console::WriteLine("{0} ", address); -// } - } -// -}; - -int main() -{ - DNSChanges::DoGetHostEntry("www.contoso.com"); - DNSChanges::DoGetHostEntry(IPAddress::Parse("127.0.0.1")); - DNSChanges::DoGetHostAddress("www.contoso.com"); - DNSChanges::DoGetHostEntryAsync(""); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp deleted file mode 100644 index 5896e74c960dd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp +++ /dev/null @@ -1,120 +0,0 @@ - - -// -// This program contains examples for the following types and methods: -// System::Net::FileWebRequest::GetResponse; -// -// -// -// This program shows how to use the FileWebRequest::GetResponse method -// to read and display the content of a file passed by the user. -// Note. In order for this program to work, the folder containing the test file -// must be shared with its permissions set to allow read access. -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -ref class TestGetResponse -{ -private: - static FileWebResponse^ myFileWebResponse; - static void showUsage() - { - Console::WriteLine( "\nPlease enter file name:" ); - Console::WriteLine( "Usage: cs_getresponse //" ); - Console::WriteLine( "Example: cs_getresponse ndpue/temp/hello.txt" ); - } - - static bool makeFileRequest( String^ fileName ) - { - bool requestOk = false; - try - { - Uri^ myUrl = gcnew Uri( String::Format( "file://{0}", fileName ) ); - - // Create a Filewebrequest object using the passed Uri. - FileWebRequest^ myFileWebRequest = dynamic_cast(WebRequest::Create( myUrl )); - - // Get the FileWebResponse object. - myFileWebResponse = dynamic_cast(myFileWebRequest->GetResponse()); - requestOk = true; - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatWebException: {0}", e->Message ); - } - - return requestOk; - } - - static void readFile() - { - try - { - - // Create the file stream. - Stream^ receiveStream = myFileWebResponse->GetResponseStream(); - - // Create a reader object to read the file content. - StreamReader^ readStream = gcnew StreamReader( receiveStream ); - - // Create a local buffer for a temporary storage of the - // read data. - array^readBuffer = gcnew array(256); - - // Read the first up to 256 bytes. - int count = readStream->Read( readBuffer, 0, 256 ); - Console::WriteLine( "The file content is:" ); - Console::WriteLine( "" ); - - // Loop to read the remaining bytes in 256 blocks - // and display the data on the console. - while ( count > 0 ) - { - String^ str = gcnew String( readBuffer,0,count ); - Console::WriteLine( "{0}\n", str ); - count = readStream->Read( readBuffer, 0, 256 ); - } - readStream->Close(); - - // Release the response object resources. - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "The WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "The UriFormatException: {0}", e->Message ); - } - - } - - -public: - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - showUsage(); - else - { - if ( makeFileRequest( args[ 1 ] ) ) - readFile(); - } - } - -}; - -int main() -{ - TestGetResponse::Main(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp deleted file mode 100644 index 0dc5fc9d3fe4c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp +++ /dev/null @@ -1,134 +0,0 @@ - - -// -// This program contains examples for the following types and methods: -// System::Net::FileWebRequest (Snippet1); System::Net::FileWebRequest::Method (Snippet2); -// System::Net::FileWebRequest::Timeout (Snippet3); -// System::Net::FileWebRequest::ContentLength (Snippet4). -// System::Net::FileWebRequest::GetRequestStream (Snippet5); -// -// -// This program creates or open a text file in which it stores a string. -// Both file and string are passed by the user. -// Note. In order for this program to work, the folder containing the test file -// must be shared with its permissions set to allow write access. -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Net; -ref class TestGetRequestStream -{ -private: - static FileWebRequest^ myFileWebRequest; - static void showUsage() - { - Console::WriteLine( "\nPlease enter file name and timeout :" ); - Console::WriteLine( "Usage: cs_getrequeststream // timeout" ); - Console::WriteLine( "Example: cs_getrequeststream ndpue/temp/hello.txt 1000" ); - Console::WriteLine( "Small timeout values (for instance 3 or less) cause a timeout exception." ); - } - - static void makeFileRequest( String^ fileName, int timeout ) - { - try - { - - // - // - // Create a Uri object. - Uri^ myUrl = gcnew Uri( String::Format( "file://{0}", fileName ) ); - - // Create a FileWebRequest object. - myFileWebRequest = dynamic_cast(WebRequest::CreateDefault( myUrl )); - - // Set the timeout to the value selected by the user. - myFileWebRequest->Timeout = timeout; - - // - // Set the Method property to POST - myFileWebRequest->Method = "POST"; - - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatWebException: {0}", e->Message ); - } - - } - - static void writeToFile() - { - try - { - - // - // Enter the string to write into the file. - Console::WriteLine( "Enter the string you want to write:" ); - String^ userInput = Console::ReadLine(); - - // Convert the string to Byte array. - ASCIIEncoding^ encoder = gcnew ASCIIEncoding; - array^byteArray = encoder->GetBytes( userInput ); - - // - // Set the ContentLength property. - myFileWebRequest->ContentLength = byteArray->Length; - String^ contentLength = myFileWebRequest->ContentLength.ToString(); - Console::WriteLine( "\nThe content length is {0}.", contentLength ); - - // - // Get the file stream handler to write into the file. - Stream^ readStream = myFileWebRequest->GetRequestStream(); - - // Write to the file stream. - // Note. In order for this to work the file must be accessible - // on the network. This can be accomplished by setting the property - // sharing of the folder containg the file. The permissions - // can be set so everyone can modify the file. - // FileWebRequest::Credentials property cannot be used for this purpose. - readStream->Write( byteArray, 0, userInput->Length ); - Console::WriteLine( "\nThe String you entered was successfully written into the file." ); - - // - readStream->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "The WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "The UriFormatWebException: {0}", e->Message ); - } - - } - - -public: - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 3 ) - showUsage(); - else - { - makeFileRequest( args[ 1 ], Int32::Parse( args[ 2 ] ) ); - writeToFile(); - } - } - -}; - -int main() -{ - TestGetRequestStream::Main(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.HttpWebRequest.BeginGetResponse/CPP/begingetresponse.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.HttpWebRequest.BeginGetResponse/CPP/begingetresponse.cpp deleted file mode 100644 index 0a03d4e4da187..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.HttpWebRequest.BeginGetResponse/CPP/begingetresponse.cpp +++ /dev/null @@ -1,195 +0,0 @@ - - -/** -* File name: Begingetresponse::cs -* This program shows how to use BeginGetResponse and EndGetResponse methods of the -* HttpWebRequest class. It also shows how to create a customized timeout. -* This is important in case od asynchronous request, because the NCL classes do -* not provide any off-the-shelf asynchronous timeout. -* It uses an asynchronous approach to get the response for the HTTP Web Request. -* The RequestState class is defined to chekc the state of the request. -* After a HttpWebRequest Object* is created, its BeginGetResponse method is used to start -* the asynchronous response phase. -* Finally, the EndGetResponse method is used to end the asynchronous response phase . -*/ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -public ref class RequestState -{ -private: - - // This class stores the State of the request. - const int BUFFER_SIZE; - -public: - StringBuilder^ requestData; - array^BufferRead; - HttpWebRequest^ request; - HttpWebResponse^ response; - Stream^ streamResponse; - RequestState() - : BUFFER_SIZE( 1024 ) - { - BufferRead = gcnew array(BUFFER_SIZE); - requestData = gcnew StringBuilder( "" ); - request = nullptr; - streamResponse = nullptr; - } - -}; - -ref class HttpWebRequest_BeginGetResponse -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - literal int BUFFER_SIZE = 1024; - literal int DefaultTimeOut = 120000; // 2 minute timeout - - // Abort the request if the timer fires. - static void TimeoutCallback( Object^ state, bool timedOut ) - { - if ( timedOut ) - { - HttpWebRequest^ request = dynamic_cast(state); - if ( request != nullptr ) - { - request->Abort(); - } - } - } - - static void RespCallback( IAsyncResult^ asynchronousResult ) - { - try - { - - // State of request is asynchronous. - RequestState^ myRequestState = dynamic_cast(asynchronousResult->AsyncState); - HttpWebRequest^ myHttpWebRequest = myRequestState->request; - myRequestState->response = dynamic_cast(myHttpWebRequest->EndGetResponse( asynchronousResult )); - - // Read the response into a Stream object. - Stream^ responseStream = myRequestState->response->GetResponseStream(); - myRequestState->streamResponse = responseStream; - - // Begin the Reading of the contents of the HTML page and print it to the console. - IAsyncResult^ asynchronousInputRead = responseStream->BeginRead( myRequestState->BufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - return; - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nRespCallback Exception raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - - allDone->Set(); - } - - static void ReadCallBack( IAsyncResult^ asyncResult ) - { - try - { - RequestState^ myRequestState = dynamic_cast(asyncResult->AsyncState); - Stream^ responseStream = myRequestState->streamResponse; - int read = responseStream->EndRead( asyncResult ); - - // Read the HTML page and then print it to the console. - if ( read > 0 ) - { - myRequestState->requestData->Append( Encoding::ASCII->GetString( myRequestState->BufferRead, 0, read ) ); - IAsyncResult^ asynchronousResult = responseStream->BeginRead( myRequestState->BufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - return; - } - else - { - Console::WriteLine( "\nThe contents of the Html page are : " ); - if ( myRequestState->requestData->Length > 1 ) - { - String^ stringContent; - stringContent = myRequestState->requestData->ToString(); - Console::WriteLine( stringContent ); - } - Console::WriteLine( "Press any key to continue.........." ); - Console::ReadLine(); - responseStream->Close(); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nReadCallBack Exception raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - - allDone->Set(); - } - -}; - -int main() -{ - try - { - - // Create a HttpWebrequest object to the desired URL. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - - /** - * If you are behind a firewall and you do not have your browser proxy setup - * you need to use the following proxy creation code. - - // Create a proxy object. - WebProxy* myProxy = new WebProxy(); - - // Associate a new Uri object to the _wProxy object, using the proxy address - // selected by the user. - myProxy.Address = new Uri(S"http://myproxy"); - - // Finally, initialize the Web request object proxy property with the _wProxy - // object. - myHttpWebRequest.Proxy=myProxy; - ***/ - // Create an instance of the RequestState and assign the previous myHttpWebRequest - // object to its request field. - RequestState^ myRequestState = gcnew RequestState; - myRequestState->request = myHttpWebRequest; - - // Start the asynchronous request. - IAsyncResult^ result = dynamic_cast(myHttpWebRequest->BeginGetResponse( gcnew AsyncCallback( HttpWebRequest_BeginGetResponse::RespCallback ), myRequestState )); - - // this line impliments the timeout, if there is a timeout, the callback fires and the request becomes aborted - ThreadPool::RegisterWaitForSingleObject( result->AsyncWaitHandle, gcnew WaitOrTimerCallback( HttpWebRequest_BeginGetResponse::TimeoutCallback ), myHttpWebRequest, HttpWebRequest_BeginGetResponse::DefaultTimeOut, true ); - - // The response came in the allowed time. The work processing will happen in the - // callback function. - HttpWebRequest_BeginGetResponse::allDone->WaitOne(); - - // Release the HttpWebResponse resource. - myRequestState->response->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nMain Exception raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - Console::WriteLine( "Press any key to continue.........." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nMain Exception raised!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - Console::WriteLine( "Press any key to continue.........." ); - Console::Read(); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp deleted file mode 100644 index 826067e44c3a9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/** -* File name: ipaddress_none_any_loopback.cs -* Exercise the IPAddress IPv6None, IPv6Any, and IPv6Loopback properties. -* Usage: cs_nal.exe. -**/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -// -// This method displays the value of the current host loopback address in -// standard compressed format. -void displayIPv6LoopBackAddress() -{ - try - { - // Get the loopback address. - IPAddress^ loopBack = IPAddress::IPv6Loopback; - - // Transform the loop-back address to a string using the overladed - // ToString() method. Note that the resulting string is in the compact - // form: "::1". - String^ ipv6LoopBack = loopBack->ToString(); - Console::WriteLine( "The IPv6 Loopback address is: {0}", ipv6LoopBack ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6LoopBackAddress] Exception: {0}", e ); - } -} -// - -// -// This method displays the value of the current host's Any address in -// standard compressed format. The Any address is used by the host to enable -// listening to client activities on all the interfaces for a given port. -void displayIPv6AnyAddress() -{ - try - { - // Get the Any address. - IPAddress^ any = IPAddress::IPv6Any; - - // Transform the Any address to a string using the overloaded - // ToString() method. Note that the resulting string is in the compact - // form: "::". - String^ ipv6Any = any->ToString(); - - // Display the Any address. - Console::WriteLine( "The IPv6 Any address is: {0}", ipv6Any ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6AnyAddress] Exception: {0}", e ); - } -} -// - -// -// This method displays the value of the current host's None address in -// standard compressed format. The None address is used by the host to disable -// listening to client activities on all the interfaces. -void displayIPv6NoneAddress() -{ - try - { - // Get the None address. - IPAddress^ none = IPAddress::IPv6None; - - // Transform the None address to a string using the overloaded - // ToString() method. Note that the resulting string is in the compact - // form: "::". - String^ ipv6None = none->ToString(); - - Console::WriteLine( "The IPv6 None address is: {0}", ipv6None ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6NoneAddress] Exception: {0}", e ); - } -} -// - -// -// This function checks whether the passed string represents a loop-back address. -void checkIPv6LoopBackAddress( String^ ipAddress ) -{ - try - { - // Parse the passed String* to obtain the internal address - // representation. - IPAddress^ loopBack = IPAddress::Parse( ipAddress ); - - // Verify that the address is a loopback address. - bool isLoopBack = IPAddress::IsLoopback( loopBack ); - - // Build the message. - String^ msg; - if ( isLoopBack ) - { - msg = " is a loop back address."; - } - else - { - msg = " is not a loop back address."; - } - - // Display the results. - Console::WriteLine( String::Concat( ipAddress, msg ) ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6LoopBackAddress] Exception: {0}", e ); - } -} -// - -int main() -{ - // Verify that the current host supports IPv6 and also call WSAStartup. - // If you do not use any IPv6 methods that call WSAStartup, you will get a - // SocketException when using IPv6Loopback, IPv6Any or IPv6None. - - bool ipv6Supported = Socket::SupportsIPv6; - - // Display current host Loopback address. - displayIPv6LoopBackAddress(); - - // Display the current host's Any address. - displayIPv6AnyAddress(); - - // Display the current host's None address. - displayIPv6NoneAddress(); - - // Check that this is a loopback address. - checkIPv6LoopBackAddress( "0::1" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp deleted file mode 100644 index 8c206f281c13a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -/* -This program checks whether the specified address is a loopback address. -It invokes the IPAddress Parse method to translate the address -input String* into the correct internal format. -The IP address String* must be in dotted-quad notation for IPv4 or in -colon-hexadecimal notation for IPv6. -*/ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -// This method calls the IPAddress::Parse method to check if the -// passed ipAddress parameter is in the correct format. -// Then it checks whether it represents a loopback address. -// Finally, it displays the results. -void parse( String^ ipAddress ) -{ - String^ loopBack = " is not a loopback address."; - try - { - - // Perform syntax check by parsing the address string entered by the user. - IPAddress^ address = IPAddress::Parse( ipAddress ); - - // Perform semantic check by verifying that the address is a valid IPv4 - // or IPv6 loopback address. - if ( IPAddress::IsLoopback( address ) && address->AddressFamily == AddressFamily::InterNetworkV6 ) - loopBack = String::Concat( " is an IPv6 loopback address whose internal format is: ", address, "." ); - else - if ( IPAddress::IsLoopback( address ) && address->AddressFamily == AddressFamily::InterNetwork ) - loopBack = String::Concat( " is an IPv4 loopback address whose internal format is: ", address, "." ); - - // Display the results. - Console::WriteLine( "Your input address: \" {0} \" {1}", ipAddress, loopBack ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length == 1 ) - { - - // No parameters entered. Display program usage. - Console::WriteLine( "Please enter an IP address." ); - Console::WriteLine( "Usage: >ipaddress_isloopback any IPv4 or IPv6 address." ); - Console::WriteLine( "Example: >ipaddress_isloopback 127.0.0.1" ); - Console::WriteLine( "Example: >ipaddress_isloopback 0:0:0:0:0:0:0:1" ); - } - else - parse( args[ 1 ] ); - - - // Parse the address string entered by the user. -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp deleted file mode 100644 index e6b401756d01a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp +++ /dev/null @@ -1,73 +0,0 @@ - - -/* -This program converts a String* containing an IP address, in dotted-quad notation for -IPv4 or in colon-hexadecimal for IPv6, into an instance of the IPAddress class. -Then it uses the overloaded IPAddress ToString method to display the address in -its standard notation. -*/ -// -#using - -using namespace System; -using namespace System::Net; - -// This method calls the IPAddress::Parse method to check the ipAddress -// input string. If the ipAddress argument represents a syntatically correct IPv4 or -// IPv6 address, the method displays the Parse output into quad-notation or -// colon-hexadecimal notation, respectively. Otherwise, it displays an -// error message. -void parse( String^ ipAddress ) -{ - try - { - - // Create an instance of IPAddress for the specified address string (in - // dotted-quad, or colon-hexadecimal notation). - IPAddress^ address = IPAddress::Parse( ipAddress ); - - // Display the address in standard notation. - Console::WriteLine( "Parsing your input string: \"{0}\" produces this address (shown in its standard notation): {1}", ipAddress, address ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ IPaddress; - if ( args->Length == 1 ) - { - Console::WriteLine( "Please enter an IP address." ); - Console::WriteLine( "Usage: >cs_parse any IPv4 or IPv6 address." ); - Console::WriteLine( "Example: >cs_parse 127.0.0.1" ); - Console::WriteLine( "Example: >cs_parse 0:0:0:0:0:0:0:1" ); - return 0; - } - else - IPaddress = args[ 1 ]; - - - // Get the list of the IPv6 addresses associated with the requested host. - parse( IPaddress ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp deleted file mode 100644 index 2edddb778a4d6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp +++ /dev/null @@ -1,142 +0,0 @@ - - -// -// File name: ipaddress.cpp -// The snippets contained here apply to: -// 1) System.Net.IPAddress.AddressFamily, snippet3. -// 2) System.Net.IPAddess.ScopeId, snippet3. -// more -// -// -// This program shows how to use the IPAddress class to obtain a server -// IP addressess and related information. -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text::RegularExpressions; - -/** -* The IPAddresses method obtains the selected server IP address information. -* It then displays the type of address family supported by the server and its -* IP address in standard and byte format. -**/ -void IPAddresses( String^ server ) -{ - try - { - System::Text::ASCIIEncoding^ ASCII = gcnew System::Text::ASCIIEncoding; - - // Get server related information. - IPHostEntry^ heserver = Dns::GetHostEntry( server ); - - // Loop on the AddressList - System::Collections::IEnumerator^ myEnum = heserver->AddressList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IPAddress^ curAdd = safe_cast(myEnum->Current); - - // - // Display the type of address family supported by the server. If the - // server is IPv6-enabled this value is: InterNetworkV6. If the server - // is also IPv4-enabled there will be an additional value of InterNetwork. - Console::WriteLine( "AddressFamily: {0}", curAdd->AddressFamily ); - - // Display the ScopeId property in case of IPV6 addresses. - if ( curAdd->AddressFamily.ToString() == ProtocolFamily::InterNetworkV6.ToString() ) - Console::WriteLine( "Scope Id: {0}", curAdd->ScopeId ); - // - - // Display the server IP address in the standard format. In - // IPv4 the format will be dotted-quad notation, in IPv6 it will be - // in colon-hexadecimal notation. - Console::WriteLine( "Address: {0}", curAdd ); - - // Display the server IP address in byte format. - Console::Write( "AddressBytes: " ); - - // - array^bytes = curAdd->GetAddressBytes(); - for ( int i = 0; i < bytes->Length; i++ ) - { - Console::Write( bytes[ i ] ); - - } - // - - Console::WriteLine( "\r\n" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "[DoResolve] Exception: {0}", e ); - } - -} - - -// This IPAddressAdditionalInfo displays additional server address information. -void IPAddressAdditionalInfo() -{ - try - { - // Display the flags that show if the server supports IPv4 or IPv6 - // address schemas. - Console::WriteLine( "\r\nSupportsIPv4: {0}", Socket::SupportsIPv4 ); - Console::WriteLine( "SupportsIPv6: {0}", Socket::SupportsIPv6 ); - if ( Socket::SupportsIPv6 ) - { - // Display the server Any address. This IP address indicates that the server - // should listen for client activity on all network interfaces. - Console::WriteLine( "\r\nIPv6Any: {0}", IPAddress::IPv6Any ); - - // Display the server loopback address. - Console::WriteLine( "IPv6Loopback: {0}", IPAddress::IPv6Loopback ); - - // Used during autoconfiguration first phase. - Console::WriteLine( "IPv6None: {0}", IPAddress::IPv6None ); - Console::WriteLine( "IsLoopback(IPv6Loopback): {0}", IPAddress::IsLoopback( IPAddress::IPv6Loopback ) ); - } - Console::WriteLine( "IsLoopback(Loopback): {0}", IPAddress::IsLoopback( IPAddress::Loopback ) ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "[IPAddresses] Exception: {0}", e ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ server = nullptr; - - // Define a regular expression to parse user's input. - // This is a security check. It allows only - // alphanumeric input string between 2 to 40 character long. - Regex^ rex = gcnew Regex( "^[a-zA-Z]\\w{1,39}$" ); - if ( args->Length < 2 ) - { - // If no server name is passed as an argument to this program, use the current - // server name as default. - server = Dns::GetHostName(); - Console::WriteLine( "Using current host: {0}", server ); - } - else - { - server = args[ 1 ]; - if ( !(rex->Match(server))->Success ) - { - Console::WriteLine( "Input string format not allowed." ); - return -1; - } - } - - // Get the list of the addresses associated with the requested server. - IPAddresses( server ); - - // Get additional address information. - IPAddressAdditionalInfo(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp deleted file mode 100644 index ddd7bf4588d82..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp +++ /dev/null @@ -1,230 +0,0 @@ - - -// File name:ipendpoint.cs. -// -// This program contains snippets applicable to the following: -// System.Net.IPEndPoint (Snippet1); -// System.Net.IPEndPoint.IPEndPoint(IPAddress, int) (Snippet2); -// System.Net.IPEndPoint.Address (Snippet3); -// System.Net.IPEndPoint.AddressFamily (Snippet3); -// System.Net.IPEndPoint.Port (Snippet3); -// System.Net.IPEndPoint.Serialize (Snippet4); -// System.Net.IPEndPoint.Create (Snippet5); -// -// -// This example uses the IPEndPoint class and its members to display the home page -// of the server selected by the user. -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text::RegularExpressions; - -// The getPage function gets the server's home page content by -// recreating the server's endpoint from the original serialized endpoint. -// Then it creates a new socket and connects it to the endpoint. -String^ getPage( String^ server, SocketAddress^ socketAddress ) -{ - //Set up variables and string to write to the server. - Encoding^ ASCII = Encoding::ASCII; - String^ Get = String::Format( "GET / HTTP/1.1\r\nHost: {0}\r\nConnection: Close\r\n\r\n", server ); - array^ByteGet = ASCII->GetBytes( Get ); - array^RecvBytes = gcnew array(256); - String^ strRetPage = nullptr; - Socket^ socket = nullptr; - - // - // Recreate the connection endpoint from the serialized information. - IPEndPoint^ endpoint = gcnew IPEndPoint( (__int64)0,0 ); - IPEndPoint^ clonedIPEndPoint = dynamic_cast(endpoint->Create( socketAddress )); - Console::WriteLine( "clonedIPEndPoint: {0}", clonedIPEndPoint ); - // - - Console::WriteLine( "Press any key to continue." ); - Console::ReadLine(); - try - { - // Create a socket object to establish a connection with the server. - socket = gcnew Socket( endpoint->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the cloned end point. - socket->Connect( clonedIPEndPoint ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - - if ( socket == nullptr ) - return ("Connection to cloned endpoint failed"); - - // Send request to the server. - socket->Send( ByteGet, ByteGet->Length, static_cast(0) ); - - // Receive the server home page content. - Int32 bytes = socket->Receive( RecvBytes, RecvBytes->Length, static_cast(0) ); - - // Read the first 256 bytes. - strRetPage = String::Format( "Default HTML page on {0}:\r\n", server ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - while ( bytes > 0 ) - { - bytes = socket->Receive( RecvBytes, RecvBytes->Length, static_cast(0) ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - } - - socket->Close(); - return strRetPage; -} - -// -// The serializeEndpoint function serializes the endpoint and returns the -// SocketAddress containing the serialized endpoint data. -SocketAddress^ serializeEndpoint( IPEndPoint^ endpoint ) -{ - // Serialize IPEndPoint details to a SocketAddress instance. - SocketAddress^ socketAddress = endpoint->Serialize(); - - // Display the serialized endpoint information. - Console::WriteLine( "Endpoint.Serialize() : {0}", socketAddress ); - Console::WriteLine( "Socket->Family : {0}", socketAddress->Family ); - Console::WriteLine( "Socket->Size : {0}", socketAddress->Size ); - Console::WriteLine( "Press any key to continue." ); - Console::ReadLine(); - return socketAddress; -} -// - -// -void displayEndpointInfo( IPEndPoint^ endpoint ) -{ - Console::WriteLine( "Endpoint->Address : {0}", endpoint->Address ); - Console::WriteLine( "Endpoint->AddressFamily : {0}", endpoint->AddressFamily ); - Console::WriteLine( "Endpoint->Port : {0}", endpoint->Port ); - Console::WriteLine( "Endpoint.ToString() : {0}", endpoint ); - Console::WriteLine( "Press any key to continue." ); - Console::ReadLine(); -} -// - -// The serializeEndpoint function determines the server endpoint and then -// serializes it to obtain the related SocketAddress object. -// Note that in the for loop a temporary socket is created to ensure that -// the current IP address format matches the AddressFamily type. -// In fact, in the case of servers supporting both IPv4 and IPv6, an exception -// may arise if an IP address format does not match the address family type. -SocketAddress^ getSocketAddress( String^ server, int port ) -{ - Socket^ tempSocket = nullptr; - IPHostEntry^ host = nullptr; - SocketAddress^ serializedSocketAddress = nullptr; - try - { - // Get the object containing Internet host information. - host = Dns::Resolve( server ); - - // - // Obtain the IP address from the list of IP addresses associated with the server. - System::Collections::IEnumerator^ myEnum = host->AddressList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IPAddress^ address = safe_cast(myEnum->Current); - IPEndPoint^ endpoint = gcnew IPEndPoint( address,port ); - tempSocket = gcnew Socket( endpoint->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - tempSocket->Connect( endpoint ); - if ( tempSocket->Connected ) - { - // Display the endpoint information. - displayEndpointInfo( endpoint ); - - // Serialize the endpoint to obtain a SocketAddress object. - serializedSocketAddress = serializeEndpoint( endpoint ); - break; - } - else - continue; - } - // - - // Close the temporary socket. - tempSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - - return serializedSocketAddress; -} - - -// The requestServerHomePage function obtains the server's home page and returns -// its content. -String^ requestServerHomePage( String^ server, int port ) -{ - String^ strRetPage = nullptr; - - // Get a socket address using the specified server and port. - SocketAddress^ socketAddress = getSocketAddress( server, port ); - if ( socketAddress == nullptr ) - strRetPage = "Connection failed"; // Obtain the server's home page content. - else - strRetPage = getPage( server, socketAddress ); - - return strRetPage; -} - - -// Show to the user how to use this program when wrong input parameters are entered. -void showUsage() -{ - Console::WriteLine( "Enter the server name as follows:" ); - Console::WriteLine( "\tcs_ipendpoint servername" ); -} - - -// This is the program entry point. It allows the user to enter -// a server name that is used to locate its current homepage. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ host = nullptr; - int port = 80; - - // Define a regular expression to parse user's input. - // This is a security check. It allows only - // alphanumeric input string between 2 to 40 character long. - Regex^ rex = gcnew Regex( "^[a-zA-Z]\\w{1,39}$" ); - if ( args->Length < 2 ) - showUsage(); - else - { - String^ message = args[ 1 ]; - if ( (rex->Match(message))->Success ) - { - host = args[ 1 ]; - - // Get the specified server home_page and display its content. - String^ result = requestServerHomePage( host, port ); - Console::WriteLine( result ); - } - else - Console::WriteLine( "Input string format not allowed." ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp deleted file mode 100644 index 8cd7216c8d8c9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp +++ /dev/null @@ -1,203 +0,0 @@ - - -// -// This example shows how to use the ServicePoint and ServicePointManager classes. -// The ServicePointManager class uses the ServicePoint class to manage connections -// to a remote host. The networking classes reuse service points for all -// requests to a given URI. In fact, the same ServicePoint object -// is used to issue requests to Internet resources identified by the same -// scheme identifier (for example, HTTP) and host fragment (for example, www.contoso.com). -// This should improve your application performance. -// Reusing service points in this way can help improve application performance. -#using - -using namespace System; -using namespace System::Net; -using namespace System::Threading; -using namespace System::Text::RegularExpressions; -void ShowProperties( ServicePoint^ sp ) -{ - Console::WriteLine( "Done calling FindServicePoint()..." ); - - // - // Display the ServicePoint Internet resource address. - Console::WriteLine( "Address = {0}", sp->Address ); - - // - // - // Display the date and time that the ServicePoint was last - // connected to a host. - Console::WriteLine( "IdleSince = {0}", sp->IdleSince ); - - // Display the maximum length of time that the ServicePoint instance - // is allowed to maintain an idle connection to an Internet - // resource before it is recycled for use in another connection. - Console::WriteLine( "MaxIdleTime = {0}", sp->MaxIdleTime ); - - // - // - Console::WriteLine( "ConnectionName = {0}", sp->ConnectionName ); - - // Display the maximum number of connections allowed on this - // ServicePoint instance. - Console::WriteLine( "ConnectionLimit = {0}", sp->ConnectionLimit ); - - // Display the number of connections associated with this - // ServicePoint instance. - Console::WriteLine( "CurrentConnections = {0}", sp->CurrentConnections ); - - // - // - if ( sp->Certificate == nullptr ) - Console::WriteLine( "Certificate = (null)" ); - else - Console::WriteLine( "Certificate = {0}", sp->Certificate ); - - if ( sp->ClientCertificate == nullptr ) - Console::WriteLine( "Client Certificate = (null)" ); - else - Console::WriteLine( "Client Certificate = {0}", sp->ClientCertificate ); - - Console::WriteLine( "ProtocolVersion = {0}", sp->ProtocolVersion->ToString() ); - Console::WriteLine( "SupportsPipelining = {0}", sp->SupportsPipelining ); - - // - // - Console::WriteLine( "UseNagleAlgorithm = {0} ", sp->UseNagleAlgorithm.ToString() ); - Console::WriteLine( "Expect 100-continue = {0}", sp->Expect100Continue.ToString() ); - - // -} - - -// -void makeWebRequest( int hashCode, String^ Uri ) -{ - HttpWebResponse^ res = nullptr; - - // Make sure that the idle time has elapsed, so that a new - // ServicePoint instance is created. - Console::WriteLine( "Sleeping for 2 sec." ); - Thread::Sleep( 2000 ); - try - { - - // Create a request to the passed URI. - HttpWebRequest^ req = dynamic_cast(WebRequest::Create( Uri )); - Console::WriteLine( "\nConnecting to {0} ............", Uri ); - - // Get the response object. - res = dynamic_cast(req->GetResponse()); - Console::WriteLine( "Connected.\n" ); - ServicePoint^ currentServicePoint = req->ServicePoint; - - // Display new service point properties. - int currentHashCode = currentServicePoint->GetHashCode(); - Console::WriteLine( "New service point hashcode: {0}", currentHashCode ); - Console::WriteLine( "New service point max idle time: {0}", currentServicePoint->MaxIdleTime ); - Console::WriteLine( "New service point is idle since {0}", currentServicePoint->IdleSince ); - - // Check that a new ServicePoint instance has been created. - if ( hashCode == currentHashCode ) - Console::WriteLine( "Service point reused." ); - else - Console::WriteLine( "A new service point created." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - finally - { - if ( res != nullptr ) - res->Close(); - } - -} - - -// -// Show the user how to use this program when wrong inputs are entered. -void showUsage() -{ - Console::WriteLine( "Enter the proxy name as follows:" ); - Console::WriteLine( "\tcs_servicepoint proxyName" ); -} - - -// -int main() -{ - array^args = Environment::GetCommandLineArgs(); - int port = 80; - - // Define a regular expression to parse the user's input. - // This is a security check. It allows only - // alphanumeric input strings between 2 to 40 characters long. - Regex^ rex = gcnew Regex( "^[a-zA-Z]\\w{1,39}$" ); - if ( args->Length < 2 ) - { - showUsage(); - return -1; - } - - String^ proxy = args[ 1 ]; - if ( (rex->Match(proxy))->Success != true ) - { - Console::WriteLine( "Input string format not allowed." ); - return -1; - } - - String^ proxyAdd = String::Format( "http://{0}:{1}", proxy, port ); - - // Create a proxy object. - WebProxy^ DefaultProxy = gcnew WebProxy( proxyAdd,true ); - - // Set the proxy that all HttpWebRequest instances use. - WebRequest::DefaultWebProxy = DefaultProxy; - - // Get the base interface for proxy access for the - // WebRequest-based classes. - IWebProxy^ Iproxy = WebRequest::DefaultWebProxy; - - - // - // Set the maximum number of ServicePoint instances to - // maintain. If a ServicePoint instance for that host already - // exists when your application requests a connection to - // an Internet resource, the ServicePointManager object - // returns this existing ServicePoint instance. If none exists - // for that host, it creates a new ServicePoint instance. - ServicePointManager::MaxServicePoints = 4; - - // Set the maximum idle time of a ServicePoint instance to 10 seconds. - // After the idle time expires, the ServicePoint object is eligible for - // garbage collection and cannot be used by the ServicePointManager. - ServicePointManager::MaxServicePointIdleTime = 10000; - - // - // - ServicePointManager::UseNagleAlgorithm = true; - ServicePointManager::Expect100Continue = true; - ServicePointManager::CheckCertificateRevocationList = true; - ServicePointManager::DefaultConnectionLimit = ServicePointManager::DefaultPersistentConnectionLimit; - - // - // Create the Uri object for the resource you want to access. - Uri^ MS = gcnew Uri( "http://msdn.microsoft.com/" ); - - // Use the FindServicePoint method to find an existing - // ServicePoint object or to create a new one. - ServicePoint^ servicePoint = ServicePointManager::FindServicePoint( MS, Iproxy ); - ShowProperties( servicePoint ); - int hashCode = servicePoint->GetHashCode(); - Console::WriteLine( "Service point hashcode: {0}", hashCode ); - - // Make a request with the same scheme identifier and host fragment - // used to create the previous ServicePoint object. - makeWebRequest( hashCode, "http://msdn.microsoft.com/library/" ); -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/makefile deleted file mode 100644 index 98dd6b4094a07..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -System.Net.ServicePointWhidbey.exe : servicepoint.cpp - cl /W4 /clr:pure /FeSystem.Net.ServicePointWhidbey.exe servicepoint.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp deleted file mode 100644 index 75524420dc359..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// This example shows how to use the ServicePoint and ServicePointManager classes. -// The ServicePointManager class uses the ServicePoint class to manage connections -// to a remote host. The networking classes reuse service points for all -// requests to a given URI. In fact, the same ServicePoint object -// is used to issue requests to Internet resources identified by the same -// scheme identifier (for example, HTTP) and host fragment (for example, www.contoso.com). -// This should improve your application performance. -// Reusing service points in this way can help improve application performance. -#using - -using namespace System; -using namespace System::Security; -using namespace System::Net; -using namespace System::Threading; -using namespace System::Text::RegularExpressions; - -void ShowProperties(ServicePoint^ service) -{ - Console::WriteLine("Done calling FindServicePoint()..."); - - // Display the ServicePoint Internet resource address. - Console::WriteLine("Address = {0} ", service->Address); - - // Display the date and time that the ServicePoint was last - // connected to a host. - Console::WriteLine("IdleSince = {0}", service->IdleSince); - - // Display the maximum length of time that the ServicePoint - // instance is allowed to maintain an idle connection to an - // Internet resource before it is recycled for use in another - // connection. - Console::WriteLine("MaxIdleTime = {0}", service->MaxIdleTime); - - Console::WriteLine("ConnectionName = {0}", - service->ConnectionName); - - // Display the maximum number of connections allowed on this - // ServicePoint instance. - Console::WriteLine("ConnectionLimit = {0}", - service->ConnectionLimit); - - // Display the number of connections associated with this - // ServicePoint instance. - Console::WriteLine("CurrentConnections = {0}", - service->CurrentConnections); - - if (service->Certificate == nullptr) - { - Console::WriteLine("Certificate = (null)"); - } - else - { - Console::WriteLine("Certificate = {0}", service->Certificate); - } - - if (service->ClientCertificate == nullptr) - { - Console::WriteLine("ClientCertificate = (null)"); - } - else - { - Console:: WriteLine("ClientCertificate = {0}", - service->ClientCertificate); - } - - Console::WriteLine("ProtocolVersion = {0}", - service->ProtocolVersion); - Console::WriteLine("SupportsPipelining = {0}", - service->SupportsPipelining); - - Console::WriteLine("UseNagleAlgorithm = {0}", - service->UseNagleAlgorithm.ToString()); - Console::WriteLine("Expect 100-continue = {0}", - service->Expect100Continue.ToString()); -} - -void MakeWebRequest(int hashCode, String^ requestedUri) -{ - HttpWebResponse^ response = nullptr; - - // Make sure that the idle time has elapsed, so that a new - // ServicePoint instance is created. - Console::WriteLine("Sleeping for 2 sec."); - Thread::Sleep(2000); - try - { - // Create a request to the passed URI. - HttpWebRequest^ request = - (HttpWebRequest^)WebRequest::Create(requestedUri); - - Console::WriteLine("\nConnecting to {0} ............", - requestedUri); - - // Get the response object. - response = (HttpWebResponse^) request->GetResponse(); - Console::WriteLine("Connected.\n"); - - ServicePoint^ currentServicePoint = request->ServicePoint; - - // Display new service point properties. - int currentHashCode = currentServicePoint->GetHashCode(); - - Console::WriteLine("New service point hashcode: {0}", - currentHashCode); - Console::WriteLine("New service point max idle time: {0}", - currentServicePoint->MaxIdleTime); - Console::WriteLine("New service point is idle since {0}", - currentServicePoint->IdleSince ); - - // Check that a new ServicePoint instance has been created. - if (hashCode == currentHashCode) - { - Console::WriteLine("Service point reused."); - } - else - { - Console::WriteLine("A new service point created.") ; - } - - } - catch (NotSupportedException^ ex) - { - Console::WriteLine( - "The request scheme specified in {0} has not been registered.", - requestedUri); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - catch (SecurityException^ ex) - { - Console::WriteLine( - "You do not have permission to connect to {0}.", - requestedUri); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - catch (UriFormatException^ ex) - { - Console::WriteLine( - "The URI specified in {0} is not a valid URI.", - requestedUri); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - catch (WebException^ ex) - { - Console::WriteLine("The proxy name could not be resolved."); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - finally - { - if (response != nullptr) - { - response->Close(); - } - } -} - -// Show the user how to use this program when wrong inputs are entered. -void ShowUsage() -{ - Console::WriteLine("Enter the proxy name as follows:"); - Console::WriteLine("\tcs_servicepoint proxyName"); -} - - -int main(array^ args) -{ - int port = 80; - - // Define a regular expression to parse the user's input. - // This is a security check. It allows only - // alphanumeric input strings between 2 to 40 characters long. - Regex^ expression = gcnew Regex("^[a-zA-Z]\\w{1,39}$"); - - if (args->Length <= 1) - { - ShowUsage(); - return 0; - } - String^ proxy = args[1]; - - if ((expression->Match(proxy))->Success != true) - { - Console::WriteLine("Input string format not allowed."); - return 0; - } - String^ proxyAddress = "http://" + proxy + ":" + port; - - // Create a proxy object. - WebProxy^ defaultProxy = gcnew WebProxy(proxyAddress, true); - - // Set the proxy that all HttpWebRequest instances use. - GlobalProxySelection::Select = (IWebProxy^)defaultProxy; - - // Get the base interface for proxy access for the - // WebRequest-based classes. - IWebProxy^ proxyInterface = GlobalProxySelection::Select; - - // Set the maximum number of ServicePoint instances to - // maintain. If a ServicePoint instance for that host already - // exists when your application requests a connection to - // an Internet resource, the ServicePointManager object - // returns this existing ServicePoint instance. If none exists - // for that host, it creates a new ServicePoint instance. - ServicePointManager::MaxServicePoints = 4; - - // Set the maximum idle time of a ServicePoint instance to 10 seconds. - // After the idle time expires, the ServicePoint object is eligible for - // garbage collection and cannot be used by the ServicePointManager object. - ServicePointManager::MaxServicePointIdleTime = 10000; - - // - ServicePointManager::UseNagleAlgorithm = true; - ServicePointManager::Expect100Continue = true; - ServicePointManager::CheckCertificateRevocationList = true; - ServicePointManager::DefaultConnectionLimit = - ServicePointManager::DefaultPersistentConnectionLimit; - ServicePointManager::EnableDnsRoundRobin = true; - ServicePointManager::DnsRefreshTimeout = 4*60*1000; // 4 minutes - // - // Create the Uri object for the resource you want to access. - Uri^ msdn = gcnew Uri("http://msdn.microsoft.com/"); - - // Use the FindServicePoint method to find an existing - // ServicePoint object or to create a new one. - ServicePoint^ servicePoint = ServicePointManager::FindServicePoint( - msdn, proxyInterface); - - ShowProperties(servicePoint); - - int hashCode = servicePoint->GetHashCode(); - - Console::WriteLine("Service point hashcode: {0}", hashCode); - - // Make a request with the same scheme identifier and host fragment - // used to create the previous ServicePoint object. - MakeWebRequest(hashCode, "http://msdn.microsoft.com/library/"); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp deleted file mode 100644 index cbceda27de956..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp +++ /dev/null @@ -1,344 +0,0 @@ - - -// This program shows how to create your own Basic authentication module, -// register it via the AuthenticationManager class and authorize allowed -// users to access a page on a Web site. -// Note: In order to run this program you must create a test Web site that performs -// Basic authentication. Also you must add to your server machine a user whose -// credentials are the same you plan to use for this example. -// CAVEAT: Basic authenticastion sends the user's credentials over HTTP. Passwords and -// user names are encoded using Base64 encoding. Although the password is encoded, it -// is considered insecure due its ability to be deciphered relatively easily. -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Collections; - -// -// The CustomBasic class creates a custom Basic authentication by implementing the -// IAuthenticationModule interface. In particular it performs the following -// tasks: -// 1) Defines and intializes the required properties. -// 2) Impements the Authenticate and PreAuthenticate methods. -public ref class CustomBasic: public IAuthenticationModule -{ -private: - - // - String^ m_authenticationType; - bool m_canPreAuthenticate; - -public: - - // The CustomBasic constructor initializes the properties of the customized - // authentication. - CustomBasic() - { - m_authenticationType = "Basic"; - m_canPreAuthenticate = false; - } - - - property String^ AuthenticationType - { - - // Define the authentication type. This type is then used to identify this - // custom authentication module. The default is set to Basic. - virtual String^ get() - { - return m_authenticationType; - } - - } - - property bool CanPreAuthenticate - { - - // Define the pre-authentication capabilities for the module. The default is set - // to false. - virtual bool get() - { - return m_canPreAuthenticate; - } - - } - - // - // The checkChallenge method checks if the challenge sent by the HttpWebRequest - // contains the correct type (Basic) and the correct domain name. - // Note: the challenge is in the form BASIC REALM="DOMAINNAME" - // and you must assure that the Internet Web site resides on a server whose - // domain name is equal to DOMAINAME. - bool checkChallenge( String^ Challenge, String^ domain ) - { - bool challengePasses = false; - String^ tempChallenge = Challenge->ToUpper(); - - // Verify that this is a Basic authorization request and the requested domain - // is correct. - // Note: When the domain is an empty string the following code only checks - // whether the authorization type is Basic. - if ( tempChallenge->IndexOf( "BASIC" ) != -1 ) - if ( domain != String::Empty ) - if ( tempChallenge->IndexOf( domain->ToUpper() ) != -1 ) - challengePasses = true; // The domain is not allowed and the authorization type is Basic. - else - challengePasses = false; - - else - challengePasses = true; - - - return challengePasses; - } - - - // - // The PreAuthenticate method specifies if the authentication implemented - // by this class allows pre-authentication. - // Even if you do not use it, this method must be implemented to obey to the rules - // of interface implemebtation. - // In this case it always returns false. - virtual Authorization^ PreAuthenticate( WebRequest^ /*request*/, ICredentials^ /*credentials*/ ) - { - return nullptr; - } - - - // - // - // Authenticate is the core method for this custom authentication. - // When an internet resource requests authentication, the WebRequest.GetResponse - // method calls the AuthenticationManager.Authenticate method. This method, in - // turn, calls the Authenticate method on each of the registered authentication - // modules, in the order they were registered. When the authentication is - // complete an Authorization object is returned to the WebRequest, as the - // retunr type of the following routine shows. - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - Encoding^ ASCII = Encoding::ASCII; - - // Get the username and password from the credentials - NetworkCredential^ MyCreds = credentials->GetCredential( request->RequestUri, "Basic" ); - if ( PreAuthenticate( request, credentials ) == nullptr ) - Console::WriteLine( "\n Pre-authentication is not allowed." ); - else - Console::WriteLine( "\n Pre-authentication is allowed." ); - - - // Verify that the challenge satisfies the authorization requirements. - bool challengeOk = checkChallenge( challenge, MyCreds->Domain ); - if ( !challengeOk ) - return nullptr; - - - // - // Create the encrypted string according to the Basic authentication format as - // follows: - // a)Concatenate username and password seperated by colon; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain the encoded - // authorization. - String^ BasicEncrypt = String::Concat( MyCreds->UserName, ":", MyCreds->Password ); - String^ BasicToken = String::Format( "Basic {0}", Convert::ToBase64String( ASCII->GetBytes( BasicEncrypt ) ) ); - - // Create an Authorization object using the above encoded authorization. - Authorization^ resourceAuthorization = gcnew Authorization( BasicToken ); - - // Get the Message property which contains the authorization string that the - // client returns to the server when accessing protected resources. - Console::WriteLine( "\n Authorization Message:{0}", resourceAuthorization->Message ); - - // Get the Complete property which is set to true when the authentication process - // between the client and the server is finished. - Console::WriteLine( "\n Authorization Complete:{0}", resourceAuthorization->Complete ); - Console::WriteLine( "\n Authorization ConnectionGroupId:{0}", resourceAuthorization->ConnectionGroupId ); - - // - return resourceAuthorization; - } - - // -}; - - -// -// The ClientAuthentication performs the following main tasks: -// 1) It obtains the user's credentials. -// 2) Unregisters the standard Basic authentication. -// 3) Registers the customized Basic authentication. -// 4) Read the selected page and displays it on the console. -ref class ClientAuthentication -{ -private: - static String^ username; - static String^ password; - static String^ domain; - static String^ uri; - - // Show how to use this program. - static void showusage() - { - Console::WriteLine( "Attempts to authenticate to a URL" ); - Console::WriteLine( "\r\nUse one of the following:" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password domain" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password" ); - Console::WriteLine( "\r\nExample:" ); - Console::WriteLine( "\tcustomBasicAuthentication http://ndpue/ncl/ basicuser basic.101 ndpue" ); - } - - - // - // Display registered authentication modules. - static void displayRegisteredModules() - { - - // The AuthenticationManager calls all authentication modules sequentially - // until one of them responds with an authorization instance. Show - // the current registered modules, for testing purposes. - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - Console::WriteLine( "\r\nThe following authentication modules are now registered with the system" ); - while ( registeredModules->MoveNext() ) - { - Console::WriteLine( "\r \n Module : {0}", registeredModules->Current ); - IAuthenticationModule^ currentAuthenticationModule = dynamic_cast(registeredModules->Current); - Console::WriteLine( "\t CanPreAuthenticate : {0}", currentAuthenticationModule->CanPreAuthenticate ); - } - } - - - // - // The getPage method accesses the selected page an displays its content - // on the console. - static void getPage( String^ url ) - { - try - { - - // Create the Web request object. - WebRequest^ req = dynamic_cast(WebRequest::Create( url )); - - // Define the request access method. - req->Method = "GET"; - - // Define the request credentials according to the user's input. - if ( domain == String::Empty ) - req->Credentials = gcnew NetworkCredential( username,password ); // If the user's specifies the Internet resource domain, this usually - else - req->Credentials = gcnew NetworkCredential( username,password,domain ); - - // is by default the name of the sever hosting the resource. - // Issue the request. - WebResponse^ result = req->GetResponse(); - Console::WriteLine( "\nAuthentication Succeeded:" ); - - // Store the response. - Stream^ sData = result->GetResponseStream(); - - // Display the response. - displayPageContent( sData ); - } - catch ( WebException^ e ) - { - - // Display the error, if any. In particular display protocol - // related error. - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - HttpWebResponse^ hresp = dynamic_cast(e->Response); - Console::WriteLine( "\nAuthentication Failed, {0}", hresp->StatusCode ); - Console::WriteLine( "Status Code: {0}", (int)hresp->StatusCode ); - Console::WriteLine( "Status Description: {0}", hresp->StatusDescription ); - return; - } - Console::WriteLine( "Caught Exception: {0}", e->Message ); - Console::WriteLine( "Stack: {0}", e->StackTrace ); - } - - } - - - // The displayPageContent method display the content of the - // selected page. - static void displayPageContent( Stream^ ReceiveStream ) - { - - // Create an ASCII encoding object. - Encoding^ ASCII = Encoding::ASCII; - - // Define the byte array to temporary hold the current read bytes. - array^read = gcnew array(512); - Console::WriteLine( "\r\nPage Content...\r\n" ); - - // Read the page content and display it on the console. - // Read the first 512 bytes. - int bytes = ReceiveStream->Read( read, 0, 512 ); - while ( bytes > 0 ) - { - Console::Write( ASCII->GetString( read, 0, bytes ) ); - bytes = ReceiveStream->Read( read, 0, 512 ); - } - - Console::WriteLine( "" ); - } - - -public: - - // - // This is the program entry point. It allows the user to enter - // their credentials and the Internet resource (Web page) to access. - // It also unregisters the standard and registers the customized basic - // authentication. - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - showusage(); - else - { - - // Read the user's credentials. - uri = args[ 1 ]; - username = args[ 2 ]; - password = args[ 3 ]; - if ( args->Length == 4 ) - domain = String::Empty; // If the domain exists, store it. Usually the domain name - else - domain = args[ 4 ]; - - - // is by default the name of the server hosting the Internet - // resource. - // Unregister the standard Basic authentication module. - AuthenticationManager::Unregister( "Basic" ); - - // Instantiate the custom Basic authentication module. - CustomBasic^ customBasicModule = gcnew CustomBasic; - - // Register the custom Basic authentication module. - AuthenticationManager::Register( customBasicModule ); - - // Display registered Authorization modules. - displayRegisteredModules(); - - // Read the specified page and display it on the console. - getPage( uri ); - } - - return; - } - - // -}; - -int main() -{ - ClientAuthentication::Main(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp deleted file mode 100644 index 344dc6ed2a97b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp +++ /dev/null @@ -1,130 +0,0 @@ - - -// -// This program contains snippets for the following members: -// 1) System::Net::Sockets::MulticastOption; -// 2) System::Net::Sockets::MulticastOption.MulticastOption(IPAddress, IPAddress); -// 3) System::Net::Sockets::MulticastOption.Group; -// 4) System::Net::Sockets::MulticastOption.LocalAddress; -// -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -// This program shows how to use the MultiCastOption type. In particular, -// it shows how to use the MultiCastOption(IPAddress, IPAddress) constructor, -// You need to use this constructor, in the case of multihomed host (i.e., -// a host with more than one network card). With the first parameter you -// specify the multicast group address, with the second you specify the -// local address of one of the network cards you want to use for the data -// exchange. -// You must run this program in conjunction with the sender program as -// follows: -// Open a console window and run the listener from the command line. -// In another console window run the sender. In both cases you must specify -// the local IPAddress to use. To obtain this address run the ipconfig from -// the command line. -// -public ref class TestMulticastOption -{ -private: - static IPAddress^ mcastAddress; - static int mcastPort; - static Socket^ mcastSocket; - static MulticastOption^ mcastOption; - - // - static void MulticastOptionProperties() - { - Console::WriteLine( "Current multicast group is: {0}", mcastOption->Group ); - Console::WriteLine( "Current multicast local address is: {0}", mcastOption->LocalAddress ); - } - - - // - static void StartMulticast() - { - try - { - mcastSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Dgram,ProtocolType::Udp ); - Console::Write( "Enter the local IP Address: " ); - IPAddress^ localIPAddr = IPAddress::Parse( Console::ReadLine() ); - - //IPAddress localIP = IPAddress::Any; - EndPoint^ localEP = dynamic_cast(gcnew IPEndPoint( localIPAddr,mcastPort )); - mcastSocket->Bind( localEP ); - - // - // Define a MuticastOption object specifying the multicast group - // address and the local IPAddress. - // The multicast group address is the same one used by the server. - mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr ); - mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership, mcastOption ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - - } - - static void ReceiveBrodcastMessages() - { - bool done = false; - array^bytes = gcnew array(100); - IPEndPoint^ groupEP = gcnew IPEndPoint( mcastAddress,mcastPort ); - EndPoint^ remoteEP = dynamic_cast(gcnew IPEndPoint( IPAddress::Any,0 )); - try - { - while ( !done ) - { - Console::WriteLine( "Waiting for Multicast packets......." ); - Console::WriteLine( "Enter ^C to terminate." ); - mcastSocket->ReceiveFrom( bytes, remoteEP ); - Console::WriteLine( "Received broadcast from {0} :\n {1}\n", groupEP, Encoding::ASCII->GetString( bytes, 0, bytes->Length ) ); - } - mcastSocket->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - - } - - -public: - static void Main() - { - - // Initialize multicast address group and multicast port. - // Both address and port are selected from the allowed sets as - // defined in the related RFC documents. These are the same values - // used by the sender. - mcastAddress = IPAddress::Parse( "224.168.100.2" ); - mcastPort = 11000; - - // Start a multicast group. - StartMulticast(); - - // Display multicast option properties. - MulticastOptionProperties(); - - // Receive brodcast messages. - ReceiveBrodcastMessages(); - } - -}; - -int main() -{ - TestMulticastOption::Main(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp deleted file mode 100644 index 9b92d3984aa1a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -// This program contains snippets for the following members: -// 1) System::Net::Sockets::MulticastOption; -// -// -#using - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Net; -using namespace System::Text; - -// This is an auxiliary program to be used in conjunction with a listener -// program. -// You must run this program as follows: -// Open a console window and run the listener from the command line. -// In another console window run the sender. In both cases you must specify -// the local IPAddress to use. To obtain this address run the ipconfig -// from the command line. -// -ref class TestMulticastOption -{ -private: - static IPAddress^ mcastAddress; - static int mcastPort; - static Socket^ mcastSocket; - static void JoinMulticast() - { - try - { - - // Create multicast socket. - mcastSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Dgram,ProtocolType::Udp ); - - // Get the local IP address used by the listener and the sender to - // exchange data in a multicast fashion. - Console::Write( "\nEnter local IPAddress for sending multicast packets: " ); - IPAddress^ localIPAddr = IPAddress::Parse( Console::ReadLine() ); - - // Create an IPEndPoint Object*. - IPEndPoint^ IPlocal = gcnew IPEndPoint( localIPAddr,0 ); - - // Bind this end point to the multicast socket. - mcastSocket->Bind( IPlocal ); - - // Define a MuticastOption Object* specifying the multicast group - // address and the local IPAddress. - // The multicast group address is the same one used by the listener. - MulticastOption^ mcastOption; - mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr ); - mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership, mcastOption ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n {0}", e ); - } - - } - - static void BrodcastMessage( String^ message ) - { - IPEndPoint^ endPoint; - try - { - - //Send multicast packets to the listener. - endPoint = gcnew IPEndPoint( mcastAddress,mcastPort ); - mcastSocket->SendTo( ASCIIEncoding::ASCII->GetBytes( message ), endPoint ); - Console::WriteLine( "Multicast data sent....." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n {0}", e ); - } - - mcastSocket->Close(); - } - - -public: - static void main() - { - - // Initialize multicast address group and multicast port. - // Both address and port are selected from the allowed sets as - // defined in the related RFC documents. These are the same values - // used by the sender. - mcastAddress = IPAddress::Parse( "224.168.100.2" ); - mcastPort = 11000; - - // Join the listener multicast group. - JoinMulticast(); - - // Broadcast message to the listener. - BrodcastMessage( "Hello multicast listener." ); - } - -}; - -int main() -{ - TestMulticastOption::main(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp deleted file mode 100644 index 258a49ca83553..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp +++ /dev/null @@ -1,140 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -ref class ConnectTester -{ -public: - - // - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - - // handles the completion of the prior asynchronous - // connect call. the socket is passed via the objectState - // paramater of BeginConnect(). - static void ConnectCallback1( IAsyncResult^ ar ) - { - allDone->Set(); - Socket^ s = dynamic_cast(ar->AsyncState); - s->EndConnect( ar ); - } - - - // - // - // Asynchronous connect using the host name, resolved via - // IPAddress - static void BeginConnect1( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - allDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->BeginConnect( IPs[ 0 ], port, gcnew AsyncCallback( ConnectCallback1 ), s ); - - // wait here until the connect finishes. - // The callback sets allDone. - allDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - - // - // - // Asynchronous connect, using DNS.ResolveToAddresses - static void BeginConnect2( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - allDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->BeginConnect( IPs, port, gcnew AsyncCallback( ConnectCallback1 ), s ); - - // wait here until the connect finishes. The callback - // sets allDone. - allDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - - // - // - // Asynchronous connect using host name (resolved by the - // BeginConnect call.) - static void BeginConnect3( String^ host, int port ) - { - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - allDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->BeginConnect( host, port, gcnew AsyncCallback( ConnectCallback1 ), s ); - - // wait here until the connect finishes. The callback - // sets allDone. - allDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - - // - // - // Synchronous connect using IPAddress to resolve the - // host name. - static void Connect1( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->Connect( IPs[ 0 ], port ); - Console::WriteLine( "Connection established" ); - } - - - // - // - // Synchronous connect using Dns.ResolveToAddresses to - // resolve the host name. - static void Connect2( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->Connect( IPs, port ); - Console::WriteLine( "Connection established" ); - } - - - // - // - // Synchronous connect using host name (resolved by the - // Connect call.) - static void Connect3( String^ host, int port ) - { - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->Connect( host, port ); - Console::WriteLine( "Connection established" ); - } - - // -}; - - -[STAThread] -int main() -{ - ConnectTester::BeginConnect1( "127.0.0.1", 80 ); - ConnectTester::BeginConnect2( "localhost", 80 ); - ConnectTester::BeginConnect3( "localhost", 80 ); - ConnectTester::Connect1( "127.0.0.1", 80 ); - ConnectTester::Connect2( "127.0.0.1", 80 ); - ConnectTester::Connect3( "localhost", 80 ); - Console::WriteLine( "hit any key" ); - Console::Read(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket/CPP/socket.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket/CPP/socket.cpp deleted file mode 100644 index 00514470652d0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket/CPP/socket.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/** -* File name:socket.cs. -* This example creates a Socket connection to the server specified by the user, -* using port 80. Once the connection has been established it asks the server for -* the content of its home page. If no server name is passed as argument to this -* program, it uses the current host name as default server. -* */ -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Collections; -Socket^ ConnectSocket( String^ server, int port ) -{ - Socket^ s = nullptr; - IPHostEntry^ hostEntry = nullptr; - - // Get host related information. - hostEntry = Dns::Resolve( server ); - - // Loop through the AddressList to obtain the supported AddressFamily. This is to avoid - // an exception that occurs when the host IP Address is not compatible with the address family - // (typical in the IPv6 case). - IEnumerator^ myEnum = hostEntry->AddressList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IPAddress^ address = safe_cast(myEnum->Current); - IPEndPoint^ endPoint = gcnew IPEndPoint( address,port ); - Socket^ tmpS = gcnew Socket( endPoint->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - tmpS->Connect( endPoint ); - if ( tmpS->Connected ) - { - s = tmpS; - break; - } - else - { - continue; - } - } - - return s; -} - -// This method requests the home page content for the specified server. -String^ SocketSendReceive( String^ server, int port ) -{ - String^ request = String::Concat( "GET / HTTP/1.1\r\nHost: ", server, "\r\nConnection: Close\r\n\r\n" ); - array^bytesSent = Encoding::ASCII->GetBytes( request ); - array^bytesReceived = gcnew array(256); - String^ strRetPage = ""; - - // Create a socket connection with the specified server and port. - Socket^ s = ConnectSocket( server, port ); - if ( s == nullptr ) - return ("Connection failed"); - - // Send request to the server. - s->Send( bytesSent, bytesSent->Length, static_cast(0) ); - - // Receive the server home page content. - int bytes = 0; - strRetPage = String::Concat( "Default HTML page on ", server, ":\r\n" ); - do - { - bytes = s->Receive( bytesReceived, bytesReceived->Length, static_cast(0) ); - strRetPage = String::Concat( strRetPage, Encoding::ASCII->GetString( bytesReceived, 0, bytes ) ); - } - while ( bytes > 0 ); - - s->Dispose(); - - return strRetPage; -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ host; - int port = 80; - if ( args->Length == 1 ) - - // If no server name is passed as argument to this program, - // use the current host name as default. - host = Dns::GetHostName(); - else - host = args[ 1 ]; - - String^ result = SocketSendReceive( host, port ); - Console::WriteLine( result ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp deleted file mode 100644 index b06fa3e3760af..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -namespace SocketExample -{ - ref class TestClass - { - public: - - static void SyncSendAndReceive(String^ host, int port) - { - // - Encoding^ asciiEncoding = Encoding::ASCII; - - // Create the TCP Socket. - IPHostEntry^ hostEntry = Dns::Resolve(host); - IPEndPoint^ endPoint = gcnew IPEndPoint( - hostEntry->AddressList[0], port); - - Socket^ tcpSocket = gcnew Socket( - AddressFamily::InterNetwork, SocketType::Stream, - ProtocolType::Tcp); - - tcpSocket->Connect(endPoint); - - // Build the buffers to be sent. - List >^ buffers = - gcnew List >(2); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - // Send the data. - tcpSocket->Send(buffers); - // - - // - - // Build the buffers for the receive. - List >^ receiveBuffers = - gcnew List >(2); - - array^ bigBuffer = gcnew array(1024); - - // Specify the first buffer segment (2 bytes, starting - // at the 4th element of bigBuffer) - receiveBuffers->Add(ArraySegment(bigBuffer, 4, 2)); - - // Specify the second buffer segment (500 bytes, starting - // at the 20th element of bigBuffer) - receiveBuffers->Add( - ArraySegment(bigBuffer, 20, 500)); - - tcpSocket->Receive(receiveBuffers); - - Console::WriteLine("{0}", - asciiEncoding->GetString(bigBuffer)); - // - } - - static void AsyncSendAndReceive(String^ host, int port) - { - // - Encoding^ asciiEncoding = Encoding::ASCII; - - // Create the TCP Socket. - IPHostEntry^ hostEntry = Dns::Resolve(host); - IPEndPoint^ endPoint = gcnew IPEndPoint( - hostEntry->AddressList[0], port); - - Socket^ tcpSocket = gcnew Socket( - AddressFamily::InterNetwork, SocketType::Stream, - ProtocolType::Tcp); - - tcpSocket->Connect(endPoint); - - // Build the buffers to be sent. - List >^ buffers = - gcnew List >(2); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - // Create delegate instance for the callback function - AsyncCallback^ sendCallback = - gcnew AsyncCallback(SendCallback); - - // Send the data. - allDone->Reset(); - tcpSocket->BeginSend(buffers, SocketFlags::None, - sendCallback, (Object^)tcpSocket); - allDone->WaitOne(); - - // done - Console::WriteLine("Data sent"); - // - - // - - // Build the buffers for the receive. - List >^ receiveBuffers = - gcnew List >(2); - - array^ bigBuffer = gcnew array(1024); - - // Specify the first buffer segment (2 bytes, starting - // at the 6th element of bigBuffer) - receiveBuffers->Add(ArraySegment(bigBuffer, 6, 2)); - - // Specify the second buffer segment (500 bytes, starting - // at the 10th element of bigBuffer) - receiveBuffers->Add( - ArraySegment(bigBuffer, 10, 500)); - - // Create delegate instance for the callback function - AsyncCallback^ receiveCallback = - gcnew AsyncCallback(ReceiveCallback); - - // Receive the data. - allDone->Reset(); - tcpSocket->BeginReceive( - receiveBuffers, SocketFlags::None, - receiveCallback, (Object^)tcpSocket); - - allDone->WaitOne(); - - Console::WriteLine("Data received:"); - Console::WriteLine("{0}", - asciiEncoding->GetString(bigBuffer)); - // - } - - private: - - static ManualResetEvent^ allDone = - gcnew ManualResetEvent(false); - - static void SendCallback(IAsyncResult^ result) - { - allDone->Set(); - Socket^ sendSocket = (Socket^)result->AsyncState; - sendSocket->EndSend(result); - } - - static void ReceiveCallback(IAsyncResult^ result) - { - allDone->Set(); - Socket^ receiveSocket = (Socket^)result->AsyncState; - receiveSocket->EndReceive(result); - } - }; -} - -int main() -{ - Console::WriteLine("starting synchronous test"); - SocketExample::TestClass::SyncSendAndReceive("localhost", 80); - Console::WriteLine("starting asynchronous test"); - SocketExample::TestClass::AsyncSendAndReceive("localhost", 80); - Console::WriteLine("ending tests"); - - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp deleted file mode 100644 index bb8d01bc621ef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// System.Net.Sockets.TcpClient main functionality. - -/** -* This program shows how to use the TcpClient -* It creates a TcpClient that connects to a TcpServer listening on the specified port -* (13000). When connecting to the server it forwards a message, as specified in -* the input parameter. -* To run this program at the command line you enter: -* cs_tcpclient serverName S"My message" -* Where the serverName is the name on which the server is running. -* For this program to work you need to have the TcpServer running in another -* console window. -* To avoid permission settings you can run this console application and the related -* TcpServer from your hard disk and not from a shared location on the network. -**/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Security::Permissions; - -/** -* The following function creates a TcpClient that connects to a -* TcpServer listening on the specified port (13000). -* When connecting to the server it forwards a message, as specified in -* the input parameter. -**/ -// -void Connect( String^ server, String^ message ) -{ - try - { - // Create a TcpClient. - // Note, for this client to work you need to have a TcpServer - // connected to the same address as specified by the server, port - // combination. - Int32 port = 13000; - TcpClient^ client = gcnew TcpClient( server,port ); - - // Translate the passed message into ASCII and store it as a Byte array. - array^data = Text::Encoding::ASCII->GetBytes( message ); - - // Get a client stream for reading and writing. - // Stream stream = client->GetStream(); - - NetworkStream^ stream = client->GetStream(); - - // Send the message to the connected TcpServer. - stream->Write( data, 0, data->Length ); - - Console::WriteLine( "Sent: {0}", message ); - - // Receive the TcpServer::response. - - // Buffer to store the response bytes. - data = gcnew array(256); - - // String to store the response ASCII representation. - String^ responseData = String::Empty; - - // Read the first batch of the TcpServer response bytes. - Int32 bytes = stream->Read( data, 0, data->Length ); - responseData = Text::Encoding::ASCII->GetString( data, 0, bytes ); - Console::WriteLine( "Received: {0}", responseData ); - - // Close everything. - client->Close(); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException: {0}", e ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException: {0}", e ); - } - - Console::WriteLine( "\n Press Enter to continue..." ); - Console::Read(); -} -// - -void main( int argc, char *argv[] ) -{ - // Parse arguments - String^ server; - String^ message; - if ( argc < 3 ) - { - message = "This is a test!"; - if ( argc == 1 ) - { - server = "localhost"; - } - else - { - server = gcnew String(argv[ 1 ]); - } - } - else - { - message = gcnew String(argv[ 2 ]); - server = gcnew String(argv[ 1 ]); - } - - // Connect to server - Connect( server, message ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp deleted file mode 100644 index 1fc0dcb58d787..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp +++ /dev/null @@ -1,131 +0,0 @@ - - -// This is the main project file for VC++ application project -// generated using an Application Wizard. -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -ref class TcpClientExamples -{ -public: - - // - static void GetAvailable( TcpClient^ t ) - { - // Find out how many bytes are ready to be read. - Console::WriteLine( "Available value is {0}", t->Available.ToString() ); - ; - } - // - - // - static void GetConnected( TcpClient^ t ) - { - // Find out whether the socket is connected to the remote - // host. - Console::WriteLine( "Connected value is {0}", t->Connected.ToString() ); - ; - } - // - - // - static void GetSetExclusiveAddressUse( TcpClient^ t ) - { - // Don't allow another process to bind to this port. - t->ExclusiveAddressUse = true; - Console::WriteLine( "ExclusiveAddressUse value is {0}", t->ExclusiveAddressUse.ToString() ); - ; - } - // - - // - static void DoConnect( String^ host, int port ) - { - // Connect to the specified host. - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); - array^IPAddresses = Dns::GetHostAddresses( host ); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->Connect( IPAddresses, port ); - Console::WriteLine( "Connection established" ); - } - // - - // - static ManualResetEvent^ connectDone = gcnew ManualResetEvent( false ); - static void ConnectCallback( IAsyncResult^ ar ) - { - connectDone->Set(); - TcpClient^ t = safe_cast(ar->AsyncState); - t->EndConnect( ar ); - } - // - - // - static void DoBeginConnect1( String^ host, int port ) - { - // Connect asynchronously to the specifed host. - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); -// IPAddress^ remoteHost = gcnew IPAddress( host ); - array^ remoteHost = Dns::GetHostAddresses( host ); - connectDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->BeginConnect( remoteHost, port, gcnew AsyncCallback( &ConnectCallback ), t ); - - // Wait here until the callback processes the connection. - connectDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - // - - // - // Connect asynchronously to the specifed host. - static void DoBeginConnect2( String^ host, int port ) - { - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); - array^remoteHost = Dns::GetHostAddresses( host ); - connectDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->BeginConnect( remoteHost, port, gcnew AsyncCallback( &ConnectCallback ), t ); - - // Wait here until the callback processes the connection. - connectDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - // - - // - // Connect asynchronously to the specifed host. - static void DoBeginConnect3( String^ host, int port ) - { - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); - connectDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->BeginConnect( host, port, gcnew AsyncCallback( &ConnectCallback ), t ); - - // Wait here until the callback processes the connection. - connectDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - // -}; - -int main() -{ - TcpClient^ t; - - // The TCP socket. - t = gcnew TcpClient( "localhost",80 ); - TcpClientExamples::GetConnected( t ); - TcpClientExamples::GetAvailable( t ); - TcpClientExamples::GetSetExclusiveAddressUse( t ); - TcpClientExamples::DoConnect( "127.0.0.1", 80 ); - TcpClientExamples::DoBeginConnect1( "127.0.0.1", 80 ); - TcpClientExamples::DoBeginConnect2( "127.0.0.1", 80 ); - TcpClientExamples::DoBeginConnect3( "127.0.0.1", 80 ); - Console::WriteLine( "enter to exit" ); - Console::Read(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp deleted file mode 100644 index 9687b62e453ae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp +++ /dev/null @@ -1,226 +0,0 @@ - - -// System.Net.Sockets.TcpListener -/** -* This program shows how to use the TcpListener class. -* It creates a TcpListener that listen on the specified port (13000). -* To run this program at the command line you enter: -* cs_tcpserver -* Any TcpClient that wants to use this server -* has to explicitly connect to an address obtained by the combination of -* the sever on which this TcpServer is runnig and the port 13000. -* This TcpServer simply echoes back the message sent by the TcpClient, after -* translating it into uppercase. -* To avoid permission settings you can run this console application and the related -* TcpClient from your hard disk and not from a shared location on the network. -**/ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; -void main() -{ - try - { - - // Set the TcpListener on port 13000. - Int32 port = 13000; - IPAddress^ localAddr = IPAddress::Parse( "127.0.0.1" ); - - // TcpListener* server = new TcpListener(port); - TcpListener^ server = gcnew TcpListener( localAddr,port ); - - // Start listening for client requests. - server->Start(); - - // Buffer for reading data - array^bytes = gcnew array(256); - String^ data = nullptr; - - // Enter the listening loop. - while ( true ) - { - Console::Write( "Waiting for a connection... " ); - - // Perform a blocking call to accept requests. - // You could also use server.AcceptSocket() here. - TcpClient^ client = server->AcceptTcpClient(); - Console::WriteLine( "Connected!" ); - data = nullptr; - - // Get a stream Object* for reading and writing - NetworkStream^ stream = client->GetStream(); - Int32 i; - - // Loop to receive all the data sent by the client. - while ( i = stream->Read( bytes, 0, bytes->Length ) ) - { - - // Translate data bytes to a ASCII String*. - data = Text::Encoding::ASCII->GetString( bytes, 0, i ); - Console::WriteLine( "Received: {0}", data ); - - // Process the data sent by the client. - data = data->ToUpper(); - array^msg = Text::Encoding::ASCII->GetBytes( data ); - - // Send back a response. - stream->Write( msg, 0, msg->Length ); - Console::WriteLine( "Sent: {0}", data ); - } - - // Shutdown and end connection - client->Close(); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException: {0}", e ); - } - - Console::WriteLine( "\nHit enter to continue..." ); - Console::Read(); -} - - -// -ref class tcplistener -{ -public: - - // - static void GetSetExclusiveAddressUse( TcpListener^ t ) - { - - // Set Exclusive Address Use for the underlying socket. - t->ExclusiveAddressUse = true; - Console::WriteLine( "ExclusiveAddressUse value is {0}", t->ExclusiveAddressUse ); - } - - - // - // - static void DoStart( TcpListener^ t, int backlog ) - { - - // Start listening for client connections with the specified - // backlog. - t->Start( backlog ); - Console::WriteLine( "started listening" ); - } - - - // - // - // Thread signal. - static ManualResetEvent^ clientConnected = gcnew ManualResetEvent( false ); - - // Accept one client connection asynchronously. - static void DoBeginAcceptSocket( TcpListener^ listener ) - { - - // Set the event to nonsignaled state. - clientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptSocket( gcnew AsyncCallback( &tcplistener::DoAcceptSocketCallback ), listener ); - - // Wait until a connection is made and processed before - // continuing. - clientConnected->WaitOne(); - } - - - // Process the client connection. - static void DoAcceptSocketCallback( IAsyncResult^ ar ) - { - - // Get the listener that handles the client request. - TcpListener^ listener = dynamic_cast(ar->AsyncState); - - // Get the client socket. - Socket^ clientSocket = listener->EndAcceptSocket( ar ); - - // Process the connection here. (Add the client to a server - // table, read data, etc.) - Console::WriteLine( "Client connected completed" ); - - // Signal the calling thread to continue. - clientConnected->Set(); - } - - - // - // - // Thread signal. - static ManualResetEvent^ tcpClientConnected = gcnew ManualResetEvent( false ); - - // Accept one client connection asynchronously. - static void DoBeginAcceptTcpClient( TcpListener^ listener ) - { - - // Set the event to nonsignaled state. - tcpClientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptTcpClient( gcnew AsyncCallback( &tcplistener::DoAcceptTcpClientCallback ), listener ); - - // Wait until a connection is made and processed before - // continuing. - tcpClientConnected->WaitOne(); - } - - - // Process the client connection. - static void DoAcceptTcpClientCallback( IAsyncResult^ ar ) - { - - // Get the listener that handles the client request. - TcpListener^ listener = dynamic_cast(ar->AsyncState); - - // Get the new TcpClient. - TcpClient^ client = listener->EndAcceptTcpClient( ar ); - - // Process the connection here. (Add the client to a server - // table, read data, etc.) - Console::WriteLine( "Client connected completed" ); - - // Signal the calling thread to continue. - tcpClientConnected->Set(); - } - - // -}; - -/*int main() -{ - TcpListener* listener = new TcpListener( - Dns::GetLocalHostAddresses()[0], - 4242); - - tcplistener::GetSetExclusiveAddressUse(listener); - - // Start listening for client connections. - tcplistener::DoStart(listener, 20); - - // Accept client connections asynchronously - tcplistener::DoBeginAcceptSocket(listener); - tcplistener::DoBeginAcceptTcpClient(listener); - - Console::WriteLine("hit any key"); - Console::Read(); - return 0; -}*/ diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/makefile deleted file mode 100644 index 8af38f517cc3a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -System.Net.Sockets.TcpListener1.exe : tcpserver.cpp - cl /clr:pure /FeSystem.Net.Sockets.TcpListener1.exe tcpserver.cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp deleted file mode 100644 index 58dab91d42375..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -namespace TcpListenerExample -{ - public ref class TcpServer - { - // - public: - static void GetSetExclusiveAddressUse(TcpListener^ listener) - { - // Set Exclusive Address Use for the underlying socket. - listener->ExclusiveAddressUse = true; - Console::WriteLine("ExclusiveAddressUse value is {0}", - listener->ExclusiveAddressUse); - } - // - - // - public: - static void DoStart(TcpListener^ listener, int backlog) - { - // Start listening for client connections with the - // specified backlog. - listener->Start(backlog); - Console::WriteLine("Started listening"); - } - // - - // - // Thread signal. - public: - static ManualResetEvent^ ClientConnected; - - // Accept one client connection asynchronously. - public: - static void DoBeginAcceptSocket(TcpListener^ listener) - { - // Set the event to nonsignaled state. - ClientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine("Waiting for a connection..."); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptSocket( - gcnew AsyncCallback(DoAcceptSocketCallback), listener); - // Wait until a connection is made and processed before - // continuing. - ClientConnected->WaitOne(); - } - - // Process the client connection. - public: - static void DoAcceptSocketCallback(IAsyncResult^ result) - { - // Get the listener that handles the client request. - TcpListener^ listener = (TcpListener^) result->AsyncState; - - // End the operation and display the received data on the - //console. - Socket^ clientSocket = listener->EndAcceptSocket(result); - - // Process the connection here. (Add the client to a - // server table, read data, etc.) - Console::WriteLine("Client connected completed"); - - // Signal the calling thread to continue. - ClientConnected->Set(); - } - // - - // - // Thread signal. - public: - static ManualResetEvent^ TcpClientConnected; - - // Accept one client connection asynchronously. - public: - static void DoBeginAcceptTcpClient(TcpListener^ listener) - { - // Set the event to nonsignaled state. - TcpClientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine("Waiting for a connection..."); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptTcpClient( - gcnew AsyncCallback(DoAcceptTcpClientCallback), - listener); - - // Wait until a connection is made and processed before - // continuing. - TcpClientConnected->WaitOne(); - } - - // Process the client connection. - public: - static void DoAcceptTcpClientCallback(IAsyncResult^ result) - { - // Get the listener that handles the client request. - TcpListener^ listener = (TcpListener^) result->AsyncState; - - // End the operation and display the received data on - // the console. - TcpClient^ client = listener->EndAcceptTcpClient(result); - - // Process the connection here. (Add the client to a - // server table, read data, etc.) - Console::WriteLine("Client connected completed"); - - // Signal the calling thread to continue. - TcpClientConnected->Set(); - - } - // - - public: - static void Main() - { - ClientConnected = gcnew ManualResetEvent(false); - - TcpClientConnected = gcnew ManualResetEvent(false); - - TcpListener^ listener = gcnew TcpListener( - Dns::GetHostAddresses(Dns::GetHostName())[0], 4242); - - GetSetExclusiveAddressUse(listener); - - // Start listening for client connections. - DoStart(listener, 20); - - // Accept one client connection asynchronously - DoBeginAcceptSocket(listener); - DoBeginAcceptTcpClient(listener); - - Console::WriteLine("Hit any key"); - Console::Read(); - } - }; -} - -[STAThread] -int main() -{ - TcpListenerExample::TcpServer::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp deleted file mode 100644 index dd99994781123..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp +++ /dev/null @@ -1,326 +0,0 @@ - - -// File name:multicastOperations.cs -// This example shows how to join a multicast group and perform a muticast -// data exchange. The OriginatorClient Object* starts the conversation while -// the TargetClient responds. The two helper objects Receive and Send -// perform the actual data exchange. -// Note. This program cannot be build with the current VS build version. -// Build it via command line. Rubuild it in VS when a suitable version is -// available. -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::IO; -using namespace System::Threading; - -// The following Receive class is used by both the ClientOriginator and -// the ClientTarget class to receive data from one another.. -public ref class Receive -{ -public: - - // The following static method performs the actual data - // exchange. In particular, it performs the following tasks: - // 1)Establishes a communication endpoint. - // 2)Receive data through this end point on behalf of the - // caller. - // 3) Returns the received data in ASCII format. - static String^ ReceiveUntilStop( UdpClient^ c ) - { - String^ strData = ""; - String^ Ret = ""; - ASCIIEncoding^ ASCII = gcnew ASCIIEncoding; - - // Establish the communication endpoint. - IPEndPoint^ endpoint = gcnew IPEndPoint( IPAddress::IPv6Any,50 ); - while ( !strData->Equals( "Over" ) ) - { - array^data = c->Receive( endpoint ); - strData = ASCII->GetString( data ); - Ret = String::Concat( Ret, strData, "\n" ); - } - - return Ret; - } - -}; - - -// The following Send class is used by both the ClientOriginator and -// ClientTarget classes to send data to one another. -public ref class Send -{ -private: - static array^greetings = {'H','e','l','l','o',' ','T','a','r','g','e','t','->'}; - static array^nice = {'H','a','v','e',' ','a',' ','n','i','c','e',' ','d','a','y','->'}; - static array^eom = {'O','v','e','r'}; - static array^tGreetings = {'H','e','l','l','o',' ','O','r','i','g','i','n','a','t','o','r','!'}; - static array^tNice = {'Y','o','u',' ','t','o','o','->'}; - -public: - - // The following static method sends data to the ClientTarget on - // behalf of the ClientOriginator. - static void OriginatorSendData( UdpClient^ c, IPEndPoint^ ep ) - { - Console::WriteLine( gcnew String( greetings ) ); - c->Send( GetByteArray( greetings ), greetings->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( nice ) ); - c->Send( GetByteArray( nice ), nice->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( eom ) ); - c->Send( GetByteArray( eom ), eom->Length, ep ); - } - - - // The following static method sends data to the ClientOriginator on - // behalf of the ClientTarget. - static void TargetSendData( UdpClient^ c, IPEndPoint^ ep ) - { - Console::WriteLine( gcnew String( tGreetings ) ); - c->Send( GetByteArray( tGreetings ), tGreetings->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( tNice ) ); - c->Send( GetByteArray( tNice ), tNice->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( eom ) ); - c->Send( GetByteArray( eom ), eom->Length, ep ); - } - - -private: - - // Internal utility - static array^ GetByteArray( array^ChArray ) - { - array^Ret = gcnew array(ChArray->Length); - for ( int i = 0; i < ChArray->Length; i++ ) - Ret[ i ] = (Byte)ChArray[ i ]; - return Ret; - } - -}; - - -// The ClientTarget class is the receiver of the ClientOriginator -// messages. The StartMulticastConversation method contains the -// logic for exchanging data between the ClientTarget and its -// counterpart ClientOriginator in a multicast operation. -public ref class ClientTarget -{ -private: - static UdpClient^ m_ClientTarget; - static IPAddress^ m_GrpAddr; - -public: - - // The following StartMulticastConversation method connects the UDP - // ClientTarget with the ClientOriginator. - // It performs the following main tasks: - // 1)Creates a UDP client to receive data on a specific port and using - // IPv6 addresses. The port is the same one used by the ClientOriginator - // to define its communication endpoint. - // 2)Joins or creates a multicast group at the specified address. - // 3)Defines the endpoint port to send data to the ClientOriginator. - // 4)Receives data from the ClientOriginator until the end of the - // communication. - // 5)Sends data to the ClientOriginator. - // Note this method is the counterpart of the - // ClientOriginator::ConnectOriginatorAndTarget(). - static void StartMulticastConversation() - { - String^ Ret; - - // Bind and listen on port 1000. Specify the IPv6 address family type. - m_ClientTarget = gcnew UdpClient( 1000,AddressFamily::InterNetworkV6 ); - - // Join or create a multicast group - m_GrpAddr = IPAddress::Parse( "FF01::1" ); - - // Use the overloaded JoinMulticastGroup method. - // Refer to the ClientOriginator method to see how to use the other - // methods. - m_ClientTarget->JoinMulticastGroup( m_GrpAddr ); - - // Define the endpoint data port. Note that this port number - // must match the ClientOriginator UDP port number which is the - // port on which the ClientOriginator is receiving data. - IPEndPoint^ ClientOriginatordest = gcnew IPEndPoint( m_GrpAddr,2000 ); - - // Receive data from the ClientOriginator. - Ret = Receive::ReceiveUntilStop( m_ClientTarget ); - Console::WriteLine( "\nThe ClientTarget received: \n\n {0}\n", Ret ); - - // Done receiving, now respond to the ClientOriginator. - // Wait to make sure the ClientOriginator is ready to receive. - Thread::Sleep( 2000 ); - Console::WriteLine( "\nThe ClientTarget sent:\n" ); - Send::TargetSendData( m_ClientTarget, ClientOriginatordest ); - - // Exit the multicast conversation. - m_ClientTarget->DropMulticastGroup( m_GrpAddr ); - } - -}; - - -// The following ClientOriginator class starts the multicast conversation -// with the ClientTarget class.. -// It performs the following main tasks: -// 1)Creates a socket and binds it to the port on which to communicate. -// 2)Specifies that the connection must use an IPv6 address. -// 3)Joins or create a multicast group. -// Note that the multicast address ranges to use are specified -// in the RFC#2375. -// 4)Defines the endpoint to send the data to and starts the -// client target (ClientTarget) thread. -public ref class ClientOriginator -{ -private: - static UdpClient^ clientOriginator; - static IPAddress^ m_GrpAddr; - static IPEndPoint^ m_ClientTargetdest; - static Thread^ m_t; - -public: - - // The ConnectOriginatorAndTarget method connects the - // ClientOriginator with the ClientTarget. - // It performs the following main tasks: - // 1)Creates a UDP client to receive data on a specific port - // using IPv6 addresses. - // 2)Joins or create a multicast group at the specified address. - // 3)Defines the endpoint port to send data to on the ClientTarget. - // 4)Starts the ClientTarget thread that also creates the ClientTarget Object*. - // Note this method is the counterpart of the - // ClientTarget::StartMulticastConversation(). - static bool ConnectOriginatorAndTarget() - { - try - { - - // - // Bind and listen on port 2000. This constructor creates a socket - // and binds it to the port on which to receive data. The family - // parameter specifies that this connection uses an IPv6 address. - clientOriginator = gcnew UdpClient( 2000,AddressFamily::InterNetworkV6 ); - - // Join or create a multicast group. The multicast address ranges - // to use are specified in RFC#2375. You are free to use - // different addresses. - // Transform the String* address into the internal format. - m_GrpAddr = IPAddress::Parse( "FF01::1" ); - - // Display the multicast address used. - Console::WriteLine( "Multicast Address: [ {0}]", m_GrpAddr ); - - // - // Exercise the use of the IPv6MulticastOption. - Console::WriteLine( "Instantiate IPv6MulticastOption(IPAddress)" ); - - // Instantiate IPv6MulticastOption using one of the - // overloaded constructors. - IPv6MulticastOption^ ipv6MulticastOption = gcnew IPv6MulticastOption( m_GrpAddr ); - - // Store the IPAdress multicast options. - IPAddress^ group = ipv6MulticastOption->Group; - __int64 interfaceIndex = ipv6MulticastOption->InterfaceIndex; - - // Display IPv6MulticastOption properties. - Console::WriteLine( "IPv6MulticastOption::Group: [ {0}]", group ); - Console::WriteLine( "IPv6MulticastOption::InterfaceIndex: [ {0}]", interfaceIndex ); - - // - // - // Instantiate IPv6MulticastOption using another - // overloaded constructor. - IPv6MulticastOption^ ipv6MulticastOption2 = gcnew IPv6MulticastOption( group,interfaceIndex ); - - // Store the IPAdress multicast options. - group = ipv6MulticastOption2->Group; - interfaceIndex = ipv6MulticastOption2->InterfaceIndex; - - // Display the IPv6MulticastOption2 properties. - Console::WriteLine( "IPv6MulticastOption::Group: [ {0} ]", group ); - Console::WriteLine( "IPv6MulticastOption::InterfaceIndex: [ {0} ]", interfaceIndex ); - - // Join the specified multicast group using one of the - // JoinMulticastGroup overloaded methods. - clientOriginator->JoinMulticastGroup( (int)interfaceIndex, group ); - - // - // Define the endpoint data port. Note that this port number - // must match the ClientTarget UDP port number which is the - // port on which the ClientTarget is receiving data. - m_ClientTargetdest = gcnew IPEndPoint( m_GrpAddr,1000 ); - - // - // Start the ClientTarget thread so it is ready to receive. - m_t = gcnew Thread( gcnew ThreadStart( ClientTarget::StartMulticastConversation ) ); - m_t->Start(); - - // Make sure that the thread has started. - Thread::Sleep( 2000 ); - return true; - } - catch ( Exception^ e ) - { - Console::WriteLine( "[ClientOriginator::ConnectClients] Exception: {0}", e ); - return false; - } - - } - - - // The SendAndReceive performs the data exchange - // between the ClientOriginator and the ClientTarget classes. - static String^ SendAndReceive() - { - String^ Ret = ""; - - // - // Send data to ClientTarget. - Console::WriteLine( "\nThe ClientOriginator sent:\n" ); - Send::OriginatorSendData( clientOriginator, m_ClientTargetdest ); - - // Receive data from ClientTarget - Ret = Receive::ReceiveUntilStop( clientOriginator ); - - // Stop the ClientTarget thread - m_t->Abort(); - - // Abandon the multicast group. - clientOriginator->DropMulticastGroup( m_GrpAddr ); - - // - return Ret; - } - -}; - - -//This is the console application entry point. -int main() -{ - - // Join the multicast group. - if ( ClientOriginator::ConnectOriginatorAndTarget() ) - { - - // Perform a multicast conversation with the ClientTarget. - String^ Ret = ClientOriginator::SendAndReceive(); - Console::WriteLine( "\nThe ClientOriginator received: \n\n {0}", Ret ); - } - else - { - Console::WriteLine( "Unable to Join the multicast group" ); - } -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp deleted file mode 100644 index 30d3d0da5b033..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp +++ /dev/null @@ -1,88 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -ref class UdpClientExamples -{ -public: - - // - static void GetAvailable( UdpClient^ u ) - { - // Get the number of bytes available for reading. - Console::WriteLine( "Available value is {0}", u->Available ); - } - // - - // - static void GetSetDontFragment( UdpClient^ u ) - { - // Set the don't fragment flag for packets emanating from - // this client. - u->DontFragment = true; - Console::WriteLine( "DontFragment value is {0}", u->DontFragment ); - } - // - - // - static void GetSetEnableBroadcast( UdpClient^ u ) - { - // Set the Broadcast flag for this client. - u->EnableBroadcast = true; - Console::WriteLine( "EnableBroadcast value is {0}", u->EnableBroadcast ); - } - // - - // - static void GetSetExclusiveAddressUse( UdpClient^ u ) - { - // Don't allow another client to bind to this port. - u->ExclusiveAddressUse = true; - Console::WriteLine( "ExclusiveAddressUse value is {0}", u->ExclusiveAddressUse ); - } - // - - // - static void GetSetTtl( UdpClient^ u ) - { - // Set the Time To Live (TTL) for this client. - u->Ttl = 42; - Console::WriteLine( "Ttl value is {0}", u->Ttl ); - } - // - - // - // Subscribe to a multicast group. - static void DoJoinMulticastGroup( UdpClient^ u, String^ mcast, String^ local ) - { - array^ multicastAddress = Dns::GetHostAddresses( mcast ); - - u->JoinMulticastGroup( multicastAddress[0] ); - Console::WriteLine( "Joined multicast Address {0}", multicastAddress ); - } - // - - // - static void GetSetMulticastLoopback( UdpClient^ u ) - { - // Deliver multicast packets back to the sending client. - u->MulticastLoopback = true; - Console::WriteLine( "MulticastLoopback value is {0}", u->MulticastLoopback ); - } - // -}; - -int main() -{ - UdpClient^ u = gcnew UdpClient( 4242 ); - UdpClientExamples::GetAvailable( u ); - UdpClientExamples::GetSetDontFragment( u ); - UdpClientExamples::GetSetEnableBroadcast( u ); - UdpClientExamples::GetSetExclusiveAddressUse( u ); - UdpClientExamples::GetSetTtl( u ); - UdpClientExamples::DoJoinMulticastGroup( u, "224.1.1.1", "172.30.186.134" ); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp deleted file mode 100644 index e6554acb19660..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -public ref class UdpClientExample -{ - // -private: - static int listenPort = 13000; - -public: - value struct UdpState - { - public: - UdpClient^ udpClient; - IPEndPoint^ ipEndPoint; - }; - - static bool isMessageReceived; - - static void ReceiveCallback(IAsyncResult^ asyncResult) - { - UdpClient^ udpClient = - ((UdpState)(asyncResult->AsyncState)).udpClient; - IPEndPoint^ ipEndPoint = - ((UdpState)(asyncResult->AsyncState)).ipEndPoint; - - array^ receiveBytes = - udpClient->EndReceive(asyncResult, ipEndPoint); - String^ receiveString = - Encoding::ASCII->GetString(receiveBytes); - - Console::WriteLine("Received: {0}", receiveString); - isMessageReceived = true; - } - - static void ReceiveMessages() - { - // Receive a message and write it to the console. - IPEndPoint^ ipEndPoint = gcnew IPEndPoint(IPAddress::Any, listenPort); - UdpClient^ udpClient = gcnew UdpClient(ipEndPoint); - - UdpState^ udpState = gcnew UdpState(); - udpState->ipEndPoint = ipEndPoint; - udpState->udpClient = udpClient; - - Console::WriteLine("listening for messages"); - udpClient->BeginReceive(gcnew AsyncCallback(ReceiveCallback), - udpState); - - // Do some work while we wait for a message. For this example, - // we'll just sleep - while (!isMessageReceived) - { - Thread::Sleep(100); - } - } - // - - // -public: - static bool isMessageSent; - - static void SendCallback(IAsyncResult^ asyncResult) - { - UdpClient^ udpClient = (UdpClient^)asyncResult->AsyncState; - - Console::WriteLine("number of bytes sent: {0}", - udpClient->EndSend(asyncResult)); - isMessageSent = true; - } - // - - // -public: - static void SendMessage1(String^ server, String^ message) - { - // create the udp socket - UdpClient^ udpClient = gcnew UdpClient(); - - udpClient->Connect(server, listenPort); - array^ sendBytes = Encoding::ASCII->GetBytes(message); - - // send the message - // the destination is defined by the call to .Connect() - udpClient->BeginSend(sendBytes, sendBytes->Length, - gcnew AsyncCallback(SendCallback), udpClient); - - // Do some work while we wait for the send to complete. For - // this example, we'll just sleep - while (!isMessageSent) - { - Thread::Sleep(100); - } - } - // - - // -public: - static void SendMessage2(String^ server, String^ message) - { - // create the udp socket - UdpClient^ udpClient = gcnew UdpClient(); - array^ sendBytes = Encoding::ASCII->GetBytes(message); - - // resolve the server name - IPHostEntry^ resolvedServer = Dns::GetHostEntry(server); - - IPEndPoint^ ipEndPoint = - gcnew IPEndPoint(resolvedServer->AddressList[0], listenPort); - - // send the message - // the destination is defined by the IPEndPoint - udpClient->BeginSend(sendBytes, sendBytes->Length, ipEndPoint, - gcnew AsyncCallback(SendCallback), udpClient); - - // Do some work while we wait for the send to complete. For - // this example, we'll just sleep - while (!isMessageSent) - { - Thread::Sleep(100); - } - } - // - - // -public: - static void SendMessage3(String^ server, String^ message) - { - // create the udp socket - UdpClient^ udpClient = gcnew UdpClient(); - - array^ sendBytes = Encoding::ASCII->GetBytes(message); - - // send the message - // the destination is defined by the server name and port - udpClient->BeginSend(sendBytes, sendBytes->Length, server, listenPort, - gcnew AsyncCallback(SendCallback), udpClient); - - // Do some work while we wait for the send to complete. For - // this example, we'll just sleep - while (!isMessageSent) - { - Thread::Sleep(100); - } - } - // - -}; - -int main(array^ args) -{ - // Parse arguments - String^ server = ""; - String^ message = "This is a test!"; - bool isServer; - int sendMethod = 1; // n called SendMessagen - - if (args->Length == 0) - { - server = "localhost"; - isServer = false; - } - else if (args->Length == 1) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - } - else if (args->Length == 2) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - server = args[1]; - } - else if (args->Length == 3) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - server = args[1]; - message = args[2]; - } - else if (args->Length == 4) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - server = args[1]; - message = args[2]; - - try - { - sendMethod = Convert::ToInt32(args[3]); - } - catch (System::ArgumentNullException^ ex) - { - Console::WriteLine(ex->Message); - } - catch (System::FormatException^ ex) - { - Console::WriteLine(ex->Message); - } - catch (System::OverflowException^ ex) - { - Console::WriteLine(ex->Message); - } - } - else - { - Console::WriteLine( - "Usage: asyncudp [s|c] [host name] [message] [send method]"); - return 0; - } - - if (isServer) - { - UdpClientExample::ReceiveMessages(); - } - else - { - switch (sendMethod) - { - case 1: - UdpClientExample::SendMessage1(server, message); - break; - case 2: - UdpClientExample::SendMessage2(server, message); - break; - case 3: - UdpClientExample::SendMessage3(server, message); - break; - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/makefile deleted file mode 100644 index f37b3cc52039e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/makefile +++ /dev/null @@ -1,2 +0,0 @@ -System.Net.Sockets.UdpClient1.exe: asyncudp.cpp - cl /clr:pure /FeSystem.Net.Sockets.UdpClient1.exe asyncudp.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_client.cpp deleted file mode 100644 index 69d3a8ab9a839..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_client.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -static void main() -{ - // Register TCP Channel. - ChannelServices::RegisterChannel( gcnew TcpChannel ); - - // - // Create activated client type entry. - ActivatedClientTypeEntry^ activatedClientTypeEntry = gcnew ActivatedClientTypeEntry( HelloServer::typeid, "tcp://localhost:8082" ); - - // - // Register type on client to activate it on the server. - RemotingConfiguration::RegisterActivatedClientType( activatedClientTypeEntry ); - - // Activate a client activated object type. - HelloServer^ helloServer = gcnew HelloServer( "ParameterString" ); - - // - // Print the object type. - Console::WriteLine( "Object type of client activated object: {0}", activatedClientTypeEntry->ObjectType->ToString() ); - - // - // - // Print the application URL. - Console::WriteLine( "Application url where the type is activated: {0}", activatedClientTypeEntry->ApplicationUrl->ToString() ); - - // - // - // Print the string representation of the type entry. - Console::WriteLine( "Type and assembly name and application URL of the remote object: {0}", activatedClientTypeEntry->ToString() ); - - // - // Print a blank line. - Console::WriteLine(); - - // Check that server was located. - if ( !helloServer ) - { - Console::WriteLine( "Could not locate server" ); - } - else - { - Console::WriteLine( "Calling remote object" ); - Console::WriteLine( helloServer->HelloMethod( "Bill" ) ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_server.cpp deleted file mode 100644 index a394900be3c4b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_server.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -void main() -{ - ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) ); - RemotingConfiguration::RegisterActivatedServiceType( HelloServer::typeid ); - Console::WriteLine( "Press enter to stop this process" ); - Console::ReadLine(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_share.cpp deleted file mode 100644 index ba2e8f35ea83e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/activatedclienttypeentry_share.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -public ref class HelloServer: public MarshalByRefObject -{ -public: - HelloServer( String^ myString ) - { - Console::WriteLine( "HelloServer activated" ); - Console::WriteLine( "Paramater passed to the constructor is {0}", myString ); - } - - String^ HelloMethod( String^ myName ) - { - Console::WriteLine( "HelloMethod : {0}", myName ); - return String::Format( "Hi there {0}", myName ); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/makefile deleted file mode 100644 index 10e3c2609ac63..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.ActivatedClientTypeEntry/CPP/makefile +++ /dev/null @@ -1,13 +0,0 @@ -all : activatedclienttypeentry_server.exe activatedclienttypeentry_client.exe - - -activatedclienttypeentry_server.exe : activatedclienttypeentry_server.cpp activatedclienttypeentry_share.dll - cl /clr:pure activatedclienttypeentry_server.cpp - -activatedclienttypeentry_client.exe : activatedclienttypeentry_client.cpp activatedclienttypeentry_share.dll - cl /clr:pure activatedclienttypeentry_client.cpp - -activatedclienttypeentry_share.dll : activatedclienttypeentry_share.cpp - cl /LD /clr:pure activatedclienttypeentry_share.cpp - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/client.cpp deleted file mode 100644 index b590a6fac71ef..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/client.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using -#using -#using "RemoteObject.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Activation; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -[STAThread] -int main() -{ - - // Report initial status. - Console::WriteLine( "Client starting." ); - - // Register TCP channel. - ChannelServices::RegisterChannel( gcnew TcpChannel ); - - // - // Create UrlAttribute. - UrlAttribute^ attribute = gcnew UrlAttribute( "tcp://localhost:1234/RemoteApp" ); - Console::WriteLine( "UrlAttribute value: {0}", attribute->UrlValue ); - - // - array^activationAttributes = {attribute}; - - // Use UrlAttribute to register for client activated remote object. - RemotingConfiguration::RegisterActivatedClientType( RemoteObject::typeid, "tcp://localhost:1234/RemoteApp" ); - - // Activate remote object. - Console::WriteLine( "Activating remote object." ); - RemoteObject ^ obj = dynamic_cast(Activator::CreateInstance( RemoteObject::typeid, nullptr, activationAttributes )); - - // Invoke a method on it. - Console::WriteLine( "Invoking Hello() on remote object." ); - obj->Hello(); - - // Inform user of termination. - Console::WriteLine( "Terminating client." ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/makefile deleted file mode 100644 index 648abbbb6893d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/makefile +++ /dev/null @@ -1,13 +0,0 @@ -all : server.exe client.exe - - -Server.exe : Server.cpp remoteobject.dll - cl /clr:pure Server.cpp - -client.exe : client.cpp remoteobject.dll - cl /clr:pure client.cpp - -remoteobject.dll : remoteobject.cpp - cl /LD /clr:pure remoteobject.cpp - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/remoteobject.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/remoteobject.cpp deleted file mode 100644 index 9ce57af4de150..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/remoteobject.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::Security; -using namespace System::Security::Permissions; - -[assembly:AllowPartiallyTrustedCallersAttribute]; -public ref class RemoteObject: public MarshalByRefObject -{ -public: - RemoteObject() - { - - // Report object construction to server's console. - Console::WriteLine( "You have called the constructor." ); - } - - void Hello() - { - - // Report method invocation to server's console. - Console::WriteLine( "You have called Hello()." ); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/server.cpp deleted file mode 100644 index d6e404eb60d68..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Activation.UrlAttribute/CPP/server.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using -#using -#using "RemoteObject.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -[STAThread] -int main() -{ - - // Report status to user. - Console::WriteLine( "Server starting." ); - - // Register the TCP channel. - ChannelServices::RegisterChannel( gcnew TcpChannel( 1234 ) ); - - // Set application name. - RemotingConfiguration::ApplicationName = "RemoteApp"; - - // Register object for client activated remoting. - RemotingConfiguration::RegisterActivatedServiceType( RemoteObject::typeid ); - - // Wait until termination. - Console::WriteLine( "Press enter to end." ); - Console::ReadLine(); - Console::WriteLine( "Terminating server." ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/client.cpp deleted file mode 100644 index 7fd2481de4696..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/client.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -/// Class: System.Runtime.Remoting.Channels.Http.HttpClientChannel -/// 10 class - client -/// 40 class - server -/// 30 class - remotable object -/// 21 #ctor(IDictionary,IClientChannelSinkProvider) -/// 22 #ctor(string,sinkProvider) -/// 11 CreateMessageSink -/// 12 Item -/// 12 Keys -/// 13 Parse -// -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -void main() -{ - // Create the channel. - HttpClientChannel^ clientChannel = gcnew HttpClientChannel; - - // Register the channel. - ChannelServices::RegisterChannel( clientChannel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( RemoteObject::typeid,L"http://localhost:9090/RemoteObject.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - - // - // Create a message sink. - String^ objectUri; - System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = clientChannel->CreateMessageSink( L"http://localhost:9090/RemoteObject.rem", nullptr, objectUri ); - Console::WriteLine( L"The URI of the message sink is {0}.", objectUri ); - if ( messageSink != nullptr ) - { - Console::WriteLine( L"The type of the message sink is {0}.", messageSink->GetType() ); - } - // - - // - // Display the channel's properties using Keys and Item. - for each(String^ key in clientChannel->Keys) - { - Console::WriteLine("clientChannel[{0}] = <{1}>", key, clientChannel[key]); - } - // - - // - // Parse the channel's URI. - String^ objectUrl = L"http://localhost:9090/RemoteObject.rem"; - String^ channelUri = clientChannel->Parse( objectUrl, objectUri ); - Console::WriteLine( L"The object URL is {0}.", objectUrl ); - Console::WriteLine( L"The object URI is {0}.", objectUri ); - Console::WriteLine( L"The channel URI is {0}.", channelUri ); - // - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/client2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/client2.cpp deleted file mode 100644 index 82c72ff9ce5d0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/client2.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -/// x broken -/// + done -/// 9 number of snippet -/// Need snippets: -/// 21 #ctor(IDictionary,IClientChannelSinkProvider) -/// 22 #ctor(string,sinkProvider) -/// 11 CreateMessageSink -/// 12 Item -/// 12 Keys -/// 13 Parse -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -static HttpClientChannel^ Ctor1() -{ - - // - // Create a client channel. - System::Collections::Hashtable^ properties = gcnew System::Collections::Hashtable; - properties->default[ L"port" ] = 9090; - IClientChannelSinkProvider^ sinkProvider = nullptr; - HttpClientChannel^ clientChannel = gcnew HttpClientChannel( properties,sinkProvider ); - - // - return clientChannel; -} - -static HttpClientChannel^ Ctor2() -{ - - // - // Create a client channel. - String^ name = L"RemotingClient"; - IClientChannelSinkProvider^ sinkProvider = nullptr; - HttpClientChannel^ clientChannel = gcnew HttpClientChannel( name,sinkProvider ); - - // - return clientChannel; -} - -static void Register( HttpClientChannel^ channel ) -{ - - // Register the channel. - ChannelServices::RegisterChannel( channel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( - RemoteObject::typeid, L"http://localhost:9090/RemoteObject.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); -} - -static void InvokeRemoteObject( RemoteObject^ service ) -{ - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() ); -} - -void main() -{ - array^args = Environment::GetCommandLineArgs(); - - // Create the channel. - HttpClientChannel^ clientChannel = nullptr; - String^ overload = args[ 1 ]; - if ( overload->Equals( L"1" ) ) - clientChannel = Ctor1(); - else - if ( overload->Equals( L"2" ) ) - clientChannel = Ctor2(); - else - throw gcnew Exception( String::Format( L"Argument {0} was invalid.", args[ 1 ] ) ); - - - - // Register the channel and the client. - Register( clientChannel ); - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - InvokeRemoteObject( service ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/common.cpp deleted file mode 100644 index 48993e10a85db..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/common.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -#using -using namespace System; -using namespace System::Runtime::Remoting; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - static int callCount = 0; - -public: - int GetCount() - { - Console::WriteLine( L"GetCount was called." ); - callCount++; - return (callCount); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/makefile deleted file mode 100644 index ab032f3a76441..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/makefile +++ /dev/null @@ -1,15 +0,0 @@ -all : server.exe client.exe client2.exe - - -server.exe : server.cpp common.dll - cl /clr:pure server.cpp - -client.exe : client.cpp common.dll - cl /clr:pure client.cpp - -client2.exe : client2.cpp common.dll - cl /clr:pure client2.cpp - -common.dll : common.cpp - cl /clr:pure /LD common.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/server.cpp deleted file mode 100644 index 644ca673c785e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpClientChannel/CPP/server.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -void main() -{ - // Create the server channel. - HttpServerChannel^ serverChannel = gcnew HttpServerChannel( 9090 ); - - // Register the server channel. - ChannelServices::RegisterChannel( serverChannel ); - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( RemoteObject::typeid, L"RemoteObject.rem", WellKnownObjectMode::Singleton ); - - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/client.cpp deleted file mode 100644 index 0bc567804aaa2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/client.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -void main() -{ - // Create the channel. - HttpClientChannel^ channel = gcnew HttpClientChannel; - - // Register the channel. - ChannelServices::RegisterChannel( channel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( - RemoteObject::typeid,L"http://localhost:9090/RemoteObject.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/common.cpp deleted file mode 100644 index db03ebf8070f4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/common.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -using namespace System; -using namespace System::Runtime::Remoting; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - static int callCount = 0; - -public: - int GetCount() - { - callCount++; - return (callCount); - } - -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/makefile deleted file mode 100644 index 5a7420094c8c5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/makefile +++ /dev/null @@ -1,15 +0,0 @@ -all : server.exe client.exe server2.exe - - -server.exe : server.cpp common.dll - cl /clr:pure server.cpp - -client.exe : client.cpp common.dll - cl /clr:pure client.cpp - -server2.exe : server2.cpp common.dll - cl /clr:pure server2.cpp - -common.dll : common.cpp - cl /clr:pure /LD common.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/server.cpp deleted file mode 100644 index 52710e3ce2a52..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/server.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Http.HttpServerChannel -/// 20 class - server -/// 30 class - client -/// 40 class - remotable object -/// 12 ctor(IDictionary,IServerChannelSinkProvider) -/// 13 ctor(string,int) -/// 14 ctor(string,int,IServerChannelSinkProvider) -/// 21 ChannelScheme -/// 23 ChannelSinkChain -/// 22 GetChannelUri() -/// 25 Parse() -/// 24 WantsToListen -/// ! Ctor() -/// ! AddHookChannelUri -/// ! Item -/// ! Keys -/// ! StartListening -/// ! StopListening -/// Bug Notes [01-26-04][Mon] -/// AddHookChannelUri does not pick up port. -/// Ctor() would be usable if AddHookChannelUri could be -/// used to set the port later. Since it can't Ctor() is -/// also unusable. Items and Keys are unimplemented. While -/// StopListening works, StartListening does not restart -/// listening -- client fails. These two are likely to be -/// used as a pair and are therefore unusable. -// -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -int main() -{ - // Create the server channel. - HttpServerChannel^ serverChannel = gcnew HttpServerChannel( 9090 ); - - // Register the server channel. - ChannelServices::RegisterChannel( serverChannel ); - - // - // Display the channel's scheme. - Console::WriteLine( L"The channel scheme is {0}.", serverChannel->ChannelScheme ); - - // - // - // Display the channel's URI. - Console::WriteLine( L"The channel URI is {0}.", serverChannel->GetChannelUri() ); - - // - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( - RemoteObject::typeid, L"RemoteObject.rem", WellKnownObjectMode::Singleton ); - - // - // Get the channel's sink chain. - IServerChannelSink^ sinkChain = serverChannel->ChannelSinkChain; - Console::WriteLine( L"The type of the server channel's sink chain is {0}.", sinkChain->GetType() ); - - // - // - // See if the channel wants to listen. - bool wantsToListen = serverChannel->WantsToListen; - Console::WriteLine( L"The value of WantsToListen is {0}.", wantsToListen ); - - // - // - // Parse the channel's URI. - array^ urls = serverChannel->GetUrlsForUri( L"RemoteObject.rem" ); - if ( urls->Length > 0 ) - { - String^ objectUrl = urls[ 0 ]; - String^ objectUri; - String^ channelUri = serverChannel->Parse( objectUrl, objectUri ); - Console::WriteLine( L"The object URI is {0}.", objectUri ); - Console::WriteLine( L"The channel URI is {0}.", channelUri ); - Console::WriteLine( L"The object URL is {0}.", objectUrl ); - } - - - // - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/server2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/server2.cpp deleted file mode 100644 index 845f7224e298a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Http.HttpServerChannel/CPP/server2.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/// Legend: -/// - Bugs -/// x Done -/// Work in progress -/// Snippets needed: -/// - Ctor() -/// x Ctor(IDictionary,IServerChannelSinkProvider) -/// x Ctor(string,int) -/// x Ctor(string,int,IServerChannelSinkProvider) -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -static HttpServerChannel^ Ctor2() -{ - // - System::Collections::Hashtable^ properties = gcnew System::Collections::Hashtable; - properties->default[ L"port" ] = 9090; - IServerChannelSinkProvider^ sinkProvider = nullptr; - HttpServerChannel^ serverChannel = gcnew HttpServerChannel( properties,sinkProvider ); - - // - return serverChannel; -} - -// Broken. -static HttpServerChannel^ Ctor1() -{ - // - HttpServerChannel^ serverChannel = gcnew HttpServerChannel; - serverChannel->AddHookChannelUri( L"http://localhost:9090" ); - - // - // return serverChannel; - // Return good channel until fix. - return Ctor2(); -} - -static HttpServerChannel^ Ctor3() -{ - // - String^ name = L"RemotingServer"; - int port = 9090; - HttpServerChannel^ serverChannel = gcnew HttpServerChannel( name,port ); - - // - return serverChannel; -} - -static HttpServerChannel^ Ctor4() -{ - - // - String^ name = L"RemotingServer"; - int port = 9090; - IServerChannelSinkProvider^ sinkProvider = nullptr; - HttpServerChannel^ serverChannel = gcnew HttpServerChannel( - name,port,sinkProvider ); - - // - return serverChannel; -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - HttpServerChannel^ serverChannel = nullptr; - String^ overload = args[ 1 ]; - if ( overload->Equals( L"1" ) ) serverChannel = Ctor1(); - else if ( overload->Equals( L"2" ) ) serverChannel = Ctor2(); - else if ( overload->Equals( L"3" ) ) serverChannel = Ctor3(); - else if ( overload->Equals( L"4" ) ) serverChannel = Ctor4(); - else throw gcnew Exception( String::Format( - L"Argument {0} was invalid.", args[ 1 ] ) ); - - // Register the server channel. - ChannelServices::RegisterChannel( serverChannel ); - - // Display the channel's URI. - Console::WriteLine( L"The URI of the channel is {0}.", - serverChannel->GetChannelUri() ); - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( - RemoteObject::typeid, L"RemoteObject.rem", - WellKnownObjectMode::Singleton ); - - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/client.cpp deleted file mode 100644 index 4c49318b1c7a3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/client.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting::Channels::Ipc; - -void main() -{ - - // - // Create the channel. - IpcChannel^ channel = gcnew IpcChannel; - - // - // Register the channel. - System::Runtime::Remoting::Channels::ChannelServices::RegisterChannel(channel); - - // Register as client for remote object. - System::Runtime::Remoting::WellKnownClientTypeEntry^ remoteType = gcnew - System::Runtime::Remoting::WellKnownClientTypeEntry( - RemoteObject::typeid,L"ipc://localhost:9090/RemoteObject.rem" ); - System::Runtime::Remoting::RemotingConfiguration::RegisterWellKnownClientType(remoteType); - - // - // Create a message sink. - String^ objectUri; - System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = channel->CreateMessageSink( - L"ipc://localhost:9090/RemoteObject.rem", nullptr, objectUri ); - Console::WriteLine( L"The URI of the message sink is {0}.", objectUri ); - if ( messageSink != nullptr ) - { - Console::WriteLine( L"The type of the message sink is {0}.", messageSink->GetType() ); - } - - - // - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/common.cpp deleted file mode 100644 index 8143f1ac9c196..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/common.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - static int callCount = 0; - -public: - int GetCount() - { - Console::WriteLine( L"GetCount has been called." ); - callCount++; - return (callCount); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/makefile deleted file mode 100644 index 5a7420094c8c5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/makefile +++ /dev/null @@ -1,15 +0,0 @@ -all : server.exe client.exe server2.exe - - -server.exe : server.cpp common.dll - cl /clr:pure server.cpp - -client.exe : client.cpp common.dll - cl /clr:pure client.cpp - -server2.exe : server2.cpp common.dll - cl /clr:pure server2.cpp - -common.dll : common.cpp - cl /clr:pure /LD common.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/server.cpp deleted file mode 100644 index fb005b99e6481..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/server.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Ipc.IpcChannel -/// 10 class - Server.cs -/// 20 class - Client.cs -/// 30 class - Common.cs -/// 21 #ctor() -/// 11 #ctor(string) -/// 41 #ctor(IDictionary,IClientChannelSinkProvider,IServerChannelSinkProvider) -/// 15 ChannelData -/// 12 ChannelName -/// 13 ChannelPriority -/// 22 CreateMessageSink() -/// 19 GetUrlsForUri() -/// 19 Parse() -/// ! StartListening() -/// ! StopListening() -// -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting::Channels::Ipc; - -void main() -{ - // - // Create the server channel. - IpcChannel^ serverChannel = gcnew IpcChannel( L"localhost:9090" ); - // - - // Register the server channel. - System::Runtime::Remoting::Channels::ChannelServices::RegisterChannel( serverChannel ); - - // - // Show the name of the channel. - Console::WriteLine( L"The name of the channel is {0}.", serverChannel->ChannelName ); - // - - // - // Show the priority of the channel. - Console::WriteLine( L"The priority of the channel is {0}.", serverChannel->ChannelPriority ); - // - - // - // Show the URIs associated with the channel. - System::Runtime::Remoting::Channels::ChannelDataStore^ channelData = (System::Runtime::Remoting::Channels::ChannelDataStore^)serverChannel->ChannelData; - for each (String^ uri in channelData->ChannelUris) - { - Console::WriteLine("The channel URI is {0}.", uri); - } - // - - // Expose an object for remote calls. - System::Runtime::Remoting::RemotingConfiguration::RegisterWellKnownServiceType( - RemoteObject::typeid,L"RemoteObject.rem", - System::Runtime::Remoting::WellKnownObjectMode::Singleton); - - // - // Parse the channel's URI. - array^ urls = serverChannel->GetUrlsForUri( L"RemoteObject.rem" ); - if ( urls->Length > 0 ) - { - String^ objectUrl = urls[ 0 ]; - String^ objectUri; - String^ channelUri = serverChannel->Parse( objectUrl, objectUri ); - Console::WriteLine( L"The object URI is {0}.", objectUri ); - Console::WriteLine( L"The channel URI is {0}.", channelUri ); - Console::WriteLine( L"The object URL is {0}.", objectUrl ); - } - // - - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/server2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/server2.cpp deleted file mode 100644 index 3bd26211f01cc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcChannel/CPP/server2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Ipc.IpcChannel -/// 41 #ctor(IDictionary,IClientChannelSinkProvider,IServerChannelSinkProvider) -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; - -void main() -{ - - // - // Create the server channel. - System::Collections::IDictionary^ properties = gcnew System::Collections::Hashtable; - properties->default[ L"name" ] = L"ipc"; - properties->default[ L"priority" ] = L"20"; - properties->default[ L"portName" ] = L"localhost:9090"; - IpcChannel^ serverChannel = gcnew IpcChannel( properties,nullptr,nullptr ); - - // - // Register the server channel. - ChannelServices::RegisterChannel( serverChannel ); - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( - RemoteObject::typeid, L"RemoteObject.rem", WellKnownObjectMode::Singleton ); - - // Show the URIs associated with the channel. - ChannelDataStore^ channelData = dynamic_cast(serverChannel->ChannelData); - System::Collections::IEnumerator^ myEnum = channelData->ChannelUris->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ uri = safe_cast(myEnum->Current); - Console::WriteLine( L"The channel URI is {0}.", uri ); - } - - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/client.cpp deleted file mode 100644 index 83717776b8bce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/client.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Ipc.IpcClientChannel -/// 41 #ctor(IDictionary,IClientChannelSinkProvider) -/// 42 #ctor(String,IClientChannelSinkProvider) -/// 21 ChannelName -/// 23 ChannelPriority -/// 22 CreateMessageSink(String,Object,String@) -/// 24 Parse(String,String@) -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; - -void main() -{ - - // Create the channel. - IpcClientChannel^ clientChannel = gcnew IpcClientChannel; - - // Register the channel. - System::Runtime::Remoting::Channels::ChannelServices::RegisterChannel(clientChannel); - - // - // Show the name of the channel. - Console::WriteLine( L"The name of the channel is {0}.", clientChannel->ChannelName ); - - // - // - // Show the priority of the channel. - Console::WriteLine( L"The priority of the channel is {0}.", clientChannel->ChannelPriority ); - - // - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( - RemoteObject::typeid,L"ipc://localhost:9090/RemoteObject.rem" ); - System::Runtime::Remoting::RemotingConfiguration::RegisterWellKnownClientType(remoteType); - - // - // Create a message sink. - String^ messageSinkUri; - Messaging::IMessageSink^ messageSink = clientChannel->CreateMessageSink( - L"ipc://localhost:9090/RemoteObject.rem", nullptr, messageSinkUri ); - Console::WriteLine( L"The URI of the message sink is {0}.", messageSinkUri ); - if ( messageSink != nullptr ) - { - Console::WriteLine( L"The type of the message sink is {0}.", messageSink->GetType() ); - } - - - // - // - // Parse the object URL. - String^ objectUrl = L"ipc://localhost:9090/RemoteObject.rem"; - String^ objectUri; - String^ channelUri = clientChannel->Parse( objectUrl, objectUri ); - Console::WriteLine( L"The object URL is {0}.", objectUrl ); - Console::WriteLine( L"The object URI is {0}.", objectUri ); - Console::WriteLine( L"The channel URI is {0}.", channelUri ); - - // - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/client2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/client2.cpp deleted file mode 100644 index 8b87bbee8c227..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/client2.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Ipc.IpcClientChannel -/// 41 #ctor(IDictionary,IClientChannelSinkProvider) -/// 42 #ctor(String,IClientChannelSinkProvider) -/// 21 ChannelName -/// 23 ChannelPriority -/// 22 CreateMessageSink(String,Object,String@) -/// 24 Parse(String,String@) -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; - -static IpcClientChannel^ Ctor1() -{ - // - // Create the client channel. - System::Collections::IDictionary^ properties = gcnew System::Collections::Hashtable; - properties->default[ L"name" ] = L"ipc client"; - properties->default[ L"priority" ] = L"1"; - IClientChannelSinkProvider^ sinkProvider = nullptr; - IpcClientChannel^ clientChannel = gcnew IpcClientChannel( properties,sinkProvider ); - // - - return clientChannel; -} - -static IpcClientChannel^ Ctor2() -{ - // - // Create the client channel. - String^ name = L"ipc client"; - IClientChannelSinkProvider^ sinkProvider = nullptr; - IpcClientChannel^ clientChannel = gcnew IpcClientChannel( name,sinkProvider ); - // - - return clientChannel; -} - -void main() -{ - array^args = Environment::GetCommandLineArgs(); - - // Create the client channel. - IpcClientChannel^ clientChannel = nullptr; -// if ( false ) {} -// else - if ( args[ 1 ]->Equals( L"1" ) ) - clientChannel = Ctor1(); - else - if ( args[ 1 ]->Equals( L"2" ) ) - clientChannel = Ctor2(); - else - throw gcnew ApplicationException( L"Invalid argument." ); - - // Register the channel. - ChannelServices::RegisterChannel( clientChannel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( - RemoteObject::typeid,L"ipc://localhost:9090/RemoteObject.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/common.cpp deleted file mode 100644 index 5cd87ac3b0217..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/common.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -using namespace System; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - static int callCount = 0; - -public: - int GetCount() - { - Console::WriteLine( L"GetCount has been called." ); - callCount++; - return (callCount); - } - -}; - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/makefile deleted file mode 100644 index ab032f3a76441..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/makefile +++ /dev/null @@ -1,15 +0,0 @@ -all : server.exe client.exe client2.exe - - -server.exe : server.cpp common.dll - cl /clr:pure server.cpp - -client.exe : client.cpp common.dll - cl /clr:pure client.cpp - -client2.exe : client2.cpp common.dll - cl /clr:pure client2.cpp - -common.dll : common.cpp - cl /clr:pure /LD common.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/server.cpp deleted file mode 100644 index c0e876d4fb37a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcClientChannel/CPP/server.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; -void main() -{ - - // Create the server channel. - IpcChannel^ serverChannel = gcnew IpcChannel( L"localhost:9090" ); - - // Register the server channel. - ChannelServices::RegisterChannel( serverChannel ); - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( RemoteObject::typeid, L"RemoteObject.rem", WellKnownObjectMode::Singleton ); - - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/client.cpp deleted file mode 100644 index 08f6b1e8cfc3b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/client.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting::Channels::Ipc; - -void main() -{ - // - // Create the channel. - IpcChannel^ channel = gcnew IpcChannel; - // - - // Register the channel. - System::Runtime::Remoting::Channels::ChannelServices::RegisterChannel(channel); - - // Register as client for remote object. - System::Runtime::Remoting::WellKnownClientTypeEntry^ remoteType = - gcnew System::Runtime::Remoting::WellKnownClientTypeEntry( - RemoteObject::typeid,L"ipc://localhost:9090/RemoteObject.rem" ); - System::Runtime::Remoting::RemotingConfiguration::RegisterWellKnownClientType(remoteType); - - // - // Create a message sink. - String^ objectUri; - System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = - channel->CreateMessageSink( L"ipc://localhost:9090/RemoteObject.rem",nullptr,objectUri ); - Console::WriteLine( L"The URI of the message sink is {0}.",objectUri ); - if ( messageSink != nullptr ) - { - Console::WriteLine( L"The type of the message sink is {0}.",messageSink->GetType() ); - } - // - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.",service->GetCount() ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/common.cpp deleted file mode 100644 index cef9f0974ffe2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/common.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -using namespace System; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - static int callCount = 0; - -public: - int GetCount() - { - Console::WriteLine( L"GetCount has been called." ); - callCount++; - return (callCount); - } - -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/makefile deleted file mode 100644 index 5a7420094c8c5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/makefile +++ /dev/null @@ -1,15 +0,0 @@ -all : server.exe client.exe server2.exe - - -server.exe : server.cpp common.dll - cl /clr:pure server.cpp - -client.exe : client.cpp common.dll - cl /clr:pure client.cpp - -server2.exe : server2.cpp common.dll - cl /clr:pure server2.cpp - -common.dll : common.cpp - cl /clr:pure /LD common.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/server.cpp deleted file mode 100644 index 81cd95206cbe2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/server.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Ipc.IpcServerChannel -/// 41 #ctor(IDictionary,IServerChannelSinkProvider) -/// 42 #ctor(String,String) -/// 43 #ctor(String,String,IServerChannelSinkProvider) -/// 15 ChannelData -/// 12 ChannelName -/// 13 ChannelPriority -/// 19 GetUrlsForUri -/// 19 Parse(String,String@) -/// ! StartListening(Object) -/// ! StopListening(Object) -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; - -void main() -{ - // Create the server channel. - IpcServerChannel^ serverChannel = gcnew IpcServerChannel( L"localhost:9090" ); - - // Register the server channel. - System::Runtime::Remoting::Channels::ChannelServices::RegisterChannel( serverChannel ); - - // - // Show the name of the channel. - Console::WriteLine( L"The name of the channel is {0}.",serverChannel->ChannelName ); - // - - // - // Show the priority of the channel. - Console::WriteLine( L"The priority of the channel is {0}.",serverChannel->ChannelPriority ); - // - - // - // Show the URIs associated with the channel. - System::Runtime::Remoting::Channels::ChannelDataStore^ channelData = - static_cast - (serverChannel->ChannelData); - System::Collections::IEnumerator^ myEnum = channelData->ChannelUris->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ uri = safe_cast( myEnum->Current ); - Console::WriteLine( L"The channel URI is {0}.",uri ); - } - // - - // Expose an object for remote calls. - System::Runtime::Remoting::RemotingConfiguration:: - RegisterWellKnownServiceType( - RemoteObject::typeid,L"RemoteObject.rem", - System::Runtime::Remoting::WellKnownObjectMode::Singleton ); - - // - // Parse the channel's URI. - array^urls = serverChannel->GetUrlsForUri( L"RemoteObject.rem" ); - if ( urls->Length > 0 ) - { - String^ objectUrl = urls[ 0 ]; - String^ objectUri; - String^ channelUri = serverChannel->Parse( objectUrl,objectUri ); - Console::WriteLine( L"The object URI is {0}.",objectUri ); - Console::WriteLine( L"The channel URI is {0}.",channelUri ); - Console::WriteLine( L"The object URL is {0}.",objectUrl ); - } - // - - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/server2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/server2.cpp deleted file mode 100644 index 41624295c7542..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Ipc.IpcServerChannel/CPP/server2.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Ipc.IpcServerChannel -/// 41 #ctor(IDictionary,IServerChannelSinkProvider) -/// 42 #ctor(String,String) -/// 43 #ctor(String,String,IServerChannelSinkProvider) -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Ipc; - -static IpcServerChannel^ Ctor1() -{ - // - // Create the server channel. - System::Collections::IDictionary^ properties = gcnew System::Collections::Hashtable; - properties->default[ L"name" ] = L"ipc"; - properties->default[ L"priority" ] = L"20"; - properties->default[ L"portName" ] = L"localhost:9090"; - IpcServerChannel^ serverChannel = gcnew IpcServerChannel( properties, nullptr ); - - // - return serverChannel; -} - -static IpcServerChannel^ Ctor2() -{ - // - // Create the server channel. - String^ name = L"ipc"; - String^ portName = L"localhost:9090"; - IpcServerChannel^ serverChannel = gcnew IpcServerChannel( name,portName ); - - // - return serverChannel; -} - -static IpcServerChannel^ Ctor3() -{ - // - // Create the server channel. - String^ name = L"ipc"; - String^ portName = L"localhost:9090"; - IServerChannelSinkProvider^ sinkProvider = nullptr; - IpcServerChannel^ serverChannel = gcnew IpcServerChannel( name,portName,sinkProvider ); - - // - return serverChannel; -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // Create the server channel. - IpcServerChannel^ serverChannel = nullptr; - if ( false ) {} - else if ( args[ 1 ]->Equals( L"1" ) ) serverChannel = Ctor1(); - else if ( args[ 1 ]->Equals( L"2" ) ) serverChannel = Ctor2(); - else if ( args[ 1 ]->Equals( L"3" ) ) serverChannel = Ctor3(); - else throw gcnew ApplicationException( L"Invalid argument." ); - - // Register the server channel. - ChannelServices::RegisterChannel( serverChannel ); - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( - RemoteObject::typeid, L"RemoteObject.rem", - WellKnownObjectMode::Singleton ); - - // Show the URIs associated with the channel. - ChannelDataStore^ channelData = static_cast(serverChannel->ChannelData); - System::Collections::IEnumerator^ myEnum = channelData->ChannelUris->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ uri = static_cast(myEnum->Current); - Console::WriteLine( L"The channel URI is {0}.", uri ); - } - - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/client.cpp deleted file mode 100644 index 5318cdac4b1c4..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/client.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Security::Permissions; - -int main(array^ args) -{ - // - // Create the channel. - TcpChannel^ clientChannel = gcnew TcpChannel(); - // - - // Register the channel. - ChannelServices::RegisterChannel(clientChannel, false); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( - RemoteObject::typeid,"tcp://localhost:9090/RemoteObject.rem"); - RemotingConfiguration::RegisterWellKnownClientType(remoteType); - - // - // Create a message sink. - String^ objectUri; - System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = - clientChannel->CreateMessageSink( - "tcp://localhost:9090/RemoteObject.rem", nullptr, - objectUri); - Console::WriteLine("The URI of the message sink is {0}.", - objectUri); - if (messageSink != nullptr) - { - Console::WriteLine("The type of the message sink is {0}.", - messageSink->GetType()->ToString()); - } - // - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject(); - - // Invoke a method on the remote object. - Console::WriteLine("The client is invoking the remote object."); - Console::WriteLine("The remote object has been called {0} times.", - service->GetCount()); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/common.cpp deleted file mode 100644 index a84a5d0ff0770..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/common.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::Remoting; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - int callCount; - -public: - RemoteObject() - : callCount( 0 ) - {} - - int GetCount() - { - callCount++; - return (callCount); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/makefile deleted file mode 100644 index 1f6757e44dcf6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: client.exe server.exe - -server.exe: server.cpp common.dll - cl /clr:pure server.cpp - -client.exe: client.cpp common.dll - cl /clr:pure client.cpp - -common.dll: common.cpp - cl /clr:pure /LD common.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/server.cpp deleted file mode 100644 index 5fbb4596bd1ad..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel/CPP/server.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/// class: System.Runtime.Remoting.Channels.Tcp.TcpChannel -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Security::Permissions; - -[SecurityPermission(SecurityAction::Demand)] -int main(array^ args) -{ - // - // Create the server channel. - TcpChannel^ serverChannel = gcnew TcpChannel(9090); - // - - // Register the server channel. - ChannelServices::RegisterChannel(serverChannel); - - // - // Show the name of the channel. - Console::WriteLine("The name of the channel is {0}.", - serverChannel->ChannelName); - // - - // - // Show the priority of the channel. - Console::WriteLine("The priority of the channel is {0}.", - serverChannel->ChannelPriority); - // - - // - // Show the URIs associated with the channel. - ChannelDataStore^ data = (ChannelDataStore^) serverChannel->ChannelData; - for each (String^ uri in data->ChannelUris) - { - Console::WriteLine("The channel URI is {0}.", uri); - } - // - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( - RemoteObject::typeid, "RemoteObject.rem", - WellKnownObjectMode::Singleton); - - // - // Parse the channel's URI. - array^ urls = serverChannel->GetUrlsForUri("RemoteObject.rem"); - if (urls->Length > 0) - { - String^ objectUrl = urls[0]; - String^ objectUri; - String^ channelUri = serverChannel->Parse(objectUrl, objectUri); - Console::WriteLine("The object URL is {0}.", objectUrl); - Console::WriteLine("The object URI is {0}.", objectUri); - Console::WriteLine("The channel URI is {0}.", channelUri); - } - // - - // Wait for the user prompt. - Console::WriteLine("Press ENTER to exit the server."); - Console::ReadLine(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/client.cpp deleted file mode 100644 index 5cf5fe50fba83..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/client.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - // Create the channel. - TcpChannel^ clientChannel = gcnew TcpChannel; - - // Register the channel. - ChannelServices::RegisterChannel( clientChannel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( RemoteObject::typeid,"tcp://localhost:9090/RemoteObject.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - - // Create a message sink. - String^ objectUri; - System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = clientChannel->CreateMessageSink( "tcp://localhost:9090/RemoteObject.rem", nullptr, objectUri ); - Console::WriteLine( "The URI of the message sink is {0}.", objectUri ); - Console::WriteLine( "The type of the message sink is {0}.", messageSink->GetType() ); - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( "The client is invoking the remote object." ); - Console::WriteLine( "The remote object has been called {0} times.", service->GetCount() ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/common.cpp deleted file mode 100644 index 4459e19adc891..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/common.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -using namespace System; -using namespace System::Runtime::Remoting; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - int callCount; - -public: - RemoteObject() - : callCount( 0 ) - {} - - int GetCount() - { - callCount++; - return (callCount); - } - -}; - - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/makefile deleted file mode 100644 index 1f6757e44dcf6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: client.exe server.exe - -server.exe: server.cpp common.dll - cl /clr:pure server.cpp - -client.exe: client.cpp common.dll - cl /clr:pure client.cpp - -common.dll: common.cpp - cl /clr:pure /LD common.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/server.cpp deleted file mode 100644 index f4d15c4f152c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpChannel2/CPP/server.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - // - // Specify the properties for the server channel. - System::Collections::IDictionary^ dict = gcnew System::Collections::Hashtable; - dict[ "port" ] = 9090; - dict[ "authenticationMode" ] = "IdentifyCallers"; - - // Set up the server channel. - TcpChannel^ serverChannel = gcnew TcpChannel( dict,nullptr,nullptr ); - ChannelServices::RegisterChannel( serverChannel ); - // - - // Show the name and priority of the channel. - Console::WriteLine( "The name of the channel is {0}.", serverChannel->ChannelName ); - Console::WriteLine( "The priority of the channel is {0}.", serverChannel->ChannelPriority ); - - // Show the URIs associated with the channel. - ChannelDataStore^ data = dynamic_cast(serverChannel->ChannelData); - for each (String^ uri in data->ChannelUris) - { - Console::WriteLine("The channel URI is {0}.", uri); - } - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( RemoteObject::typeid, "RemoteObject.rem", WellKnownObjectMode::Singleton ); - - // Parse the channel's URI. - array^urls = serverChannel->GetUrlsForUri( "RemoteObject.rem" ); - if ( urls->Length > 0 ) - { - String^ objectUrl = urls[ 0 ]; - String^ objectUri; - String^ channelUri = serverChannel->Parse( objectUrl, objectUri ); - Console::WriteLine( "The object URL is {0}.", objectUrl ); - Console::WriteLine( "The object URI is {0}.", objectUri ); - Console::WriteLine( "The channel URI is {0}.", channelUri ); - } - - // Wait for the user prompt. - Console::WriteLine( "Press enter to terminate the server." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/client.cpp deleted file mode 100644 index 83994f5bc7fb3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/client.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// class: System.Runtime.Remoting.Channels.Tcp.TcpClientChannel -// client.cs: -// Ctor(string, IClientChannelSinkProvider) -// CreateMessageSink -// Parse -// -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - - // - // Create the channel. - TcpClientChannel^ clientChannel = gcnew TcpClientChannel( "Client",nullptr ); - - // - // Register the channel. - ChannelServices::RegisterChannel( clientChannel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( RemoteObject::typeid,"tcp://localhost:9090/RemoteObject.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - - // - // Create a message sink. - String^ objectUri; - System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = clientChannel->CreateMessageSink( "tcp://localhost:9090/RemoteObject.rem", nullptr, objectUri ); - Console::WriteLine( "The URI of the message sink is {0}.", objectUri ); - Console::WriteLine( "The type of the message sink is {0}.", messageSink->GetType() ); - - // - // - // Parse the channel's URI. - String^ objectUrl = "tcp://localhost:9090/RemoteObject.rem"; - String^ channelUri = clientChannel->Parse( objectUrl, objectUri ); - Console::WriteLine( "The object URL is {0}.", objectUrl ); - Console::WriteLine( "The object URI is {0}.", objectUri ); - Console::WriteLine( "The channel URI is {0}.", channelUri ); - - // - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( "The client is invoking the remote object." ); - Console::WriteLine( "The remote object has been called {0} times.", service->GetCount() ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/common.cpp deleted file mode 100644 index a84a5d0ff0770..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/common.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::Remoting; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - int callCount; - -public: - RemoteObject() - : callCount( 0 ) - {} - - int GetCount() - { - callCount++; - return (callCount); - } - -}; - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/makefile deleted file mode 100644 index 1f6757e44dcf6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: client.exe server.exe - -server.exe: server.cpp common.dll - cl /clr:pure server.cpp - -client.exe: client.cpp common.dll - cl /clr:pure client.cpp - -common.dll: common.cpp - cl /clr:pure /LD common.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/server.cpp deleted file mode 100644 index 265a1ceabc0ce..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpClientChannel/CPP/server.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - - // Create the server channel. - TcpChannel^ serverChannel = gcnew TcpChannel( 9090 ); - - // Register the server channel. - ChannelServices::RegisterChannel( serverChannel ); - - // Show the name of the channel. - Console::WriteLine( "The name of the channel is {0}.", serverChannel->ChannelName ); - - // Show the priority of the channel. - Console::WriteLine( "The priority of the channel is {0}.", serverChannel->ChannelPriority ); - - // Show the URIs associated with the channel. - ChannelDataStore^ data = dynamic_cast(serverChannel->ChannelData); - System::Collections::IEnumerator^ myEnum = data->ChannelUris->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ uri = safe_cast(myEnum->Current); - Console::WriteLine( "The channel URI is {0}.", uri ); - } - - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( RemoteObject::typeid, "RemoteObject.rem", WellKnownObjectMode::Singleton ); - - // Wait for the user prompt. - Console::WriteLine( "Press enter to terminate the server." ); - Console::ReadLine(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/client.cpp deleted file mode 100644 index 1e675f10b9462..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/client.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -int main() -{ - // Create the channel. - TcpClientChannel^ channel = gcnew TcpClientChannel; - - // Register the channel. - ChannelServices::RegisterChannel( channel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( Remotable::typeid,"tcp://localhost:9090/Remotable.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - - // Create an instance of the remote object. - Remotable^ service = gcnew Remotable; - - // Invoke a method on the remote object. - Console::WriteLine( "The client is invoking the remote object." ); - Console::WriteLine( "The remote object has been called {0} times.", service->GetCount() ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/common.cpp deleted file mode 100644 index 48eb499c2abd1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/common.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -using namespace System; -using namespace System::Runtime::Remoting; - -// Remote object. -public ref class Remotable: public MarshalByRefObject -{ -private: - int callCount; - -public: - Remotable() - : callCount( 0 ) - {} - - int GetCount() - { - callCount++; - return (callCount); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/makefile deleted file mode 100644 index 1f6757e44dcf6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: client.exe server.exe - -server.exe: server.cpp common.dll - cl /clr:pure server.cpp - -client.exe: client.cpp common.dll - cl /clr:pure client.cpp - -common.dll: common.cpp - cl /clr:pure /LD common.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/server.cpp deleted file mode 100644 index 3f6748f6f9690..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.2/CPP/server.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -/// Snippets needed: -/// 21 Ctor(string, int) -#using -#using -#using "common.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; -int main() -{ - // - // Create the server channel. - TcpServerChannel^ channel = gcnew TcpServerChannel( "Server Channel",9090 ); - - // - // Register the server channel. - ChannelServices::RegisterChannel( channel ); - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( Remotable::typeid, "Remotable.rem", WellKnownObjectMode::Singleton ); - - // Display the channel's URI. - Console::WriteLine( "The channel URI is {0}.", channel->GetChannelUri() ); - - // Parse the channel's URI. - array^urls = channel->GetUrlsForUri( "Remotable.rem" ); - if ( urls->Length > 0 ) - { - String^ objectUrl = urls[ 0 ]; - String^ objectUri; - String^ channelUri = channel->Parse( objectUrl, objectUri ); - Console::WriteLine( "The object URI is {0}.", objectUri ); - Console::WriteLine( "The channel URI is {0}.", channelUri ); - Console::WriteLine( "The object URL is {0}.", objectUrl ); - } - - // Wait for the user prompt. - Console::WriteLine( "Press enter to terminate the server." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/client.cpp deleted file mode 100644 index 010cf8b521a31..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/client.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -void main() -{ - // Create the channel. - TcpClientChannel^ channel = gcnew TcpClientChannel; - - // Register the channel. - ChannelServices::RegisterChannel( channel ); - - // Register as client for remote object. - WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( - RemoteObject::typeid,L"tcp://localhost:9090/RemoteObject.rem" ); - RemotingConfiguration::RegisterWellKnownClientType( remoteType ); - - // Create an instance of the remote object. - RemoteObject^ service = gcnew RemoteObject; - - // Invoke a method on the remote object. - Console::WriteLine( L"The client is invoking the remote object." ); - Console::WriteLine( L"The remote object has been called {0} times.", - service->GetCount() ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/common.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/common.cpp deleted file mode 100644 index 89de31f37b950..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/common.cpp +++ /dev/null @@ -1,17 +0,0 @@ -using namespace System; -using namespace System::Runtime::Remoting; - -// Remote object. -public ref class RemoteObject: public MarshalByRefObject -{ -private: - static int callCount = 0; - -public: - int GetCount() - { - callCount++; - return (callCount); - } - -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/makefile deleted file mode 100644 index 620d747fa8219..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/makefile +++ /dev/null @@ -1,12 +0,0 @@ -all : server.exe client.exe - - -server.exe : server.cpp common.dll - cl /clr:pure server.cpp - -client.exe : client.cpp common.dll - cl /clr:pure client.cpp - -common.dll : common.cpp - cl /clr:pure /LD common.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/server.cpp deleted file mode 100644 index f7e0ccdcfef49..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Channels.Tcp.TcpServerChannel/CPP/server.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/// Class: System.Runtime.Remoting.Channels.Tcp.TcpServerChannel -/// 21 Ctor(string, int, IServerChannelSinkProvider) -/// 22 GetChannelUri(); -/// 23 Parse(); -/// ! Ctor(string, int) -#using -#using -#using "common.dll" -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Tcp; - -void main() -{ - // - // Create the server channel. - TcpServerChannel^ channel = gcnew TcpServerChannel( - L"Server Channel",9090,nullptr ); - // - - // Register the server channel. - ChannelServices::RegisterChannel( channel ); - - // Expose an object for remote calls. - RemotingConfiguration::RegisterWellKnownServiceType( - RemoteObject::typeid, L"RemoteObject.rem", - WellKnownObjectMode::Singleton ); - - // - // Display the channel's URI. - Console::WriteLine( L"The channel URI is {0}.", - channel->GetChannelUri() ); - // - - // - // Parse the channel's URI. - array^urls = channel->GetUrlsForUri( L"RemoteObject.rem" ); - if ( urls->Length > 0 ) - { - String^ objectUrl = urls[ 0 ]; - String^ objectUri; - String^ channelUri = channel->Parse( objectUrl, objectUri ); - Console::WriteLine( L"The object URI is {0}.", objectUri ); - Console::WriteLine( L"The channel URI is {0}.", channelUri ); - Console::WriteLine( L"The object URL is {0}.", objectUrl ); - } - // - - // Wait for the user prompt. - Console::WriteLine( L"Press ENTER to exit the server." ); - Console::ReadLine(); - Console::WriteLine( L"The server is exiting." ); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/client.cpp deleted file mode 100644 index e3b283e04255f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/client.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -public ref class MyClientSponsor: public MarshalByRefObject, public ISponsor -{ -private: - DateTime lastRenewal; - -public: - MyClientSponsor() - { - Console::WriteLine( "Activating client..." ); - lastRenewal = DateTime::Now; - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual TimeSpan Renewal( ILease^ lease ) - { - Console::WriteLine( "Renewing a lease for 4 seconds." ); - Console::WriteLine( "Time since last renewal: {0}", (DateTime::Now - lastRenewal) ); - lastRenewal = DateTime::Now; - return TimeSpan::FromSeconds( 4 ); - } -}; - -int main() -{ - ChannelServices::RegisterChannel( gcnew HttpChannel( 0 ) ); - RemotingConfiguration::RegisterActivatedClientType( ClientActivatedType::typeid, "http://localhost:8080" ); - ClientActivatedType ^ CAObject = gcnew ClientActivatedType; - ILease^ serverLease = dynamic_cast(RemotingServices::GetLifetimeService( CAObject )); - MyClientSponsor^ sponsor = gcnew MyClientSponsor; - serverLease->Register( sponsor ); - - // Call same method on the Object* - Console::WriteLine( "Client-activated Object*: {0}", CAObject->RemoteMethod( "Bob" ) ); - Console::WriteLine( "Press Enter to end the client application domain." ); - Console::ReadLine(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/makefile deleted file mode 100644 index 3091512feda81..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: client.exe server.exe - -server.exe: server.cpp service.dll - cl /clr:pure server.cpp - -client.exe: client.cpp service.dll - cl /clr:pure client.cpp - -service.dll: service.cpp - cl /clr:pure /LD service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/server.cpp deleted file mode 100644 index 4c0cf07dc06ac..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/server.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Runtime::Remoting::Lifetime; - -int main() -{ - LifetimeServices::LeaseTime = TimeSpan::FromSeconds( 5 ); - LifetimeServices::LeaseManagerPollTime = TimeSpan::FromSeconds( 3 ); - LifetimeServices::RenewOnCallTime = TimeSpan::FromSeconds( 2 ); - LifetimeServices::SponsorshipTimeout = TimeSpan::FromSeconds( 1 ); - ChannelServices::RegisterChannel( gcnew HttpChannel( 8080 ) ); - RemotingConfiguration::RegisterActivatedServiceType( ClientActivatedType::typeid ); - Console::WriteLine( "The server is listening. Press Enter to exit...." ); - Console::ReadLine(); - Console::WriteLine( "GC'ing." ); - GC::Collect(); - GC::WaitForPendingFinalizers(); - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/service.cpp deleted file mode 100644 index d62c5857225bd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Lifetime/CPP/service.cpp +++ /dev/null @@ -1,191 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting::Lifetime; - -public ref class MyLease: public MarshalByRefObject, public ILease -{ -private: - ILease^ baseLease; - -public: - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - MyLease( ILease^ oldLease ) - { - Console::WriteLine( "Constructing MyLease." ); - if ( oldLease == nullptr ) - Console::WriteLine( "CRUD!" ); - - baseLease = oldLease; - } - - - property TimeSpan CurrentLeaseTime - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual TimeSpan get() - { - TimeSpan time = baseLease->CurrentLeaseTime; - Console::WriteLine( "The CurrentLeaseTime property returned {0}.", time.Milliseconds ); - return time; - } - - } - - property LeaseState CurrentState - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual LeaseState get() - { - LeaseState state = baseLease->CurrentState; - Console::WriteLine( "The CurrentState property returned {0}.", state ); - return state; - } - - } - - - property TimeSpan InitialLeaseTime - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual TimeSpan get() - { - TimeSpan time = baseLease->InitialLeaseTime; - Console::WriteLine( "The InitialLeaseTime property returned {0}.", time.Milliseconds ); - return time; - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void set( TimeSpan value ) - { - baseLease->InitialLeaseTime = value; - Console::WriteLine( "The InitialLeaseTime property was set to {0}.", value.Milliseconds ); - } - - } - - property TimeSpan RenewOnCallTime - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual TimeSpan get() - { - TimeSpan time = baseLease->RenewOnCallTime; - Console::WriteLine( "The RenewOnCallTime property returned {0}.", time.Milliseconds ); - return time; - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void set( TimeSpan value ) - { - Console::WriteLine( "The RenewOnCallTime property was set to {0}.", value.Milliseconds ); - baseLease->RenewOnCallTime = value; - } - - } - - property TimeSpan SponsorshipTimeout - { - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual TimeSpan get() - { - TimeSpan time = baseLease->SponsorshipTimeout; - Console::WriteLine( "The SponsorshipTimeout property returned {0}.", time.Milliseconds ); - return time; - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void set( TimeSpan value ) - { - Console::WriteLine( "The SponsorshipTimeout property was set to {0}.", value.Milliseconds ); - baseLease->SponsorshipTimeout = value; - } - - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void Register( ISponsor^ sponsor ) - { - Console::WriteLine( "The sponsor {0} has been registered with the current lease.", sponsor ); - baseLease->Register( sponsor ); - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void Register( ISponsor^ sponsor, TimeSpan renewalTime ) - { - Console::WriteLine( "The sponsor {0} has been registered with the current lease for {0} milliseconds...", sponsor, renewalTime.Milliseconds ); - baseLease->Register( sponsor, renewalTime ); - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual TimeSpan Renew( TimeSpan renewalTime ) - { - Console::WriteLine( "The lease has been renewed for {0} milliseconds...", renewalTime.Milliseconds ); - return baseLease->Renew( renewalTime ); - } - - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual void Unregister( ISponsor^ sponsor ) - { - Console::WriteLine( "The sponsor {0} has been unregistered from the current lease.", sponsor ); - baseLease->Unregister( sponsor ); - } - -}; - - -public ref class ClientActivatedType: public MarshalByRefObject -{ -public: - - // the lease settings for this Object* - [System::Security::Permissions::SecurityPermissionAttribute - (System::Security::Permissions::SecurityAction::LinkDemand, - Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] - virtual Object^ InitializeLifetimeService() override - { - ILease^ lease = gcnew MyLease( dynamic_cast(MarshalByRefObject::InitializeLifetimeService()) ); - return lease; - } - - String^ RemoteMethod( String^ name ) - { - - // announce to the server that we've been called. - Console::WriteLine( "ClientActivatedType::RemoteMethod called by {0}", name ); - - // report our client identity name - return String::Format( "Hello, {0}!", name ); - } - -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.SoapMethodAttribute/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.SoapMethodAttribute/CPP/demo.cpp deleted file mode 100644 index f1a1fd691e985..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.SoapMethodAttribute/CPP/demo.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.SoapMethodAttribute -/// 100 class -/// 110 ResponseXmlElementName -/// 110 ResponseXmlNamespace -/// 110 ReturnXmlElementName -/// 110 SoapAction -/// 110 XmlNamespace -/// ! #ctor cannot be snippeted because attribute is not constructed -/// using new, but rather implicitly constructed through an attribute -/// tag. -/// -/// ! UseAttribute cannot be snippeted because exception is thrown. -// -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata; - -namespace ExampleNamespace -{ - public ref class ExampleClass - { - public: - // - [SoapMethod( - ResponseXmlElementName="ExampleResponseElement", - ResponseXmlNamespace= - "http://example.org/MethodResponseXmlNamespace", - ReturnXmlElementName="HelloMessage", - SoapAction="http://example.org/ExampleSoapAction#GetHello", - XmlNamespace="http://example.org/MethodCallXmlNamespace")] - String^ GetHello( String^ name ) - { - return String::Format( L"Hello, {0}", name ); - } - // - }; - -} - -int main() -{ - - // Get the method info object for the GetHello method. - System::Reflection::MethodBase^ getHelloMethod = - ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" ); - - // Print the XML namespace for the invocation of this method. - String^ methodCallXmlNamespace = - System::Runtime::Remoting::SoapServices::GetXmlNamespaceForMethodCall( - getHelloMethod ); - Console::WriteLine( L"The XML namespace for the response of the method " - L"GetHello in ExampleClass is {0}.", methodCallXmlNamespace ); - - // Print the XML namespace for the response of this method. - String^ methodResponseXmlNamespace = - System::Runtime::Remoting::SoapServices::GetXmlNamespaceForMethodCall( - getHelloMethod ); - Console::WriteLine( L"The XML namespace for the invocation of the method " - L"GetHello in ExampleClass is {0}.", methodResponseXmlNamespace ); - - // Print the SOAP action for this method. - String^ getHelloSoapAction = - System::Runtime::Remoting::SoapServices::GetXmlNamespaceForMethodCall( - getHelloMethod ); - Console::WriteLine( L"The SOAP action for the method " - L"GetHello in ExampleClass is {0}.", getHelloSoapAction ); -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri/CPP/demo.cpp deleted file mode 100644 index 58dea74626683..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri/CPP/demo.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri -/// 10 class -/// 21 #ctor() -/// 22 #ctor(string) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// -/// Bugs in SoapAnyUri: None found. -// -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapAnyUri object. - String^ xsdAnyUri = L"http://localhost:8080/WebService"; - SoapAnyUri^ anyUri = SoapAnyUri::Parse( xsdAnyUri ); - // - - // - // Print the value of the SoapAnyUri object in XSD format. - Console::WriteLine( L"The SoapAnyUri object in XSD format is {0}.", anyUri ); - // - - // - // Print the XSD type string of the SoapAnyUri object. - Console::WriteLine( L"The XSD type of the SoapAnyUri " - L"object is {0}.", anyUri->GetXsdType() ); - // - - // - // Print the value of the SoapAnyUri object. - Console::WriteLine( L"The value of the SoapAnyUri object is {0}.", anyUri->Value ); - - // - // - // Print the XSD type string of the SoapAnyUri class. - Console::WriteLine( L"The XSD type of the SoapAnyUri class " - L"is {0}.", SoapAnyUri::XsdType ); - // - - return 1; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri/CPP/demo2.cpp deleted file mode 100644 index c8ca68e2b1e78..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri/CPP/demo2.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(string) -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapAnyUri object. - SoapAnyUri^ anyUri = gcnew SoapAnyUri; - anyUri->Value = L"http://localhost:8080/WebService"; - Console::WriteLine( L"The value of the SoapAnyUri object is {0}.", anyUri ); - // -} - -static void Ctor2() -{ - // - // Create a SoapAnyUri object. - String^ anyUriValue = L"http://localhost:8080/WebService"; - SoapAnyUri^ anyUri = gcnew SoapAnyUri( anyUriValue ); - Console::WriteLine( L"The value of the SoapAnyUri object is {0}.", anyUri ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary/CPP/demo.cpp deleted file mode 100644 index e73224d01e0bd..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary/CPP/demo.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary -/// 10 class -/// 21 #ctor() -/// 22 #ctor(byte[]) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapBase64Binary: -/// No bugs were detected. -// -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapBase64Binary object. - // The string "AgMFBws=" is byte[]{ 2, 3, 5, 7, 11 } expressed in - // Base 64 format. - String^ xsdBase64Binary = L"AgMFBws="; - SoapBase64Binary^ base64Binary = SoapBase64Binary::Parse( xsdBase64Binary ); - // - - // - // Print the value of the SoapBase64Binary object in XSD format. - Console::WriteLine( L"The SoapBase64Binary object in XSD format is {0}.", - base64Binary ); - // - - // - // Print the XSD type string of the SoapBase64Binary object. - Console::WriteLine( L"The XSD type of the SoapBase64Binary " - L"object is {0}.", base64Binary->GetXsdType() ); - // - - // - // Print the value of the SoapBase64Binary object. - Console::Write( L"base64Binary.Value contains:" ); - for ( int i = 0; i < base64Binary->Value->Length; ++i ) - { - Console::Write( L" {0}", base64Binary->Value[ i ] ); - - } - Console::WriteLine(); - // - - // - // Print the XSD type string of the SoapBase64Binary class. - Console::WriteLine( L"The XSD type of the class SoapBase64Binary " - L"is {0}.", SoapBase64Binary::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary/CPP/demo2.cpp deleted file mode 100644 index 296902a8a0e8d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary/CPP/demo2.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapBase64Binary object. - SoapBase64Binary^ base64Binary = gcnew SoapBase64Binary; - base64Binary->Value = gcnew array(7){ - 2,3,5,7,11,0,5 - }; - Console::WriteLine( L"The SoapBase64Binary object is {0}.", - base64Binary ); - // -} - -static void Ctor2() -{ - // - // Create a SoapBase64Binary object. - array^bytes = gcnew array(5){ - 2,3,5,7,11 - }; - SoapBase64Binary^ base64Binary = gcnew SoapBase64Binary( bytes ); - Console::WriteLine( L"The SoapBase64Binary object is {0}.", - base64Binary ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDate/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDate/CPP/demo.cpp deleted file mode 100644 index 7f234a9eb5ac3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDate/CPP/demo.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/// Need snippets: -/// 10 class -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 23 #ctor(DateTime,int) -/// 13 GetXsdType -/// 11 Parse -/// 15 Sign -/// 12 ToString -/// 14 Value -/// 16 XsdType - -// -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD date to create a SoapDate object. - String^ xsdDate = "2003-02-04"; - SoapDate^ date = SoapDate::Parse( xsdDate ); - // - - // - // Serialize a DateTime object as an XSD date string. - Console::WriteLine( "The date in XSD format is {0}.", - date ); - // - - // - // Print out the XSD type string of this particular SoapDate object. - Console::WriteLine( "The XSD type of the SoapDate instance is {0}.", - date->GetXsdType() ); - // - - // - // Print out the value of the SoapDate object. - Console::WriteLine( "The value of the SoapDate instance is {0}.", - date->Value ); - // - - // - // Print out the sign of the SoapDate object. - Console::WriteLine( "The sign of the SoapDate instance is {0}.", - date->Sign ); - // - - // - // Print out the XSD type string of the SoapDate class. - Console::WriteLine( "The XSD type of SoapDate is {0}.", - SoapDate::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDate/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDate/CPP/demo2.cpp deleted file mode 100644 index 668a507b945fa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDate/CPP/demo2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 23 #ctor(DateTime,int) - -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -void Ctor1() -{ - // - // Create a SoapDate object. - SoapDate^ date = gcnew SoapDate; - date->Value = DateTime::Now; - Console::WriteLine( "The date is {0}.", date ); - // -} - -void Ctor2() -{ - // - // Create a SoapDate object. - SoapDate^ date = gcnew SoapDate( DateTime::Now ); - Console::WriteLine( "The date is {0}.", date ); - // -} - -void Ctor3() -{ - // - // Create a SoapDate object with a positive sign. - SoapDate^ date = gcnew SoapDate( DateTime::Now,1 ); - Console::WriteLine( "The date is {0}.", date ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); - Ctor3(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDateTime/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDateTime/CPP/demo.cpp deleted file mode 100644 index 413b5d7bcba3b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDateTime/CPP/demo.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -/// Need snippets: -/// ! #ctor -/// x Parse -/// x ToString -/// x XsdType -/// -/// Bug report: -/// Constructor unusable since all methods are static. -// -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; -int main() -{ - - // - // Parse an XSD dateTime to create a DateTime object. - String^ xsdDateTime = "2003-02-04T13:58:59.9999999+03:00"; - DateTime dateTime = SoapDateTime::Parse( xsdDateTime ); - - // - // - // Serialize a DateTime object as an XSD dateTime string. - Console::WriteLine( "The date in XSD format is {0}.", SoapDateTime::ToString( dateTime ) ); - - // - // - // Print out the XSD type string of the SoapDateTime class. - Console::WriteLine( "The XSD type of SoapDateTime is {0}.", SoapDateTime::XsdType ); - - // -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay/CPP/demo.cpp deleted file mode 100644 index 176bd8d588a57..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay/CPP/demo.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay -/// Need snippets: -/// 10 class -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// -/// Bugs: -/// -/// 1. Documentation bug: according to the XML spec and the code -/// SoapDay.Parse(string) should accept the format "---ddzzz" and -/// "---dd"; the documentation states that SoapDay.Parse(string) -/// accepts "ddzzz" (which it does not). For gDay examples, see -/// http://books.xmlschemata.org/relaxng/ch17-77066.html. -/// 2. Documentation bug: zzz cannot be in this format "08:00". It -/// must equal "Z" or it must be in one of these formats: "+08:00" -/// or "-08:00". Without the leading "+" or "-" sign Parse(string) -/// fails. - -// -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD gDay to create a SoapDay object. - // The time zone of this object is +08:00. - String^ xsdDay = "---30+08:00"; - SoapDay^ day = SoapDay::Parse( xsdDay ); - // - - // - // Display the day in XSD format. - Console::WriteLine( "The day in XSD format is {0}.", - day ); - // - - // - // Display the XSD type string of this particular SoapDay object. - Console::WriteLine( "The XSD type of the SoapDay instance is {0}.", - day->GetXsdType() ); - // - - // - // Display the value of the SoapDay object. - Console::WriteLine( "The value of the SoapDay instance is {0}.", - day->Value ); - // - - // - // Display the XSD type string of the SoapDay class. - Console::WriteLine( "The XSD type of the class SoapDay is {0}.", - SoapDay::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay/CPP/demo2.cpp deleted file mode 100644 index e070d48be1075..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay/CPP/demo2.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) - -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -void Ctor1() -{ - // - // Create a SoapDay object. - SoapDay^ day = gcnew SoapDay; - day->Value = DateTime::Now; - Console::WriteLine( "The day is {0}.", day ); - // -} - -void Ctor2() -{ - // - // Create a SoapDay object. - SoapDay^ day = gcnew SoapDay( DateTime::Now ); - Console::WriteLine( "The day is {0}.", day ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDuration/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDuration/CPP/demo.cpp deleted file mode 100644 index cb673df07d3df..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDuration/CPP/demo.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDuration -/// 10 class -/// ! #ctor -/// 11 Parse() -/// 12 ToString() -/// 13 XsdType -/// -/// Bug report: -/// The constructor is unusable since all methods are static. -// -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD duration to create a TimeSpan object. - // This is a duration of 2 years, 3 months, 9 days, 12 hours, - // 35 minutes, 20 seconds, and 10 milliseconds. - String^ xsdDuration = L"P2Y3M9DT12H35M20.0100000S"; - TimeSpan timeSpan = SoapDuration::Parse( xsdDuration ); - Console::WriteLine( L"The time span contains {0} days.", - timeSpan.Days ); - Console::WriteLine( L"The time span contains {0} hours.", - timeSpan.Hours ); - Console::WriteLine( L"The time span contains {0} minutes.", - timeSpan.Minutes ); - Console::WriteLine( L"The time span contains {0} seconds.", - timeSpan.Seconds ); - // - - // - // Serialize a TimeSpan object as an XSD duration string. - // This object represents a time span of 399 days, 12 hours, - // 35 minutes, 20 seconds, and 10 milliseconds. - TimeSpan duration = TimeSpan(399,12,35,20,10); - Console::WriteLine( L"The duration in XSD format is {0}.", - SoapDuration::ToString( duration ) ); - // - - // - // Print the XSD type string of the SoapDuration class. - Console::WriteLine( L"The XSD type of SoapDuration is {0}.", - SoapDuration::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary/CPP/demo.cpp deleted file mode 100644 index f07c6ddafe81d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary/CPP/demo.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary -/// 10 class -/// 21 #ctor() -/// 22 #ctor(byte[]) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapHexBinary: -/// No bugs were detected. -// -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapHexBinary object. - String^ xsdHexBinary = L"3f789ABC"; - SoapHexBinary^ hexBinary = SoapHexBinary::Parse( xsdHexBinary ); - // - - // - // Print the value of the SoapHexBinary object in XSD format. - Console::WriteLine( L"The SoapHexBinary object in XSD format is {0}.", - hexBinary ); - // - - // - // Print the XSD type string of this particular SoapHexBinary object. - Console::WriteLine( L"The XSD type of the SoapHexBinary object is {0}.", - hexBinary->GetXsdType() ); - // - - // - // Print the value of the SoapHexBinary object. - Console::Write( L"hexBinary.Value contains:" ); - for ( int i = 0; i < hexBinary->Value->Length; ++i ) - { - Console::Write( L" {0}", hexBinary->Value[ i ] ); - - } - Console::WriteLine(); - // - - // - // Print the XSD type string of the SoapHexBinary class. - Console::WriteLine( L"The XSD type of the class SoapHexBinary is {0}.", - SoapHexBinary::XsdType ); - // -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary/CPP/demo2.cpp deleted file mode 100644 index dc7d28b8f1a34..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary/CPP/demo2.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapHexBinary object. - SoapHexBinary^ hexBinary = gcnew SoapHexBinary; - hexBinary->Value = gcnew array(5){ - 2,3,5,7,11 - }; - Console::WriteLine( L"The SoapHexBinary object is {0}.", hexBinary ); - // -} - -static void Ctor2() -{ - // - // Create a SoapHexBinary object. - array^ bytes = gcnew array(5){ - 2,3,5,7,11 - }; - SoapHexBinary^ hexBinary = gcnew SoapHexBinary( bytes ); - Console::WriteLine( L"The SoapHexBinary object is {0}.", hexBinary ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger/CPP/demo.cpp deleted file mode 100644 index fb6f8987512f3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger/CPP/demo.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger -/// 10 class -/// 21 #ctor() -/// 22 #ctor(decimal) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapInteger: -/// No bugs were detected. -// -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapInteger object. - String^ xsdIntegerString = L"-13"; - SoapInteger^ xsdInteger = SoapInteger::Parse( xsdIntegerString ); - // - - // - // Print the value of the SoapInteger object in XSD format. - Console::WriteLine( L"The SoapInteger object in XSD format is {0}.", - xsdInteger ); - // - - // - // Print the XSD type string of the SoapInteger object. - Console::WriteLine( L"The XSD type of the SoapInteger " - L"object is {0}.", xsdInteger->GetXsdType() ); - // - - // - // Print the value of the SoapInteger object. - Console::WriteLine( L"The value of the SoapInteger object is {0}.", - xsdInteger->Value ); - // - - // - // Print the XSD type string of the SoapInteger class. - Console::WriteLine( L"The XSD type of the SoapInteger class is {0}.", - SoapInteger::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger/CPP/demo2.cpp deleted file mode 100644 index 1ce5d78cc1e4c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger/CPP/demo2.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapInteger object. - SoapInteger^ xsdInteger = gcnew SoapInteger; - xsdInteger->Value = -14; - Console::WriteLine( L"The value of the SoapInteger object is {0}.", - xsdInteger ); - // -} - -static void Ctor2() -{ - // - // Create a SoapInteger object. - Decimal decimalValue = -14; - SoapInteger^ xsdInteger = gcnew SoapInteger( decimalValue ); - Console::WriteLine( L"The value of the SoapInteger object is {0}.", - xsdInteger ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth/CPP/demo.cpp deleted file mode 100644 index 93620f32b0bd0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth/CPP/demo.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth -/// 10 class -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// -/// Bugs in SoapMonth: -/// -/// 1. SoapMonth.Parse interprets timezone inconsistently: The -/// following both reduce the month by 1. Either they should not -/// alter the month. Or the first one should reduce but the second -/// one should not: -/// SoapMonth.Parse("--02--+08:00").ToString() // Prints "--01--". -/// SoapMonth.Parse("--02---07:00").ToString() // Prints "--01--". -/// -/// 2. SoapMonth.Parse throws exception when the timezone is "Z": -/// SoapMonth.Parse throws the following exception, -/// System.FormatException: String was not recognized as a valid DateTime. -/// when invoked as follows, -/// SoapMonth.Parse("--02--Z"); // Throws exception. -/// It fails to correctly interpret Z as the current timezone. -/// -/// 3. SoapMonth.Parse documentation incorrect: The documentation -/// states that Parse can accept months formatted as "05", "01". -/// This is incorrect. The acceptable formats (according to the code -/// and according to the XML spec) are: "--MM--" and "--MM--zzz". - -// -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD gMonth to create a SoapMonth object. - // The timezone of this object is +08:00. - String^ xsdMonth = "--02--+08:00"; - SoapMonth^ month = SoapMonth::Parse( xsdMonth ); - // - - // - // Print the month in XSD format. - Console::WriteLine( "The month in XSD format is {0}.", - month ); - // - - // - // Print the XSD type string of this particular SoapMonth object. - Console::WriteLine( "The XSD type of the SoapMonth instance is {0}.", - month->GetXsdType() ); - // - - // - // Print the value of the SoapMonth object. - Console::WriteLine( "The value of the SoapMonth instance is {0}.", - month->Value ); - // - - // - // Print the XSD type string of the SoapMonth class. - Console::WriteLine( "The XSD type of the class SoapMonth is {0}.", - SoapMonth::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth/CPP/demo2.cpp deleted file mode 100644 index b8fcf45cfc378..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth/CPP/demo2.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) - -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -void Ctor1() -{ - // - // Create a SoapMonth object. - SoapMonth^ month = gcnew SoapMonth; - month->Value = DateTime::Now; - Console::WriteLine( "The month is {0}.", month ); - // -} - -void Ctor2() -{ - // - // Create a SoapMonth object. - SoapMonth^ month = gcnew SoapMonth( DateTime::Now ); - Console::WriteLine( "The month is {0}.", month ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay/CPP/demo.cpp deleted file mode 100644 index cef26ec71c249..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay/CPP/demo.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay -/// 10 class -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapMonthDay: -/// 1. SoapMonthDay.Parse throws exception when the time zone is "Z": -/// SoapMonthDay.Parse throws the following exception, -/// System.FormatException: String was not recognized -/// as a valid DateTime. -/// when invoked as follows, -/// SoapMonthDay.Parse("--02--Z"); // Throws exception. -/// It fails to correctly interpret "Z" as the current time zone. -/// -/// 2. SoapMonthDay.Parse documentation incorrect: The documentation -/// does not state how to compose a SoapMonthDay for Parse. It also -/// incorrectly states that "08:00" is a valid time zone (this should -/// be "+08:00"). -// -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD gMonthDay to create a SoapMonthDay object. - // Parse the representation for February 21, in the UTC+8 time zone. - String^ xsdMonthDay = L"--02-21+08:00"; - SoapMonthDay^ monthDay = SoapMonthDay::Parse( xsdMonthDay ); - // - - // - // Print the monthDay in XSD format. - Console::WriteLine( L"The SoapMonthDay object in XSD format is {0}.", - monthDay ); - // - - // - // Print the XSD type string of this particular SoapMonthDay object. - Console::WriteLine( L"The XSD type of the SoapMonthDay object is {0}.", - monthDay->GetXsdType() ); - // - - // - // Print the value of the SoapMonthDay object. - Console::WriteLine( L"The value of the SoapMonthDay object is {0}.", - monthDay->Value ); - // - - // - // Print the XSD type string of the SoapMonthDay class. - Console::WriteLine( L"The XSD type of the class SoapMonthDay is {0}.", - SoapMonthDay::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay/CPP/demo2.cpp deleted file mode 100644 index f0109194443c6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay/CPP/demo2.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapMonthDay object. - SoapMonthDay^ monthDay = gcnew SoapMonthDay; - monthDay->Value = DateTime::Now; - Console::WriteLine( L"The SoapMonthDay object is {0}.", monthDay ); - // -} - -static void Ctor2() -{ - // - // Create a SoapMonthDay object. - SoapMonthDay^ monthDay = gcnew SoapMonthDay( DateTime::Now ); - Console::WriteLine( L"The SoapMonthDay object is {0}.", monthDay ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger/CPP/demo.cpp deleted file mode 100644 index 3dd233fe9fd65..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger/CPP/demo.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger -/// 10 class -/// 21 #ctor() -/// 22 #ctor(Decimal) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapNegativeInteger: -/// No bugs were detected. -// -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapNegativeInteger - // object. - String^ xsdIntegerString = L"-13"; - SoapNegativeInteger^ xsdInteger = SoapNegativeInteger::Parse( - xsdIntegerString ); - // - - // - // Print the value of the SoapNegativeInteger object in XSD format. - Console::WriteLine( L"The SoapNegativeInteger object in XSD format is {0}.", - xsdInteger ); - // - - // - // Print the XSD type string of the SoapNegativeInteger object. - Console::WriteLine( L"The XSD type of the SoapNegativeInteger " - L"object is {0}.", xsdInteger->GetXsdType() ); - // - - // - // Print the value of the SoapNegativeInteger object. - Console::WriteLine( L"The value of the SoapNegativeInteger " - L"object is {0}.", xsdInteger->Value ); - // - - // - // Print the XSD type string of the SoapNegativeInteger class. - Console::WriteLine( L"The XSD type of the SoapNegativeInteger class " - L"is {0}.", SoapNegativeInteger::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger/CPP/demo2.cpp deleted file mode 100644 index bc37451f56c7d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger/CPP/demo2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; -static void Ctor1() -{ - // - // Create a SoapNegativeInteger object. - SoapNegativeInteger^ xsdInteger = gcnew SoapNegativeInteger; - xsdInteger->Value = -14; - Console::WriteLine( L"The value of the SoapNegativeInteger object is {0}.", - xsdInteger ); - // -} - -static void Ctor2() -{ - // - // Create a SoapNegativeInteger object. - Decimal decimalValue = -14; - SoapNegativeInteger^ xsdInteger = gcnew SoapNegativeInteger( - decimalValue ); - Console::WriteLine( L"The value of the SoapNegativeInteger object is {0}.", - xsdInteger ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger/CPP/demo.cpp deleted file mode 100644 index bfe4587163d48..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger/CPP/demo.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger -/// 10 class -/// 21 #ctor() -/// 22 #ctor(Decimal) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapNonNegativeInteger: -/// No bugs were detected. -// -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapNonNegativeInteger - // object. - String^ xsdIntegerString = L"+13"; - SoapNonNegativeInteger^ xsdInteger = SoapNonNegativeInteger::Parse( - xsdIntegerString ); - // - - // - // Print the value of the SoapNonNegativeInteger object - // in XSD format. - Console::WriteLine( - L"The SoapNonNegativeInteger object in XSD format is {0}.", - xsdInteger ); - // - - // - // Print the XSD type string of the SoapNonNegativeInteger object. - Console::WriteLine( L"The XSD type of the SoapNonNegativeInteger " - L"object is {0}.", xsdInteger->GetXsdType() ); - // - - // - // Print the value of the SoapNonNegativeInteger object. - Console::WriteLine( L"The value of the SoapNonNegativeInteger " - L"object is {0}.", xsdInteger->Value ); - // - - // - // Print the XSD type string of the SoapNonNegativeInteger class. - Console::WriteLine( L"The XSD type of the SoapNonNegativeInteger class " - L"is {0}.", SoapNonNegativeInteger::XsdType ); - // -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger/CPP/demo2.cpp deleted file mode 100644 index 073b01560aa9a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger/CPP/demo2.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapNonNegativeInteger object. - SoapNonNegativeInteger^ xsdInteger = gcnew SoapNonNegativeInteger; - xsdInteger->Value = +14; - Console::WriteLine( L"The value of the SoapNonNegativeInteger object is {0}.", xsdInteger ); - // -} - -static void Ctor2() -{ - // - // Create a SoapNonNegativeInteger object. - Decimal decimalValue = +14; - SoapNonNegativeInteger^ xsdInteger = gcnew SoapNonNegativeInteger( decimalValue ); - Console::WriteLine( L"The value of the SoapNonNegativeInteger object is {0}.", xsdInteger ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger/CPP/demo.cpp deleted file mode 100644 index 2c51262dccaa5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger/CPP/demo.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger -/// 10 class -/// 21 #ctor() -/// 22 #ctor(Decimal) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapNonPositiveInteger: -/// No bugs were detected. -// -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapNonPositiveInteger - // object. - String^ xsdIntegerString = L"-13"; - SoapNonPositiveInteger^ xsdInteger = - SoapNonPositiveInteger::Parse( xsdIntegerString ); - // - - // - // Print the value of the SoapNonPositiveInteger object - // in XSD format. - Console::WriteLine( L"The SoapNonPositiveInteger object in XSD format is {0}.", - xsdInteger ); - // - - // - // Print the XSD type string of the SoapNonPositiveInteger object. - Console::WriteLine( L"The XSD type of the SoapNonPositiveInteger object is {0}.", - xsdInteger->GetXsdType() ); - // - - // - // Print the value of the SoapNonPositiveInteger object. - Console::WriteLine( L"The value of the SoapNonPositiveInteger object is {0}.", - xsdInteger->Value ); - // - - // - // Print the XSD type string of the SoapNonPositiveInteger class. - Console::WriteLine( L"The XSD type of the SoapNonPositiveInteger class is {0}.", - SoapNonPositiveInteger::XsdType ); - // -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger/CPP/demo2.cpp deleted file mode 100644 index 1ab5dc805a149..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger/CPP/demo2.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapNonPositiveInteger object. - SoapNonPositiveInteger^ xsdInteger = gcnew SoapNonPositiveInteger; - xsdInteger->Value = -14; - Console::WriteLine( L"The value of the SoapNonPositiveInteger object is {0}.", - xsdInteger ); - // -} - -static void Ctor2() -{ - // - // Create a SoapNonPositiveInteger object. - Decimal decimalValue = -14; - SoapNonPositiveInteger^ xsdInteger = gcnew SoapNonPositiveInteger( - decimalValue ); - Console::WriteLine( L"The value of the SoapNonPositiveInteger object is {0}.", - xsdInteger ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString/CPP/demo.cpp deleted file mode 100644 index 8b481e05ce000..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString/CPP/demo.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString -/// 10 class -/// 21 #ctor() -/// 22 #ctor(string) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -// -/// Bugs in SoapNormalizedString: None found. -/// -// -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void TestParse( String^ testString ) -{ - try - { - // - // Parse the test string. - SoapNormalizedString^ normalized = SoapNormalizedString::Parse( - testString ); - // - - // Report that the parse succeeded if no exception was thrown. - Console::WriteLine( L"Parse succeeded on the string \"{0}\".", - testString ); - - // - // Print the string representation of the object. - Console::WriteLine( L"The normalized value of this string is \"{0}\".", - normalized ); - // - - // - // Print the XSD type of the object. - Console::WriteLine( L"The XSD type of the SoapNormalizedString object is {0}.", - normalized->GetXsdType() ); - // - - // - // Print the value of the SoapNormalizedString object. - Console::WriteLine( L"The value of the SoapNormalizedString object is \"{0}\".", - normalized->Value ); - // - } - catch ( System::Runtime::Remoting::RemotingException^ e ) - { - // Report the details of the exception that was thrown. - Console::WriteLine( L"Parse failed on the string \"{0}\".", - testString ); - Console::WriteLine( e->Message ); - } -} - -int main() -{ - // Create strings to test the Parse method. - String^ stringWithSpaces = L"one two"; - String^ stringWithSpacesAndTabs = L"one two\t"; - String^ stringWithSpacesAndLineFeed = L"one two\n"; - String^ stringWithSpacesAndCarriageReturn = L"one two\r"; - - // Test the Parse method with each string. - TestParse( stringWithSpaces ); - TestParse( stringWithSpacesAndTabs ); - TestParse( stringWithSpacesAndLineFeed ); - TestParse( stringWithSpacesAndCarriageReturn ); - - // - // Print the XSD type string of the SoapNormalizedString class. - Console::WriteLine( L"The XSD type of the SoapNormalizedString class is {0}.", - SoapNormalizedString::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString/CPP/demo2.cpp deleted file mode 100644 index 1641c8861fe05..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString/CPP/demo2.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(string) -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapNormalizedString object. - SoapNormalizedString^ normalized = gcnew SoapNormalizedString; - normalized->Value = L"one two"; - Console::WriteLine( L"The value of the SoapNormalizedString object is {0}.", - normalized ); - // -} - -static void Ctor2() -{ - // - // Create a SoapNormalizedString object. - String^ testString = L"one two"; - SoapNormalizedString^ normalized = gcnew SoapNormalizedString( - testString ); - Console::WriteLine( L"The value of the SoapNormalizedString object is {0}.", - normalized ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger/CPP/demo.cpp deleted file mode 100644 index 38f2440c82706..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger/CPP/demo.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger -/// 10 class -/// 21 #ctor() -/// 22 #ctor(Decimal) -/// 13 GetXsdType() -/// 11 Parse() -/// 12 ToString() -/// 14 Value -/// 16 XsdType -/// Bugs in SoapPositiveInteger: -/// No bugs were detected. -// -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapPositiveInteger - // object. - String^ xsdIntegerString = L"+13"; - SoapPositiveInteger^ xsdInteger = - SoapPositiveInteger::Parse( xsdIntegerString ); - // - - // - // Print the value of the SoapPositiveInteger object in XSD format. - Console::WriteLine( L"The SoapPositiveInteger object in XSD format is {0}.", - xsdInteger ); - // - - // - // Print the XSD type string of the SoapPositiveInteger object. - Console::WriteLine( L"The XSD type of the SoapPositiveInteger " - L"object is {0}.", xsdInteger->GetXsdType() ); - // - - // - // Print the value of the SoapPositiveInteger object. - Console::WriteLine( L"The value of the SoapPositiveInteger object is {0}.", - xsdInteger->Value ); - // - - // - // Print the XSD type string of the SoapPositiveInteger class. - Console::WriteLine( L"The XSD type of the SoapPositiveInteger class " - L"is {0}.", SoapPositiveInteger::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger/CPP/demo2.cpp deleted file mode 100644 index 1992569528ae8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger/CPP/demo2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapPositiveInteger object. - SoapPositiveInteger^ xsdInteger = gcnew SoapPositiveInteger; - xsdInteger->Value = 14; - Console::WriteLine( L"The value of the SoapPositiveInteger object is {0}.", - xsdInteger ); - // -} - -static void Ctor2() -{ - // - // Create a SoapPositiveInteger object. - Decimal decimalValue = 14; - SoapPositiveInteger^ xsdInteger = gcnew SoapPositiveInteger( decimalValue ); - Console::WriteLine( L"The value of the SoapPositiveInteger object is {0}.", - xsdInteger ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName/CPP/demo.cpp deleted file mode 100644 index 4e39d11bf3f5b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName/CPP/demo.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName -/// 10 class -/// 21 #ctor() -/// 22 #ctor(string) -/// 23 #ctor(string,string) -/// 24 #ctor(string,string,string) -/// 13 GetXsdType() -/// 17 Key -/// 18 Name -/// 19 Namespace -/// 11 Parse() -/// 12 ToString() -/// 16 XsdType -/// -/// Bugs in SoapQName: -/// 1. SoapQName.Namespace is not used anywhere. The field exists but has -/// no clear purpose. It cannot be parsed. -/// 2. SoapQName.Name cannot contain a ':', however, this is not validated -/// in the code anywhere. SoapQName.Parse("a:b:c").Name results in "b:c", -/// which is an invalid name. -// -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD formatted string to create a SoapQName object. - String^ xsdQName = L"tns:SomeName"; - SoapQName^ qName = SoapQName::Parse( xsdQName ); - // - - // - // Print the value of the SoapQName object in XSD format. - Console::WriteLine( L"The SoapQName object in XSD format is {0}.", qName ); - // - - // - // Print the XSD type string of the SoapQName object. - Console::WriteLine( L"The XSD type of the SoapQName " - L"object is {0}.", qName->GetXsdType() ); - // - - // - // Print the XSD type string of the SoapQName class. - Console::WriteLine( L"The XSD type of the SoapQName class " - L"is {0}.", SoapQName::XsdType ); - // - - // Create a QName object. - SoapQName^ soapQNameInstance = gcnew SoapQName( - L"tns",L"SomeName",L"http://example.org" ); - - // - // Print the key the SoapQName object. - Console::WriteLine( L"The key of the SoapQName object is {0}.", - soapQNameInstance->Key ); - // - - // - // Print the name of the SoapQName object. - Console::WriteLine( L"The name of the SoapQName " - L"object is {0}.", soapQNameInstance->Name ); - // - - // - // Print the namespace of the SoapQName class. - Console::WriteLine( L"The namespace for this instance of SoapQName is {0}.", - soapQNameInstance->Namespace ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName/CPP/demo2.cpp deleted file mode 100644 index 7c2359708b8cf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName/CPP/demo2.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(string) -/// 23 #ctor(string,string) -/// 24 #ctor(string,string,string) -#using -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -static void Ctor1() -{ - // - // Create a SoapQName object. - SoapQName^ qName = gcnew SoapQName; - Console::WriteLine( - L"The value of the SoapQName object is \"{0}\".", qName ); - // -} - -static void Ctor2() -{ - // - // Create a SoapQName object. - String^ name = L"SomeName"; - SoapQName^ qName = gcnew SoapQName( name ); - Console::WriteLine( - L"The value of the SoapQName object is \"{0}\".", qName ); - // -} - -static void Ctor3() -{ - // - // Create a SoapQName object. - String^ key = L"tns"; - String^ name = L"SomeName"; - SoapQName^ qName = gcnew SoapQName( key,name ); - Console::WriteLine( - L"The value of the SoapQName object is \"{0}\".", qName ); - // -} - -static void Ctor4() -{ - // - // Create a SoapQName object. - String^ key = L"tns"; - String^ name = L"SomeName"; - String^ namespaceValue = L"http://example.org"; - SoapQName^ qName = gcnew SoapQName( - key,name,namespaceValue ); - Console::WriteLine( - L"The value of the SoapQName object is \"{0}\".", qName ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); - Ctor3(); - Ctor4(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime/CPP/demo.cpp deleted file mode 100644 index 1192e22eec0a2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime/CPP/demo.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime -/// Need snippets: -/// 10 class -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 13 GetXsdType -/// 11 Parse -/// 12 ToString -/// 14 Value -/// 16 XsdType -/// -/// Bugs: -/// -/// Parse should take upto 9 digits in fractional seconds, but only -/// accepts up to 7. Also it only parses the first three, and ignores -/// the others (fractional second digits). - -// -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD gTime to create a SoapTime object. - // The timezone of this object is the current timezone. - String^ xsdTime = "12:13:14.123Z"; - SoapTime^ time = SoapTime::Parse( xsdTime ); - // - - // - // Display the time in XSD format. - Console::WriteLine( "The time in XSD format is {0}.", - time ); - // - - // - // Display the XSD type string of this particular SoapTime object. - Console::WriteLine( "The XSD type of the SoapTime instance is {0}.", - time->GetXsdType() ); - // - - // - // Display the value of the SoapTime object. - Console::WriteLine( "The value of the SoapTime instance is {0}.", - time->Value ); - // - - // - // Display the XSD type string of the SoapTime class. - Console::WriteLine( "The XSD type of the class SoapTime is {0}.", - SoapTime::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime/CPP/demo2.cpp deleted file mode 100644 index 315eb68d5654c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime/CPP/demo2.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) - -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -void Ctor1() -{ - // - // Create a SoapTime object. - SoapTime^ time = gcnew SoapTime; - time->Value = DateTime::Now; - Console::WriteLine( "The time is {0}.", time ); - // -} - -void Ctor2() -{ - // - // Create a SoapTime object. - SoapTime^ time = gcnew SoapTime( DateTime::Now ); - Console::WriteLine( "The time is {0}.", time ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear/CPP/demo.cpp deleted file mode 100644 index 0c90607a48622..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear/CPP/demo.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/// Need snippets: -/// 10 class -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 23 #ctor(DateTime,int) -/// 13 GetXsdType -/// 11 Parse -/// 15 Sign -/// 12 ToString -/// 14 Value -/// 16 XsdType - -// -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD date to create a SoapYear object. - String^ xsdDate = "2003"; - SoapYear^ date = SoapYear::Parse( xsdDate ); - // - - // - // Serialize a DateTime object as an XSD date string. - Console::WriteLine( "The date in XSD format is {0}.", - date ); - // - - // - // Print out the XSD type string of this particular SoapYear object. - Console::WriteLine( "The XSD type of the SoapYear instance is {0}.", - date->GetXsdType() ); - // - - // - // Print out the value of the SoapYear object. - Console::WriteLine( "The value of the SoapYear instance is {0}.", - date->Value ); - // - - // - // Print out the sign of the SoapYear object. - Console::WriteLine( "The sign of the SoapYear instance is {0}.", - date->Sign ); - // - - // - // Print out the XSD type string of the SoapYear class. - Console::WriteLine( "The XSD type of SoapYear is {0}.", - SoapYear::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear/CPP/demo2.cpp deleted file mode 100644 index aa3c6d2fbc14d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear/CPP/demo2.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 23 #ctor(DateTime,int) - -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; -void Ctor1() -{ - // - // Create a SoapYear object. - SoapYear^ date = gcnew SoapYear; - date->Value = DateTime::Now; - Console::WriteLine( "The date is {0}.", date ); - // -} - -void Ctor2() -{ - // - // Create a SoapYear object. - SoapYear^ date = gcnew SoapYear( DateTime::Now ); - Console::WriteLine( "The date is {0}.", date ); - // -} - -void Ctor3() -{ - // - // Create a SoapYear object with a positive sign. - SoapYear^ date = gcnew SoapYear( DateTime::Now,1 ); - Console::WriteLine( "The date is {0}.", date ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); - Ctor3(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth/CPP/demo.cpp deleted file mode 100644 index 0479bd8049dc2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth/CPP/demo.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/// Class: System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth -/// Need snippets: -/// 10 class -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 23 #ctor(DateTime,int) -/// 13 GetXsdType -/// 11 Parse -/// 15 Sign -/// 12 ToString -/// 14 Value -/// 16 XsdType - -// -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; - -int main() -{ - // - // Parse an XSD gYearMonth to create a SoapYearMonth object. - // The timezone of this object is -08:00. - String^ xsdYearMonth = "2003-11-08:00"; - SoapYearMonth^ yearMonth = SoapYearMonth::Parse( xsdYearMonth ); - // - - // - // Display the yearMonth in XSD format. - Console::WriteLine( "The yearMonth in XSD format is {0}.", - yearMonth ); - // - - // - // Display the XSD type string of this particular SoapYearMonth object. - Console::WriteLine( "The XSD type of the SoapYearMonth instance is {0}.", - yearMonth->GetXsdType() ); - // - - // - // Display the value of the SoapYearMonth object. - Console::WriteLine( "The value of the SoapYearMonth instance is {0}.", - yearMonth->Value ); - // - - // - // Display the sign of the SoapYearMonth object. - Console::WriteLine( "The sign of the SoapYearMonth instance is {0}.", - yearMonth->Sign ); - // - - // - // Display the XSD type string of the SoapYearMonth class. - Console::WriteLine( "The XSD type of the class SoapYearMonth is {0}.", - SoapYearMonth::XsdType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth/CPP/demo2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth/CPP/demo2.cpp deleted file mode 100644 index 208e3500ca959..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth/CPP/demo2.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/// Need snippets: -/// 21 #ctor() -/// 22 #ctor(DateTime) -/// 23 #ctor(DateTime,int) - -using namespace System; -using namespace System::Runtime::Remoting::Metadata::W3cXsd2001; -void Ctor1() -{ - // - // Create a SoapYearMonth object. - SoapYearMonth^ year = gcnew SoapYearMonth; - year->Value = DateTime::Now; - Console::WriteLine( "The year is {0}.", year ); - // -} - -void Ctor2() -{ - // - // Create a SoapYearMonth object. - SoapYearMonth^ year = gcnew SoapYearMonth( DateTime::Now ); - Console::WriteLine( "The year is {0}.", year ); - // -} - -void Ctor3() -{ - // - // Create a SoapYearMonth object with a positive sign. - SoapYearMonth^ year = gcnew SoapYearMonth( DateTime::Now,1 ); - Console::WriteLine( "The year is {0}.", year ); - // -} - -int main() -{ - Ctor1(); - Ctor2(); - Ctor3(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.RemotingServices/CPP/remotingservicessample.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.RemotingServices/CPP/remotingservicessample.cpp deleted file mode 100644 index 8df0b7dcb4725..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.RemotingServices/CPP/remotingservicessample.cpp +++ /dev/null @@ -1,232 +0,0 @@ - - -// C:\Program Files\Microsoft::NET\FrameworkSDK\Samples\technologies\remoting\advanced\customproxies -// -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Messaging; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Reflection; -// - -// -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Runtime::Remoting::Proxies; -// - -// -using namespace System::Runtime::Remoting::Channels::Http; -using namespace System::Net; -using namespace System::IO; -using namespace System::Security::Permissions; -// - -// -public ref class HelloServer: public MarshalByRefObject -{ -public: - HelloServer() - { - Console::WriteLine( "HelloServer activated." ); - } - - [OneWay] - void SayHelloToServer( String^ name ) - { - Console::WriteLine( "Client invoked SayHelloToServer(\" {0}\").", name ); - } - - // - // IsOneWay: Note the lack of the OneWayAttribute adornment on this method. - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - String^ SayHelloToServerAndWait( String^ name ) - { - Console::WriteLine( "Client invoked SayHelloToServerAndWait(\" {0}\").", name ); - Console::WriteLine( "Client waiting for return? {0}", RemotingServices::IsOneWay( MethodBase::GetCurrentMethod() ) ? (String^)"No" : "Yes" ); - return String::Format( "Hi there, {0}.", name ); - } - // -}; -// - -// -// An instance of ClientApp will call an instance of this class remotely. -public ref class TcpServerApp -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - TcpServerApp() - { - // Register a class over TCP at tcp://localhost:8085/HttpHelloServer. - const String^ myObjectUri = "TcpHelloServer"; - const int myPort = 8085; - TcpChannel^ myTcpChannel = gcnew TcpChannel( myPort ); - ChannelServices::RegisterChannel( myTcpChannel ); - RemotingConfiguration::RegisterWellKnownServiceType( HelloServer::typeid, const_cast(myObjectUri), WellKnownObjectMode::Singleton ); - // - - // - Console::WriteLine( "Server type: {0}", RemotingServices::GetServerTypeForUri( const_cast(myObjectUri) ) ); - // - - // - Console::WriteLine( "Press Enter to stop the demo." ); - Console::ReadLine(); - } - -}; -// - -// -public ref class HttpServerApp -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - HttpServerApp() - { - // Marshal an Object* over HTTP at http://localhost:8090/HttpHelloServer. - const String^ myObjectUri = "HttpHelloServer"; - const int myPort = 8090; - HttpChannel^ myHttpChannel = gcnew HttpChannel( myPort ); - ChannelServices::RegisterChannel( myHttpChannel ); - MarshalByRefObject^ myMbro = dynamic_cast(Activator::CreateInstance( HelloServer::typeid )); - RemotingServices::SetObjectUriForMarshal( myMbro, const_cast(myObjectUri) ); - ObjRef^ myObjRef = RemotingServices::Marshal( myMbro ); - Console::WriteLine( "Press Enter to stop the demo." ); - Console::ReadLine(); - HelloServer^ umObj = dynamic_cast(RemotingServices::Unmarshal( myObjRef )); - RemotingServices::Disconnect( myMbro ); - } -}; -// - -// -// An instance of this class will call an instance of ServerApp remotely. -[SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] -public ref class TcpClientApp -{ -public: - TcpClientApp() - { - const String^ myHelloServerUrl = "tcp://localhost:8085/TcpHelloServer"; - HelloServer^ obj = static_cast(RemotingServices::Connect( HelloServer::typeid, const_cast(myHelloServerUrl) )); - // - - // - //GetRealProxy, GetObjectUri, GetEnvoyChainForProxy - RealProxy^ proxy = RemotingServices::GetRealProxy( obj ); - Console::WriteLine( "Real proxy type: {0}", proxy->GetProxiedType() ); - Console::WriteLine( "Object URI: {0}", RemotingServices::GetObjectUri( obj ) ); - IMessageSink^ msgSink = RemotingServices::GetEnvoyChainForProxy( obj )->NextSink; - // - - // - //IsTransparentProxy, IsObjectOutOfAppDomain, IsObjectOutOfContext - Console::WriteLine( "Proxy transparent? {0}", RemotingServices::IsTransparentProxy( obj ) ? (String^)"Yes" : "No" ); - Console::WriteLine( "Object outside app domain? {0}", RemotingServices::IsObjectOutOfAppDomain( obj ) ? (String^)"Yes" : "No" ); - Console::WriteLine( "Object [Out] of* context? {0}", RemotingServices::IsObjectOutOfContext( obj ) ? (String^)"Yes" : "No" ); - // - - // - //GetLifetimeService - ILease^ lease = dynamic_cast(RemotingServices::GetLifetimeService( obj )); - Console::WriteLine( "Object lease time remaining: {0}.", lease->CurrentLeaseTime ); - // - - // - String^ twoWayMethodArg = "John"; - Console::WriteLine( "Invoking SayHelloToServerAndWait(\" {0}\").", twoWayMethodArg ); - Console::WriteLine( "Server returned: {0}", obj->SayHelloToServerAndWait( twoWayMethodArg ) ); - // - - // - String^ oneWayMethodArg = "Mary"; - Console::WriteLine( "Invoking SayHelloToServer(\" {0}\").", oneWayMethodArg ); - obj->SayHelloToServer( oneWayMethodArg ); - // - - // - } - // - - // -}; -// - -// -public ref class HttpClientApp -{ -public: - HttpClientApp() - { - const String^ myHelloServerUrl = "http://localhost:8090/HttpHelloServer"; - - // Output the WSDL for the marshalled Object*. - WebClient^ myWebClient = gcnew WebClient; - Stream^ myStream = myWebClient->OpenRead( String::Format( "{0}?wsdl", const_cast(myHelloServerUrl) ) ); - int b = myStream->ReadByte(); - while ( b != -1 ) - { - char p[2] = {(char)b}; - Console::Write( p ); - b = myStream->ReadByte(); - } - } - -}; -// - -// -int main() -{ - array^args = Environment::GetCommandLineArgs(); - // - - bool isServer = false; - if ( args->Length > 1 ) - if ( args[ 1 ]->ToLower()->Equals( "s" ) ) - isServer = true; - - if ( !isServer ) - { - Console::WriteLine( "Run this program in another window, \npassing the letter 's' as an argument.\nPress Enter here when the server has been activated." ); - Console::ReadLine(); - Console::WriteLine( "Running TCP client." ); - } - - // - if ( isServer ) - { - gcnew TcpServerApp; - } - else - { - gcnew TcpClientApp; - } - // - - if ( !isServer ) - { - Console::WriteLine( "\nPress Enter in the other window to continue to the next demo.\nThen press Enter here." ); - Console::ReadLine(); - } - - // - if ( isServer ) - { - gcnew HttpServerApp; - } - else - { - gcnew HttpClientApp; - } - // - - // - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.SoapServices/CPP/demo.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.SoapServices/CPP/demo.cpp deleted file mode 100644 index dcfbf9f217f27..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Runtime.Remoting.SoapServices/CPP/demo.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/// Class: System.Runtime.Remoting.SoapServices -/// 100 class -/// 101 CodeXmlNamespaceForClrTypeNamespace() -/// 102 DecodeXmlNamespaceForClrTypeNamespace() -/// 150 GetInteropFieldTypeAndNameFromXmlAttribute() -/// 150 GetInteropFieldTypeAndNameFromXmlElement() -/// 160 GetInteropTypeFromXmlElement() -/// 160 GetInteropTypeFromXmlType() -/// 140 GetSoapActionFromMethodBase() -/// 140 GetTypeAndMethodNameFromSoapAction() -/// 103 GetXmlElementForInteropType() -/// 105 GetXmlNamespaceForMethodCall() -/// 105 GetXmlNamespaceForMethodResponse() -/// 104 GetXmlTypeForInteropType() -/// 106 IsClrTypeNamespace() -/// 140 IsSoapActionValidForMethodBase() -/// 120 PreLoad(Assembly) -/// 121 PreLoad(Type) -/// 180 RegisterInteropXmlElement() -/// 190 RegisterInteropXmlType() -/// 170 RegisterSoapActionForMethodBase(MethodBase) -/// 170 RegisterSoapActionForMethodBase(MethodBase,String) -/// 130 XmlNsForClrType -/// 131 XmlNsForClrTypeWithAssembly -/// 132 XmlNsForClrTypeWithNs -/// 133 XmlNsForClrTypeWithNsAndAssembly -// -#using -using namespace System; -using namespace System::Runtime::Remoting; - -namespace ExampleNamespace -{ - [System::Runtime::Remoting::Metadata::SoapTypeAttribute( - XmlElementName="ExampleClassElementName", - XmlNamespace="http://example.org/ExampleXmlNamespace", - XmlTypeName="ExampleXmlTypeName", - XmlTypeNamespace="http://example.org/ExampleXmlTypeNamespace")] - public ref class ExampleClass - { - public: - - // A field that will be serialized as an XML element. - [System::Runtime::Remoting::Metadata::SoapField( - XmlElementName="ExampleFieldElementName", - XmlNamespace="http://example.org/ExampleFieldNamespace")] - String^ ExampleFieldUsingElement; - - // A field that will be serialized as an XML attribute. - [System::Runtime::Remoting::Metadata::SoapField( - XmlElementName="ExampleFieldAttributeName", - XmlNamespace="http://example.org/ExampleAttributeNamespace", - UseAttribute=true)] - String^ ExampleFieldUsingAttribute; - - [System::Runtime::Remoting::Metadata::SoapMethod( - SoapAction="http://example.org/ExampleSoapAction#GetHello")] - String^ GetHello( String^ name ) - { - return String::Format( L"Hello, {0}", name ); - } - - }; - -} - -[System::Security::Permissions::SecurityPermissionAttribute( -System::Security::Permissions::SecurityAction::LinkDemand, -Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] -int main() -{ - // - // Convert a CLR namespace and assembly name into an XML namespace. - String^ xmlNamespace = SoapServices::CodeXmlNamespaceForClrTypeNamespace( - L"ExampleNamespace", L"AssemblyName" ); - Console::WriteLine( L"The name of the XML namespace is {0}.", xmlNamespace ); - // - - // - // Extract a CLR namespace and assembly name from an XML namespace. - String^ typeNamespace; - String^ assemblyName; - SoapServices::DecodeXmlNamespaceForClrTypeNamespace( - xmlNamespace,typeNamespace,assemblyName ); - Console::WriteLine( L"The name of the CLR namespace is {0}.", typeNamespace ); - Console::WriteLine( L"The name of the CLR assembly is {0}.", assemblyName ); - // - - // - // Get the XML element name and the XML namespace for - // an Interop type. - String^ xmlElement; - bool isSoapTypeAttribute = SoapServices::GetXmlElementForInteropType( - ExampleNamespace::ExampleClass::typeid,xmlElement,xmlNamespace ); - - // Print whether the requested value was flagged - // with a SoapTypeAttribute. - if ( isSoapTypeAttribute ) - { - Console::WriteLine( L"The requested value was flagged " - L"with the SoapTypeAttribute." ); - } - else - { - Console::WriteLine( L"The requested value was not flagged " - L"with the SoapTypeAttribute." ); - } - - // Print the XML element and the XML namespace. - Console::WriteLine( L"The XML element for the type " - L"ExampleNamespace.ExampleClass is {0}.", xmlElement ); - Console::WriteLine( L"The XML namespace for the type " - L"ExampleNamespace.ExampleClass is {0}.", xmlNamespace ); - // - - // - // Get the XML type name and the XML type namespace for - // an Interop type. - String^ xmlTypeName; - String^ xmlTypeNamespace; - isSoapTypeAttribute = SoapServices::GetXmlTypeForInteropType( ExampleNamespace::ExampleClass::typeid,xmlTypeName,xmlTypeNamespace ); - - // Print whether the requested value was flagged - // with a SoapTypeAttribute. - if ( isSoapTypeAttribute ) - { - Console::WriteLine( L"The requested value was flagged " - L"with the SoapTypeAttribute." ); - } - else - { - Console::WriteLine( L"The requested value was not flagged " - L"with the SoapTypeAttribute." ); - } - - // Print the XML type name and the XML type namespace. - Console::WriteLine( L"The XML type for the type " - L"ExampleNamespace.ExampleClass is {0}.", xmlTypeName ); - Console::WriteLine( L"The XML type namespace for the type " - L"ExampleNamespace.ExampleClass is {0}.", xmlTypeNamespace ); - // - - // - // Print the XML namespace for a method invocation and its - // response. - System::Reflection::MethodBase^ getHelloMethod = - ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" ); - String^ methodCallXmlNamespace = - SoapServices::GetXmlNamespaceForMethodCall( getHelloMethod ); - String^ methodResponseXmlNamespace = - SoapServices::GetXmlNamespaceForMethodResponse( getHelloMethod ); - Console::WriteLine( L"The XML namespace for the invocation of the method " - L"GetHello in ExampleClass is {0}.", methodResponseXmlNamespace ); - Console::WriteLine( L"The XML namespace for the response of the method " - L"GetHello in ExampleClass is {0}.", methodCallXmlNamespace ); - // - - // - // Determine whether an XML namespace represents a CLR namespace. - String^ clrNamespace = SoapServices::XmlNsForClrType; - if ( SoapServices::IsClrTypeNamespace( clrNamespace ) ) - { - Console::WriteLine( L"The namespace {0} is a CLR namespace.", - clrNamespace ); - } - else - { - Console::WriteLine( L"The namespace {0} is not a CLR namespace.", - clrNamespace ); - } - // - - // - // Print the XML namespace for the CLR types. - Console::WriteLine( L"The XML namespace for the CLR types " - L"is {0}.", SoapServices::XmlNsForClrType ); - // - - // - // Print the XML namespace for the CLR types - // that have an assembly but no common language runtime namespace. - Console::WriteLine( L"The XML namespace for the CLR types " - L"that have an assembly but no namespace, is {0}.", - SoapServices::XmlNsForClrTypeWithAssembly ); - // - - // - // Print the XML namespace for the CLR types - // that are a part of the Mscorlib.dll. - Console::WriteLine( L"The XML namespace for the CLR types " - L"that are part of the Mscorlib.dll, is {0}.", - SoapServices::XmlNsForClrTypeWithNs ); - // - - // - // Print the XML namespace for the CLR types - // that have both an assembly and a common language runtime - // namespace. - Console::WriteLine( L"The XML namespace for the CLR types " - L"that have both an assembly and a namespace, is {0}.", - SoapServices::XmlNsForClrTypeWithNsAndAssembly ); - // - - // - // Get the SOAP action for the method. - System::Reflection::MethodBase^ getHelloMethodBase = - ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" ); - String^ getHelloSoapAction = - SoapServices::GetSoapActionFromMethodBase( getHelloMethodBase ); - Console::WriteLine( L"The SOAP action for the method " - L"ExampleClass.GetHello is {0}.", getHelloSoapAction ); - bool isSoapActionValid = - SoapServices::IsSoapActionValidForMethodBase( - getHelloSoapAction, getHelloMethodBase ); - if ( isSoapActionValid ) - { - Console::WriteLine( L"The SOAP action, {0}, " - L"is valid for ExampleClass.GetHello", getHelloSoapAction ); - } - else - { - Console::WriteLine( L"The SOAP action, {0}, " - L"is not valid for ExampleClass.GetHello", getHelloSoapAction ); - } - - // Register the SOAP action for the GetHello method. - SoapServices::RegisterSoapActionForMethodBase( getHelloMethodBase ); - - // Get the type and the method names encoded into the SOAP action. - String^ encodedTypeName; - String^ encodedMethodName; - SoapServices::GetTypeAndMethodNameFromSoapAction( - getHelloSoapAction,encodedTypeName,encodedMethodName ); - Console::WriteLine( L"The type name encoded in this SOAP action is {0}.", - encodedTypeName ); - Console::WriteLine( L"The method name encoded in this SOAP action is {0}.", - encodedMethodName ); - // - - // - // Get the name and the type of the field using its XML - // element name and its XML namespace. For this query to work, - // the containing type must be preloaded, and the XML element - // name and the XML namespace must be explicitly declared on - // the field using a SoapFieldAttribute. - // Preload the containing type. - SoapServices::PreLoad( ExampleNamespace::ExampleClass::typeid ); - - // Get the name and the type of a field that will be - // serialized as an XML element. - Type^ containingType = ExampleNamespace::ExampleClass::typeid; - String^ xmlElementNamespace = L"http://example.org/ExampleFieldNamespace"; - String^ xmlElementName = L"ExampleFieldElementName"; - Type^ fieldType; - String^ fieldName; - SoapServices::GetInteropFieldTypeAndNameFromXmlElement( - containingType,xmlElementName,xmlElementNamespace,fieldType,fieldName ); - Console::WriteLine( L"The type of the field is {0}.", fieldType ); - Console::WriteLine( L"The name of the field is {0}.", fieldName ); - - // Get the name and the type of a field that will be - // serialized as an XML attribute. - String^ xmlAttributeNamespace = - L"http://example.org/ExampleAttributeNamespace"; - String^ xmlAttributeName = L"ExampleFieldAttributeName"; - SoapServices::GetInteropFieldTypeAndNameFromXmlAttribute( - containingType,xmlAttributeName,xmlAttributeNamespace,fieldType,fieldName ); - Console::WriteLine( L"The type of the field is {0}.", fieldType ); - Console::WriteLine( L"The name of the field is {0}.", fieldName ); - // - - // - String^ interopTypeXmlElementName = L"ExampleClassElementName"; - String^ interopTypeXmlNamespace = L"http://example.org/ExampleXmlNamespace"; - Type^ interopType = SoapServices::GetInteropTypeFromXmlElement( - interopTypeXmlElementName, interopTypeXmlNamespace ); - Console::WriteLine( L"The interop type is {0}.", interopType ); - String^ interopTypeXmlTypeName = L"ExampleXmlTypeName"; - String^ interopTypeXmlTypeNamespace = - L"http://example.org/ExampleXmlTypeNamespace"; - interopType = SoapServices::GetInteropTypeFromXmlType( - interopTypeXmlTypeName,interopTypeXmlTypeNamespace ); - Console::WriteLine( L"The interop type is {0}.", interopType ); - // - - // - // Get the method base object for the GetHello method. - System::Reflection::MethodBase^ methodBase = - ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" ); - - // Print its current SOAP action. - Console::WriteLine( L"The SOAP action for the method " - L"ExampleClass.GetHello is {0}.", - SoapServices::GetSoapActionFromMethodBase( methodBase ) ); - - // Set the SOAP action of the GetHello method to a new value. - String^ newSoapAction = L"http://example.org/ExampleSoapAction#NewSoapAction"; - SoapServices::RegisterSoapActionForMethodBase( methodBase, newSoapAction ); - Console::WriteLine( L"The SOAP action for the method " - L"ExampleClass.GetHello is {0}.", - SoapServices::GetSoapActionFromMethodBase( methodBase ) ); - - // Reset the SOAP action of the GetHello method to its default - // value, which is determined using its SoapMethod attribute. - SoapServices::RegisterSoapActionForMethodBase( methodBase ); - Console::WriteLine( L"The SOAP action for the method " - L"ExampleClass.GetHello is {0}.", - SoapServices::GetSoapActionFromMethodBase( methodBase ) ); - // - - // - // Register all types in the assembly with the SoapType attribute. - System::Reflection::Assembly^ executingAssembly = - System::Reflection::Assembly::GetExecutingAssembly(); - SoapServices::PreLoad( executingAssembly ); - // - - // - // Register a specific type with the SoapType attribute. - Type^ exampleType = ExampleNamespace::ExampleClass::typeid; - SoapServices::PreLoad( exampleType ); - // - - // - // Get the currently registered type for the given XML element - // and namespace. - String^ registeredXmlElementName = L"ExampleClassElementName"; - String^ registeredXmlNamespace = - L"http://example.org/ExampleXmlNamespace"; - Type^ registeredType = - SoapServices::GetInteropTypeFromXmlElement( - registeredXmlElementName, registeredXmlNamespace ); - Console::WriteLine( L"The registered interop type is {0}.", - registeredType ); - - // Register a new type for the XML element and namespace. - SoapServices::RegisterInteropXmlElement( - registeredXmlElementName,registeredXmlNamespace,String::typeid ); - - // Get the currently registered type for the given XML element - // and namespace. - registeredType = SoapServices::GetInteropTypeFromXmlElement( - registeredXmlElementName,registeredXmlNamespace ); - Console::WriteLine( L"The registered interop type is {0}.", - registeredType ); - // - - // - // Get the currently registered type for the given XML element - // and namespace. - String^ registeredXmlTypeName = L"ExampleXmlTypeName"; - String^ registeredXmlTypeNamespace = - L"http://example.org/ExampleXmlTypeNamespace"; - registeredType = SoapServices::GetInteropTypeFromXmlType( - registeredXmlTypeName, registeredXmlTypeNamespace ); - Console::WriteLine( L"The registered interop type is {0}.", - registeredType ); - - // Register a new type for the XML element and namespace. - SoapServices::RegisterInteropXmlType( registeredXmlTypeName, - registeredXmlTypeNamespace,String::typeid ); - - // Get the currently registered type for the given XML element - // and namespace. - registeredType = SoapServices::GetInteropTypeFromXmlType( - registeredXmlTypeName,registeredXmlTypeNamespace ); - Console::WriteLine( L"The registered interop type is {0}.", - registeredType ); - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/System.Web.Services.Protocols.WebClientProtocol constructor/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/System.Web.Services.Protocols.WebClientProtocol constructor/CPP/class1.cpp deleted file mode 100644 index fda8e86ad0163..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/System.Web.Services.Protocols.WebClientProtocol constructor/CPP/class1.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Xml::Serialization; -using namespace System::Web::Services::Protocols; -using namespace System::Web::Services; - -int main(){} - -// This class derives from System::Web::Services::Protocols.WebClientProtocol -// as if the user implemented their own protocol. -// It demonstrates the use of WebClientProtocol's constructor. - -// -[System::Web::Services::WebServiceBindingAttribute(Name="Service1Soap", - Namespace="http://tempuri.org/")] -ref class TempConvertService: public System::Web::Services::Protocols::WebClientProtocol -{ -public: - TempConvertService() : WebClientProtocol() - { - // Rest of class initialization. - } - // -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/class1.cpp deleted file mode 100644 index 864f52557568e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/class1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using -#using -#using "Service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Collections; - -int main() -{ - // Create a remotable object. - TcpChannel^ tcpChannel = gcnew TcpChannel( 8085 ); - WellKnownServiceTypeEntry^ WKSTE = - gcnew WellKnownServiceTypeEntry( HelloService::typeid, - "Service", - WellKnownObjectMode::Singleton ); - RemotingConfiguration::RegisterWellKnownServiceType( WKSTE ); - - RemotingConfiguration::ApplicationName = "HelloServer"; - - // Print out the urls for the HelloServer. - array^ urls = tcpChannel->GetUrlsForUri( "HelloServer" ); - - for each ( String^ url in urls ) - { - System::Console::WriteLine( "{0}", url ); - } - return 0; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/makefile deleted file mode 100644 index f326ce956a05c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/makefile +++ /dev/null @@ -1,8 +0,0 @@ -all : class1.exe - - -class1.exe : class1.cpp Service.dll - cl /clr:pure /Zi /nologo class1.cpp - -Service.dll : Service.cpp - cl /clr:pure /Zi /nologo /LD Service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/service.cpp deleted file mode 100644 index 5cf56738d9e18..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/TcpChannel.GetUrlsForUri/CPP/service.cpp +++ /dev/null @@ -1,27 +0,0 @@ -using namespace System; - -public ref class HelloService: public MarshalByRefObject -{ -private: - static int n_instances; - -public: - HelloService() - { - n_instances++; - Console::WriteLine( "" ); - Console::WriteLine( "HelloService activated - instance # {0}.", n_instances ); - } - - ~HelloService() - { - Console::WriteLine( "HelloService instance {0} destroyed.", n_instances ); - n_instances--; - } - - String^ HelloMethod( String^ name ) - { - Console::WriteLine( "HelloMethod called on HelloService instance {0}.", n_instances ); - return String::Format( "Hi there {0}.", name ); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp deleted file mode 100644 index a2417ed5c5552..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -void main() -{ - const int portNumber = 13; - - // - try - { - // Use the Pending method to poll the underlying socket instance for client connection requests. - TcpListener^ tcpListener = gcnew TcpListener( portNumber ); - tcpListener->Start(); - - if ( !tcpListener->Pending() ) - { - Console::WriteLine( "Sorry, no connection requests have arrived" ); - } - else - { - //Accept the pending client connection and return a TcpClient object^ initialized for communication. - TcpClient^ tcpClient = tcpListener->AcceptTcpClient(); - - // Using the RemoteEndPoint property. - Console::WriteLine( "I am listening for connections on {0} on port number {1}", - IPAddress::Parse( ( (IPEndPoint^)(tcpListener->LocalEndpoint) )->Address->ToString() ), - ( (IPEndPoint^)(tcpListener->LocalEndpoint) )->Port ); - // - - //Close the tcpListener and tcpClient instances - tcpClient->Close(); - } - tcpListener->Stop(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/class1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/class1.cpp deleted file mode 100644 index 5d26295d74509..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/class1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using -#using -#using "service.dll" - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels::Tcp; -using namespace System::Collections; - -int main() -{ - // Create a remotable object. - TcpServerChannel^ tcpChannel = gcnew TcpServerChannel( 8085 ); - - WellKnownServiceTypeEntry^ WKSTE = - gcnew WellKnownServiceTypeEntry( HelloService::typeid, - "Service", - WellKnownObjectMode::Singleton ); - RemotingConfiguration::RegisterWellKnownServiceType( WKSTE ); - - RemotingConfiguration::ApplicationName = "HelloServer"; - - // Print out the urls for the HelloServer. - array^ urls = tcpChannel->GetUrlsForUri( "HelloServer" ); - - for each ( String^ url in urls ) - { - System::Console::WriteLine( "{0}", url ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/makefile deleted file mode 100644 index d78435d4b9ca1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: class1.exe - -class1.exe: class1.cpp service.dll - cl /clr:pure class1.cpp - -service.dll: service.cpp - cl /clr:pure /LD service.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/service.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/service.cpp deleted file mode 100644 index 5cf56738d9e18..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/TcpServerChannel.GetUrlsForUri/CPP/service.cpp +++ /dev/null @@ -1,27 +0,0 @@ -using namespace System; - -public ref class HelloService: public MarshalByRefObject -{ -private: - static int n_instances; - -public: - HelloService() - { - n_instances++; - Console::WriteLine( "" ); - Console::WriteLine( "HelloService activated - instance # {0}.", n_instances ); - } - - ~HelloService() - { - Console::WriteLine( "HelloService instance {0} destroyed.", n_instances ); - n_instances--; - } - - String^ HelloMethod( String^ name ) - { - Console::WriteLine( "HelloMethod called on HelloService instance {0}.", n_instances ); - return String::Format( "Hi there {0}.", name ); - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp deleted file mode 100644 index 0f5bd7c779933..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp +++ /dev/null @@ -1,90 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -ref class Vehicle; - -[SoapInclude(Vehicle::typeid)] -public ref class Vehicle -{ -public: - String^ licenseNumber; -}; - - -// You must use the SoapIncludeAttribute to inform the XmlSerializer -// that the Vehicle type should be recognized when deserializing. - -[SoapInclude(Vehicle::typeid)] -public ref class Group -{ -public: - String^ GroupName; - Vehicle^ GroupVehicle; -}; - -public ref class Run -{ -public: - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = ((gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid )); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - mySerializer->UnreferencedObject += gcnew UnreferencedObjectEventHandler( this, &Run::Serializer_UnreferencedObject ); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement(); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - -private: - void Serializer_UnreferencedObject( Object^ /*sender*/, UnreferencedObjectEventArgs^ e ) - { - Console::WriteLine( "UnreferencedObject:" ); - Console::WriteLine( "ID: {0}", e->UnreferencedId ); - Console::WriteLine( "UnreferencedObject: {0}", e->UnreferencedObject ); - Vehicle^ myVehicle = dynamic_cast(e->UnreferencedObject); - Console::WriteLine( "License: {0}", myVehicle->licenseNumber ); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->DeserializeObject( "UnrefObj.xml" ); -} - -// The file named S"UnrefObj.xml" should contain this XML: -// -// -// -// -// ABCD -// -// -// 1234 -// -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp deleted file mode 100644 index d4b536a14d2aa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#pragma region^ Using directives - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Text; - -#pragma endregion - -int main() -{ - // - UriBuilder^ baseUri = gcnew UriBuilder - ("http://www.contoso.com/default.aspx?Param1=7890"); - String^ queryToAppend = "param2=1234"; - if (baseUri->Query != nullptr && baseUri->Query->Length > 1) - { - baseUri->Query = baseUri->Query->Substring(1)+ "&" + queryToAppend; - } - - else - { - baseUri->Query = queryToAppend; - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/makefile deleted file mode 100644 index 3e6fc62975f01..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/makefile +++ /dev/null @@ -1,3 +0,0 @@ -UriBuilderSample.exe: main.cpp - cl /FeUriBuilderSample.exe /clr:pure main.cpp - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient/CPP/webclient.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient/CPP/webclient.cpp deleted file mode 100644 index 13f395578e459..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient/CPP/webclient.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::Collections::Specialized; - -int main() -{ - // - try - { - // Download the data to a buffer. - WebClient^ client = gcnew WebClient; - - array^ pageData = client->DownloadData( "http://www.contoso.com" ); - String^ pageHtml = Encoding::ASCII->GetString( pageData ); - Console::WriteLine( pageHtml ); - - // Download the data to a file. - client->DownloadFile( "http://www.contoso.com", "page.htm" ); - - // Upload some form post values. - NameValueCollection^ form = gcnew NameValueCollection; - form->Add( "MyName", "MyValue" ); - array^ responseData = client->UploadValues( "http://www.contoso.com/form.aspx", form ); - } - catch ( WebException^ webEx ) - { - Console::WriteLine( webEx->ToString() ); - if ( webEx->Status == WebExceptionStatus::ConnectFailure ) - { - Console::WriteLine( "Are you behind a firewall? If so, go through the proxy server." ); - } - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClientAuthentication/CPP/webclientauth.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClientAuthentication/CPP/webclientauth.cpp deleted file mode 100644 index 36fa4c4787334..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClientAuthentication/CPP/webclientauth.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -// -int main() -{ - try - { - WebClient^ client = gcnew WebClient; - client->Credentials = CredentialCache::DefaultCredentials; - array^pageData = client->DownloadData( "http://www.contoso.com" ); - String^ pageHtml = Encoding::ASCII->GetString( pageData ); - Console::WriteLine( pageHtml ); - } - catch ( WebException^ webEx ) - { - Console::Write( webEx ); - } - -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_BaseAddress_ResponseHeaders/CPP/webclient_baseaddress_responseheaders.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_BaseAddress_ResponseHeaders/CPP/webclient_baseaddress_responseheaders.cpp deleted file mode 100644 index 20b89ad7be49b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_BaseAddress_ResponseHeaders/CPP/webclient_baseaddress_responseheaders.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Net::WebClient::BaseAddress; System::Net::WebClient::ResponseHeaders - -/*This program demonstrates the 'BaseAddress' and 'ResponseHeaders' property of 'WebClient' class. -It accepts the base Uri from the user and assigns it to the 'BaseAddress' property of the -'WebClient' class.It then invokes 'DownloadFile' for the specific web page requested by the -user. WebClient internally combines the 'BaseAddress' and specific page name to retrieve the page. - -The 'ResponseHeaders' property is a 'WebHeaderCollection' that contains the -header information of the response received from the server.This is displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { - Console::Write( "\nPlease enter a Url {e.g. : http://www.microsoft.com}" ); - String^ hostUri = Console::ReadLine(); - Console::Write( "\nPlease enter the specific web page you require {e.g. : windows/default.asp} : " ); - String^ uriSuffix = Console::ReadLine(); - -// - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - - // Set the BaseAddress of the Web Resource in the WebClient. - myWebClient->BaseAddress = hostUri; - Console::WriteLine( "Downloading from {0}/ {1}", hostUri, uriSuffix ); - Console::WriteLine( "\nPress Enter key to continue" ); - Console::ReadLine(); - - // Download the target Web Resource into a Byte array. - array^ myDatabuffer = myWebClient->DownloadData( uriSuffix ); - - // Display the downloaded data. - String^ download = Encoding::ASCII->GetString( myDatabuffer ); - Console::WriteLine( download ); - Console::WriteLine( "Download of {0}{1} was successful.", myWebClient->BaseAddress, uriSuffix ); -// - -// - // Obtain the WebHeaderCollection instance containing the header name/value pair from the response. - WebHeaderCollection^ myWebHeaderCollection = myWebClient->ResponseHeaders; - Console::WriteLine( "\nDisplaying the response headers\n" ); - - // Loop through the ResponseHeaders and display the header name/value pairs. - for ( int i = 0; i < myWebHeaderCollection->Count; i++ ) - { - Console::WriteLine( "\t{0} = {1}", myWebHeaderCollection->GetKey( i ), - myWebHeaderCollection->Get( i ) ); - } -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following WebException was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following Exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_DownloadData/CPP/webclient_downloaddata.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_DownloadData/CPP/webclient_downloaddata.cpp deleted file mode 100644 index d306a8cb394bc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_DownloadData/CPP/webclient_downloaddata.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// System::Net::WebClient::DownloadData; System::Net::WebClient::WebClient - -/* -This program demonstrates the 'DownloadData' method and 'WebClient()' constructor of 'WebClient' class. -It creates a URI to access a web resource. The Uri can point -to any text or binary web resource, like images etc. The 'DownloadData' method then downloads -the required text/html homepage into a Byte array. The downloaded data is displayed on the Console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// -// - Console::Write( "\nPlease enter a URI (e.g. http://www.contoso.com): " ); - String^ remoteUri = Console::ReadLine(); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - // Download home page data. - Console::WriteLine( "Downloading {0}", remoteUri ); - // Download the Web resource and save it into a data buffer. - array^ myDataBuffer = myWebClient->DownloadData( remoteUri ); - - // Display the downloaded data. - String^ download = Encoding::ASCII->GetString( myDataBuffer ); - Console::WriteLine( download ); - - Console::WriteLine( "Download successful." ); -// -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "Download failed!!! WebException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following general exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_DownloadFile/CPP/webclient_downloadfile.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_DownloadFile/CPP/webclient_downloadfile.cpp deleted file mode 100644 index f7dd44ee87f33..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_DownloadFile/CPP/webclient_downloadfile.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// System::Net::WebClient::DownloadFile - -/* -This program demonstrates the 'DownloadFile' method of 'WebClient' class. -It creates a URI to access a web resource at 'http://www.microsoft.com'. The Uri can point -to any text or binary web resource, like images etc. The 'DownloadFile' method then downloads -the target web resource which is a combination of the Uri and the actual web resource required, -into the current filesystem folder with a specified name. -Information regarding the sucess or failure of this operation is displayed on the console. -*/ - -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Windows::Forms; - -int main() -{ - try - { -// - String^ remoteUri = "http://www.contoso.com/library/homepage/images/"; - String^ fileName = "ms-banner.gif", ^myStringWebResource = nullptr; - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - // Concatenate the domain with the Web resource filename. - myStringWebResource = String::Concat( remoteUri, fileName ); - Console::WriteLine( "Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource ); - // Download the Web resource and save it into the current filesystem folder. - myWebClient->DownloadFile( myStringWebResource, fileName ); - Console::WriteLine( "Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource ); - Console::WriteLine( "\nDownloaded file saved in the following file system folder:\n\t {0}", Application::StartupPath ); -// - } - catch ( WebException^ e ) - { - // Display the exception. - Console::WriteLine( "Download failed!!! WebException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - // Display the exception. - Console::WriteLine( "The following general exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenRead/CPP/webclient_openread.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenRead/CPP/webclient_openread.cpp deleted file mode 100644 index d2ddda3c6cd1d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenRead/CPP/webclient_openread.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// System::Net::WebClient::OpenRead - -/* -This program demonstrates the 'OpenRead' method of 'WebClient' class. -It creates a URI to access a web resource. It then invokes 'OpenRead' tp obtain a 'Stream' -instance which is used to retrieve the web page data. The data read from the stream is then -displayed on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; - -int main() -{ - try - { - Console::Write( "\nPlease enter a URI (e.g. http://www.contoso.com): " ); - String^ uriString = Console::ReadLine(); - -// - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - // Download home page data. - Console::WriteLine( "Accessing {0} ...", uriString ); - // Open a stream to point to the data stream coming from the Web resource. - Stream^ myStream = myWebClient->OpenRead( uriString ); - - Console::WriteLine( "\nDisplaying Data :\n" ); - StreamReader^ sr = gcnew StreamReader( myStream ); - Console::WriteLine( sr->ReadToEnd() ); - - // Close the stream. - myStream->Close(); -// - } - catch ( WebException^ e ) - { - // Display the exception. - Console::WriteLine( "Webresource access failed!!! WebException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - // Display the exception. - Console::WriteLine( "The following general exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenWrite/CPP/webclient_openwrite.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenWrite/CPP/webclient_openwrite.cpp deleted file mode 100644 index d2973d8873298..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenWrite/CPP/webclient_openwrite.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Net::WebClientOpenWrite(String, String) - -/* -This program demonstrates the 'OpenWrite(String, String)' method of S"WebClient" class. -It accepts an Uri and some String* content to be posted to the Uri. The -program makes a call to 'OpenWrite(String, String)' method and obtains a S"Stream" instance -This stream is used to post data to the site. - -Note : Behaviour of this program may not be the same with all other sites. Also certain -sites would not accept S"Post" method thereby leading to an error.It is advisable -to construct a site using files accompanying this and provide -url name of this site to the program. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - try - { -// - String^ uriString; - Console::Write( "\nPlease enter the URI to post data to: " ); - uriString = Console::ReadLine(); - Console::WriteLine( "\nPlease enter the data to be posted to the URI {0}:", uriString ); - String^ postData = Console::ReadLine(); - // Apply ASCII encoding to obtain an array of bytes . - array^ postArray = Encoding::ASCII->GetBytes( postData ); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - - Console::WriteLine( "Uploading to {0} ...", uriString ); - Stream^ postStream = myWebClient->OpenWrite( uriString, "POST" ); - postStream->Write( postArray, 0, postArray->Length ); - - // Close the stream and release resources. - postStream->Close(); - Console::WriteLine( "\nSuccessfully posted the data." ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenWrite2/CPP/webclient_openwrite2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenWrite2/CPP/webclient_openwrite2.cpp deleted file mode 100644 index 31de18430dc23..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_OpenWrite2/CPP/webclient_openwrite2.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Net::WebClient::OpenWrite(String) - -/* -This program demonstrates the 'OpenWrite(String)' method of S"WebClient" class. -It accepts an Uri and some String* content to be posted to the Uri. The -program makes a call to 'OpenWrite(String)' method and obtains a S"Stream" instance -This stream is used to post data to the site. - -Note : Behaviour of this program may not be the same with all other sites. Also certain -sites would not accept S"Post" method thereby leading to an error.It is advisable -to construct a site using files accompanying this and provide -url name of this site to the program. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - try - { -// - String^ uriString; - Console::Write( "\nPlease enter the URI to post data to: " ); - uriString = Console::ReadLine(); - Console::WriteLine( "\nPlease enter the data to be posted to the URI {0}:", uriString ); - String^ postData = Console::ReadLine(); - // Apply Ascii Encoding to obtain an array of bytes. - array^ postArray = Encoding::ASCII->GetBytes( postData ); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - - // postStream implicitly sets HTTP POST as the request method. - Console::WriteLine( "Uploading to {0} ...", uriString ); - Stream^ postStream = myWebClient->OpenWrite( uriString ); - - postStream->Write( postArray, 0, postArray->Length ); - - // Close the stream and release resources. - postStream->Close(); - - Console::WriteLine( "\nSuccessfully posted the data." ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_QueryString/CPP/webclient_querystring.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_QueryString/CPP/webclient_querystring.cpp deleted file mode 100644 index 9d13d718d71ba..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_QueryString/CPP/webclient_querystring.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// System::Net::WebClient::QueryString - -/*This program demonstrates the 'QueryString' property of 'WebClient' class. -It accepts a search phrase as user input and invokes the search of www.google.com for -the user-entered search-phrase, using the 'QueryString' property of WebClient. The result is -then saved into the current -filesystem folder as 'searchresult.htm'. -*/ - -#using - -using namespace System; -using namespace System::Collections::Specialized; -using namespace System::Net; - -int main() -{ - try - { -// - String^ uriString = "http://www.contoso.com/search"; - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - // Create a new NameValueCollection instance to hold the QueryString parameters and values. - NameValueCollection^ myQueryStringCollection = gcnew NameValueCollection; - Console::Write( "Enter the word(s), separated by space character to search for in {0}: ", uriString ); - // Read user input phrase to search for at uriString. - String^ searchPhrase = Console::ReadLine(); - if ( searchPhrase->Length > 1 ) - { - // Assign the user-defined search phrase. - myQueryStringCollection->Add( "q", searchPhrase ); - } - else - { - // If error, default to search for 'Microsoft'. - myQueryStringCollection->Add( "q", "Microsoft" ); - } - // Assign auxilliary parameters required for the search. - Console::WriteLine( "Searching {0} .......", uriString ); - // Attach QueryString to the WebClient. - myWebClient->QueryString = myQueryStringCollection; - // Download the search results Web page into 'searchresult.htm' for inspection. - myWebClient->DownloadFile( uriString, "searchresult.htm" ); - Console::WriteLine( "\nDownload of {0} was successful. Please see 'searchresult.htm' for results.", uriString ); -// - // Get the collection of Headers sent back in response to the WebClient request. - WebHeaderCollection^ myWebHeaderCollection = myWebClient->ResponseHeaders; - Console::WriteLine( "\nDisplaying Response Headers\n" ); - // Loop through the ResponseHeader collection and display the Headers as name/value pairs. - for ( int i = 0; i < myWebHeaderCollection->Count; i++ ) - { - // Display the Headers as 'Name = Value' pairs. - Console::WriteLine( "\t {0} = {1}", myWebHeaderCollection->GetKey( i ), myWebHeaderCollection->Get( i ) ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following WebException was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following Exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadData2/CPP/webclient_uploaddata2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadData2/CPP/webclient_uploaddata2.cpp deleted file mode 100644 index 8d8aa1b36a2a0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadData2/CPP/webclient_uploaddata2.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Net::WebClient::UploadData(String, Byte->Item[]) - -/* -This program demonstrates the 'UploadData(String, Byte->Item[])' method of S"WebClient" class. -It accepts an Uri and some String* content to be posted to the Uri. This String* is posted to the Uri -provided as input using the 'UploadData(String, Byte->Item[])' method. The custom made site responds back -with whatever was posted to it. The contents of the response are displayed to the console. - -Note : The results described were obtained using a custom made site. This behaviour may not be the -same with all other sites. Also certain sites would not accept "Post" method thereby leading to -an error.It is advisable to construct a site using files accompanying this and provide -url name of this site to the program. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - Console::Write( "\nPlease enter the URI to post data to: " ); - String^ uriString = Console::ReadLine(); - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - Console::WriteLine( "\nPlease enter the data to be posted to the URI {0}:", uriString ); - String^ postData = Console::ReadLine(); - // Apply ASCII Encoding to obtain the String* as a Byte array. - array^ postArray = Encoding::ASCII->GetBytes( postData ); - Console::WriteLine( "Uploading to {0} ...", uriString ); - myWebClient->Headers->Add( "Content-Type", "application/x-www-form-urlencoded" ); - - //UploadData implicitly sets HTTP POST as the request method. - array^responseArray = myWebClient->UploadData( uriString, postArray ); - - // Decode and display the response. - Console::WriteLine( "\nResponse received was: {0}", Encoding::ASCII->GetString( responseArray ) ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadData_Headers/CPP/webclient_uploaddata_headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadData_Headers/CPP/webclient_uploaddata_headers.cpp deleted file mode 100644 index af0b76ef722a0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadData_Headers/CPP/webclient_uploaddata_headers.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// System::Net::WebClient::UplodaData(String, String, Byte->Item[]); System::Net::WebClient::Headers - -/* -This program demonstrates the 'UploadData(String, String, Byte->Item[])' method and 'Headers' property of -'WebClient' class.It accepts an Uri and some String* content to be posted to the Uri. This String* -is posted to the Uri provided as input using the 'UploadData(String, String, Byte->Item[])' method. -The 'Headers' property is used to set the S"Content-Type" header to S"application/x-www-form-urlencoded". -The custom made site responds back with whatever was posted to it. -The contents of the response are displayed to the console. - -Note : The results described were obtained using a custom made site. This behaviour may not be the -same with all other sites. Also certain sites would not support the S"Post" method thereby leading to -an error.It is advisable to construct a site using files accompanying this and provide -url name of this site to the program. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// -// - String^ uriString; - Console::Write( "\nPlease enter the URI to post data to {for example, http://www.contoso.com}: " ); - uriString = Console::ReadLine(); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - Console::WriteLine( "\nPlease enter the data to be posted to the URI {0}:", uriString ); - String^ postData = Console::ReadLine(); - myWebClient->Headers->Add( "Content-Type", "application/x-www-form-urlencoded" ); - - // Displays the headers in the request - Console::Write( "Resulting Request Headers: "); - Console::WriteLine(myWebClient->Headers); - - // Apply ASCII Encoding to obtain the String^ as a Byte array. - array^ byteArray = Encoding::ASCII->GetBytes( postData ); - Console::WriteLine( "Uploading to {0} ...", uriString ); - // Upload the input String* using the HTTP 1.0 POST method. - array^responseArray = myWebClient->UploadData( uriString, "POST", byteArray ); - // Decode and display the response. - Console::WriteLine( "\nResponse received was {0}", - Encoding::ASCII->GetString( responseArray ) ); -// -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadFile/CPP/webclient_uploadfile.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadFile/CPP/webclient_uploadfile.cpp deleted file mode 100644 index bf0fee1422ef6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadFile/CPP/webclient_uploadfile.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// System::Net::WebClient::UploadFile(String, String) -/* -This program demonstrates the 'UploadFile(String, String)' method of S"WebClient" class. -It accepts an Uri and the path of a file to be uploaded to the Uri. This file is uploaded to the Uri -provided as input using the 'UploadFile(String, String)' method. The custom made site responds back -with whatever was posted to it. Thus the contents of the file are displayed to the console. - -Note : The results described were obtained using a custom made site. This behaviour may not be the -same with all other sites. Also certain sites would not accept S"Post" method thereby leading to -an error.It is advisable to construct a site using files accompanying this and provide -url name of this site to the program. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -public class WebClient_UploadFile -{ -public: - int main() - { - try - { - // - Console::Write( "\nPlease enter the URI to post data to : " ); - String^ uriString = Console::ReadLine(); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - Console::WriteLine( "\nPlease enter the fully qualified path of the file to be uploaded to the URI" ); - String^ fileName = Console::ReadLine(); - Console::WriteLine( "Uploading {0} to {1} ...", fileName, uriString ); - - // Upload the file to the URI. - // The 'UploadFile(uriString, fileName)' method implicitly uses HTTP POST method. - array^responseArray = myWebClient->UploadFile( uriString, fileName ); - - // Decode and display the response. - Console::WriteLine( "\nResponse Received::The contents of the file uploaded are: \n {0}", - System::Text::Encoding::ASCII->GetString( responseArray ) ); - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadFile2/CPP/webclient_uploadfile2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadFile2/CPP/webclient_uploadfile2.cpp deleted file mode 100644 index 817d269e4d658..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UpLoadFile2/CPP/webclient_uploadfile2.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// System::Net::WebClient::UploadFile(String, String, String) -/* -This program demonstrates the 'UploadFile(String, String, String)' method of S"WebClient" class. -It accepts an Uri and the path of a file to be uploaded to the Uri. This file is uploaded to the Uri -provided as input using the 'UploadFile(String, String, String)' method. The custom made site responds back -with whatever was posted to it. Thus the contents of the file are displayed to the console. - -Note : The results described were obtained using a custom made site. This behaviour may not be the -same with all other sites. Also certain sites would not accept S"Post" method thereby leading to -an error.It is advisable to construct a site using files accompanying this and provide -url name of this site to the program. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -public class WebClient_UploadFile { - public: - int main() - { - try - { - // - Console::Write( "\nPlease enter the URL to post data to : " ); - String^ uriString = Console::ReadLine(); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - Console::WriteLine - ("\nPlease enter the fully qualified path of the file to be uploaded to the URL" ); - String^ fileName = Console::ReadLine(); - Console::WriteLine( "Uploading {0} to {1} ...", fileName, uriString ); - - // Upload the file to the URL using the HTTP 1.0 POST. - array^responseArray = myWebClient->UploadFile( uriString, "POST", fileName ); - - // Decode and display the response. - Console::WriteLine( "\nResponse Received::The contents of the file uploaded are: \n {0}", - System::Text::Encoding::ASCII->GetString( responseArray )); - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UploadValues/CPP/webclient_uploadvalues.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UploadValues/CPP/webclient_uploadvalues.cpp deleted file mode 100644 index 4e12d33bf883b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UploadValues/CPP/webclient_uploadvalues.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// System::Net::WebClient::UploadValues(String, NameValueCollection) - -/* -This program demonstrates the 'UploadValues(String, NameValueCollection)' method of S"WebClient" class. -It accepts an Uri::Forms a 'NameValueCollection' instance using -a set of pre-defined name-value pairs. These are posted to the Uri provided as input using the -'UploadValues(String, NameValueCollection)'method. The custom made site responds back -with whatever was posted to it. This is displayed to the console. - -Note : The results described were obtained using a custom made site. This behaviour may not be the -same with all other sites. Also certain sites would not accept S"Post" method thereby leading to -an error.It is advisable to construct a site using files accompanying this and provide -url name of this site to the program. -*/ - -#using - -using namespace System; -using namespace System::Collections::Specialized; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - Console::Write( "\nPlease enter the URI to post data to: " ); - String^ uriString = Console::ReadLine(); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - - // Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL. - NameValueCollection^ myNameValueCollection = gcnew NameValueCollection; - - Console::WriteLine( "Please enter the following parameters to be posted to the URL" ); - Console::Write( "Name: " ); - String^ name = Console::ReadLine(); - - Console::Write( "Age: " ); - String^ age = Console::ReadLine(); - - Console::Write( "Address: " ); - String^ address = Console::ReadLine(); - - // Add necessary parameter/value pairs to the name/value container. - myNameValueCollection->Add( "Name", name ); - myNameValueCollection->Add( "Address", address ); - myNameValueCollection->Add( "Age", age ); - - Console::WriteLine( "\nUploading to {0} ...", uriString ); - // 'The Upload(String, NameValueCollection)' implicitly method sets HTTP POST as the request method. - array^ responseArray = myWebClient->UploadValues( uriString, myNameValueCollection ); - - // Decode and display the response. - Console::WriteLine( "\nResponse received was :\n {0}", Encoding::ASCII->GetString( responseArray ) ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UploadValues2/CPP/webclient_uploadvalues2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UploadValues2/CPP/webclient_uploadvalues2.cpp deleted file mode 100644 index 716679a190930..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebClient_UploadValues2/CPP/webclient_uploadvalues2.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// System::Net::WebClient::UploadValues(String, String, NameValueCollection) - -/* -This program demonstrates the 'UploadValues(String, String, NameValueCollection)' method of S"WebClient" class. -It accepts an Uri::Forms a 'NameValueCollection' instance using -a set of pre-defined name-value pairs. These are posted to the Uri provided as input using the -'UploadValues(String, String, NameValueCollection)'method. The custom made site responds back -with whatever was posted to it. This is displayed to the console. - -Note : The results described were obtained using a custom made site. This behaviour may not be the -same with all other sites. Also certain sites would not accept S"Post" method thereby leading to -an error.It is advisable to construct a site using files accompanying this and provide -url name of this site to the program. -*/ - -#using - -using namespace System; -using namespace System::Collections::Specialized; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - Console::Write( "\nPlease enter the URL to post data to: " ); - String^ uriString = Console::ReadLine(); - - // Create a new WebClient instance. - WebClient^ myWebClient = gcnew WebClient; - - // Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL. - NameValueCollection^ myNameValueCollection = gcnew NameValueCollection; - - Console::WriteLine( "Please enter the following parameters to be posted to the URI" ); - Console::Write( "Name: " ); - String^ name = Console::ReadLine(); - - Console::Write( "Age: " ); - String^ age = Console::ReadLine(); - - Console::Write( "Address: " ); - String^ address = Console::ReadLine(); - - // Add necessary parameter/value pairs to the name/value container. - myNameValueCollection->Add( "Name", name ); - myNameValueCollection->Add( "Address", address ); - myNameValueCollection->Add( "Age", age ); - Console::WriteLine( "\nUploading to {0} ...", uriString ); - - // Upload the NameValueCollection. - array^ responseArray = myWebClient->UploadValues( uriString, "POST", myNameValueCollection ); - - // Decode and display the response. - Console::WriteLine( "\nResponse received was :\n {0}", Encoding::ASCII->GetString( responseArray ) ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp deleted file mode 100644 index 431b3d41063be..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System::Net::WebException::WebException(); - -/* -This program demonstrates the 'WebException()' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with an invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown.In -the 'catch' block a new 'WebException' Object* is created and thrown to the caller.That exception -is caught in the calling method and the error message is dispalyed to the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - - IPHostEntry^ hostEntry = Dns::Resolve( "http://www.contoso.com" ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - String^ exp = e->Message; - // Throw the WebException with no parameters. - throw gcnew WebException; - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.contoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "The Exception is: {0}", e->Message ); - Console::WriteLine( "The Exception is: Unable to Contact the server" ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp deleted file mode 100644 index 30f09111b53dc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// System::Net::WebException::WebException(String); - -/* -This program demonstrates the 'WebException(String)' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown.In -the 'catch' block a new 'WebException' Object* is created with a message(specific to the present -situatuation) and thrown to the caller.That exception is caught in the calling method and the -error message is dispalyed on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - IPHostEntry^ hostEntry = Dns::Resolve( connectUri ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "\nException thrown.\nThe Original Message is: {0}", e->Message ); - - // Throw the 'WebException' object with a message string specific to the situation. - throw gcnew WebException( "Unable to locate the Server with 'www.contoso.com' Uri." ); - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.contoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe New Message is: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp deleted file mode 100644 index 2514b0a0bda70..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// System::Net::WebException::WebException(String, WebExceptionStatus); - -/* -This program demonstrates the 'WebException(String, WebExceptionStatus)' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown and -in the 'catch' block a new 'WebException' Object* is created and thrown.That exception is caught -in the calling method and the error message is displayed on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - - IPHostEntry^ hostEntry = Dns::Resolve( "http://www.contoso.com" ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "\nException thrown.\nThe Original Message is: {0}", e->Message ); - // Throw the 'WebException' object with a message string and message status specific to the situation. - throw gcnew WebException( "Unable to locate the Server with 'www.contoso.com' Uri.", WebExceptionStatus::NameResolutionFailure ); - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.contoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe New Message is: {0}", e->Message ); - Console::WriteLine( "\nThe Status is : {0}", e->Status ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp deleted file mode 100644 index 5bd7d8b032185..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// System::Net::WebException::WebException(String, InnetException); - -/* -This program demonstrates the 'WebException(String, InnerException)' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown and -in the 'catch' block a new 'WebException' Object* is created and thrown.That exception is caught -in the calling method and the error message is displayed on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - - IPHostEntry^ hostEntry = Dns::Resolve( connectUri ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "\nException thrown.\nThe Original Message is: {0}", e->Message ); - // Throw the 'WebException' object with a message string specific to the situation; - // and the 'InnerException' that actually led to this exception. - throw gcnew WebException( "Unable to locate the Server with 'www.contoso.com' Uri.", e ); - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.constoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe New Message is: {0}", e->Message ); - Console::WriteLine( "\nThe Inner Exception is : {0}", e->InnerException ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp deleted file mode 100644 index a8b0b156c3d28..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// System::Net::WebException::WebException(String, InnerException, Status, WebResponse); - -/* -This program demonstrates the 'WebException(String, InnerException, Status, WebResponse)' constructor of -'WebException' class. -A 'HttpConnect' class is defined which extends the 'WebResponse' class. Then a 'HttpConnect' Object* is -created by taking an uri(intranet) from the user as input and 'ConnectHttpServer' method is called to connect -the InternetServer at the specified 'URL'. It asks for a file named 'nhjj.htm' , gets the response from the -InternetServer and checks the status of the response. If status is '404 File not Found' a 'WebResponse' Object* -is created and then a new 'WebException' Object* is created and thrown.That exception is caught in the calling -method and the error message along with the response obtained from the InternetServer is displayed to the -console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::IO; - -public ref class HttpConnect: public WebResponse -{ -public: - Stream^ getStream; - - // Default constructor. - HttpConnect() - { - getStream = nullptr; - } - - // Constructor accepting stream as a parameter. - HttpConnect( Stream^ getStream ) - { - this->getStream = getStream; - } - - // Override 'GetResponseStream' method of the 'WebResponse' class. - virtual Stream^ GetResponseStream() override - { - return getStream; - } - - void ConnectHttpServer( String^ connectUri ) - { -// - // Send the data. - Encoding^ ASCII = Encoding::ASCII; - String^ requestPage = String::Concat( "GET /nhjj.htm HTTP/1.1\r\nHost: ", connectUri, "\r\nConnection: Close\r\n\r\n" ); - array^ byteGet = ASCII->GetBytes( requestPage ); - array^ recvBytes = gcnew array(256); - - // Create an 'IPEndPoint' object. - - IPHostEntry^ hostEntry = Dns::Resolve( connectUri ); - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress,80 ); - - // Create a 'Socket' object for sending data. - Socket^ connectSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // Connect to host using 'IPEndPoint' object. - - connectSocket->Connect( endPoint ); - - // Sent the 'requestPage' text to the host. - connectSocket->Send( byteGet, byteGet->Length, (SocketFlags)(0) ); - - // Receive the information sent by the server. - Int32 bytesReceived = connectSocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)(0) ); - String^ headerString = ASCII->GetString( recvBytes, 0, bytesReceived ); - - // Check whether 'status 404' is there or not in the information sent by server. - if ( headerString->IndexOf( "404" ) != -1 ) - { - bytesReceived = connectSocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)(0) ); - MemoryStream^ memoryStream = gcnew MemoryStream( recvBytes ); - getStream = (System::IO::Stream^)(memoryStream); - - // Create a 'WebResponse' object - WebResponse^ myWebResponse = (WebResponse^)(gcnew HttpConnect( getStream )); - Exception^ myException = gcnew Exception( "File Not found" ); - - // Throw the 'WebException' object with a message string, message status, InnerException and WebResponse - throw gcnew WebException( "The Requested page is not found.",myException,WebExceptionStatus::ProtocolError,myWebResponse ); - } - - connectSocket->Close(); -// - } -}; - -int main() -{ - try - { - Console::WriteLine( "Please give any Intranet Site Address (eg:manjeera.wipro.com)" ); - String^ uriConnect = Console::ReadLine(); - HttpConnect^ myHttpConnect = gcnew HttpConnect; - myHttpConnect->ConnectHttpServer( uriConnect ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe WebException is : {0}", e->Message ); - Console::WriteLine( "\nThe status of the WebException is : {0}", e->Status ); - Console::WriteLine( "\nThe Inner Exception is :' {0}'", e->InnerException ); - Console::WriteLine( "\nThe Web Response is:\n" ); - StreamReader^ readStream = gcnew StreamReader( e->Response->GetResponseStream() ); - Console::WriteLine( readStream->ReadToEnd() ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp deleted file mode 100644 index a74ca8330a13f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* This program demonstrates the S"Status" and the S"Response" property of S"WebException" class. -It tries to access an invalid site and displays the status code and status description of the -resultant exception that is raised. -*/ - -#using - -using namespace System; -using namespace System::Net; - -int main() -{ -// -// - try - { - // Create a web request for an unknown server (this raises the WebException). - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)(WebRequest::Create( "http://unknown.unknown.com" )); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)(myHttpWebRequest->GetResponse()); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "This program is expected to throw WebException on successful run." + - "\n\nException Message : " + e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code: {0}", ( (HttpWebResponse^)(e->Response) )->StatusCode ); - Console::WriteLine( "Status Description: {0}", ( (HttpWebResponse^)(e->Response) )->StatusDescription ); - } -// - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -// -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp deleted file mode 100644 index 69020651232b7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -/* This program demonstrates the S"Add" method of S"WebHeaderCollection" class. -It uses the S"Add" method of S"WebHeaderCollection" class to add the 'Accept-Language' header in the request. -The 'Accept-Language' header is used in a request to specify the language preferences of the user. The server -can use the language preferences specified to generate output for that particular language. -*/ -#using - -using namespace System; -using namespace System::Net; -void printHeaders( WebHeaderCollection^ headers ) -{ - Console::WriteLine( "Printing Headers : " ); - if ( headers->Count == 0 ) - Console::WriteLine( "\tNo Headers to Display" ); - - for ( int i = 0; i < headers->Count; i++ ) - Console::WriteLine( "\t {0} : {1}", headers->AllKeys[ i ], headers[ i ] ); -} - -int main() -{ - // - try - { - //Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - //Get the headers associated with the request. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebRequest->Headers; - Console::WriteLine( "Configuring Webrequest to accept Danish and English language using 'Add' method" ); - - //Add the Accept-Language header (for Danish) in the request. - myWebHeaderCollection->Add( "Accept-Language:da" ); - - //Include English in the Accept-Langauge header. - myWebHeaderCollection->Add( "Accept-Language:en;q=0.8" ); - - //Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - //Print the headers for the request. - printHeaders( myWebHeaderCollection ); - myHttpWebResponse->Close(); - } - //Catch exception if trying to add a restricted header. - catch ( ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is thrown. \nMessage is : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp deleted file mode 100644 index 096efbded87f8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -/* -This program demonstrate's the 'GetValues(String*)' method of 'WebHeaderCollection' class. - -The program creates a 'HttpWebRequest' Object* from the specified URL and gets the response from it. The -headers of the response is assigned to a 'WeHeaderCollection' Object* and all the values associated with -the corresponding headers in the response are displayed to the console. -*/ -#using - -using namespace System; -using namespace System::Net; -int main() -{ - try - { - // - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - myHttpWebRequest->Timeout = 1000; - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Get the headers associated with the response. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebResponse->Headers; - for ( int i = 0; i < myWebHeaderCollection->Count; i++ ) - { - String^ header = myWebHeaderCollection->GetKey( i ); - array^values = myWebHeaderCollection->GetValues( header ); - if ( values->Length > 0 ) - { - Console::WriteLine( "The values of {0} header are : ", header ); - for ( int j = 0; j < values->Length; j++ ) - Console::WriteLine( "\t {0}", values[ j ] ); - } - else - Console::WriteLine( "There is no value associated with the header" ); - } - myHttpWebResponse->Close(); - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n Exception raised : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp deleted file mode 100644 index 842da2d6a2171..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -/*This program demonstrates the S"IsRestricted" method of S"WebHeaderCollection". -It checks if the first header returned in the response is a restricted header or not. -*/ -#using - -using namespace System; -using namespace System::Net; -int main() -{ - // - try - { - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Get the headers associated with the response. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebResponse->Headers; - for ( int i = 0; i < myWebHeaderCollection->Count; i++ ) - { - // Check if the first response header is restriced. - if ( WebHeaderCollection::IsRestricted( dynamic_cast(myWebHeaderCollection->AllKeys[ i ]) ) ) - Console::WriteLine( "' {0}' is a restricted header", myWebHeaderCollection->AllKeys[ i ] ); - else - Console::WriteLine( "' {0}' is not a restricted header", myWebHeaderCollection->AllKeys[ i ] ); - } - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is thrown.\nMessage is: {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } -// -} - diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp deleted file mode 100644 index c8286d49cd483..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -/* -This program demonstrates the S"Remove" method of S"WebHeaderCollection" class. -It uses the S"Remove" method of S"WebHeaderCollection" to remove the 'Cache-Control' header from the request. -The 'Cache-Control' header is used to specify the directive that must be followed by all caching mechanisms -in the Request-Response chain. The 'no-cache' directive indicates that the caching mechanism must not resend -the cached response for a previous request with->Item[Out] validating* from the origin server (HTTP version 1.1, RFC2616, -Sec 14.9) -*/ -#using - -using namespace System; -using namespace System::Net; -void printHeaders( WebHeaderCollection^ headers ) -{ - if ( headers->Count == 0 ) - Console::WriteLine( "\tNo Headers to Display" ); - - for ( int i = 0; i < headers->Count; i++ ) - Console::WriteLine( "\t {0} : {1}", headers->AllKeys[ i ], headers[ i ] ); -} - -int main() -{ - // - try - { - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - // Get the headers associated with the request. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebRequest->Headers; - - // Set the Cache-Control header. - myWebHeaderCollection->Set( "Cache-Control", "no-cache" ); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Print the headers of the request to console. - Console::WriteLine( "Print request headers after adding Cache-Control for first request:" ); - printHeaders( myHttpWebRequest->Headers ); - - // Remove the Cache-Control header for the new request. - myWebHeaderCollection->Remove( "Cache-Control" ); - - // Get the response for the new request. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Print the headers of the new request with->Item[Out] the* Cache-Control header. - Console::WriteLine( "Print request headers after removing Cache-Control for the new request:" ); - printHeaders( myHttpWebRequest->Headers ); - myHttpWebResponse->Close(); - } - // Catch exception if trying to remove a restricted header. - catch ( ArgumentException^ e ) - { - Console::WriteLine( "Error : Trying to remove a restricted header" ); - Console::WriteLine( "ArgumentException is thrown. Message is : {0}", e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException is thrown. Message is : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } - - - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp deleted file mode 100644 index 08a56e07a73cc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -/* This program demonstrates the S"Set" method of S"WebHeaderCollection" class. -It sets the value of the 'Cache-Control' header in the request to S"no-cache". The 'Cache-Control' header -is used to specify the directive that must be followed by all caching mechanisms in the Request-Response chain. -The 'no-cache' directive indicates that the caching mechanism must not resend the cached response for a -previous request with->Item[Out] validating* from the origin server (HTTP version 1.1, RFC2616, Sec 14.9). -*/ -#using - -using namespace System; -using namespace System::Net; -void PrintHeaders( WebHeaderCollection^ headers ) -{ - Console::WriteLine( "Printing Headers : " ); - if ( headers->Count == 0 ) - Console::WriteLine( "\tNo Headers to Display" ); - - for ( int i = 0; i < headers->Count; i++ ) - Console::WriteLine( "\t {0} : {1}", headers->AllKeys[ i ], headers[ i ] ); -} - -int main() -{ - // - try - { - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - // Get the headers associated with the request. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebRequest->Headers; - - // Set the Cache-Control header in the request. - myWebHeaderCollection->Set( "Cache-Control", "no-cache" ); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - Console::WriteLine( "Headers after 'Set' method is used on Cache-Control :" ); - - // Print the headers for the request. - PrintHeaders( myWebHeaderCollection ); - myHttpWebResponse->Close(); - } - // Catch exception if trying to set a restricted header. - catch ( ArgumentException^ e ) - { - Console::WriteLine( "ArgumentException is thrown. Message is : {0}", e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException is thrown. Message is : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } - // -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp deleted file mode 100644 index f4e56ffd6bfad..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -/* -* Demonstrate how to use the WebPermissionAttribute to specify the Accept property. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - // Deny access to a specific resource by setting the Accept property. - [method:WebPermission(SecurityAction::Deny,Accept="http://www.contoso.com/Private.htm")] - - static void CheckAcceptPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Accept, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - // Pass the security check when accessing allowed resources. - CheckAcceptPermission( "http://www.contoso.com/" ); - Console::WriteLine( "Public page has passed Accept permission check" ); - - try - { - // Throw a SecurityException when trying to access not allowed resources. - CheckAcceptPermission( "http://www.contoso.com/Private.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Exception trying to access private resource: {0}", e->Message ); - } - } -// -}; - -int main() -{ - WebPermissionAttribute_AcceptConnect::demoDenySite(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp deleted file mode 100644 index 05d097162a976..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -// Demonstrate how to use the WebPermissionAttribute to specify an allowable ConnectPattern. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -// -public: - // Deny access to a specific resource by setting the ConnectPattern property. - [method:WebPermission(SecurityAction::Deny,ConnectPattern="http://www.contoso.com/")] - - void Connect() - { - // Create a Connection. - HttpWebRequest^ myWebRequest = (HttpWebRequest^)(WebRequest::Create( "http://www.contoso.com" )); - Console::WriteLine( "This line should never be printed" ); - } -// -// -}; - -int main() -{ - try - { - WebPermissionAttribute_AcceptConnect^ myWebAttrib = gcnew WebPermissionAttribute_AcceptConnect; - myWebAttrib->Connect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Security Exception raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp deleted file mode 100644 index fd594b719b182..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -/* -This program demonstrates the 'Connect' and 'Accept' properties of the class 'WebPermissionAttribute'. -The program uses declarative security for calling the code in 'Connect' method. -By using the 'Accept' and 'Connect' properties of 'WebPermissionAttribute' accept and connect access -has been given to the uri www.contoso.com. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Text::RegularExpressions; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - [method:WebPermission(SecurityAction::Deny,AcceptPattern="http://www\\.contoso\\.com/Private/.*")] - static void CheckAcceptPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Accept, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - // Passes a security check. - CheckAcceptPermission( "http://www.contoso.com/Public/page.htm" ); - Console::WriteLine( "Public page has passed Accept permission check" ); - - try - { - // Throws a SecurityException. - CheckAcceptPermission( "http://www.contoso.com/Private/page.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception: {0}", e->Message ); - } - } -// -}; - -int main() -{ - WebPermissionAttribute_AcceptConnect::demoDenySite(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp deleted file mode 100644 index d369bcc8ee1b3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::connect; - -// Demonstrate how to use the WebPermissionAttribute Connect property. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_Connect -{ -// -public: - // Set the WebPermissionAttribute Connect property. - [method:WebPermission(SecurityAction::Deny,Connect="http://www.contoso.com/Private.htm")] - - static void demoDenySite() - { - //Pass the security check. - CheckConnectPermission( "http://www.contoso.com/Public.htm" ); - Console::WriteLine( "Public page has passed connect permission check" ); - - try - { - //Throw a SecurityException. - CheckConnectPermission( "http://www.contoso.com/Private.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception {0}", e->Message ); - } - } - - static void CheckConnectPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Connect, uriToCheck ); - permissionToCheck->Demand(); - } -// -}; - -int main() -{ - WebPermissionAttribute_Connect::demoDenySite(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp deleted file mode 100644 index 648da93ee852a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Connect; - -// Demonstrate how to use the WebPermissionAttribute ConnectPattern property. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Text::RegularExpressions; - -public ref class WebPermissionAttribute_Connect -{ -// -public: - // Set the WebPermissionAttribute ConnectPattern property. - [WebPermission(SecurityAction::Deny,ConnectPattern="http://www\\.contoso\\.com/Private/.*")] - - static void CheckConnectPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Connect, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - //Pass the security check. - CheckConnectPermission( "http://www.contoso.com/Public/page.htm" ); - Console::WriteLine( "Public page has passed Connect permission check" ); - - try - { - //Throw a SecurityException. - CheckConnectPermission( "http://www.contoso.com/Private/page.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception {0}", e->Message ); - } - } -}; -// - -int main() -{ - WebPermissionAttribute_Connect::demoDenySite(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp deleted file mode 100644 index 8606c8f6c7832..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - // Set the declarative security for the URI. - [WebPermission(SecurityAction::Deny,Connect="http://www.contoso.com/")] - void Connect() - { - // Throw an exception. - try - { - HttpWebRequest^ myWebRequest = dynamic_cast(WebRequest::Create( "http://www.contoso.com/" )); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e ); - } -// - } -}; - -int main() -{ - try - { - WebPermissionAttribute_AcceptConnect^ myWebAttrib = gcnew WebPermissionAttribute_AcceptConnect; - myWebAttrib->Connect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Security Exception raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp deleted file mode 100644 index df7946668831b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp +++ /dev/null @@ -1,99 +0,0 @@ - - -// System::Net::WebPermission::ConnectList;System::Net::WebPermission::AcceptList; -/** -* This program demonstrates the use of the ConnectList and AcceptList WebPermission -* class prerties. -* It first creates a WebPermission object with Permissionstate set to None and then -* sets the Connect and Accept access right to some predefined URLs. -* The using the AcceptList and ConnectList properties it displays the URLs that have -* the Accept and Connect permission set, respectively. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class WebPermission_AcceptConnectList -{ -public: - void DisplayAcceptConnect() - { - // Create a 'WebPermission' object with permission state set to 'None'. - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Allow 'Connect' access right to first set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.contoso.com" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.alpineskihouse.com" ); - - // Allow 'Accept' access right to second set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.contoso.com" ); - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.adventure-works.com" ); - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.alpineskihouse.com" ); - - // Check whether all callers higher in the call stack have been granted the permission or not. - myWebPermission1->Demand(); - Console::WriteLine( "The Attributes, Values and Children of the 'WebPermission' object are :\n" ); - - // Display the Attributes, Values and Children of the XML encoded instance. - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - - // - // Gets all URIs with Connect permission. - IEnumerator^ myEnum = myWebPermission1->ConnectList; - Console::WriteLine( "\nThe URIs with Connect permission are :\n" ); - while ( myEnum->MoveNext() ) - { - Console::WriteLine( "\tThe URI is : {0}", myEnum->Current ); - } - // - - // - // Get all URI's with Accept permission. - IEnumerator^ myEnum1 = myWebPermission1->AcceptList; - Console::WriteLine( "\n\nThe URIs with Accept permission are :\n" ); - while ( myEnum1->MoveNext() ) - { - Console::WriteLine( "\tThe URI is : {0}", myEnum1->Current ); - } - // - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtabel. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-Attribute-\t-Value-" ); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - - Console::WriteLine(); - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : \n" ); - while ( myEnumerator1->MoveNext() ) - Console::Write( myEnumerator1->Current ); - } - -}; - -int main() -{ - try - { - WebPermission_AcceptConnectList * myWebPermission_AcceptConnectList = new WebPermission_AcceptConnectList; - myWebPermission_AcceptConnectList->DisplayAcceptConnect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp deleted file mode 100644 index 7ecf4f0e7a0ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// System::Net::WebPermission::WebPermission(NetworkAccess, Regex); - -/* -This program demonstrates the 'WebPermission(NetworkAccess, Regex)' constructor of 'WebPermission' class. -First a 'Regex' Object* is created that will accept all the urls which is having the hostfragment of -'www.contoso.com'.Then a 'WebPermission' Object* created by passing the 'NetworkAccess' permission and -'Regex' Object* as parameters. It checks the 'WebPermission' for all the url's having the host fragment -as 'www.contoso.com'. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Text::RegularExpressions; -using namespace System::Collections; - -class WebPermission_regexConstructor -{ -public: - void CreateRegexConstructor() - { -// - // Create an instance of 'Regex' that accepts all URL's containing the host - // fragment 'www.contoso.com'. - Regex^ myRegex = gcnew Regex( "http://www.contoso.com/.*" ); - - // Create a WebPermission that gives the permissions to all the hosts containing - // the same fragment. - WebPermission^ myWebPermission = gcnew WebPermission( NetworkAccess::Connect,myRegex ); - - // Checks all callers higher in the call stack have been granted the permission. - myWebPermission->Demand(); -// - - Console::WriteLine( "Attribute and Values of WebPermission are : \n" ); - // Display the Attributes, Values and Children of the XML encoded copied instance. - PrintKeysAndValues( myWebPermission->ToXml()->Attributes, myWebPermission->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-ATTRIBUTES-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "\nThe Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermission_regexConstructor * myWebPermissionRegex = new WebPermission_regexConstructor; - myWebPermissionRegex->CreateRegexConstructor(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp deleted file mode 100644 index 8b3e407874a8f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// System::Net::WebPermission::WebPermission(PermissionState);System::Net::WebPermission::Copy; - -/** -* This program demonstrates the WebPermission(PermissionState) constructor and -* Copy method of the WebPermission class . -* It creates a WebPermission instance with Permissionstate set to None and -* sets the access right to one pair of URLs. -* Then it uses the Copy method to create another instance of WebPermission class -* Finally, the attributes , values and childrens of both the XML encoded instances -* are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class CopyWebPermission -{ -public: - void CreateCopy() - { -// - // Create a WebPermission instance. - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Allow access to the first set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.microsoft.com/default.htm" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.msn.com" ); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission1->Demand(); -// - -// - // Create another WebPermission instance that is the copy of the above WebPermission instance. - WebPermission^ myWebPermission2 = (WebPermission^)(myWebPermission1->Copy()); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission2->Demand(); -// - - Console::WriteLine( "The Attributes and Values are :\n" ); - // Display the Attributes, Values and Children of the XML encoded instance. - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - Console::WriteLine( "\nCopied Instance Attributes and Values are:\n" ); - - // Display the Attributes, Values and Children of the XML encoded copied instance. - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Gets the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are: " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - CopyWebPermission^ myCopyWebPermission = gcnew CopyWebPermission; - myCopyWebPermission->CreateCopy(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp deleted file mode 100644 index ea42dec4dbce6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// System::Net::WebPermission::ToXml;System::Net::WebPermission::FromXml; - -/** -* This program shows the use of the ToXml and FromXml methods of the WebPermission class. -* It creates a WebPermission instance with the Permissionstate set to None and -* displays the attributes and the values of the XML encoded instance . -* Then a SecurityElement instance is created and it's attributes are -* set. -* Finally, using the FromXml method the WebPermission instance is reconstructed from -* the above SecurityElement instance and the attributes are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -public ref class WebPermission_FromToXml -{ -public: - void CallXml() - { -// - // Create a WebPermission without permission on the protected resource - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Create a SecurityElement by calling the ToXml method on the WebPermission - // instance and display its attributes (which hold the XML encoding of - // the WebPermission). - Console::WriteLine( "Attributes and Values of the WebPermission are:" ); - myWebPermission1->ToXml(); - - // Create another WebPermission with no permission on the protected resource - WebPermission^ myWebPermission2 = gcnew WebPermission( PermissionState::None ); - - //Converts the new WebPermission from XML using myWebPermission1. - myWebPermission2->FromXml( myWebPermission1->ToXml() ); -// - - Console::WriteLine( "The Attributes and Values of 'WebPermission' instance after reconstruction are: \n" ); - // Display the Attributes and values of the XML encoded instances. - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable ) - { - // Get the enumerator to iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } -}; - -int main() -{ - try - { - WebPermission_FromToXml^ myWebPermission_FromToXml = gcnew WebPermission_FromToXml; - myWebPermission_FromToXml->CallXml(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp deleted file mode 100644 index 692f71b9feaed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// System::Net::WebPermission::WebPermission(); -// System::Net::WebPermission->AddPermission(NetworkAccess, stringuri); -// System::Net::WebPermission::Intersect; - -/** -* This program shows the use of the WebPermission() constructor, the AddPermission, -* and Intersect' methods of the WebPermission' class. -* It first creates two WebPermission objects with no arguments, with each of them -* setting the access rights to one pair of URLs. -* Then it displays the attributes , values and childrens of the XML encoded instances. -* Finally, it creates a third WebPermission Object* using the logical intersection of the -* first two objects. It does so by using the Intersect method. -* It then displays the attributes , values and childrens of the related XML encoded -* instances. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class WebPermissionIntersect -{ -public: - void CreateIntersect() - { -// - // Create two WebPermission instances. - WebPermission^ myWebPermission1 = gcnew WebPermission; - WebPermission^ myWebPermission2 = gcnew WebPermission; - -// - // Allow access to the first set of resources. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.contoso.com/default.htm" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com/default.htm" ); - - // Check whether if the callers higher in the call stack have been granted - // access permissions. - myWebPermission1->Demand(); -// - - // Allow access right to the second set of resources. - myWebPermission2->AddPermission( NetworkAccess::Connect, "http://www.alpineskihouse.com/default.htm" ); - myWebPermission2->AddPermission( NetworkAccess::Connect, "http://www.baldwinmuseumofscience.com/default.htm" ); - myWebPermission2->Demand(); - -// - // Display the attributes , values and childrens of the XML encoded instances. - Console::WriteLine( "Attributes and values of first 'WebPermission' instance are :" ); - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - - Console::WriteLine( "\nAttributes and values of second 'WebPermission' instance are : " ); - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - -// - // Create a third WebPermission instance via the logical intersection of the previous - // two WebPermission instances. - WebPermission^ myWebPermission3 = (WebPermission^)(myWebPermission1->Intersect( myWebPermission2 )); - - Console::WriteLine( "\nAttributes and Values of the WebPermission instance after the Intersect are:\n" ); - Console::WriteLine( myWebPermission3->ToXml() ); -// - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionIntersect * myWebPermissionIntersect = new WebPermissionIntersect; - myWebPermissionIntersect->CreateIntersect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp deleted file mode 100644 index b2aed826d7b53..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// System::Net::WebPermission->AddPermission(NetworkAccess, regex); -// System::Net::WebPermission::IsSubsetOf; - -/** -* This program shows how to use the AddPermission(NetworkAccess, regex) and -* IsSubset methods of WebPermission class. -* It creates two WebPermission instances with the Connect access rights for the -* specified URIs. -* For the first WebPermission instance, a Connect access right is given to the -* URLs with the host fragment www.microsoft.com. This is done by using -* the AddPermission(NetworkAccess, regex) method. -* Then, a third WebPermission instance is created with the Connect access right to -* the URLs of the first and second WebPermission instances. -* Finally, the attributes, values and children of that instance are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -using namespace System::Text::RegularExpressions; - -class WebPermissionIsSubset -{ -public: - void CheckSubset() - { -// - // Create a WebPermission. - WebPermission^ myWebPermission1 = gcnew WebPermission; - - // Allow Connect access to the specified URLs. - myWebPermission1->AddPermission( NetworkAccess::Connect, gcnew Regex( "http://www\\.contoso\\.com/.*", - (RegexOptions)(RegexOptions::Compiled | RegexOptions::IgnoreCase | RegexOptions::Singleline) ) ); - - myWebPermission1->Demand(); -// - - // Create another WebPermission with the specified URL. - WebPermission^ myWebPermission2 = gcnew WebPermission( NetworkAccess::Connect,"http://www.contoso.com" ); - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission2->Demand(); - -// - WebPermission^ myWebPermission3 = nullptr; - - // Check which permissions have the Connect access to more number of URLs. - if ( myWebPermission2->IsSubsetOf( myWebPermission1 ) ) - { - Console::WriteLine( "\n WebPermission2 is the Subset of WebPermission1\n" ); - myWebPermission3 = myWebPermission1; - } - else if ( myWebPermission1->IsSubsetOf( myWebPermission2 ) ) - { - Console::WriteLine( "\n WebPermission1 is the Subset of WebPermission2" ); - myWebPermission3 = myWebPermission2; - } - else - { - // Create the third permission. - myWebPermission3 = (WebPermission^)(myWebPermission1->Union( myWebPermission2 )); - } -// - - // Prints the attributes, values and children of XML encoded instances. - Console::WriteLine( "\nAttributes and Values of third WebPermission instance are : " ); - PrintKeysAndValues( myWebPermission3->ToXml()->Attributes, myWebPermission3->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionIsSubset * myWebPermissionIsSubset = new WebPermissionIsSubset; - myWebPermissionIsSubset->CheckSubset(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp deleted file mode 100644 index 5f132c99a7c7c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// System::Net::WebPermission->AddPermission(NetworkAccess, regex);System::Net::WebPermission::IsSubsetOf; - -/** -* This program shows the use of the AddPermission(NetworkAccess, regex) and -* IsSubset methods of the WebPermission class. -* It creates two WebPermission instances with the Connect access rights for the specified -* URIs. The second URI being a subset of the first one. -* Then the IsSubsetOf method is called to verify that the second URI is indeed a subset -* of the firts one. The result of the call to the IsSubsetOf is then displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -using namespace System::Text::RegularExpressions; - -static void myIsSubsetExample() -{ -// - // Create the target permission. - WebPermission^ targetPermission = gcnew WebPermission; - targetPermission->AddPermission( NetworkAccess::Connect, gcnew Regex( "www\\.contoso\\.com/Public/.*" ) ); - - // Create the permission for a URI matching target. - WebPermission^ connectPermission = gcnew WebPermission; - connectPermission->AddPermission( NetworkAccess::Connect, "www.contoso.com/Public/default.htm" ); - - //The following statement prints true. - Console::WriteLine( "Is the second URI a subset of the first one?: {0}", connectPermission->IsSubsetOf( targetPermission ) ); -// -} - -int main() -{ - // Verify that the second URI is a subset of the first one. - myIsSubsetExample(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp deleted file mode 100644 index ccc6b05561465..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Text::RegularExpressions; -using namespace System::Collections; - -void MySample() -{ -// - // Create a Regex that accepts all URLs containing the host fragment www.contoso.com. - Regex^ myRegex = gcnew Regex( "http://www\\.contoso\\.com/.*" ); - - // Create a WebPermission that gives permissions to all the hosts containing the same host fragment. - WebPermission^ myWebPermission = gcnew WebPermission( NetworkAccess::Connect,myRegex ); - - //Add connect privileges for a www.adventure-works.com. - myWebPermission->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com" ); - - //Add accept privileges for www.alpineskihouse.com. - myWebPermission->AddPermission( NetworkAccess::Accept, "http://www.alpineskihouse.com/" ); - - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission->Demand(); - - // Get all the URIs with Connect permission. - IEnumerator^ myConnectEnum = myWebPermission->ConnectList; - Console::WriteLine( "\nThe 'URIs' with 'Connect' permission are :\n" ); - while ( myConnectEnum->MoveNext() ) - { - Console::WriteLine( "\t{0}", myConnectEnum->Current ); - } - - // Get all the URIs with Accept permission. - IEnumerator^ myAcceptEnum = myWebPermission->AcceptList; - Console::WriteLine( "\n\nThe 'URIs' with 'Accept' permission is :\n" ); - - while ( myAcceptEnum->MoveNext() ) - { - Console::WriteLine( "\t{0}", myAcceptEnum->Current ); - } -// -} - -int main() -{ - MySample(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp deleted file mode 100644 index 9610688f60842..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// System::Net::WebPermission::WebPermission(NetworkAccess, uriString);System::Net::WebPermission::Union; - -/** -* This program shows the use of the WebPermission(NetworkAccess access, String* uriString) -* constructor and Union method of the WebPermission' class. -* It creates two instance of the WebPermission class with the specified access -* rights to the predefined URIs. -* It displays the attributes , values and childrens of those XML encoded -* instances. -* Then, using the Union method, it creates a third WebPermission instance -* via a logical union of the first two. -* Finally, it displays the attributes , values and childrens of those XML encoded -* instances. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class WebPermissionUnion -{ -public: - void CreateUnion() - { -// - // Create a WebPermission::instance. - WebPermission^ myWebPermission1 = gcnew WebPermission( NetworkAccess::Connect,"http://www.contoso.com/default.htm" ); - myWebPermission1->Demand(); -// - - // Create another WebPermission instance. - WebPermission^ myWebPermission2 = gcnew WebPermission( NetworkAccess::Connect,"http://www.adventure-works.com" ); - myWebPermission2->Demand(); - - // Print the attributes, values and childrens of the XML encoded instances. - Console::WriteLine( "Attributes and values of the first WebPermission are : " ); - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - - Console::WriteLine( "\nAttributes and values of the second WebPermission are : " ); - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - -// - // Create another WebPermission that is the Union of previous two WebPermission - // instances. - WebPermission^ myWebPermission3 = (WebPermission^)(myWebPermission1->Union( myWebPermission2 )); - Console::WriteLine( "\nAttributes and values of the WebPermission after the Union are : " ); - // Display the attributes, values and children. - Console::WriteLine( myWebPermission3->ToXml() ); -// - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - - Console::WriteLine(); - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionUnion^ myWebPermissionUnion = gcnew WebPermissionUnion; - myWebPermissionUnion->CreateUnion(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp deleted file mode 100644 index c6e380e0a44f1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp +++ /dev/null @@ -1,92 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -public ref class RequestState -{ -public: - - // This class stores the request state of the request. - WebRequest^ request; - RequestState() - { - request = nullptr; - } - -}; - -ref class WebRequest_BeginGetRequeststream -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void ReadCallback( IAsyncResult^ asynchronousResult ) - { - RequestState^ myRequestState = dynamic_cast(asynchronousResult->AsyncState); - WebRequest^ myWebRequest = myRequestState->request; - - // End of the Asynchronus request. - Stream^ streamResponse = myWebRequest->EndGetRequestStream( asynchronousResult ); - - // Create a string that is to be posted to the uri. - Console::WriteLine( "Please enter a string to be posted:" ); - String^ postData = Console::ReadLine(); - - // Convert the string into a Byte array. - array^byteArray = Encoding::UTF8->GetBytes( postData ); - - // Write data to the stream. - streamResponse->Write( byteArray, 0, postData->Length ); - streamResponse->Close(); - allDone->Set(); - } - -}; - -int main() -{ - - // - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Create an instance of the RequestState and assign 'myWebRequest' to its request field. - RequestState^ myRequestState = gcnew RequestState; - myRequestState->request = myWebRequest; - myWebRequest->ContentType = "application/x-www-form-urlencoded"; - - // Set the 'Method' prperty to 'POST' to post data to a Uri. - myRequestState->request->Method = "POST"; - - // - // Start the Asynchronous 'BeginGetRequestStream' method call. - IAsyncResult^ r = dynamic_cast(myWebRequest->BeginGetRequestStream( gcnew AsyncCallback( WebRequest_BeginGetRequeststream::ReadCallback ), myRequestState )); - WebRequest_BeginGetRequeststream::allDone->WaitOne(); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - Console::WriteLine( "The String* entered has been posted." ); - Console::WriteLine( "Please wait for the response..." ); - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "The contents of the HTML page are " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myWebResponse->Close(); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetResponse/CPP/webrequest_begingetresponse.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetResponse/CPP/webrequest_begingetresponse.cpp deleted file mode 100644 index f9ea0d0ee1580..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetResponse/CPP/webrequest_begingetresponse.cpp +++ /dev/null @@ -1,173 +0,0 @@ - - -// System::Net::WebRequest::BeginGetResponse System::Net::WebRequest::EndGetResponse -/* -* This program demonstrates BeginGetResponse and EndGetResponse methods of -* WebRequest Class::A new WebRequest object is created to the mentioned Uri. -* An Asynchronous call is started for response from the Uri using BeginGetResponse -* method of WebRequest class. -* The asynchronous response is ended by the EndGetResponse method of the -* WebRequest class. The page at the requested Uri is finally displayed. -*/ -// -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -public ref class RequestState -{ -private: - - // This class stores the state of the request. - literal int BUFFER_SIZE = 1024; - -public: - StringBuilder^ requestData; - array^bufferRead; - WebRequest^ request; - WebResponse^ response; - Stream^ responseStream; - RequestState() - { - bufferRead = gcnew array(BUFFER_SIZE); - requestData = gcnew StringBuilder( "" ); - request = nullptr; - responseStream = nullptr; - } - -}; - -ref class WebRequest_BeginGetResponse -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - literal int BUFFER_SIZE = 1024; - static void RespCallback( IAsyncResult^ asynchronousResult ) - { - try - { - - // Set the State of request to asynchronous. - RequestState^ myRequestState = dynamic_cast(asynchronousResult->AsyncState); - WebRequest^ myWebRequest1 = myRequestState->request; - - // End the Asynchronous response. - myRequestState->response = myWebRequest1->EndGetResponse( asynchronousResult ); - - // Read the response into a 'Stream' object. - Stream^ responseStream = myRequestState->response->GetResponseStream(); - myRequestState->responseStream = responseStream; - - // Begin the reading of the contents of the HTML page and print it to the console. - IAsyncResult^ asynchronousResultRead = responseStream->BeginRead( myRequestState->bufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - - } - - static void ReadCallBack( IAsyncResult^ asyncResult ) - { - try - { - - // Result state is set to AsyncState. - RequestState^ myRequestState = dynamic_cast(asyncResult->AsyncState); - Stream^ responseStream = myRequestState->responseStream; - int read = responseStream->EndRead( asyncResult ); - - // Read the contents of the HTML page and then print to the console. - if ( read > 0 ) - { - myRequestState->requestData->Append( Encoding::ASCII->GetString( myRequestState->bufferRead, 0, read ) ); - IAsyncResult^ asynchronousResult = responseStream->BeginRead( myRequestState->bufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - } - else - { - Console::WriteLine( "\nThe HTML page Contents are: " ); - if ( myRequestState->requestData->Length > 1 ) - { - String^ sringContent; - sringContent = myRequestState->requestData->ToString(); - Console::WriteLine( sringContent ); - } - Console::WriteLine( "\nPress 'Enter' key to continue........" ); - responseStream->Close(); - allDone->Set(); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - - } - -}; - -int main() -{ - try - { - - // Create a new webrequest to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Please, set the proxy to a correct value. - WebProxy^ proxy = gcnew WebProxy( "myproxy:80" ); - proxy->Credentials = gcnew NetworkCredential( "srikun","simrin123" ); - myWebRequest->Proxy = proxy; - - // Create a new instance of the RequestState. - RequestState^ myRequestState = gcnew RequestState; - - // The 'WebRequest' object is associated to the 'RequestState' object. - myRequestState->request = myWebRequest; - - // Start the Asynchronous call for response. - IAsyncResult^ asyncResult = dynamic_cast(myWebRequest->BeginGetResponse( gcnew AsyncCallback( WebRequest_BeginGetResponse::RespCallback ), myRequestState )); - WebRequest_BeginGetResponse::allDone->WaitOne(); - - // Release the WebResponse resource. - myRequestState->response->Close(); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp deleted file mode 100644 index c42e50f8358ff..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* System::Net::WebRequest::ContentType System::Net::WebRequest::ContentLength System::Net::WebRequest::GetRequestStream -This program demonstrates 'GetRequestStream' method , 'ContentLength' and 'ContentType' properties of - 'WebRequestClass'. -A new 'WebRequest' Object* is created and the method used for sending data is set to 'POST' method by setting -The 'Method' property to 'POST'.The 'ContentType' property is set to 'application/x-www-form-urlencoded'. -The 'ContentLength' property is set to the length of the Byte stream to be posted. A new 'Stream' Object* is -obtained from the 'GetRequestStream' method of the 'WebRequest' class.Data to be posted is requested from -the user and is posted using the stream Object*.The HTML contents of the page are then displayed to the -console after the Posted data is accepted by the URL. - -Note: This program POSTs data to the Uri: http://www20.Brinkster::com/codesnippets/next.asp -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// -// -// - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com " ); - - // Set the 'Method' property of the myWebrequest to POST. - myWebRequest->Method = "POST"; - - // Create a new string object to POST data to the above url. - Console::WriteLine( "\nThe value of 'ContentLength' property before sending the data is {0}", myWebRequest->ContentLength ); - Console::WriteLine( "\nPlease enter the data to be posted to (http://www.contoso.com/codesnippets/next.asp) Uri" ); - String^ inputData = Console::ReadLine(); - String^ postData = String::Concat( "firstone= ", inputData ); - ASCIIEncoding^ encoding = gcnew ASCIIEncoding; - array^ byteArray = encoding->GetBytes( postData ); - -// - // Set the 'ContentType' property of the WebRequest. - myWebRequest->ContentType = "application/x-www-form-urlencoded"; - - // Set the 'ContentLength' property of the WebRequest. - myWebRequest->ContentLength = byteArray->Length; - Stream^ newStream = myWebRequest->GetRequestStream(); - newStream->Write( byteArray, 0, byteArray->Length ); - - // Close the Stream object. - newStream->Close(); - - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// -// -// -// - - Console::WriteLine( "\nThe value of ContentLength property after sending the data is {0}", myWebRequest->ContentLength ); - Console::WriteLine( "\nThe String* entered has been succesfully posted to the Uri." ); - Console::WriteLine( "\nPlease wait for the response......." ); - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - - // Release the resources of response Object*. - myWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' Key to Continue........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp deleted file mode 100644 index ff1aa9ebfe6c7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*System::Net::WebRequest::Create(Uri) - -This program demonstrates the 'Create(Uri)' method of the 'WebRequest' class. -A new 'Uri' object is created to the specified Uri. -A new 'WebRequest' object is created to the 'specified' Uri by passing the 'Uri' object as parameter. -The response is obtained . -The HTML contents of the page of the requested Uri are displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'Uri' object with the specified string. - Uri^ myUri = gcnew Uri( "http://www.contoso.com" ); - // Create a new request to the above mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( myUri ); - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// - - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML Page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the WebResponse Resource. - myWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' key to continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Headers/CPP/webrequest_headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Headers/CPP/webrequest_headers.cpp deleted file mode 100644 index 39527d5bcdde3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Headers/CPP/webrequest_headers.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*System::Net::WebRequest::Headers -* This program demonstrates the 'Headers' property of 'WebRequest' Class. -A new 'WebRequest' Object* is created.The (name, value) collection of the HTTP Headers are displayed to the -console.The contents of the HTML page of the requested URI are displayed to the console. */ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Release the resources of response object. - myWebResponse->Close(); - Console::WriteLine( "\nThe HttpHeaders are \n {0}", myWebRequest->Headers ); -// - - Console::WriteLine( "\nPress Enter Key to Continue........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_PreAuthenticate/CPP/webrequest_preauthenticate.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_PreAuthenticate/CPP/webrequest_preauthenticate.cpp deleted file mode 100644 index 1776e52a3d1ea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_PreAuthenticate/CPP/webrequest_preauthenticate.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* -System::Net::WebRequest::PreAuthenticate, System::Net::WebRequest::Credentials -This program demonstrates the 'PreAuthenticate' and 'NetworkCredential' properties of the WebRequest Class. -The PreAuthenticate Property has a default value set to False. -This is set to True and new NetwrokCredential object is created with UserName and Password. -This NetworkCredential Object associated to the WebRequest Object to be able to authenticate the requested Uri -To check the validity of this program, please try with some authenticated sites with appropriate credentials -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// -// - // Create a new webrequest to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( url ); - - // Set 'Preauthenticate' property to true. Credentials will be sent with the request. - myWebRequest->PreAuthenticate = true; - - Console::WriteLine( "\nPlease enter your credentials for the requested Url" ); - Console::WriteLine( "UserName" ); - String^ UserName = Console::ReadLine(); - Console::WriteLine( "Password" ); - String^ Password = Console::ReadLine(); - - // Create a New 'NetworkCredential' object. - NetworkCredential^ networkCredential = gcnew NetworkCredential( UserName,Password ); - - // Associate the 'NetworkCredential' object with the 'WebRequest' object. - myWebRequest->Credentials = networkCredential; - - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// -// - - // Read the 'Response' into a Stream object and then print to the console. - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html page of the requested Uri are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is raised. " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException is raised. " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } - -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the url which requires authentication as command line parameter" ); - Console::WriteLine( "Example:WebRequest_PreAuthenticate http://www.microsoft.com" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "\nPress any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Proxy/CPP/webrequest_proxy.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Proxy/CPP/webrequest_proxy.cpp deleted file mode 100644 index 6781c2fe11402..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Proxy/CPP/webrequest_proxy.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*System::Net::WebRequest::Proxy -This program demonstrates the 'Proxy' property of the 'WebRequest' class. -A WebRequest Object* is created and a new Proxy Object is created. -The Proxy Object is assigned the 'Proxy' Property of the WebRequest Object and then printed to the console, this is the default Proxy setting. -New Proxy address and the credentials are requested from the User. -A new Proxy Object* is then constructed from the inputs. -Then the 'Proxy' property of the request is associated with the new Proxy Object* constructed*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - WebProxy^ myProxy = gcnew WebProxy; - // Obtain the Proxy Prperty of the Default browser. - myProxy = (WebProxy^)(myWebRequest->Proxy); - - // Print myProxy address to the console. - Console::WriteLine( "\nThe actual default Proxy settings are {0}", myProxy->Address ); - try - { - Console::WriteLine( "\nPlease enter the new Proxy Address to be set " ); - Console::WriteLine( "The format of the address should be http://proxyUriAddress:portaddress" ); - Console::WriteLine( "Example:http://proxyadress.com:8080" ); - String^ proxyAddress; - proxyAddress = Console::ReadLine(); - - if ( proxyAddress->Length == 0 ) - { - myWebRequest->Proxy = myProxy; - } - else - { - Console::WriteLine( "\nPlease enter the Credentials" ); - Console::WriteLine( "Username:" ); - String^ username; - username = Console::ReadLine(); - Console::WriteLine( "\nPassword:" ); - String^ password; - password = Console::ReadLine(); - - // Create a new Uri object. - Uri^ newUri = gcnew Uri( proxyAddress ); - - // Associate the new Uri object to the myProxy object. - myProxy->Address = newUri; - - // Create a NetworkCredential object and is assign to the Credentials - // property of the Proxy object. - myProxy->Credentials = gcnew NetworkCredential( username,password ); - myWebRequest->Proxy = myProxy; - } - Console::WriteLine( "\nThe Address of the new Proxy settings are {0}", myProxy->Address ); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Print the HTML contents of the page to the console. - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html pages are :" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - - // Close the Stream object. - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myWebResponse->Close(); - Console::WriteLine( "\nPress any key to continue........." ); - Console::Read(); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "\nUriFormatException is thrown->Message is {0}", e->Message ); - Console::WriteLine( "\nThe format of the myProxy address you entered is invalid" ); - Console::WriteLine( "\nPress any key to continue........." ); - Console::Read(); - } -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is raised. " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException is raised. " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp deleted file mode 100644 index f763b367eb0c5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*System::Net::WebRequest::RequestUri -* This program demonstrates the 'RequestUri' property of the 'WebRequest' Class -Here the 'RequestUri' property displays the request Uri name to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new WebRequest object to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - Console::WriteLine( "\nThe Uri requested is {0}", myWebRequest->RequestUri); - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - // Get the stream containing content returned by the server. - Stream^ streamResponse = myWebResponse->GetResponseStream(); - Console::WriteLine("\nThe Uri that responded to the request is '{0}'",myWebResponse->ResponseUri); - StreamReader^ reader = gcnew StreamReader(streamResponse); - // Read the content. - String^ responseFromServer = reader->ReadToEnd(); - // Display the content. - Console::WriteLine("\nThe HTML Contents received:"); - Console::WriteLine (responseFromServer); - // Cleanup the streams and the response. - reader->Close(); - streamResponse->Close(); - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine("\nWebException is raised. "); - Console::WriteLine("\nThe Error Message is {0} ", e->Message); - Console::WriteLine("\nStatus: {0}", e->Status); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException is raised " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp deleted file mode 100644 index 519c8be578ec3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*System::Net::WebRequest::Time->Item[Out] ** This program demonstrates the 'Timeout' property of the WebRequest Class. -A new 'WebRequest' Object* is created .The default value of the 'Timeout' property is printed to the console. -It is then set to a value and displayed to the console. If the 'Timeout' property is set to a value less than -the time required to get the response an Exception is raised.'Timeout' property measures the time in -Milliseconds. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new WebRequest Object to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - Console::WriteLine( "\nThe Timeout time of the request before setting is : {0} milliseconds", myWebRequest->Timeout ); - - // Set the 'Timeout' property in Milliseconds. - myWebRequest->Timeout = 10000; - - // This request will throw a WebException if it reaches the timeout limit - // before it is able to fetch the resource. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// - - // Print the Timeout time to the console. - Console::WriteLine( "\nThe Time->Item[Out] time* of the request after setting the time is : {0} milliseconds", myWebRequest->Timeout ); - Console::WriteLine( "\nPress any Key to Continue..........." ); - Console::Read(); - // Print the HTML contents of the page to the console. - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html page of the requested Url are :" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myWebResponse->Close(); - Console::WriteLine( "\nPress any Key to Continue..........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is raised " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException is raised " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp deleted file mode 100644 index b8b8c49e8675b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Net::WebResponse::Close -/*This program demonstrates the 'Close' method of 'WebResponse' Class. -It takes an URL from console and creates a 'WebRequest' Object* for the Url::It then gets back -the response Object* from the Url. The response Object* can be processed as desired. -The program then closes the response Object* and releases resources associated with it. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response here. - Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." ); - // Release resources of response Object*. - myWebResponse->Close(); - Console::WriteLine( "\nResponse Stream successfully closed" ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised::Status is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the Url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_Close http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp deleted file mode 100644 index 8e70c11388632..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System::Net::WebResponse::ContentLength;System::Net::WebResponse::ContentType - -/* This program demonstrates the 'ContentLength' and 'ContentType' property of 'WebResponse' class -It creates a web request and queries for a response.It then prints the content length and content type -of the entity body in the response onto the console */ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// -// - // Create a 'WebRequest' with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Display the content length and content type received as headers in the response object. - Console::WriteLine( "\nContent length : {0}, Content Type : {1}", myWebResponse->ContentLength, myWebResponse->ContentType ); - - // Release resources of response object. - myWebResponse->Close(); -// -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised. Status is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_ContentLength_Type http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp deleted file mode 100644 index b1e2cd254c7e3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// System::Net::WebResponse::GetResponseStream - -/* This program demonstrates the 'GetResponseStream' method of the 'WebResponse' class. -It creates a web request and queries for a response. It then gets the response stream . This response stream -is piped to a higher level stream reader. The reader reads 256 characters at a time , writes them into a String* and then displays the String* in the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void getPage( String^ url ) -{ - try - { -// - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Obtain a 'Stream' object associated with the response object. - Stream^ ReceiveStream = myWebResponse->GetResponseStream(); - - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - - // Pipe the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( ReceiveStream,encode ); - Console::WriteLine( "\nResponse stream received" ); - array^ read = gcnew array(256); - - // Read 256 charcters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "HTML...\r\n" ); - - while ( count > 0 ) - { - // Dump the 256 characters on a string and display the string onto the console. - String^ str = gcnew String( read,0,count ); - Console::Write( str ); - count = readStream->Read( read, 0, 256 ); - } - - Console::WriteLine( "" ); - // Release the resources of stream object. - readStream->Close(); - - // Release the resources of response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised::Status is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_GetResponseStream http://dotnet.microsoft.com/" ); - } - else - { - getPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp deleted file mode 100644 index 22e623e03213f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// System::Net::WebResponse::Headers -/* This program demonstrates the 'Headers' property of the 'WebResponse' class. -It creates a web request and queries for a response.It then prints out all the response -headers (name -value pairs) onto the console */ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { - // - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Display all the Headers present in the response received from the URl. - Console::WriteLine( "\nThe following headers were received in the response" ); - - // Display each header and its key , associated with the response object. - for ( int i = 0; i < myWebResponse->Headers->Count; ++i ) - Console::WriteLine( "\nHeader Name: {0}, Header value : {1}", myWebResponse->Headers->Keys[ i ], myWebResponse->Headers[ i ] ); - - // Release resources of response object. - myWebResponse->Close(); - - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised::Status is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised.Message is : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the Url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_Headers http://dotnet.microsoft.com/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp deleted file mode 100644 index 05f3759415e3e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Net::WebResponse::ResponseUri - -/* This program demonstrates the 'ResponseUri' property of the 'WebResponse' class -It creates a web request and queries for a response.It then compares the ResponseUri value to the actual Url -value to see if the original request was redirected*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ ourUri = gcnew Uri( url ); - - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Use "ResponseUri" property to get the actual Uri from where the response was attained. - if ( ourUri->Equals( myWebResponse->ResponseUri ) ) - { - Console::WriteLine( "\nRequest Url : {0} was not redirected", url ); - } - else - { - Console::WriteLine( "\nRequest Url : {0} was redirected to {1}", url, myWebResponse->ResponseUri ); - } - - // Release resources of response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is raised->Status is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the Url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_ResponseUri http://www.microsoft.com" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebServices_Description_Importer/CPP/import.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebServices_Description_Importer/CPP/import.cpp deleted file mode 100644 index 624ea9b6f2ed0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebServices_Description_Importer/CPP/import.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Get a WSDL file describing a service. - ServiceDescription^ description = ServiceDescription::Read( "service.wsdl" ); - - // - // Initialize a service description importer. - ServiceDescriptionImporter^ importer = gcnew ServiceDescriptionImporter; - importer->ProtocolName = "Soap12"; // Use SOAP 1.2. - importer->AddServiceDescription( description, nullptr, nullptr ); - // - - // - // Report on the service descriptions. - Console::WriteLine( "Importing {0} service descriptions with {1} associated schemas.", importer->ServiceDescriptions->Count, importer->Schemas->Count ); - // - - // - // Generate a proxy client. - importer->Style = ServiceDescriptionImportStyle::Client; - // - - // - // Generate properties to represent primitive values. - importer->CodeGenerationOptions = System::Xml::Serialization::CodeGenerationOptions::GenerateProperties; - // - - // Initialize a Code-DOM tree into which we will import the service. - CodeNamespace^ nmspace = gcnew CodeNamespace; - CodeCompileUnit^ unit = gcnew CodeCompileUnit; - unit->Namespaces->Add( nmspace ); - - // - // Import the service into the Code-DOM tree. This creates proxy code - // that uses the service. - ServiceDescriptionImportWarnings warning = importer->Import(nmspace,unit); - if ( warning == (ServiceDescriptionImportWarnings)0 ) - { - // Generate and print the proxy code in C#. - CodeDomProvider^ provider = CodeDomProvider::CreateProvider( "CSharp" ); - ICodeGenerator^ generator = provider->CreateGenerator(); - generator->GenerateCodeFromCompileUnit( unit, Console::Out, gcnew CodeGeneratorOptions ); - } - else - { - // Print an error message. - Console::WriteLine( warning ); - } - // -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WebServices_HttpBinding/CPP/httpbinding.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WebServices_HttpBinding/CPP/httpbinding.cpp deleted file mode 100644 index 4d69d267acb71..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WebServices_HttpBinding/CPP/httpbinding.cpp +++ /dev/null @@ -1,151 +0,0 @@ - - -//System.Web.Services.HttpBinding;System.Web.Services.HttpBinding.Verb; -//System.Web.Services.HttpAddressBinding; -//System.Web.Services.HttpAddressBinding.Location; -/* - The following example demonstrates the 'HttpBinding()' constructor - and 'Verb' property of class 'HttpBinding' and 'HttpAddressBinding() - 'constructor and 'Location' property of class 'HttpAddressBinding'. - It creates a 'ServiceDescription' instance by using the - static read method of 'ServiceDescription' by passing the - 'AddNumbers1.wsdl' name as an argument.It creates a 'Binding' - object and adds that binding object to 'ServiceDescription'. - It adds the 'PortType',Messages to the 'ServiceDescription' object. - Finally it writes the 'ServiceDescrption' as a WSDL file with name - 'AddNumbers.wsdl. - */ -#using -#using -#using - -using namespace System; -using namespace System::Web::Services::Description; -using namespace System::Collections; -using namespace System::Xml; - -int main() -{ - ServiceDescription^ myDescription = ServiceDescription::Read( "AddNumbers1.wsdl" ); - - // Create the 'Binding' object. - Binding^ myBinding = gcnew Binding; - myBinding->Name = "Service1HttpPost"; - XmlQualifiedName^ qualifiedName = gcnew XmlQualifiedName( "s0:Service1HttpPost" ); - myBinding->Type = qualifiedName; - - // - // - // Create the 'HttpBinding' object. - HttpBinding^ myHttpBinding = gcnew HttpBinding; - myHttpBinding->Verb = "POST"; - - // Add the 'HttpBinding' to the 'Binding'. - myBinding->Extensions->Add( myHttpBinding ); - // - // - - // Create the 'OperationBinding' object. - OperationBinding^ myOperationBinding = gcnew OperationBinding; - myOperationBinding->Name = "AddNumbers"; - HttpOperationBinding^ myOperation = gcnew HttpOperationBinding; - myOperation->Location = "/AddNumbers"; - - // Add the 'HttpOperationBinding' to 'OperationBinding'. - myOperationBinding->Extensions->Add( myOperation ); - - // Create the 'InputBinding' object. - InputBinding^ myInput = gcnew InputBinding; - MimeContentBinding^ postMimeContentbinding = gcnew MimeContentBinding; - postMimeContentbinding->Type = "application/x-www-form-urlencoded"; - myInput->Extensions->Add( postMimeContentbinding ); - - // Add the 'InputBinding' to 'OperationBinding'. - myOperationBinding->Input = myInput; - - // Create the 'OutputBinding' object. - OutputBinding^ myOutput = gcnew OutputBinding; - MimeXmlBinding^ postMimeXmlbinding = gcnew MimeXmlBinding; - postMimeXmlbinding->Part = "Body"; - myOutput->Extensions->Add( postMimeXmlbinding ); - - // Add the 'OutPutBinding' to 'OperationBinding'. - myOperationBinding->Output = myOutput; - - // Add the 'OperationBinding' to 'Binding'. - myBinding->Operations->Add( myOperationBinding ); - - // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. - myDescription->Bindings->Add( myBinding ); - - // Create a 'Port' object. - Port^ postPort = gcnew Port; - postPort->Name = "Service1HttpPost"; - postPort->Binding = gcnew XmlQualifiedName( "s0:Service1HttpPost" ); - - // - // - // Create the 'HttpAddressBinding' object. - HttpAddressBinding^ postAddressBinding = gcnew HttpAddressBinding; - postAddressBinding->Location = "http://localhost/Service1.asmx"; - - // Add the 'HttpAddressBinding' to the 'Port'. - postPort->Extensions->Add( postAddressBinding ); - // - // - - // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. - myDescription->Services[ 0 ]->Ports->Add( postPort ); - - // Create a 'PortType' object. - PortType^ postPortType = gcnew PortType; - postPortType->Name = "Service1HttpPost"; - Operation^ postOperation = gcnew Operation; - postOperation->Name = "AddNumbers"; - OperationMessage^ postInput = dynamic_cast(gcnew OperationInput); - postInput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostIn" ); - OperationMessage^ postOutput = dynamic_cast(gcnew OperationOutput); - postOutput->Message = gcnew XmlQualifiedName( "s0:AddNumbersHttpPostOut" ); - postOperation->Messages->Add( postInput ); - postOperation->Messages->Add( postOutput ); - - // Add the 'Operation' to 'PortType'. - postPortType->Operations->Add( postOperation ); - - // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. - myDescription->PortTypes->Add( postPortType ); - - // Create the 'Message' object. - Message^ postMessage1 = gcnew Message; - postMessage1->Name = "AddNumbersHttpPostIn"; - - // Create the 'MessageParts'. - MessagePart^ postMessagePart1 = gcnew MessagePart; - postMessagePart1->Name = "firstnumber"; - postMessagePart1->Type = gcnew XmlQualifiedName( "s:string" ); - MessagePart^ postMessagePart2 = gcnew MessagePart; - postMessagePart2->Name = "secondnumber"; - postMessagePart2->Type = gcnew XmlQualifiedName( "s:string" ); - - // Add the 'MessagePart' objects to 'Messages'. - postMessage1->Parts->Add( postMessagePart1 ); - postMessage1->Parts->Add( postMessagePart2 ); - - // Create another 'Message' object. - Message^ postMessage2 = gcnew Message; - postMessage2->Name = "AddNumbersHttpPostOut"; - MessagePart^ postMessagePart3 = gcnew MessagePart; - postMessagePart3->Name = "Body"; - postMessagePart3->Element = gcnew XmlQualifiedName( "s0:int" ); - - // Add the 'MessagePart' to 'Message' - postMessage2->Parts->Add( postMessagePart3 ); - - // Add the 'Message' objects to 'ServiceDescription'. - myDescription->Messages->Add( postMessage1 ); - myDescription->Messages->Add( postMessage2 ); - - // Write the 'ServiceDescription' as a WSDL file. - myDescription->Write( "AddNumbers.wsdl" ); - Console::WriteLine( "WSDL file with name 'AddNumber.Wsdl' file created Successfully" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/WellKnownClientTypeEntry_Server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/WellKnownClientTypeEntry_Server.cpp deleted file mode 100644 index 9888745c042c9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/WellKnownClientTypeEntry_Server.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// This is the server program for the 'WellKnownClientTypeEntry_Client.cpp' program. - -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; - -using namespace System::Runtime::Remoting::Channels::Http; - -public ref class MyServer -{ -public: - static void Run() - { - ChannelServices::RegisterChannel(gcnew HttpChannel(8086)); - // Record the 'HelloServer' type as 'Singleton' well-known type. - WellKnownServiceTypeEntry^ myWellKnownServiceTypeEntry= - gcnew WellKnownServiceTypeEntry(HelloServer::typeid, - "SayHello", - WellKnownObjectMode::Singleton); - RemotingConfiguration::RegisterWellKnownServiceType( - myWellKnownServiceTypeEntry); - Console::WriteLine("Started the Server, Hit to exit..."); - Console::ReadLine(); - } -}; - -int main() -{ - MyServer::Run(); -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/WellKnownClientTypeEntry_Share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/WellKnownClientTypeEntry_Share.cpp deleted file mode 100644 index a0d437c05ba2a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/WellKnownClientTypeEntry_Share.cpp +++ /dev/null @@ -1,16 +0,0 @@ -using namespace System; - -public ref class HelloServer : public MarshalByRefObject -{ -public: - HelloServer() - { - Console::WriteLine("The hashcode of servicing object:"+this->GetHashCode()); - } -public: - String^ HelloMethod(String^ name) - { - Console::WriteLine("'HelloServer.HelloMethod' method is called by : {0}", name); - return "Hi! " + name + " is calling 'HelloServer.HelloMethod' method. "; - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/makefile deleted file mode 100644 index 3901d52a9e4c8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: WellKnownClientTypeEntry_Server.exe WellKnownClientTypeEntry_Client.exe - -WellKnownClientTypeEntry_Server.exe: WellKnownClientTypeEntry_Server.cpp WellKnownClientTypeEntry_Share.dll - cl /clr:pure WellKnownClientTypeEntry_Server.cpp - -WellKnownClientTypeEntry_Client.exe: WellKnownClientTypeEntry_Client.cpp WellKnownClientTypeEntry_Share.dll - cl /clr:pure WellKnownClientTypeEntry_Client.cpp - -WellKnownClientTypeEntry_Share.dll: WellKnownClientTypeEntry_Share.cpp - cl /clr:pure /LD WellKnownClientTypeEntry_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/wellknownclienttypeentry_client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/wellknownclienttypeentry_client.cpp deleted file mode 100644 index e970f19660974..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownClientTypeEntry_Client/CPP/wellknownclienttypeentry_client.cpp +++ /dev/null @@ -1,43 +0,0 @@ - - -// System.Runtime.Remoting.WellKnownClientTypeEntry -/* -The following example demonstrates the 'WellKnownClientTypeEntry' class. -It registers a 'HttpChannel' object with the channel services. Then registers the 'HelloServer' -type as well known type with the Remoting Infrastructure at the client end and activates the -remote object. It displays the properties of the 'WellKnownClientTypeEntry' object holding the -values for the above well-known type and makes few method calls on the remote object. -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -int main() -{ - // Create a 'HttpChannel' object and register with channel services. - ChannelServices::RegisterChannel( gcnew HttpChannel ); - Console::WriteLine( " Start calling from Client One......." ); - WellKnownClientTypeEntry^ myWellKnownClientTypeEntry = gcnew WellKnownClientTypeEntry( HelloServer::typeid,"http://localhost:8086/SayHello" ); - myWellKnownClientTypeEntry->ApplicationUrl = "http://localhost:8086/SayHello"; - RemotingConfiguration::RegisterWellKnownClientType( myWellKnownClientTypeEntry ); - - // Get the proxy object for the remote object. - HelloServer^ myHelloServerObject = gcnew HelloServer; - - // Retrieve an array of object types registered on the - // client end as well-known types. - array^myWellKnownClientTypeEntryCollection = RemotingConfiguration::GetRegisteredWellKnownClientTypes(); - Console::WriteLine( "The Application Url to activate the Remote Object :{0}", myWellKnownClientTypeEntryCollection[ 0 ]->ApplicationUrl ); - Console::WriteLine( "The 'WellKnownClientTypeEntry' object :{0}", myWellKnownClientTypeEntryCollection[ 0 ] ); - - // Make remote method calls. - for ( int i = 0; i < 5; i++ ) - Console::WriteLine( myHelloServerObject->HelloMethod( " Client One" ) ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/WellKnownServiceTypeEntry_Client.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/WellKnownServiceTypeEntry_Client.cpp deleted file mode 100644 index 1992406adc918..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/WellKnownServiceTypeEntry_Client.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// This is the client program for the 'WellKnownServiceTypeEntry_Server.cs' program. - -using namespace System; -using namespace System::Runtime::Remoting; -#using -#using - -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -public ref class MyClient -{ -public: - static void Run() - { - ChannelServices::RegisterChannel(gcnew HttpChannel()); - Console::WriteLine(" Start calling from Client One......."); - WellKnownClientTypeEntry^ myWellKnownClientTypeEntry = - gcnew WellKnownClientTypeEntry(HelloServer::typeid, - "http://localhost:8086/SayHello"); - myWellKnownClientTypeEntry->ApplicationUrl="http://localhost:8086/SayHello"; - RemotingConfiguration::RegisterWellKnownClientType(myWellKnownClientTypeEntry); - HelloServer^ myHelloServerObject = gcnew HelloServer(); - for (int i = 0; i < 5; i++) - Console::WriteLine(myHelloServerObject->HelloMethod(" Client One")); - } -}; - -int main() -{ - MyClient::Run(); -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/WellKnownServiceTypeEntry_Share.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/WellKnownServiceTypeEntry_Share.cpp deleted file mode 100644 index a0d437c05ba2a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/WellKnownServiceTypeEntry_Share.cpp +++ /dev/null @@ -1,16 +0,0 @@ -using namespace System; - -public ref class HelloServer : public MarshalByRefObject -{ -public: - HelloServer() - { - Console::WriteLine("The hashcode of servicing object:"+this->GetHashCode()); - } -public: - String^ HelloMethod(String^ name) - { - Console::WriteLine("'HelloServer.HelloMethod' method is called by : {0}", name); - return "Hi! " + name + " is calling 'HelloServer.HelloMethod' method. "; - } -}; diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/makefile deleted file mode 100644 index a509a8a038aa7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: WellKnownServiceTypeEntry_Server.exe WellKnownServiceTypeEntry_Client.exe - -WellKnownServiceTypeEntry_Server.exe: WellKnownServiceTypeEntry_Server.cpp WellKnownServiceTypeEntry_Share.dll - cl /clr:pure WellKnownServiceTypeEntry_Server.cpp - -WellKnownServiceTypeEntry_Client.exe: WellKnownServiceTypeEntry_Client.cpp WellKnownServiceTypeEntry_Share.dll - cl /clr:pure WellKnownServiceTypeEntry_Client.cpp - -WellKnownServiceTypeEntry_Share.dll: WellKnownServiceTypeEntry_Share.cpp - cl /clr:pure /LD WellKnownServiceTypeEntry_Share.cpp diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/wellknownservicetypeentry_server.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/wellknownservicetypeentry_server.cpp deleted file mode 100644 index afa2f82f1c46e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/WellKnownServiceTypeEntry_Server/CPP/wellknownservicetypeentry_server.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// System.Runtime.Remoting.WellKnownServiceTypeEntry -/* -The following example demonstrates the 'WellKnownServiceTypeEntry' class. -It registers a 'HttpChannel' object with the channel services. Then registers the 'HelloServer' -type as well known type with the Remoting Infrastructure at the service end . It displays the -properties of the 'WellKnownServiceTypeEntry' object holding the values for the above well-known -type . -*/ -// -#using -#using -#using - -using namespace System; -using namespace System::Runtime::Remoting; -using namespace System::Runtime::Remoting::Channels; -using namespace System::Runtime::Remoting::Channels::Http; - -int main() -{ - // Create a 'HttpChannel' object and register it with the - // channel services. - ChannelServices::RegisterChannel( gcnew HttpChannel( 8086 ) ); - - // Record the 'HelloServer' type as 'Singleton' well-known type. - WellKnownServiceTypeEntry^ myWellKnownServiceTypeEntry = gcnew WellKnownServiceTypeEntry( HelloServer::typeid,"SayHello",WellKnownObjectMode::Singleton ); - - // Register the remote object as well-known type. - RemotingConfiguration::RegisterWellKnownServiceType( myWellKnownServiceTypeEntry ); - - // Retrieve object types registered on the service end - // as well-known types. - array^myWellKnownServiceTypeEntryCollection = RemotingConfiguration::GetRegisteredWellKnownServiceTypes(); - Console::WriteLine( "The 'WellKnownObjectMode' of the remote object : {0}", myWellKnownServiceTypeEntryCollection[ 0 ]->Mode ); - Console::WriteLine( "The 'WellKnownServiceTypeEntry' object: {0}", myWellKnownServiceTypeEntryCollection[ 0 ] ); - Console::WriteLine( "Started the Server, Hit to exit..." ); - Console::ReadLine(); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp deleted file mode 100644 index f12a596e77001..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// System.Xml.Serialization.XmlAttributeAttribute.XmlAttributeAttribute() -// System.Xml.Serialization.XmlAttributeAttribute.XmlAttributeAttribute(String) -/* The following example demonstrates the constructor of XmlAttributeAttribute . -* This sample serializes a class named 'Student'.The StudentName property is -* serialized as an XML attribute.It also serializes a class named 'Book' -*/ -// -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Student -{ -public: - String^ StudentName; - int StudentNumber; -}; - -public ref class Book -{ -public: - String^ BookName; - int BookNumber; -}; - -void SerializeObject( String^ studentFilename, String^ bookFilename ) -{ - XmlSerializer^ mySerializer; - TextWriter^ writer; - - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ myXmlAttributeOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - /* Create an XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ myXmlAttributeAttribute = gcnew XmlAttributeAttribute; - myXmlAttributeAttribute->AttributeName = "Name"; - myXmlAttributes->XmlAttribute = myXmlAttributeAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - myXmlAttributeOverrides->Add( Student::typeid, "StudentName", myXmlAttributes ); - - // Create the XmlSerializer. - mySerializer = gcnew XmlSerializer( Student::typeid,myXmlAttributeOverrides ); - writer = gcnew StreamWriter( studentFilename ); - - // Create an instance of the class that will be serialized. - Student^ myStudent = gcnew Student; - - // Set the Name property, which will be generated as an XML attribute. - myStudent->StudentName = "James"; - myStudent->StudentNumber = 1; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myStudent ); - writer->Close(); - - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ myXmlBookAttributeOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ myXmlBookAttributes = gcnew XmlAttributes; - - /* Create an XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ myXmlBookAttributeAttribute = gcnew XmlAttributeAttribute( "Name" ); - myXmlBookAttributes->XmlAttribute = myXmlBookAttributeAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - myXmlBookAttributeOverrides->Add( Book::typeid, "BookName", myXmlBookAttributes ); - - // Create the XmlSerializer. - mySerializer = gcnew XmlSerializer( Book::typeid,myXmlBookAttributeOverrides ); - writer = gcnew StreamWriter( bookFilename ); - - // Create an instance of the class that will be serialized. - Book^ myBook = gcnew Book; - - // Set the Name property, which will be generated as an XML attribute. - myBook->BookName = ".NET"; - myBook->BookNumber = 10; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myBook ); - writer->Close(); -} - -int main() -{ - SerializeObject( "Student.xml", "Book.xml" ); -} -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp deleted file mode 100644 index a12e4ff3e02c7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// System::Xml::Serialization::XmlRootAttribute.XmlRootAttribute(String*) - -/* The following example demonstrates the constructor -'XmlRootAttribute(String*)' of class 'XmlRootAttribute'. -This program demonstrates 'Student' class to -which the 'XmlRootAttribute(String*)' constructor has been applied. -*/ - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class Student -{ -public: - String^ Name; -}; - -public ref class XMLRootAttributeClass -{ -// -public: - void SerializeOrder( String^ filename ) - { - // Create an XmlSerializer instance using the method below. - XmlSerializer^ myXmlSerializer = CreateOverrider(); - - // Create the object, and set its Name property. - Student^ myStudent = gcnew Student; - myStudent->Name = "Student class1"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myStudent ); - writer->Close(); - } - - // Return an XmlSerializer to the root serialization. - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributes to the default root element. - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - // Create an XmlRootAttribute overloaded constructer - // and set its namespace. - XmlRootAttribute^ myXmlRootAttribute = - gcnew XmlRootAttribute( "OverriddenRootElementName" ); - myXmlRootAttribute->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - myXmlAttributes->XmlRoot = myXmlRootAttribute; - XmlAttributeOverrides^ myXmlAttributeOverrides = - gcnew XmlAttributeOverrides; - - // Add the XmlAttributes object to the XmlAttributeOverrides object - myXmlAttributeOverrides->Add( Student::typeid, myXmlAttributes ); - - // Create the Serializer, and return it. - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( - Student::typeid, myXmlAttributeOverrides ); - return myXmlSerializer; - } -// -}; - -int main() -{ - XMLRootAttributeClass^ myXMLRootAttributeClass = - gcnew XMLRootAttributeClass; - myXMLRootAttributeClass->SerializeOrder( - "XMLRootAttributeConstructor.xml" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp deleted file mode 100644 index c87e784d7f0a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// System::Xml::Serialization::XmlRootAttribute.ElementName - -// The following example demonstrates the property -// 'ElementName' of class 'XmlRootAttribute'. -// This program demonstrates 'Student' class to -// which the 'ElementName' property has been applied. - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class Student -{ -public: - String^ Name; -}; - -public ref class XMLRootAttributeClass -{ -// -public: - void SerializeOrder( String^ filename ) - { - // Create an XmlSerializer instance using the method below. - XmlSerializer^ myXmlSerializer = CreateOverrider(); - - // Create the object, and set its Name property. - Student^ myStudent = gcnew Student; - myStudent->Name = "Student class1"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myStudent ); - writer->Close(); - } - - // Return an XmlSerializer to the root serialization. - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributes to the default root element. - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - // Create an XmlRootAttribute and set its element name and namespace. - XmlRootAttribute^ myXmlRootAttribute = gcnew XmlRootAttribute; - myXmlRootAttribute->ElementName = "OverriddenRootElementName"; - myXmlRootAttribute->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - myXmlAttributes->XmlRoot = myXmlRootAttribute; - XmlAttributeOverrides^ myXmlAttributeOverrides = - gcnew XmlAttributeOverrides; - - // Add the XmlAttributes object to the XmlAttributeOverrides object. - myXmlAttributeOverrides->Add( Student::typeid, myXmlAttributes ); - - // Create the Serializer, and return it. - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( - Student::typeid, myXmlAttributeOverrides ); - return myXmlSerializer; - } -// -}; - -int main() -{ - XMLRootAttributeClass^ myXMLRootAttributeClass = - gcnew XMLRootAttributeClass; - myXMLRootAttributeClass->SerializeOrder( - "XMLRootAttributeConstuctor.xml" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp deleted file mode 100644 index df16b69569b7d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp +++ /dev/null @@ -1,77 +0,0 @@ - - -// System::Xml::Serialization::XmlTypeAttribute.XmlTypeAttribute() -// System::Xml::Serialization::XmlTypeAttribute.XmlTypeAttribute(String*) -// The following example demonstrates the contructors 'XmlTypeAttribute()' -// and 'XmlTypeAttribute(String*)' of class 'XmlTypeAttribute'. -// This program demonstrates 'Person' and 'Address' classes to -// which the 'XmlTypeAttribute' has been applied.This sample then -// serializes an Object* of class 'Person' into an XML document. -// -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Address -{ -public: - String^ state; - String^ zip; -}; - -public ref class Person -{ -public: - String^ personName; - Address^ address; -}; - -public ref class PersonTypeAttribute -{ -public: - XmlSerializer^ CreateOverrider() - { - XmlAttributeOverrides^ personOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ personAttributes = gcnew XmlAttributes; - XmlTypeAttribute^ personType = gcnew XmlTypeAttribute; - personType->TypeName = "Employee"; - personType->Namespace = "http://www.microsoft.com"; - personAttributes->XmlType = personType; - XmlAttributes^ addressAttributes = gcnew XmlAttributes; - - // Create 'XmlTypeAttribute' with 'TypeName' as an argument. - XmlTypeAttribute^ addressType = gcnew XmlTypeAttribute( "Address" ); - addressType->Namespace = "http://www.microsoft.com"; - addressAttributes->XmlType = addressType; - personOverride->Add( Person::typeid, personAttributes ); - personOverride->Add( Address::typeid, addressAttributes ); - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( Person::typeid,personOverride ); - return myXmlSerializer; - } - - void SerializeObject( String^ filename ) - { - XmlSerializer^ myXmlSerializer = CreateOverrider(); - Address^ myAddress = gcnew Address; - myAddress->state = "AAA"; - myAddress->zip = "11111"; - Person^ myPerson = gcnew Person; - myPerson->personName = "Smith"; - myPerson->address = myAddress; - - // Serialize to a file. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myPerson ); - } -}; - -int main() -{ - PersonTypeAttribute^ myPersonTypeAttribute = gcnew PersonTypeAttribute; - myPersonTypeAttribute->SerializeObject( "XmlType.xml" ); -} -// -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp deleted file mode 100644 index 5c3508dc8e833..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; - -public ref class Group -{ -public: - String^ GroupName; - - // The UnknownAttributes array will be used to collect all unknown - // attributes found when deserializing. - - [XmlAnyAttributeAttribute] - array^XAttributes; -}; - -void SerializeObject( String^ filename, Object^ g ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, g ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - - // Write out the data, including unknown attributes. - Console::WriteLine( g->GroupName ); - Console::WriteLine( "Number of unknown attributes: {0}", g->XAttributes->Length ); - for ( IEnumerator ^ e = g->XAttributes->GetEnumerator(); e->MoveNext(); ) - { - XmlAttribute^ xAtt = safe_cast(e->Current); - Console::WriteLine( "{0}: {1}", xAtt->Name, xAtt->InnerXml ); - } - SerializeObject( "AttributesAdded.xml", g ); -} - -int main() -{ - // Deserialize the file containing unknown attributes. - DeserializeObject( "UnknownAttributes.xml" ); -} - -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp deleted file mode 100644 index 31e83e6251914..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Group -{ -public: - String^ GroupName; - - // The Things array will be used to collect all unknown - // attributes found when deserializing. - array^Things; -}; - -XmlSerializer^ CreateOverrideSerializer(); -void DeserializeObject( String^ filename ) -{ - // Use the CreateOverrideSerializer to return an instance - // of the XmlSerializer customized for overrides. - XmlSerializer^ ser = CreateOverrideSerializer(); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - Console::WriteLine( g->GroupName ); - Console::WriteLine( g->Things->Length ); - for ( IEnumerator ^ e = g->Things->GetEnumerator(); e->MoveNext(); ) - { - XmlAttribute^ xAtt = safe_cast(e->Current); - Console::WriteLine( "{0}: {1}", xAtt->Name, xAtt->InnerXml ); - } -} - -XmlSerializer^ CreateOverrideSerializer() -{ - // Override the Things field to capture all - // unknown XML attributes. - XmlAnyAttributeAttribute^ myAnyAttribute = gcnew XmlAnyAttributeAttribute; - XmlAttributeOverrides^ xOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ xAtts = gcnew XmlAttributes; - xAtts->XmlAnyAttribute = myAnyAttribute; - xOverride->Add( Group::typeid, "Things", xAtts ); - return gcnew XmlSerializer( Group::typeid,xOverride ); -} - -int main() -{ - DeserializeObject( "UnknownAttributes.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp deleted file mode 100644 index 9915009fc75f1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -[XmlRoot(Namespace="http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - - // This is for serializing Employee elements. - - [XmlAnyElement(Name="Employee")] - array^UnknownEmployees; - - // This is for serializing City elements. - - [XmlAnyElement - (Name="City", - Namespace="http://www.cpandl.com")] - array^UnknownCity; - - // This one is for all other unknown elements. - - [XmlAnyElement] - array^UnknownElements; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Create an XmlNamespaces to use. - XmlSerializerNamespaces^ namespaces = gcnew XmlSerializerNamespaces; - namespaces->Add( "c", "http://www.cohowinery.com" ); - namespaces->Add( "i", "http://www.cpandl.com" ); - Group^ myGroup = gcnew Group; - - // Create arrays of arbitrary XmlElement objects. - // First create an XmlDocument, used to create the - // XmlElement objects. - XmlDocument^ xDoc = gcnew XmlDocument; - - // Create an array of Employee XmlElement objects. - XmlElement^ El1 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El1->InnerText = "John"; - XmlElement^ El2 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El2->InnerText = "Joan"; - XmlElement^ El3 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El3->InnerText = "Jim"; - array^employees = {El1,El2,El3}; - myGroup->UnknownEmployees = employees; - - // Create an array of City XmlElement objects. - XmlElement^ inf1 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf1->InnerText = "Tokyo"; - XmlElement^ inf2 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf2->InnerText = "New York"; - XmlElement^ inf3 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf3->InnerText = "Rome"; - array^cities = {inf1,inf2,inf3}; - myGroup->UnknownCity = cities; - XmlElement^ xEl1 = xDoc->CreateElement( "bld" ); - xEl1->InnerText = "42"; - XmlElement^ xEl2 = xDoc->CreateElement( "Region" ); - xEl2->InnerText = "West"; - XmlElement^ xEl3 = xDoc->CreateElement( "type" ); - xEl3->InnerText = "Technical"; - array^elements = {xEl1,xEl2,xEl3}; - myGroup->UnknownElements = elements; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup, namespaces ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup; - myGroup = safe_cast(ser->Deserialize( fs )); - fs->Close(); - for ( int i = 0; i < myGroup->UnknownEmployees->Length; ++i ) - { - XmlElement^ xEmp = myGroup->UnknownEmployees[ i ]; - Console::WriteLine( "{0}: {1}", xEmp->LocalName, xEmp->InnerText ); - } - for ( int i = 0; i < myGroup->UnknownCity->Length; ++i ) - { - XmlElement^ xCity = myGroup->UnknownCity[ i ]; - Console::WriteLine( "{0}: {1}", xCity->LocalName, xCity->InnerText ); - } - for ( int i = 0; i < myGroup->UnknownElements->Length; ++i ) - { - XmlElement^ xEmp = myGroup->UnknownElements[ i ]; - Console::WriteLine( "{0}: {1}", xEmp->LocalName, xEmp->InnerText ); - } -} - -int main() -{ - SerializeObject( "AnyElementArray.xml" ); - DeserializeObject( "AnyElementArray.xml" ); - Console::WriteLine( "Done" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp deleted file mode 100644 index 9787259757cea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; -using namespace System::Xml::Schema; -public ref class Item -{ -public: - String^ ItemID; - Item(){} - - Item( String^ id ) - { - ItemID = id; - } -}; - -public ref class NewItem: public Item -{ -public: - String^ Category; - NewItem(){} - - NewItem( String^ id, String^ cat ) - { - ItemID = id; - Category = cat; - } -}; - -public ref class PurchaseOrder -{ -public: - - [XmlArrayItem(DataType="gMonth", - ElementName="MyMonths", - Namespace="http://www.cohowinery.com")] - array^Months; - - [XmlArrayItem(Item::typeid),XmlArrayItem(NewItem::typeid)] - array^Items; - - [XmlArray(IsNullable=true)] - [XmlArrayItem(String::typeid), - XmlArrayItem(Double::typeid), - XmlArrayItem(NewItem::typeid)] - array^Things; -}; - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class; - // specify the type of object to serialize. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create a PurchaseOrder and set its properties. - PurchaseOrder^ po = gcnew PurchaseOrder; - array^months = {"March","May","August"}; - po->Months = months; - array^items = {gcnew Item( "a1" ),gcnew NewItem( "b1","book" )}; - po->Items = items; - array^things = {"String",2003.31,gcnew NewItem( "Item100","book" )}; - po->Things = things; - - // Serialize the purchase order, and close the TextWriter. - serializer->Serialize( writer, po ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class; - // specify the type of object to be deserialized. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - PurchaseOrder^ po; - - /* Use the Deserialize method to restore the object's state with - data from the XML document. */ - po = safe_cast(serializer->Deserialize( fs )); - for ( int i = 0; i < po->Months->Length; ++i ) - Console::WriteLine( po->Months[ i ] ); - for ( int i = 0; i < po->Items->Length; ++i ) - Console::WriteLine( po->Items[ i ]->ItemID ); - for ( int i = 0; i < po->Things->Length; ++i ) - Console::WriteLine( po->Things[ i ] ); -} - -int main() -{ - // Read and write purchase orders. - SerializeObject( "ArrayItemEx.xml" ); - DeserializeObject( "ArrayItemEx.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp deleted file mode 100644 index 37278b0a8b3ae..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Group -{ -public: - String^ GroupName; - - [XmlAnyElement] - array^Things; -}; - -void SerializeObject( String^ filename ); -void DeserializeObject( String^ filename ); -XmlSerializer^ CreateOverrideSerializer(); -int main() -{ - // 1 Run this and create the XML document. - // 2 Add new elements to the XML document. - // 3 Comment out the next line, and uncomment - // the DeserializeObject line to deserialize the - // XML document and see unknown elements. - SerializeObject( "UnknownElements.xml" ); - - // DeserializeObject(S"UnknownElements.xml"); -} - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ g = gcnew Group; - g->GroupName = "MyGroup"; - ser->Serialize( writer, g ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = CreateOverrideSerializer(); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - Console::WriteLine( g->GroupName ); - Console::WriteLine( g->Things->Length ); - for ( int i = 0; i < g->Things->Length; ++i ) - { - XmlElement^ xelement = safe_cast(g->Things[ i ]); - Console::WriteLine( "{0}: {1}", xelement->Name, xelement->InnerXml ); - } -} - -XmlSerializer^ CreateOverrideSerializer() -{ - XmlAnyElementAttribute^ myAnyElement = gcnew XmlAnyElementAttribute; - XmlAttributeOverrides^ xOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ xAtts = gcnew XmlAttributes; - xAtts->XmlAnyElements->Add( myAnyElement ); - xOverride->Add( Group::typeid, "Things", xAtts ); - return gcnew XmlSerializer( Group::typeid,xOverride ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp deleted file mode 100644 index a86b3632f0694..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp +++ /dev/null @@ -1,86 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Student -{ -public: - - [XmlAttributeAttribute] - String^ Name; - - [XmlNamespaceDeclarationsAttribute] - XmlSerializerNamespaces^ myNamespaces; -}; - -void SerializeStudent( String^ filename ); -void DeserializeStudent( String^ filename ); -int main() -{ - SerializeStudent( "Student.xml" ); - DeserializeStudent( "Student.xml" ); -} - -void SerializeStudent( String^ filename ) -{ - XmlAttributes^ atts = gcnew XmlAttributes; - - // Set to true to preserve namespaces, - // or false to ignore them. - atts->Xmlns = true; - XmlAttributeOverrides^ xover = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes and specify the name of the element - // containing namespaces. - xover->Add( Student::typeid, "myNamespaces", atts ); - - // Create the XmlSerializer using the - // XmlAttributeOverrides object. - XmlSerializer^ xser = gcnew XmlSerializer( Student::typeid,xover ); - Student^ myStudent = gcnew Student; - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "myns1", "http://www.cpandl.com" ); - ns->Add( "myns2", "http://www.cohowinery.com" ); - myStudent->myNamespaces = ns; - myStudent->Name = "Student1"; - FileStream^ fs = gcnew FileStream( filename,FileMode::Create ); - xser->Serialize( fs, myStudent ); - fs->Close(); -} - -void DeserializeStudent( String^ filename ) -{ - XmlAttributes^ atts = gcnew XmlAttributes; - - // Set to true to preserve namespaces, or false to ignore them. - atts->Xmlns = true; - XmlAttributeOverrides^ xover = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes and specify the name of the - // element containing namespaces. - xover->Add( Student::typeid, "myNamespaces", atts ); - - // Create the XmlSerializer using the - // XmlAttributeOverrides object. - XmlSerializer^ xser = gcnew XmlSerializer( Student::typeid,xover ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Student^ myStudent; - myStudent = safe_cast(xser->Deserialize( fs )); - fs->Close(); - - // Use the ToArray method to get an array of - // XmlQualifiedName objects. - array^qNames = myStudent->myNamespaces->ToArray(); - for ( int i = 0; i < qNames->Length; i++ ) - { - Console::WriteLine( "{0}:{1}", qNames[ i ]->Name, qNames[ i ]->Namespace ); - - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp deleted file mode 100644 index 51329745b7a77..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp +++ /dev/null @@ -1,131 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -[XmlType(IncludeInSchema=false)] - -public enum class ItemChoiceType -{ - None, Word, Number, DecimalNumber -}; - -public enum class MoreChoices -{ - None, Item, Amount, Temp -}; - -public ref class Choices -{ -public: - - // The MyChoice field can be set to any one of - // the types below. - - [XmlChoiceIdentifier("EnumType")] - [XmlElement("Word",String::typeid)] - [XmlElement("Number",Int32::typeid)] - [XmlElement("DecimalNumber",Double::typeid)] - Object^ MyChoice; - - // Don't serialize this field. The EnumType field - // contains the enumeration value that corresponds - // to the MyChoice field value. - - [XmlIgnore] - ItemChoiceType EnumType; - - // The ManyChoices field can contain an array - // of choices. Each choice must be matched to - // an array item in the ChoiceArray field. - - [XmlChoiceIdentifier("ChoiceArray")] - [XmlElement("Item",String::typeid)] - [XmlElement("Amount",Int32::typeid)] - [XmlElement("Temp",Double::typeid)] - array^ManyChoices; - - // TheChoiceArray field contains the enumeration - // values, one for each item in the ManyChoices array. - - [XmlIgnore] - array^ChoiceArray; -}; - -void SerializeObject( String^ filename ); -void DeserializeObject( String^ filename ); -int main() -{ - SerializeObject( "Choices.xml" ); - DeserializeObject( "Choices.xml" ); -} - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Choices::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Choices^ myChoices = gcnew Choices; - - // Set the MyChoice field to a string. Set the - // EnumType to Word. - myChoices->MyChoice = "Book"; - myChoices->EnumType = ItemChoiceType::Word; - - // Populate an object array with three items, one - // of each enumeration type. Set the array to the - // ManyChoices field. - array^strChoices = {"Food",5,98.6}; - myChoices->ManyChoices = strChoices; - - // For each item in the ManyChoices array, add an - // enumeration value. - array^ itmChoices = {MoreChoices::Item,MoreChoices::Amount,MoreChoices::Temp}; - myChoices->ChoiceArray = itmChoices; - mySerializer->Serialize( writer, myChoices ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Choices::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Choices^ myChoices = safe_cast(ser->Deserialize( fs )); - fs->Close(); - - // Disambiguate the MyChoice value using the enumeration. - if ( myChoices->EnumType == ItemChoiceType::Word ) - { - Console::WriteLine( "Word: {0}", myChoices->MyChoice->ToString() ); - } - else - if ( myChoices->EnumType == ItemChoiceType::Number ) - { - Console::WriteLine( "Number: {0}", myChoices->MyChoice->ToString() ); - } - else - if ( myChoices->EnumType == ItemChoiceType::DecimalNumber ) - { - Console::WriteLine( "DecimalNumber: {0}", myChoices->MyChoice->ToString() ); - } - - // Disambiguate the ManyChoices values using the enumerations. - for ( int i = 0; i < myChoices->ManyChoices->Length; i++ ) - { - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Item ) - Console::WriteLine( "Item: {0}", myChoices->ManyChoices[ i ] ); - else - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Amount ) - Console::WriteLine( "Amount: ", myChoices->ManyChoices[ i ]->ToString() ); - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Temp ) - Console::WriteLine( "Temp: {0}", myChoices->ManyChoices[ i ]->ToString() ); - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/makefile b/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/makefile deleted file mode 100644 index 3d8d5b129d1e0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/makefile +++ /dev/null @@ -1,9 +0,0 @@ -all: Reader.exe Writer.exe -Reader.exe: Reader.cpp Person.dll - cl /clr:pure Reader.cpp -Writer.exe: Writer.cpp Person.dll - cl /clr:pure Writer.cpp -Person.dll: Person.cpp - cl /LD /clr:pure Person.cpp -clean: - del *.exe diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp deleted file mode 100644 index 61dea2ac4264f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; -public ref class Person: public IXmlSerializable -{ -private: - - // Private state - String^ personName; - -public: - - // Constructors - Person( String^ name ) - { - personName = name; - } - - Person() - { - personName = nullptr; - } - - // Xml Serialization Infrastructure - // - virtual void WriteXml( XmlWriter^ writer ) - { - writer->WriteString( personName ); - } - // - - // - virtual void ReadXml( XmlReader^ reader ) - { - personName = reader->ReadString(); - } - // - - // - virtual XmlSchema^ GetSchema() - { - return nullptr; - } - // - - // Print - virtual String^ ToString() override - { - return (personName); - } -}; -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp deleted file mode 100644 index f5ab5ef1cb045..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -int main() -{ - XmlSerializer^ serializer = gcnew XmlSerializer( Person::typeid ); - FileStream^ file = gcnew FileStream( "test.xml",FileMode::Open ); - Person^ aPerson = dynamic_cast(serializer->Deserialize( file )); - Console::WriteLine( aPerson ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp deleted file mode 100644 index 35d2a29a53238..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -int main() -{ - // Create a person object. - Person ^ fred = gcnew Person( "Fred Flintstone" ); - - // Serialize the object to a file. - XmlTextWriter^ writer = gcnew XmlTextWriter( "test.xml", nullptr ); - XmlSerializer^ serializer = gcnew XmlSerializer( Person::typeid ); - serializer->Serialize( writer, fred ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp deleted file mode 100644 index 22cef24ad7a88..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Test -{ -private: - void Serializer_UnknownElement( Object^ sender, XmlElementEventArgs^ e ) - { - Console::WriteLine( "Unknown Element" ); - Console::Write( "\t {0}", e->Element->Name ); - Console::WriteLine( " {0}", e->Element->InnerXml ); - Console::WriteLine( "\t LineNumber: {0}", e->LineNumber ); - Console::WriteLine( "\t LinePosition: {0}", e->LinePosition ); - Group^ x = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( x->GroupName ); - Console::WriteLine( sender ); - } - -public: - void DeserializeObject( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Add a delegate to handle unknown element events. - ser->UnknownElement += gcnew XmlElementEventHandler( this, &Test::Serializer_UnknownElement ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = dynamic_cast(ser->Deserialize( fs )); - fs->Close(); - } -}; - -int main() -{ - Test^ t = gcnew Test; - - // Deserialize the file containing unknown elements. - t->DeserializeObject( "UnknownElements.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp deleted file mode 100644 index e453759982a28..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// System::Xml::Serialization::XmlSerializerNamespaces.constructor - -// The following example demonstrates the constructor of class -// XmlSerializerNamespaces. This sample serializes an Object* of 'MyPriceClass' -// into an XML document. - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class MyPriceClass -{ -public: - [XmlAttributeAttribute] - String^ Units; - Decimal Price; -}; - -public ref class MyBook -{ -public: - String^ BookName; - String^ Author; - MyPriceClass^ BookPrice; - String^ Description; -}; - -public ref class MyMainClass -{ -// -public: - void CreateBook( String^ filename ) - { - try - { - // Create instance of XmlSerializerNamespaces and add the namespaces. - XmlSerializerNamespaces^ myNameSpaces = gcnew XmlSerializerNamespaces; - myNameSpaces->Add( "BookName", "http://www.cpandl.com" ); - - // Create instance of XmlSerializer and specify the type of object - // to be serialized. - XmlSerializer^ mySerializerObject = - gcnew XmlSerializer( MyBook::typeid ); - - TextWriter^ myWriter = gcnew StreamWriter( filename ); - // Create object to be serialized. - MyBook^ myXMLBook = gcnew MyBook; - - myXMLBook->Author = "XMLAuthor"; - myXMLBook->BookName = "DIG THE XML"; - myXMLBook->Description = "This is a XML Book"; - - MyPriceClass^ myBookPrice = gcnew MyPriceClass; - myBookPrice->Price = (Decimal)45.89; - myBookPrice->Units = "$"; - myXMLBook->BookPrice = myBookPrice; - - // Serialize the object. - mySerializerObject->Serialize( myWriter, myXMLBook, myNameSpaces ); - myWriter->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0} occurred", e->Message ); - } - } -// -}; - -int main() -{ - MyMainClass^ myMain = gcnew MyMainClass; - // Create the XML document. - myMain->CreateBook( "myBook.xml" ); -} diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp deleted file mode 100644 index 8f321e5bf2479..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Text; - -public ref class Thing -{ -public: - String^ ThingName; -}; - -[SoapType("TheGroup","http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - array^Things; - - [SoapElement(DataType="language")] - static String^ Lang = "en"; - - [SoapElement(DataType="integer")] - String^ MyNumber; - - [SoapElement(DataType="duration")] - static String^ ReDate = "8/31/01"; -}; - -void GetMap( String^ filename ) -{ - // Create an XmlSerializer instance. - SoapReflectionImporter^ sri = gcnew SoapReflectionImporter; - XmlTypeMapping^ map = sri->ImportTypeMapping( Group::typeid ); - Console::WriteLine( "ElementName: {0}", map->ElementName ); - Console::WriteLine( "Namespace: {0}", map->Namespace ); - Console::WriteLine( "TypeFullName: {0}", map->TypeFullName ); - Console::WriteLine( "TypeName: {0}", map->TypeName ); - XmlSerializer^ ser = gcnew XmlSerializer( map ); - Group^ xGroup = gcnew Group; - xGroup->GroupName = "MyCar"; - xGroup->MyNumber = "5454"; - xGroup->Things = gcnew array(2); // {new Thing(), new Thing()}; - xGroup->Things[ 0 ] = gcnew Thing; - xGroup->Things[ 1 ] = gcnew Thing; - - // To write the outer wrapper, use an XmlTextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, xGroup ); - writer->WriteEndElement(); - writer->Close(); -} - -int main() -{ - GetMap( "MyMap.xml" ); -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp b/samples/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp deleted file mode 100644 index a1d62acbb7b93..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -This program demonstrates the 'Intersect' and 'Union' methods of 'DnsPermission' class. -It creates a 'DnsPermission' instance that is the Union/Intersection of current permission -instance and specified permission instance. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ -private: - DnsPermission^ dnsPermission1; - DnsPermission^ dnsPermission2; - - // -private: - void MyUnion() - { - // Create a DnsPermission instance that is the union of the current DnsPermission - // instance and the specified DnsPermission instance. - DnsPermission^ permission = dynamic_cast(dnsPermission1->Union( dnsPermission2 )); - // Print the attributes and the values of the union instance of DnsPermission. - PrintKeysAndValues( permission->ToXml()->Attributes ); - } - - // -public: - void useDns() - { - // Create a DnsPermission instance. - dnsPermission1 = gcnew DnsPermission( PermissionState::Unrestricted ); - dnsPermission2 = gcnew DnsPermission( PermissionState::None ); - // Check for permission. - dnsPermission1->Demand(); - dnsPermission2->Demand(); - Console::WriteLine( "Attributes and Values of first DnsPermission instance :" ); - PrintKeysAndValues( dnsPermission1->ToXml()->Attributes ); - Console::WriteLine( "Attributes and Values of second DnsPermission instance :" ); - PrintKeysAndValues( dnsPermission2->ToXml()->Attributes ); - Console::WriteLine( "Union of both instances : " ); - MyUnion(); - Console::WriteLine( "Intersection of both instances : " ); - MyIntersection(); - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash tabble. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // - - // Create a DnsPermission instance that is the intersection of current - // DnsPermission instance and the specified DnsPermission instance. - void MyIntersection() - { - DnsPermission^ permission = dynamic_cast(dnsPermission1->Intersect( dnsPermission2 )); - // Print the attributes and the values of the intersection instance of - // DnsPermission. - PrintKeysAndValues( permission->ToXml()->Attributes ); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/BitmapMetadata.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/BitmapMetadata.cpp deleted file mode 100644 index 93100c5d8ddec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/BitmapMetadata.cpp +++ /dev/null @@ -1,92 +0,0 @@ -//BitmapMetadata.cpp file - -using namespace System; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; -using namespace System::Security; - - -namespace SDKSample { - - public ref class app : Application { - - private: Window^ mainWindow; - - protected: virtual void OnStartup (StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: void CreateAndShowMainWindow () - { - - // Create the application's main window - mainWindow = gcnew Window(); - mainWindow->Title = "Image Metadata"; - - // - Stream^ pngStream = gcnew FileStream("smiley.png", FileMode::Open, FileAccess::ReadWrite, FileShare::ReadWrite); - PngBitmapDecoder^ pngDecoder = gcnew PngBitmapDecoder(pngStream, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapFrame^ pngFrame = pngDecoder->Frames[0]; - InPlaceBitmapMetadataWriter^ pngInplace = pngFrame->CreateInPlaceBitmapMetadataWriter(); - if (pngInplace->TrySave() == true) - { - pngInplace->SetQuery("/Text/Description", "Have a nice day."); - } - pngStream->Close(); - // - - // Draw the Image - Image^ myImage = gcnew Image(); - myImage->Source = gcnew BitmapImage(gcnew System::Uri("smiley.png", UriKind::Relative)); - myImage->Stretch = Stretch::None; - myImage->Margin = System::Windows::Thickness(20); - - // - - // Add the metadata of the bitmap image to the text block. - TextBlock^ myTextBlock = gcnew TextBlock(); - myTextBlock->Text = "The Description metadata of this image is: " + pngInplace->GetQuery("/Text/Description")->ToString(); - // - - // Define a StackPanel to host Controls - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Vertical; - myStackPanel->Height = 200; - myStackPanel->VerticalAlignment = VerticalAlignment::Top; - myStackPanel->HorizontalAlignment = HorizontalAlignment::Center; - - // Add the Image and TextBlock to the parent Grid - myStackPanel->Children->Add(myImage); - myStackPanel->Children->Add(myTextBlock); - - // Add the StackPanel as the Content of the Parent Window Object - mainWindow->Content = myStackPanel; - mainWindow->Show(); - }; - }; - - // Define a static entry class - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/bitmapmetadata.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/bitmapmetadata.vcxproj deleted file mode 100644 index 74b2f3f4b0298..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/bitmapmetadata.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/smiley.png b/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/smiley.png deleted file mode 100644 index 1e0b9496cad2e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/BitMapMetadata/CPP/smiley.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/BitmapFrame.h b/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/BitmapFrame.h deleted file mode 100644 index 5c2f439e6d749..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/BitmapFrame.h +++ /dev/null @@ -1,46 +0,0 @@ -//BitmapFrame.h file - -#pragma once - -/*#using -#using -#using -#using -#using -#using -#using -#using -#using */ -namespace SDKSample { - ref class app; - ref class EntryClass; -} - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; - -namespace SDKSample { - - public ref class app : Application { - - private: System::Windows::Window^ mainWindow; - - protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override ; - - private: void CreateAndShowMainWindow () ; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () ; - }; -} - diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp deleted file mode 100644 index 9c9135fadd295..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp +++ /dev/null @@ -1,134 +0,0 @@ -using namespace System; -using namespace System::Collections::Generic; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; -using namespace System::Security; - -namespace SDKSample { - - public ref class app : Application { - - private: System::Windows::Window^ mainWindow; - - protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: void CreateAndShowMainWindow () - { - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "BMP Imaging Sample"; - ScrollViewer^ mySV = gcnew ScrollViewer(); - - // - int width = 128; - int height = width; - int stride = width / 8; - array^ pixels = gcnew array(height * stride); - - List^ colors = gcnew List(); - colors->Add(Colors::Red); - colors->Add(Colors::Blue); - colors->Add(Colors::Green); - BitmapPalette^ myPalette = gcnew BitmapPalette(colors); - - // Creates a new empty image with the pre-defined palette - - // - BitmapSource^ image = BitmapSource::Create( - width, - height, - 96, - 96, - PixelFormats::Indexed1, - myPalette, - pixels, - stride); - // - - // - FileStream^ stream = gcnew FileStream("new.bmp", FileMode::Create); - BmpBitmapEncoder^ encoder = gcnew BmpBitmapEncoder(); - TextBlock^ myTextBlock = gcnew TextBlock(); - myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString(); - encoder->Frames->Add(BitmapFrame::Create(image)); - encoder->Save(stream); - // - - // - - // - - // Open a Stream and decode a BMP image - Stream^ imageStreamSource = gcnew FileStream("tulipfarm.bmp", FileMode::Open, FileAccess::Read, FileShare::Read); - BmpBitmapDecoder^ decoder = gcnew BmpBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource = decoder->Frames[0]; - - // Draw the Image - Image^ myImage = gcnew Image(); - myImage->Source = bitmapSource; - myImage->Stretch = Stretch::None; - myImage->Margin = System::Windows::Thickness(20); - // - - // - - // Open a Uri and decode a BMP image - System::Uri^ myUri = gcnew System::Uri("tulipfarm.bmp", UriKind::RelativeOrAbsolute); - BmpBitmapDecoder^ decoder2 = gcnew BmpBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource2 = decoder2->Frames[0]; - - // Draw the Image - Image^ myImage2 = gcnew Image(); - myImage2->Source = bitmapSource2; - myImage2->Stretch = Stretch::None; - myImage2->Margin = System::Windows::Thickness(20); - // - - // Define a StackPanel to host the decoded BMP images - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Vertical; - myStackPanel->VerticalAlignment = VerticalAlignment::Stretch; - myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch; - - // Add the Image and TextBlock to the parent Grid - myStackPanel->Children->Add(myImage); - myStackPanel->Children->Add(myImage2); - myStackPanel->Children->Add(myTextBlock); - - // Add the StackPanel as the Content of the Parent Window Object - mySV->Content = myStackPanel; - mainWindow->Content = mySV; - mainWindow->Show(); - } - - - }; - - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; - -} - - -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherproject.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherproject.vcxproj deleted file mode 100644 index 1f985d5f281be..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherproject.vcxproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {6900EB9F-8008-437C-BB1E-3C7C06662F84} - v4.0 - ManagedCProj - AnotherProject - - - - Application - true - Unicode - - - Application - true - Unicode - - - - - - - - - - - - - true - .\ - - - false - - - - Level3 - ProgramDatabase - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - true - - - true - - - - - - - - - Level3 - ProgramDatabase - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - true - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherproject.vcxproj.filters b/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherproject.vcxproj.filters deleted file mode 100644 index aad46846bb3f6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherproject.vcxproj.filters +++ /dev/null @@ -1,32 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/tulipfarm.bmp b/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/tulipfarm.bmp deleted file mode 100644 index a3f88f4d09ad7..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/tulipfarm.bmp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/CanvasAttachedProperties/CPP/CanvasAttachedProperties.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/CanvasAttachedProperties/CPP/CanvasAttachedProperties.vcxproj deleted file mode 100644 index 4d1c3a2a476ea..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/CanvasAttachedProperties/CPP/CanvasAttachedProperties.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/CanvasAttachedProperties/CPP/CanvasAttachedProps.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/CanvasAttachedProperties/CPP/CanvasAttachedProps.cpp deleted file mode 100644 index 2aac3c70079f2..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/CanvasAttachedProperties/CPP/CanvasAttachedProps.cpp +++ /dev/null @@ -1,95 +0,0 @@ -//CanvasAttachedProps.cpp file - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Threading; - -namespace SDKSample { - - public ref class app : Application { - - private: - Window^ mainWindow; - - protected: - virtual void OnStartup (StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // - - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "Canvas Attached Properties Sample"; - - // Add a Border - Border^ myBorder = gcnew Border(); - myBorder->HorizontalAlignment = HorizontalAlignment::Left; - myBorder->VerticalAlignment = VerticalAlignment::Top; - myBorder->BorderBrush = Brushes::Black; - myBorder->BorderThickness = System::Windows::Thickness(2); - - // Create the Canvas - Canvas^ myCanvas = gcnew Canvas(); - myCanvas->Background = Brushes::LightBlue; - myCanvas->Width = 400; - myCanvas->Height = 400; - - // Create the child Button elements - Button^ myButton1 = gcnew Button(); - Button^ myButton2 = gcnew Button(); - Button^ myButton3 = gcnew Button(); - Button^ myButton4 = gcnew Button(); - - // Set Positioning attached properties on Button elements - Canvas::SetTop(myButton1, 50); - myButton1->Content = "Canvas.Top=50"; - Canvas::SetBottom(myButton2, 50); - myButton2->Content = "Canvas.Bottom=50"; - Canvas::SetLeft(myButton3, 50); - myButton3->Content = "Canvas.Left=50"; - Canvas::SetRight(myButton4, 50); - myButton4->Content = "Canvas.Right=50"; - - // Add Buttons to the Canvas' Children collection - myCanvas->Children->Add(myButton1); - myCanvas->Children->Add(myButton2); - myCanvas->Children->Add(myButton3); - myCanvas->Children->Add(myButton4); - - // Add the Canvas as the lone Child of the Border - myBorder->Child = myCanvas; - - // Add the Border as the Content of the Parent Window Object - mainWindow->Content = myBorder; - mainWindow->Show(); - - // - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/DiagnoseProblematicPrintJob/CPP/Program.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/DiagnoseProblematicPrintJob/CPP/Program.cpp deleted file mode 100644 index 22572e527cd05..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/DiagnoseProblematicPrintJob/CPP/Program.cpp +++ /dev/null @@ -1,345 +0,0 @@ -//Program.cpp file -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Text; -using namespace System::Printing; -using namespace System::IO; - -namespace DiagnoseProblematicPrintJob { - - // - private ref class TimeConverter { - - internal: - static DateTime ConvertToLocalHumanReadableTime (Int32 timeInMinutesAfterUTCMidnight) - { - // Construct a UTC midnight object. - // Must start with current date so that the local Daylight Savings system, if any, will be taken into account. - DateTime utcNow = DateTime::UtcNow; - DateTime utcMidnight = DateTime(utcNow.Year, utcNow.Month, utcNow.Day, 0, 0, 0, DateTimeKind::Utc); - - // Add the minutes passed into the method in order to get the intended UTC time. - Double minutesAfterUTCMidnight = ((Double)timeInMinutesAfterUTCMidnight); - DateTime utcTime = utcMidnight.AddMinutes(minutesAfterUTCMidnight); - - // Convert to local time. - DateTime localTime = utcTime.ToLocalTime(); - - return localTime; - }; - }; - // - - private ref class TroubleSpotter { - - internal: - // - // Check for possible trouble states of a print job using its properties - static void SpotTroubleUsingProperties (PrintSystemJobInfo^ theJob) - { - if (theJob->IsBlocked) - { - Console::WriteLine("The job is blocked."); - } - if (theJob->IsCompleted || theJob->IsPrinted) - { - Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked."); - } - if (theJob->IsDeleted || theJob->IsDeleting) - { - Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted."); - } - if (theJob->IsInError) - { - Console::WriteLine("The job has errored."); - } - if (theJob->IsOffline) - { - Console::WriteLine("The printer is offline. Have user put it online with printer front panel."); - } - if (theJob->IsPaperOut) - { - Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper."); - } - - if (theJob->IsPaused || theJob->HostingPrintQueue->IsPaused) - { - HandlePausedJob(theJob); - //HandlePausedJob is defined in the complete example. - } - - if (theJob->IsPrinting) - { - Console::WriteLine("The job is printing now."); - } - if (theJob->IsSpooling) - { - Console::WriteLine("The job is spooling now."); - } - if (theJob->IsUserInterventionRequired) - { - Console::WriteLine("The printer needs human intervention."); - } - }; - // - - // - // Check for possible trouble states of a print job using the flags of the JobStatus property - static void SpotTroubleUsingJobAttributes (PrintSystemJobInfo^ theJob) - { - if ((theJob->JobStatus & PrintJobStatus::Blocked) == PrintJobStatus::Blocked) - { - Console::WriteLine("The job is blocked."); - } - if (((theJob->JobStatus & PrintJobStatus::Completed) == PrintJobStatus::Completed) - || - ((theJob->JobStatus & PrintJobStatus::Printed) == PrintJobStatus::Printed)) - { - Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked."); - } - if (((theJob->JobStatus & PrintJobStatus::Deleted) == PrintJobStatus::Deleted) - || - ((theJob->JobStatus & PrintJobStatus::Deleting) == PrintJobStatus::Deleting)) - { - Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted."); - } - if ((theJob->JobStatus & PrintJobStatus::Error) == PrintJobStatus::Error) - { - Console::WriteLine("The job has errored."); - } - if ((theJob->JobStatus & PrintJobStatus::Offline) == PrintJobStatus::Offline) - { - Console::WriteLine("The printer is offline. Have user put it online with printer front panel."); - } - if ((theJob->JobStatus & PrintJobStatus::PaperOut) == PrintJobStatus::PaperOut) - { - Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper."); - } - if (((theJob->JobStatus & PrintJobStatus::Paused) == PrintJobStatus::Paused) - || - ((theJob->HostingPrintQueue->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused)) - { - HandlePausedJob(theJob); - //HandlePausedJob is defined in the complete example. - } - - if ((theJob->JobStatus & PrintJobStatus::Printing) == PrintJobStatus::Printing) - { - Console::WriteLine("The job is printing now."); - } - if ((theJob->JobStatus & PrintJobStatus::Spooling) == PrintJobStatus::Spooling) - { - Console::WriteLine("The job is spooling now."); - } - if ((theJob->JobStatus & PrintJobStatus::UserIntervention) == PrintJobStatus::UserIntervention) - { - Console::WriteLine("The printer needs human intervention."); - } - }; - // - - // - static void HandlePausedJob (PrintSystemJobInfo^ theJob) - { - // If there's no good reason for the queue to be paused, resume it and - // give user choice to resume or cancel the job. - Console::WriteLine("The user or someone with administrative rights to the queue" + "\nhas paused the job or queue." + "\nResume the queue? (Has no effect if queue is not paused.)" + "\nEnter \"Y\" to resume, otherwise press return: "); - String^ resume = Console::ReadLine(); - if (resume == "Y") - { - theJob->HostingPrintQueue->Resume(); - - // It is possible the job is also paused. Find out how the user wants to handle that. - Console::WriteLine("Does user want to resume print job or cancel it?" + "\nEnter \"Y\" to resume (any other key cancels the print job): "); - String^ userDecision = Console::ReadLine(); - if (userDecision == "Y") - { - theJob->Resume(); - } else - { - theJob->Cancel(); - } - } - }; - // - - // - static void ReportQueueAndJobAvailability (PrintSystemJobInfo^ theJob) - { - if (!(ReportAvailabilityAtThisTime(theJob->HostingPrintQueue) && ReportAvailabilityAtThisTime(theJob))) - { - if (!ReportAvailabilityAtThisTime(theJob->HostingPrintQueue)) - { - Console::WriteLine("\nThat queue is not available at this time of day." + "\nJobs in the queue will start printing again at {0}", TimeConverter::ConvertToLocalHumanReadableTime(theJob->HostingPrintQueue->StartTimeOfDay).ToShortTimeString()); - // TimeConverter class is defined in the complete sample - } - if (!ReportAvailabilityAtThisTime(theJob)) - { - Console::WriteLine("\nThat job is set to print only between {0} and {1}", TimeConverter::ConvertToLocalHumanReadableTime(theJob->StartTimeOfDay).ToShortTimeString(), TimeConverter::ConvertToLocalHumanReadableTime(theJob->UntilTimeOfDay).ToShortTimeString()); - } - Console::WriteLine("\nThe job will begin printing as soon as it reaches the top of the queue after:"); - if (theJob->StartTimeOfDay > theJob->HostingPrintQueue->StartTimeOfDay) - { - Console::WriteLine(TimeConverter::ConvertToLocalHumanReadableTime(theJob->StartTimeOfDay).ToShortTimeString()); - } else - { - Console::WriteLine(TimeConverter::ConvertToLocalHumanReadableTime(theJob->HostingPrintQueue->StartTimeOfDay).ToShortTimeString()); - } - - } - }; - // - - - // - static Boolean ReportAvailabilityAtThisTime (PrintQueue^ pq) - { - Boolean available = true; - if (pq->StartTimeOfDay != pq->UntilTimeOfDay) - { - DateTime utcNow = DateTime::UtcNow; - Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes; - - // If now is not within the range of available times . . . - if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay))) - { - available = false; - } - } - return available; - }; - // - - - // - static Boolean ReportAvailabilityAtThisTime (PrintSystemJobInfo^ theJob) - { - Boolean available = true; - if (theJob->StartTimeOfDay != theJob->UntilTimeOfDay) - { - DateTime utcNow = DateTime::UtcNow; - Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes; - - // If "now" is not within the range of available times . . . - if (!((theJob->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < theJob->UntilTimeOfDay))) - { - available = false; - } - } - return available; - } - // - - }; - - - private ref class Program { - - public: - static void Main (array^ args) - { - // Obtain a list of print servers. - Console::Write("Enter path and file name of CRLF-delimited list of print servers" + "\n(press Return for default \"C:\\PrintServers.txt\"): "); - String^ pathToListOfPrintServers = Console::ReadLine(); - if (pathToListOfPrintServers == "") - { - pathToListOfPrintServers = "C:\\PrintServers.txt"; - } - StreamReader^ fileOfPrintServers = gcnew StreamReader(pathToListOfPrintServers); - - // Obtain the username of the person with the problematic print job. - Console::Write("\nEnter username of person that submitted print job" + "\n(press Return for the current user {0}: ", Environment::UserName); - String^ userName = Console::ReadLine(); - if (userName == "") - { - userName = Environment::UserName; - } - - // Prompt user to determine the method that will be used to read the queue status. - Console::Write("\nEnter \"Y\" to check the problematic job using its JobStatus attributes." + "\nOtherwise, press Return and the job will be checked using its specific properties: "); - String^ useAttributesResponse = Console::ReadLine(); - - // Create list of all jobs submitted by user. - String^ line; - Boolean atLeastOne = false; - String^ jobList = "\n\nAll print jobs submitted by the user are listed here:\n\n"; - while ((line = fileOfPrintServers->ReadLine()) != nullptr) - { - PrintServer^ myPS = gcnew PrintServer(line, PrintSystemDesiredAccess::AdministrateServer); - PrintQueueCollection^ myPrintQueues = myPS->GetPrintQueues(); - - // - for each (PrintQueue^ pq in myPrintQueues) - { - pq->Refresh(); - PrintJobInfoCollection^ jobs = pq->GetPrintJobInfoCollection(); - for each (PrintSystemJobInfo^ job in jobs) - { - // Since the user may not be able to articulate which job is problematic, - // present information about each job the user has submitted. - if (job->Submitter == userName) - { - atLeastOne = true; - jobList = jobList + "\nServer:" + line; - jobList = jobList + "\n\tQueue:" + pq->Name; - jobList = jobList + "\n\tLocation:" + pq->Location; - jobList = jobList + "\n\t\tJob: " + job->JobName + " ID: " + job->JobIdentifier; - } - } - } - // - } - - fileOfPrintServers->Close(); - - if (!atLeastOne) - { - jobList = "\n\nNo jobs submitted by " + userName + " were found.\n\n"; - Console::WriteLine(jobList); - } else - { - jobList = jobList + "\n\nIf multiple jobs are listed, use the information provided" + " above and by the user to identify the job needing diagnosis.\n\n"; - Console::WriteLine(jobList); - // - // When the problematic print job has been identified, enter information about it. - Console::Write("\nEnter the print server hosting the job (including leading slashes \\\\): " + "\n(press Return for the current computer \\\\{0}): ", Environment::MachineName); - String^ pServer = Console::ReadLine(); - if (pServer == "") - { - pServer = "\\\\" + Environment::MachineName; - } - Console::Write("\nEnter the print queue hosting the job: "); - String^ pQueue = Console::ReadLine(); - Console::Write("\nEnter the job ID: "); - Int16 jobID = Convert::ToInt16(Console::ReadLine()); - - // Create objects to represent the server, queue, and print job. - PrintServer^ hostingServer = gcnew PrintServer(pServer, PrintSystemDesiredAccess::AdministrateServer); - PrintQueue^ hostingQueue = gcnew PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess::AdministratePrinter); - PrintSystemJobInfo^ theJob = hostingQueue->GetJob(jobID); - - if (useAttributesResponse == "Y") - { - TroubleSpotter::SpotTroubleUsingJobAttributes(theJob); - // TroubleSpotter class is defined in the complete example. - } else - { - TroubleSpotter::SpotTroubleUsingProperties(theJob); - } - - TroubleSpotter::ReportQueueAndJobAvailability(theJob); - // - } - Console::WriteLine("\nPress Return to end."); - Console::ReadLine(); - }; - }; - -} - -//Entry Point: -int main (array^ args) -{ - DiagnoseProblematicPrintJob::Program::Main(args); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/DiagnoseProblematicPrintJob/CPP/diagnoseproblematicprintjob.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/DiagnoseProblematicPrintJob/CPP/diagnoseproblematicprintjob.vcxproj deleted file mode 100644 index d3327709232b8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/DiagnoseProblematicPrintJob/CPP/diagnoseproblematicprintjob.vcxproj +++ /dev/null @@ -1,131 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21208.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Console - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/DockPanel_Ovw_Sample.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/DockPanel_Ovw_Sample.cpp deleted file mode 100644 index 8979de0de5163..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/DockPanel_Ovw_Sample.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//DockPanel_Ovw_Sample.cpp file - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Shapes; -using namespace System::Threading; - -namespace SDKSample { - - public ref class app : Application { - - private: - Window^ mainWindow; - - protected: - virtual void OnStartup (StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // - - // Create the application's main window - mainWindow = gcnew Window(); - mainWindow->Title = "DockPanel Sample"; - - // Create the DockPanel - DockPanel^ myDockPanel = gcnew DockPanel(); - myDockPanel->LastChildFill = true; - - // Define the child content - Border^ myBorder1 = gcnew Border(); - myBorder1->Height = 25; - myBorder1->Background = Brushes::SkyBlue; - myBorder1->BorderBrush = Brushes::Black; - myBorder1->BorderThickness = Thickness(1); - DockPanel::SetDock(myBorder1, Dock::Top); - TextBlock^ myTextBlock1 = gcnew TextBlock(); - myTextBlock1->Foreground = Brushes::Black; - myTextBlock1->Text = "Dock = Top"; - myBorder1->Child = myTextBlock1; - - Border^ myBorder2 = gcnew Border(); - myBorder2->Height = 25; - myBorder2->Background = Brushes::SkyBlue; - myBorder2->BorderBrush = Brushes::Black; - myBorder2->BorderThickness = Thickness(1); - DockPanel::SetDock(myBorder2, Dock::Top); - TextBlock^ myTextBlock2 = gcnew TextBlock(); - myTextBlock2->Foreground = Brushes::Black; - myTextBlock2->Text = "Dock = Top"; - myBorder2->Child = myTextBlock2; - - Border^ myBorder3 = gcnew Border(); - myBorder3->Height = 25; - myBorder3->Background = Brushes::LemonChiffon; - myBorder3->BorderBrush = Brushes::Black; - myBorder3->BorderThickness = Thickness(1); - DockPanel::SetDock(myBorder3, Dock::Bottom); - TextBlock^ myTextBlock3 = gcnew TextBlock(); - myTextBlock3->Foreground = Brushes::Black; - myTextBlock3->Text = "Dock = Bottom"; - myBorder3->Child = myTextBlock3; - - Border^ myBorder4 = gcnew Border(); - myBorder4->Width = 200; - myBorder4->Background = Brushes::PaleGreen; - myBorder4->BorderBrush = Brushes::Black; - myBorder4->BorderThickness = Thickness(1); - DockPanel::SetDock(myBorder4, Dock::Left); - TextBlock^ myTextBlock4 = gcnew TextBlock(); - myTextBlock4->Foreground = Brushes::Black; - myTextBlock4->Text = "Dock = Left"; - myBorder4->Child = myTextBlock4; - - Border^ myBorder5 = gcnew Border(); - myBorder5->Background = Brushes::White; - myBorder5->BorderBrush = Brushes::Black; - myBorder5->BorderThickness = Thickness(1); - TextBlock^ myTextBlock5 = gcnew TextBlock(); - myTextBlock5->Foreground = Brushes::Black; - myTextBlock5->Text = "This content will Fill the remaining space"; - myBorder5->Child = myTextBlock5; - - // Add child elements to the DockPanel Children collection - myDockPanel->Children->Add(myBorder1); - myDockPanel->Children->Add(myBorder2); - myDockPanel->Children->Add(myBorder3); - myDockPanel->Children->Add(myBorder4); - myDockPanel->Children->Add(myBorder5); - - // Add the parent Canvas as the Content of the Window Object - mainWindow->Content = myDockPanel; - mainWindow->Show(); - - // - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/dockpanel_ovw_sample.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/dockpanel_ovw_sample.vcxproj deleted file mode 100644 index 9f1e7fd1db03d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/dockpanel_ovw_sample.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CPP/Program.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CPP/Program.cpp deleted file mode 100644 index f559468cac9f8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CPP/Program.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//Program.cpp file - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Text; -using namespace System::Printing; -using namespace System::Collections; - -namespace EnumerateSubsetOfPrintQueues { - - private ref class Program { - - public: - static void Main (array^ args) - { - // - // Specify that the list will contain only the print queues that are installed as local and are shared - array^ enumerationFlags = {EnumeratedPrintQueueTypes::Local,EnumeratedPrintQueueTypes::Shared}; - - LocalPrintServer^ printServer = gcnew LocalPrintServer(); - - //Use the enumerationFlags to filter out unwanted print queues - PrintQueueCollection^ printQueuesOnLocalServer = printServer->GetPrintQueues(enumerationFlags); - - Console::WriteLine("These are your shared, local print queues:\n\n"); - - for each (PrintQueue^ printer in printQueuesOnLocalServer) - { - Console::WriteLine("\tThe shared printer " + printer->Name + " is located at " + printer->Location + "\n"); - } - Console::WriteLine("Press enter to continue."); - Console::ReadLine(); - // - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -int main (array^ args) -{ - EnumerateSubsetOfPrintQueues::Program::Main(args); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CPP/enumeratesubsetofprintqueues.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CPP/enumeratesubsetofprintqueues.vcxproj deleted file mode 100644 index 4c1138eccdf6a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/EnumerateSubsetOfPrintQueues/CPP/enumeratesubsetofprintqueues.vcxproj +++ /dev/null @@ -1,131 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21208.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Console - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp deleted file mode 100644 index 4c510d2b162ed..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//GifEncoderDecoder.cpp file - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; -using namespace System::Security; - - -namespace SDKSample { - - public ref class app : Application { - - private: System::Windows::Window^ mainWindow; - - protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - - private: - [SecuritySafeCritical] - void CreateAndShowMainWindow () - { - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "GIF Imaging Sample"; - ScrollViewer^ mySV = gcnew ScrollViewer(); - - // - int width = 128; - int height = width; - int stride = width / 8; - array^ pixels = gcnew array(height * stride); - - // Define the image palette - - BitmapPalette^ myPalette = BitmapPalettes::WebPalette; - - // Creates a new empty image with the pre-defined palette - - // - BitmapSource^ image = BitmapSource::Create( - width, - height, - 96, - 96, - PixelFormats::Indexed1, - myPalette, - pixels, - stride); - // - - // - FileStream^ stream = gcnew FileStream("new.gif", FileMode::Create); - GifBitmapEncoder^ encoder = gcnew GifBitmapEncoder(); - TextBlock^ myTextBlock = gcnew TextBlock(); - myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString(); - encoder->Frames->Add(BitmapFrame::Create(image)); - encoder->Save(stream); - // - - // - - // - - // Open a Stream and decode a GIF image - Stream^ imageStreamSource = gcnew FileStream("tulipfarm.gif", FileMode::Open, FileAccess::Read, FileShare::Read); - GifBitmapDecoder^ decoder = gcnew GifBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource = decoder->Frames[0]; - - // Draw the Image - Image^ myImage = gcnew Image(); - myImage->Source = bitmapSource; - myImage->Stretch = Stretch::None; - myImage->Margin = System::Windows::Thickness(20); - // - - // - - // Open a Uri and decode a GIF image - System::Uri^ myUri = gcnew System::Uri("tulipfarm.gif", UriKind::RelativeOrAbsolute); - GifBitmapDecoder^ decoder2 = gcnew GifBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource2 = decoder2->Frames[0]; - - // Draw the Image - Image^ myImage2 = gcnew Image(); - myImage2->Source = bitmapSource2; - myImage2->Stretch = Stretch::None; - myImage2->Margin = System::Windows::Thickness(20); - // - - // Define a StackPanel to host the decoded GIF images - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Vertical; - myStackPanel->VerticalAlignment = VerticalAlignment::Stretch; - myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch; - - // Add the Image and TextBlock to the parent Grid - myStackPanel->Children->Add(myImage); - myStackPanel->Children->Add(myImage2); - myStackPanel->Children->Add(myTextBlock); - - // Add the StackPanel as the Content of the Parent Window Object - mySV->Content = myStackPanel; - mainWindow->Content = mySV; - mainWindow->Show(); - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/gifencoderdecoder.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/gifencoderdecoder.vcxproj deleted file mode 100644 index 88bb58890774c..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/gifencoderdecoder.vcxproj +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/tulipfarm.gif b/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/tulipfarm.gif deleted file mode 100644 index def1be66323b9..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/tulipfarm.gif and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/jpegencoderdecoder.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/jpegencoderdecoder.cpp deleted file mode 100644 index b74221067e8a0..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/jpegencoderdecoder.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//jpegencoderdecoder.cpp file - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; -using namespace System::Security; - - - -namespace SDKSample { - - public ref class app : Application { - - private: - System::Windows::Window^ mainWindow; - - protected: - virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "JPEG Imaging Sample"; - System::Windows::Controls::ScrollViewer^ mySV = gcnew System::Windows::Controls::ScrollViewer(); - - // - int width = 128; - int height = width; - int stride = width / 8; - array^ pixels = gcnew array(height * stride); - - // Define the image palette - BitmapPalette^ myPalette = BitmapPalettes::Halftone256; - - // Creates a new empty image with the pre-defined palette. - // - BitmapSource^ image = BitmapSource::Create( - width, height, - 96, 96, - PixelFormats::Indexed1, - myPalette, - pixels, - stride); - // - // - - System::IO::FileStream^ stream = gcnew System::IO::FileStream("new.jpg", FileMode::Create); - JpegBitmapEncoder^ encoder = gcnew JpegBitmapEncoder(); - TextBlock^ myTextBlock = gcnew System::Windows::Controls::TextBlock(); - myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString(); - encoder->FlipHorizontal = true; - encoder->FlipVertical = false; - encoder->QualityLevel = 30; - encoder->Rotation = Rotation::Rotate90; - encoder->Frames->Add(BitmapFrame::Create(image)); - encoder->Save(stream); - // - // - - // - // Open a Stream and decode a JPEG image - Stream^ imageStreamSource = gcnew FileStream("tulipfarm.jpg", FileMode::Open, FileAccess::Read, FileShare::Read); - JpegBitmapDecoder^ decoder = gcnew JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource = decoder->Frames[0]; - - // Draw the Image - Image^ myImage = gcnew Image(); - myImage->Source = bitmapSource; - myImage->Stretch = Stretch::None; - myImage->Margin = System::Windows::Thickness(20); - // - - // - // Open a Uri and decode a JPEG image - System::Uri^ myUri = gcnew System::Uri("tulipfarm.jpg", UriKind::RelativeOrAbsolute); - JpegBitmapDecoder^ decoder2 = gcnew JpegBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource2 = decoder2->Frames[0]; - - // Draw the Image - Image^ myImage2 = gcnew Image(); - myImage2->Source = bitmapSource2; - myImage2->Stretch = Stretch::None; - myImage2->Margin = System::Windows::Thickness(20); - // - - // Define a StackPanel to host the decoded JPEG images - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Vertical; - myStackPanel->VerticalAlignment = VerticalAlignment::Stretch; - myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch; - - // Add the Image and TextBlock to the parent Grid. - myStackPanel->Children->Add(myImage); - myStackPanel->Children->Add(myImage2); - myStackPanel->Children->Add(myTextBlock); - - // Add the StackPanel as the content of the parent window. - mySV->Content = myStackPanel; - mainWindow->Content = mySV; - mainWindow->Show(); - }; - }; - - private ref class EntryClass { - - public: - [System::STAThreadAttribute()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - } - ; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -int main(array ^args) -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/jpegencoderdecoder.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/jpegencoderdecoder.vcxproj deleted file mode 100644 index f5748c9785958..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/jpegencoderdecoder.vcxproj +++ /dev/null @@ -1,129 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {6EFA9BEA-6237-4CCC-BFD8-87EB6499E919} - SDKSample - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/tulipfarm.jpg b/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/tulipfarm.jpg deleted file mode 100644 index 2ce60cad09155..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/JpegBitmapDecoderEncoder/CPP/tulipfarm.jpg and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/MarginPaddingAlignmentSample/CPP/Margin_Padding_Alignment_Sample.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/MarginPaddingAlignmentSample/CPP/Margin_Padding_Alignment_Sample.cpp deleted file mode 100644 index 2e77a263adb1e..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/MarginPaddingAlignmentSample/CPP/Margin_Padding_Alignment_Sample.cpp +++ /dev/null @@ -1,220 +0,0 @@ -//Margin_Padding_Alignment_Sample.cpp file -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Shapes; -using namespace System::Threading; - -namespace Margin_Padding_Alignment_Sample { - - public ref class app : Application { - - private: - Border^ myBorder; - Grid^ myGrid; - Window^ mainWindow; - - protected: - virtual void OnStartup (StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // - mainWindow = gcnew Window(); - - // - myBorder = gcnew Border(); - myBorder->Background = Brushes::LightBlue; - myBorder->BorderBrush = Brushes::Black; - myBorder->BorderThickness = Thickness(2); - myBorder->CornerRadius = CornerRadius(45); - myBorder->Padding = Thickness(25); - // - - // Define the Grid. - myGrid = gcnew Grid(); - myGrid->Background = Brushes::White; - myGrid->ShowGridLines = true; - - // Define the Columns. - ColumnDefinition^ myColDef1 = gcnew ColumnDefinition(); - myColDef1->Width = GridLength(1, GridUnitType::Auto); - ColumnDefinition^ myColDef2 = gcnew ColumnDefinition(); - myColDef2->Width = GridLength(1, GridUnitType::Star); - ColumnDefinition^ myColDef3 = gcnew ColumnDefinition(); - myColDef3->Width = GridLength(1, GridUnitType::Auto); - - // Add the ColumnDefinitions to the Grid. - myGrid->ColumnDefinitions->Add(myColDef1); - myGrid->ColumnDefinitions->Add(myColDef2); - myGrid->ColumnDefinitions->Add(myColDef3); - - // Add the first child StackPanel. - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->HorizontalAlignment = HorizontalAlignment::Left; - myStackPanel->VerticalAlignment = VerticalAlignment::Top; - Grid::SetColumn(myStackPanel, 0); - Grid::SetRow(myStackPanel, 0); - TextBlock^ myTextBlock1 = gcnew TextBlock(); - myTextBlock1->FontSize = 18; - myTextBlock1->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock1->Margin = Thickness(0, 0, 0, 15); - myTextBlock1->Text = "StackPanel 1"; - // - Button^ myButton1 = gcnew Button(); - myButton1->Margin = Thickness(0, 10, 0, 10); - myButton1->Content = "Button 1"; - Button^ myButton2 = gcnew Button(); - myButton2->Margin = Thickness(0, 10, 0, 10); - myButton2->Content = "Button 2"; - Button^ myButton3 = gcnew Button(); - myButton3->Margin = Thickness(0, 10, 0, 10); - // - TextBlock^ myTextBlock2 = gcnew TextBlock(); - myTextBlock2->Text = "ColumnDefinition.Width = \"Auto\""; - TextBlock^ myTextBlock3 = gcnew TextBlock(); - myTextBlock3->Text = "StackPanel.HorizontalAlignment = \"Left\""; - TextBlock^ myTextBlock4 = gcnew TextBlock(); - myTextBlock4->Text = "StackPanel.VerticalAlignment = \"Top\""; - TextBlock^ myTextBlock5 = gcnew TextBlock(); - myTextBlock5->Text = "StackPanel.Orientation = \"Vertical\""; - TextBlock^ myTextBlock6 = gcnew TextBlock(); - myTextBlock6->Text = "Button.Margin = \"1,10,0,10\""; - myStackPanel->Children->Add(myTextBlock1); - myStackPanel->Children->Add(myButton1); - myStackPanel->Children->Add(myButton2); - myStackPanel->Children->Add(myButton3); - myStackPanel->Children->Add(myTextBlock2); - myStackPanel->Children->Add(myTextBlock3); - myStackPanel->Children->Add(myTextBlock4); - myStackPanel->Children->Add(myTextBlock5); - myStackPanel->Children->Add(myTextBlock6); - - // Add the second child StackPanel. - StackPanel^ myStackPanel2 = gcnew StackPanel(); - myStackPanel2->HorizontalAlignment = HorizontalAlignment::Stretch; - myStackPanel2->VerticalAlignment = VerticalAlignment::Top; - myStackPanel2->Orientation = Orientation::Vertical; - Grid::SetColumn(myStackPanel2, 1); - Grid::SetRow(myStackPanel2, 0); - TextBlock^ myTextBlock7 = gcnew TextBlock(); - myTextBlock7->FontSize = 18; - myTextBlock7->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock7->Margin = Thickness(0, 0, 0, 15); - myTextBlock7->Text = "StackPanel 2"; - Button^ myButton4 = gcnew Button(); - myButton4->Margin = Thickness(10, 0, 10, 0); - myButton4->Content = "Button 4"; - Button^ myButton5 = gcnew Button(); - myButton5->Margin = Thickness(10, 0, 10, 0); - myButton5->Content = "Button 5"; - Button^ myButton6 = gcnew Button(); - myButton6->Margin = Thickness(10, 0, 10, 0); - myButton6->Content = "Button 6"; - TextBlock^ myTextBlock8 = gcnew TextBlock(); - myTextBlock8->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock8->Text = "ColumnDefinition.Width = \"*\""; - TextBlock^ myTextBlock9 = gcnew TextBlock(); - myTextBlock9->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock9->Text = "StackPanel.HorizontalAlignment = \"Stretch\""; - TextBlock^ myTextBlock10 = gcnew TextBlock(); - myTextBlock10->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock10->Text = "StackPanel.VerticalAlignment = \"Top\""; - TextBlock^ myTextBlock11 = gcnew TextBlock(); - myTextBlock11->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock11->Text = "StackPanel.Orientation = \"Horizontal\""; - TextBlock^ myTextBlock12 = gcnew TextBlock(); - myTextBlock12->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock12->Text = "Button.Margin = \"10,0,10,0\""; - myStackPanel2->Children->Add(myTextBlock7); - myStackPanel2->Children->Add(myButton4); - myStackPanel2->Children->Add(myButton5); - myStackPanel2->Children->Add(myButton6); - myStackPanel2->Children->Add(myTextBlock8); - myStackPanel2->Children->Add(myTextBlock9); - myStackPanel2->Children->Add(myTextBlock10); - myStackPanel2->Children->Add(myTextBlock11); - myStackPanel2->Children->Add(myTextBlock12); - - // Add the final child StackPanel. - StackPanel^ myStackPanel3 = gcnew StackPanel(); - myStackPanel3->HorizontalAlignment = HorizontalAlignment::Left; - myStackPanel3->VerticalAlignment = VerticalAlignment::Top; - Grid::SetColumn(myStackPanel3, 2); - Grid::SetRow(myStackPanel3, 0); - TextBlock^ myTextBlock13 = gcnew TextBlock(); - myTextBlock13->FontSize = 18; - myTextBlock13->HorizontalAlignment = HorizontalAlignment::Center; - myTextBlock13->Margin = Thickness(0, 0, 0, 15); - myTextBlock13->Text = "StackPanel 3"; - // - Button^ myButton7 = gcnew Button(); - myButton7->Margin = Thickness(10); - myButton7->Content = "Button 7"; - Button^ myButton8 = gcnew Button(); - myButton8->Margin = Thickness(10); - myButton8->Content = "Button 8"; - Button^ myButton9 = gcnew Button(); - myButton9->Margin = Thickness(10); - myButton9->Content = "Button 9"; - // - TextBlock^ myTextBlock14 = gcnew TextBlock(); - myTextBlock14->Text = "ColumnDefinition.Width = \"Auto\""; - TextBlock^ myTextBlock15 = gcnew TextBlock(); - myTextBlock15->Text = "StackPanel.HorizontalAlignment = \"Left\""; - TextBlock^ myTextBlock16 = gcnew TextBlock(); - myTextBlock16->Text = "StackPanel.VerticalAlignment = \"Top\""; - TextBlock^ myTextBlock17 = gcnew TextBlock(); - myTextBlock17->Text = "StackPanel.Orientation = \"Vertical\""; - TextBlock^ myTextBlock18 = gcnew TextBlock(); - myTextBlock18->Text = "Button.Margin = \"10\""; - myStackPanel3->Children->Add(myTextBlock13); - myStackPanel3->Children->Add(myButton7); - myStackPanel3->Children->Add(myButton8); - myStackPanel3->Children->Add(myButton9); - myStackPanel3->Children->Add(myTextBlock14); - myStackPanel3->Children->Add(myTextBlock15); - myStackPanel3->Children->Add(myTextBlock16); - myStackPanel3->Children->Add(myTextBlock17); - myStackPanel3->Children->Add(myTextBlock18); - - // Add child content to the parent Grid. - myGrid->Children->Add(myStackPanel); - myGrid->Children->Add(myStackPanel2); - myGrid->Children->Add(myStackPanel3); - - // Add the Grid as the lone child of the Border. - myBorder->Child = myGrid; - - // Add the Border to the Window as Content and show the Window. - mainWindow->Content = myBorder; - mainWindow->Title = "Margin, Padding, and Alignment Sample"; - mainWindow->Show(); - // - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - Margin_Padding_Alignment_Sample::app^ app = gcnew Margin_Padding_Alignment_Sample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return Margin_Padding_Alignment_Sample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/MarginPaddingAlignmentSample/CPP/margin_padding_alignment_sample.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/MarginPaddingAlignmentSample/CPP/margin_padding_alignment_sample.vcxproj deleted file mode 100644 index c7ea1dd116812..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/MarginPaddingAlignmentSample/CPP/margin_padding_alignment_sample.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21230.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/PlotPanel/CPP/PlotPanel.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/PlotPanel/CPP/PlotPanel.cpp deleted file mode 100644 index c9a768363223d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/PlotPanel/CPP/PlotPanel.cpp +++ /dev/null @@ -1,101 +0,0 @@ -//PlotPanel.cpp file -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Shapes; -using namespace System::Windows::Media; -using namespace System::Threading; - -namespace PlotPanel { - - public ref class app : System::Windows::Application { - - // - public: - ref class PlotPanel : Panel { - - public: - PlotPanel () {}; - - protected: - // Override the default Measure method of Panel - // - virtual Size MeasureOverride(Size availableSize) override - { - Size^ panelDesiredSize = gcnew Size(); - - // In our example, we just have one child. - // Report that our panel requires just the size of its only child. - for each (UIElement^ child in InternalChildren) - { - child->Measure(availableSize); - panelDesiredSize = child->DesiredSize; - } - return *panelDesiredSize ; - } - // - - protected: - virtual System::Windows::Size ArrangeOverride (Size finalSize) override - { - for each (UIElement^ child in InternalChildren) - { - double x = 50; - double y = 50; - child->Arrange(Rect(Point(x, y), child->DesiredSize)); - } - return finalSize; - }; - }; - // - - private: - PlotPanel^ plot1; - Window^ mainWindow; - Shapes::Rectangle^ rect1; - - protected: - virtual void OnStartup (StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // Create the application's main window - - mainWindow = gcnew Window(); - plot1 = gcnew PlotPanel(); - plot1->Background = Brushes::White; - - rect1 = gcnew Shapes::Rectangle(); - rect1->Fill = Brushes::CornflowerBlue; - rect1->Width = 200; - rect1->Height = 200; - mainWindow->Content = plot1; - plot1->Children->Add(rect1); - mainWindow->Title = "Custom Panel Sample"; - mainWindow->Show(); - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - PlotPanel::app^ app = gcnew PlotPanel::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return PlotPanel::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/PlotPanel/CPP/plotpanel.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/PlotPanel/CPP/plotpanel.vcxproj deleted file mode 100644 index 4c075c21996d9..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/PlotPanel/CPP/plotpanel.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp deleted file mode 100644 index 31e7053f823d5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp +++ /dev/null @@ -1,130 +0,0 @@ -//PngEncoderDecoder.cpp file - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; -using namespace System::Security; - - -namespace SDKSample { - - public ref class app : Application { - - private: Window^ mainWindow; - - protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: void CreateAndShowMainWindow () - { - - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "PNG Imaging Sample"; - ScrollViewer^ mySV = gcnew ScrollViewer(); - - // - int width = 128; - int height = 128; - int stride = width; - array^ pixels = gcnew array(height * stride); - - // Define the image palette - BitmapPalette^ myPalette = BitmapPalettes::Halftone256; - - // Creates a new empty image with the pre-defined palette - - // - BitmapSource^ image = BitmapSource::Create(width, - height, - 96, - 96, - PixelFormats::Indexed8, - myPalette, - pixels, - stride); - // - - // - FileStream^ stream = gcnew FileStream("new.png", FileMode::Create); - PngBitmapEncoder^ encoder = gcnew PngBitmapEncoder(); - TextBlock^ myTextBlock = gcnew TextBlock(); - myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString(); - encoder->Interlace = PngInterlaceOption::On; - encoder->Frames->Add(BitmapFrame::Create(image)); - encoder->Save(stream); - // - - // - - // - - // Open a Stream and decode a PNG image - Stream^ imageStreamSource = gcnew FileStream("smiley.png", FileMode::Open, FileAccess::Read, FileShare::Read); - PngBitmapDecoder^ decoder = gcnew PngBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource = decoder->Frames[0]; - - // Draw the Image - Image^ myImage = gcnew Image(); - myImage->Source = bitmapSource; - myImage->Stretch = Stretch::None; - myImage->Margin = System::Windows::Thickness(20); - // - - // - - // Open a Uri and decode a PNG image - System::Uri^ myUri = gcnew System::Uri("smiley.png", UriKind::RelativeOrAbsolute); - PngBitmapDecoder^ decoder2 = gcnew PngBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource2 = decoder2->Frames[0]; - - // Draw the Image - Image^ myImage2 = gcnew Image(); - myImage2->Source = bitmapSource2; - myImage2->Stretch = Stretch::None; - myImage2->Margin = System::Windows::Thickness(20); - // - - // Define a StackPanel to host the decoded PNG images - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Vertical; - myStackPanel->VerticalAlignment = VerticalAlignment::Stretch; - myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch; - - // Add the Image and TextBlock to the parent Grid - myStackPanel->Children->Add(myImage); - myStackPanel->Children->Add(myImage2); - myStackPanel->Children->Add(myTextBlock); - - // Add the StackPanel as the Content of the Parent Window Object - mySV->Content = myStackPanel; - mainWindow->Content = mySV; - mainWindow->Show(); - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/pngencoderdecoder.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/pngencoderdecoder.vcxproj deleted file mode 100644 index 160ee1fcda544..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/pngencoderdecoder.vcxproj +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/smiley.png b/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/smiley.png deleted file mode 100644 index 1e0b9496cad2e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/smiley.png and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/PrinterStatusSurvey/CPP/Program.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/PrinterStatusSurvey/CPP/Program.cpp deleted file mode 100644 index 6f9c51c88d30d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/PrinterStatusSurvey/CPP/Program.cpp +++ /dev/null @@ -1,213 +0,0 @@ -//Program.cpp file -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Text; -using namespace System::Printing; -using namespace System::Collections; -using namespace System::IO; - -namespace PrinterStatusSurvey { - - private ref class TroubleSpotter { - - // - internal: - // Check for possible trouble states of a printer using its properties - static void SpotTroubleUsingProperties (System::String^% statusReport, System::Printing::PrintQueue^ pq) - { - if (pq->HasPaperProblem) - { - statusReport = statusReport + "Has a paper problem. "; - } - if (!(pq->HasToner)) - { - statusReport = statusReport + "Is out of toner. "; - } - if (pq->IsDoorOpened) - { - statusReport = statusReport + "Has an open door. "; - } - if (pq->IsInError) - { - statusReport = statusReport + "Is in an error state. "; - } - if (pq->IsNotAvailable) - { - statusReport = statusReport + "Is not available. "; - } - if (pq->IsOffline) - { - statusReport = statusReport + "Is off line. "; - } - if (pq->IsOutOfMemory) - { - statusReport = statusReport + "Is out of memory. "; - } - if (pq->IsOutOfPaper) - { - statusReport = statusReport + "Is out of paper. "; - } - if (pq->IsOutputBinFull) - { - statusReport = statusReport + "Has a full output bin. "; - } - if (pq->IsPaperJammed) - { - statusReport = statusReport + "Has a paper jam. "; - } - if (pq->IsPaused) - { - statusReport = statusReport + "Is paused. "; - } - if (pq->IsTonerLow) - { - statusReport = statusReport + "Is low on toner. "; - } - if (pq->NeedUserIntervention) - { - statusReport = statusReport + "Needs user intervention. "; - } - - // Check if queue is even available at this time of day - // The following method is defined in the complete example. - ReportAvailabilityAtThisTime(statusReport, pq); - }; - // - - // - internal: - // Check for possible trouble states of a printer using the flags of the QueueStatus property - static void SpotTroubleUsingQueueAttributes (System::String^% statusReport, System::Printing::PrintQueue^ pq) - { - if ((pq->QueueStatus & PrintQueueStatus::PaperProblem) == PrintQueueStatus::PaperProblem) - { - statusReport = statusReport + "Has a paper problem. "; - } - if ((pq->QueueStatus & PrintQueueStatus::NoToner) == PrintQueueStatus::NoToner) - { - statusReport = statusReport + "Is out of toner. "; - } - if ((pq->QueueStatus & PrintQueueStatus::DoorOpen) == PrintQueueStatus::DoorOpen) - { - statusReport = statusReport + "Has an open door. "; - } - if ((pq->QueueStatus & PrintQueueStatus::Error) == PrintQueueStatus::Error) - { - statusReport = statusReport + "Is in an error state. "; - } - if ((pq->QueueStatus & PrintQueueStatus::NotAvailable) == PrintQueueStatus::NotAvailable) - { - statusReport = statusReport + "Is not available. "; - } - if ((pq->QueueStatus & PrintQueueStatus::Offline) == PrintQueueStatus::Offline) - { - statusReport = statusReport + "Is off line. "; - } - if ((pq->QueueStatus & PrintQueueStatus::OutOfMemory) == PrintQueueStatus::OutOfMemory) - { - statusReport = statusReport + "Is out of memory. "; - } - if ((pq->QueueStatus & PrintQueueStatus::PaperOut) == PrintQueueStatus::PaperOut) - { - statusReport = statusReport + "Is out of paper. "; - } - if ((pq->QueueStatus & PrintQueueStatus::OutputBinFull) == PrintQueueStatus::OutputBinFull) - { - statusReport = statusReport + "Has a full output bin. "; - } - if ((pq->QueueStatus & PrintQueueStatus::PaperJam) == PrintQueueStatus::PaperJam) - { - statusReport = statusReport + "Has a paper jam. "; - } - if ((pq->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused) - { - statusReport = statusReport + "Is paused. "; - } - if ((pq->QueueStatus & PrintQueueStatus::TonerLow) == PrintQueueStatus::TonerLow) - { - statusReport = statusReport + "Is low on toner. "; - } - if ((pq->QueueStatus & PrintQueueStatus::UserIntervention) == PrintQueueStatus::UserIntervention) - { - statusReport = statusReport + "Needs user intervention. "; - } - - // Check if queue is even available at this time of day - // The method below is defined in the complete example. - ReportAvailabilityAtThisTime(statusReport, pq); - }; - // - - // - private: - static void ReportAvailabilityAtThisTime (System::String^% statusReport, System::Printing::PrintQueue^ pq) - { - if (pq->StartTimeOfDay != pq->UntilTimeOfDay) - { - System::DateTime utcNow = DateTime::UtcNow; - System::Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes; - - // If now is not within the range of available times . . . - if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay))) - { - statusReport = statusReport + " Is not available at this time of day. "; - } - } - }; - // - }; - - private ref class Program { - - public: - static void Main (array^ args) - { - // Obtain a list of print servers - Console::Write("Enter path and file name of CRLF-delimited list of print servers: "); - System::String^ pathToListOfPrintServers = Console::ReadLine(); - System::IO::StreamReader^ fileOfPrintServers = gcnew System::IO::StreamReader(pathToListOfPrintServers); - - // Prompt user to determine the method of reading queue status that will be used - Console::Write("Enter \"y\" to check queues using their QueueStatus attributes.\nOtherwise, press Return and they will be checked using their specific properties: "); - System::String^ useAttributesResponse = Console::ReadLine(); - - // - // Survey queue status for every queue on every print server - System::String^ line; - System::String^ statusReport = "\n\nAny problem states are indicated below:\n\n"; - while ((line = fileOfPrintServers->ReadLine()) != nullptr) - { - System::Printing::PrintServer^ myPS = gcnew System::Printing::PrintServer(line, PrintSystemDesiredAccess::AdministrateServer); - System::Printing::PrintQueueCollection^ myPrintQueues = myPS->GetPrintQueues(); - statusReport = statusReport + "\n" + line; - for each (System::Printing::PrintQueue^ pq in myPrintQueues) - { - pq->Refresh(); - statusReport = statusReport + "\n\t" + pq->Name + ":"; - if (useAttributesResponse == "y") - { - TroubleSpotter::SpotTroubleUsingQueueAttributes(statusReport, pq); - // TroubleSpotter class is defined in the complete example. - } else - { - TroubleSpotter::SpotTroubleUsingProperties(statusReport, pq); - } - } - } - fileOfPrintServers->Close(); - Console::WriteLine(statusReport); - Console::WriteLine("\nPress Return to continue."); - Console::ReadLine(); - // - }; - }; - -} - -//Entry Point: -[System::STAThreadAttribute()] -int main (array^ args) -{ - PrinterStatusSurvey::Program::Main(args); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/PrinterStatusSurvey/CPP/printerstatussurvey.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/PrinterStatusSurvey/CPP/printerstatussurvey.vcxproj deleted file mode 100644 index 4ab6335b9cfdf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/PrinterStatusSurvey/CPP/printerstatussurvey.vcxproj +++ /dev/null @@ -1,127 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21208.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Console - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/ScrollViewer/CPP/ScrollViewer_wcp.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/ScrollViewer/CPP/ScrollViewer_wcp.cpp deleted file mode 100644 index 8739a01220b26..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/ScrollViewer/CPP/ScrollViewer_wcp.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//ScrollViewer_wcp.cpp file - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Shapes; -using namespace System::Threading; - -namespace SDKSample { - - public ref class app : Application { - - private: - ScrollViewer^ myScrollViewer; - StackPanel^ myStackPanel; - Window^ mainWindow; - - protected: - virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // - - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "ScrollViewer Sample"; - - // Define a ScrollViewer - myScrollViewer = gcnew ScrollViewer(); - myScrollViewer->HorizontalScrollBarVisibility = ScrollBarVisibility::Auto; - - // Add Layout control - myStackPanel = gcnew StackPanel(); - myStackPanel->HorizontalAlignment = HorizontalAlignment::Left; - myStackPanel->VerticalAlignment = VerticalAlignment::Top; - - TextBlock^ myTextBlock = gcnew TextBlock(); - myTextBlock->TextWrapping = TextWrapping::Wrap; - myTextBlock->Margin = System::Windows::Thickness(0, 0, 0, 20); - myTextBlock->Text = "Scrolling is enabled when it is necessary. Resize the Window, making it larger and smaller."; - - Rectangle^ myRectangle = gcnew Rectangle(); - myRectangle->Fill = Brushes::Red; - myRectangle->Width = 500; - myRectangle->Height = 500; - - // Add child elements to the parent StackPanel - myStackPanel->Children->Add(myTextBlock); - myStackPanel->Children->Add(myRectangle); - - // Add the StackPanel as the lone Child of the Border - myScrollViewer->Content = myStackPanel; - - // Add the Border as the Content of the Parent Window Object - mainWindow->Content = myScrollViewer; - mainWindow->Show(); - - // - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/ScrollViewer/CPP/scrollviewer_cpp.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/ScrollViewer/CPP/scrollviewer_cpp.vcxproj deleted file mode 100644 index 46659bd0f7573..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/ScrollViewer/CPP/scrollviewer_cpp.vcxproj +++ /dev/null @@ -1,118 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - ScrollViewer - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30109.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/ShapesProcedural/CPP/ShapesProcedural.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/ShapesProcedural/CPP/ShapesProcedural.cpp deleted file mode 100644 index d45a1b4ef20a8..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/ShapesProcedural/CPP/ShapesProcedural.cpp +++ /dev/null @@ -1,264 +0,0 @@ -//ShapesProcedural.cpp file - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Shapes; -using namespace System::Threading; - -namespace ShapesProcedural { - - public ref class app : Application { - - private: - Border^ myBorder; - Rectangle^ myRect; - Ellipse^ myEllipse; - Line^ myLine; - Path^ myPath; - Polygon^ myPolygon; - Polyline^ myPolyline; - Grid^ myGrid; - TextBlock^ myTextBlock; - ColumnDefinition^ myColDef1; - ColumnDefinition^ myColDef2; - RowDefinition^ myRowDef; - RowDefinition^ myRowDef1; - RowDefinition^ myRowDef2; - RowDefinition^ myRowDef3; - RowDefinition^ myRowDef4; - RowDefinition^ myRowDef5; - RowDefinition^ myRowDef6; - Window^ myWindow; - - protected: virtual void OnStartup (StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: void CreateAndShowMainWindow () - { - // Create the application's main window - myWindow = gcnew Window(); - - // Add a Border - myBorder = gcnew Border(); - myBorder->BorderBrush = Brushes::Black; - myBorder->BorderThickness = Thickness(2); - myBorder->Width = 400; - myBorder->Height = 600; - myBorder->Padding = Thickness(15); - myBorder->Background = Brushes::White; - - // Create a Grid to host the Shapes - myGrid = gcnew Grid(); - myGrid->Margin = Thickness(15); - myColDef1 = gcnew ColumnDefinition(); - myColDef1->Width = GridLength(125); - myColDef2 = gcnew ColumnDefinition(); - myColDef2->Width = GridLength(1, GridUnitType::Star); - myGrid->ColumnDefinitions->Add(myColDef1); - myGrid->ColumnDefinitions->Add(myColDef2); - myRowDef = gcnew RowDefinition(); - myRowDef1 = gcnew RowDefinition(); - myRowDef2 = gcnew RowDefinition(); - myRowDef3 = gcnew RowDefinition(); - myRowDef4 = gcnew RowDefinition(); - myRowDef5 = gcnew RowDefinition(); - myRowDef6 = gcnew RowDefinition(); - myGrid->RowDefinitions->Add(myRowDef); - myGrid->RowDefinitions->Add(myRowDef1); - myGrid->RowDefinitions->Add(myRowDef2); - myGrid->RowDefinitions->Add(myRowDef3); - myGrid->RowDefinitions->Add(myRowDef4); - myGrid->RowDefinitions->Add(myRowDef5); - myGrid->RowDefinitions->Add(myRowDef6); - myTextBlock = gcnew TextBlock(); - myTextBlock->FontSize = 20; - myTextBlock->Text = "WPF Shapes Gallery"; - myTextBlock->HorizontalAlignment = HorizontalAlignment::Left; - myTextBlock->VerticalAlignment = VerticalAlignment::Center; - myGrid->Children->Add(myTextBlock); - Grid::SetRow(myTextBlock, 0); - Grid::SetColumnSpan(myTextBlock, 2); - - // - - // Add a Rectangle Element - myRect = gcnew Rectangle(); - myRect->Stroke = Brushes::Black; - myRect->Fill = Brushes::SkyBlue; - myRect->HorizontalAlignment = HorizontalAlignment::Left; - myRect->VerticalAlignment = VerticalAlignment::Center; - myRect->Height = 50; - myRect->Width = 50; - myGrid->Children->Add(myRect); - // - Grid::SetRow(myRect, 1); - Grid::SetColumn(myRect, 0); - TextBlock^ myTextBlock1 = gcnew TextBlock(); - myTextBlock1->FontSize = 14; - myTextBlock1->Text = "A Rectangle Element"; - myTextBlock1->VerticalAlignment = VerticalAlignment::Center; - myGrid->Children->Add(myTextBlock1); - Grid::SetRow(myTextBlock1, 1); - Grid::SetColumn(myTextBlock1, 1); - - // - - // Add an Ellipse Element - myEllipse = gcnew Ellipse(); - myEllipse->Stroke = Brushes::Black; - myEllipse->Fill = Brushes::DarkBlue; - myEllipse->HorizontalAlignment = HorizontalAlignment::Left; - myEllipse->VerticalAlignment = VerticalAlignment::Center; - myEllipse->Width = 50; - myEllipse->Height = 75; - myGrid->Children->Add(myEllipse); - // - Grid::SetRow(myEllipse, 2); - Grid::SetColumn(myEllipse, 0); - TextBlock^ myTextBlock2 = gcnew TextBlock(); - myTextBlock2->FontSize = 14; - myTextBlock2->Text = "An Ellipse Element"; - myTextBlock2->VerticalAlignment = VerticalAlignment::Center; - myGrid->Children->Add(myTextBlock2); - Grid::SetRow(myTextBlock2, 2); - Grid::SetColumn(myTextBlock2, 1); - - // - - // Add a Line Element - myLine = gcnew Line(); - myLine->Stroke = Brushes::LightSteelBlue; - myLine->X1 = 1; - myLine->X2 = 50; - myLine->Y1 = 1; - myLine->Y2 = 50; - myLine->HorizontalAlignment = HorizontalAlignment::Left; - myLine->VerticalAlignment = VerticalAlignment::Center; - myLine->StrokeThickness = 2; - myGrid->Children->Add(myLine); - // - Grid::SetRow(myLine, 3); - Grid::SetColumn(myLine, 0); - TextBlock^ myTextBlock3 = gcnew TextBlock(); - myTextBlock3->FontSize = 14; - myTextBlock3->Text = "A Line Element"; - myTextBlock3->VerticalAlignment = VerticalAlignment::Center; - myGrid->Children->Add(myTextBlock3); - Grid::SetRow(myTextBlock3, 3); - Grid::SetColumn(myTextBlock3, 1); - - // - - //Add the Path Element - myPath = gcnew Path(); - myPath->Stroke = Brushes::Black; - myPath->Fill = Brushes::MediumSlateBlue; - myPath->StrokeThickness = 4; - myPath->HorizontalAlignment = HorizontalAlignment::Left; - myPath->VerticalAlignment = VerticalAlignment::Center; - EllipseGeometry^ myEllipseGeometry = gcnew EllipseGeometry(); - myEllipseGeometry->Center = Point(50, 50); - myEllipseGeometry->RadiusX = 25; - myEllipseGeometry->RadiusY = 25; - myPath->Data = myEllipseGeometry; - myGrid->Children->Add(myPath); - // - Grid::SetRow(myPath, 4); - Grid::SetColumn(myPath, 0); - TextBlock^ myTextBlock4 = gcnew TextBlock(); - myTextBlock4->FontSize = 14; - myTextBlock4->Text = "A Path Element"; - myTextBlock4->VerticalAlignment = VerticalAlignment::Center; - myGrid->Children->Add(myTextBlock4); - Grid::SetRow(myTextBlock4, 4); - Grid::SetColumn(myTextBlock4, 1); - - // - - //Add the Polygon Element - myPolygon = gcnew Polygon(); - myPolygon->Stroke = Brushes::Black; - myPolygon->Fill = Brushes::LightSeaGreen; - myPolygon->StrokeThickness = 2; - myPolygon->HorizontalAlignment = HorizontalAlignment::Left; - myPolygon->VerticalAlignment = VerticalAlignment::Center; - Point Point1 = Point(1, 50); - Point Point2 = Point(10, 80); - Point Point3 = Point(50, 50); - PointCollection^ myPointCollection = gcnew PointCollection(); - myPointCollection->Add(Point1); - myPointCollection->Add(Point2); - myPointCollection->Add(Point3); - myPolygon->Points = myPointCollection; - myGrid->Children->Add(myPolygon); - // - Grid::SetRow(myPolygon, 5); - Grid::SetColumn(myPolygon, 0); - TextBlock^ myTextBlock5 = gcnew TextBlock(); - myTextBlock5->Text = "A Polygon Element"; - myTextBlock5->FontSize = 14; - myTextBlock5->VerticalAlignment = VerticalAlignment::Center; - myGrid->Children->Add(myTextBlock5); - Grid::SetRow(myTextBlock5, 5); - Grid::SetColumn(myTextBlock5, 1); - - // - - // Add the Polyline Element - myPolyline = gcnew Polyline(); - myPolyline->Stroke = Brushes::SlateGray; - myPolyline->StrokeThickness = 2; - myPolyline->FillRule = FillRule::EvenOdd; - Point Point4 = Point(1, 50); - Point Point5 = Point(10, 80); - Point Point6 = Point(20, 40); - PointCollection^ myPointCollection2 = gcnew PointCollection(); - myPointCollection2->Add(Point4); - myPointCollection2->Add(Point5); - myPointCollection2->Add(Point6); - myPolyline->Points = myPointCollection2; - myGrid->Children->Add(myPolyline); - // - Grid::SetRow(myPolyline, 6); - Grid::SetColumn(myPolyline, 0); - TextBlock^ myTextBlock6 = gcnew TextBlock(); - myTextBlock6->FontSize = 14; - myTextBlock6->Text = "A Polyline Element"; - myTextBlock6->VerticalAlignment = VerticalAlignment::Center; - myGrid->Children->Add(myTextBlock6); - Grid::SetRow(myTextBlock6, 6); - Grid::SetColumn(myTextBlock6, 1); - - // Add the Grid to the Window as Content and show the Window - myBorder->Child = myGrid; - myWindow->Content = myBorder; - myWindow->Background = Brushes::LightSlateGray; - myWindow->Title = "Shapes Sample"; - myWindow->Show(); - - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - ShapesProcedural::app^ app = gcnew ShapesProcedural::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return ShapesProcedural::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/ShapesProcedural/CPP/shapesprocedural.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/ShapesProcedural/CPP/shapesprocedural.vcxproj deleted file mode 100644 index 6a714f7e91ce3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/ShapesProcedural/CPP/shapesprocedural.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21230.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/StackPanel_Ovw_Sample4.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/StackPanel_Ovw_Sample4.cpp deleted file mode 100644 index 76064af559338..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/StackPanel_Ovw_Sample4.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//StackPanel_Ovw_Sample4.cpp file - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; - -namespace SDKSample { - - public ref class app : Application { - - private: - Border^ myBorder; - Grid^ myGrid; - StackPanel^ myStackPanel; - DockPanel^ myDockPanel; - System::Windows::Window^ mainWindow; - - protected: - virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // - - // Create the application's main window - mainWindow = gcnew Window(); - mainWindow->Title = "StackPanel vs. DockPanel"; - - // Add root Grid - myGrid = gcnew Grid(); - myGrid->Width = 175; - myGrid->Height = 150; - RowDefinition^ myRowDef1 = gcnew RowDefinition(); - RowDefinition^ myRowDef2 = gcnew RowDefinition(); - myGrid->RowDefinitions->Add(myRowDef1); - myGrid->RowDefinitions->Add(myRowDef2); - - // Define the DockPanel - myDockPanel = gcnew DockPanel(); - Grid::SetRow(myDockPanel, 0); - - //Define an Image and Source - Image^ myImage = gcnew Image(); - BitmapImage^ bi = gcnew BitmapImage(); - bi->BeginInit(); - bi->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative); - bi->EndInit(); - myImage->Source = bi; - - Image^ myImage2 = gcnew Image(); - BitmapImage^ bi2 = gcnew BitmapImage(); - bi2->BeginInit(); - bi2->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative); - bi2->EndInit(); - myImage2->Source = bi2; - - // - Image^ myImage3 = gcnew Image(); - BitmapImage^ bi3 = gcnew BitmapImage(); - bi3->BeginInit(); - bi3->UriSource = gcnew System::Uri("smiley_stackpanel.PNG", UriKind::Relative); - bi3->EndInit(); - myImage3->Stretch = Stretch::Fill; - myImage3->Source = bi3; - // - - // Add the images to the parent DockPanel - myDockPanel->Children->Add(myImage); - myDockPanel->Children->Add(myImage2); - myDockPanel->Children->Add(myImage3); - - //Define a StackPanel - myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Horizontal; - Grid::SetRow(myStackPanel, 1); - - Image^ myImage4 = gcnew Image(); - BitmapImage^ bi4 = gcnew BitmapImage(); - bi4->BeginInit(); - bi4->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative); - bi4->EndInit(); - myImage4->Source = bi4; - - Image^ myImage5 = gcnew Image(); - BitmapImage^ bi5 = gcnew BitmapImage(); - bi5->BeginInit(); - bi5->UriSource = gcnew System::Uri("smiley_stackpanel.png", UriKind::Relative); - bi5->EndInit(); - myImage5->Source = bi5; - - Image^ myImage6 = gcnew Image(); - BitmapImage^ bi6 = gcnew BitmapImage(); - bi6->BeginInit(); - bi6->UriSource = gcnew System::Uri("smiley_stackpanel.PNG", UriKind::Relative); - bi6->EndInit(); - myImage6->Stretch = Stretch::Fill; - myImage6->Source = bi6; - - // Add the images to the parent StackPanel - myStackPanel->Children->Add(myImage4); - myStackPanel->Children->Add(myImage5); - myStackPanel->Children->Add(myImage6); - - // Add the layout panels as children of the Grid - myGrid->Children->Add(myDockPanel); - myGrid->Children->Add(myStackPanel); - - // Add the Grid as the Content of the Parent Window Object - mainWindow->Content = myGrid; - mainWindow->Show(); - - // - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/smiley_stackpanel.PNG b/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/smiley_stackpanel.PNG deleted file mode 100644 index 1e0b9496cad2e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/smiley_stackpanel.PNG and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/stackpanel_ovw_sample4.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/stackpanel_ovw_sample4.vcxproj deleted file mode 100644 index d51e412a035b1..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/StackPanelOvw4/CPP/stackpanel_ovw_sample4.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/app.xaml b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/app.xaml deleted file mode 100644 index 99fa837118352..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/app.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/d3dhost.csproj b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/d3dhost.csproj deleted file mode 100644 index 7a9be6d662c6a..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/d3dhost.csproj +++ /dev/null @@ -1,93 +0,0 @@ - - - Debug - AnyCPU - 10.0.20821 - 2.0 - {D1FC6F31-1F0B-4085-96A6-B9B55944CCC0} - WinExe - Properties - D3DHost - D3DHost - v4.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - Client - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - 3.5 - - - 3.5 - - - 3.5 - - - - - - - - 4.0 - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Window1.xaml - Code - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/dllmain.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/dllmain.cpp deleted file mode 100644 index 0be6a655d208d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/dllmain.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -// dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -static CRendererManager *pManager = NULL; - -static HRESULT EnsureRendererManager() -{ - return pManager ? S_OK : CRendererManager::Create(&pManager); -} - -extern "C" HRESULT WINAPI SetSize(UINT uWidth, UINT uHeight) -{ - HRESULT hr = S_OK; - - IFC(EnsureRendererManager()); - - pManager->SetSize(uWidth, uHeight); - -Cleanup: - return hr; -} - -extern "C" HRESULT WINAPI SetAlpha(BOOL fUseAlpha) -{ - HRESULT hr = S_OK; - - IFC(EnsureRendererManager()); - - pManager->SetAlpha(!!fUseAlpha); - -Cleanup: - return hr; -} - -extern "C" HRESULT WINAPI SetNumDesiredSamples(UINT uNumSamples) -{ - HRESULT hr = S_OK; - - IFC(EnsureRendererManager()); - - pManager->SetNumDesiredSamples(uNumSamples); - -Cleanup: - return hr; -} - -extern "C" HRESULT WINAPI SetAdapter(POINT screenSpacePoint) -{ - HRESULT hr = S_OK; - - IFC(EnsureRendererManager()); - - pManager->SetAdapter(screenSpacePoint); - -Cleanup: - return hr; -} - -extern "C" HRESULT WINAPI GetBackBufferNoRef(IDirect3DSurface9 **ppSurface) -{ - HRESULT hr = S_OK; - - IFC(EnsureRendererManager()); - - IFC(pManager->GetBackBufferNoRef(ppSurface)); - -Cleanup: - return hr; -} - -extern "C" HRESULT WINAPI Render() -{ - assert(pManager); - - return pManager->Render(); -} - -extern "C" void WINAPI Destroy() -{ - delete pManager; - pManager = NULL; -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderer.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderer.cpp deleted file mode 100644 index 08c2b115d795d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderer.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// -//+----------------------------------------------------------------------------- -// -// CRenderer -// -// An abstract base class that creates a device and a target render -// surface. Derive from this class and override Init() and Render() -// to do your own rendering. See CTriangleRenderer for an example. - - -//------------------------------------------------------------------------------ - -#include "StdAfx.h" - -//+----------------------------------------------------------------------------- -// -// Member: -// CRenderer ctor -// -//------------------------------------------------------------------------------ -CRenderer::CRenderer() : m_pd3dDevice(NULL), m_pd3dDeviceEx(NULL), m_pd3dRTS(NULL) -{ -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRenderer dtor -// -//------------------------------------------------------------------------------ -CRenderer::~CRenderer() -{ - SAFE_RELEASE(m_pd3dDevice); - SAFE_RELEASE(m_pd3dDeviceEx); - SAFE_RELEASE(m_pd3dRTS); -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRenderer::CheckDeviceState -// -// Synopsis: -// Returns the status of the device. 9Ex devices are a special case because -// TestCooperativeLevel() has been deprecated in 9Ex. -// -//------------------------------------------------------------------------------ -HRESULT -CRenderer::CheckDeviceState() -{ - if (m_pd3dDeviceEx) - { - return m_pd3dDeviceEx->CheckDeviceState(NULL); - } - else if (m_pd3dDevice) - { - return m_pd3dDevice->TestCooperativeLevel(); - } - else - { - return D3DERR_DEVICELOST; - } -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRenderer::CreateSurface -// -// Synopsis: -// Creates and sets the render target -// -//------------------------------------------------------------------------------ -// -HRESULT -CRenderer::CreateSurface(UINT uWidth, UINT uHeight, bool fUseAlpha, UINT m_uNumSamples) -{ - HRESULT hr = S_OK; - - SAFE_RELEASE(m_pd3dRTS); - - IFC(m_pd3dDevice->CreateRenderTarget( - uWidth, - uHeight, - fUseAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8, - static_cast(m_uNumSamples), - 0, - m_pd3dDeviceEx ? FALSE : TRUE, // Lockable RT required for good XP perf - &m_pd3dRTS, - NULL - )); - - IFC(m_pd3dDevice->SetRenderTarget(0, m_pd3dRTS)); - -Cleanup: - return hr; -} -// - -//+----------------------------------------------------------------------------- -// -// Member: -// CRenderer::Init -// -// Synopsis: -// Creates the device -// -//------------------------------------------------------------------------------ -// -HRESULT -CRenderer::Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter) -{ - HRESULT hr = S_OK; - - D3DPRESENT_PARAMETERS d3dpp; - ZeroMemory(&d3dpp, sizeof(d3dpp)); - d3dpp.Windowed = TRUE; - d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; - d3dpp.BackBufferHeight = 1; - d3dpp.BackBufferWidth = 1; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - - D3DCAPS9 caps; - DWORD dwVertexProcessing; - IFC(pD3D->GetDeviceCaps(uAdapter, D3DDEVTYPE_HAL, &caps)); - if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == D3DDEVCAPS_HWTRANSFORMANDLIGHT) - { - dwVertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING; - } - else - { - dwVertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING; - } - - if (pD3DEx) - { - IDirect3DDevice9Ex *pd3dDevice = NULL; - IFC(pD3DEx->CreateDeviceEx( - uAdapter, - D3DDEVTYPE_HAL, - hwnd, - dwVertexProcessing | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, - &d3dpp, - NULL, - &m_pd3dDeviceEx - )); - - IFC(m_pd3dDeviceEx->QueryInterface(__uuidof(IDirect3DDevice9), reinterpret_cast(&m_pd3dDevice))); - } - else - { - assert(pD3D); - - IFC(pD3D->CreateDevice( - uAdapter, - D3DDEVTYPE_HAL, - hwnd, - dwVertexProcessing | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, - &d3dpp, - &m_pd3dDevice - )); - } - -Cleanup: - return hr; -} -// -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderer.h b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderer.h deleted file mode 100644 index a11c58d022731..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderer.h +++ /dev/null @@ -1,28 +0,0 @@ -// - -#pragma once - -class CRenderer -{ -public: - virtual ~CRenderer(); - - HRESULT CheckDeviceState(); - HRESULT CreateSurface(UINT uWidth, UINT uHeight, bool fUseAlpha, UINT m_uNumSamples); - - virtual HRESULT Render() = 0; - - IDirect3DSurface9 *GetSurfaceNoRef() { return m_pd3dRTS; } - -protected: - CRenderer(); - - virtual HRESULT Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter); - - IDirect3DDevice9 *m_pd3dDevice; - IDirect3DDevice9Ex *m_pd3dDeviceEx; - - IDirect3DSurface9 *m_pd3dRTS; - -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderermanager.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderermanager.cpp deleted file mode 100644 index e53387adb403d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderermanager.cpp +++ /dev/null @@ -1,518 +0,0 @@ -// - -//+----------------------------------------------------------------------------- -// -// CRendererManager -// -// Manages the list of CRenderers. Managed code pinvokes into this class -// and this class forwards to the appropriate CRenderer. -// -//------------------------------------------------------------------------------ - -#include "StdAfx.h" - -const static TCHAR szAppName[] = TEXT("D3DImageSample"); -typedef HRESULT (WINAPI *DIRECT3DCREATE9EXFUNCTION)(UINT SDKVersion, IDirect3D9Ex**); - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager ctor -// -//------------------------------------------------------------------------------ -CRendererManager::CRendererManager() - : - m_pD3D(NULL), - m_pD3DEx(NULL), - m_cAdapters(0), - m_hwnd(NULL), - m_pCurrentRenderer(NULL), - m_rgRenderers(NULL), - m_uWidth(1024), - m_uHeight(1024), - m_uNumSamples(0), - m_fUseAlpha(false), - m_fSurfaceSettingsChanged(true) -{ - -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager dtor -// -//------------------------------------------------------------------------------ -CRendererManager::~CRendererManager() -{ - DestroyResources(); - - if (m_hwnd) - { - DestroyWindow(m_hwnd); - UnregisterClass(szAppName, NULL); - } -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::Create -// -// Synopsis: -// Creates the manager -// -//------------------------------------------------------------------------------ -HRESULT -CRendererManager::Create(CRendererManager **ppManager) -{ - HRESULT hr = S_OK; - - *ppManager = new CRendererManager(); - IFCOOM(*ppManager); - -Cleanup: - return hr; -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::EnsureRenderers -// -// Synopsis: -// Makes sure the CRenderer objects exist -// -//------------------------------------------------------------------------------ -HRESULT -CRendererManager::EnsureRenderers() -{ - HRESULT hr = S_OK; - - if (!m_rgRenderers) - { - IFC(EnsureHWND()); - - assert(m_cAdapters); - m_rgRenderers = new CRenderer*[m_cAdapters]; - IFCOOM(m_rgRenderers); - ZeroMemory(m_rgRenderers, m_cAdapters * sizeof(m_rgRenderers[0])); - - for (UINT i = 0; i < m_cAdapters; ++i) - { - IFC(CTriangleRenderer::Create(m_pD3D, m_pD3DEx, m_hwnd, i, &m_rgRenderers[i])); - } - - // Default to the default adapter - m_pCurrentRenderer = m_rgRenderers[0]; - } - -Cleanup: - return hr; -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::EnsureHWND -// -// Synopsis: -// Makes sure an HWND exists if we need it -// -//------------------------------------------------------------------------------ -// -HRESULT -CRendererManager::EnsureHWND() -{ - HRESULT hr = S_OK; - - if (!m_hwnd) - { - WNDCLASS wndclass; - - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = DefWindowProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = NULL; - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = szAppName; - - if (!RegisterClass(&wndclass)) - { - IFC(E_FAIL); - } - - m_hwnd = CreateWindow(szAppName, - TEXT("D3DImageSample"), - WS_OVERLAPPEDWINDOW, - 0, // Initial X - 0, // Initial Y - 0, // Width - 0, // Height - NULL, - NULL, - NULL, - NULL); - } - -Cleanup: - return hr; -} -// - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::EnsureD3DObjects -// -// Synopsis: -// Makes sure the D3D objects exist -// -//------------------------------------------------------------------------------ -// -HRESULT -CRendererManager::EnsureD3DObjects() -{ - HRESULT hr = S_OK; - - HMODULE hD3D = NULL; - if (!m_pD3D) - { - hD3D = LoadLibrary(TEXT("d3d9.dll")); - DIRECT3DCREATE9EXFUNCTION pfnCreate9Ex = (DIRECT3DCREATE9EXFUNCTION)GetProcAddress(hD3D, "Direct3DCreate9Ex"); - if (pfnCreate9Ex) - { - IFC((*pfnCreate9Ex)(D3D_SDK_VERSION, &m_pD3DEx)); - IFC(m_pD3DEx->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast(&m_pD3D))); - } - else - { - m_pD3D = Direct3DCreate9(D3D_SDK_VERSION); - if (!m_pD3D) - { - IFC(E_FAIL); - } - } - - m_cAdapters = m_pD3D->GetAdapterCount(); - } - -Cleanup: - if (hD3D) - { - FreeLibrary(hD3D); - } - - return hr; -} -// - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::CleanupInvalidDevices -// -// Synopsis: -// Checks to see if any devices are bad and if so, deletes all resources -// -// We could delete resources and wait for D3DERR_DEVICENOTRESET and reset -// the devices, but if the device is lost because of an adapter order -// change then our existing D3D objects would have stale adapter -// information. We'll delete everything to be safe rather than sorry. -// -//------------------------------------------------------------------------------ -void -CRendererManager::CleanupInvalidDevices() -{ - for (UINT i = 0; i < m_cAdapters; ++i) - { - if (FAILED(m_rgRenderers[i]->CheckDeviceState())) - { - DestroyResources(); - break; - } - } -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::GetBackBufferNoRef -// -// Synopsis: -// Returns the surface of the current renderer without adding a reference -// -// This can return NULL if we're in a bad device state. -// -//------------------------------------------------------------------------------ -HRESULT -CRendererManager::GetBackBufferNoRef(IDirect3DSurface9 **ppSurface) -{ - HRESULT hr = S_OK; - - // Make sure we at least return NULL - *ppSurface = NULL; - - CleanupInvalidDevices(); - - IFC(EnsureD3DObjects()); - - // - // Even if we never render to another adapter, this sample creates devices - // and resources on each one. This is a potential waste of video memory, - // but it guarantees that we won't have any problems (e.g. out of video - // memory) when switching to render on another adapter. In your own code - // you may choose to delay creation but you'll need to handle the issues - // that come with it. - // - - IFC(EnsureRenderers()); - - if (m_fSurfaceSettingsChanged) - { - if (FAILED(TestSurfaceSettings())) - { - IFC(E_FAIL); - } - - for (UINT i = 0; i < m_cAdapters; ++i) - { - IFC(m_rgRenderers[i]->CreateSurface(m_uWidth, m_uHeight, m_fUseAlpha, m_uNumSamples)); - } - - m_fSurfaceSettingsChanged = false; - } - - if (m_pCurrentRenderer) - { - *ppSurface = m_pCurrentRenderer->GetSurfaceNoRef(); - } - -Cleanup: - // If we failed because of a bad device, ignore the failure for now and - // we'll clean up and try again next time. - if (hr == D3DERR_DEVICELOST) - { - hr = S_OK; - } - - return hr; -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::TestSurfaceSettings -// -// Synopsis: -// Checks to see if our current surface settings are allowed on all -// adapters. -// -//------------------------------------------------------------------------------ -// -HRESULT -CRendererManager::TestSurfaceSettings() -{ - HRESULT hr = S_OK; - - D3DFORMAT fmt = m_fUseAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8; - - // - // We test all adapters because because we potentially use all adapters. - // But even if this sample only rendered to the default adapter, you - // should check all adapters because WPF may move your surface to - // another adapter for you! - // - - for (UINT i = 0; i < m_cAdapters; ++i) - { - // Can we get HW rendering? - IFC(m_pD3D->CheckDeviceType( - i, - D3DDEVTYPE_HAL, - D3DFMT_X8R8G8B8, - fmt, - TRUE - )); - - // Is the format okay? - IFC(m_pD3D->CheckDeviceFormat( - i, - D3DDEVTYPE_HAL, - D3DFMT_X8R8G8B8, - D3DUSAGE_RENDERTARGET | D3DUSAGE_DYNAMIC, // We'll use dynamic when on XP - D3DRTYPE_SURFACE, - fmt - )); - - // D3DImage only allows multisampling on 9Ex devices. If we can't - // multisample, overwrite the desired number of samples with 0. - if (m_pD3DEx && m_uNumSamples > 1) - { - assert(m_uNumSamples <= 16); - - if (FAILED(m_pD3D->CheckDeviceMultiSampleType( - i, - D3DDEVTYPE_HAL, - fmt, - TRUE, - static_cast(m_uNumSamples), - NULL - ))) - { - m_uNumSamples = 0; - } - } - else - { - m_uNumSamples = 0; - } - } - -Cleanup: - return hr; -} -// - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::DestroyResources -// -// Synopsis: -// Delete all D3D resources -// -//------------------------------------------------------------------------------ -void -CRendererManager::DestroyResources() -{ - SAFE_RELEASE(m_pD3D); - SAFE_RELEASE(m_pD3DEx); - - for (UINT i = 0; i < m_cAdapters; ++i) - { - delete m_rgRenderers[i]; - } - delete [] m_rgRenderers; - m_rgRenderers = NULL; - - m_pCurrentRenderer = NULL; - m_cAdapters = 0; - - m_fSurfaceSettingsChanged = true; -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::SetSize -// -// Synopsis: -// Update the size of the surface. Next render will create a new surface. -// -//------------------------------------------------------------------------------ -void -CRendererManager::SetSize(UINT uWidth, UINT uHeight) -{ - if (uWidth != m_uWidth || uHeight != m_uHeight) - { - m_uWidth = uWidth; - m_uHeight = uHeight; - m_fSurfaceSettingsChanged = true; - } -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::SetAlpha -// -// Synopsis: -// Update the format of the surface. Next render will create a new surface. -// -//------------------------------------------------------------------------------ -void -CRendererManager::SetAlpha(bool fUseAlpha) -{ - if (fUseAlpha != m_fUseAlpha) - { - m_fUseAlpha = fUseAlpha; - m_fSurfaceSettingsChanged = true; - } -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::SetNumDesiredSamples -// -// Synopsis: -// Update the MSAA settings of the surface. Next render will create a -// new surface. -// -//------------------------------------------------------------------------------ -void -CRendererManager::SetNumDesiredSamples(UINT uNumSamples) -{ - if (m_uNumSamples != uNumSamples) - { - m_uNumSamples = uNumSamples; - m_fSurfaceSettingsChanged = true; - } -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::SetAdapter -// -// Synopsis: -// Update the current renderer. Next render will use the new renderer. -// -//------------------------------------------------------------------------------ -// -void -CRendererManager::SetAdapter(POINT screenSpacePoint) -{ - CleanupInvalidDevices(); - - // - // After CleanupInvalidDevices, we may not have any D3D objects. Rather than - // recreate them here, ignore the adapter update and wait for render to recreate. - // - - if (m_pD3D && m_rgRenderers) - { - HMONITOR hMon = MonitorFromPoint(screenSpacePoint, MONITOR_DEFAULTTONULL); - - for (UINT i = 0; i < m_cAdapters; ++i) - { - if (hMon == m_pD3D->GetAdapterMonitor(i)) - { - m_pCurrentRenderer = m_rgRenderers[i]; - break; - } - } - } -} -// - -//+----------------------------------------------------------------------------- -// -// Member: -// CRendererManager::Render -// -// Synopsis: -// Forward to the current renderer -// -//------------------------------------------------------------------------------ -HRESULT -CRendererManager::Render() -{ - return m_pCurrentRenderer ? m_pCurrentRenderer->Render() : S_OK; -} -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderermanager.h b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderermanager.h deleted file mode 100644 index 90866fb030378..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/renderermanager.h +++ /dev/null @@ -1,49 +0,0 @@ -// - -#pragma once - -class CRenderer; - -class CRendererManager -{ -public: - static HRESULT Create(CRendererManager **ppManager); - ~CRendererManager(); - - HRESULT EnsureDevices(); - - void SetSize(UINT uWidth, UINT uHeight); - void SetAlpha(bool fUseAlpha); - void SetNumDesiredSamples(UINT uNumSamples); - void SetAdapter(POINT screenSpacePoint); - - HRESULT GetBackBufferNoRef(IDirect3DSurface9 **ppSurface); - - HRESULT Render(); - -private: - CRendererManager(); - - void CleanupInvalidDevices(); - HRESULT EnsureRenderers(); - HRESULT EnsureHWND(); - HRESULT EnsureD3DObjects(); - HRESULT TestSurfaceSettings(); - void DestroyResources(); - - IDirect3D9 *m_pD3D; - IDirect3D9Ex *m_pD3DEx; - - UINT m_cAdapters; - CRenderer **m_rgRenderers; - CRenderer *m_pCurrentRenderer; - - HWND m_hwnd; - - UINT m_uWidth; - UINT m_uHeight; - UINT m_uNumSamples; - bool m_fUseAlpha; - bool m_fSurfaceSettingsChanged; -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/stdafx.h b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/stdafx.h deleted file mode 100644 index eae1506cb4491..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/stdafx.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - -#include -#include - -#include - -#include "RendererManager.h" -#include "Renderer.h" -#include "TriangleRenderer.h" - -#define IFC(x) { hr = (x); if (FAILED(hr)) goto Cleanup; } -#define IFCOOM(x) { if ((x) == NULL) { hr = E_OUTOFMEMORY; IFC(hr); } } -#define SAFE_RELEASE(x) { if (x) { x->Release(); x = NULL; } } - -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/trianglerenderer.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/trianglerenderer.cpp deleted file mode 100644 index 2f8977e6cd2a5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/trianglerenderer.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// - -//+----------------------------------------------------------------------------- -// -// CTriangleRenderer -// -// Subclass of CRenderer that renders a single, spinning triangle -// -//------------------------------------------------------------------------------ - -#include "StdAfx.h" - -struct CUSTOMVERTEX -{ - FLOAT x, y, z; - DWORD color; -}; - -#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE) - -//+----------------------------------------------------------------------------- -// -// Member: -// CTriangleRenderer ctor -// -//------------------------------------------------------------------------------ -CTriangleRenderer::CTriangleRenderer() : CRenderer(), m_pd3dVB(NULL) -{ -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CTriangleRenderer dtor -// -//------------------------------------------------------------------------------ -CTriangleRenderer::~CTriangleRenderer() -{ - SAFE_RELEASE(m_pd3dVB); -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CTriangleRenderer::Create -// -// Synopsis: -// Creates the renderer -// -//------------------------------------------------------------------------------ -HRESULT -CTriangleRenderer::Create(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter, CRenderer **ppRenderer) -{ - HRESULT hr = S_OK; - - CTriangleRenderer *pRenderer = new CTriangleRenderer(); - IFCOOM(pRenderer); - - IFC(pRenderer->Init(pD3D, pD3DEx, hwnd, uAdapter)); - - *ppRenderer = pRenderer; - pRenderer = NULL; - -Cleanup: - delete pRenderer; - - return hr; -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CTriangleRenderer::Init -// -// Synopsis: -// Override of CRenderer::Init that calls base to create the device and -// then creates the CTriangleRenderer-specific resources -// -//------------------------------------------------------------------------------ -HRESULT -CTriangleRenderer::Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter) -{ - HRESULT hr = S_OK; - D3DXMATRIXA16 matView, matProj; - D3DXVECTOR3 vEyePt(0.0f, 0.0f,-5.0f); - D3DXVECTOR3 vLookatPt(0.0f, 0.0f, 0.0f); - D3DXVECTOR3 vUpVec(0.0f, 1.0f, 0.0f); - - // Call base to create the device and render target - IFC(CRenderer::Init(pD3D, pD3DEx, hwnd, uAdapter)); - - // Set up the VB - CUSTOMVERTEX vertices[] = - { - { -1.0f, -1.0f, 0.0f, 0xffff0000, }, // x, y, z, color - { 1.0f, -1.0f, 0.0f, 0xff00ff00, }, - { 0.0f, 1.0f, 0.0f, 0xff00ffff, }, - }; - - IFC(m_pd3dDevice->CreateVertexBuffer(sizeof(vertices), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &m_pd3dVB, NULL)); - - void *pVertices; - IFC(m_pd3dVB->Lock(0, sizeof(vertices), &pVertices, 0)); - memcpy(pVertices, vertices, sizeof(vertices)); - m_pd3dVB->Unlock(); - - // Set up the camera - D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec); - IFC(m_pd3dDevice->SetTransform(D3DTS_VIEW, &matView)); - D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI / 4, 1.0f, 1.0f, 100.0f); - IFC(m_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj)); - - // Set up the global state - IFC(m_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE)); - IFC(m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE)); - IFC(m_pd3dDevice->SetStreamSource(0, m_pd3dVB, 0, sizeof(CUSTOMVERTEX))); - IFC(m_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX)); - -Cleanup: - return hr; -} - -//+----------------------------------------------------------------------------- -// -// Member: -// CTriangleRenderer::Render -// -// Synopsis: -// Renders the rotating triangle -// -//------------------------------------------------------------------------------ -HRESULT -CTriangleRenderer::Render() -{ - HRESULT hr = S_OK; - D3DXMATRIXA16 matWorld; - - IFC(m_pd3dDevice->BeginScene()); - IFC(m_pd3dDevice->Clear( - 0, - NULL, - D3DCLEAR_TARGET, - D3DCOLOR_ARGB(128, 0, 0, 128), // NOTE: Premultiplied alpha! - 1.0f, - 0 - )); - - // Set up the rotation - UINT iTime = GetTickCount() % 1000; - FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f; - D3DXMatrixRotationY(&matWorld, fAngle); - IFC(m_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld)); - - IFC(m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1)); - - IFC(m_pd3dDevice->EndScene()); - -Cleanup: - return hr; -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/trianglerenderer.h b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/trianglerenderer.h deleted file mode 100644 index a848e2bd02d22..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/trianglerenderer.h +++ /dev/null @@ -1,20 +0,0 @@ -// -#pragma once - -class CTriangleRenderer : public CRenderer -{ -public: - static HRESULT Create(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter, CRenderer **ppRenderer); - ~CTriangleRenderer(); - - HRESULT Render(); - -protected: - HRESULT Init(IDirect3D9 *pD3D, IDirect3D9Ex *pD3DEx, HWND hwnd, UINT uAdapter); - -private: - CTriangleRenderer(); - - IDirect3DVertexBuffer9 *m_pd3dVB; -}; -// \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/window1.xaml b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/window1.xaml deleted file mode 100644 index b45b0b9921749..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/window1.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/window1.xaml.cs b/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/window1.xaml.cs deleted file mode 100644 index 38f3021fbe554..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/System.Windows.Interop.D3DImage/cpp/window1.xaml.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Interop; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using System.Windows.Threading; -using System.Runtime.InteropServices; -using System.Security.Permissions; - -namespace D3DHost -{ - public partial class MainWindow : Window - { - public MainWindow() - { - InitializeComponent(); - - // Set up the initial state for the D3DImage. - HRESULT.Check(SetSize(512, 512)); - HRESULT.Check(SetAlpha(false)); - HRESULT.Check(SetNumDesiredSamples(4)); - - // - // Optional: Subscribing to the IsFrontBufferAvailableChanged event. - // - // If you don't render every frame (e.g. you only render in - // reaction to a button click), you should subscribe to the - // IsFrontBufferAvailableChanged event to be notified when rendered content - // is no longer being displayed. This event also notifies you when - // the D3DImage is capable of being displayed again. - - // For example, in the button click case, if you don't render again when - // the IsFrontBufferAvailable property is set to true, your - // D3DImage won't display anything until the next button click. - // - // Because this application renders every frame, there is no need to - // handle the IsFrontBufferAvailableChanged event. - // - CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); - - // - // Optional: Multi-adapter optimization - // - // The surface is created initially on a particular adapter. - // If the WPF window is dragged to another adapter, WPF - // ensures that the D3DImage still shows up on the new - // adapter. - // - // This process is slow on Windows XP. - // - // Performance is better on Vista with a 9Ex device. It's only - // slow when the D3DImage crosses a video-card boundary. - // - // To work around this issue, you can move your surface when - // the D3DImage is displayed on another adapter. To - // determine when that is the case, transform a point on the - // D3DImage into screen space and find out which adapter - // contains that screen space point. - // - // When your D3DImage straddles two adapters, nothing - // can be done, because one will be updating slowly. - // - _adapterTimer = new DispatcherTimer(); - _adapterTimer.Tick += new EventHandler(AdapterTimer_Tick); - _adapterTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); - _adapterTimer.Start(); - - // - // Optional: Surface resizing - // - // The D3DImage is scaled when WPF renders it at a size - // different from the natural size of the surface. If the - // D3DImage is scaled up significantly, image quality - // degrades. - // - // To avoid this, you can either create a very large - // texture initially, or you can create new surfaces as - // the size changes. Below is a very simple example of - // how to do the latter. - // - // By creating a timer at Render priority, you are guaranteed - // that new surfaces are created while the element - // is still being arranged. A 200 ms interval gives - // a good balance between image quality and performance. - // You must be careful not to create new surfaces too - // frequently. Frequently allocating a new surface may - // fragment or exhaust video memory. This issue is more - // significant on XDDM than it is on WDDM, because WDDM - // can page out video memory. - // - // Another approach is deriving from the Image class, - // participating in layout by overriding the ArrangeOverride method, and - // updating size in the overriden method. Performance will degrade - // if you resize too frequently. - // - // Blurry D3DImages can still occur due to subpixel - // alignments. - // - _sizeTimer = new DispatcherTimer(DispatcherPriority.Render); - _sizeTimer.Tick += new EventHandler(SizeTimer_Tick); - _sizeTimer.Interval = new TimeSpan(0, 0, 0, 0, 200); - _sizeTimer.Start(); - } - - ~MainWindow() - { - Destroy(); - } - - void AdapterTimer_Tick(object sender, EventArgs e) - { - POINT p = new POINT(imgelt.PointToScreen(new Point(0, 0))); - - HRESULT.Check(SetAdapter(p)); - } - - void SizeTimer_Tick(object sender, EventArgs e) - { - // The following code does not account for RenderTransforms. - // To handle that case, you must transform up to the root and - // check the size there. - - // Given that the D3DImage is at 96.0 DPI, its Width and Height - // properties will always be integers. ActualWidth/Height - // may not be integers, so they are cast to integers. - uint actualWidth = (uint)imgelt.ActualWidth; - uint actualHeight = (uint)imgelt.ActualHeight; - if ((actualWidth > 0 && actualHeight > 0) && - (actualWidth != (uint)d3dimg.Width || actualHeight != (uint)d3dimg.Height)) - { - HRESULT.Check(SetSize(actualWidth, actualHeight)); - } - } - - void CompositionTarget_Rendering(object sender, EventArgs e) - { - RenderingEventArgs args = (RenderingEventArgs)e; - - // It's possible for Rendering to call back twice in the same frame - // so only render when we haven't already rendered in this frame. - if (d3dimg.IsFrontBufferAvailable && _lastRender != args.RenderingTime) - { - IntPtr pSurface = IntPtr.Zero; - HRESULT.Check(GetBackBufferNoRef(out pSurface)); - if (pSurface != IntPtr.Zero) - { - - d3dimg.Lock(); - // Repeatedly calling SetBackBuffer with the same IntPtr is - // a no-op. There is no performance penalty. - d3dimg.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface); - HRESULT.Check(Render()); - d3dimg.AddDirtyRect(new Int32Rect(0, 0, d3dimg.PixelWidth, d3dimg.PixelHeight)); - d3dimg.Unlock(); - - _lastRender = args.RenderingTime; - } - } - } - - DispatcherTimer _sizeTimer; - DispatcherTimer _adapterTimer; - TimeSpan _lastRender; - - // Import the methods exported by the unmanaged Direct3D content. - - [DllImport("D3DCode.dll")] - static extern int GetBackBufferNoRef(out IntPtr pSurface); - - [DllImport("D3DCode.dll")] - static extern int SetSize(uint width, uint height); - - [DllImport("D3DCode.dll")] - static extern int SetAlpha(bool useAlpha); - - [DllImport("D3DCode.dll")] - static extern int SetNumDesiredSamples(uint numSamples); - - [StructLayout(LayoutKind.Sequential)] - struct POINT - { - public POINT(Point p) - { - x = (int)p.X; - y = (int)p.Y; - } - - public int x; - public int y; - } - - [DllImport("D3DCode.dll")] - static extern int SetAdapter(POINT screenSpacePoint); - - [DllImport("D3DCode.dll")] - static extern int Render(); - - [DllImport("D3DCode.dll")] - static extern void Destroy(); - } - - public static class HRESULT - { - [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] - public static void Check(int hr) - { - Marshal.ThrowExceptionForHR(hr); - } - } -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp deleted file mode 100644 index 685472dce19dc..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp +++ /dev/null @@ -1,130 +0,0 @@ -//TiffEncoderDecoder.cpp file - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; -using namespace System::Security; - - -namespace SDKSample { - - public ref class app : Application { - - private: System::Windows::Window^ mainWindow; - - protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: void CreateAndShowMainWindow () - { - - // Create the application's main window. - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "TIFF Imaging Sample"; - ScrollViewer^ mySV = gcnew ScrollViewer(); - - // - int width = 128; - int height = width; - int stride = width / 8; - array^ pixels = gcnew array(height * stride); - - // Define the image palette. - BitmapPalette^ myPalette = BitmapPalettes::WebPalette; - - // Creates a new empty image with the pre-defined palette. - - // - BitmapSource^ image = BitmapSource::Create(width, - height, - 96, - 96, - PixelFormats::Indexed1, - myPalette, - pixels, - stride); - // - - // - FileStream^ stream = gcnew FileStream("new.tif", FileMode::Create); - TiffBitmapEncoder^ encoder = gcnew TiffBitmapEncoder(); - TextBlock^ myTextBlock = gcnew TextBlock(); - myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString(); - encoder->Compression = TiffCompressOption::Zip; - encoder->Frames->Add(BitmapFrame::Create(image)); - encoder->Save(stream); - // - - // - - // - // Open a Stream and decode a TIFF image. - Stream^ imageStreamSource = gcnew FileStream("tulipfarm.tif", FileMode::Open, FileAccess::Read, FileShare::Read); - TiffBitmapDecoder^ decoder = gcnew TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource = decoder->Frames[0]; - - // Draw the Image. - Image^ myImage = gcnew Image(); - myImage->Source = bitmapSource; - myImage->Stretch = Stretch::None; - myImage->Margin = System::Windows::Thickness(20); - // - - // - - // Open a Uri and decode a TIFF image. - System::Uri^ myUri = gcnew System::Uri("tulipfarm.tif", UriKind::RelativeOrAbsolute); - TiffBitmapDecoder^ decoder2 = gcnew TiffBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource2 = decoder2->Frames[0]; - - // Draw the Image. - Image^ myImage2 = gcnew Image(); - myImage2->Source = bitmapSource2; - myImage2->Stretch = Stretch::None; - myImage2->Margin = System::Windows::Thickness(20); - // - - // Define a StackPanel to host the decoded TIFF images. - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Vertical; - myStackPanel->VerticalAlignment = VerticalAlignment::Stretch; - myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch; - - // Add the Image and TextBlock to the parent Grid. - myStackPanel->Children->Add(myImage); - myStackPanel->Children->Add(myImage2); - myStackPanel->Children->Add(myTextBlock); - - // Add the StackPanel as the Content of the Parent Window Object. - mySV->Content = myStackPanel; - mainWindow->Content = mySV; - mainWindow->Show(); - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/tiffencoderdecoder.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/tiffencoderdecoder.vcxproj deleted file mode 100644 index 7c1873181a0b5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/tiffencoderdecoder.vcxproj +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/tulipfarm.tif b/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/tulipfarm.tif deleted file mode 100644 index 50746baa7337e..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/tulipfarm.tif and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp deleted file mode 100644 index a50b95e31c532..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp +++ /dev/null @@ -1,142 +0,0 @@ -//WDPEncoderDecoder.cpp file - - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::IO; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Imaging; -using namespace System::Threading; -using namespace System::Security; - - -namespace SDKSample { - - public ref class app : Application { - - private: Window^ mainWindow; - - protected: virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: void CreateAndShowMainWindow () - { - - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "WDP Imaging Sample"; - ScrollViewer^ mySV = gcnew ScrollViewer(); - - // - int width = 128; - int height = width; - int stride = width / 8; - array^ pixels = gcnew array(height * stride); - - // Define the image palette - BitmapPalette^ myPalette = BitmapPalettes::WebPalette; - - // Creates a new empty image with the pre-defined palette - - // - BitmapSource^ image = BitmapSource::Create( - width, - height, - 96, - 96, - PixelFormats::Indexed1, - myPalette, - pixels, - stride); - // - - // - FileStream^ stream = gcnew FileStream("new.wdp", FileMode::Create); - WmpBitmapEncoder^ encoder = gcnew WmpBitmapEncoder(); - TextBlock^ myTextBlock = gcnew TextBlock(); - myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString(); - encoder->Frames->Add(BitmapFrame::Create(image)); - encoder->Save(stream); - // - - // - - // - - // Open a Stream and decode a WDP image - Stream^ imageStreamSource = gcnew FileStream("tulipfarm.wdp", FileMode::Open, FileAccess::Read, FileShare::Read); - WmpBitmapDecoder^ decoder = gcnew WmpBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource = decoder->Frames[0]; - - // Draw the Image - Image^ myImage = gcnew Image(); - myImage->Source = bitmapSource; - myImage->Stretch = Stretch::None; - myImage->Margin = System::Windows::Thickness(20); - // - - // - - // Open a Uri and decode a WDP image - System::Uri^ myUri = gcnew System::Uri("tulipfarm.wdp", UriKind::RelativeOrAbsolute); - WmpBitmapDecoder^ decoder3 = gcnew WmpBitmapDecoder(myUri, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource3 = decoder3->Frames[0]; - - // Draw the Image - Image^ myImage2 = gcnew Image(); - myImage2->Source = bitmapSource3; - myImage2->Stretch = Stretch::None; - myImage2->Margin = System::Windows::Thickness(20); - // - - // - FileStream^ stream2 = gcnew FileStream("tulipfarm.jpg", FileMode::Open); - JpegBitmapDecoder^ decoder2 = gcnew JpegBitmapDecoder(stream2, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); - BitmapSource^ bitmapSource2 = decoder2->Frames[0]; - FileStream^ stream3 = gcnew FileStream("new2.wdp", FileMode::Create); - WmpBitmapEncoder^ encoder2 = gcnew WmpBitmapEncoder(); - encoder2->Frames->Add(BitmapFrame::Create(bitmapSource2)); - encoder2->Save(stream3); - // - - // Define a StackPanel to host the decoded WDP images - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Orientation = Orientation::Vertical; - myStackPanel->VerticalAlignment = VerticalAlignment::Stretch; - myStackPanel->HorizontalAlignment = HorizontalAlignment::Stretch; - - // Add the Image and TextBlock to the parent Grid - myStackPanel->Children->Add(myImage); - myStackPanel->Children->Add(myImage2); - myStackPanel->Children->Add(myTextBlock); - - // Add the StackPanel as the Content of the Parent Window Object - mySV->Content = myStackPanel; - mainWindow->Content = mySV; - mainWindow->Show(); - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - SDKSample::app^ app = gcnew SDKSample::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return SDKSample::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/tulipfarm.jpg b/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/tulipfarm.jpg deleted file mode 100644 index 2ce60cad09155..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/tulipfarm.jpg and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/tulipfarm.wdp b/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/tulipfarm.wdp deleted file mode 100644 index 4dc329ec51c1d..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/tulipfarm.wdp and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/wdpencoderdecoder.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/wdpencoderdecoder.vcxproj deleted file mode 100644 index 82611d115d451..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/wdpencoderdecoder.vcxproj +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Resource.h b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Resource.h deleted file mode 100644 index 8c31d345818a7..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Resource.h +++ /dev/null @@ -1,31 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Win32HostingWPFPage.rc -// - -#define IDS_APP_TITLE 103 - -#define IDR_MAINFRAME 128 -#define IDD_WIN32HOSTINGWPFPAGE_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDI_WIN32HOSTINGWPFPAGE 107 -#define IDI_SMALL 108 -#define IDC_WIN32HOSTINGWPFPAGE 109 -#define IDC_MYICON 2 -#ifndef IDC_STATIC -#define IDC_STATIC -1 -#endif -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS - -#define _APS_NO_MFC 130 -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/SampleID.txt b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/SampleID.txt deleted file mode 100644 index 16304d284ae24..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/SampleID.txt +++ /dev/null @@ -1 +0,0 @@ -win32_hosting_avalon_page_cpp \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/WPFPage.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/WPFPage.cpp deleted file mode 100644 index 5a01a71753e76..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/WPFPage.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "stdafx.h" -#include "WPFPage.h" - -WPFPage::WPFPage() {} -// -// -WPFPage::WPFPage(int allottedWidth, int allotedHeight) -{ - array ^ columnDef = gcnew array (4); - array ^ rowDef = gcnew array (6); - - this->Height = allotedHeight; - this->Width = allottedWidth; - this->Background = gcnew SolidColorBrush(Colors::LightGray); - - //Set up the Grid's row and column definitions - for(int i=0; i<4; i++) - { - columnDef[i] = gcnew ColumnDefinition(); - columnDef[i]->Width = GridLength(1, GridUnitType::Auto); - this->ColumnDefinitions->Add(columnDef[i]); - } - for(int i=0; i<6; i++) - { - rowDef[i] = gcnew RowDefinition(); - rowDef[i]->Height = GridLength(1, GridUnitType::Auto); - this->RowDefinitions->Add(rowDef[i]); - } -// -// - //Add the title - titleText = gcnew Label(); - titleText->Content = "Simple WPF Control"; - titleText->HorizontalAlignment = System::Windows::HorizontalAlignment::Center; - titleText->Margin = Thickness(10, 5, 10, 0); - titleText->FontWeight = FontWeights::Bold; - titleText->FontSize = 14; - Grid::SetColumn(titleText, 0); - Grid::SetRow(titleText, 0); - Grid::SetColumnSpan(titleText, 4); - this->Children->Add(titleText); -// -// - //Add the Name Label and TextBox - nameLabel = CreateLabel(0, 1, "Name"); - this->Children->Add(nameLabel); - nameTextBox = CreateTextBox(1, 1, 3); - this->Children->Add(nameTextBox); -// - //Add the Address Label and TextBox - addressLabel = CreateLabel(0, 2, "Address"); - this->Children->Add(addressLabel); - addressTextBox = CreateTextBox(1, 2, 3); - this->Children->Add(addressTextBox); - - //Add the City Label and TextBox - cityLabel = CreateLabel(0, 3, "City"); - this->Children->Add(cityLabel); - cityTextBox = CreateTextBox(1, 3, 1); - cityTextBox->Width = 100; - this->Children->Add(cityTextBox); - - //Add the State Label and TextBox - stateLabel = CreateLabel(2, 3, "State"); - this->Children->Add(stateLabel); - stateTextBox = CreateTextBox(3, 3, 1); - stateTextBox->Width = 50; - this->Children->Add(stateTextBox); - - //Add the Zip Label and TextBox - zipLabel = CreateLabel(0, 4, "Zip"); - this->Children->Add(zipLabel); - zipTextBox = CreateTextBox(1, 4, 1); - this->Children->Add(zipTextBox); -// - //Add the Buttons and atttach event handlers - okButton = CreateButton(0, 5, "OK"); - cancelButton = CreateButton(1, 5, "Cancel"); - this->Children->Add(okButton); - this->Children->Add(cancelButton); - okButton->Click += gcnew RoutedEventHandler(this, &WPFPage::ButtonClicked); - cancelButton->Click += gcnew RoutedEventHandler(this, &WPFPage::ButtonClicked); -// - //Set the default font properties - DefaultFontFamily = nameLabel->FontFamily; - DefaultFontStyle = nameLabel->FontStyle; - DefaultFontSize = nameLabel->FontSize; - DefaultFontWeight = nameLabel->FontWeight; - DefaultForeBrush = nameLabel->Foreground; - -} -// -// -Label ^WPFPage::CreateLabel(int column, int row, String ^ text) -{ - Label ^ newLabel = gcnew Label(); - newLabel->Content = text; - newLabel->Margin = Thickness(10, 5, 10, 0); - newLabel->FontWeight = FontWeights::Normal; - newLabel->FontSize = 12; - Grid::SetColumn(newLabel, column); - Grid::SetRow(newLabel, row); - return newLabel; -} -TextBox ^WPFPage::CreateTextBox(int column, int row, int span) -{ - TextBox ^newTextBox = gcnew TextBox(); - newTextBox->Margin = Thickness(10, 5, 10, 0); - Grid::SetColumn(newTextBox, column); - Grid::SetRow(newTextBox, row); - Grid::SetColumnSpan(newTextBox, span); - return newTextBox; -} -// -Button ^WPFPage::CreateButton(int column, int row, String ^text) -{ - Button ^newButton = gcnew Button(); - newButton->Content = text; - newButton->Margin = Thickness(10, 10, 10, 10); - newButton->Width = 60; - Grid::SetColumn(newButton, column); - Grid::SetRow(newButton, row); - return newButton; -} -// -void WPFPage::ButtonClicked(Object ^sender, RoutedEventArgs ^args) -{ - - //TODO: validate input data - bool okClicked = true; - if(sender == cancelButton) - okClicked = false; - EnteredName = nameTextBox->Text; - EnteredAddress = addressTextBox->Text; - EnteredCity = cityTextBox->Text; - EnteredState = stateTextBox->Text; - EnteredZip = zipTextBox->Text; - OnButtonClicked(this, gcnew MyPageEventArgs(okClicked)); -} -// -// -void WPFPage::SetFontFamily(FontFamily^ newFontFamily) -{ - _defaultFontFamily = newFontFamily; - titleText->FontFamily = newFontFamily; - nameLabel->FontFamily = newFontFamily; - addressLabel->FontFamily = newFontFamily; - cityLabel->FontFamily = newFontFamily; - stateLabel->FontFamily = newFontFamily; - zipLabel->FontFamily = newFontFamily; -} -// -void WPFPage::SetFontStyle(FontStyle newFontStyle) -{ - _defaultFontStyle = newFontStyle; - titleText->FontStyle = newFontStyle; - nameLabel->FontStyle = newFontStyle; - addressLabel->FontStyle = newFontStyle; - cityLabel->FontStyle = newFontStyle; - stateLabel->FontStyle = newFontStyle; - zipLabel->FontStyle = newFontStyle; -} - -void WPFPage::SetFontSize(double newFontSize) -{ - _defaultFontSize = newFontSize; - titleText->FontSize = newFontSize; - nameLabel->FontSize = newFontSize; - addressLabel->FontSize = newFontSize; - cityLabel->FontSize = newFontSize; - stateLabel->FontSize = newFontSize; - zipLabel->FontSize = newFontSize; -} - -void WPFPage::SetFontWeight(FontWeight newFontWeight) -{ - _defaultFontWeight = newFontWeight; - titleText->FontWeight = newFontWeight; - nameLabel->FontWeight = newFontWeight; - addressLabel->FontWeight = newFontWeight; - cityLabel->FontWeight = newFontWeight; - stateLabel->FontWeight = newFontWeight; - zipLabel->FontWeight = newFontWeight; -} - -void WPFPage::SetForeBrush(Brush^ newForeBrush) -{ - _defaultForeBrush = newForeBrush; - titleText->Foreground = newForeBrush; - nameLabel->Foreground = newForeBrush; - addressLabel->Foreground = newForeBrush; - cityLabel->Foreground = newForeBrush; - stateLabel->Foreground = newForeBrush; - zipLabel->Foreground = newForeBrush; -} - -MyPageEventArgs::MyPageEventArgs() {} - -MyPageEventArgs::MyPageEventArgs(bool okClicked) -{ - IsOK = okClicked; -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/WPFPage.h b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/WPFPage.h deleted file mode 100644 index 821738f3166b6..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/WPFPage.h +++ /dev/null @@ -1,87 +0,0 @@ -#include "stdafx.h" - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Documents; -using namespace System::Threading; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; - -public ref class MyPageEventArgs : EventArgs -{ -public: - MyPageEventArgs(); - MyPageEventArgs(bool isOK); - - property bool IsOK; -}; - -public ref class WPFPage : public Grid -{ -private: - Label ^titleText, ^nameLabel, ^addressLabel, ^cityLabel, ^stateLabel, ^zipLabel; - TextBox ^nameTextBox, ^addressTextBox, ^cityTextBox, ^stateTextBox, ^zipTextBox; - Button ^okButton, ^cancelButton; - String ^_name, ^_address, ^_city, ^_state, ^_zip; - FontFamily ^_defaultFontFamily; - void SetFontFamily(FontFamily^ newFont); - FontStyle _defaultFontStyle; - void SetFontStyle(FontStyle newFont); - double _defaultFontSize; - void SetFontSize(double newSize); - FontWeight _defaultFontWeight; - void SetFontWeight(FontWeight newWeight); - Brush^ _defaultForeBrush; - void SetForeBrush(Brush^ newForeBrush); - - Label ^ CreateLabel(int column, int row, String ^text); - TextBox ^ CreateTextBox(int column, int row, int span); - Button ^CreateButton(int column, int row, String ^text); - void ButtonClicked(Object ^sender, RoutedEventArgs ^args); - -// -public: - delegate void ButtonClickHandler(Object ^, MyPageEventArgs ^); - WPFPage(); - WPFPage(int height, int width); - event ButtonClickHandler ^OnButtonClicked; -// - //properties -// - property FontFamily^ DefaultFontFamily - { - FontFamily^ get() {return _defaultFontFamily;} - void set(FontFamily^ value) {SetFontFamily(value);} - }; -// - property FontStyle DefaultFontStyle - { - FontStyle get() {return _defaultFontStyle;} - void set(FontStyle value) {SetFontStyle(value);} - }; - property double DefaultFontSize - { - double get() {return _defaultFontSize;} - void set(double value) {SetFontSize(value);} - }; - property FontWeight DefaultFontWeight - { - FontWeight get() {return _defaultFontWeight;} - void set(FontWeight value) {SetFontWeight(value);} - }; - - property Brush^ DefaultForeBrush - { - Brush^ get() {return _defaultForeBrush;} - void set(Brush^ value) {SetForeBrush(value);} - }; - - property String ^EnteredName; - property String ^EnteredAddress; - property String ^EnteredCity; - property String ^EnteredState; - property String ^EnteredZip; -}; - - - diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.cpp deleted file mode 100644 index 9851d3e70734b..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.cpp +++ /dev/null @@ -1,602 +0,0 @@ -// Win32HostingWPFPage.cpp : Defines the entry point for the application. -// -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Runtime; - -#include "stdafx.h" -#include "Win32HostingWPFPage.h" -#include - -#define MAX_LOADSTRING 100 - -// Global Variables: -HINSTANCE hInst; // current instance -TCHAR szTitle[MAX_LOADSTRING]; // The title bar text -TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name -HWND wpfHwnd; //The hwnd associated with the hosted WPF page - -// Forward declarations of functions included in this code module: -ATOM MyRegisterClass(HINSTANCE hInstance); -BOOL InitInstance(HINSTANCE, int); -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); -// -[System::STAThreadAttribute] //Needs to be an STA thread to play nicely with WPF -int APIENTRY _tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) -{ -// - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - - // TODO: Place code here. - - MSG msg; - HACCEL hAccelTable; - - // Initialize global strings - LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadString(hInstance, IDC_WIN32HOSTINGWPFPAGE, szWindowClass, MAX_LOADSTRING); - MyRegisterClass(hInstance); - - // Perform application initialization: - if (!InitInstance (hInstance, nCmdShow)) - { - return FALSE; - } - - hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WIN32HOSTINGWPFPAGE)); - - // Main message loop: - while (GetMessage(&msg, NULL, 0, 0)) - { - if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - return (int) msg.wParam; -} - - - -// -// FUNCTION: MyRegisterClass() -// -// PURPOSE: Registers the window class. -// -// COMMENTS: -// -// This function and its usage are only necessary if you want this code -// to be compatible with Win32 systems prior to the 'RegisterClassEx' -// function that was added to Windows 95. It is important to call this function -// so that the application will get 'well formed' small icons associated -// with it. -// -ATOM MyRegisterClass(HINSTANCE hInstance) -{ - WNDCLASSEX wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN32HOSTINGWPFPAGE)); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_BTNSHADOW); - wcex.lpszMenuName = MAKEINTRESOURCE(IDC_WIN32HOSTINGWPFPAGE); - wcex.lpszClassName = szWindowClass; - wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); - - return RegisterClassEx(&wcex); -} - -// -// FUNCTION: InitInstance(HINSTANCE, int) -// -// PURPOSE: Saves instance handle and creates main window -// -// COMMENTS: -// -// In this function, we save the instance handle in a global variable and -// create and display the main program window. -// -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) -{ - HWND hWnd; - - hInst = hInstance; // Store instance handle in our global variable - - hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); - - if (!hWnd) - { - return FALSE; - } - - ShowWindow(hWnd, nCmdShow); - UpdateWindow(hWnd); - - return TRUE; -} - -// -// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) -// -// PURPOSE: Processes messages for the main window. -// -// WM_COMMAND - process the application menu -// WM_PAINT - Paint the main window -// WM_DESTROY - post a quit message and return -// -// -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId, wmEvent; - PAINTSTRUCT ps; - HDC hdc; - - switch (message) - { -// - case WM_CREATE : - GetClientRect(hWnd, &rect); - wpfHwnd = GetHwnd(hWnd, rect.right-375, 0, 375, 250); - CreateDataDisplay(hWnd, 275, rect.right-375, 375); - CreateRadioButtons(hWnd); - break; -// -// - case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); - - switch (wmId) - { - //Menu selections - case IDM_ABOUT: - DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); - break; - case IDM_EXIT: - DestroyWindow(hWnd); - break; - //RadioButtons - case IDC_ORIGINALBACKGROUND : - WPFPageHost::hostedPage->Background = WPFPageHost::initBackBrush; - break; - case IDC_LIGHTGREENBACKGROUND : - WPFPageHost::hostedPage->Background = gcnew SolidColorBrush(Colors::LightGreen); - break; - case IDC_LIGHTSALMONBACKGROUND : - WPFPageHost::hostedPage->Background = gcnew SolidColorBrush(Colors::LightSalmon); - break; -// - - case IDC_ORIGINALFONTFAMILY : - WPFPageHost::hostedPage->DefaultFontFamily = WPFPageHost::initFontFamily; - break; - case IDC_TIMESNEWROMAN : - WPFPageHost::hostedPage->DefaultFontFamily = gcnew FontFamily("Times New Roman"); - break; - case IDC_WINGDINGS: - WPFPageHost::hostedPage->DefaultFontFamily = gcnew FontFamily("WingDings"); - break; - case IDC_ORIGINALFONTSTYLE : - WPFPageHost::hostedPage->DefaultFontStyle = WPFPageHost::initFontStyle; - break; - case IDC_ITALIC : - WPFPageHost::hostedPage->DefaultFontStyle = System::Windows::FontStyles::Italic; - break; - case IDC_ORIGINALFONTSIZE : - WPFPageHost::hostedPage->DefaultFontSize = WPFPageHost::initFontSize; - break; - case IDC_TENPOINT : - WPFPageHost::hostedPage->DefaultFontSize = 10; - break; - case IDC_TWELVEPOINT : - WPFPageHost::hostedPage->DefaultFontSize = 12; - break; - case IDC_ORIGINALFONTWEIGHT : - WPFPageHost::hostedPage->DefaultFontWeight = WPFPageHost::initFontWeight; - break; - case IDC_BOLD : - WPFPageHost::hostedPage->DefaultFontWeight = FontWeights::Bold; - break; - case IDC_ORIGINALFOREGROUND : - WPFPageHost::hostedPage->DefaultForeBrush = WPFPageHost::initForeBrush; - break; - case IDC_REDFOREGROUND : - WPFPageHost::hostedPage->DefaultForeBrush = gcnew SolidColorBrush(Colors::Red); - break; - case IDC_YELLOWFOREGROUND : - WPFPageHost::hostedPage->DefaultForeBrush = gcnew SolidColorBrush(Colors::Yellow); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - break; - case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); - // TODO: Add any drawing code here... - EndPaint(hWnd, &ps); - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; -} - -// Message handler for about box. -INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - UNREFERENCED_PARAMETER(lParam); - switch (message) - { - case WM_INITDIALOG: - return (INT_PTR)TRUE; - - case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) - { - EndDialog(hDlg, LOWORD(wParam)); - return (INT_PTR)TRUE; - } - break; - } - return (INT_PTR)FALSE; -} - -WPFPageHost::WPFPageHost(){} -// -HWND GetHwnd(HWND parent, int x, int y, int width, int height) -{ - System::Windows::Interop::HwndSourceParameters^ sourceParams = gcnew System::Windows::Interop::HwndSourceParameters( - "hi" // NAME - ); - sourceParams->PositionX = x; - sourceParams->PositionY = y; - sourceParams->Height = height; - sourceParams->Width = width; - sourceParams->ParentWindow = IntPtr(parent); - sourceParams->WindowStyle = WS_VISIBLE | WS_CHILD; // style - System::Windows::Interop::HwndSource^ source = gcnew System::Windows::Interop::HwndSource(*sourceParams); - WPFPage ^myPage = gcnew WPFPage(width, height); - //Assign a reference to the WPF page and a set of UI properties to a set of static properties in a class - //that is designed for that purpose. - WPFPageHost::hostedPage = myPage; - WPFPageHost::initBackBrush = myPage->Background; - WPFPageHost::initFontFamily = myPage->DefaultFontFamily; - WPFPageHost::initFontSize = myPage->DefaultFontSize; - WPFPageHost::initFontStyle = myPage->DefaultFontStyle; - WPFPageHost::initFontWeight = myPage->DefaultFontWeight; - WPFPageHost::initForeBrush = myPage->DefaultForeBrush; - myPage->OnButtonClicked += gcnew WPFPage::ButtonClickHandler(WPFButtonClicked); - source->RootVisual = myPage; - return (HWND) source->Handle.ToPointer(); -} -// -// -void WPFButtonClicked(Object ^sender, MyPageEventArgs ^args) -{ - if(args->IsOK) //display data if OK button was clicked - { - WPFPage ^myPage = WPFPageHost::hostedPage; - LPCWSTR userName = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("Name: " + myPage->EnteredName).ToPointer(); - SetWindowText(nameLabel, userName); - LPCWSTR userAddress = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("Address: " + myPage->EnteredAddress).ToPointer(); - SetWindowText(addressLabel, userAddress); - LPCWSTR userCity = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("City: " + myPage->EnteredCity).ToPointer(); - SetWindowText(cityLabel, userCity); - LPCWSTR userState = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("State: " + myPage->EnteredState).ToPointer(); - SetWindowText(stateLabel, userState); - LPCWSTR userZip = (LPCWSTR) InteropServices::Marshal::StringToHGlobalAuto("Zip: " + myPage->EnteredZip).ToPointer(); - SetWindowText(zipLabel, userZip); - } - else - { - SetWindowText(nameLabel, L"Name: "); - SetWindowText(addressLabel, L"Address: "); - SetWindowText(cityLabel, L"City: "); - SetWindowText(stateLabel, L"State: "); - SetWindowText(zipLabel, L"Zip: "); - } -} -// - -void CreateDataDisplay(HWND hWnd, int top, int left, int width) -{ - dataDisplayLabel = CreateWindowEx(0, L"static", L"Data From WPF Control", - WS_CHILD | WS_VISIBLE | SS_LEFT, - left, top+25, - width, 25, - hWnd, - (HMENU) 1, - hInst, - NULL); - - nameLabel = CreateWindowEx(0, L"static", L"Name: ", - WS_CHILD | WS_VISIBLE | SS_LEFT, - left, top+60, - width, 25, - hWnd, - (HMENU) 1, - hInst, - NULL); - - addressLabel = CreateWindowEx(0, L"static", L"Address: ", - WS_CHILD | WS_VISIBLE | SS_LEFT, - left, top+85, - width, 25, - hWnd, - (HMENU) 1, - hInst, - NULL); - cityLabel = CreateWindowEx(0, L"static", L"City: ", - WS_CHILD | WS_VISIBLE | SS_LEFT, - left, top+110, - width, 25, - hWnd, - (HMENU) 1, - hInst, - NULL); - - stateLabel = CreateWindowEx(0, L"static", L"State: ", - WS_CHILD | WS_VISIBLE | SS_LEFT, - left, top+135, - width, 25, - hWnd, - (HMENU) 1, - hInst, - NULL); - - zipLabel = CreateWindowEx(0, L"static", L"Zip: ", - WS_CHILD | WS_VISIBLE | SS_LEFT, - left, top+160, - width, 25, - hWnd, - (HMENU) 1, - hInst, - NULL); - -} - -void CreateRadioButtons(HWND hWnd) -{ - //Background color - int top = 25; - controlDisplayLabel = CreateWindowEx(0, L"static", L"ControlProperties", - WS_CHILD | WS_VISIBLE | SS_LEFT, - 10, top, - 125, 25, - hWnd, - NULL, - hInst, - NULL); - - //Background radio buttons - top += 35; - backgroundGroup = CreateWindowEx(0, L"button", L"Background Color", - WS_CHILD | WS_VISIBLE | BS_GROUPBOX, - 10, top, - 175, 100, - hWnd, - (HMENU) IDC_ORIGINALBACKGROUND, - hInst, - NULL); - top += 20; - originalBackgroundButton = CreateWindowEx(0, L"button", L"Original", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_ORIGINALBACKGROUND, - hInst, - NULL); - top += 20; - lightGreenBackgroundButton = CreateWindowEx(0, L"button", L"Light Green", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_LIGHTGREENBACKGROUND, - hInst, - NULL); - - top += 20; - lightSalmonBackgroundButton = CreateWindowEx(0, L"button", L"Light Salmon", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_LIGHTSALMONBACKGROUND, - hInst, - NULL); - //Foreground color - top += 45; - foregroundGroup = CreateWindowEx(0, L"button", L"Foreground Color", - WS_CHILD | WS_VISIBLE | BS_GROUPBOX, - 10, top, - 175, 100, - hWnd, - NULL, - hInst, - NULL); - top += 20; - originalForegroundButton = CreateWindowEx(0, L"button", L"Original", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_ORIGINALFOREGROUND, - hInst, - NULL); - top += 20; - redForegroundButton = CreateWindowEx(0, L"button", L"Red", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_REDFOREGROUND, - hInst, - NULL); - - top += 20; - yellowForegroundButton = CreateWindowEx(0, L"button", L"Yellow", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_YELLOWFOREGROUND, - hInst, - NULL); - - //Font family - top += 45; - fontFamilyGroup = CreateWindowEx(0, L"button", L"Font Family", - WS_CHILD | WS_VISIBLE | BS_GROUPBOX, - 10, top, - 175, 100, - hWnd, - NULL, - hInst, - NULL); - top += 20; - originalFontFamily = CreateWindowEx(0, L"button", L"Original", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_ORIGINALFONTFAMILY, - hInst, - NULL); - top += 20; - timesFontFamily = CreateWindowEx(0, L"button", L"Times New Roman", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 140, 25, - hWnd, - (HMENU) IDC_TIMESNEWROMAN, - hInst, - NULL); - - top += 20; - wingdingsFontFamily = CreateWindowEx(0, L"button", L"WingDings", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_WINGDINGS, - hInst, - NULL); - - //Font size - top += 45; - fontSizeGroup = CreateWindowEx(0, L"button", L"Font Size", - WS_CHILD | WS_VISIBLE | BS_GROUPBOX, - 10, top, - 175, 100, - hWnd, - NULL, - hInst, - NULL); - top += 20; - originalFontSize = CreateWindowEx(0, L"button", L"Original", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_ORIGINALFONTSIZE, - hInst, - NULL); - top += 20; - tenpointFontSize = CreateWindowEx(0, L"button", L"10", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_TENPOINT, - hInst, - NULL); - - top += 20; - twelvepointFontSize = CreateWindowEx(0, L"button", L"12", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_TWELVEPOINT, - hInst, - NULL); - - //Font style - top += 45; - fontStyleGroup = CreateWindowEx(0, L"button", L"Font Style", - WS_CHILD | WS_VISIBLE | BS_GROUPBOX, - 10, top, - 175, 70, - hWnd, - NULL, - hInst, - NULL); - top += 20; - originalFontStyle = CreateWindowEx(0, L"button", L"Original", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_ORIGINALFONTSTYLE, - hInst, - NULL); - top += 20; - italicFontStyle = CreateWindowEx(0, L"button", L"Italic", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_ITALIC, - hInst, - NULL); - - //Font weight - top += 45; - fontWeightGroup = CreateWindowEx(0, L"button", L"Font Weight", - WS_CHILD | WS_VISIBLE | BS_GROUPBOX, - 10, top, - 175, 70, - hWnd, - NULL, - hInst, - NULL); - top += 20; - originalFontWeight = CreateWindowEx(0, L"button", L"Original", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_ORIGINALFONTWEIGHT, - hInst, - NULL); - top += 20; - boldFontWeight = CreateWindowEx(0, L"button", L"Bold", - WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, - 15, top, - 125, 25, - hWnd, - (HMENU) IDC_BOLD, - hInst, - NULL); -} \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.h b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.h deleted file mode 100644 index 06c1b4379dfcb..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include "resource.h" -#include "WPFPage.h" -#include -#include - -//Radiobutton IDs -#define IDC_ORIGINALBACKGROUND 1 -#define IDC_LIGHTGREENBACKGROUND 2 -#define IDC_LIGHTSALMONBACKGROUND 3 -#define IDC_ORIGINALFOREGROUND 4 -#define IDC_REDFOREGROUND 5 -#define IDC_YELLOWFOREGROUND 6 -#define IDC_ORIGINALFONTFAMILY 7 -#define IDC_TIMESNEWROMAN 8 -#define IDC_WINGDINGS 9 -#define IDC_ORIGINALFONTSIZE 10 -#define IDC_TENPOINT 11 -#define IDC_TWELVEPOINT 12 -#define IDC_ORIGINALFONTSTYLE 13 -#define IDC_ITALIC 14 -#define IDC_ORIGINALFONTWEIGHT 15 -#define IDC_BOLD 16 -// -public ref class WPFPageHost -{ -public: - WPFPageHost(); - static WPFPage^ hostedPage; - //initial property settings - static System::Windows::Media::Brush^ initBackBrush; - static System::Windows::Media::Brush^ initForeBrush; - static System::Windows::Media::FontFamily^ initFontFamily; - static System::Windows::FontStyle initFontStyle; - static System::Windows::FontWeight initFontWeight; - static double initFontSize; -}; -// - -RECT rect; -HWND GetHwnd(HWND parent, int x, int y, int width, int height); -HWND dataDisplayLabel, nameLabel, addressLabel, cityLabel, stateLabel, zipLabel; -HWND controlDisplayLabel, foregroundLabel, fontLabel, sizeLabel, styleLabel, weightLabel; -HWND backgroundGroup, originalBackgroundButton, lightGreenBackgroundButton, lightSalmonBackgroundButton; -HWND foregroundGroup, originalForegroundButton, redForegroundButton, yellowForegroundButton; -HWND fontFamilyGroup, originalFontFamily, timesFontFamily, wingdingsFontFamily; -HWND fontSizeGroup, originalFontSize, tenpointFontSize, twelvepointFontSize; -HWND fontStyleGroup, originalFontStyle, italicFontStyle; -HWND fontWeightGroup, originalFontWeight, boldFontWeight; -void WPFButtonClicked(Object ^sender, MyPageEventArgs ^args); -void CreateDataDisplay(HWND hWnd, int top, int left, int width); -void CreateRadioButtons(HWND hWnd); \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.ico b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.ico deleted file mode 100644 index d551aa3aaf80a..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.rc b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.rc deleted file mode 100644 index f3a536a7a3fbf..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.rc +++ /dev/null @@ -1,127 +0,0 @@ -//Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. - -IDI_WIN32HOSTINGWPFPAGE ICON "Win32HostingWPFPage.ico" -IDI_SMALL ICON "small.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDC_WIN32HOSTINGWPFPAGE MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "E&xit", IDM_EXIT - END - POPUP "&Help" - BEGIN - MENUITEM "&About ...", IDM_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDC_WIN32HOSTINGWPFPAGE ACCELERATORS -BEGIN - "?", IDM_ABOUT, ASCII, ALT - "/", IDM_ABOUT, ASCII, ALT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG 22, 17, 230, 75 -STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -CAPTION "About" -FONT 8, "System" -BEGIN - ICON IDI_WIN32HOSTINGWPFPAGE,IDC_MYICON,14,9,16,16 - LTEXT "Win32HostingWPFPage Version 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX - LTEXT "Copyright (C) 2005",IDC_STATIC,49,20,119,8 - DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP -END - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDC_WIN32HOSTINGWPFPAGE "WIN32HOSTINGWPFPAGE" - IDS_APP_TITLE "Win32HostingWPFPage" -END - -#endif -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.vcxproj deleted file mode 100644 index d416d920a72df..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/Win32HostingWPFPage.vcxproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {8E4A7F4E-64A9-4313-AAD8-C0E888223A32} - Win32HostingWPFPage - Win32Proj - - - - Application - Unicode - - - Application - Unicode - true - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21230.0 - Debug\ - Debug\ - true - Release\ - Release\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - false - Default - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - mscoree.lib %(AdditionalOptions) - C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Lib;%(AdditionalLibraryDirectories) - true - true - Windows - false - - - MachineX86 - - - - - MaxSpeed - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - true - Windows - true - true - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/small.ico b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/small.ico deleted file mode 100644 index d551aa3aaf80a..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/small.ico and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/stdafx.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/stdafx.cpp deleted file mode 100644 index ca33f749ea7ec..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// Win32HostingWPFPag.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/stdafx.h b/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/stdafx.h deleted file mode 100644 index 0da5e573762a5..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/Win32HostingWPFPage/CPP/stdafx.h +++ /dev/null @@ -1,37 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. -#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. -#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. -#endif - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - -// C RunTime Header Files -#include -#include -#include -#include - - -// TODO: reference additional headers your program requires here diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/WrapPanel_Intro/CPP/WrapPanel_Code.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/WrapPanel_Intro/CPP/WrapPanel_Code.cpp deleted file mode 100644 index 95e061129c359..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/WrapPanel_Intro/CPP/WrapPanel_Code.cpp +++ /dev/null @@ -1,92 +0,0 @@ -//WrapPanel_Code.cpp file - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Controls; -using namespace System::Windows::Media; -using namespace System::Threading; - -namespace WrapPanel_Demo { - - public ref class app : System::Windows::Application { - - private: - System::Windows::Controls::Button^ btn1; - System::Windows::Controls::Button^ btn2; - System::Windows::Controls::Button^ btn3; - System::Windows::Controls::WrapPanel^ myWrapPanel; - System::Windows::Window^ mainWindow; - - protected: - virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // - - // Create the application's main window - mainWindow = gcnew System::Windows::Window(); - mainWindow->Title = "WrapPanel Sample"; - - // - - // Instantiate a new WrapPanel and set properties - myWrapPanel = gcnew WrapPanel(); - myWrapPanel->Background = Brushes::Azure; - myWrapPanel->Orientation = Orientation::Horizontal; - // - myWrapPanel->ItemHeight = 25; - // - - // - myWrapPanel->ItemWidth = 75; - // - myWrapPanel->Width = 150; - myWrapPanel->HorizontalAlignment = HorizontalAlignment::Left; - myWrapPanel->VerticalAlignment = VerticalAlignment::Top; - - // Define 3 button elements. Each button is sized at width of 75, so the third button wraps to the next line. - btn1 = gcnew Button(); - btn1->Content = "Button 1"; - btn2 = gcnew Button(); - btn2->Content = "Button 2"; - btn3 = gcnew Button(); - btn3->Content = "Button 3"; - - // Add the buttons to the parent WrapPanel using the Children.Add method. - myWrapPanel->Children->Add(btn1); - myWrapPanel->Children->Add(btn2); - myWrapPanel->Children->Add(btn3); - - // Add the WrapPanel to the MainWindow as Content - mainWindow->Content = myWrapPanel; - mainWindow->Show(); - // - - // - }; - }; - - private ref class EntryClass { - - public: - [System::STAThread()] - static void Main () - { - WrapPanel_Demo::app^ app = gcnew WrapPanel_Demo::app(); - app->Run(); - }; - }; -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return WrapPanel_Demo::EntryClass::Main(); -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/WrapPanel_Intro/CPP/wrappanel_code_cpp.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/WrapPanel_Intro/CPP/wrappanel_code_cpp.vcxproj deleted file mode 100644 index 98f58d453c06d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/WrapPanel_Intro/CPP/wrappanel_code_cpp.vcxproj +++ /dev/null @@ -1,124 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - WrapPanel_Code - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/XpsCreate.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/XpsCreate.cpp deleted file mode 100644 index 39cf60785a05f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/XpsCreate.cpp +++ /dev/null @@ -1,459 +0,0 @@ -//XpsCreate.cpp file - -using namespace System; -using namespace System::IO; -using namespace System::Collections::Generic; -using namespace System::IO::Packaging; -using namespace System::Xml; -using namespace System::Windows::Forms; -using namespace System::Windows::Xps; -using namespace System::Windows::Xps::Packaging; -using namespace System::Printing; - -public ref class XpsCreate { - -private: - literal System::String^ packageWithPrintTicketName = "XpsDocument-withPrintTicket.xps"; - literal System::String^ packageName = "XpsDocument.xps"; - literal System::String^ image1 = "picture.jpg"; - literal System::String^ image2 = "image.tif"; - literal System::String^ font1 = "courier.ttf"; - literal System::String^ font2 = "arial.ttf"; - literal System::String^ fontContentType = "application/vnd.ms-package.obfuscated-opentype"; - -public: - [STAThread()] - static void Main (array^ args) - { - XpsCreate^ xpsCreate = gcnew XpsCreate(); - xpsCreate->Run(); - }; - -public: - // -------------------------------- Run ----------------------------------- - /// - /// Creates two XpsDocument packages, the first without a PrintTicket - /// and a second with a PrintTicket. - void Run () - { - // First, create an XpsDocument without a PrintTicket. - - - - - - - - - - // If the document package exists from a previous run, delete it. - if (File::Exists(packageName)) - { - File::Delete(packageName); - } - // - // Create an XpsDocument package (without PrintTicket). - { - Package^ package = Package::Open(packageName); - try - { - XpsDocument^ xpsDocument = gcnew XpsDocument(package); - - // Add the package content (false=without PrintTicket). - AddPackageContent(xpsDocument, false); - - // Close the package. - xpsDocument->Close(); - } finally - { - delete package; - } - // - - // Next, create a second XpsDocument with a PrintTicket. - - - - - - - - - // If the document package exists from a previous run, delete it. - if (File::Exists(packageWithPrintTicketName)) - { - File::Delete(packageWithPrintTicketName); - } - - // Create an XpsDocument with PrintTicket. - { - Package^ package2 = Package::Open(packageWithPrintTicketName); - try - { - XpsDocument^ xpsDocumentWithPrintTicket = gcnew XpsDocument(package2); - - // Add the package content (true=with PrintTicket). - AddPackageContent(xpsDocumentWithPrintTicket, true); - - // Close the package. - xpsDocumentWithPrintTicket->Close(); - } finally - { - delete package2; - } - } - - System::String^ msg = "Created two XPS document packages:\n - " + packageName + "\n - " + packageWithPrintTicketName; - MessageBox::Show(msg, "Normal Completion", MessageBoxButtons::OK, MessageBoxIcon::Information); - } - }; - -private: - // - // ------------------------- AddPackageContent ---------------------------- - /// - /// Adds a predefined set of content to a given XPS document. - /// - /// The package to add the document content to. - /// - /// true to include a PrintTicket with the - /// document; otherwise, false. - void AddPackageContent (XpsDocument^ xpsDocument, bool attachPrintTicket) - { - try - { - PrintTicket^ printTicket = GetPrintTicketFromPrinter(); - // PrintTicket is null, there is no need to attach one. - if (printTicket == nullptr) - { - attachPrintTicket = false; - } - // Add a FixedDocumentSequence at the Package root - IXpsFixedDocumentSequenceWriter^ documentSequenceWriter = xpsDocument->AddFixedDocumentSequence(); - - // Add the 1st FixedDocument to the FixedDocumentSequence. - - - - - - IXpsFixedDocumentWriter^ fixedDocumentWriter = documentSequenceWriter->AddFixedDocument(); - - AddDocumentContent(fixedDocumentWriter); - - // Commit the 1st Document - fixedDocumentWriter->Commit(); - - // Add a 2nd FixedDocument to the FixedDocumentSequence. - - - - - - - fixedDocumentWriter = documentSequenceWriter->AddFixedDocument(); - - // Add content to the 2nd document. - AddDocumentContent(fixedDocumentWriter); - - // If attaching PrintTickets, attach one at the FixedDocument level. - if (attachPrintTicket) - { - fixedDocumentWriter->PrintTicket = printTicket; - } - // Commit the 2nd document. - fixedDocumentWriter->Commit(); - - // If attaching PrintTickets, attach one at - // the package FixedDocumentSequence level. - if (attachPrintTicket) - { - documentSequenceWriter->PrintTicket = printTicket; - } - // Commit the FixedDocumentSequence - documentSequenceWriter->Commit(); - } catch (XpsPackagingException^ xpsException) - { - throw xpsException; - - } - };// end:AddPackageContent() - // - - - // - // ------------------------- AddDocumentContent --------------------------- - /// - /// Adds a predefined set of content to a given document writer. - /// - /// The document writer to add the content to. - void AddDocumentContent (IXpsFixedDocumentWriter^ fixedDocumentWriter) - { - // Collection of image and font resources used on the current page. - // Key: "XpsImage", "XpsFont" - // Value: List of XpsImage or XpsFont resources - Dictionary^>^ resources; - - try - { - // Add Page 1 to current document. - IXpsFixedPageWriter^ fixedPageWriter = fixedDocumentWriter->AddFixedPage(); - // Add the resources for Page 1 and get the resource collection. - resources = AddPageResources(fixedPageWriter); - - // Write page content for Page 1. - WritePageContent(fixedPageWriter->XmlWriter, "Page 1 of " + fixedDocumentWriter->Uri->ToString(), resources); - // Commit Page 1. - fixedPageWriter->Commit(); - - // Add Page 2 to current document. - fixedPageWriter = fixedDocumentWriter->AddFixedPage(); - - // Add the resources for Page 2 and get the resource collection. - resources = AddPageResources(fixedPageWriter); - - // Write page content to Page 2. - WritePageContent(fixedPageWriter->XmlWriter, "Page 2 of " + fixedDocumentWriter->Uri->ToString(), resources); - // Commit Page 2. - fixedPageWriter->Commit(); - } catch (XpsPackagingException^ xpsException) - { - throw xpsException; - - } - };// end:AddDocumentContent() - // - - - // - // -------------------------- AddPageResources ---------------------------- - Dictionary^>^ AddPageResources (IXpsFixedPageWriter^ fixedPageWriter) - { - // Collection of all resources for this page. - // Key: "XpsImage", "XpsFont" - // Value: List of XpsImage or XpsFont - Dictionary^>^ resources = gcnew Dictionary^>(); - - // Collections of images and fonts used in the current page. - List^ xpsImages = gcnew List(); - List^ xpsFonts = gcnew List(); - - try - { - XpsImage^ xpsImage; - XpsFont^ xpsFont; - - // Add, Write, and Commit image1 to the current page. - xpsImage = fixedPageWriter->AddImage(XpsImageType::JpegImageType); - WriteToStream(xpsImage->GetStream(), image1); - xpsImage->Commit(); - xpsImages->Add(xpsImage); // Add image1 as a required resource. - - // Add, Write, and Commit font 1 to the current page. - xpsFont = fixedPageWriter->AddFont(); - WriteObfuscatedStream(xpsFont->Uri->ToString(), xpsFont->GetStream(), font1); - xpsFont->Commit(); - xpsFonts->Add(xpsFont); // Add font1 as a required resource. - - // Add, Write, and Commit image2 to the current page. - xpsImage = fixedPageWriter->AddImage(XpsImageType::TiffImageType); - WriteToStream(xpsImage->GetStream(), image2); - xpsImage->Commit(); - xpsImages->Add(xpsImage); // Add image2 as a required resource. - - // Add, Write, and Commit font2 to the current page. - xpsFont = fixedPageWriter->AddFont(false); - WriteToStream(xpsFont->GetStream(), font2); - xpsFont->Commit(); - xpsFonts->Add(xpsFont); // Add font2 as a required resource. - - // Return the image and font resources in a combined collection. - resources->Add("XpsImage", xpsImages); - resources->Add("XpsFont", xpsFonts); - return resources; - } catch (XpsPackagingException^ xpsException) - { - throw xpsException; - - } - };// end:AddPageResources() - // - - - // - // ---------------------- GetPrintTicketFromPrinter ----------------------- - /// - /// Returns a PrintTicket based on the current default printer. - /// - /// A PrintTicket for the current local default printer. - PrintTicket^ GetPrintTicketFromPrinter () - { - PrintQueue^ printQueue = nullptr; - - LocalPrintServer^ localPrintServer = gcnew LocalPrintServer(); - - // Retrieving collection of local printer on user machine - PrintQueueCollection^ localPrinterCollection = localPrintServer->GetPrintQueues(); - - System::Collections::IEnumerator^ localPrinterEnumerator = localPrinterCollection->GetEnumerator(); - - if (localPrinterEnumerator->MoveNext()) - { - // Get PrintQueue from first available printer - printQueue = ((PrintQueue^)localPrinterEnumerator->Current); - } else - { - return nullptr; - } - // Get default PrintTicket from printer - PrintTicket^ printTicket = printQueue->DefaultPrintTicket; - - PrintCapabilities^ printCapabilites = printQueue->GetPrintCapabilities(); - - // Modify PrintTicket - if (printCapabilites->CollationCapability->Contains(Collation::Collated)) - { - printTicket->Collation = Collation::Collated; - } - if (printCapabilites->DuplexingCapability->Contains(Duplexing::TwoSidedLongEdge)) - { - printTicket->Duplexing = Duplexing::TwoSidedLongEdge; - } - if (printCapabilites->StaplingCapability->Contains(Stapling::StapleDualLeft)) - { - printTicket->Stapling = Stapling::StapleDualLeft; - } - return printTicket; - };// end:GetPrintTicketFromPrinter() - // - - - // - // --------------------------- WritePageContent --------------------------- - void WritePageContent (System::Xml::XmlWriter^ xmlWriter, System::String^ documentUri, Dictionary^>^ resources) - { - List^ xpsImages = resources["XpsImage"]; - List^ xpsFonts = resources["XpsFont"]; - - // Element are indented for reading purposes only - xmlWriter->WriteStartElement("FixedPage"); - xmlWriter->WriteAttributeString("Width", "816"); - xmlWriter->WriteAttributeString("Height", "1056"); - xmlWriter->WriteAttributeString("xmlns", "http://schemas.microsoft.com/xps/2005/06"); - xmlWriter->WriteAttributeString("xml:lang", "en-US"); - - xmlWriter->WriteStartElement("Glyphs"); - xmlWriter->WriteAttributeString("Fill", "#ff000000"); - xmlWriter->WriteAttributeString("FontUri", xpsFonts[0]->Uri->ToString()); - xmlWriter->WriteAttributeString("FontRenderingEmSize", "18"); - xmlWriter->WriteAttributeString("OriginX", "120"); - xmlWriter->WriteAttributeString("OriginY", "110"); - xmlWriter->WriteAttributeString("UnicodeString", documentUri); - xmlWriter->WriteEndElement(); - - xmlWriter->WriteStartElement("Glyphs"); - xmlWriter->WriteAttributeString("Fill", "#ff000000"); - xmlWriter->WriteAttributeString("FontUri", xpsFonts[1]->Uri->ToString()); - xmlWriter->WriteAttributeString("FontRenderingEmSize", "16"); - xmlWriter->WriteAttributeString("OriginX", "120"); - xmlWriter->WriteAttributeString("OriginY", "130"); - xmlWriter->WriteAttributeString("UnicodeString", "Test String in Arial"); - xmlWriter->WriteEndElement(); - - xmlWriter->WriteStartElement("Path"); - xmlWriter->WriteAttributeString("Data", "M 120,187 L 301,187 301,321 120,321 z"); - xmlWriter->WriteStartElement("Path.Fill"); - xmlWriter->WriteStartElement("ImageBrush"); - xmlWriter->WriteAttributeString("ImageSource", xpsImages[0]->Uri->ToString()); - xmlWriter->WriteAttributeString("Viewbox", "0,0,181,134"); - xmlWriter->WriteAttributeString("TileMode", "None"); - xmlWriter->WriteAttributeString("ViewboxUnits", "Absolute"); - xmlWriter->WriteAttributeString("ViewportUnits", "Absolute"); - xmlWriter->WriteAttributeString("Viewport", "120,187,181,134"); - xmlWriter->WriteEndElement(); - xmlWriter->WriteEndElement(); - xmlWriter->WriteEndElement(); - - xmlWriter->WriteStartElement("Path"); - xmlWriter->WriteAttributeString("Data", "M 120,357 L 324,357 324,510 120,510 z"); - xmlWriter->WriteStartElement("Path.Fill"); - xmlWriter->WriteStartElement("ImageBrush"); - xmlWriter->WriteAttributeString("ImageSource", xpsImages[1]->Uri->ToString()); - xmlWriter->WriteAttributeString("Viewbox", "0,0,204,153"); - xmlWriter->WriteAttributeString("TileMode", "None"); - xmlWriter->WriteAttributeString("ViewboxUnits", "Absolute"); - xmlWriter->WriteAttributeString("ViewportUnits", "Absolute"); - xmlWriter->WriteAttributeString("Viewport", "120,357,204,153"); - xmlWriter->WriteEndElement(); - xmlWriter->WriteEndElement(); - xmlWriter->WriteEndElement(); - xmlWriter->WriteEndElement(); - };// end:WritePageContent() - // - - - // ----------------------------- WriteToStream ---------------------------- - void WriteToStream (System::IO::Stream^ stream, System::String^ resource) - { - int bufSize = 0x1000; - array^ buf = gcnew array(bufSize); - int bytesRead = 0; - { - System::IO::FileStream^ fileStream = gcnew System::IO::FileStream(resource, FileMode::Open, FileAccess::Read); - try - { - while ((bytesRead = fileStream->Read(buf, 0, bufSize)) > 0) - { - stream->Write(buf, 0, bytesRead); - } - } finally - { - delete fileStream; - } - } - }; - - // ------------------------- WriteObfuscatedStream ------------------------ - void WriteObfuscatedStream (System::String^ resourceName, System::IO::Stream^ stream, System::String^ resource) { - int bufSize = 0x1000; - int guidByteSize = 16; - int obfuscatedByte = 32; - - // Get the GUID byte from the resource name. Typical Font name: - // /Resources/Fonts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.ODTTF - int startPos = resourceName->LastIndexOf('/') + 1; - int length = resourceName->LastIndexOf('.') - startPos; - resourceName = resourceName->Substring(startPos, length); - - System::Guid guid = System::Guid(resourceName); - - System::String^ guidString = guid.ToString("N"); - - // Parsing the guid string and coverted into byte value - array^ guidBytes = gcnew array(guidByteSize); - - for ( - int i = 0; - i < guidBytes->Length; - i++) - { - guidBytes[i] = Convert::ToByte(guidString->Substring(i * 2, 2), 16); - } - - { - System::IO::FileStream^ filestream = gcnew System::IO::FileStream(resource, FileMode::Open); - try - { - // XOR the first 32 bytes of the source - // resource stream with GUID byte. - array^ buf = gcnew array(obfuscatedByte); - filestream->Read(buf, 0, obfuscatedByte); - - for ( - int i = 0; - i < obfuscatedByte; - i++) - { - int guidBytesPos = guidBytes->Length - (i % guidBytes->Length) - 1; - buf[i] ^= guidBytes[guidBytesPos]; - } - - stream->Write(buf, 0, obfuscatedByte); - - // copy remaining stream from source without obfuscation - buf = gcnew array(bufSize); - int bytesRead = 0; - while ((bytesRead = filestream->Read(buf, 0, bufSize)) > 0) - { - stream->Write(buf, 0, bytesRead); - } - } finally - { - delete filestream; - } - } - }; - -}; - - -//Entry Point: -int main (array^ args) -{ - XpsCreate::Main(args); - return 0; -} diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/arial.ttf b/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/arial.ttf deleted file mode 100644 index ff0815cd8c64b..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/arial.ttf and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/courier.ttf b/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/courier.ttf deleted file mode 100644 index 2c99e08c25536..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/courier.ttf and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/image.tif b/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/image.tif deleted file mode 100644 index c9df35e767491..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/image.tif and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/picture.jpg b/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/picture.jpg deleted file mode 100644 index 5aaafc1aa06d9..0000000000000 Binary files a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/picture.jpg and /dev/null differ diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/xpscreate.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/xpscreate.vcxproj deleted file mode 100644 index 3061287a6bb7d..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/XpsCreate/CPP/xpscreate.vcxproj +++ /dev/null @@ -1,131 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - TemplateNamespace - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21208.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/InteractiveExample.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/InteractiveExample.cpp deleted file mode 100644 index 1fd1457f99a63..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/InteractiveExample.cpp +++ /dev/null @@ -1,125 +0,0 @@ -//InteractiveExample.cpp file -// -/* - -This sample animates the position of an ellipse when -the user clicks within the main border. If the user -left-clicks, the SnapshotAndReplace HandoffBehavior -is used when applying the animations. If the user -right-clicks, the Compose HandoffBehavior is used -instead. - -*/ - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Navigation; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Animation; -using namespace System::Windows::Shapes; -using namespace System::Windows::Controls; -using namespace System::Windows::Input; - -namespace Microsoft { - namespace Samples { - namespace Animation { - namespace LocalAnimations { - public ref class InteractiveAnimationExample : Page { - private: - TranslateTransform^ interactiveTranslateTransform; - Border^ containerBorder; - Ellipse^ interactiveEllipse; - - public: - InteractiveAnimationExample () - { - WindowTitle = "Interactive Animation Example"; - DockPanel^ myPanel = gcnew DockPanel(); - myPanel->Margin = Thickness(20.0); - - containerBorder = gcnew Border(); - containerBorder->Background = Brushes::White; - containerBorder->BorderBrush = Brushes::Black; - containerBorder->BorderThickness = Thickness(2.0); - containerBorder->VerticalAlignment = System::Windows::VerticalAlignment::Stretch; - - interactiveEllipse = gcnew Ellipse(); - interactiveEllipse->Fill = Brushes::Lime; - interactiveEllipse->Stroke = Brushes::Black; - interactiveEllipse->StrokeThickness = 2.0; - interactiveEllipse->Width = 25; - interactiveEllipse->Height = 25; - interactiveEllipse->HorizontalAlignment = System::Windows::HorizontalAlignment::Left; - interactiveEllipse->VerticalAlignment = System::Windows::VerticalAlignment::Top; - - interactiveTranslateTransform = gcnew TranslateTransform(); - interactiveEllipse->RenderTransform = interactiveTranslateTransform; - - containerBorder->MouseLeftButtonDown += - gcnew MouseButtonEventHandler(this, &Microsoft::Samples::Animation::LocalAnimations::InteractiveAnimationExample::border_mouseLeftButtonDown); - containerBorder->MouseRightButtonDown += - gcnew MouseButtonEventHandler(this, &Microsoft::Samples::Animation::LocalAnimations::InteractiveAnimationExample::border_mouseRightButtonDown); - containerBorder->Child = interactiveEllipse; - - myPanel->Children->Add(containerBorder); - this->Content = myPanel; - }; - - private: - // When the user left-clicks, use the - // SnapshotAndReplace HandoffBehavior when applying the animation. - void border_mouseLeftButtonDown (System::Object^ sender, System::Windows::Input::MouseButtonEventArgs^ e) - { - System::Windows::Point clickPoint = Mouse::GetPosition(containerBorder); - - // Set the target point so the center of the ellipse - // ends up at the clicked point. - Point targetPoint = Point(); - targetPoint.X = clickPoint.X - interactiveEllipse->Width / 2; - targetPoint.Y = clickPoint.Y - interactiveEllipse->Height / 2; - - // Animate to the target point. - DoubleAnimation^ xAnimation = gcnew DoubleAnimation(targetPoint.X, - Duration(TimeSpan::FromSeconds(4))); - interactiveTranslateTransform->BeginAnimation(TranslateTransform::XProperty, xAnimation, HandoffBehavior::SnapshotAndReplace); - - DoubleAnimation^ yAnimation = gcnew DoubleAnimation(targetPoint.Y, - Duration(TimeSpan::FromSeconds(4))); - interactiveTranslateTransform->BeginAnimation(TranslateTransform::YProperty, yAnimation, HandoffBehavior::SnapshotAndReplace); - - // Chage the color of the ellipse. - interactiveEllipse->Fill = Brushes::Lime; - } - - private: - // When the user right-clicks, use the - // Compose HandoffBehavior when applying the animation. - void border_mouseRightButtonDown (System::Object^ sender, System::Windows::Input::MouseButtonEventArgs^ e) - { - // Find the point where the use clicked. - Point clickPoint = Mouse::GetPosition(containerBorder); - - // Set the target point so the center of the ellipse - // ends up at the clicked point. - Point targetPoint = System::Windows::Point(); - targetPoint.X = clickPoint.X - interactiveEllipse->Width / 2; - targetPoint.Y = clickPoint.Y - interactiveEllipse->Height / 2; - - // Animate to the target point. - DoubleAnimation^ xAnimation = gcnew DoubleAnimation(targetPoint.X, - Duration(TimeSpan::FromSeconds(4))); - interactiveTranslateTransform->BeginAnimation(TranslateTransform::XProperty, xAnimation, HandoffBehavior::Compose); - - DoubleAnimation^ yAnimation = gcnew DoubleAnimation(targetPoint.Y, - Duration(TimeSpan::FromSeconds(4))); - - // Change the color of the ellipse. - interactiveTranslateTransform->BeginAnimation(TranslateTransform::YProperty, yAnimation, HandoffBehavior::Compose); - interactiveEllipse->Fill = Brushes::Orange; - } - }; - } - } - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/LocalAnimationExample.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/LocalAnimationExample.cpp deleted file mode 100644 index 7660b657d007f..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/LocalAnimationExample.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//LocalAnimationExample.cpp file -// -/* - - This sample demonstrates how to apply non-storyboard animations to a property. - To animate in markup, you must use storyboards. - -*/ - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Navigation; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Animation; -using namespace System::Windows::Shapes; -using namespace System::Windows::Controls; - - -namespace Microsoft { - namespace Samples { - namespace Animation { - namespace LocalAnimations { - // Create the demonstration. - public ref class LocalAnimationExample : Page { - - public: - LocalAnimationExample () - { - WindowTitle = "Local Animation Example"; - StackPanel^ myStackPanel = gcnew StackPanel(); - myStackPanel->Margin = Thickness(20); - - // Create and set the Button. - Button^ aButton = gcnew Button(); - aButton->Content = "A Button"; - - // Animate the Button's Width. - DoubleAnimation^ myDoubleAnimation = gcnew DoubleAnimation(); - myDoubleAnimation->From = 75; - myDoubleAnimation->To = 300; - myDoubleAnimation->Duration = Duration(TimeSpan::FromSeconds(5)); - myDoubleAnimation->AutoReverse = true; - myDoubleAnimation->RepeatBehavior = RepeatBehavior::Forever; - - // Apply the animation to the button's Width property. - aButton->BeginAnimation(Button::WidthProperty, myDoubleAnimation); - - // Create and animate a Brush to set the button's Background. - SolidColorBrush^ myBrush = gcnew SolidColorBrush(); - myBrush->Color = Colors::Blue; - - ColorAnimation^ myColorAnimation = gcnew ColorAnimation(); - myColorAnimation->From = Colors::Blue; - myColorAnimation->To = Colors::Red; - myColorAnimation->Duration = Duration(TimeSpan::FromMilliseconds(7000)); - myColorAnimation->AutoReverse = true; - myColorAnimation->RepeatBehavior = RepeatBehavior::Forever; - - // Apply the animation to the brush's Color property. - myBrush->BeginAnimation(SolidColorBrush::ColorProperty, myColorAnimation); - aButton->Background = myBrush; - - // Add the Button to the panel. - myStackPanel->Children->Add(aButton); - this->Content = myStackPanel; - }; - }; - } - } - } -} -// diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/animagionproperty_cpp.vcxproj b/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/animagionproperty_cpp.vcxproj deleted file mode 100644 index ad5eb76eab3c3..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/animagionproperty_cpp.vcxproj +++ /dev/null @@ -1,135 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - LocalAnimationsExample - {1006019E-21B6-40FF-915C-EBB1C580417E} - Microsoft.Samples.Animation.LocalAnimations - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21230.0 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/app.cpp b/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/app.cpp deleted file mode 100644 index dae3f92d86bfa..0000000000000 --- a/samples/snippets/cpp/VS_Snippets_Wpf/animateproperty/CPP/app.cpp +++ /dev/null @@ -1,99 +0,0 @@ -//app.cpp file - - -using namespace System; -using namespace System::Windows; -using namespace System::Windows::Navigation; -using namespace System::Windows::Media; -using namespace System::Windows::Media::Animation; -using namespace System::Windows::Shapes; -using namespace System::Windows::Controls; -using namespace System::Windows::Input; - - -namespace Microsoft { - namespace Samples { - namespace Animation { - namespace LocalAnimations { - - // Forward class declaration. - public ref class LocalAnimationExample : Page { - public: - LocalAnimationExample () ; - }; - - // Forward class declaration. - public ref class InteractiveAnimationExample : Page { - public: - InteractiveAnimationExample () ; - private: - TranslateTransform^ interactiveTranslateTransform; - Border^ containerBorder; - Ellipse^ interactiveEllipse; - void border_mouseLeftButtonDown (System::Object^ sender, MouseButtonEventArgs^ e) ; - void border_mouseRightButtonDown (System::Object^ sender, MouseButtonEventArgs^ e) ; - }; - - // SampleViewer class. - public ref class SampleViewer : Window { - public: - SampleViewer (){ - TabControl^ tControl = gcnew TabControl(); - TabItem^ tItem = gcnew TabItem(); - tItem->Header = "Local Animation Example"; - Frame^ contentFrame = gcnew Frame(); - contentFrame->Content = gcnew LocalAnimationExample(); - tItem->Content = contentFrame; - tControl->Items->Add(tItem); - tItem = gcnew System::Windows::Controls::TabItem(); - tItem->Header = "Interactive Animation Example"; - contentFrame = gcnew System::Windows::Controls::Frame(); - contentFrame->Content = gcnew InteractiveAnimationExample(); - tItem->Content = contentFrame; - tControl->Items->Add(tItem); - this->Content = tControl; - this->Title = "Local Animations Example"; - } ; - }; - - // Application class. - public ref class app : Application { - protected: - virtual void OnStartup (System::Windows::StartupEventArgs^ e) override - { - Application::OnStartup(e); - CreateAndShowMainWindow(); - }; - - private: - void CreateAndShowMainWindow () - { - // Create the application's main window. - Window^ sViewer = gcnew SampleViewer(); - MainWindow = sViewer; - sViewer->Show(); - }; - }; - - private ref class EntryClass sealed { - public: - [System::STAThread()] - static void Main () - { - LocalAnimations::app^ app = gcnew LocalAnimations::app(); - app->Run(); - } - ; - }; - - } - } - } -} - -//Entry Point: -[System::STAThreadAttribute()] -void main () -{ - return Microsoft::Samples::Animation::LocalAnimations::EntryClass::Main(); -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/Project.csproj new file mode 100644 index 0000000000000..d9f06df6e42fc --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/Project.csproj @@ -0,0 +1,12 @@ + + + + Library + net4.8 + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/makefile deleted file mode 100644 index 6c7850479e5fa..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: source.exe - -source.exe: source.cs - csc /t:exe source.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll,System.IdentityModel.dll /lib:c:\whidbey\assemblies diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/source.cs index 1bb569628b4a6..6e780e6b0aafa 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_certificatevalidationdifferences/cs/source.cs @@ -4,14 +4,11 @@ using System.ServiceModel; using System.Security.Cryptography.X509Certificates; using System.ServiceModel.Security; -using System.Security.Permissions; using System.Net; using System.Net.Security; using System.Runtime.Serialization; using System.Xml.Schema; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] public class Test { public static void Main() diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_collection_types_in_data_contracts/cs/program.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_collection_types_in_data_contracts/cs/program.cs index 1df8dd7351ff4..93c09daf8b693 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_collection_types_in_data_contracts/cs/program.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_collection_types_in_data_contracts/cs/program.cs @@ -1,6 +1,4 @@ -// snippet -// C:\sdtree\snippets\indigo\c_Collection_Types_in_Data_Contracts\CS\Program.cs -using System; +using System; using System.Collections; using System.Runtime.Serialization; using System.ServiceModel; @@ -9,7 +7,6 @@ using System.Security.Permissions; using System.Collections.Generic; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.Security.Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/Project.csproj new file mode 100644 index 0000000000000..0cb2c6d132712 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/Project.csproj @@ -0,0 +1,11 @@ + + + + Library + net4.8 + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/makefile deleted file mode 100644 index 3c20f4a0cdd43..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: source.exe - -source.exe: source.cs - csc /t:library source.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll /lib:c:\whidbey\assemblies \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/source.cs index eae3fc09d9084..15f8aa4ae57d7 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_controlserviceinstancing/cs/source.cs @@ -1,8 +1,6 @@ using System; using System.ServiceModel; -using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Microsoft.ServiceModel.Samples { // @@ -55,4 +53,4 @@ public class Class4 { } public class Class5 { } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/Project.csproj new file mode 100644 index 0000000000000..0cb2c6d132712 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/Project.csproj @@ -0,0 +1,11 @@ + + + + Library + net4.8 + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/makefile deleted file mode 100644 index 3801a2709ccc1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: SecureService.exe - -SecureService.exe: SecureService.cs - csc /t:exe *.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll /lib:c:\whidbey\assemblies diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/secureservice.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/secureservice.cs index e02d1ff0c0118..32928bd759ae9 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/secureservice.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_createsecuresession/cs/secureservice.cs @@ -1,12 +1,7 @@ using System; -using System.Collections; -using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Channels; -using System.ServiceModel.Description; -using System.Security.Permissions; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.Security.Samples { public class Test @@ -106,4 +101,4 @@ public double Add(double a, double b) return a + b; } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_createstatefulsct/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_createstatefulsct/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_createstatefulsct/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_createstatefulsct/cs/secureservice.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_createstatefulsct/cs/secureservice.cs index 6cfcf4bd624f0..d0675a55edcf4 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_createstatefulsct/cs/secureservice.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_createstatefulsct/cs/secureservice.cs @@ -4,9 +4,7 @@ using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; -using System.Security.Permissions; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.Security.Samples { public class Test @@ -96,4 +94,4 @@ public double Add(double a, double b) return a + b; } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_creatests/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_creatests/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_creatests/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_creatests/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_creatests/cs/source.cs index 515393cc2216c..44b61dfadb328 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_creatests/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_creatests/cs/source.cs @@ -3,15 +3,12 @@ using System.ServiceModel.Security; using System.IdentityModel.Tokens; using System.Collections.Generic; -using System.Security.Permissions; using System.ServiceModel.Description; using System.ServiceModel.Security.Tokens; using System.IdentityModel.Claims; using System.ServiceModel.Channels; using System.Security.Cryptography.X509Certificates; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace CreateSts { public class Test diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customauthmgr/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthmgr/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthmgr/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customauthmgr/cs/c_customauthmgr.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthmgr/cs/c_customauthmgr.cs index 1675b9f48077c..6c16960e3fd7d 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customauthmgr/cs/c_customauthmgr.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthmgr/cs/c_customauthmgr.cs @@ -3,10 +3,8 @@ using System; using System.IdentityModel.Claims; using System.ServiceModel; -using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customauthpol/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthpol/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthpol/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customauthpol/cs/c_customauthpol.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthpol/cs/c_customauthpol.cs index 4ae1ca00d07e1..ea99b8837c5c3 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customauthpol/cs/c_customauthpol.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customauthpol/cs/c_customauthpol.cs @@ -5,10 +5,8 @@ using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.ServiceModel; -using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_custombinding/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_custombinding/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_custombinding/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_custombinding/cs/c_custombinding.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_custombinding/cs/c_custombinding.cs index 208744a84bddb..8c4ef81c76ae0 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_custombinding/cs/c_custombinding.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_custombinding/cs/c_custombinding.cs @@ -7,10 +7,8 @@ using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; -using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { public sealed class CustomBindingCreator diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_custombindingsauthmode/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_custombindingsauthmode/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_custombindingsauthmode/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_custombindingsauthmode/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_custombindingsauthmode/cs/source.cs index 7cd22cd0daaf9..2e99c81fa6503 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_custombindingsauthmode/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_custombindingsauthmode/cs/source.cs @@ -6,13 +6,10 @@ using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; -using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { - public sealed class CustomBindingCreator { private CustomBindingCreator() { } diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customcertificatevalidator/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customcertificatevalidator/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customcertificatevalidator/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customcertificatevalidator/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customcertificatevalidator/cs/source.cs index 0c8475c9f52f9..db2d82340b080 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customcertificatevalidator/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customcertificatevalidator/cs/source.cs @@ -6,10 +6,6 @@ using System.ServiceModel; using System.ServiceModel.Security; -using System.Security.Permissions; - -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.ServiceModel.Samples { [ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")] diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customclaim/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaim/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaim/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customclaim/cs/c_customclaim.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaim/cs/c_customclaim.cs index 238faf35e6eba..510f733cc905a 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customclaim/cs/c_customclaim.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaim/cs/c_customclaim.cs @@ -3,10 +3,8 @@ using System; using System.IdentityModel.Claims; using System.Runtime.Serialization; -using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customclaimcomparison/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaimcomparison/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaimcomparison/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customclaimcomparison/cs/c_customclaimcomparison.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaimcomparison/cs/c_customclaimcomparison.cs index 476ca3a5e4e1e..f75b2144ae5bd 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customclaimcomparison/cs/c_customclaimcomparison.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customclaimcomparison/cs/c_customclaimcomparison.cs @@ -2,10 +2,8 @@ // using System; using System.IdentityModel.Claims; -using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/Project.csproj new file mode 100644 index 0000000000000..140c6c2fcaf71 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/Project.csproj @@ -0,0 +1,14 @@ + + + + Library + net48 + + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/makefile deleted file mode 100644 index 5e2958972cacd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: source.dll - -source.dll: source.cs - csc /t:library source.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll,System.IdentityModel.dll /lib:c:\whidbey\assemblies diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/source.cs index 487972ab7dbf3..55ccbe185334c 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customcredentials/cs/source.cs @@ -1,7 +1,6 @@ // using System; using System.IdentityModel.Selectors; -using System.Security.Permissions; using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Security; @@ -9,8 +8,6 @@ using System.ServiceModel.Configuration; using System.Configuration; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, - Execution = true)] namespace Microsoft.ServiceModel.Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customfederationbinding/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customfederationbinding/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customfederationbinding/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customfederationbinding/cs/c_customfederationbinding.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customfederationbinding/cs/c_customfederationbinding.cs index d84710f8eccca..7de9658ccf6f1 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customfederationbinding/cs/c_customfederationbinding.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customfederationbinding/cs/c_customfederationbinding.cs @@ -5,13 +5,10 @@ using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Security.Tokens; -using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { - public sealed class CustomBindingCreator { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customtoken/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customtoken/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customtoken/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customtoken/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customtoken/cs/source.cs index 904cab1da330a..6a14ac2149473 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customtoken/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customtoken/cs/source.cs @@ -7,7 +7,6 @@ using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; using System.IO; -using System.Security.Permissions; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; @@ -15,8 +14,6 @@ using System.ServiceModel.Security.Tokens; using System.Xml; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.ServiceModel.Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenauthenticator/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenauthenticator/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenauthenticator/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenauthenticator/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenauthenticator/cs/source.cs index 15333785bce98..4a97db62cc346 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenauthenticator/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenauthenticator/cs/source.cs @@ -6,13 +6,10 @@ using System.IdentityModel.Policy; using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; -using System.Security.Permissions; using System.ServiceModel.Description; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace CustomTokenAuthenticator { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenprovider/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenprovider/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenprovider/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenprovider/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenprovider/cs/source.cs index bcb64de641737..ea14709d88f89 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenprovider/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customtokenprovider/cs/source.cs @@ -2,13 +2,11 @@ using System; using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; -using System.Security.Permissions; using System.Security.Cryptography.X509Certificates; using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Security.Tokens; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] namespace CustomProvider { // @@ -68,4 +66,4 @@ public override SecurityTokenProvider CreateSecurityTokenProvider( } // } -// \ No newline at end of file +// diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/Project.csproj new file mode 100644 index 0000000000000..d05e7e2561064 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/Project.csproj @@ -0,0 +1,15 @@ + + + + Library + net48 + 8 + + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/makefile deleted file mode 100644 index 5e2958972cacd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: source.dll - -source.dll: source.cs - csc /t:library source.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll,System.IdentityModel.dll /lib:c:\whidbey\assemblies diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/source.cs index e167c7b1382c7..a91aef3dd3a55 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_customx509token/cs/source.cs @@ -7,14 +7,11 @@ using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.Xml; -using System.Security.Permissions; using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.ServiceModel.Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_dataarchitecture/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_dataarchitecture/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_dataarchitecture/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_dataarchitecture/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_dataarchitecture/cs/source.cs index b7e1504f6cb7b..9867ba15fb43f 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_dataarchitecture/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_dataarchitecture/cs/source.cs @@ -2,19 +2,14 @@ using System.IO; using System.Runtime.Serialization; using System.Xml; -using System.Security.Permissions; using System.Security; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Security.Tokens; - using System.ServiceModel.Description; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Samples { - // [ServiceContract] public interface IAirfareFinderService @@ -187,4 +182,4 @@ public interface three void SubmitOrder(string customerID, string item, int quantity); // } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_datacontract/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontract/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontract/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_datacontract/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontract/cs/source.cs index c773820628a40..4da08161f040d 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_datacontract/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontract/cs/source.cs @@ -2,8 +2,6 @@ using System.ServiceModel; using System.Security.Permissions; using System.Runtime.Serialization; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Example { @@ -192,4 +190,4 @@ private void setDefaultCountryRegion(StreamingContext c) } } // -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractenumerations/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractenumerations/cs/source.cs index 841f03ccb0c73..eb3cda100f180 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractenumerations/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractenumerations/cs/source.cs @@ -2,10 +2,9 @@ using System; using System.Collections.Generic; using System.Text; -using System.Security.Permissions; using System.Runtime.Serialization; // -[assembly: SecurityPermission(SecurityAction.RequestMinimum)] + namespace ServiceModel.Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractversioning/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractversioning/cs/source.cs index df2a157288941..95ea51b2e2a59 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractversioning/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_datacontractversioning/cs/source.cs @@ -3,8 +3,6 @@ using System.Security.Permissions; using System.Runtime.Serialization; using System.Xml; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace DataContractsPrime { //C_DataContractVersioning#1 @@ -58,4 +56,4 @@ static void Main() { } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_delegation/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_delegation/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_delegation/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_delegation/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_delegation/cs/source.cs index e5d6261080221..cf24eb0a025b7 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_delegation/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_delegation/cs/source.cs @@ -5,8 +5,6 @@ using System.Security.Principal; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace SnippetsPart1 { [ServiceContract] diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/makefile deleted file mode 100644 index 5e2958972cacd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: source.dll - -source.dll: source.cs - csc /t:library source.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll,System.IdentityModel.dll /lib:c:\whidbey\assemblies diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/source.cs index 327646763ffe4..3f8acc517ca57 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedclient/cs/source.cs @@ -1,16 +1,8 @@ // // using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens; -using System.Security.Cryptography.X509Certificates; using System.ServiceModel; -using System.ServiceModel.Channels; using System.ServiceModel.Security; -using System.ServiceModel.Security.Tokens; -using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Samples { // @@ -25,7 +17,7 @@ SecurityKeyEntropyMode entropyMode { if (cf == null) { - throw new ArgumentNullException("ChannelFactory"); + throw new ArgumentNullException("cf"); } // Set the CacheIssuedTokens property cf.Credentials.IssuedToken.CacheIssuedTokens = cacheTokens; @@ -47,4 +39,4 @@ SecurityKeyEntropyMode entropyMode private IssuedTokenClientCredentialsConfiguration() { } } } - // +// diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedservice/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedservice/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedservice/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedservice/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedservice/cs/source.cs index 419b1349ca88b..4b4dfdd03c880 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_federatedservice/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federatedservice/cs/source.cs @@ -10,8 +10,6 @@ using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Samples { [ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")] diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/makefile deleted file mode 100644 index eab7a5b56a5e2..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: source.exe - -source.exe: source.cs - csc /t:exe source.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll,System.IdentityModel.dll /lib:c:\whidbey\assemblies \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/source.cs index 6d3986f82e8f9..7f739eaa577d6 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federation/cs/source.cs @@ -1,18 +1,12 @@ // -using System; using System.Collections.Generic; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; using System.Security.Cryptography.X509Certificates; -using System.Security.Permissions; using System.ServiceModel; -using System.ServiceModel.Channels; -using System.ServiceModel.Security.Tokens; -using System.Text; // -[assembly: SecurityPermission(SecurityAction.RequestMinimum)] namespace Federation_Conceptual { class Program @@ -261,25 +255,4 @@ private static bool IsValidEmailAddress(string emailAddress) } } // - - // - public class myService_M_AuthorizationManager : ServiceAuthorizationManager - { - // set max size for message - int someMaxSize = 16000; - protected override bool CheckAccessCore(OperationContext operationContext, ref Message message) - { - bool accessAllowed = false; - MessageBuffer requestBuffer = message.CreateBufferedCopy(someMaxSize); - - // do access checks using the message parameter value and set accessAllowed appropriately - if (accessAllowed) - { - // replace incoming message with fresh copy since accessing the message consumes it - message = requestBuffer.CreateMessage(); - } - return accessAllowed; - } - } - // } diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federationbinding/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_federationbinding/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federationbinding/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_federationbinding/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_federationbinding/cs/source.cs index 56c66776bb950..e2fdbbbddf3a7 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_federationbinding/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_federationbinding/cs/source.cs @@ -9,8 +9,6 @@ using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_findclaimsperf/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_findclaimsperf/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_findclaimsperf/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_findclaimsperf/cs/c_findclaimsperf.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_findclaimsperf/cs/c_findclaimsperf.cs index 6322114fd82be..819eaebf0efd8 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_findclaimsperf/cs/c_findclaimsperf.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_findclaimsperf/cs/c_findclaimsperf.cs @@ -5,8 +5,6 @@ using System.IdentityModel.Claims; using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Samples { class Program diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_fourcerts/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_fourcerts/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_fourcerts/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_fourcerts/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_fourcerts/cs/source.cs index 8cf4b128f4a69..3f95a222c84d6 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_fourcerts/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_fourcerts/cs/source.cs @@ -11,8 +11,6 @@ using System.ServiceModel.Channels; using System.IdentityModel.Policy; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.ServiceModel.Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howtocheckformexrequestsinauthorization/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_howtocheckformexrequestsinauthorization/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_howtocheckformexrequestsinauthorization/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howtocheckformexrequestsinauthorization/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_howtocheckformexrequestsinauthorization/cs/source.cs index 50fe0903c37e0..7ac3345eba27d 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_howtocheckformexrequestsinauthorization/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_howtocheckformexrequestsinauthorization/cs/source.cs @@ -10,8 +10,6 @@ using System.ServiceModel.Channels; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.Samples { public class test diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howtosecureendpoint/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosecureendpoint/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosecureendpoint/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howtosecureendpoint/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosecureendpoint/cs/source.cs index bec4b99e4c7fe..fcf89078652a3 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_howtosecureendpoint/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosecureendpoint/cs/source.cs @@ -3,9 +3,7 @@ using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Description; -using System.Security.Permissions; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.Security.Samples { public class Test @@ -71,4 +69,4 @@ public double Add(double a, double b) return a + b; } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howtosetcustomclientidentity/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosetcustomclientidentity/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosetcustomclientidentity/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howtosetcustomclientidentity/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosetcustomclientidentity/cs/source.cs index f6eb1fbe3f3a5..68e938e2fb0c1 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_howtosetcustomclientidentity/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_howtosetcustomclientidentity/cs/source.cs @@ -10,8 +10,6 @@ using System.ServiceModel.Channels; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.ServiceModel.Samples { [System.Diagnostics.DebuggerStepThroughAttribute()] diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_identity/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_identity/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_identity/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_identity/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_identity/cs/source.cs index 2889a14b6083f..fc2cb5104f1fd 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_identity/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_identity/cs/source.cs @@ -7,8 +7,6 @@ using System.Security.Permissions; using System.ServiceModel.Security.Tokens; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace IdentityExample { public class Test diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_impersonationanddelegation/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_impersonationanddelegation/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_impersonationanddelegation/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_impersonationanddelegation/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_impersonationanddelegation/cs/source.cs index 0f4dfccdc92d6..739eee2b00463 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_impersonationanddelegation/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_impersonationanddelegation/cs/source.cs @@ -5,8 +5,6 @@ using System.Security.Principal; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace SnippetsPart1 { interface IHelloService @@ -106,4 +104,4 @@ private void BuildStuff() // } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_knowntypeattribute/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_knowntypeattribute/cs/source.cs index 1850348ad0b0d..58a4ec48dd09c 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_knowntypeattribute/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_knowntypeattribute/cs/source.cs @@ -4,8 +4,6 @@ using System.Collections; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace ConceptualKnownTypeSamples { public sealed class Test diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_maxclockskew/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_maxclockskew/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_maxclockskew/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_maxclockskew/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_maxclockskew/cs/source.cs index 37c394de6a2ca..0441c6e50f0d9 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_maxclockskew/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_maxclockskew/cs/source.cs @@ -7,8 +7,6 @@ //using System.Security.Cryptography.X509Certificates; using System.ServiceModel.Security.Tokens; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Examples { public class Program @@ -100,4 +98,4 @@ public int Add(int a, int b) return a + b; } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_programmingsecurity/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_programmingsecurity/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_programmingsecurity/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_programmingsecurity/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_programmingsecurity/cs/source.cs index 6164c1fd944c1..63d4a612f9e61 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_programmingsecurity/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_programmingsecurity/cs/source.cs @@ -5,8 +5,6 @@ using System.Security.Permissions; using System.ServiceModel.Description; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Windows.Communication.Foundation.Samples { diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_protectionlevel/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_protectionlevel/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_protectionlevel/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_protectionlevel/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_protectionlevel/cs/source.cs index 49be8bddc4da0..b63b973182e90 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_protectionlevel/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_protectionlevel/cs/source.cs @@ -3,15 +3,12 @@ using System.ServiceModel; using System.Net.Security; using System.ServiceModel.Description; -using System.Security.Permissions; using System.Security.Cryptography.X509Certificates; using System.Runtime.Serialization; // -[assembly: SecurityPermission(SecurityAction.RequestMinimum)] namespace Microsoft.WCF.Samples1 { - // // // Set the ProtectionLevel on the whole service to Sign. @@ -19,7 +16,6 @@ namespace Microsoft.WCF.Samples1 public interface ICalculator // { - // Set the ProtectionLevel on this operation to None. [OperationContract(ProtectionLevel = ProtectionLevel.Sign)] double Add(double a, double b); @@ -205,4 +201,4 @@ public interface IPurchaseOrder } // } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/makefile b/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/makefile deleted file mode 100644 index 5e2958972cacd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: source.dll - -source.dll: source.cs - csc /t:library source.cs /r:System.ServiceModel.dll,System.Runtime.Serialization.dll,System.IdentityModel.dll /lib:c:\whidbey\assemblies diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/source.cs index f8149d19522f4..66056707b9288 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_schemaimportexport/cs/source.cs @@ -1,200 +1,221 @@ // using System; -using System.ServiceModel; -using System.Net.Security; -using System.ServiceModel.Description; -using System.Security.Permissions; -using System.Security.Cryptography.X509Certificates; -using System.Runtime.Serialization; -using System.ComponentModel; using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.Serialization; // -[assembly: SecurityPermission(SecurityAction.RequestMinimum)] namespace ImportExport1 { -// -[DataContract] -public partial class Vehicle : IExtensibleDataObject -{ - private int yearField; - private string colorField; + // + [DataContract] + public partial class Vehicle : IExtensibleDataObject + { + private int yearField; + private string colorField; - [DataMember] public int year { - get {return this.yearField;} - set {this.yearField=value;} - } -[DataMember] public string color{ - get {return this.colorField;} - set {this.colorField=value;} - } + [DataMember] + public int year + { + get { return this.yearField; } + set { this.yearField = value; } + } + [DataMember] + public string color + { + get { return this.colorField; } + set { this.colorField = value; } + } - private ExtensionDataObject extensionDataField; - public ExtensionDataObject ExtensionData { - get {return this.extensionDataField;} - set {this.extensionDataField=value;} + private ExtensionDataObject extensionDataField; + public ExtensionDataObject ExtensionData + { + get { return this.extensionDataField; } + set { this.extensionDataField = value; } + } } -} -// + // } namespace ImportExport2 { -// -[DataContract] -internal partial class Vehicle : IExtensibleDataObject -{ - private int yearField; - private string colorField; + // + [DataContract] + internal partial class Vehicle : IExtensibleDataObject + { + private int yearField; + private string colorField; - [DataMember] internal int year { - get {return this.yearField;} - set {this.yearField=value;} - } -[DataMember] internal string color{ - get {return this.colorField;} - set {this.colorField=value;} - } + [DataMember] + internal int year + { + get { return this.yearField; } + set { this.yearField = value; } + } + [DataMember] + internal string color + { + get { return this.colorField; } + set { this.colorField = value; } + } - private ExtensionDataObject extensionDataField; - public ExtensionDataObject ExtensionData { - get {return this.extensionDataField;} - set {this.extensionDataField=value;} + private ExtensionDataObject extensionDataField; + public ExtensionDataObject ExtensionData + { + get { return this.extensionDataField; } + set { this.extensionDataField = value; } + } } -} -// + // } namespace ImportExport3 { -// -namespace Contoso.Cars { -[DataContract] -public partial class Vehicle : IExtensibleDataObject -{ - // Code not shown. - - public ExtensionDataObject ExtensionData + // + namespace Contoso.Cars { - get - { - throw new Exception("The method or operation is not implemented."); - } - set + [DataContract] + public partial class Vehicle : IExtensibleDataObject { - throw new Exception("The method or operation is not implemented."); + // Code not shown. + + public ExtensionDataObject ExtensionData + { + get + { + throw new Exception("The method or operation is not implemented."); + } + set + { + throw new Exception("The method or operation is not implemented."); + } + } } + // } -} -// -} -// -[DataContract] -[Serializable] -public partial class Vehicle : IExtensibleDataObject -{ - // Code not shown. - public ExtensionDataObject ExtensionData + // + [DataContract] + [Serializable] + public partial class Vehicle : IExtensibleDataObject { - get + // Code not shown. + public ExtensionDataObject ExtensionData { - throw new Exception("The method or operation is not implemented."); - } - set - { - throw new Exception("The method or operation is not implemented."); + get + { + throw new Exception("The method or operation is not implemented."); + } + set + { + throw new Exception("The method or operation is not implemented."); + } } } -} -// + // } namespace ImportExport4 - { -// -[DataContract] -public partial class Vehicle : IExtensibleDataObject, INotifyPropertyChanged { - private int yearField; - private string colorField; + // + [DataContract] + public partial class Vehicle : IExtensibleDataObject, INotifyPropertyChanged + { + private int yearField; + private string colorField; - [DataMember] public int year { - get {return this.yearField;} - set { - if (this.yearField.Equals(value) != true) { - this.yearField = value; - this.RaisePropertyChanged("year"); + [DataMember] + public int year + { + get { return this.yearField; } + set + { + if (this.yearField.Equals(value) != true) + { + this.yearField = value; + this.RaisePropertyChanged("year"); + } } -} - } -[DataMember] public string color{ - get {return this.colorField;} - set { - if (this.colorField.Equals(value) != true) { - this.colorField = value; - this.RaisePropertyChanged("color"); + } + [DataMember] + public string color + { + get { return this.colorField; } + set + { + if (this.colorField.Equals(value) != true) + { + this.colorField = value; + this.RaisePropertyChanged("color"); + } } -} - } + } - public event PropertyChangedEventHandler PropertyChanged; - protected void RaisePropertyChanged (string propertyName) { - PropertyChangedEventHandler propertyChanged = -this.PropertyChanged; - if (propertyChanged != null) { - propertyChanged(this, -new PropertyChangedEventArgs(propertyName)); + public event PropertyChangedEventHandler PropertyChanged; + protected void RaisePropertyChanged(string propertyName) + { + PropertyChangedEventHandler propertyChanged = + this.PropertyChanged; + if (propertyChanged != null) + { + propertyChanged(this, + new PropertyChangedEventArgs(propertyName)); + } } - } - private ExtensionDataObject extensionDataField; - public ExtensionDataObject ExtensionData { - get {return this.extensionDataField;} - set {this.extensionDataField=value;} + private ExtensionDataObject extensionDataField; + public ExtensionDataObject ExtensionData + { + get { return this.extensionDataField; } + set { this.extensionDataField = value; } + } } -} -// + // } namespace ImportExport5 { -// -[DataContract] public partial class Vehicle : IExtensibleDataObject -{ - [DataMember] public int yearField; - [DataMember] public string colorField; - [DataMember] public people passengers; + // + [DataContract] + public partial class Vehicle : IExtensibleDataObject + { + [DataMember] public int yearField; + [DataMember] public string colorField; + [DataMember] public people passengers; - // Other code not shown. + // Other code not shown. - public ExtensionDataObject ExtensionData - { - get - { - throw new Exception("The method or operation is not implemented."); - } - set + public ExtensionDataObject ExtensionData { - throw new Exception("The method or operation is not implemented."); + get + { + throw new Exception("The method or operation is not implemented."); + } + set + { + throw new Exception("The method or operation is not implemented."); + } } } + [CollectionDataContract(ItemName = "person")] + public class people : List { } + // } -[CollectionDataContract(ItemName="person")] -public class people : List {} -// -} + namespace ImportExport6 { - // [CollectionDataContract(ItemName = "person")] public class people : BindingList { } // } + namespace ImportExport7 { - public static void snippet() + class HolderClass { - // - XsdDataContractImporter importer = new XsdDataContractImporter(); - importer.Options.Namespaces.Add(new KeyValuePair("http://schemas.contoso.com/carSchema", "Contoso.Cars")); - // + public static void snippet() + { + // + XsdDataContractImporter importer = new XsdDataContractImporter(); + importer.Options.Namespaces.Add(new KeyValuePair("http://schemas.contoso.com/carSchema", "Contoso.Cars")); + // + } } } diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_securewindowsservice/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_securewindowsservice/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_securewindowsservice/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_securewindowsservice/cs/secureservice.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_securewindowsservice/cs/secureservice.cs index a0d7c22f5a127..578898488b751 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_securewindowsservice/cs/secureservice.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_securewindowsservice/cs/secureservice.cs @@ -4,9 +4,7 @@ using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Description; -using System.Security.Permissions; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.Security.Samples { public class Test @@ -75,4 +73,4 @@ public double Add(double a, double b) } } } -// \ No newline at end of file +// diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_securewithcertificate/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_securewithcertificate/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_securewithcertificate/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_securewithcertificate/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_securewithcertificate/cs/source.cs index 1b47587586ade..2a8be50e941f9 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_securewithcertificate/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_securewithcertificate/cs/source.cs @@ -3,12 +3,10 @@ using System.ServiceModel; using System.Net.Security; using System.ServiceModel.Description; -using System.Security.Permissions; using System.Security.Cryptography.X509Certificates; using System.Runtime.Serialization; // -[assembly: SecurityPermission(SecurityAction.RequestMinimum)] namespace Samples1 { [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)] diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/source.cs index 8132b42cd8bd4..d5d9d280611fe 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_securitybestpractices/cs/source.cs @@ -5,8 +5,6 @@ using System.ServiceModel; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Design2 { class Program diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_settingsecuritymode/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_settingsecuritymode/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_settingsecuritymode/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_settingsecuritymode/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_settingsecuritymode/cs/source.cs index 88dc5112f9e50..795b5f999daf5 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_settingsecuritymode/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_settingsecuritymode/cs/source.cs @@ -1,8 +1,7 @@ using System; using System.ServiceModel; -using System.Security.Permissions; using System.Security.Cryptography.X509Certificates; -[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] + namespace Samples { public class Test diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_signatureconfirmation/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_signatureconfirmation/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_signatureconfirmation/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_signatureconfirmation/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_signatureconfirmation/cs/source.cs index d62fe15884f35..1fc334bef8419 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_signatureconfirmation/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_signatureconfirmation/cs/source.cs @@ -10,8 +10,6 @@ using System.IO; using System.Text; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Example { public class Test diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_simpleimpersonation/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_simpleimpersonation/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_simpleimpersonation/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_simpleimpersonation/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_simpleimpersonation/cs/source.cs index 79a4270040fec..c1e480a0dceb7 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_simpleimpersonation/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_simpleimpersonation/cs/source.cs @@ -4,8 +4,6 @@ using System.ServiceModel.Channels; using System.ServiceModel.Security.Tokens; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace ProxySample { @@ -101,4 +99,4 @@ public double Add(double a, double b) } // } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_standalonedatacontractserializer/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_standalonedatacontractserializer/cs/source.cs index af58d475cba84..bafc19f7a59f6 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_standalonedatacontractserializer/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_standalonedatacontractserializer/cs/source.cs @@ -2,11 +2,9 @@ using System.Collections.Generic; using System.Text; using System.Runtime.Serialization; -using System.Security.Permissions; using System.IO; using System.Xml; -[assembly: SecurityPermission(SecurityAction.RequestMinimum)] namespace ServiceModel.Samples { // diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_supportingcredential/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_supportingcredential/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_supportingcredential/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_supportingcredential/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_supportingcredential/cs/source.cs index ac28d72bb36fa..2a0cfe105462d 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_supportingcredential/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_supportingcredential/cs/source.cs @@ -12,8 +12,6 @@ using System.IdentityModel.Selectors; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Samples { public class Test diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_tcpclient/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_tcpclient/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_tcpclient/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_tcpclient/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_tcpclient/cs/source.cs index 7005c56dac866..020aa664b6d93 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_tcpclient/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_tcpclient/cs/source.cs @@ -6,8 +6,6 @@ using System.Runtime.Serialization; using System.Security.Permissions; // -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Microsoft.Security.Samples { internal class Service { diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_unsecuredservice/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_unsecuredservice/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_unsecuredservice/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_unsecuredservice/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_unsecuredservice/cs/source.cs index e204a9aad8bc5..796d09aebe8ab 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_unsecuredservice/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_unsecuredservice/cs/source.cs @@ -3,11 +3,9 @@ using System.Collections.Generic; using System.ServiceModel; // -using System.Security.Permissions; using System.ServiceModel.Description; using System.Security.Principal; -[assembly: PermissionSet(SecurityAction.RequestMinimum)] namespace Unsecured { class Service diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_workingwithcertificates/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_workingwithcertificates/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_workingwithcertificates/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_workingwithcertificates/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_workingwithcertificates/cs/source.cs index 53526ffddce15..f248ff92d0101 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_workingwithcertificates/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_workingwithcertificates/cs/source.cs @@ -6,8 +6,6 @@ using System.ServiceModel.Description; using System.Security.Cryptography.X509Certificates; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Examples { @@ -39,4 +37,4 @@ public int Add(int a, int b) return a + b; } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_xmlserializer/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/c_xmlserializer/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_xmlserializer/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_xmlserializer/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_xmlserializer/cs/source.cs index 84abafc55b2af..60bf11f818bf8 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_xmlserializer/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/c_xmlserializer/cs/source.cs @@ -4,8 +4,6 @@ using System.Runtime.Serialization; using System.ServiceModel.Description; using System.Xml.Serialization; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace UsingXml1 { @@ -113,4 +111,4 @@ public class BankingTransaction public int amount; } // -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/datacontractattribute/cs/overview.cs b/samples/snippets/csharp/VS_Snippets_CFX/datacontractattribute/cs/overview.cs index 4d4a8c85ccd3d..dd2c764a165d9 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/datacontractattribute/cs/overview.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/datacontractattribute/cs/overview.cs @@ -3,8 +3,6 @@ using System.Runtime.Serialization; using System.Xml; using System.Security.Permissions; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] // namespace DataContractAttributeExample { @@ -216,4 +214,4 @@ public void TestClass() } } // -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/serializationguidelines/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/serializationguidelines/cs/source.cs index 8a41b8004fbe0..25c95006ec0bd 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/serializationguidelines/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/serializationguidelines/cs/source.cs @@ -215,16 +215,14 @@ public class Person_Runtime_Serializable : ISerializable string fullName; public Person_Runtime_Serializable() { } + // protected Person_Runtime_Serializable(SerializationInfo info, StreamingContext context){ // if (info == null) throw new System.ArgumentNullException("info"); fullName = (string)info.GetValue("name", typeof(string)); } - // - [SecurityPermission(SecurityAction.LinkDemand, - Flags = SecurityPermissionFlag.SerializationFormatter)] - // + // void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { diff --git a/samples/snippets/csharp/VS_Snippets_CFX/trustedsubsystems/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CFX/trustedsubsystems/cs/Project.csproj new file mode 100644 index 0000000000000..105404c5886f1 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CFX/trustedsubsystems/cs/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net48 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_CFX/trustedsubsystems/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CFX/trustedsubsystems/cs/source.cs index 58f2ff5b8ffac..9974dd353a026 100644 --- a/samples/snippets/csharp/VS_Snippets_CFX/trustedsubsystems/cs/source.cs +++ b/samples/snippets/csharp/VS_Snippets_CFX/trustedsubsystems/cs/source.cs @@ -2,12 +2,9 @@ using System.ServiceModel; using System.ServiceModel.Channels; using System.Security.Cryptography.X509Certificates; -using System.Security.Permissions; using System.ServiceModel.Description; using System.Configuration; -[assembly: SecurityPermission( - SecurityAction.RequestMinimum, Execution = true)] namespace Windows.Communication.Foundation.Samples { diff --git a/samples/snippets/csharp/VS_Snippets_CLR/DPAPI-HowTO/cs/sample.cs b/samples/snippets/csharp/VS_Snippets_CLR/DPAPI-HowTO/cs/sample.cs index aba7302fa2dcc..335f0103d116a 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/DPAPI-HowTO/cs/sample.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/DPAPI-HowTO/cs/sample.cs @@ -6,16 +6,12 @@ public class MemoryProtectionSample { - public static void Main() - { - Run(); - } + public static void Main() => Run(); public static void Run() { try { - /////////////////////////////// // // Memory Encryption - ProtectedMemory @@ -25,19 +21,19 @@ public static void Run() // Create the original data to be encrypted (The data length should be a multiple of 16). byte[] toEncrypt = UnicodeEncoding.ASCII.GetBytes("ThisIsSomeData16"); - Console.WriteLine("Original data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); + Console.WriteLine($"Original data: {UnicodeEncoding.ASCII.GetString(toEncrypt)}"); Console.WriteLine("Encrypting..."); // Encrypt the data in memory. EncryptInMemoryData(toEncrypt, MemoryProtectionScope.SameLogon); - Console.WriteLine("Encrypted data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); + Console.WriteLine($"Encrypted data: {UnicodeEncoding.ASCII.GetString(toEncrypt)}"); Console.WriteLine("Decrypting..."); // Decrypt the data in memory. DecryptInMemoryData(toEncrypt, MemoryProtectionScope.SameLogon); - Console.WriteLine("Decrypted data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); + Console.WriteLine($"Decrypted data: {UnicodeEncoding.ASCII.GetString(toEncrypt)}"); /////////////////////////////// // @@ -55,7 +51,7 @@ public static void Run() byte[] entropy = CreateRandomEntropy(); Console.WriteLine(); - Console.WriteLine("Original data: " + UnicodeEncoding.ASCII.GetString(toEncrypt)); + Console.WriteLine($"Original data: {UnicodeEncoding.ASCII.GetString(toEncrypt)}"); Console.WriteLine("Encrypting and writing to disk..."); // Encrypt a copy of the data to the stream. @@ -73,20 +69,20 @@ public static void Run() fStream.Close(); - Console.WriteLine("Decrypted data: " + UnicodeEncoding.ASCII.GetString(decryptData)); + Console.WriteLine($"Decrypted data: {UnicodeEncoding.ASCII.GetString(decryptData)}"); } catch (Exception e) { - Console.WriteLine("ERROR: " + e.Message); + Console.WriteLine($"ERROR: {e.Message}"); } } public static void EncryptInMemoryData(byte[] Buffer, MemoryProtectionScope Scope ) { if (Buffer == null) - throw new ArgumentNullException("Buffer"); + throw new ArgumentNullException(nameof(Buffer)); if (Buffer.Length <= 0) - throw new ArgumentException("Buffer"); + throw new ArgumentException("The buffer length was 0.", nameof(Buffer)); // Encrypt the data in memory. The result is stored in the same array as the original data. ProtectedMemory.Protect(Buffer, Scope); @@ -95,9 +91,9 @@ public static void EncryptInMemoryData(byte[] Buffer, MemoryProtectionScope Scop public static void DecryptInMemoryData(byte[] Buffer, MemoryProtectionScope Scope) { if (Buffer == null) - throw new ArgumentNullException("Buffer"); + throw new ArgumentNullException(nameof(Buffer)); if (Buffer.Length <= 0) - throw new ArgumentException("Buffer"); + throw new ArgumentException("The buffer length was 0.", nameof(Buffer)); // Decrypt the data in memory. The result is stored in the same array as the original data. ProtectedMemory.Unprotect(Buffer, Scope); @@ -119,15 +115,15 @@ public static byte[] CreateRandomEntropy() public static int EncryptDataToStream(byte[] Buffer, byte[] Entropy, DataProtectionScope Scope, Stream S) { if (Buffer == null) - throw new ArgumentNullException("Buffer"); + throw new ArgumentNullException(nameof(Buffer)); if (Buffer.Length <= 0) - throw new ArgumentException("Buffer"); + throw new ArgumentException("The buffer length was 0.", nameof(Buffer)); if (Entropy == null) - throw new ArgumentNullException("Entropy"); + throw new ArgumentNullException(nameof(Entropy)); if (Entropy.Length <= 0) - throw new ArgumentException("Entropy"); + throw new ArgumentException("The entropy length was 0.", nameof(Entropy)); if (S == null) - throw new ArgumentNullException("S"); + throw new ArgumentNullException(nameof(S)); int length = 0; @@ -149,13 +145,13 @@ public static int EncryptDataToStream(byte[] Buffer, byte[] Entropy, DataProtect public static byte[] DecryptDataFromStream(byte[] Entropy, DataProtectionScope Scope, Stream S, int Length) { if (S == null) - throw new ArgumentNullException("S"); + throw new ArgumentNullException(nameof(S)); if (Length <= 0 ) - throw new ArgumentException("Length"); + throw new ArgumentException("The given length was 0.", nameof(Length)); if (Entropy == null) - throw new ArgumentNullException("Entropy"); + throw new ArgumentNullException(nameof(Entropy)); if (Entropy.Length <= 0) - throw new ArgumentException("Entropy"); + throw new ArgumentException("The entropy length was 0.", nameof(Entropy)); byte[] inBuffer = new byte[Length]; byte[] outBuffer; @@ -172,7 +168,7 @@ public static byte[] DecryptDataFromStream(byte[] Entropy, DataProtectionScope S throw new IOException("Could not read the stream."); } - // Return the length that was written to the stream. + // Return the decrypted data return outBuffer; } } diff --git a/samples/snippets/csharp/VS_Snippets_CLR/DPAPI-HowTO/cs/sample.csproj b/samples/snippets/csharp/VS_Snippets_CLR/DPAPI-HowTO/cs/sample.csproj new file mode 100644 index 0000000000000..18b78dcf3f1a5 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CLR/DPAPI-HowTO/cs/sample.csproj @@ -0,0 +1,12 @@ + + + + Exe + net461 + + + + + + + \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/Custom1.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/Custom1.cs index 8fc81a40c77ab..adceebb8e6a1b 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/Custom1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/Custom1.cs @@ -274,7 +274,8 @@ private static void Show_zSpecifier() DateTime date1 = DateTime.UtcNow; Console.WriteLine(String.Format("{0:%z}, {0:zz}, {0:zzz}", date1)); - // Displays -7, -07, -07:00 + // Displays -7, -07, -07:00 on .NET Framework + // Displays +0, +00, +00:00 on .NET Core and .NET 5+ DateTimeOffset date2 = new DateTimeOffset(2008, 8, 1, 0, 0, 0, new TimeSpan(6, 0, 0)); diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx1.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx1.cs index 0c3ba8578c0ba..dd45ac5c97ec7 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx1.cs @@ -2,25 +2,25 @@ using System; using System.Globalization; -public class Example +public class Example5 { - public static void Main() - { - String[] formats = { "dd MMM yyyy hh:mm tt PST", + public static void Main() + { + String[] formats = { "dd MMM yyyy hh:mm tt PST", "dd MMM yyyy hh:mm tt PDT" }; - var dat = new DateTime(2016, 8, 18, 16, 50, 0); - // Display the result string. - Console.WriteLine(dat.ToString(formats[1])); + var dat = new DateTime(2016, 8, 18, 16, 50, 0); + // Display the result string. + Console.WriteLine(dat.ToString(formats[1])); - // Parse a string. - String value = "25 Dec 2016 12:00 pm PST"; - DateTime newDate; - if (DateTime.TryParseExact(value, formats, null, - DateTimeStyles.None, out newDate)) - Console.WriteLine(newDate); - else - Console.WriteLine("Unable to parse '{0}'", value); - } + // Parse a string. + String value = "25 Dec 2016 12:00 pm PST"; + DateTime newDate; + if (DateTime.TryParseExact(value, formats, null, + DateTimeStyles.None, out newDate)) + Console.WriteLine(newDate); + else + Console.WriteLine("Unable to parse '{0}'", value); + } } // The example displays the following output: // 18 Aug 2016 04:50 PM PDT diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx2.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx2.cs index 23e74138046a0..d0dc9ff9fa0b5 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx2.cs @@ -2,24 +2,24 @@ using System; using System.Globalization; -public class Example +public class Example3 { - public static void Main() - { - String format = "dd MMM yyyy hh:mm tt p\\s\\t"; - var dat = new DateTime(2016, 8, 18, 16, 50, 0); - // Display the result string. - Console.WriteLine(dat.ToString(format)); + public static void Main() + { + String format = "dd MMM yyyy hh:mm tt p\\s\\t"; + var dat = new DateTime(2016, 8, 18, 16, 50, 0); + // Display the result string. + Console.WriteLine(dat.ToString(format)); - // Parse a string. - String value = "25 Dec 2016 12:00 pm pst"; - DateTime newDate; - if (DateTime.TryParseExact(value, format, null, - DateTimeStyles.None, out newDate)) - Console.WriteLine(newDate); - else - Console.WriteLine("Unable to parse '{0}'", value); - } + // Parse a string. + String value = "25 Dec 2016 12:00 pm pst"; + DateTime newDate; + if (DateTime.TryParseExact(value, format, null, + DateTimeStyles.None, out newDate)) + Console.WriteLine(newDate); + else + Console.WriteLine("Unable to parse '{0}'", value); + } } // The example displays the following output: // 18 Aug 2016 04:50 PM pst diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx3.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx3.cs index 900dc5159a4ca..63a30dead224e 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx3.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/LiteralsEx3.cs @@ -2,24 +2,24 @@ using System; using System.Globalization; -public class Example +public class Example6 { - public static void Main() - { - String format = "dd MMM yyyy hh:mm tt \"pst\""; - var dat = new DateTime(2016, 8, 18, 16, 50, 0); - // Display the result string. - Console.WriteLine(dat.ToString(format)); + public static void Main() + { + String format = "dd MMM yyyy hh:mm tt \"pst\""; + var dat = new DateTime(2016, 8, 18, 16, 50, 0); + // Display the result string. + Console.WriteLine(dat.ToString(format)); - // Parse a string. - String value = "25 Dec 2016 12:00 pm pst"; - DateTime newDate; - if (DateTime.TryParseExact(value, format, null, - DateTimeStyles.None, out newDate)) - Console.WriteLine(newDate); - else - Console.WriteLine("Unable to parse '{0}'", value); - } + // Parse a string. + String value = "25 Dec 2016 12:00 pm pst"; + DateTime newDate; + if (DateTime.TryParseExact(value, format, null, + DateTimeStyles.None, out newDate)) + Console.WriteLine(newDate); + else + Console.WriteLine("Unable to parse '{0}'", value); + } } // The example displays the following output: // 18 Aug 2016 04:50 PM pst diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/Project.csproj new file mode 100644 index 0000000000000..c258ea5606282 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/Project.csproj @@ -0,0 +1,6 @@ + + + Library + net6.0 + + diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/custandparsing1.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/custandparsing1.cs index 8faaa75e8903e..54150f69bd798 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/custandparsing1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/custandparsing1.cs @@ -2,25 +2,26 @@ using System; using System.Globalization; -public class Example +public class Example1 { - public static void Main() - { - string[] dateValues = { "30-12-2011", "12-30-2011", + public static void Main() + { + string[] dateValues = { "30-12-2011", "12-30-2011", "30-12-11", "12-30-11" }; - string pattern = "MM-dd-yy"; - DateTime parsedDate; + string pattern = "MM-dd-yy"; + DateTime parsedDate; - foreach (var dateValue in dateValues) { - if (DateTime.TryParseExact(dateValue, pattern, null, - DateTimeStyles.None, out parsedDate)) - Console.WriteLine("Converted '{0}' to {1:d}.", - dateValue, parsedDate); - else - Console.WriteLine("Unable to convert '{0}' to a date and time.", - dateValue); - } - } + foreach (var dateValue in dateValues) + { + if (DateTime.TryParseExact(dateValue, pattern, null, + DateTimeStyles.None, out parsedDate)) + Console.WriteLine("Converted '{0}' to {1:d}.", + dateValue, parsedDate); + else + Console.WriteLine("Unable to convert '{0}' to a date and time.", + dateValue); + } + } } // The example displays the following output: // Unable to convert '30-12-2011' to a date and time. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/escape1.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/escape1.cs index 08829575fd26d..6dde1fe51a3ef 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/escape1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/escape1.cs @@ -1,19 +1,19 @@ using System; -public class Example +public class Example4 { - public static void Main() - { - // - DateTime date = new DateTime(2009, 06, 15, 13, 45, 30, 90); - string fmt1 = "h \\h m \\m"; - string fmt2 = @"h \h m \m"; + public static void Main() + { + // + DateTime date = new DateTime(2009, 06, 15, 13, 45, 30, 90); + string fmt1 = "h \\h m \\m"; + string fmt2 = @"h \h m \m"; - Console.WriteLine("{0} ({1}) -> {2}", date, fmt1, date.ToString(fmt1)); - Console.WriteLine("{0} ({1}) -> {2}", date, fmt2, date.ToString(fmt2)); - // The example displays the following output: - // 6/15/2009 1:45:30 PM (h \h m \m) -> 1 h 45 m - // 6/15/2009 1:45:30 PM (h \h m \m) -> 1 h 45 m - // - } + Console.WriteLine("{0} ({1}) -> {2}", date, fmt1, date.ToString(fmt1)); + Console.WriteLine("{0} ({1}) -> {2}", date, fmt2, date.ToString(fmt2)); + // The example displays the following output: + // 6/15/2009 1:45:30 PM (h \h m \m) -> 1 h 45 m + // 6/15/2009 1:45:30 PM (h \h m \m) -> 1 h 45 m + // + } } diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/literal1.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/literal1.cs index 9c8382ca27c80..52ab46fe4ce95 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/literal1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/literal1.cs @@ -1,19 +1,19 @@ using System; -public class Example +public class Example2 { - public static void Main() - { - // - DateTime dat1 = new DateTime(2009, 6, 15, 13, 45, 0); + public static void Main() + { + // + DateTime dat1 = new DateTime(2009, 6, 15, 13, 45, 0); - Console.WriteLine("'{0:%h}'", dat1); - Console.WriteLine("'{0: h}'", dat1); - Console.WriteLine("'{0:h }'", dat1); - // The example displays the following output: - // '1' - // ' 1' - // '1 ' - // - } + Console.WriteLine("'{0:%h}'", dat1); + Console.WriteLine("'{0: h}'", dat1); + Console.WriteLine("'{0:h }'", dat1); + // The example displays the following output: + // '1' + // ' 1' + // '1 ' + // + } } diff --git a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/parseexact2digityear1.cs b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/parseexact2digityear1.cs index 82f135d126f83..7dbe00dc5c86d 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/parseexact2digityear1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/Formatting.DateAndTime.Custom/cs/parseexact2digityear1.cs @@ -3,29 +3,29 @@ using System.Globalization; using System.Threading; -public class Example +public class Example7 { - public static void Main() - { - string fmt = "dd-MMM-yy"; - string value = "24-Jan-49"; + public static void Main() + { + string fmt = "dd-MMM-yy"; + string value = "24-Jan-49"; - Calendar cal = (Calendar) CultureInfo.CurrentCulture.Calendar.Clone(); - Console.WriteLine("Two Digit Year Range: {0} - {1}", - cal.TwoDigitYearMax - 99, cal.TwoDigitYearMax); + Calendar cal = (Calendar)CultureInfo.CurrentCulture.Calendar.Clone(); + Console.WriteLine("Two Digit Year Range: {0} - {1}", + cal.TwoDigitYearMax - 99, cal.TwoDigitYearMax); - Console.WriteLine("{0:d}", DateTime.ParseExact(value, fmt, null)); - Console.WriteLine(); + Console.WriteLine("{0:d}", DateTime.ParseExact(value, fmt, null)); + Console.WriteLine(); - cal.TwoDigitYearMax = 2099; - CultureInfo culture = (CultureInfo) CultureInfo.CurrentCulture.Clone(); - culture.DateTimeFormat.Calendar = cal; - Thread.CurrentThread.CurrentCulture = culture; + cal.TwoDigitYearMax = 2099; + CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); + culture.DateTimeFormat.Calendar = cal; + Thread.CurrentThread.CurrentCulture = culture; - Console.WriteLine("Two Digit Year Range: {0} - {1}", - cal.TwoDigitYearMax - 99, cal.TwoDigitYearMax); - Console.WriteLine("{0:d}", DateTime.ParseExact(value, fmt, null)); - } + Console.WriteLine("Two Digit Year Range: {0} - {1}", + cal.TwoDigitYearMax - 99, cal.TwoDigitYearMax); + Console.WriteLine("{0:d}", DateTime.ParseExact(value, fmt, null)); + } } // The example displays the following output: // Two Digit Year Range: 1930 - 2029 diff --git a/samples/snippets/csharp/VS_Snippets_CLR/HowToGeneric/CS/Project.csproj b/samples/snippets/csharp/VS_Snippets_CLR/HowToGeneric/CS/Project.csproj new file mode 100644 index 0000000000000..706cd0177f4ad --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CLR/HowToGeneric/CS/Project.csproj @@ -0,0 +1,8 @@ + + + + Library + net4.8 + + + diff --git a/samples/snippets/csharp/VS_Snippets_CLR/HowToGeneric/CS/ur.cs b/samples/snippets/csharp/VS_Snippets_CLR/HowToGeneric/CS/ur.cs index 545113dcbdacb..29a8a1a7cd67f 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/HowToGeneric/CS/ur.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/HowToGeneric/CS/ur.cs @@ -3,7 +3,6 @@ using System; using System.Reflection; using System.Collections.Generic; -using System.Security.Permissions; // Define an example interface. public interface ITestArgument {} @@ -126,7 +125,6 @@ private static void DisplayGenericParameter(Type tp) // } - [PermissionSetAttribute(SecurityAction.Demand, Name="FullTrust")] public static void Main() { // Two ways to get a Type object that represents the generic diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/Project.csproj new file mode 100644 index 0000000000000..b83f0211b39c5 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/Project.csproj @@ -0,0 +1,7 @@ + + + + Library + net6.0 + + diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/case2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/case2.cs index 733cf3056af1f..fe66d36484f8c 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/case2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/case2.cs @@ -2,21 +2,21 @@ using System; using System.Text.RegularExpressions; -public class Example +public class CaseExample { - public static void Main() - { - string pattern = @"\b(?i:t)he\w*\b"; - string input = "The man then told them about that event."; - foreach (Match match in Regex.Matches(input, pattern)) - Console.WriteLine("Found {0} at index {1}.", match.Value, match.Index); + public static void Main() + { + string pattern = @"\b(?i:t)he\w*\b"; + string input = "The man then told them about that event."; + foreach (Match match in Regex.Matches(input, pattern)) + Console.WriteLine("Found {0} at index {1}.", match.Value, match.Index); - Console.WriteLine(); - pattern = @"(?i)\bthe\w*\b"; - foreach (Match match in Regex.Matches(input, pattern, - RegexOptions.IgnoreCase)) - Console.WriteLine("Found {0} at index {1}.", match.Value, match.Index); - } + Console.WriteLine(); + pattern = @"(?i)\bthe\w*\b"; + foreach (Match match in Regex.Matches(input, pattern, + RegexOptions.IgnoreCase)) + Console.WriteLine("Found {0} at index {1}.", match.Value, match.Index); + } } // The example displays the following output: // Found The at index 0. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/culture1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/culture1.cs index ff3b5647eb04e..0c43cd1420cf6 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/culture1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/culture1.cs @@ -3,58 +3,58 @@ using System.Text.RegularExpressions; using System.Threading; -public class Example +public class CultureExample { - public static void Main() - { - ShowIllegalAccess(); - Console.WriteLine("-----"); - ShowNoAccess(); - } - - private static void ShowIllegalAccess() - { - // - CultureInfo defaultCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); - - string input = "file://c:/Documents.MyReport.doc"; - string pattern = "FILE://"; - - Console.WriteLine("Culture-sensitive matching ({0} culture)...", - Thread.CurrentThread.CurrentCulture.Name); - if (Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase)) - Console.WriteLine("URLs that access files are not allowed."); - else - Console.WriteLine("Access to {0} is allowed.", input); - - Thread.CurrentThread.CurrentCulture = defaultCulture; - // The example displays the following output: - // Culture-sensitive matching (tr-TR culture)... - // Access to file://c:/Documents.MyReport.doc is allowed. - // - } - - private static void ShowNoAccess() - { - // - CultureInfo defaultCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); - - string input = "file://c:/Documents.MyReport.doc"; - string pattern = "FILE://"; - - Console.WriteLine("Culture-insensitive matching..."); - if (Regex.IsMatch(input, pattern, - RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) - Console.WriteLine("URLs that access files are not allowed."); - else - Console.WriteLine("Access to {0} is allowed.", input); - - Thread.CurrentThread.CurrentCulture = defaultCulture; - // The example displays the following output: - // Culture-insensitive matching... - // URLs that access files are not allowed. - // - } + public static void Main() + { + ShowIllegalAccess(); + Console.WriteLine("-----"); + ShowNoAccess(); + } + + private static void ShowIllegalAccess() + { + // + CultureInfo defaultCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); + + string input = "file://c:/Documents.MyReport.doc"; + string pattern = "FILE://"; + + Console.WriteLine("Culture-sensitive matching ({0} culture)...", + Thread.CurrentThread.CurrentCulture.Name); + if (Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase)) + Console.WriteLine("URLs that access files are not allowed."); + else + Console.WriteLine("Access to {0} is allowed.", input); + + Thread.CurrentThread.CurrentCulture = defaultCulture; + // The example displays the following output: + // Culture-sensitive matching (tr-TR culture)... + // Access to file://c:/Documents.MyReport.doc is allowed. + // + } + + private static void ShowNoAccess() + { + // + CultureInfo defaultCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); + + string input = "file://c:/Documents.MyReport.doc"; + string pattern = "FILE://"; + + Console.WriteLine("Culture-insensitive matching..."); + if (Regex.IsMatch(input, pattern, + RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) + Console.WriteLine("URLs that access files are not allowed."); + else + Console.WriteLine("Access to {0} is allowed.", input); + + Thread.CurrentThread.CurrentCulture = defaultCulture; + // The example displays the following output: + // Culture-insensitive matching... + // URLs that access files are not allowed. + // + } } diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/determine1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/determine1.cs index 3d20026197c43..0c2e3f011ba26 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/determine1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/determine1.cs @@ -1,20 +1,20 @@ using System; using System.Text.RegularExpressions; -public class Example +public class DetermineOptionsExample { - public static void Main() - { - Regex rgx = new Regex(@"\w*\s", RegexOptions.IgnoreCase); - // - if ((rgx.Options & RegexOptions.IgnoreCase) == RegexOptions.IgnoreCase) - Console.WriteLine("Case-insensitive pattern comparison."); - else - Console.WriteLine("Case-sensitive pattern comparison."); - // - // - if (rgx.Options == RegexOptions.None) - Console.WriteLine("No options have been set."); - // - } + public static void Main() + { + Regex rgx = new Regex(@"\w*\s", RegexOptions.IgnoreCase); + // + if ((rgx.Options & RegexOptions.IgnoreCase) == RegexOptions.IgnoreCase) + Console.WriteLine("Case-insensitive pattern comparison."); + else + Console.WriteLine("Case-sensitive pattern comparison."); + // + // + if (rgx.Options == RegexOptions.None) + Console.WriteLine("No options have been set."); + // + } } diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript1.cs index fe1b472b7ba5e..72f5e30ef0be9 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript1.cs @@ -2,28 +2,28 @@ using System; using System.Text.RegularExpressions; -public class Example +public class EcmaScriptExample { - public static void Main() - { - string[] values = { "целый мир", "the whole world" }; - string pattern = @"\b(\w+\s*)+"; - foreach (var value in values) - { - Console.Write("Canonical matching: "); - if (Regex.IsMatch(value, pattern)) - Console.WriteLine("'{0}' matches the pattern.", value); - else - Console.WriteLine("{0} does not match the pattern.", value); + public static void Main() + { + string[] values = { "целый мир", "the whole world" }; + string pattern = @"\b(\w+\s*)+"; + foreach (var value in values) + { + Console.Write("Canonical matching: "); + if (Regex.IsMatch(value, pattern)) + Console.WriteLine("'{0}' matches the pattern.", value); + else + Console.WriteLine("{0} does not match the pattern.", value); - Console.Write("ECMAScript matching: "); - if (Regex.IsMatch(value, pattern, RegexOptions.ECMAScript)) - Console.WriteLine("'{0}' matches the pattern.", value); - else - Console.WriteLine("{0} does not match the pattern.", value); - Console.WriteLine(); - } - } + Console.Write("ECMAScript matching: "); + if (Regex.IsMatch(value, pattern, RegexOptions.ECMAScript)) + Console.WriteLine("'{0}' matches the pattern.", value); + else + Console.WriteLine("{0} does not match the pattern.", value); + Console.WriteLine(); + } + } } // The example displays the following output: // Canonical matching: 'целый мир' matches the pattern. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript2.cs index 659e8bf41de7b..7677606014692 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/ecmascript2.cs @@ -2,47 +2,47 @@ using System; using System.Text.RegularExpressions; -public class Example +public class EcmaScript2Example { - static string pattern; + static string pattern; - public static void Main() - { - string input = "aa aaaa aaaaaa "; - pattern = @"((a+)(\1) ?)+"; + public static void Main() + { + string input = "aa aaaa aaaaaa "; + pattern = @"((a+)(\1) ?)+"; - // Match input using canonical matching. - AnalyzeMatch(Regex.Match(input, pattern)); + // Match input using canonical matching. + AnalyzeMatch(Regex.Match(input, pattern)); - // Match input using ECMAScript. - AnalyzeMatch(Regex.Match(input, pattern, RegexOptions.ECMAScript)); - } + // Match input using ECMAScript. + AnalyzeMatch(Regex.Match(input, pattern, RegexOptions.ECMAScript)); + } - private static void AnalyzeMatch(Match m) - { - if (m.Success) - { - Console.WriteLine("'{0}' matches {1} at position {2}.", - pattern, m.Value, m.Index); - int grpCtr = 0; - foreach (Group grp in m.Groups) - { - Console.WriteLine(" {0}: '{1}'", grpCtr, grp.Value); - grpCtr++; - int capCtr = 0; - foreach (Capture cap in grp.Captures) + private static void AnalyzeMatch(Match m) + { + if (m.Success) + { + Console.WriteLine("'{0}' matches {1} at position {2}.", + pattern, m.Value, m.Index); + int grpCtr = 0; + foreach (Group grp in m.Groups) { - Console.WriteLine(" {0}: '{1}'", capCtr, cap.Value); - capCtr++; + Console.WriteLine(" {0}: '{1}'", grpCtr, grp.Value); + grpCtr++; + int capCtr = 0; + foreach (Capture cap in grp.Captures) + { + Console.WriteLine(" {0}: '{1}'", capCtr, cap.Value); + capCtr++; + } } - } - } - else - { - Console.WriteLine("No match found."); - } - Console.WriteLine(); - } + } + else + { + Console.WriteLine("No match found."); + } + Console.WriteLine(); + } } // The example displays the following output: // No match found. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/example1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/example1.cs index 0c8ffaeb07210..b77ea3508478f 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/example1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/example1.cs @@ -1,57 +1,57 @@ using System; using System.Text.RegularExpressions; -public class Example +public class ShowOptionsExamples { - public static void Main() - { - ShowOptionsArgument(); - Console.WriteLine("-----"); - ShowInlineOptions(); - Console.WriteLine("-----"); - ShowGroupOptions(); - } + public static void Main() + { + ShowOptionsArgument(); + Console.WriteLine("-----"); + ShowInlineOptions(); + Console.WriteLine("-----"); + ShowGroupOptions(); + } - private static void ShowOptionsArgument() - { - // - string pattern = @"d \w+ \s"; - string input = "Dogs are decidedly good pets."; - RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace; + private static void ShowOptionsArgument() + { + // + string pattern = @"d \w+ \s"; + string input = "Dogs are decidedly good pets."; + RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace; - foreach (Match match in Regex.Matches(input, pattern, options)) - Console.WriteLine("'{0}// found at index {1}.", match.Value, match.Index); - // The example displays the following output: - // 'Dogs // found at index 0. - // 'decidedly // found at index 9. - // - } + foreach (Match match in Regex.Matches(input, pattern, options)) + Console.WriteLine("'{0}// found at index {1}.", match.Value, match.Index); + // The example displays the following output: + // 'Dogs // found at index 0. + // 'decidedly // found at index 9. + // + } - private static void ShowInlineOptions() - { - // - string pattern = @"(?ix) d \w+ \s"; - string input = "Dogs are decidedly good pets."; + private static void ShowInlineOptions() + { + // + string pattern = @"(?ix) d \w+ \s"; + string input = "Dogs are decidedly good pets."; - foreach (Match match in Regex.Matches(input, pattern)) - Console.WriteLine("'{0}// found at index {1}.", match.Value, match.Index); - // The example displays the following output: - // 'Dogs // found at index 0. - // 'decidedly // found at index 9. - // - } + foreach (Match match in Regex.Matches(input, pattern)) + Console.WriteLine("'{0}// found at index {1}.", match.Value, match.Index); + // The example displays the following output: + // 'Dogs // found at index 0. + // 'decidedly // found at index 9. + // + } - private static void ShowGroupOptions() - { - // - string pattern = @"\b(?ix: d \w+)\s"; - string input = "Dogs are decidedly good pets."; + private static void ShowGroupOptions() + { + // + string pattern = @"\b(?ix: d \w+)\s"; + string input = "Dogs are decidedly good pets."; - foreach (Match match in Regex.Matches(input, pattern)) - Console.WriteLine("'{0}// found at index {1}.", match.Value, match.Index); - // The example displays the following output: - // 'Dogs // found at index 0. - // 'decidedly // found at index 9. - // - } + foreach (Match match in Regex.Matches(input, pattern)) + Console.WriteLine("'{0}// found at index {1}.", match.Value, match.Index); + // The example displays the following output: + // 'Dogs // found at index 0. + // 'decidedly // found at index 9. + // + } } diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit1.cs index 06e0b3702aa5c..867eafa25126e 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit1.cs @@ -2,50 +2,50 @@ using System; using System.Text.RegularExpressions; -public class Example +public class Explicit1Example { - public static void Main() - { - string input = "This is the first sentence. Is it the beginning " + - "of a literary masterpiece? I think not. Instead, " + - "it is a nonsensical paragraph."; - string pattern = @"\b\(?((?>\w+),?\s?)+[\.!?]\)?"; - Console.WriteLine("With implicit captures:"); - foreach (Match match in Regex.Matches(input, pattern)) - { - Console.WriteLine("The match: {0}", match.Value); - int groupCtr = 0; - foreach (Group group in match.Groups) - { - Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); - groupCtr++; - int captureCtr = 0; - foreach (Capture capture in group.Captures) + public static void Main() + { + string input = "This is the first sentence. Is it the beginning " + + "of a literary masterpiece? I think not. Instead, " + + "it is a nonsensical paragraph."; + string pattern = @"\b\(?((?>\w+),?\s?)+[\.!?]\)?"; + Console.WriteLine("With implicit captures:"); + foreach (Match match in Regex.Matches(input, pattern)) + { + Console.WriteLine("The match: {0}", match.Value); + int groupCtr = 0; + foreach (Group group in match.Groups) { - Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); - captureCtr++; + Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); + groupCtr++; + int captureCtr = 0; + foreach (Capture capture in group.Captures) + { + Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); + captureCtr++; + } } - } - } - Console.WriteLine(); - Console.WriteLine("With explicit captures only:"); - foreach (Match match in Regex.Matches(input, pattern, RegexOptions.ExplicitCapture)) - { - Console.WriteLine("The match: {0}", match.Value); - int groupCtr = 0; - foreach (Group group in match.Groups) - { - Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); - groupCtr++; - int captureCtr = 0; - foreach (Capture capture in group.Captures) + } + Console.WriteLine(); + Console.WriteLine("With explicit captures only:"); + foreach (Match match in Regex.Matches(input, pattern, RegexOptions.ExplicitCapture)) + { + Console.WriteLine("The match: {0}", match.Value); + int groupCtr = 0; + foreach (Group group in match.Groups) { - Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); - captureCtr++; + Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); + groupCtr++; + int captureCtr = 0; + foreach (Capture capture in group.Captures) + { + Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); + captureCtr++; + } } - } - } - } + } + } } // The example displays the following output: // With implicit captures: diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit2.cs index 101b2896ed23e..84b80b26a1f6a 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit2.cs @@ -2,32 +2,32 @@ using System; using System.Text.RegularExpressions; -public class Example +public class Explicit2Example { - public static void Main() - { - string input = "This is the first sentence. Is it the beginning " + - "of a literary masterpiece? I think not. Instead, " + - "it is a nonsensical paragraph."; - string pattern = @"(?n)\b\(?((?>\w+),?\s?)+[\.!?]\)?"; + public static void Main() + { + string input = "This is the first sentence. Is it the beginning " + + "of a literary masterpiece? I think not. Instead, " + + "it is a nonsensical paragraph."; + string pattern = @"(?n)\b\(?((?>\w+),?\s?)+[\.!?]\)?"; - foreach (Match match in Regex.Matches(input, pattern)) - { - Console.WriteLine("The match: {0}", match.Value); - int groupCtr = 0; - foreach (Group group in match.Groups) - { - Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); - groupCtr++; - int captureCtr = 0; - foreach (Capture capture in group.Captures) + foreach (Match match in Regex.Matches(input, pattern)) + { + Console.WriteLine("The match: {0}", match.Value); + int groupCtr = 0; + foreach (Group group in match.Groups) { - Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); - captureCtr++; + Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); + groupCtr++; + int captureCtr = 0; + foreach (Capture capture in group.Captures) + { + Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); + captureCtr++; + } } - } - } - } + } + } } // The example displays the following output: // The match: This is the first sentence. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit3.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit3.cs index a366e5007e671..1290ee0d555d9 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit3.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/explicit3.cs @@ -2,32 +2,32 @@ using System; using System.Text.RegularExpressions; -public class Example +public class Explicit3Example { - public static void Main() - { - string input = "This is the first sentence. Is it the beginning " + - "of a literary masterpiece? I think not. Instead, " + - "it is a nonsensical paragraph."; - string pattern = @"\b\(?(?n:(?>\w+),?\s?)+[\.!?]\)?"; + public static void Main() + { + string input = "This is the first sentence. Is it the beginning " + + "of a literary masterpiece? I think not. Instead, " + + "it is a nonsensical paragraph."; + string pattern = @"\b\(?(?n:(?>\w+),?\s?)+[\.!?]\)?"; - foreach (Match match in Regex.Matches(input, pattern)) - { - Console.WriteLine("The match: {0}", match.Value); - int groupCtr = 0; - foreach (Group group in match.Groups) - { - Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); - groupCtr++; - int captureCtr = 0; - foreach (Capture capture in group.Captures) + foreach (Match match in Regex.Matches(input, pattern)) + { + Console.WriteLine("The match: {0}", match.Value); + int groupCtr = 0; + foreach (Group group in match.Groups) { - Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); - captureCtr++; + Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); + groupCtr++; + int captureCtr = 0; + foreach (Capture capture in group.Captures) + { + Console.WriteLine(" Capture {0}: {1}", captureCtr, capture.Value); + captureCtr++; + } } - } - } - } + } + } } // The example displays the following output: // The match: This is the first sentence. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline1.cs index 55e756f49e063..28a1fd6614eb8 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline1.cs @@ -3,47 +3,47 @@ using System.Collections.Generic; using System.Text.RegularExpressions; -public class Example +public class Multiline1Example { - public static void Main() - { - SortedList scores = new SortedList(new DescendingComparer()); + public static void Main() + { + SortedList scores = new SortedList(new DescendingComparer1()); - string input = "Joe 164\n" + - "Sam 208\n" + - "Allison 211\n" + - "Gwen 171\n"; - string pattern = @"^(\w+)\s(\d+)$"; - bool matched = false; + string input = "Joe 164\n" + + "Sam 208\n" + + "Allison 211\n" + + "Gwen 171\n"; + string pattern = @"^(\w+)\s(\d+)$"; + bool matched = false; - Console.WriteLine("Without Multiline option:"); - foreach (Match match in Regex.Matches(input, pattern)) - { - scores.Add(Int32.Parse(match.Groups[2].Value), (string) match.Groups[1].Value); - matched = true; - } - if (! matched) - Console.WriteLine(" No matches."); - Console.WriteLine(); + Console.WriteLine("Without Multiline option:"); + foreach (Match match in Regex.Matches(input, pattern)) + { + scores.Add(Int32.Parse(match.Groups[2].Value), (string)match.Groups[1].Value); + matched = true; + } + if (!matched) + Console.WriteLine(" No matches."); + Console.WriteLine(); - // Redefine pattern to handle multiple lines. - pattern = @"^(\w+)\s(\d+)\r*$"; - Console.WriteLine("With multiline option:"); - foreach (Match match in Regex.Matches(input, pattern, RegexOptions.Multiline)) - scores.Add(Int32.Parse(match.Groups[2].Value), (string) match.Groups[1].Value); + // Redefine pattern to handle multiple lines. + pattern = @"^(\w+)\s(\d+)\r*$"; + Console.WriteLine("With multiline option:"); + foreach (Match match in Regex.Matches(input, pattern, RegexOptions.Multiline)) + scores.Add(Int32.Parse(match.Groups[2].Value), (string)match.Groups[1].Value); - // List scores in descending order. - foreach (KeyValuePair score in scores) - Console.WriteLine("{0}: {1}", score.Value, score.Key); - } + // List scores in descending order. + foreach (KeyValuePair score in scores) + Console.WriteLine("{0}: {1}", score.Value, score.Key); + } } -public class DescendingComparer : IComparer +public class DescendingComparer1 : IComparer { - public int Compare(T x, T y) - { - return Comparer.Default.Compare(x, y) * -1; - } + public int Compare(T x, T y) + { + return Comparer.Default.Compare(x, y) * -1; + } } // The example displays the following output: // Without Multiline option: diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline2.cs index a12f9fa8d27cd..3c929c0483e9a 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/multiline2.cs @@ -3,33 +3,33 @@ using System.Collections.Generic; using System.Text.RegularExpressions; -public class Example +public class Multiline2Example { - public static void Main() - { - SortedList scores = new SortedList(new DescendingComparer()); + public static void Main() + { + SortedList scores = new SortedList(new DescendingComparer()); - string input = "Joe 164\n" + - "Sam 208\n" + - "Allison 211\n" + - "Gwen 171\n"; - string pattern = @"(?m)^(\w+)\s(\d+)\r*$"; + string input = "Joe 164\n" + + "Sam 208\n" + + "Allison 211\n" + + "Gwen 171\n"; + string pattern = @"(?m)^(\w+)\s(\d+)\r*$"; - foreach (Match match in Regex.Matches(input, pattern, RegexOptions.Multiline)) - scores.Add(Convert.ToInt32(match.Groups[2].Value), match.Groups[1].Value); + foreach (Match match in Regex.Matches(input, pattern, RegexOptions.Multiline)) + scores.Add(Convert.ToInt32(match.Groups[2].Value), match.Groups[1].Value); - // List scores in descending order. - foreach (KeyValuePair score in scores) - Console.WriteLine("{0}: {1}", score.Value, score.Key); - } + // List scores in descending order. + foreach (KeyValuePair score in scores) + Console.WriteLine("{0}: {1}", score.Value, score.Key); + } } public class DescendingComparer : IComparer { - public int Compare(T x, T y) - { - return Comparer.Default.Compare(x, y) * -1; - } + public int Compare(T x, T y) + { + return Comparer.Default.Compare(x, y) * -1; + } } // The example displays the following output: // Allison: 211 diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft1.cs index 45f5129b3070a..b297aafa9476e 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft1.cs @@ -2,16 +2,17 @@ using System; using System.Text.RegularExpressions; -public class Example +public class RTL1Example { - public static void Main() - { - string pattern = @"\bb\w+\s"; - string input = "builder rob rabble"; - foreach (Match match in Regex.Matches(input, pattern, RegexOptions.RightToLeft)) - Console.WriteLine("'{0}' found at position {1}.", match.Value, match.Index); - } + public static void Main() + { + string pattern = @"\bb\w+\s"; + string input = "build band tab"; + foreach (Match match in Regex.Matches(input, pattern, RegexOptions.RightToLeft)) + Console.WriteLine("'{0}' found at position {1}.", match.Value, match.Index); + } } // The example displays the following output: -// 'builder ' found at position 0. +// 'band ' found at position 6. +// 'build ' found at position 0. // diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft2.cs index af91ec60fa888..961ef6e223e0f 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/righttoleft2.cs @@ -2,24 +2,25 @@ using System; using System.Text.RegularExpressions; -public class Example +public class RTL2Example { - public static void Main() - { - string[] inputs = { "1 May 1917", "June 16, 2003" }; - string pattern = @"(?<=\d{1,2}\s)\w+,?\s\d{4}"; + public static void Main() + { + string[] inputs = { "1 May, 1917", "June 16, 2003" }; + string pattern = @"(?<=\d{1,2}\s)\w+,\s\d{4}"; - foreach (string input in inputs) - { - Match match = Regex.Match(input, pattern, RegexOptions.RightToLeft); - if (match.Success) - Console.WriteLine("The date occurs in {0}.", match.Value); - else - Console.WriteLine("{0} does not match.", input); - } - } + foreach (string input in inputs) + { + Match match = Regex.Match(input, pattern, RegexOptions.RightToLeft); + if (match.Success) + Console.WriteLine("The date occurs in {0}.", match.Value); + else + Console.WriteLine("{0} does not match.", input); + } + } } + // The example displays the following output: -// The date occurs in May 1917. +// The date occurs in May, 1917. // June 16, 2003 does not match. // diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/singleline1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/singleline1.cs index fe64c4ba7ebf1..7f1959067fe82 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/singleline1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/singleline1.cs @@ -2,16 +2,16 @@ using System; using System.Text.RegularExpressions; -public class Example +public class SingleLineExample { - public static void Main() - { - string pattern = "(?s)^.+"; - string input = "This is one line and" + Environment.NewLine + "this is the second."; + public static void Main() + { + string pattern = "(?s)^.+"; + string input = "This is one line and" + Environment.NewLine + "this is the second."; - foreach (Match match in Regex.Matches(input, pattern)) - Console.WriteLine(Regex.Escape(match.Value)); - } + foreach (Match match in Regex.Matches(input, pattern)) + Console.WriteLine(Regex.Escape(match.Value)); + } } // The example displays the following output: // This\ is\ one\ line\ and\r\nthis\ is\ the\ second\. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace1.cs index df71f9ae33b71..8babd516a4689 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace1.cs @@ -2,18 +2,18 @@ using System; using System.Text.RegularExpressions; -public class Example +public class Whitespace1Example { - public static void Main() - { - string input = "This is the first sentence. Is it the beginning " + - "of a literary masterpiece? I think not. Instead, " + - "it is a nonsensical paragraph."; - string pattern = @"\b \(? ( (?>\w+) ,?\s? )+ [\.!?] \)? # Matches an entire sentence."; + public static void Main() + { + string input = "This is the first sentence. Is it the beginning " + + "of a literary masterpiece? I think not. Instead, " + + "it is a nonsensical paragraph."; + string pattern = @"\b \(? ( (?>\w+) ,?\s? )+ [\.!?] \)? # Matches an entire sentence."; - foreach (Match match in Regex.Matches(input, pattern, RegexOptions.IgnorePatternWhitespace)) - Console.WriteLine(match.Value); - } + foreach (Match match in Regex.Matches(input, pattern, RegexOptions.IgnorePatternWhitespace)) + Console.WriteLine(match.Value); + } } // The example displays the following output: // This is the first sentence. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace2.cs index ed887b1b9f812..754365c12846c 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.regex.language.options/cs/whitespace2.cs @@ -2,18 +2,18 @@ using System; using System.Text.RegularExpressions; -public class Example +public class Whitespace2Example { - public static void Main() - { - string input = "This is the first sentence. Is it the beginning " + - "of a literary masterpiece? I think not. Instead, " + - "it is a nonsensical paragraph."; - string pattern = @"(?x)\b \(? ( (?>\w+) ,?\s? )+ [\.!?] \)? # Matches an entire sentence."; + public static void Main() + { + string input = "This is the first sentence. Is it the beginning " + + "of a literary masterpiece? I think not. Instead, " + + "it is a nonsensical paragraph."; + string pattern = @"(?x)\b \(? ( (?>\w+) ,?\s? )+ [\.!?] \)? # Matches an entire sentence."; - foreach (Match match in Regex.Matches(input, pattern)) - Console.WriteLine(match.Value); - } + foreach (Match match in Regex.Matches(input, pattern)) + Console.WriteLine(match.Value); + } } // The example displays the following output: // This is the first sentence. diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTimeOffset.Conceptual.Instantiate/cs/Instantiate.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTimeOffset.Conceptual.Instantiate/cs/Instantiate.cs index f2773bc52298b..d6c5b5da506ce 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTimeOffset.Conceptual.Instantiate/cs/Instantiate.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTimeOffset.Conceptual.Instantiate/cs/Instantiate.cs @@ -161,7 +161,7 @@ private static void CallDateTimeWithOffsetConstructors() // Throws exception and displays the following to the console: // Attempt to create DateTimeOffset value from 5/1/2008 8:30:00 AM failed. - // Instantiate a DateTimeOffset value with an arbitary time zone. + // Instantiate a DateTimeOffset value with an arbitrary time zone. string timeZoneName = "Central Standard Time"; TimeSpan offset = TimeZoneInfo.FindSystemTimeZoneById(timeZoneName). GetUtcOffset(sourceDate); diff --git a/samples/snippets/csharp/VS_Snippets_Data/XmlSchemaReadWriteExample/CS/XmlSchemaReadWriteExample.cs b/samples/snippets/csharp/VS_Snippets_Data/XmlSchemaReadWriteExample/CS/XmlSchemaReadWriteExample.cs index 2bb3ec379f45e..17cdd7f63d0d3 100644 --- a/samples/snippets/csharp/VS_Snippets_Data/XmlSchemaReadWriteExample/CS/XmlSchemaReadWriteExample.cs +++ b/samples/snippets/csharp/VS_Snippets_Data/XmlSchemaReadWriteExample/CS/XmlSchemaReadWriteExample.cs @@ -12,12 +12,12 @@ static void Main() try { XmlTextReader reader = new XmlTextReader("example.xsd"); - XmlSchema myschema = XmlSchema.Read(reader, ValidationCallback); - myschema.Write(Console.Out); + XmlSchema schema = XmlSchema.Read(reader, ValidationCallback); + schema.Write(Console.Out); FileStream file = new FileStream("new.xsd", FileMode.Create, FileAccess.ReadWrite); XmlTextWriter xwriter = new XmlTextWriter(file, new UTF8Encoding()); xwriter.Formatting = Formatting.Indented; - myschema.Write(xwriter); + schema.Write(xwriter); } catch(Exception e) { diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/CustomException.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/CustomException.cs new file mode 100644 index 0000000000000..edb200f4a5860 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/CustomException.cs @@ -0,0 +1,6 @@ +public class CustomException : Exception +{ + public CustomException(string message) : base(message) + { + } +} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/Program.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/Program.cs new file mode 100644 index 0000000000000..a621b1dd3e666 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/Program.cs @@ -0,0 +1,23 @@ +public static partial class Program +{ + public static void Main() + { + //Detached(); + //DetachedTwo(); + //ExceptionPropagation(); + //ExceptionPropagationTwo(); + //ThrowDemo(); + //ExceptionTwo(); + //Flatten(); + //FlattenTwo(); + //HandleMethod(); + //HandleMethodTwo(); + //HandleMethodThree(); + //Handle(); + //HandleTwo(); + //HandleThree(); + //HandleFour(); + //TaskException(); + //TaskExceptionTwo(); + } +} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached1.cs index 8ba0e66e974b6..2d5c496c9f484 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached1.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached1.cs @@ -1,38 +1,34 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run(() => { - var nested1 = Task.Run(() => { - throw new CustomException("Detached child task faulted."); - }); + public static void Detached() + { + var task = Task.Run(() => + { + var nestedTask = Task.Run( + () => throw new CustomException("Detached child task faulted.")); - // Here the exception will be escalated back to the calling thread. - // We could use try/catch here to prevent that. - nested1.Wait(); - }); + // Here the exception will be escalated back to the calling thread. + // We could use try/catch here to prevent that. + nestedTask.Wait(); + }); - try { - task1.Wait(); - } - catch (AggregateException ae) { - foreach (var e in ae.Flatten().InnerExceptions) { - if (e is CustomException) { - Console.WriteLine(e.Message); + try + { + task.Wait(); + } + catch (AggregateException ae) + { + foreach (var e in ae.Flatten().InnerExceptions) + { + if (e is CustomException) + { + Console.WriteLine(e.Message); + } } - } - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + } + } } // The example displays the following output: // Detached child task faulted. diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached21.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached21.cs index 9faab130dbba1..78b5b7ecf5dea 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached21.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/detached21.cs @@ -1,38 +1,34 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run(() => { - var nested1 = Task.Run(() => { - throw new CustomException("Detached child task faulted."); - }); + public static void DetachedTwo() + { + var task = Task.Run(() => + { + var nestedTask = Task.Run( + () => throw new CustomException("Detached child task faulted.")); - // Here the exception will be escalated back to the calling thread. - // We could use try/catch here to prevent that. - nested1.Wait(); - }); + // Here the exception will be escalated back to the calling thread. + // We could use try/catch here to prevent that. + nestedTask.Wait(); + }); - try { - task1.Wait(); - } - catch (AggregateException ae) { - foreach (var e in ae.Flatten().InnerExceptions) { - if (e is CustomException) { - Console.WriteLine(e.Message); + try + { + task.Wait(); + } + catch (AggregateException ae) + { + foreach (var e in ae.Flatten().InnerExceptions) + { + if (e is CustomException) + { + Console.WriteLine(e.Message); + } } - } - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + } + } } // The example displays the following output: // Detached child task faulted. diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop1.cs index 70d57d90ef6c6..3060959a1acd5 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop1.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop1.cs @@ -1,27 +1,24 @@ -using System; +// -// -using System.Threading; -using System.Threading.Tasks; - -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run(() => - { throw new CustomException("task1 faulted."); - }).ContinueWith( t => { Console.WriteLine("{0}: {1}", - t.Exception.InnerException.GetType().Name, - t.Exception.InnerException.Message); - }, TaskContinuationOptions.OnlyOnFaulted); - Thread.Sleep(500); - } -} + public static void ExceptionPropagation() + { + _ = Task.Run( + () => throw new CustomException("task1 faulted.")) + .ContinueWith(_ => + { + if (_.Exception?.InnerException is { } inner) + { + Console.WriteLine("{0}: {1}", + inner.GetType().Name, + inner.Message); + } + }, + TaskContinuationOptions.OnlyOnFaulted); -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + Thread.Sleep(500); + } } // The example displays output like the following: // CustomException: task1 faulted. diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop21.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop21.cs index 6b2dea22cccb4..7ffd25822793f 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop21.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptionprop21.cs @@ -1,27 +1,24 @@ - -// -using System; -using System.Threading; -using System.Threading.Tasks; +// -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run(() => - { throw new CustomException("task1 faulted."); - }).ContinueWith( t => { Console.WriteLine("{0}: {1}", - t.Exception.InnerException.GetType().Name, - t.Exception.InnerException.Message); - }, TaskContinuationOptions.OnlyOnFaulted); - Thread.Sleep(500); - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + public static void ExceptionPropagationTwo() + { + _ = Task.Run( + () => throw new CustomException("task1 faulted.")) + .ContinueWith(_ => + { + if (_.Exception?.InnerException is { } inner) + { + Console.WriteLine("{0}: {1}", + inner.GetType().Name, + inner.Message); + } + }, + TaskContinuationOptions.OnlyOnFaulted); + + Thread.Sleep(500); + } } // The example displays output like the following: // CustomException: task1 faulted. diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptions.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptions.cs index 15be42f258483..3c1e13ffea912 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptions.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/exceptions.cs @@ -1,137 +1,122 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Collections.Concurrent; +using System.Collections.Concurrent; -namespace TPL_Exceptions +public static partial class Program { - class ExceptionDemoCS + public static void ThrowDemo() { - class MyCustomException : Exception + var task = Task.Factory.StartNew( + () => throw new CustomException("I'm bad, but not too bad!")); + + try { - public MyCustomException(string s) : base(s) { } + task.Wait(); } - - static void ThrowDemo() + catch (AggregateException ae) { - var task1 = Task.Factory.StartNew(() => - { - throw new MyCustomException("I'm bad, but not too bad!"); - }); - - try + // Assume we know what's going on with this particular exception. + // Rethrow anything else. AggregateException.Handle provides + // another way to express this. See later example. + // + foreach (var ex in ae.InnerExceptions) { - task1.Wait(); - } - catch (AggregateException ae) - { - // Assume we know what's going on with this particular exception. - // Rethrow anything else. AggregateException.Handle provides - // another way to express this. See later example. - // - foreach (var e in ae.InnerExceptions) + if (ex is CustomException) { - if (e is MyCustomException) - { - Console.WriteLine(e.Message); - } - else - { - throw; - } + Console.WriteLine(ex.Message); + } + else + { + throw; } - // } + // } + } - static void CancelDemo() + static void CancelDemo() + { + bool someCondition = true; + // + var tokenSource = new CancellationTokenSource(); + var token = tokenSource.Token; + var task = Task.Factory.StartNew(() => { - bool someCondition = true; - // - var tokenSource = new CancellationTokenSource(); - var token = tokenSource.Token; - - var task1 = Task.Factory.StartNew(() => + CancellationToken ct = token; + while (someCondition) { - CancellationToken ct = token; - while (someCondition) - { - // Do some work... - Thread.SpinWait(50000); - ct.ThrowIfCancellationRequested(); - } - }, - token); + // Do some work... + Thread.SpinWait(50_000); + ct.ThrowIfCancellationRequested(); + } + }, + token); - // No waiting required. - tokenSource.Dispose(); - // - } + // No waiting required. + tokenSource.Dispose(); + // } +} - // - class ExceptionDemo2 +// +public static partial class Program +{ + public static void ExceptionTwo() { - static void Main(string[] args) - { - // Create some random data to process in parallel. - // There is a good probability this data will cause some exceptions to be thrown. - byte[] data = new byte[5000]; - Random r = new Random(); - r.NextBytes(data); + // Create some random data to process in parallel. + // There is a good probability this data will cause some exceptions to be thrown. + byte[] data = new byte[5_000]; + Random r = Random.Shared; + r.NextBytes(data); - try + try + { + ProcessDataInParallel(data); + } + catch (AggregateException ae) + { + var ignoredExceptions = new List(); + // This is where you can choose which exceptions to handle. + foreach (var ex in ae.Flatten().InnerExceptions) { - ProcessDataInParallel(data); + if (ex is ArgumentException) Console.WriteLine(ex.Message); + else ignoredExceptions.Add(ex); } - catch (AggregateException ae) + if (ignoredExceptions.Count > 0) { - var ignoredExceptions = new List(); - // This is where you can choose which exceptions to handle. - foreach (var ex in ae.Flatten().InnerExceptions) - { - if (ex is ArgumentException) - Console.WriteLine(ex.Message); - else - ignoredExceptions.Add(ex); - } - if (ignoredExceptions.Count > 0) throw new AggregateException(ignoredExceptions); + throw new AggregateException(ignoredExceptions); } - - Console.WriteLine("Press any key to exit."); - Console.ReadKey(); } - private static void ProcessDataInParallel(byte[] data) - { - // Use ConcurrentQueue to enable safe enqueueing from multiple threads. - var exceptions = new ConcurrentQueue(); + Console.WriteLine("Press any key to exit."); + Console.ReadKey(); + } - // Execute the complete loop and capture all exceptions. - Parallel.ForEach(data, d => + private static void ProcessDataInParallel(byte[] data) + { + // Use ConcurrentQueue to enable safe enqueueing from multiple threads. + var exceptions = new ConcurrentQueue(); + + // Execute the complete loop and capture all exceptions. + Parallel.ForEach(data, d => + { + try { - try - { - // Cause a few exceptions, but not too many. - if (d < 3) - throw new ArgumentException($"Value is {d}. Value must be greater than or equal to 3."); - else - Console.Write(d + " "); - } - // Store the exception and continue with the loop. - catch (Exception e) - { - exceptions.Enqueue(e); - } - }); - Console.WriteLine(); + // Cause a few exceptions, but not too many. + if (d < 3) throw new ArgumentException($"Value is {d}. Value must be greater than or equal to 3."); + else Console.Write(d + " "); + } + // Store the exception and continue with the loop. + catch (Exception e) + { + exceptions.Enqueue(e); + } + }); + Console.WriteLine(); - // Throw the exceptions here after the loop completes. - if (exceptions.Count > 0) throw new AggregateException(exceptions); + // Throw the exceptions here after the loop completes. + if (!exceptions.IsEmpty) + { + throw new AggregateException(exceptions); } } - // -} \ No newline at end of file +} +// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten1.cs index 883eab7fce70d..1f30538d86cb4 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten1.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten1.cs @@ -1,43 +1,43 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Factory.StartNew(() => { - var child1 = Task.Factory.StartNew(() => { - var child2 = Task.Factory.StartNew(() => { - // This exception is nested inside three AggregateExceptions. - throw new CustomException("Attached child2 faulted."); - }, TaskCreationOptions.AttachedToParent); + public static void Flatten() + { + var task = Task.Factory.StartNew(() => + { + var child = Task.Factory.StartNew(() => + { + var grandChild = Task.Factory.StartNew(() => + { + // This exception is nested inside three AggregateExceptions. + throw new CustomException("Attached child2 faulted."); + }, TaskCreationOptions.AttachedToParent); - // This exception is nested inside two AggregateExceptions. - throw new CustomException("Attached child1 faulted."); - }, TaskCreationOptions.AttachedToParent); - }); + // This exception is nested inside two AggregateExceptions. + throw new CustomException("Attached child1 faulted."); + }, TaskCreationOptions.AttachedToParent); + }); - try { - task1.Wait(); - } - catch (AggregateException ae) { - foreach (var e in ae.Flatten().InnerExceptions) { - if (e is CustomException) { - Console.WriteLine(e.Message); + try + { + task.Wait(); + } + catch (AggregateException ae) + { + foreach (var ex in ae.Flatten().InnerExceptions) + { + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + else + { + throw; + } } - else { - throw; - } - } - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + } + } } // The example displays the following output: // Attached child1 faulted. diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten2.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten2.cs index 568d3225a6f6e..7d0101f1ad6d7 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten2.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/flatten2.cs @@ -1,43 +1,43 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Factory.StartNew(() => { - var child1 = Task.Factory.StartNew(() => { - var child2 = Task.Factory.StartNew(() => { - // This exception is nested inside three AggregateExceptions. - throw new CustomException("Attached child2 faulted."); - }, TaskCreationOptions.AttachedToParent); + public static void FlattenTwo() + { + var task = Task.Factory.StartNew(() => + { + var child = Task.Factory.StartNew(() => + { + var grandChild = Task.Factory.StartNew(() => + { + // This exception is nested inside three AggregateExceptions. + throw new CustomException("Attached child2 faulted."); + }, TaskCreationOptions.AttachedToParent); - // This exception is nested inside two AggregateExceptions. - throw new CustomException("Attached child1 faulted."); - }, TaskCreationOptions.AttachedToParent); - }); + // This exception is nested inside two AggregateExceptions. + throw new CustomException("Attached child1 faulted."); + }, TaskCreationOptions.AttachedToParent); + }); - try { - task1.Wait(); - } - catch (AggregateException ae) { - foreach (var e in ae.Flatten().InnerExceptions) { - if (e is CustomException) { - Console.WriteLine(e.Message); + try + { + task.Wait(); + } + catch (AggregateException ae) + { + foreach (var ex in ae.Flatten().InnerExceptions) + { + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + else + { + throw; + } } - else { - throw; - } - } - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + } + } } // The example displays the following output: // Attached child1 faulted. diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod1.cs index 688a63071f37e..2d3896785dbed 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod1.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod1.cs @@ -1,32 +1,30 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run( () => { throw new CustomException("This exception is expected!"); } ); + public static void HandleMethod() + { + var task = Task.Run( + () => throw new CustomException("This exception is expected!")); - try { - task1.Wait(); - } - catch (AggregateException ae) - { - // Call the Handle method to handle the custom exception, - // otherwise rethrow the exception. - ae.Handle(ex => { if (ex is CustomException) - Console.WriteLine(ex.Message); - return ex is CustomException; - }); - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + try + { + task.Wait(); + } + catch (AggregateException ae) + { + // Call the Handle method to handle the custom exception, + // otherwise rethrow the exception. + ae.Handle(ex => + { + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + return ex is CustomException; + }); + } + } } // The example displays the following output: // This exception is expected! diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod2.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod2.cs index 7bc69462487de..073ddd61cd164 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod2.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod2.cs @@ -1,32 +1,30 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run( () => { throw new CustomException("This exception is expected!"); } ); + public static void HandleMethodTwo() + { + var task1 = Task.Run( + () => throw new CustomException("This exception is expected!")); - try { - task1.Wait(); - } - catch (AggregateException ae) - { - // Call the Handle method to handle the custom exception, - // otherwise rethrow the exception. - ae.Handle(ex => { if (ex is CustomException) - Console.WriteLine(ex.Message); - return ex is CustomException; - }); - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + try + { + task1.Wait(); + } + catch (AggregateException ae) + { + // Call the Handle method to handle the custom exception, + // otherwise rethrow the exception. + ae.Handle(ex => + { + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + return ex is CustomException; + }); + } + } } // The example displays the following output: // This exception is expected! diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod21.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod21.cs index 7eef839163607..1978c8aa704db 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod21.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handlemethod21.cs @@ -1,32 +1,30 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run( () => { throw new CustomException("This exception is expected!"); } ); + public static void HandleMethodThree() + { + var task = Task.Run( + () => throw new CustomException("This exception is expected!")); - try { - task1.Wait(); - } - catch (AggregateException ae) - { - // Call the Handle method to handle the custom exception, - // otherwise rethrow the exception. - ae.Handle(ex => { if (ex is CustomException) - Console.WriteLine(ex.Message); - return ex is CustomException; - }); - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + try + { + task.Wait(); + } + catch (AggregateException ae) + { + // Call the Handle method to handle the custom exception, + // otherwise rethrow the exception. + ae.Handle(ex => + { + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + return ex is CustomException; + }); + } + } } // The example displays the following output: // This exception is expected! diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling-tpl-exceptions.csproj b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling-tpl-exceptions.csproj new file mode 100644 index 0000000000000..835740427d7cb --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling-tpl-exceptions.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + true + + + \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling1.cs index 1d95eb0563e0a..d247148a51651 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling1.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling1.cs @@ -1,37 +1,33 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run( () => { throw new CustomException("This exception is expected!"); } ); + public static void Handle() + { + var task = Task.Run( + () => throw new CustomException("This exception is expected!")); - try - { - task1.Wait(); - } - catch (AggregateException ae) - { - foreach (var e in ae.InnerExceptions) { - // Handle the custom exception. - if (e is CustomException) { - Console.WriteLine(e.Message); - } - // Rethrow any other exception. - else { - throw; - } - } - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + try + { + task.Wait(); + } + catch (AggregateException ae) + { + foreach (var ex in ae.InnerExceptions) + { + // Handle the custom exception. + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + // Rethrow any other exception. + else + { + throw; + } + } + } + } } // The example displays the following output: // This exception is expected! diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling2.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling2.cs index 7227586bf370b..cb3628a12b77a 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling2.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling2.cs @@ -1,34 +1,33 @@ // + using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run( () => { throw new CustomException("This exception is expected!"); } ); - - while(! task1.IsCompleted) {} + public static void HandleTwo() + { + var task = Task.Run( + () => throw new CustomException("This exception is expected!")); - if (task1.Status == TaskStatus.Faulted) { - foreach (var e in task1.Exception.InnerExceptions) { - // Handle the custom exception. - if (e is CustomException) { - Console.WriteLine(e.Message); - } - // Rethrow any other exception. - else { - throw e; - } - } - } - } -} + while (!task.IsCompleted) { } -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + if (task.Status == TaskStatus.Faulted) + { + foreach (var ex in task.Exception?.InnerExceptions ?? new(Array.Empty())) + { + // Handle the custom exception. + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + // Rethrow any other exception. + else + { + throw ex; + } + } + } + } } // The example displays the following output: // This exception is expected! diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling21.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling21.cs index 99f24e370480d..a80ff1c6d1285 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling21.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling21.cs @@ -1,37 +1,33 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run( () => { throw new CustomException("This exception is expected!"); } ); + public static void HandleThree() + { + var task = Task.Run( + () => throw new CustomException("This exception is expected!")); - try - { - task1.Wait(); - } - catch (AggregateException ae) - { - foreach (var e in ae.InnerExceptions) { - // Handle the custom exception. - if (e is CustomException) { - Console.WriteLine(e.Message); - } - // Rethrow any other exception. - else { - throw e; - } - } - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + try + { + task.Wait(); + } + catch (AggregateException ae) + { + foreach (var ex in ae.InnerExceptions) + { + // Handle the custom exception. + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + // Rethrow any other exception. + else + { + throw ex; + } + } + } + } } // The example displays the following output: // This exception is expected! diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling22.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling22.cs index a0c6210bccee7..e0db8873c671e 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling22.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling22.cs @@ -1,34 +1,31 @@ // -using System; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - var task1 = Task.Run( () => { throw new CustomException("This exception is expected!"); } ); + public static void HandleFour() + { + var task = Task.Run( + () => throw new CustomException("This exception is expected!")); - while(! task1.IsCompleted) {} + while (!task.IsCompleted) { } - if (task1.Status == TaskStatus.Faulted) { - foreach (var e in task1.Exception.InnerExceptions) { - // Handle the custom exception. - if (e is CustomException) { - Console.WriteLine(e.Message); - } - // Rethrow any other exception. - else { - throw e; - } - } - } - } -} - -public class CustomException : Exception -{ - public CustomException(String message) : base(message) - {} + if (task.Status == TaskStatus.Faulted) + { + foreach (var ex in task.Exception?.InnerExceptions ?? new(Array.Empty())) + { + // Handle the custom exception. + if (ex is CustomException) + { + Console.WriteLine(ex.Message); + } + // Rethrow any other exception. + else + { + throw ex; + } + } + } + } } // The example displays the following output: // This exception is expected! diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions.cs index 570e2cde955aa..e4748c534e893 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions.cs @@ -1,55 +1,73 @@ // -using System; -using System.IO; -using System.Threading.Tasks; - -public class Example +public static partial class Program { - public static void Main() + public static void TaskException() { // This should throw an UnauthorizedAccessException. - try { - var files = GetAllFiles(@"C:\"); - if (files != null) - foreach (var file in files) - Console.WriteLine(file); + try + { + if (GetAllFiles(@"C:\") is { Length: > 0 } files) + { + foreach (var file in files) + { + Console.WriteLine(file); + } + } } - catch (AggregateException ae) { - foreach (var ex in ae.InnerExceptions) - Console.WriteLine("{0}: {1}", ex.GetType().Name, ex.Message); + catch (AggregateException ae) + { + foreach (var ex in ae.InnerExceptions) + { + Console.WriteLine( + "{0}: {1}", ex.GetType().Name, ex.Message); + } } Console.WriteLine(); // This should throw an ArgumentException. - try { - foreach (var s in GetAllFiles("")) - Console.WriteLine(s); + try + { + foreach (var s in GetAllFiles("")) + { + Console.WriteLine(s); + } } - catch (AggregateException ae) { - foreach (var ex in ae.InnerExceptions) - Console.WriteLine("{0}: {1}", ex.GetType().Name, ex.Message); + catch (AggregateException ae) + { + foreach (var ex in ae.InnerExceptions) + Console.WriteLine( + "{0}: {1}", ex.GetType().Name, ex.Message); } } static string[] GetAllFiles(string path) { - var task1 = Task.Run( () => Directory.GetFiles(path, "*.txt", - SearchOption.AllDirectories)); + var task1 = + Task.Run(() => Directory.GetFiles( + path, "*.txt", + SearchOption.AllDirectories)); - try { - return task1.Result; - } - catch (AggregateException ae) { - ae.Handle( x => { // Handle an UnauthorizedAccessException - if (x is UnauthorizedAccessException) { - Console.WriteLine("You do not have permission to access all folders in this path."); - Console.WriteLine("See your network administrator or try another path."); - } - return x is UnauthorizedAccessException; - }); - return Array.Empty(); - } - } + try + { + return task1.Result; + } + catch (AggregateException ae) + { + ae.Handle(x => + { + // Handle an UnauthorizedAccessException + if (x is UnauthorizedAccessException) + { + Console.WriteLine( + "You do not have permission to access all folders in this path."); + Console.WriteLine( + "See your network administrator or try another path."); + } + return x is UnauthorizedAccessException; + }); + return Array.Empty(); + } + } } // The example displays the following output: // You do not have permission to access all folders in this path. diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions2.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions2.cs index 0842100efad61..15a8752c31f2a 100644 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions2.cs +++ b/samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/taskexceptions2.cs @@ -1,48 +1,58 @@ // -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; -public class Example +public static partial class Program { - public static void Main() - { - try { - ExecuteTasks(); - } - catch (AggregateException ae) { - foreach (var e in ae.InnerExceptions) { - Console.WriteLine("{0}:\n {1}", e.GetType().Name, e.Message); - } - } - } + public static void TaskExceptionTwo() + { + try + { + ExecuteTasks(); + } + catch (AggregateException ae) + { + foreach (var e in ae.InnerExceptions) + { + Console.WriteLine( + "{0}:\n {1}", e.GetType().Name, e.Message); + } + } + } - static void ExecuteTasks() - { + static void ExecuteTasks() + { // Assume this is a user-entered String. - String path = @"C:\"; - List tasks = new List(); + string path = @"C:\"; + List tasks = new(); - tasks.Add(Task.Run(() => { - // This should throw an UnauthorizedAccessException. - return Directory.GetFiles(path, "*.txt", - SearchOption.AllDirectories); - })); + tasks.Add(Task.Run(() => + { + // This should throw an UnauthorizedAccessException. + return Directory.GetFiles( + path, "*.txt", + SearchOption.AllDirectories); + })); - tasks.Add(Task.Run(() => { - if (path == @"C:\") - throw new ArgumentException("The system root is not a valid path."); - return new String[] { ".txt", ".dll", ".exe", ".bin", ".dat" }; - })); + tasks.Add(Task.Run(() => + { + if (path == @"C:\") + { + throw new ArgumentException( + "The system root is not a valid path."); + } + return new string[] { ".txt", ".dll", ".exe", ".bin", ".dat" }; + })); - tasks.Add(Task.Run(() => { - throw new NotImplementedException("This operation has not been implemented."); - })); + tasks.Add(Task.Run(() => + { + throw new NotImplementedException( + "This operation has not been implemented."); + })); - try { + try + { Task.WaitAll(tasks.ToArray()); } - catch (AggregateException ae) { + catch (AggregateException ae) + { throw ae.Flatten(); } } diff --git a/samples/snippets/csharp/VS_Snippets_Remoting/HowToChunkSerializedData/CS/Project.csproj b/samples/snippets/csharp/VS_Snippets_Remoting/HowToChunkSerializedData/CS/Project.csproj new file mode 100644 index 0000000000000..37d0726d213f6 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Remoting/HowToChunkSerializedData/CS/Project.csproj @@ -0,0 +1,13 @@ + + + + Library + net4.8 + + + + + + + + diff --git a/samples/snippets/csharp/VS_Snippets_Remoting/HowToChunkSerializedData/CS/SerializationChunk.cs b/samples/snippets/csharp/VS_Snippets_Remoting/HowToChunkSerializedData/CS/SerializationChunk.cs index b509e3e7c586c..2aa52c0a11ab0 100644 --- a/samples/snippets/csharp/VS_Snippets_Remoting/HowToChunkSerializedData/CS/SerializationChunk.cs +++ b/samples/snippets/csharp/VS_Snippets_Remoting/HowToChunkSerializedData/CS/SerializationChunk.cs @@ -2,116 +2,110 @@ using System.IO; using System.Web.Services; using System.Web.Services.Protocols; -using System.Runtime.Serialization; using System.Xml; using System.Xml.Serialization; using System.Xml.Schema; -using System.Security.Permissions; public class Test { + public class DownloadAuthorization { } -public class DownloadAuthorization{} - -static void Main() -{ - Console.WriteLine("Hello"); -} + static void Main() + { + Console.WriteLine("Hello"); + } -// + // [WebMethod] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute - (ParameterStyle= SoapParameterStyle.Bare)] + [SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)] public SongStream DownloadSong(DownloadAuthorization Authorization, string filePath) { - - // Turn off response buffering. - System.Web.HttpContext.Current.Response.Buffer = false; - // Return a song. - SongStream song = new SongStream(filePath); - return song; + // Turn off response buffering. + System.Web.HttpContext.Current.Response.Buffer = false; + // Return a song. + SongStream song = new SongStream(filePath); + return song; } -// + // } // [XmlSchemaProvider("MySchema")] public class SongStream : IXmlSerializable { - private const string ns = "http://demos.Contoso.com/webservices"; private string filePath; - public SongStream(){ } + public SongStream() { } public SongStream(string filePath) { - this.filePath = filePath; + this.filePath = filePath; } // This is the method named by the XmlSchemaProviderAttribute applied to the type. public static XmlQualifiedName MySchema(XmlSchemaSet xs) { - // This method is called by the framework to get the schema for this type. - // We return an existing schema from disk. - - XmlSerializer schemaSerializer = new XmlSerializer(typeof(XmlSchema)); - string xsdPath = null; - // NOTE: replace the string with your own path. - xsdPath = System.Web.HttpContext.Current.Server.MapPath("SongStream.xsd"); - XmlSchema s = (XmlSchema)schemaSerializer.Deserialize( - new XmlTextReader(xsdPath), null); - xs.XmlResolver = new XmlUrlResolver(); - xs.Add(s); - - return new XmlQualifiedName("songStream", ns); + // This method is called by the framework to get the schema for this type. + // We return an existing schema from disk. + + XmlSerializer schemaSerializer = new XmlSerializer(typeof(XmlSchema)); + string xsdPath = null; + // NOTE: replace the string with your own path. + xsdPath = System.Web.HttpContext.Current.Server.MapPath("SongStream.xsd"); + XmlSchema s = (XmlSchema)schemaSerializer.Deserialize( + new XmlTextReader(xsdPath), null); + xs.XmlResolver = new XmlUrlResolver(); + xs.Add(s); + + return new XmlQualifiedName("songStream", ns); } void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { - // This is the chunking code. - // ASP.NET buffering must be turned off for this to work. + // This is the chunking code. + // ASP.NET buffering must be turned off for this to work. - int bufferSize = 4096; - char[] songBytes = new char[bufferSize]; - FileStream inFile = File.Open(this.filePath, FileMode.Open, FileAccess.Read); + int bufferSize = 4096; + char[] songBytes = new char[bufferSize]; + FileStream inFile = File.Open(this.filePath, FileMode.Open, FileAccess.Read); - long length = inFile.Length; + long length = inFile.Length; - // Write the file name. - writer.WriteElementString("fileName", ns, Path.GetFileNameWithoutExtension(this.filePath)); + // Write the file name. + writer.WriteElementString("fileName", ns, Path.GetFileNameWithoutExtension(this.filePath)); - // Write the size. - writer.WriteElementString("size", ns, length.ToString()); + // Write the size. + writer.WriteElementString("size", ns, length.ToString()); - // Write the song bytes. - writer.WriteStartElement("song", ns); + // Write the song bytes. + writer.WriteStartElement("song", ns); - StreamReader sr = new StreamReader(inFile, true); - int readLen = sr.Read(songBytes, 0, bufferSize); + StreamReader sr = new StreamReader(inFile, true); + int readLen = sr.Read(songBytes, 0, bufferSize); - while (readLen > 0) - { - writer.WriteStartElement("chunk", ns); - writer.WriteChars(songBytes, 0, readLen); - writer.WriteEndElement(); + while (readLen > 0) + { + writer.WriteStartElement("chunk", ns); + writer.WriteChars(songBytes, 0, readLen); + writer.WriteEndElement(); - writer.Flush(); - readLen = sr.Read(songBytes, 0, bufferSize); - } + writer.Flush(); + readLen = sr.Read(songBytes, 0, bufferSize); + } - writer.WriteEndElement(); - inFile.Close(); + writer.WriteEndElement(); + inFile.Close(); } - System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() + XmlSchema IXmlSerializable.GetSchema() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } // @@ -160,26 +154,26 @@ void ReadAndSaveSong(XmlReader reader) string songBase64; byte[] songBytes; reader.ReadStartElement("song", ns); - double totalRead=0; - while(true) + double totalRead = 0; + while (true) { if (reader.IsStartElement("chunk", ns)) { - songBase64 = reader.ReadElementString(); - totalRead += songBase64.Length; - songBytes = Convert.FromBase64String(songBase64); - outFile.Write(songBytes, 0, songBytes.Length); - outFile.Flush(); - - if (OnProgress != null) - { - OnProgress(100 * (totalRead / size)); - } + songBase64 = reader.ReadElementString(); + totalRead += songBase64.Length; + songBytes = Convert.FromBase64String(songBase64); + outFile.Write(songBytes, 0, songBytes.Length); + outFile.Flush(); + + if (OnProgress != null) + { + OnProgress(100 * (totalRead / size)); + } } else { - break; + break; } } @@ -187,20 +181,19 @@ void ReadAndSaveSong(XmlReader reader) reader.ReadEndElement(); } - [PermissionSet(SecurityAction.Demand, Name="FullTrust")] public void Play() { System.Diagnostics.Process.Start(this.filePath); } - System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() + XmlSchema IXmlSerializable.GetSchema() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void WriteXml(XmlWriter writer) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } // diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/BitmapFrame.cs b/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/BitmapFrame.cs deleted file mode 100644 index 1f3d823477f81..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/BitmapFrame.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Threading; -using System.Security.Permissions; -using System.Collections.ObjectModel; - -namespace SDKSample -{ - public class MyApp : Application - { - Window mainWindow; - - protected override void OnStartup (StartupEventArgs e) - { - base.OnStartup (e); - CreateAndShowMainWindow (); - } - [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] - private void CreateAndShowMainWindow () - { - - // Create the application's main window - mainWindow = new Window (); - mainWindow.Title = "Imaging Sample"; - ScrollViewer mySV = new ScrollViewer(); - - // - int width = 128; - int height = width; - int stride = width/8; - byte[] pixels = new byte[height*stride]; - - // Try creating a new image with a custom palette. - List colors = new List(); - colors.Add(System.Windows.Media.Colors.Red); - colors.Add(System.Windows.Media.Colors.Blue); - colors.Add(System.Windows.Media.Colors.Green); - BitmapPalette myPalette = new BitmapPalette(colors); - - // Creates a new empty image with the pre-defined palette - - // - BitmapSource image = BitmapSource.Create( - width, - height, - 96, - 96, - PixelFormats.Indexed1, - myPalette, - pixels, - stride); - // - - // - FileStream stream = new FileStream("empty.tif", FileMode.Create); - TiffBitmapEncoder encoder = new TiffBitmapEncoder(); - TextBlock myTextBlock = new TextBlock(); - myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString(); - encoder.Frames.Add(BitmapFrame.Create(image)); - MessageBox.Show(myPalette.Colors.Count.ToString()); - encoder.Save(stream); - // - - // - - // Draw the Image - Image myImage = new Image(); - myImage.Source = image; - myImage.Stretch = Stretch.None; - myImage.Margin = new Thickness(20); - - // - - // Open a Stream and decode a TIFF image - Stream imageStreamSource = new FileStream("tulipfarm.tif", FileMode.Open, FileAccess.Read, FileShare.Read); - TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); - BitmapSource bitmapSource = decoder.Frames[0]; - - // Draw the Image - Image myImage1 = new Image(); - myImage1.Source = bitmapSource; - myImage1.Stretch = Stretch.None; - myImage1.Margin = new Thickness(20); - // - - // - - // Get the palette from an image - BitmapImage image2 = new BitmapImage(); - image2.BeginInit(); - image2.UriSource = new Uri("tulipfarm.tif", UriKind.RelativeOrAbsolute); - image2.EndInit(); - BitmapPalette myPalette3 = new BitmapPalette(image2, 256); - - //Draw the third Image - Image myImage2 = new Image(); - myImage2.Source = image2; - myImage2.Stretch = Stretch.None; - myImage2.Margin = new Thickness(20); - // - - // - - //Create a new TIFF image based on existing Image - FileStream stream2 = new FileStream("image.tif", FileMode.Create); - TiffBitmapEncoder encoder2 = new TiffBitmapEncoder(); - TiffBitmapDecoder decoder2 = new TiffBitmapDecoder(new Uri("tulipfarm.tif", UriKind.RelativeOrAbsolute), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None); - encoder2.Frames = decoder2.Frames; - // - BitmapMetadata tiffMetadata = new BitmapMetadata("tiff"); - tiffMetadata.SetQuery("/ifd/{ushort=1000}", 9999); - tiffMetadata.SetQuery("/ifd/{uint=1001}", 23456); - tiffMetadata.SetQuery("/ifd/{uint=1002}", 34567); - tiffMetadata.SetQuery("/ifd/PaddingSchema:padding", (UInt32)4096); - tiffMetadata.SetQuery("/ifd/exif", new BitmapMetadata("exif")); - tiffMetadata.SetQuery("/ifd/exif/PaddingSchema:padding", (UInt32)4096); - // - encoder2.Save(stream2); - stream2.Close(); - // - - // - FileStream stream4 = new FileStream("image3.tif", FileMode.Create); - BitmapMetadata myBitmapMetadata2 = new BitmapMetadata("tiff"); - TiffBitmapEncoder encoder4 = new TiffBitmapEncoder(); - MessageBox.Show(myBitmapMetadata2.IsFixedSize.ToString()); - MessageBox.Show(myBitmapMetadata2.IsReadOnly.ToString()); - MessageBox.Show(myBitmapMetadata2.Format.ToString()); - MessageBox.Show(myBitmapMetadata2.Location.ToString()); - encoder4.Frames = decoder2.Frames; - encoder4.Save(stream4); - stream4.Close(); - // - - // - FileStream stream3 = new FileStream( "image2.tif", FileMode.Create ); - BitmapMetadata myBitmapMetadata = new BitmapMetadata( "tiff" ); - TiffBitmapEncoder encoder3 = new TiffBitmapEncoder(); - myBitmapMetadata.ApplicationName = "Microsoft Digital Image Suite 10"; - myBitmapMetadata.Author = new ReadOnlyCollection( - new List() { "Lori Kane" } ); - myBitmapMetadata.CameraManufacturer = "Tailspin Toys"; - myBitmapMetadata.CameraModel = "TT23"; - myBitmapMetadata.Comment = "Nice Picture"; - myBitmapMetadata.Copyright = "2010"; - myBitmapMetadata.DateTaken = "5/23/2010"; - myBitmapMetadata.Keywords = new ReadOnlyCollection( - new List() { "Lori", "Kane" } ); - myBitmapMetadata.Rating = 5; - myBitmapMetadata.Subject = "Lori"; - myBitmapMetadata.Title = "Lori's photo"; - - // Create a new frame that is identical to the one - // from the original image, except for the new metadata. - encoder3.Frames.Add( - BitmapFrame.Create( - decoder2.Frames[0], - decoder2.Frames[0].Thumbnail, - myBitmapMetadata, - decoder2.Frames[0].ColorContexts ) ); - - encoder3.Save( stream3 ); - stream3.Close(); - // - - // - BitmapSource image5 = BitmapSource.Create( - width, - height, - 96, - 96, - PixelFormats.Indexed1, - BitmapPalettes.WebPalette, - pixels, - stride); - - FileStream stream5 = new FileStream("palette.tif", FileMode.Create); - TiffBitmapEncoder encoder5 = new TiffBitmapEncoder(); - encoder5.Frames.Add(BitmapFrame.Create(image5)); - encoder5.Save(stream5); - // - - // Define a StackPanel to host Content - - StackPanel myStackPanel = new StackPanel(); - myStackPanel.Orientation = Orientation.Vertical; - myStackPanel.VerticalAlignment = VerticalAlignment.Stretch; - myStackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; - - // Add the Image and TextBlock to the parent Grid - myStackPanel.Children.Add(myImage); - myStackPanel.Children.Add(myTextBlock); - myStackPanel.Children.Add(myImage1); - myStackPanel.Children.Add(myImage2); - - // Add the StackPanel as the Content of the Parent Window Object - mySV.Content = myStackPanel; - mainWindow.Content = mySV; - mainWindow.Show(); - } - } - - // Define a static entry class - internal static class EntryClass - { - [System.STAThread()] - private static void Main () - { - MyApp app = new MyApp (); - app.Run (); - } - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/BitmapFrame.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/BitmapFrame.csproj deleted file mode 100644 index eb1794c1c9002..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/BitmapFrame.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - WinExe - net48 - true - - - - - Always - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/tulipfarm.tif b/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/tulipfarm.tif deleted file mode 100644 index fbe1e1015ea23..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_Wpf/BitmapFrameExample/CSharp/tulipfarm.tif and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.cs b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.cs index 0e7707a80a8e2..9d8ef0298dfb4 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.cs +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.cs @@ -11,8 +11,6 @@ namespace WmpAxLib { public partial class WmpAxControl : UserControl { - [System.Security.Permissions.PermissionSetAttribute - (System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] public WmpAxControl() { InitializeComponent(); @@ -26,4 +24,4 @@ public void Play(string url) // } } -// \ No newline at end of file +// diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.designer.cs b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.designer.cs index 55026edf22d42..3f9af95d586b1 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.designer.cs +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxcontrol.designer.cs @@ -32,19 +32,20 @@ private void InitializeComponent() this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer(); ((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).BeginInit(); this.SuspendLayout(); - // + // // axWindowsMediaPlayer1 - // + // this.axWindowsMediaPlayer1.Dock = System.Windows.Forms.DockStyle.Fill; this.axWindowsMediaPlayer1.Enabled = true; this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(0, 0); this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1"; this.axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState"))); this.axWindowsMediaPlayer1.Size = new System.Drawing.Size(337, 359); + this.axWindowsMediaPlayer1.TabIndex = 0; this.axWindowsMediaPlayer1.Text = "axWindowsMediaPlayer1"; - // + // // WmpAxControl - // + // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.axWindowsMediaPlayer1); diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxlib.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxlib.csproj index a870294e7b581..9612928933882 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxlib.csproj +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/AxControl/wmpaxlib.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -9,8 +9,9 @@ Properties WmpAxLib WmpAxLib - v4.0 - Client + v4.8 + + true @@ -20,6 +21,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -28,6 +30,7 @@ TRACE prompt 4 + false diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/app.config b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/app.config new file mode 100644 index 0000000000000..3e0e37cfc8c7a --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/app.config @@ -0,0 +1,3 @@ + + + diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/app.xaml.cs b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/app.xaml.cs index 337294ae8d7ae..b9f2bd197e4a2 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/app.xaml.cs +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/app.xaml.cs @@ -1,8 +1,4 @@ -using System; -using System.Windows; -using System.Data; -using System.Xml; -using System.Configuration; +using System.Windows; namespace HostingAxInWpf { @@ -12,11 +8,10 @@ namespace HostingAxInWpf public partial class app : Application { - void AppStartup(object sender, StartupEventArgs args) { - Window1 mainWindow = new Window1(); + Window mainWindow = new Window(); mainWindow.Show(); } } -} \ No newline at end of file +} diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/hostingaxinwpf.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/hostingaxinwpf.csproj index ad8a4fb5bb20d..89cb917afb9f1 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/hostingaxinwpf.csproj +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/hostingaxinwpf.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -11,8 +11,9 @@ 10.0.20821 2.0 - v4.0 - Client + v4.8 + + true @@ -20,17 +21,18 @@ false .\bin\Debug\ DEBUG;TRACE + false false true .\bin\Release\ TRACE + false - - False - ..\bin\AxInterop.WMPLib.dll + + ..\AxControl\bin\Debug\AxInterop.WMPLib.dll @@ -61,9 +63,12 @@ + + + - {4788D423-0FFB-4778-905A-76610471029F} + {4788d423-0ffb-4778-905a-76610471029f} WmpAxLib diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/window1.xaml.cs b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/window1.xaml.cs index 11732b87bb685..0940ea9c8ef16 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/window1.xaml.cs +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/HostingAxInWpf/window1.xaml.cs @@ -1,11 +1,5 @@ // -using System; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Media; -using System.Windows.Shapes; namespace HostingAxInWpf { @@ -24,7 +18,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) new System.Windows.Forms.Integration.WindowsFormsHost(); // Create the ActiveX control. - WmpAxLib.AxWindowsMediaPlayer axWmp = new WmpAxLib.AxWindowsMediaPlayer(); + AxWMPLib.AxWindowsMediaPlayer axWmp = new AxWMPLib.AxWindowsMediaPlayer(); // Assign the ActiveX control as the host control's child. host.Child = axWmp; diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/snippets.5000.json b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/snippets.5000.json new file mode 100644 index 0000000000000..da9ebf8da2f9d --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Wpf/HostingAxInWpf/CSharp/snippets.5000.json @@ -0,0 +1,3 @@ +{ + "host": "visualstudio" +} diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.sln b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.sln index 6ab0aa2283bfb..8e7434d0ab704 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.sln +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.sln @@ -1,9 +1,11 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvokePatternApp", "InvokePatternApp.csproj", "{A0B1E8EE-DA82-44CA-B383-EF92EA1E8F11}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32407.343 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvokePatternApp", "InvokePatternApp\InvokePatternApp.csproj", "{A0B1E8EE-DA82-44CA-B383-EF92EA1E8F11}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Target", "Target.csproj", "{B9A74CE9-0384-42D2-BFED-9B1A83A0E8A1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Target", "Target\Target.csproj", "{B9A74CE9-0384-42D2-BFED-9B1A83A0E8A1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -23,4 +25,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {200FC30F-1B32-4D17-ADE8-7D21C871263E} + EndGlobalSection EndGlobal diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.cs similarity index 98% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.cs index c8d75c89e3c76..919b181666acc 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.cs +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.cs @@ -51,7 +51,6 @@ using System.Windows.Threading; using System.Windows.Media; using System.IO; -using System.Security.Permissions; namespace SDKSample { @@ -176,13 +175,12 @@ protected override void OnStartup(StartupEventArgs args) /// /// Start the target application. /// - /// The target appliation. + /// The target application. /// - /// Starts the application that we are going to use for as our + /// Starts the application that we are going to use as our /// root element for this sample. /// ///-------------------------------------------------------------------- - [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)] private AutomationElement StartApp(string app) { if (File.Exists(app)) diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.csproj similarity index 92% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.csproj rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.csproj index e595054b17db3..de372c2c2364a 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp.csproj +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/InvokePatternApp.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -11,9 +11,10 @@ 10.0.20821 2.0 - v4.0 + v4.8 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Client + + true @@ -21,12 +22,14 @@ false .\bin\Debug\ DEBUG;TRACE + false false true .\bin\Release\ TRACE + false diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/AssemblyInfo.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/AssemblyInfo.cs similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/AssemblyInfo.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/AssemblyInfo.cs diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Resources.Designer.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Resources.Designer.cs similarity index 88% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Resources.Designer.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Resources.Designer.cs index 4992257893e49..d6c1fa4cabc8f 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Resources.Designer.cs +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Resources.Designer.cs @@ -1,17 +1,17 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1378 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace SelectionPatternTarget.Properties { +namespace InvokePatternApp.Properties { using System; - - + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,19 +19,19 @@ namespace SelectionPatternTarget.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { - + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// @@ -39,13 +39,13 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SelectionPatternTarget.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("InvokePatternApp.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Resources.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Resources.cs similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Resources.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Resources.cs diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Resources.resx b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Resources.resx similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Resources.resx rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Resources.resx diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Settings.Designer.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Settings.Designer.cs similarity index 91% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Settings.Designer.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Settings.Designer.cs index 452a1b685fa84..d8911b38650ed 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Settings.Designer.cs +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -9,14 +9,14 @@ //------------------------------------------------------------------------------ namespace InvokePatternApp.Properties { - - + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - + public static Settings Default { get { return defaultInstance; diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Settings.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Settings.cs similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Settings.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Settings.cs diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Settings.settings b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Settings.settings similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Properties/Settings.settings rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/Properties/Settings.settings diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/security.xml b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/security.xml similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/security.xml rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/InvokePatternApp/security.xml diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/App.xaml b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/App.xaml similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/App.xaml rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/App.xaml diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/App.xaml.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/App.xaml.cs similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/App.xaml.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/App.xaml.cs diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/Target.csproj similarity index 87% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target.csproj rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/Target.csproj index 5775fefbfa3e1..3d543e7fb9c11 100644 --- a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target.csproj +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/Target.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -11,9 +11,10 @@ 10.0.20821 2.0 - v4.0 + v4.8 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Client + + true @@ -21,12 +22,14 @@ false .\bin\Debug\ DEBUG;TRACE + false false true .\bin\Release\ TRACE + false @@ -63,5 +66,8 @@ Window1.xaml + + + \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Window1.xaml b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/Window1.xaml similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Window1.xaml rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/Window1.xaml diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Window1.xaml.cs b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/Window1.xaml.cs similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Window1.xaml.cs rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/Window1.xaml.cs diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/app.config b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/app.config new file mode 100644 index 0000000000000..3e0e37cfc8c7a --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/app.config @@ -0,0 +1,3 @@ + + + diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/data/cat.png b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/data/cat.png similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/data/cat.png rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/data/cat.png diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/data/dog.png b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/data/dog.png similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/data/dog.png rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/data/dog.png diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/data/fish.png b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/data/fish.png similarity index 100% rename from samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/data/fish.png rename to samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/Target/data/fish.png diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/snippets.5000.json b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/snippets.5000.json new file mode 100644 index 0000000000000..da9ebf8da2f9d --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_Wpf/InvokePatternApp/CSharp/snippets.5000.json @@ -0,0 +1,3 @@ +{ + "host": "visualstudio" +} diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInSideAdapters/AddInSideAdapters.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInSideAdapters/AddInSideAdapters.csproj deleted file mode 100644 index 8bfb0da421d5e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInSideAdapters/AddInSideAdapters.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Library - net48 - true - - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInSideAdapters/WPFAddIn_ViewToContractAddInSideAdapter.cs b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInSideAdapters/WPFAddIn_ViewToContractAddInSideAdapter.cs deleted file mode 100644 index 19dc89e196748..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInSideAdapters/WPFAddIn_ViewToContractAddInSideAdapter.cs +++ /dev/null @@ -1,64 +0,0 @@ -// -using System; -using System.AddIn.Contract; -using System.AddIn.Pipeline; -using System.Security.Permissions; - -using AddInViews; -using Contracts; - -namespace AddInSideAdapters -{ - /// - /// Adapts the add-in's view of the contract to the add-in contract - /// - [AddInAdapter] - public class WPFAddIn_ViewToContractAddInSideAdapter : ContractBase, IWPFAddInContract - { - WPFAddInView wpfAddInView; - - public WPFAddIn_ViewToContractAddInSideAdapter(WPFAddInView wpfAddInView) - { - // Adapt the add-in view of the contract (WPFAddInView) - // to the contract (IWPFAddInContract) - this.wpfAddInView = wpfAddInView; - } - - /// - /// ContractBase.QueryContract must be overridden to: - /// * Safely return a window handle for an add-in UI to the host - /// application's application. - /// * Enable tabbing between host application UI and add-in UI, in the - /// "add-in is a UI" scenario. - /// - public override IContract QueryContract(string contractIdentifier) - { - if (contractIdentifier.Equals(typeof(INativeHandleContract).AssemblyQualifiedName)) - { - return FrameworkElementAdapters.ViewToContractAdapter(this.wpfAddInView); - } - - return base.QueryContract(contractIdentifier); - } - - /// - /// GetHandle is called by the WPF add-in model from the host application's - /// application domain to get the window handle for an add-in UI from the - /// add-in's application domain. GetHandle is called if a window handle isn't - /// returned by other means ie overriding ContractBase.QueryContract, - /// as shown above. - /// NOTE: This method requires UnmanagedCodePermission to be called - /// (full-trust by default), to prevent illegal window handle - /// access in partially trusted scenarios. If the add-in could - /// run in a partially trusted application domain - /// (eg AddInSecurityLevel.Internet), you can safely return a window - /// handle by overriding ContractBase.QueryContract, as shown above. - /// - [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] - public IntPtr GetHandle() - { - return FrameworkElementAdapters.ViewToContractAdapter(this.wpfAddInView).GetHandle(); - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInViews/AddInViews.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInViews/AddInViews.csproj deleted file mode 100644 index 3ab9889835834..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInViews/AddInViews.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - Library - net48 - true - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInViews/WPFAddInView.cs b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInViews/WPFAddInView.cs deleted file mode 100644 index 7648cc102aa5d..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/AddInViews/WPFAddInView.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -using System.AddIn.Pipeline; -using System.Windows.Controls; - -namespace AddInViews -{ - /// - /// Defines the add-in's view of the contract. - /// - [AddInBase] - public class WPFAddInView : UserControl { } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Contracts/Contracts.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Contracts/Contracts.csproj deleted file mode 100644 index 429ddc41f5f79..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Contracts/Contracts.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - Library - net48 - true - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Contracts/IWPFAddInContract.cs b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Contracts/IWPFAddInContract.cs deleted file mode 100644 index af7dbfd8fc814..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Contracts/IWPFAddInContract.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -using System.AddIn.Contract; -using System.AddIn.Pipeline; - -namespace Contracts -{ - /// - /// Defines the services that an add-in will provide to a host application. - /// In this case, the add-in is a UI. - /// - [AddInContract] - public interface IWPFAddInContract : INativeHandleContract {} -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/App.cs b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/App.cs deleted file mode 100644 index 583a1d78be007..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/App.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Windows; - -namespace Host -{ - /// - /// A custom entry point method, Main(), is required to use LoaderOptimizationAttribute, - /// which ensures that WPF assemblies are shared between the main application's appdomain - /// and the subsequent appdomains that are created to host isolated add-ins. Using - /// LoaderOptimizationAttribute dramatically improves performance; otherwise, each - /// add-in needs to load a complete set of WPF assemblies. - /// - public class App : Application - { - [STAThread] - [LoaderOptimization(LoaderOptimization.MultiDomainHost)] - public static void Main() - { - App app = new App(); - app.Run(); - } - - protected override void OnStartup(StartupEventArgs e) - { - base.OnStartup(e); - - // Show main application window - MainWindow mainWindow = new MainWindow(); - mainWindow.Show(); - } - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/Host.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/Host.csproj deleted file mode 100644 index 5a5400a886140..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/Host.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - WinExe - net48 - true - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/MainWindow.xaml b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/MainWindow.xaml deleted file mode 100644 index e81dace736ff3..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/MainWindow.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/MainWindow.xaml.cs b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/MainWindow.xaml.cs deleted file mode 100644 index e631681595ca6..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/Host/MainWindow.xaml.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.AddIn.Hosting; -using System.Windows; - -using HostViews; - -namespace Host -{ - public partial class MainWindow : Window - { - WPFAddInHostView wpfAddInHostView; - - public MainWindow() - { - InitializeComponent(); - } - - void fileExitMenuItem_Click(object sender, RoutedEventArgs e) - { - this.Close(); - } - - void loadAddInUIMenuItem_Click(object sender, RoutedEventArgs e) - { -// -// Get add-in pipeline folder (the folder in which this application was launched from) -string appPath = Environment.CurrentDirectory; - -// Rebuild visual add-in pipeline -string[] warnings = AddInStore.Rebuild(appPath); -if (warnings.Length > 0) -{ - string msg = "Could not rebuild pipeline:"; - foreach (string warning in warnings) msg += "\n" + warning; - MessageBox.Show(msg); - return; -} - -// Activate add-in with Internet zone security isolation -Collection addInTokens = AddInStore.FindAddIns(typeof(WPFAddInHostView), appPath); -AddInToken wpfAddInToken = addInTokens[0]; -this.wpfAddInHostView = wpfAddInToken.Activate(AddInSecurityLevel.Internet); - -// Display add-in UI -this.addInUIHostGrid.Children.Add(this.wpfAddInHostView); -// - } - - void unloadAddInUIMenuItem_Click(object sender, RoutedEventArgs e) - { - // Stop displyaing add-in UI - this.addInUIHostGrid.Children.Clear(); - - // Unload add-in - AddInController addInController = AddInController.GetAddInController(this.wpfAddInHostView); - addInController.Shutdown(); - } - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostSideAdapters/HostSideAdapters.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostSideAdapters/HostSideAdapters.csproj deleted file mode 100644 index f1b6769567bc8..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostSideAdapters/HostSideAdapters.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Library - net48 - true - - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostSideAdapters/WPFAddIn_ContractToViewHostSideAdapter.cs b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostSideAdapters/WPFAddIn_ContractToViewHostSideAdapter.cs deleted file mode 100644 index 2855409d3f080..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostSideAdapters/WPFAddIn_ContractToViewHostSideAdapter.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System.AddIn.Contract; -using System.AddIn.Pipeline; -using System.Windows; - -using Contracts; -using HostViews; - -namespace HostSideAdapters -{ - /// - /// Adapts the add-in contract to the host's view of the add-in - /// - [HostAdapter] - public class WPFAddIn_ContractToViewHostSideAdapter : WPFAddInHostView - { - IWPFAddInContract wpfAddInContract; - ContractHandle wpfAddInContractHandle; - - public WPFAddIn_ContractToViewHostSideAdapter(IWPFAddInContract wpfAddInContract) - { - // Adapt the contract (IWPFAddInContract) to the host application's - // view of the contract (WPFAddInHostView) - this.wpfAddInContract = wpfAddInContract; - - // Prevent the reference to the contract from being released while the - // host application uses the add-in - this.wpfAddInContractHandle = new ContractHandle(wpfAddInContract); - - // Convert the INativeHandleContract for the add-in UI that was passed - // from the add-in side of the isolation boundary to a FrameworkElement - string aqn = typeof(INativeHandleContract).AssemblyQualifiedName; - INativeHandleContract inhc = (INativeHandleContract)wpfAddInContract.QueryContract(aqn); - FrameworkElement fe = (FrameworkElement)FrameworkElementAdapters.ContractToViewAdapter(inhc); - - // Add FrameworkElement (which displays the UI provided by the add-in) as - // content of the view (a UserControl) - this.Content = fe; - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostViews/HostViews.csproj b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostViews/HostViews.csproj deleted file mode 100644 index 60fc990b69b32..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostViews/HostViews.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - Library - net48 - true - - - diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostViews/WPFAddInHostView.cs b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostViews/WPFAddInHostView.cs deleted file mode 100644 index 61d82847c7867..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/HostViews/WPFAddInHostView.cs +++ /dev/null @@ -1,11 +0,0 @@ -// -using System.Windows.Controls; - -namespace HostViews -{ - /// - /// Defines the host's view of the add-in - /// - public class WPFAddInHostView : UserControl { } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/SimpleAddInIsAUISample.sln b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/SimpleAddInIsAUISample.sln deleted file mode 100644 index 8513da795fdc7..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/SimpleAddInIsAUISample.sln +++ /dev/null @@ -1,56 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 10 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Host", "Host\Host.csproj", "{6624317E-A5FA-47AB-A634-5EC4E5F10E69}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HostViews", "HostViews\HostViews.csproj", "{F76C568A-2D37-47B2-AAC0-A384D72F7E78}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{E808F287-31D1-4F2B-8EA9-3F027BF8C51B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInViews", "AddInViews\AddInViews.csproj", "{75CCA4C0-CDCC-4779-9617-3817BE939F60}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInSideAdapters", "AddInSideAdapters\AddInSideAdapters.csproj", "{D6B2D9E4-FFA9-4D82-B973-BB6792FDDDBB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HostSideAdapters", "HostSideAdapters\HostSideAdapters.csproj", "{04C538AD-419B-4733-8F53-6DB2C4D3E010}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFAddIn1", "WPFAddIn1\WPFAddIn1.csproj", "{68E9A1C9-DDA7-4079-9EBB-F14FE03446B4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6624317E-A5FA-47AB-A634-5EC4E5F10E69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6624317E-A5FA-47AB-A634-5EC4E5F10E69}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6624317E-A5FA-47AB-A634-5EC4E5F10E69}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6624317E-A5FA-47AB-A634-5EC4E5F10E69}.Release|Any CPU.Build.0 = Release|Any CPU - {F76C568A-2D37-47B2-AAC0-A384D72F7E78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F76C568A-2D37-47B2-AAC0-A384D72F7E78}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F76C568A-2D37-47B2-AAC0-A384D72F7E78}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F76C568A-2D37-47B2-AAC0-A384D72F7E78}.Release|Any CPU.Build.0 = Release|Any CPU - {E808F287-31D1-4F2B-8EA9-3F027BF8C51B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E808F287-31D1-4F2B-8EA9-3F027BF8C51B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E808F287-31D1-4F2B-8EA9-3F027BF8C51B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E808F287-31D1-4F2B-8EA9-3F027BF8C51B}.Release|Any CPU.Build.0 = Release|Any CPU - {75CCA4C0-CDCC-4779-9617-3817BE939F60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75CCA4C0-CDCC-4779-9617-3817BE939F60}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75CCA4C0-CDCC-4779-9617-3817BE939F60}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75CCA4C0-CDCC-4779-9617-3817BE939F60}.Release|Any CPU.Build.0 = Release|Any CPU - {D6B2D9E4-FFA9-4D82-B973-BB6792FDDDBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D6B2D9E4-FFA9-4D82-B973-BB6792FDDDBB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D6B2D9E4-FFA9-4D82-B973-BB6792FDDDBB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D6B2D9E4-FFA9-4D82-B973-BB6792FDDDBB}.Release|Any CPU.Build.0 = Release|Any CPU - {04C538AD-419B-4733-8F53-6DB2C4D3E010}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {04C538AD-419B-4733-8F53-6DB2C4D3E010}.Debug|Any CPU.Build.0 = Debug|Any CPU - {04C538AD-419B-4733-8F53-6DB2C4D3E010}.Release|Any CPU.ActiveCfg = Release|Any CPU - {04C538AD-419B-4733-8F53-6DB2C4D3E010}.Release|Any CPU.Build.0 = Release|Any CPU - {68E9A1C9-DDA7-4079-9EBB-F14FE03446B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {68E9A1C9-DDA7-4079-9EBB-F14FE03446B4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {68E9A1C9-DDA7-4079-9EBB-F14FE03446B4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {68E9A1C9-DDA7-4079-9EBB-F14FE03446B4}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/WPFAddIn1/AddInUI.xaml b/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/WPFAddIn1/AddInUI.xaml deleted file mode 100644 index a2c39011626a2..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInIsAUISample/CSharp/WPFAddIn1/AddInUI.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - -